This is an archive of the discontinued LLVM Phabricator instance.

[X86] Support MCU psABI when marking inregs
ClosedPublic

Authored by mkuper on Oct 22 2015, 3:45 AM.

Details

Summary

The MCU psABI has a calling convention that is somewhat, but not quite, like -mregparm 3.
This adds support for this calling convention.

It depends on D13977 which introduces MCU triple support.

Diff Detail

Event Timeline

mkuper updated this revision to Diff 38107.Oct 22 2015, 3:45 AM
mkuper retitled this revision from to [X86] Support MCU psABI when marking inregs.
mkuper updated this object.
mkuper added reviewers: rnk, rafael.
mkuper added a subscriber: cfe-commits.
DavidKreitzer added inline comments.Oct 22 2015, 8:56 AM
lib/CodeGen/TargetInfo.cpp
1239

Minor nit - you don't need the comma after "earlier".

test/CodeGen/x86_32-arguments-iamcu.c
1

Good test!

I think it would be a good idea to add a varargs function & verify that the args do not get marked inreg.

rnk accepted this revision.Oct 23 2015, 12:34 PM
rnk edited edge metadata.

lgtm with the suggested simplification.

lib/CodeGen/TargetInfo.cpp
857

Rather than taking this as a parameter, how about initializing IsMCUABI with getTarget().getTriple().isEnvironmentIAMCU()? Then you can drop a level of parameters.

This revision is now accepted and ready to land.Oct 23 2015, 12:34 PM
mkuper added inline comments.Oct 25 2015, 1:00 AM
lib/CodeGen/TargetInfo.cpp
857

Sure, will do.

test/CodeGen/x86_32-arguments-iamcu.c
1

They do get marked inreg, actually.
The varargs handling for -mregparm - and that means for IAMCU as well - happens on the CG level.

def CC_X86_32_C : CallingConv<[
  ...
  // The first 3 integer arguments, if marked 'inreg' and if the call is not
  // a vararg call, are passed in integer registers.
  **CCIfNotVarArg**<CCIfInReg<CCIfType<[i32], CCAssignToReg<[EAX, EDX, ECX]>>>>,

  ...
]>;

(Yes, this is incredibly ugly. We should probably fix that in a separate patch.)

This revision was automatically updated to reflect the committed changes.