search for: getglobalcontext

Displaying 20 results from an estimated 192 matches for "getglobalcontext".

2010 Jan 04
4
[LLVMdev] Getting Kaleidoscope to compile
...ocs/tutorial/LangImpl3.html#code and trying to compile it with the provided instructions gives me the following errors: a at a-desktop:~$ g++ -g -O3 toy.cpp `llvm-config --cppflags --ldflags --libs core` -o toy toy.cpp:5:30: error: llvm/LLVMContext.h: No such file or directory toy.cpp:352: error: ‘getGlobalContext’ was not declared in this scope toy.cpp: In member function ‘virtual llvm::Value* NumberExprAST::Codegen()’: toy.cpp:358: error: ‘getGlobalContext’ was not declared in this scope toy.cpp: In member function ‘virtual llvm::Value* BinaryExprAST::Codegen()’: toy.cpp:379: error: ‘getDoubleTy’ is not a...
2010 May 11
2
[LLVMdev] How to create Global Variables using LLVM API?
...PI. and I am experimenting with it. I want to create Global Variables in a module. I am able to create local variables using IRBuilder class. I tried using GlobalVariable class to create global variables. but it doesn't work. my code looks like this: Module* mod = new Module("test", getGlobalContext()); Constant* c = mod->getOrInsertFunction("main", IntegerType::get(getGlobalContext(), 32), NULL); Function* main = cast<Function> (c); main->setCallingConv(CallingConv::C); Twine s("foo"); StringRef s1("foo"); Constant *cons = ConstantArray::get(getGlobal...
2012 Jul 02
1
[LLVMdev] Intrinsic::getDeclaration causing dump() segfault
...is is with llvm 3.0. I'm only dipping my toes into the waters of llvm for the first time, and have no idea what I am doing incorrectly. In actual code, I would be wanting to call the memcpy intrinsic eventually, of course. int main(void) { Module *module = new Module("testmod", getGlobalContext()); FunctionType *ft = FunctionType::get( Type::getInt1Ty(getGlobalContext()), false); Function *func = Function::Create(ft, Function::ExternalLinkage, "", module); BasicBlock *bb = BasicBlock::Create(getGlobalContext(), "entr...
2010 Jan 04
0
[LLVMdev] Getting Kaleidoscope to compile
...nd trying to > compile it with the provided instructions gives me the following > errors: > > a at a-desktop:~$ g++ -g -O3 toy.cpp `llvm-config --cppflags --ldflags > --libs core` -o toy > toy.cpp:5:30: error: llvm/LLVMContext.h: No such file or directory > toy.cpp:352: error: ‘getGlobalContext’ was not declared in this scope > toy.cpp: In member function ‘virtual llvm::Value* > NumberExprAST::Codegen()’: > toy.cpp:358: error: ‘getGlobalContext’ was not declared in this scope > toy.cpp: In member function ‘virtual llvm::Value* > BinaryExprAST::Codegen()’: > toy.cpp:379:...
2013 Nov 26
0
[LLVMdev] Help needed with a pass
...m.h"#include "llvm/IR/Module.h"#include "llvm/PassManager.h"#include "llvm/Analysis/Verifier.h"#include "llvm/Assembly/PrintModulePass.h"#include "llvm/IR/IRBuilder.h" using namespace llvm; Module* makeLLVMModule() { Module* mod = new Module(getGlobalContext()); Function* strncpy_func = cast<Function>(mod->getOrInsertFunction(new StringRef("strncpy"), Type::getInt32Ty(getGlobalContext()), Type::getInt32Ty(getGlobalContext()), Type::getInt32Ty(getGlobalContext()), NULL)); Function* printf_func = cast<Function>(mod-&g...
2012 Sep 05
1
[LLVMdev] Calling a function with a pointer to a global char array as argument
...ucntion. Now I am trying to declare a global char array with the content "hi" and call a function "print" (which takes a char pointer and return an insteger. I am doing the following in the code - Function Creation: PointerType* array = PointerType::get(IntegerType::getInt8Ty(getGlobalContext()) /*CI->getPointerOperand()->getType()*/, 0); printFunc = M.getOrInsertFunction("print", IntegerType::getInt32Ty(getGlobalContext()), array, NULL); Global Declaration: Constant *fname = ConstantDataArray::getString(getGlobalContext(),"hi", true);...
2012 May 27
0
[LLVMdev] Help with Values sign
I show you the trace of calls to llvm that my compiler makes to generate the code above. bloques.back().last is of type Value* and bloques.back().bl is BasicBlock* (the current Block) bloques.back().last = dyn_cast<Value>(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), $1, true)); // $1 is an int AllocaInst *alloc = new AllocaInst( Type::getInt32Ty(getGlobalContext()), izq.c_str(), bloques.back().bl); Value *derecha = bloques.back().last; StoreInst *s = new StoreInst(derecha, alloc, false, bloques.back().bl);...
2013 May 21
1
[LLVMdev] Is it valid to add parameters to a function once it is created
I create a function with an empty signature: void llvm_start_new_function() { llvm::outs() << "Staring new LLVM function ...\n"; Mod = new llvm::Module("module", llvm::getGlobalContext()); builder = new llvm::IRBuilder<>(llvm::getGlobalContext()); llvm::FunctionType *funcType = llvm::FunctionType::get(builder->getVoidTy(), false); mainFunc = llvm::Function::Create(funcType, llvm::Function::ExternalLinkage, "main", Mod); llvm::BasicBlock*...
2010 May 11
0
[LLVMdev] How to create Global Variables using LLVM API?
...ith it. > I want to create Global Variables in a module. > I am able to create local variables using IRBuilder class. I tried using > GlobalVariable class to create global variables. > but it doesn't work. my code looks like this: > > Module* mod = new Module("test", getGlobalContext()); > Constant* c = mod->getOrInsertFunction("main", > IntegerType::get(getGlobalContext(), 32), NULL); > Function* main = cast<Function> (c); > main->setCallingConv(CallingConv::C); > Twine s("foo"); > StringRef s1("foo"); > Constant...
2012 May 27
2
[LLVMdev] Help with Values sign
Hi everyone, I'm having some problems when loading values. Here's a simple example of the IR that my compiler generates to show the problem: define i32 @main() { entry: %a = alloca i32 ; <i32*> [#uses=2] store i32 1, i32* %a %r = load i32* %a ; <i32> [#uses=1] br label %Return Return:
2009 Aug 23
1
[LLVMdev] Having JIT resolve extern "C" functions declared in executible
...on doesn't > take parameters. Maybe using an irbuilder would help? It does take one parameter. Here's the important bits: // My Function extern "C" void print(double X) { printf("%f\n", X); } // Args type std::vector<const Type*> args(1, Type::getDoubleTy(getGlobalContext())); // return void, 1 arg double, no varargs FT = FunctionType::get(Type::getVoidTy(getGlobalContext()), args, false); // creating stub for print function Function* printFunction = Function::Create(FT, Function::ExternalLinkage, "print", module); By doing this (and the variable declarat...
2010 Jun 21
0
[LLVMdev] getGlobalContext()
...l places that explicitly refer to the global context (like in Module.cpp). I wonder wether this is indended or has yet to be fixed ? Thanks Junjie -------- Module.cpp GlobalVariable *ilist_traits<GlobalVariable>::createSentinel() { GlobalVariable *Ret = new GlobalVariable(Type::getInt32Ty(getGlobalContext()), false, GlobalValue::ExternalLinkage); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); return Ret; } GlobalAlias *ilist_traits<GlobalAlias>::createSentinel() { GlobalAlias *Ret = new GlobalAlias(Type::getIn...
2017 Feb 21
3
What is the proper usage of LLVMContext?
Hi, I'm Ryo Ota. I have two questions about `llvm::LLVMContext`. Q1) What is the difference between the following (A)`my_context` and (B)`global_context`? Do I have to create a LLVMContext by myself? Or use `getGlobalContext()`? Could you tell me what situation needs a LLVMContext which is created by myself such as (A)? (A) { llvm::LLVMContext my_context; // codes using only my_context (get Int32ty() or StructType::create or etc...) } (B) { llvm::LLVMContext &globa_context = llvm::getGlobalContext(); // codes usi...
2010 Jan 04
2
[LLVMdev] Getting Kaleidoscope to compile
...e it with the provided instructions gives me the following >> errors: >> >> a at a-desktop:~$ g++ -g -O3 toy.cpp `llvm-config --cppflags --ldflags >> --libs core` -o toy >> toy.cpp:5:30: error: llvm/LLVMContext.h: No such file or directory >> toy.cpp:352: error: ‘getGlobalContext’ was not declared in this scope >> toy.cpp: In member function ‘virtual llvm::Value* >> NumberExprAST::Codegen()’: >> toy.cpp:358: error: ‘getGlobalContext’ was not declared in this scope >> toy.cpp: In member function ‘virtual llvm::Value* >> BinaryExprAST::Codegen()’...
2010 Feb 16
3
[LLVMdev] Creating a global variable in JIT context
...create a global variable initialized to zero, and return its value from a newly created function, in JIT context. I'm keeping all types as i32 for the moment, and I only have the one module object. This is the code I have for creating the global variable: const Type *type = Type::getInt32Ty(getGlobalContext()); // Constant *zerov = Constant::getNullValue(type); Constant *zerov = Constant::getIntegerValue(type, APInt(32, 0)); V = new GlobalVariable(getGlobalContext(), type, 0, GlobalValue::PrivateLinkage, zerov, name); And these are the error messages given by verifyFunction: Function return type d...
2010 Apr 28
1
[LLVMdev] LLVM Tutorial 1: Something got wrong?
...or call to ‘llvm::IntegerType::get(int)’ /usr/local/include/llvm/DerivedTypes.h:108: note: candidates are: static const llvm::IntegerType* llvm::IntegerType::get(llvm::LLVMContext&, unsigned int) Module* makeLLVMModule() { // Module Construction Module* mod = new Module("test", getGlobalContext()); Constant* c = mod->getOrInsertFunction("mul_add", /*ret type*/ IntegerType::get(32), /*args*/ IntegerType::get(32), IntegerType::get(32),...
2013 Jul 25
2
[LLVMdev] Error for AllocaInst and Instruction
Hi, For the following code const Type * Int32Type = IntegerType::getInt32Ty(getGlobalContext()); AllocaInst* newInst = new AllocaInst(Int32Type, 0, "flag", Bb); Bb->getInstList().push_back(newInst); It gives me the error " error: no matching constructor for initialization of 'llvm::AllocaInst' AllocaInst* newInst = new AllocaInst(Int3...
2009 Oct 06
0
[LLVMdev] 2.6/trunk Execution Engine question
.../TargetSelect.h" #include "llvm/ExecutionEngine/JIT.h" #include <assert.h> using namespace llvm; static raw_stdout_ostream raw_cout; int main(int argc, char** argv) { // Test JITting a variable without JITting any functions.' Module* mod = new Module("test", getGlobalContext()); GlobalVariable* gv = cast<GlobalVariable>(mod->getOrInsertGlobal("TestGV", Type::getInt32Ty(getGlobalContext()))); gv->setInitializer(ConstantInt::get( Type::getInt32Ty(getGlobalContext()), 24601)); ModuleProvider* modp = new ExistingModuleProvider(mod); Initiali...
2009 Oct 06
1
[LLVMdev] 2.6/trunk Execution Engine question
On Tue, Oct 6, 2009 at 5:49 PM, Reid Kleckner <rnk at mit.edu> wrote: >> Also, the null pointer is coming from a call to JCE->allocateSpace(). >> This is a virtual function; I'm trying to discover what subclass it >> is. > > So, there's JITEmitter::allocateSpace which overrides > JITCodeEmitter::allocateSpace(), but *most* of the time it just calls >
2010 Aug 19
1
[LLVMdev] Function Arguments
...te the character string with a pointer that I can pass to the function, just like I've shown here for the integer. The following is the code I'm working with so far: // Declare the function as external vector<const Type*> runTimeFuncArgs; runTimeFuncArgs.push_back(Type::getInt32Ty(getGlobalContext())); // int type, first arg runTimeFuncArgs.push_back(ArrayType::get(Type::getInt8Ty(getGlobalContext()), str.length() + 1)); // 2nd arg as an array FunctionType *runTimeFuncType = FunctionType::get(Type::getInt32Ty(getGlobalContext()), runTimeFuncArgs, false); Function *runTimeFunc = Function...