search for: getcast

Displaying 15 results from an estimated 15 matches for "getcast".

2009 Jan 19
1
[LLVMdev] Load from abs address generated bad code on LLVM 2.4
...Functions. IIRC, the stuff I used was something like... GlobalVariable *gv = new GlobalVariable( /* your pointer type */, other required parameters...); AddGlobalMapping(gv, your_pointer_value); // i.e. (void*)0x938742 then, where you use Constant* thp = ConstantExpr::getCast(Instruction::IntToPtr, your_pointer_value, /* i.e. 0x938742 */ /* your pointer type */); /* Now use thp */ change it to /* Now just use gv */ GetGlobalValueAtAddress may be useful for housekeeping. If something is wrong or not as effcient as it could be, I hope someone on the mailing list...
2009 Jan 21
0
[LLVMdev] Load from abs address generated bad code on LLVM 2.4
...omething like... > > GlobalVariable *gv = new GlobalVariable( /* your pointer type */, > other required parameters...); > AddGlobalMapping(gv, your_pointer_value); // i.e. (void*)0x938742 > > then, where you use > > Constant* thp = ConstantExpr::getCast(Instruction::IntToPtr, > your_pointer_value, /* i.e. 0x938742 */ > /* your pointer type */); > > /* Now use thp */ > > change it to > > /* Now just use gv */ > > GetGlobalValueAtAddress may be useful for housekeeping. How does one use GetGlobalValueAtAddress?...
2005 Nov 02
0
[LLVMdev] Statically Initialized Arrays
...erence to the array, use the global created by #1. 3. When you have the final array, create a *new* global with the correct size and the initializer formed from the vector. 4. Replace the old GV with the new GV using code that looks like this: OldGV->replaceAllUsesWith(ConstantExpr::getCast(NewGV, OldGV->getType()); OldGV->eraseFromParent(); At the end of this, any instructions or other globals that referenced the temporary global will now reference the new one. > int array[size] = { ... }; > > int* globalArray( int index ) > { > return &array[index];...
2005 Nov 02
2
[LLVMdev] Statically Initialized Arrays
I am trying to generate LLVM code that references a global array. Unfortunately, while I am generating the code I do not know the final length of the array, as I add elements to it as my compiler goes along. What is the best way to do this in LLVM? Ideally, I would be able to define the GlobalVariable array and change its length later on. I would love for it to have the correct length so I
2009 Jan 19
6
[LLVMdev] Load from abs address generated bad code on LLVM 2.4
This is x86_64. I have a problem where an absolute memory load define i32 @foo() { entry: %0 = load i32* inttoptr (i64 12704196 to i32*) ; <i32> [#uses=1] ret i32 %0 } generates incorrect code on LLVM 2.4: 0x7ffff6d54010: mov 0xc1d9c4(%rip),%eax # 0x7ffff79719da 0x7ffff6d54016: retq should be 0x7ffff6d54010: mov 0xc1d9c4, %eax 0x7ffff6d54016: retq
2012 Jun 17
3
[LLVMdev] BlockAddress instruction is copied instead of cloned during module link?
...elems.push_back(const_ptr_6); Constant* const_ptr_7 = BlockAddress::get(label_switch_body_begin1); const_array_5_elems.push_back(const_ptr_7); ConstantInt* const_int32_9 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10)); Constant* const_ptr_8 = ConstantExpr::getCast(Instruction::IntToPtr, const_int32_9, PointerTy_1); const_array_5_elems.push_back(const_ptr_8); Constant* const_array_5 = ConstantArray::get(ArrayTy_0, const_array_5_elems); ConstantInt* const_int32_10 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("0"), 10)); Con...
2005 Nov 02
1
[LLVMdev] Statically Initialized Arrays
On Nov 2, 2005, at 16:39, Chris Lattner wrote: > 4. Replace the old GV with the new GV using code that looks like this: > > OldGV->replaceAllUsesWith(ConstantExpr::getCast(NewGV, > OldGV->getType()); > OldGV->eraseFromParent(); > > At the end of this, any instructions or other globals that referenced > the temporary global will now reference the new one. Ah ha! I was looking for something like this. Why didn't I see that there? I must...
2013 Sep 28
1
[LLVMdev] use function address as global variable initializer
Hi I would like to initialize a global variable to the address of a function. Looking at how clang compiles the C code below, i see @main_ptr = global i8* bitcast (i32 ()* @main to i8*), align 8 but how do i generate i8* bitcast (i32 ()* @main to i8*), align 8 in LLVM IR and use it as initializer to a GlobalVariable. I know i will need to use the bitcast instruction. but as far i as i
2003 May 09
3
[LLVMdev] ConstantPointerRef and void*'s to functions
I have a Function* to a function that has a signature like: void foo(double*, double*); I need to write the address of this function into a global variable initializer (really, into the initializer of a particular structure field). The structure field type is void*, and must be. Because of type constraints, doing something like: Function* foo = ...; std::vector<const Type*> fields; ...
2011 Feb 04
3
[LLVMdev] ConstantBuilder proposal
...nstant *C2) { return ConstantExpr::getNUWMul(C1, C2); } static Constant *GetExactSDiv(Constant *C1, Constant *C2) { return ConstantExpr::getExactSDiv(C1, C2); } // @brief Convenience function for getting one of the casting operations // using a CastOps opcode. static Constant *GetCast( unsigned ops, ///< The opcode for the conversion Constant *C, ///< The constant to be converted const Type *Ty ///< The type to which the constant is converted ) { return ConstantExpr::getCast(ops, C, Ty); } // @brief Create a ZExt or BitCast cast constant expres...
2007 Dec 17
0
[LLVMdev] Elsa and LLVM and LLVM submissions
...Instruction::BitCast, V, DestTy, Name); > + } > + > + Value *CreateCast(Instruction::CastOps Op, Value *V, const Type > *DestTy, > + const char *Name = "") { > + if (Constant *VC = dyn_cast<Constant>(V)) > + return ConstantExpr::getCast(Op, VC, DestTy); > + return LLVMBuilder::CreateCast(Op, V, DestTy, Name); > + } > + Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned, > + const char *Name = "") { > + if (Constant *VC = dyn_cast<Constant>(V)) > +...
2010 Feb 07
3
[LLVMdev] Help with Mac OS X 10.6.2 build
..., std::allocator<llvm::Value*> > >, llvm::Twine const&, llvm::Instruction*)in ccHkdHVT.o "llvm::ReturnInst::ReturnInst(llvm::LLVMContext&, llvm::Value*, llvm::Instruction*)", referenced from: FunctionAST::Codegen() in ccHkdHVT.o "llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type const*)", referenced from: BinaryExprAST::Codegen() in ccHkdHVT.o "llvm::Module::dump() const", referenced from: _main in ccHkdHVT.o "llvm::ConstantExpr::getMul(llvm::Constant*, llvm::Constant*)", referenced fro...
2007 Dec 17
2
[LLVMdev] Elsa and LLVM and LLVM submissions
Devang Patel wrote: > On Dec 15, 2007, at 12:15 PM, Richard Pennington wrote: > >> I got the current version of LLVM via svn yesterday and modified my >> code to >> use the LLVMFoldingBuilder. Very nice! >> >> My question is this: I noticed that the folding builder doesn't fold >> some >> operations, e.g. casts. Is there some reason why? If
2010 Feb 07
0
[LLVMdev] Help with Mac OS X 10.6.2 build
...e*> > >, llvm::Twine const&, > llvm::Instruction*)in ccHkdHVT.o > "llvm::ReturnInst::ReturnInst(llvm::LLVMContext&, llvm::Value*, > llvm::Instruction*)", referenced from: > FunctionAST::Codegen() in ccHkdHVT.o > "llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, > llvm::Type const*)", referenced from: > BinaryExprAST::Codegen() in ccHkdHVT.o > "llvm::Module::dump() const", referenced from: > _main in ccHkdHVT.o > "llvm::ConstantExpr::getMul(llvm::Constant*, llvm::Con...
2006 May 09
1
[LLVMdev] Memory leaks in LLVM
...llocator<llvm::Constant*> > >, llvm::Type, llvm::ConstantExpr, false>::getOrCreate(llvm::Type const*, std::pair<unsigned, std::vector<llvm::Constant*, std::allocator<llvm::Constant*> > > const&) ( Constants.cpp:639) ==10132== by 0x8494CA1: llvm::ConstantExpr::getCast(llvm::Constant*, llvm::Type const*) (Constants.cpp:1262) ==10132== by 0x83E23D9: llvm::BytecodeReader::ParseConstantPoolValue(unsigned) (Reader.cpp :1476) ==10132== by 0x83E44E0: llvm::BytecodeReader::ParseConstantPool(std::vector<llvm::BytecodeReader::ValueList*, std::allocator<llvm::B...