This is an archive of the discontinued LLVM Phabricator instance.

FPXX modeless calling convention
ClosedPublic

Authored by jkolek on Jun 25 2014, 8:42 AM.

Details

Summary

Implemented caller/callee saved registers for FPXX modeless calling convention.

Diff Detail

Repository
rL LLVM

Event Timeline

jkolek updated this revision to Diff 10836.Jun 25 2014, 8:42 AM
jkolek retitled this revision from to FPXX modeless calling convention.
jkolek updated this object.
jkolek edited the test plan for this revision. (Show Details)
jkolek added reviewers: dsanders, vmedic.
jkolek added a subscriber: zoran.jovanovic.
dsanders edited edge metadata.Jun 26 2014, 7:43 AM

I have doubts about whether using the odd registers F21 to F31 correctly cause the corresponding double to be saved.

lib/Target/Mips/MipsCallingConv.td
242–247 ↗(On Diff #10836)

I'm not sure these are correct. What happens when only F21 is touched by a function? It should cause D10 to be saved/restored. We don't appear to test this case.

getCallPreservedMask() returns CSR_O32_FPXX_NoOdd_RegMask which contains F20, F22, ..., F30 but does not contain D10, D11, ..., D15. I would have expected this function to return the evens from F20 to F30 as well as D10 to D15.

Also, I believe that if you merged these two classes into the same definition like this:

def CSR_O32_FPXX : CalleeSavedRegs<(add (sequence "D%u", 15, 10), RA, FP, (sequence "S%u", 7, 0))> {
  let OtherPreserved = (add F20, F22, F24, F26, F28, F30);
}

then you wouldn't need two definitions and it would make getCallPreservedMask() do the right thing.

lib/Target/Mips/MipsSubtarget.cpp
89 ↗(On Diff #10836)

Style nit: This ought to be in the member initializer list

lib/Target/Mips/MipsSubtarget.h
62–64 ↗(On Diff #10836)

Would it be easy to make this a member of the MipsABIEnum enum?

As far as I can tell there are only two explicit checks for the O32 ABI in our backend. One is in MipsAsmParser.cpp (search for FeatureO32), the other is in MipsLongBranch.cpp. These would need to become tests for O32 || O32FPXX.

This isn't a blocking issue in my opinion but it would be best to put it in the enum if we can do so easily.

test/CodeGen/Mips/cconv/callee-saved-fpxx.ll
55–61 ↗(On Diff #10836)

The O32-FPXX-INV-NOT's in this region are redundant. They are covered on lines 40-43,

Also, use of FPXX needs to cause a '.module fp=fpxx' to be emitted (you'll need the patch in D4031). That directive can be emitted by a follow-up patch if you prefer. Without it, the binaries will be treated as using the O32 ABI rather than the O32+fpxx ABI.

jkolek added inline comments.Jun 27 2014, 3:04 AM
lib/Target/Mips/MipsSubtarget.h
62–64 ↗(On Diff #10836)

I added this flag according to the way O32 FP32/FP64 are currently implemented. I think that both ways make sense, but if we add O32FPXX to MipsABIEnum, I think that probably O32FP64 should be added there as well. I would like to leave this as it is for now.

jkolek updated this revision to Diff 10920.Jun 27 2014, 3:17 AM
jkolek edited edge metadata.
dsanders added inline comments.Jun 27 2014, 3:44 AM
lib/Target/Mips/MipsCallingConv.td
243 ↗(On Diff #10920)

indent

242–247 ↗(On Diff #10836)

What happens when only F21 is touched by a function? It should cause D10 to be saved/restored. We don't appear to test this case.

Could you add a test to cover this case? With that and the indent it will LGTM.

lib/Target/Mips/MipsSubtarget.h
62–64 ↗(On Diff #10836)

That makes sense. We'll leave it as-is for now.

I agree with your comment that O32FP64 belongs in the enum too. We should fix that when we move O32FPXX there. It can be part of general the work to handle ABI's more sensibly.

jkolek updated this revision to Diff 10927.Jun 27 2014, 5:27 AM
jkolek updated this revision to Diff 10928.Jun 27 2014, 5:49 AM

Added test case where only F21 is touched by a function, to check that D10 is saved/restored.

dsanders accepted this revision.Jun 27 2014, 5:52 AM
dsanders edited edge metadata.

LGTM with one last test addition. Please add a check to callee-saved-fpxx1.ll to check that the base O32 doesn't save 64-bit $f20 when 32-bit $f21 is touched.

This revision is now accepted and ready to land.Jun 27 2014, 5:52 AM
jkolek updated this revision to Diff 10930.Jun 27 2014, 6:35 AM
jkolek edited edge metadata.

Added check to callee-saved-fpxx1.ll that the base O32 doesn't save 64-bit $f20 when 32-bit $f21 is touched.

jkolek closed this revision.Jul 10 2014, 8:44 AM
jkolek updated this revision to Diff 11279.

Closed by commit rL212726 (authored by zjovanovic).

jkolek added a subscriber: Unknown Object (MLST).Nov 18 2014, 5:54 AM