Skip to content

Commit

Permalink
issue #102
Browse files Browse the repository at this point in the history
  • Loading branch information
Dibyendu Majumdar committed Sep 13, 2016
1 parent 1282ea7 commit 0c73c2b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()

Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
-------
Expand Down
8 changes: 4 additions & 4 deletions readthedocs/ravi-overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
-------
Expand Down
26 changes: 13 additions & 13 deletions tests/test_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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");
Expand All @@ -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();
Expand Down

0 comments on commit 0c73c2b

Please sign in to comment.