lower-lever IR (A-normal form)

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

lower-lever IR (A-normal form)

Eirini _
Hi,

 i would like to ask you, if i can get a lower-level representation than the llvm IR.
For example, having the following instruction in the llvm IR, 
 call void @llvm.memcpy.i32(i8* %19, i8* getelementptr inbounds ([2 x [2 x [3 x i8]]]* @main.s, i32 0, i32 0, i32 0, i32 0), i32 12, i32 1)

i would like to get something like this (in A-normal form (without nested instructions):
%temp =  i8* getelementptr inbounds ([2 x [2 x [3 x i8]]]* @main.s, i32 0, i32 0, i32 0, i32 0)
 call void @llvm.memcpy.i32(i8* %19, %temp, i32 12, i32 1)


Thanks

_______________________________________________
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: lower-lever IR (A-normal form)

Tim Northover-2
Hi Eirini,

> i would like to get something like this (in A-normal form (without nested
> instructions):

The nested instructions come from anything LLVM can identify as a
constant (specifically, any value that's a subclass of Constant).

I'm not aware of a pass to turn them back into non-constant Values,
though one could clearly be written. It would probably count more as a
pessimisation than an optimisation though. The Constants have a
reasonable chance at resulting in no instructions at all, which I
doubt the expanded form would.

What are you trying to do where you think it would be an advantage?
Perhaps there's a better way without compromising optimisations.

Cheers.

Tim.
_______________________________________________
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: lower-lever IR (A-normal form)

John Criswell-4
In reply to this post by Eirini _
On 7/10/13 1:35 PM, Eirini _ wrote:
Hi,

 i would like to ask you, if i can get a lower-level representation than the llvm IR.
For example, having the following instruction in the llvm IR, 
 call void @llvm.memcpy.i32(i8* %19, i8* getelementptr inbounds ([2 x [2 x [3 x i8]]]* @main.s, i32 0, i32 0, i32 0, i32 0), i32 12, i32 1)

As Tim has pointed out, the "nested" getelementptr isn't really a nested instruction.  It is a compile-time constant.  The reason why it looks like a GEP is that it is in a symbolic form.

If you really want to convert these constants into instructions, take a look at the BreakConstantGEPs pass in SAFECode.  It converts some (but not all) constant expressions into LLVM instructions and will alleviate the "nesting" that you see.

As Tim also said, this conversion is not an optimization.  You should not expect the resulting IR to compile into efficient code.

-- John T.


i would like to get something like this (in A-normal form (without nested instructions):
%temp =  i8* getelementptr inbounds ([2 x [2 x [3 x i8]]]* @main.s, i32 0, i32 0, i32 0, i32 0)
 call void @llvm.memcpy.i32(i8* %19, %temp, i32 12, i32 1)


Thanks


_______________________________________________
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: lower-lever IR (A-normal form)

Eirini _
In reply to this post by Eirini _

I would like to create some tables for my instructions in the IR. For example a table that has all the store instructions.
I want all the arguments to a function or instruction or constant etc to be trivial.
So to fix my previous example instead of having :

 call void @llvm.memcpy.i32(i8* %19, i8* getelementptr inbounds ([2 x [2 x [3 x i8]]]* @main.s, i32 0, i32 0, i32 0, i32 0), i32 12, i32 1)
i would like to have in my IR the following :

%temp =  i8* getelementptr inbounds ([2 x [2 x [3 x i8]]]* @main.s, i32 0)
%temp1 i8* getelementptr inbounds( %temp, i32 0)
%temp2 i8* getelementptr inbounds (%temp1, i32 0)                                                                                
%temp4 i8* getelementptr inbounds (%temp3, i32 0)

call void @llvm.memcpy.i32(i8* %19, i8* %temp4, i32 12, i32 1)        

What i'm asking is, if LLVM can do this for me (for example with a certain flag while compiling the code) or i should break on my own these kind of expressions into simpler.     

                                                                 



Let me rephrase your question slightly. Would you be satisfied if the disassembled llvm format showed constant expressions on their own line, without turning them into instructions or changing the binary representation at all?


On Thu, Jul 11, 2013 at 4:05 AM, Eirini _ <[hidden email]> wrote:
Hi,

 i would like to ask you, if i can get a lower-level representation than the llvm IR.
For example, having the following instruction in the llvm IR, 
 call void @llvm.memcpy.i32(i8* %19, i8* getelementptr inbounds ([2 x [2 x [3 x i8]]]* @main.s, i32 0, i32 0, i32 0, i32 0), i32 12, i32 1)

i would like to get something like this (in A-normal form (without nested instructions):
%temp =  i8* getelementptr inbounds ([2 x [2 x [3 x i8]]]* @main.s, i32 0, i32 0, i32 0, i32 0)
 call void @llvm.memcpy.i32(i8* %19, %temp, i32 12, i32 1)


Thanks

_______________________________________________
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