Abhinash Jain
2013-Jul-25 17:12 UTC
[LLVMdev] Passing String to an external function in llvm
I did some computation through llvm pass, and store those computed values on string. eg. :- stringstream lhs; lhs << instr->getOperand(1); // 'instr' is some instruction string lhsvar=lhs.str(); Now I want to pass this 'lhsvar' to the external function, so how can i do this??? This is just the part of a code to make you understand. if you say I can even provide the link to the code. -- View this message in context: http://llvm.1065342.n5.nabble.com/Passing-String-to-an-external-function-in-llvm-tp59798p59803.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
David Blaikie
2013-Jul-25 17:36 UTC
[LLVMdev] Passing String to an external function in llvm
On Thu, Jul 25, 2013 at 10:12 AM, Abhinash Jain <omnia at mailinator.com> wrote:> I did some computation through llvm pass, and store those computed values on > string. eg. :- > > stringstream lhs; > lhs << instr->getOperand(1); // 'instr' is some instruction > string lhsvar=lhs.str(); > > Now I want to pass this 'lhsvar' to the external function, so how can i do > this???Why are you storing this in a string at all - just use the operand itself, it will be the LLVM Value you want to pass to the function.> > This is just the part of a code to make you understand. if you say I can > even provide the link to the code. > > > > > > > > -- > View this message in context: http://llvm.1065342.n5.nabble.com/Passing-String-to-an-external-function-in-llvm-tp59798p59803.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Abhinash Jain
2013-Jul-25 18:07 UTC
[LLVMdev] Passing String to an external function in llvm
Thanx for the response. %x = alloca i32, align 4 %y = alloca i32, align 4 %a = alloca i32, align 4 %t = alloca i32, align 4 1. %10 = load i32* %x, align 4 2. %11 = load i32* %y, align 4 3. %div = sdiv i32 %10, %11 4. %12 = load i32* %a, align 4 5. %mul4 = mul nsw i32 %div, %12 6. store i32 %mul4, i32* %t, align 4 a. %mul4 = mul nsw i32 %div, %12 b. %div = sdiv i32 %10, %11 c. %10 = load i32* %x, align 4 d. %11 = load i32* %y, align 4 e. %12 = load i32* %a, align 4 This is a IR of " t = x/y*a " The address of the "%x, %y, %a" are "0xbe4ab94, 0xbe4abd4, 0xbe4ac54" respectively. and the opcode of "*, /" are "12, 15" respectively. Point (6.a to 6.e) are the result of use-def chain, with the help of which I managed to make a string as - "12_15_0xbe4ab94_0xbe4abd4_0xbe4ac54" (by converting getOpcode() and getOperand() to string and than concatenating it) Now I want to pass this whole string to some other external function, How can I do this? If you want I can show you the full code. -- View this message in context: http://llvm.1065342.n5.nabble.com/Passing-String-to-an-external-function-in-llvm-tp59798p59807.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Reasonably Related Threads
- [LLVMdev] Passing String to an external function in llvm
- [LLVMdev] Passing String to an external function in llvm
- [LLVMdev] Passing String to an external function in llvm
- [LLVMdev] Passing String to an external function in llvm
- [LLVMdev] Passing String to an external function in llvm