Grabbing Result of an Instruction.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Grabbing Result of an Instruction.

Manish Gupta-8
What member function to use if I wish to operate on results of an instruction. 

eg. 
Instruction  %1 = getelementptr inbounds [10 x i32]* %a, i32 0, i32 %0

I->getOperand will give me the operands. 
How should I get hold of %1? 

Thanks,
Manish 

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing Result of an Instruction.

Michael Ilseman-2
In LLVM, %1 is the instruction itself. This is because LLVM IR is in
SSA, so the "=" really means equality. If you look at a use of %1,
e.g. as an operand to another instruction, you'll see that it's the
instruction itself that is there (i.e. you can dyn_cast<Instruction>
it).

On Mon, Aug 1, 2011 at 5:27 PM, Manish Gupta <[hidden email]> wrote:

> What member function to use if I wish to operate on results of an
> instruction.
> eg.
> Instruction  %1 = getelementptr inbounds [10 x i32]* %a, i32 0, i32 %0
> I->getOperand will give me the operands.
> How should I get hold of %1?
> Thanks,
> Manish
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing Result of an Instruction.

Manish Gupta-8
Thanks Michael.
I wish to get Type of %1 i.e. result of instruction. Let me try out your suggestion. But It is still not clear to me how will dyn_cast will help here. I already have pointer to this particular instruction. 


On Mon, Aug 1, 2011 at 5:34 PM, Michael Ilseman <[hidden email]> wrote:
In LLVM, %1 is the instruction itself. This is because LLVM IR is in
SSA, so the "=" really means equality. If you look at a use of %1,
e.g. as an operand to another instruction, you'll see that it's the
instruction itself that is there (i.e. you can dyn_cast<Instruction>
it).

On Mon, Aug 1, 2011 at 5:27 PM, Manish Gupta <[hidden email]> wrote:
> What member function to use if I wish to operate on results of an
> instruction.
> eg.
> Instruction  %1 = getelementptr inbounds [10 x i32]* %a, i32 0, i32 %0
> I->getOperand will give me the operands.
> How should I get hold of %1?
> Thanks,
> Manish
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing Result of an Instruction.

James Molloy-3

Hi Manish,

 

As Michael mentioned, the Instruction is its own result.

 

The Instruction class subclasses Value. If you treat the Instruction as a Value you will get what you want – just call I->getType() to get the type of the instruction.

 

James

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Manish Gupta
Sent: 02 August 2011 15:43
To: Michael Ilseman; llvmdev
Subject: Re: [LLVMdev] Grabbing Result of an Instruction.

 

Thanks Michael.

I wish to get Type of %1 i.e. result of instruction. Let me try out your suggestion. But It is still not clear to me how will dyn_cast will help here. I already have pointer to this particular instruction. 

 

On Mon, Aug 1, 2011 at 5:34 PM, Michael Ilseman <[hidden email]> wrote:

In LLVM, %1 is the instruction itself. This is because LLVM IR is in
SSA, so the "=" really means equality. If you look at a use of %1,
e.g. as an operand to another instruction, you'll see that it's the
instruction itself that is there (i.e. you can dyn_cast<Instruction>
it).


On Mon, Aug 1, 2011 at 5:27 PM, Manish Gupta <[hidden email]> wrote:


> What member function to use if I wish to operate on results of an
> instruction.
> eg.
> Instruction  %1 = getelementptr inbounds [10 x i32]* %a, i32 0, i32 %0
> I->getOperand will give me the operands.
> How should I get hold of %1?
> Thanks,
> Manish

> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>

 

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing Result of an Instruction.

Manish Gupta-8
In reply to this post by Manish Gupta-8
Thanks!!!  James and Michael. yes now got the idea how it is working.  

Manish

On Tue, Aug 2, 2011 at 7:59 AM, James Molloy <[hidden email]> wrote:

Hi Manish,

 

As Michael mentioned, the Instruction is its own result.

 

The Instruction class subclasses Value. If you treat the Instruction as a Value you will get what you want – just call I->getType() to get the type of the instruction.

 

James

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Manish Gupta
Sent: 02 August 2011 15:43
To: Michael Ilseman; llvmdev
Subject: Re: [LLVMdev] Grabbing Result of an Instruction.

 

Thanks Michael.

I wish to get Type of %1 i.e. result of instruction. Let me try out your suggestion. But It is still not clear to me how will dyn_cast will help here. I already have pointer to this particular instruction. 

 

On Mon, Aug 1, 2011 at 5:34 PM, Michael Ilseman <[hidden email]> wrote:

In LLVM, %1 is the instruction itself. This is because LLVM IR is in
SSA, so the "=" really means equality. If you look at a use of %1,
e.g. as an operand to another instruction, you'll see that it's the
instruction itself that is there (i.e. you can dyn_cast<Instruction>
it).


On Mon, Aug 1, 2011 at 5:27 PM, Manish Gupta <[hidden email]> wrote:
> What member function to use if I wish to operate on results of an
> instruction.
> eg.
> Instruction  %1 = getelementptr inbounds [10 x i32]* %a, i32 0, i32 %0
> I->getOperand will give me the operands.
> How should I get hold of %1?
> Thanks,
> Manish

> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>

 



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev