[LLVMdev] Integer promotion of return node operand
Evan Cheng
evan.cheng at apple.com
Tue May 13 09:34:06 PDT 2008
On May 12, 2008, at 8:21 AM, Sachin.Punyani at microchip.com wrote:
>
> When LLVM constructs the DAG for above case - it tries to promote
> (during DAG construction phase - before any combine or legalize phase)
> the return node operand to i32.
>
> I have few doubts here:
> 1) If C language requires integer promotion of return value argument
> then should it not be done by the C language frontend. (I think LLVM
> is
> langauge
> independent). This is what happens when we use char in calculations.
> Clang promotes char in calculations to int and this promotion is
> visible
> in the disassembly. However return node operand promotion is not
> visible
> in disassembly but LLVM is doing that.
I think all currently defined calling conventions are "C like". You
can add a calling convention and check for it in visitRet.
>
>
> 2) Also should the char not be promoted to target integer (Target
> integer may be 16 bits). LLVM tries to promote to i32 (promotion to
> i32
> is hardcoded in file SelectionDAGISel.cpp - function visitRet).
>
> The comment in LLVM code says "C calling convention requires
> the return type to be promoted to atleast 32 bits. But this is not
> necessary for non-C calling conventions." What about targets where
> integer size is not 32 bits ??
I think C calling convention requires promotion to "int" type. So if
your int is 16-bit, it should be promoted to 16-bits. Someone else
would chime in, I am not 100% about this.
>
>
> 3) And How should this promotion be handled when the target does not
> have register to handle int size. e.g. if a target has int size of 16
> bits but the register size of 8 bits.
I am not sure how that would work. I'd think you need to have int
register class. How does your target handle i16? Can it use register
pair?
Evan
>
>
>
> Regards
> -:SP:-
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list