search for: elementptr

Displaying 9 results from an estimated 9 matches for "elementptr".

2011 May 18
3
[LLVMdev] access array problem
...tore operations in run-time int *counterArray; //record the load/store addresses //increase the counter if a load/store is performed std::vector<Constant *>index(2); index[0] = Constant::getNullvalue(Type:getInt32Ty(Context)); index[1] = Constant::get(Type::getInt32Ty(Context), 0); Constant *ElementPtr = ConstantExpr::getGetElementPtr(counter, &index[0], index.size()); Value *oldcounter = new LoadInst(ElementPtr, "oldcounter", InsertPos); Value *newcounter = BinaryOperator::Create(Instruction::Add, oldcounter, ConstantInt::get(Type::getInt64Ty(Context), 1), "newcounter", I...
2011 May 18
0
[LLVMdev] access array problem
...erformed > std::vector<Constant *>index(2); > index[0] = Constant::getNullvalue(Type:getInt32Ty(Context)); > index[1] = Constant::get(Type::getInt32Ty(Context), 0); The above two lines both compute the same thing (an i32 constant equal to zero) in two different ways. > Constant *ElementPtr = ConstantExpr::getGetElementPtr(counter, > &index[0], index.size()); > Value *oldcounter = new LoadInst(ElementPtr, "oldcounter", InsertPos); > Value *newcounter = BinaryOperator::Create(Instruction::Add, > oldcounter, ConstantInt::get(Type::getInt64Ty(Context), 1), >...
2011 May 18
2
[LLVMdev] access array problem
...<Constant *>index(2); >> index[0] = Constant::getNullvalue(Type:getInt32Ty(Context)); >> index[1] = Constant::get(Type::getInt32Ty(Context), 0); > The above two lines both compute the same thing (an i32 constant equal to > zero) in two different ways. > >> Constant *ElementPtr = ConstantExpr::getGetElementPtr(counter, >> &index[0], index.size()); >> Value *oldcounter = new LoadInst(ElementPtr, "oldcounter", InsertPos); >> Value *newcounter = BinaryOperator::Create(Instruction::Add, >> oldcounter, ConstantInt::get(Type::getInt64Ty(Con...
2005 Aug 26
3
[LLVMdev] Mapping of class derivated and interfaces
> In any case when you > want to obtain a base pointer to a "derived" object (where derivation > is implemented as you showed - with nesting) it's simply a matter of > using getelementptr to obtain a pointer to the nested base object and > using that. Umm ok, but i've the strange feeling that i'm missing something.. First a simple question: getelementptr with index 0 just give me the same pointer, right? Ok, if it's so the example you gave me worked becouse the firs...
2011 May 18
0
[LLVMdev] access array problem
...ArrayType::get(Type::getInt32Ty(M.getContext()), 3000); > GlobalVariable *Counters = new GlobalVariable(M, ATy, false, > GlobalValue::InternalLinkage, > Constant::getNullValue(ATy), "MemTraceCounters"); OK, so Counters is an array of 3000 32 bit integers. >>> Constant *ElementPtr = ConstantExpr::getGetElementPtr(counter, >>> &index[0], index.size()); What is "counter", the same things as CounterSize? >>> //store the memory address to counterArray[oldcounter] >>> std::vector<Constant*> indexC(2); >>> indexC[0] = C...
2005 Aug 26
0
[LLVMdev] Mapping of class derivated and interfaces
On Fri, 2005-08-26 at 09:24 +0200, Nicola Lugato wrote: > > In any case when you > > want to obtain a base pointer to a "derived" object (where derivation > > is implemented as you showed - with nesting) it's simply a matter of > > using getelementptr to obtain a pointer to the nested base object and > > using that. > > Umm ok, but i've the strange feeling that i'm missing something.. > First a simple question: getelementptr with index 0 just give me the > same pointer, right? > > Ok, if it's so the example...
2011 May 18
2
[LLVMdev] access array problem
...lobalValue::InternalLinkage, Constant::getNullValue(ATy), "MemTraceCounters"); //get the index std::vector<Constant*>IndicesC(2); IndicesC[0] = Constant::getNullValue(Type::getInt32Ty(Context)); IndicesC[1] = ConstantInt::get(Type::getInt32Ty(Context),0); Constant *ElementPtrC = ConstantExpr::getGetElementPtr(CounterSize,&IndicesC[0],IndicesC.size()); Value *OldCounterSize =new LoadInst(ElementPtrC, "OldCounterSize", InsertPos); Value *OldCounterSize =new LoadInst(ElementPtrC, "", InsertPos);...
2005 Aug 26
0
[LLVMdev] Mapping of class derivated and interfaces
...object (whereas in a language like Java where one can only work with pointers to objects it's quite impossible). In any case when you want to obtain a base pointer to a "derived" object (where derivation is implemented as you showed - with nesting) it's simply a matter of using getelementptr to obtain a pointer to the nested base object and using that. One of the easiest ways to explore how this can be done (unless you really want to try to invent it for yourself, which is well worth trying to get a better understanding of OOP implementation and LLVM) is to try some simple C++ snippet...
2005 Aug 25
5
[LLVMdev] Mapping of class derivated and interfaces
Hi! i'm tring to figure out how classes and dependencies can be mapped to llvm. I've read on docs that nesting can be used: class base { int Y; }; class derived : base { short Z; }; becomes: %base = type { int } %derived = type { %base, short } That's ok, but now the question is: how do i encode a function that takes "base" type so that it also takes "derived"