search for: createinttoptr

Displaying 20 results from an estimated 23 matches for "createinttoptr".

2016 Mar 29
2
JIT compiler and calls to existing functions
That seems to work, thanks! The specific code I ended up with to call int64_t print(int64_t) looks like: auto f = builder.CreateIntToPtr( ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), PointerType::getUnqual(FunctionType::get( builder.getInt64Ty(), {builder.getInt64Ty()}, false))); return builder.CreateCall(f, args); On Mon, Mar 28, 2016 at 1:40 PM, Caldarale, Charles R &l...
2016 Mar 28
0
JIT compiler and calls to existing functions
...it seems to me that it should be possible to use a more efficient and > portable solution that takes advantage of the fact that you already have an actual pointer > to cos, even if you haven't linked with debugging symbols. Perhaps not the most elegant, but we simply use the IRBuilder.CreateIntToPtr() method to construct the Callee argument for IRBuilder.CreateCall(). The first argument for CreateIntToPtr() comes from ConstantInt::get(I64, uintptr_t(ptr)), while the second is a function type pointer defined by using PointerType::get() on the result of FunctionType::get() with the appropriate...
2016 Mar 29
0
JIT compiler and calls to existing functions
...alyze IR. I recommend leaving everything symbolic until link time if you can. Philip On 03/28/2016 06:33 PM, Russell Wallace via llvm-dev wrote: > That seems to work, thanks! The specific code I ended up with to call > int64_t print(int64_t) looks like: > > auto f = builder.CreateIntToPtr( > ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), > PointerType::getUnqual(FunctionType::get( > builder.getInt64Ty(), {builder.getInt64Ty()}, false))); > return builder.CreateCall(f, args); > > > On Mon, Mar 28, 2016 at...
2016 Mar 29
2
JIT compiler and calls to existing functions
...ving everything symbolic until link time if you can. > > Philip > > > On 03/28/2016 06:33 PM, Russell Wallace via llvm-dev wrote: > > That seems to work, thanks! The specific code I ended up with to call > int64_t print(int64_t) looks like: > > auto f = builder.CreateIntToPtr( > ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), > PointerType::getUnqual(FunctionType::get( > builder.getInt64Ty(), {builder.getInt64Ty()}, false))); > return builder.CreateCall(f, args); > > > On Mon, Mar 28, 2016 at...
2016 Mar 28
2
JIT compiler and calls to existing functions
In the context of a JIT compiler, what's the recommended way to generate a call to an existing function, that is, not one that you are generating on-the-fly with LLVM, but one that's already linked into your program? For example the cosine function (from the standard math library); the Kaleidoscope tutorial recommends looking it up by name with dlsym("cos"), but it seems to me
2016 Mar 29
0
JIT compiler and calls to existing functions
...f you can. >> >> Philip >> >> >>> On 03/28/2016 06:33 PM, Russell Wallace via llvm-dev wrote: >>> That seems to work, thanks! The specific code I ended up with to call int64_t print(int64_t) looks like: >>> >>> auto f = builder.CreateIntToPtr( >>> ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), >>> PointerType::getUnqual(FunctionType::get( >>> builder.getInt64Ty(), {builder.getInt64Ty()}, false))); >>> return builder.CreateCall(f, args); >&g...
2016 Mar 29
3
JIT compiler and calls to existing functions
...if you can. >> >> Philip >> >> >> On 03/28/2016 06:33 PM, Russell Wallace via llvm-dev wrote: >> >> That seems to work, thanks! The specific code I ended up with to call >> int64_t print(int64_t) looks like: >> >> auto f = builder.CreateIntToPtr( >> ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), >> PointerType::getUnqual(FunctionType::get( >> builder.getInt64Ty(), {builder.getInt64Ty()}, false))); >> return builder.CreateCall(f, args); >> >> >...
2012 Jun 19
0
[LLVMdev] Cast Pointer Address to Functions
...for us: std::vector<Type*> margs; FunctionType* fType; PointerType* pm3_routine; Value* m3func; Value* result; margs.resize(1); margs[0] = I64; fType = FunctionType::get(I32, margs, false); pm3_routine = PointerType::get(fType, 0); m3func = Builder.CreateIntToPtr(I64_Const((uint64_t)pFunc), pm3_routine, "pm3func"); result = Builder.CreateCall(m3func, parameter, "m3func"); - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received th...
2016 Mar 30
4
JIT compiler and calls to existing functions
...gt;> >>>> On 03/28/2016 06:33 PM, Russell Wallace via llvm-dev wrote: >>>> >>>> That seems to work, thanks! The specific code I ended up with to call >>>> int64_t print(int64_t) looks like: >>>> >>>> auto f = builder.CreateIntToPtr( >>>> ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), >>>> PointerType::getUnqual(FunctionType::get( >>>> builder.getInt64Ty(), {builder.getInt64Ty()}, false))); >>>> return builder.CreateCall(...
2016 Mar 29
3
JIT compiler and calls to existing functions
...hilip >>> >>> >>> On 03/28/2016 06:33 PM, Russell Wallace via llvm-dev wrote: >>> >>> That seems to work, thanks! The specific code I ended up with to call >>> int64_t print(int64_t) looks like: >>> >>> auto f = builder.CreateIntToPtr( >>> ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), >>> PointerType::getUnqual(FunctionType::get( >>> builder.getInt64Ty(), {builder.getInt64Ty()}, false))); >>> return builder.CreateCall(f, args); >&g...
2016 Mar 29
0
JIT compiler and calls to existing functions
...gt;> >> >> On 03/28/2016 06:33 PM, Russell Wallace via llvm-dev wrote: >>> That seems to work, thanks! The specific code I ended up >>> with to call int64_t print(int64_t) looks like: >>> >>> auto f = builder.CreateIntToPtr( >>> ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), >>> PointerType::getUnqual(FunctionType::get( >>> builder.getInt64Ty(), {builder.getInt64Ty()}, false))); >>> return builder.CreateCall(f, args); >>> &...
2012 Jun 18
4
[LLVMdev] Cast Pointer Address to Functions
I have a function address held in an uint64_t. I would like to cast the function address to a function prototype and create a call to the function in LLVM. How could I do this ? Thanks Xin
2016 Mar 30
0
JIT compiler and calls to existing functions
...> On 03/28/2016 06:33 PM, Russell Wallace via llvm-dev wrote: >>>>> >>>>> That seems to work, thanks! The specific code I ended up with to call >>>>> int64_t print(int64_t) looks like: >>>>> >>>>> auto f = builder.CreateIntToPtr( >>>>> ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), >>>>> PointerType::getUnqual(FunctionType::get( >>>>> builder.getInt64Ty(), {builder.getInt64Ty()}, false))); >>>>> return bui...
2016 Mar 29
0
JIT compiler and calls to existing functions
...On 03/28/2016 06:33 PM, Russell Wallace via llvm-dev wrote: >>>> That seems to work, thanks! The specific code I ended >>>> up with to call int64_t print(int64_t) looks like: >>>> >>>> auto f = builder.CreateIntToPtr( >>>> ConstantInt::get(builder.getInt64Ty(), uintptr_t(print)), >>>> PointerType::getUnqual(FunctionType::get( >>>> builder.getInt64Ty(), {builder.getInt64Ty()}, false))); >>>> return builder.CreateCall(...
2016 Mar 30
1
JIT compiler and calls to existing functions
...v wrote: >>>>> That seems to work, thanks! The specific code I >>>>> ended up with to call int64_t print(int64_t) looks >>>>> like: >>>>> >>>>> auto f = builder.CreateIntToPtr( >>>>> ConstantInt::get(builder.getInt64Ty(), >>>>> uintptr_t(print)), >>>>> PointerType::getUnqual(FunctionType::get( >>>>> builder.getInt64Ty(), {builder.getInt64Ty()}, >...
2015 Aug 19
5
creating a callinst to an external function
Dear All I'm making an instrumentation pass. The pass is supposed to modify the given IR in a specefic way. One of the required modifications is to insert a call to a function at a specific location. This is the signature of the called function: void myclass::foo(Function *f, BasicBlock* b) This function's prototype is in an foofile.h file in include/llvm And the function
2013 Nov 04
0
[LLVMdev] Implementing an llvm.setreturnaddress intrinsic
...o I'm implementing a new intrinsic: def int_setreturnaddress : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty], []>; And I'm using it as follows: B.CreateCall2( Intrinsic::getDeclaration(M, Intrinsic::setreturnaddress), ConstantInt::get(Type::getInt32Ty(RI->getContext()), 0), B.CreateIntToPtr(ConstantInt::get(IntPtrTy, 0 /* testing */)), RA->getReturnType())); The problem I'm facing is that for some reason, my following line inside X86TargetLowering::LowerOperation is never getting called: case ISD::SETRETURNADDR: return LowerSETRETURNADDR(Op, DAG); This is despite the fac...
2007 Aug 22
0
[LLVMdev] RFC: Patch for CFA on Darwin
...Intrinsic::eh_dwarf_cfa), - ConstantInt::get(Type::Int32Ty, cfa_offset)); - + Result = + Builder.CreateCall(Intrinsic::getDeclaration(TheModule, + Intrinsic::eh_dwarf_cfa), + Builder.CreateIntToPtr(ConstantInt::get(Type::Int32Ty, + cfa_offset), + ConvertType(TREE_TYPE(exp)))); return true; } The reason for it: when going to calculate the CFA in LLVM, the original code was adding an o...
2019 Feb 05
2
IRBuilder constraints
...mread instruction is the following for both cases(simplified version): int constVal = param1; llvm::IRBuilder<>& irb; llvm::Value* op1 = llvm::ConstantInt::getSigned(irb.getInt32Ty(), constVal); auto* pt = llvm::PointerType::get(op1->getType(), 0); auto* addr = irb.CreateIntToPtr(op1, pt); auto* loaded = irb.CreateLoad(addr); irb.CreateStore(loaded, module->getNamedGlobal(regname)); I cannot get LLVM to leave an llvm::Value as ConstantInt in every case, if I pass it to IRBuilder for processing(for example through a globalvariable storing instruction). Do you kno...
2007 Dec 17
0
[LLVMdev] Elsa and LLVM and LLVM submissions
...t; + return CreateCast(Instruction::FPExt, V, DestTy, Name); > + } > + Value *CreatePtrToInt(Value *V, const Type *DestTy, > + const char *Name = "") { > + return CreateCast(Instruction::PtrToInt, V, DestTy, Name); > + } > + Value *CreateIntToPtr(Value *V, const Type *DestTy, > + const char *Name = "") { > + return CreateCast(Instruction::IntToPtr, V, DestTy, Name); > + } > + Value *CreateBitCast(Value *V, const Type *DestTy, > + const char *Name = &quot...