gccjit-ravi534
Dibyendu Majumdar 8 years ago
parent 1282ea7e5a
commit 0c73c2bab5

@ -78,6 +78,7 @@ if (MSVC)
add_definitions("/wd4996")
add_definitions("/wd4291")
add_definitions("/wd4624")
add_definitions("/wd4141")
add_definitions("/DLUA_COMPAT_5_2")
endif ()

@ -317,9 +317,10 @@ Build Dependencies - LLVM version
---------------------------------
* CMake
* LLVM 3.7
* LLVM 3.7 or 3.8 or 3.9
The build is CMake based.
Unless otherwise noted the instructions below should work for LLVM 3.7 or above.
Building LLVM on Windows
------------------------
@ -354,6 +355,8 @@ Building Ravi
-------------
I am developing Ravi using Visual Studio 2015 Community Edition on Windows 8.1 64bit, gcc on Unbuntu 64-bit, and clang/Xcode on MAC OS X.
.. note:: Location of cmake files has moved in LLVM 3.9; the new path is ``$LLVM_INSTALL_DIR/lib/cmake/llvm``.
Assuming that LLVM has been installed as described above, then on Windows I invoke the cmake config as follows::
cd build
@ -406,9 +409,6 @@ Work Plan
* 2016 priorties
* `IDE support (Visual Studio Code) <https://github.com/dibyendumajumdar/ravi/tree/master/vscode-debugger>`_
* BLAS and LAPACK
* GNU Scientific library
* symengine
License
-------

@ -317,9 +317,10 @@ Build Dependencies - LLVM version
---------------------------------
* CMake
* LLVM 3.7
* LLVM 3.7 or 3.8 or 3.9
The build is CMake based.
Unless otherwise noted the instructions below should work for LLVM 3.7 or above.
Building LLVM on Windows
------------------------
@ -354,6 +355,8 @@ Building Ravi
-------------
I am developing Ravi using Visual Studio 2015 Community Edition on Windows 8.1 64bit, gcc on Unbuntu 64-bit, and clang/Xcode on MAC OS X.
.. note:: Location of cmake files has moved in LLVM 3.9; the new path is ``$LLVM_INSTALL_DIR/lib/cmake/llvm``.
Assuming that LLVM has been installed as described above, then on Windows I invoke the cmake config as follows::
cd build
@ -406,9 +409,6 @@ Work Plan
* 2016 priorties
* `IDE support (Visual Studio Code) <https://github.com/dibyendumajumdar/ravi/tree/master/vscode-debugger>`_
* BLAS and LAPACK
* GNU Scientific library
* symengine
License
-------

@ -32,15 +32,15 @@ typedef struct RaviGCObject {
typedef int (*myfunc_t)(RaviGCObject *);
int test1() {
// Get global context - not sure what the impact is of sharing
// the global context
llvm::LLVMContext &context = llvm::getGlobalContext();
// FIXME context should be deleted at the end but here we
// don't bother
llvm::LLVMContext *context = new llvm::LLVMContext();
// Module is the translation unit
std::unique_ptr<llvm::Module> theModule =
std::unique_ptr<llvm::Module>(new llvm::Module("ravi", context));
std::unique_ptr<llvm::Module>(new llvm::Module("ravi", *context));
llvm::Module *module = theModule.get();
llvm::IRBuilder<> builder(context);
llvm::IRBuilder<> builder(*context);
#if defined(_WIN32) && (!defined(_WIN64) || LLVM_VERSION_MINOR < 7)
// On Windows we get error saying incompatible object format
@ -54,19 +54,19 @@ int test1() {
// create a GCObject structure as defined in lobject.h
llvm::StructType *structType =
llvm::StructType::create(context, "RaviGCObject");
llvm::StructType::create(*context, "RaviGCObject");
llvm::PointerType *pstructType =
llvm::PointerType::get(structType, 0); // pointer to RaviGCObject
std::vector<llvm::Type *> elements;
elements.push_back(pstructType);
elements.push_back(llvm::Type::getInt8Ty(context));
elements.push_back(llvm::Type::getInt8Ty(context));
elements.push_back(llvm::Type::getInt8Ty(*context));
elements.push_back(llvm::Type::getInt8Ty(*context));
structType->setBody(elements);
structType->dump();
// Create printf declaration
std::vector<llvm::Type *> args;
args.push_back(llvm::Type::getInt8PtrTy(context));
args.push_back(llvm::Type::getInt8PtrTy(*context));
// accepts a char*, is vararg, and returns int
llvm::FunctionType *printfType =
llvm::FunctionType::get(builder.getInt32Ty(), args, true);
@ -81,7 +81,7 @@ int test1() {
llvm::Function *mainFunc = llvm::Function::Create(
funcType, llvm::Function::ExternalLinkage, "testfunc", module);
llvm::BasicBlock *entry =
llvm::BasicBlock::Create(context, "entrypoint", mainFunc);
llvm::BasicBlock::Create(*context, "entrypoint", mainFunc);
builder.SetInsertPoint(entry);
// printf format string
@ -98,10 +98,10 @@ int test1() {
llvm::APInt one(32, 1);
// This is the array offset into RaviGCObject*
values.push_back(
llvm::Constant::getIntegerValue(llvm::Type::getInt32Ty(context), zero));
llvm::Constant::getIntegerValue(llvm::Type::getInt32Ty(*context), zero));
// This is the field offset
values.push_back(
llvm::Constant::getIntegerValue(llvm::Type::getInt32Ty(context), one));
llvm::Constant::getIntegerValue(llvm::Type::getInt32Ty(*context), one));
// Create the GEP value
llvm::Value *arg1_a = builder.CreateGEP(arg1, values, "ptr");
@ -110,7 +110,7 @@ int test1() {
llvm::Value *tmp1 = builder.CreateLoad(arg1_a, "a");
// As the retrieved value is a byte - convert to int i
llvm::Value *tmp2 =
builder.CreateZExt(tmp1, llvm::Type::getInt32Ty(context), "i");
builder.CreateZExt(tmp1, llvm::Type::getInt32Ty(*context), "i");
// Call the printf function
values.clear();

Loading…
Cancel
Save