This patch implements CallLowering::lowerCall based on M68k calling convention and adds M68kOutgoingValueHandler and CallReturnHandler to handle argument passing and returned value.
Details
Diff Detail
Event Timeline
Also there is a little problem: GlobalISel reject to combine G_LOAD followed by G_STORE into a move <ea>, <ea> unless there're consecutive in order. That is to say, if there is any instruction between them, GlobalISel will generate weird code like this:
Some of the move <ea>, <ea> definitions are actually missing IIRC. I'm tidying up all the MOVE instructions (to add those missing definitions, for instance) as part of the D115128 series and I think that will solve this problem.
llvm/lib/Target/M68k/M68kInstrData.td | ||
---|---|---|
71 ↗ | (On Diff #394840) | is there any particular reason you made this change? Like, some restrictions imposed by GISel? |
Adding @sushmaunnibhavi (who started GISel support in M68k) as a reviewer in case she still working in this area.
llvm/lib/Target/M68k/M68kInstrData.td | ||
---|---|---|
71 ↗ | (On Diff #394840) | Yes, GISel rejects the original pattern. It says "Dst operand has an unsupported type" The SelectionDAG isn't affected. The MatcherTable is still the same after this change. |
update diff.
Since now I've discovered some problems in CallLowering and Legalizer, I want to defer the review of RegisterBankInfo & InstructionSelector. Doing that will also make reviewing simpler
llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp | ||
---|---|---|
199 | Using F.getCallingConv() is using the calling function's calling convention. You want Info.CallConv like above | |
215 | Ditto | |
llvm/test/CodeGen/M68k/GlobalISel/irtranslator-call.ll | ||
2 | Don't need the 2>&1. Also, probably should just use update_mir_test_checks | |
38 | Value name in declaration list. I'm not sure why even parse this | |
42 | These tests aren't comprehensive enough. You should add a wider variety of return value and outgoing argument types (particularly some pointers and aggregates). Maybe add some byval / sret too. You're also testing a few different call instruction types which aren't covered (in particular indirect call and the isPositionIndependent switch). |
Address the issue pointed out by @arsenm. Thanks arsenm !
The following additional tests are included in this revision:
- return value with i32 / i16 / i8 and sret
- outgoing argument with i32 / i16 / i8 / pointer / array / struct
- struct passed byval.
- integer passed byval.
- array passed byval.
- indirect call
- call with pic
Using F.getCallingConv() is using the calling function's calling convention. You want Info.CallConv like above