> i would like to get something like this (in A-normal form (without nested
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.
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)
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 :
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?