This is an archive of the discontinued LLVM Phabricator instance.

[X86][GlobalISel] Add limited ret lowering support to the IRTranslator.
ClosedPublic

Authored by igorb on Jan 29 2017, 3:57 AM.

Details

Summary

Support return lowering for i8/i16/i32/i64/float/double, vector type supported for 64bit platform only.
Support argument lowering for float/double types.

Diff Detail

Repository
rL LLVM

Event Timeline

igorb created this revision.Jan 29 2017, 3:57 AM
zvi added inline comments.Jan 29 2017, 4:35 AM
lib/Target/X86/X86CallLowering.cpp
44 ↗(On Diff #86212)

Isn't there already a class member that can be casted to X86TargetLowering?

125 ↗(On Diff #86212)

Is it ok to insert if Success == false?

195 ↗(On Diff #86212)

Is there a test-case for when the condition is false?

lib/Target/X86/X86CallLowering.h
38 ↗(On Diff #86212)

Can you please document this typedef? What is it used for and what are the roles of the arguments?

igorb updated this revision to Diff 86216.Jan 29 2017, 6:06 AM
igorb marked an inline comment as done.

Fixed according to the comments.

rovka added inline comments.Jan 31 2017, 3:36 AM
lib/Target/X86/X86CallLowering.cpp
38 ↗(On Diff #86216)

I was wondering if it's possible to use just one of these for all backends.

In particular, I see you need to split values based on TLI.getNumRegisters/getRegisterType. I was looking into that myself for the ARM port. For ARM, I think it would be enough to extract the function from AArch64 and then add this splitting logic in the loop on the SplitVTs (and also not exit if we only have one VT - I think that doesn't do the right thing for AArch64 either if we have i128 arguments). Some generalization in the handling of bit offsets would be needed too, but that probably wouldn't be too exotic.

Would something like that work for x86 as well? I see that in the arg handling in SelectionDAG there are some special cases for some x86 calling conventions (vector call, intr) and obviously we don't want to special-case in the common code anymore. Do you see any way in which we could share some of this code across all backends, without doing anything awkward? Like I said, ARM and AArch64 are pretty similar, so some x86 perspective would definitely help here :)

igorb added inline comments.Jan 31 2017, 5:37 AM
lib/Target/X86/X86CallLowering.cpp
44 ↗(On Diff #86212)

This is getter for target specific TargetLowering class.

195 ↗(On Diff #86212)

In case of empty function ( ret instruction only)

38 ↗(On Diff #86216)

I think it is possible to use just one ( like void SelectionDAGISel::LowerArguments) with additional target specific hooks to handle special cases, most probably X86 back-end is the only one that need it for now.
I don't know if it is a good long-term solution.
May be we can break it to a few generic help factions , so very target can construct his own solution?

rovka edited edge metadata.Feb 1 2017, 1:33 AM

I don't see anything wrong with this patch, but I'll let Zvi or someone else that knows the x86 ABI approve if the tests cover all interesting cases.

lib/Target/X86/X86CallLowering.cpp
38 ↗(On Diff #86216)

Sure, breaking it into several helper functions is a good idea. We can leave it for later if you think it's too soon to know what the best helpers would be.

zvi accepted this revision.Feb 5 2017, 8:02 AM

LGTM.

This revision is now accepted and ready to land.Feb 5 2017, 8:02 AM
This revision was automatically updated to reflect the committed changes.
igorb added a comment.Feb 6 2017, 12:53 AM

Diana , Thank you very much for your comments.