[LLVMdev] Getelementptr woes
Vladimir Prus
ghost at cs.msu.su
Thu Jun 17 08:39:02 PDT 2004
Hello,
I'm having problems with the following LLVM instruction
%tmp.0.i = call int (sbyte*, ...)*
%printf( sbyte* getelementptr ([11 x sbyte]* %.str_1, long 0, ......
The first argument in function call,
sbyte* getelementptr ([11 x sbyte]* %.str_1.....
appears to be ConstantExpression*, and my backend does not support
ConstantExpression yet.
I probable can implement that, and getelementptr instruction too, but I wonder
if I need to. Looking at X86 backend, I see it does some smart things, like
folding getelementptr into instruction which uses it, and using 'lea' asm
instruction to perform addressing.
On my target, neither of this is possible -- there's just no such fancy
addressing modes.
So I wonder if I can away by writing two passes which work on LLVM level.
The first pass would extract all ConstantExpr* operands from instructions and
move them into separate instructions. E.g. the example above would become:
%tmp.1 = sbyte* getelementptr ([11 x sbyte]* %.str_1, ..........
%tmp.0.i = call int (sbyte*, ...)*
%printf(%tmp.1 , .........
The second pass would convert getelementptr into casts and pointer arithmetic.
As a result, my backend would not care about both ConstantExpr and getelement
ptr, both of which look scary. The biggest advantage is any target which does
not have fancy addressing modes can just use those two passes.
I've started to sketch such passes already, but would be intetested to know
what you think.
TIA,
Volodya
More information about the llvm-dev
mailing list