Page MenuHomePhabricator

[X86] Support MCU psABI when marking inregs

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



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
1239 ↗(On Diff #38107)

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

1 ↗(On Diff #38107)

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.

857 ↗(On Diff #38107)

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
857 ↗(On Diff #38107)

Sure, will do.

1 ↗(On Diff #38107)

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.