[LLVMdev] trouble with 32-bit promotion of return value
gohman at apple.com
Tue May 13 17:21:16 CDT 2008
On May 13, 2008, at 11:54 AM, Alireza.Moshtaghi at microchip.com wrote:
> There is a FIXME part in SelectionDAGLowering::visitRet() that is
> us trouble. And I would like to know how the community has planned for
> addressing this problem.
> The current implementation assumes that all C calling conventions
> require the return value of integer types in the largest register
> (for most ports 32-bit). However, this is not the case for our port.
> have two register classes (8-bit and 16-bit) and we only return the
> 8-bit return values in the 8-bit register. The rest is returned in the
> memory. But the current behavior of LLVM promotes the return value
> to 16
> bits (largest register class that it can find in the target).
> To me, such promotions are Target/ABI specific and should not happen
> the general llvm modules. The correct place (I think) is the target
> specific part of the backend. It may also be taken care of in the
> specific modules of the front-end but I'm not sure... (I think it is
> more of code generation issue rather than language issue)
I think a reasonable way to fix this would be to add a new field to
the TargetLowering class, and then let each target specify the minimum
integer type to promote return types to. SelectionDAGISel.cpp can then
use this information instead of hard-coding i32. You can have the
default value be i32 so that most targets don't need override it.
More information about the LLVMdev