[LLVMdev] Calls to functions with signext/zeroext return values

Ken Dyck kd at kendyck.com
Thu Mar 17 06:42:55 PDT 2011


On Wed, Mar 16, 2011 at 8:58 AM, Ken Dyck <kd at kendyck.com> wrote:
> I ran into problems in a DSP back end that I'm working on where the
> return conventions for i16 and i32 are slightly different (they are
> both returned in the same accumulator register, but at different
> offsets within the accumulator). The callee promoted the return value
> to i32, but the caller was expecting it to be returned as an i16.
>
> So I made some changes to SelectionDAGBuilder (see attached patch) to
> truncate return values back to their declared sizes and that seemed to
> fix the problems for my DSP backend.

That patch has been rendered obsolete by some recent changes by
Cameron. Attached is an updated one.

> So my questions:
>
> ...
> 2. If so, any suggestions on how to fix my patch or the MSP430 back
> end so it won't crash the MSP430 tests?

With Cameron's addition of a getTypeForExtendedInteger() hook in
TargetLowering, I've been able to work around the failures in the
MSP430 back end by overriding the extension size to i16 (see the
attached patch). This seems like it would be the appropriate size for
the architecture -- since the current default of i32 isn't a legal
type -- but I really have no idea what affects it has on the runtime
library or whether it conforms to an official ABI (does one exist?).
Anton, do you have any comments?

-Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: call-extended-return.r2.patch
Type: text/x-patch
Size: 2656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110317/8aab78c2/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: msp430-i16-extend.patch
Type: text/x-patch
Size: 1238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110317/8aab78c2/attachment-0001.bin>


More information about the llvm-dev mailing list