Add the minimal support to lower function calls.
Support only functions with arguments/return that go through registers, and have type i32.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I've only gone through the ABI side of things (and from memory) but I have a couple comments.
lib/Target/Mips/MipsCallLowering.cpp | ||
---|---|---|
279 ↗ | (On Diff #142426) | I assume it's O32 you're implementing based on the magic number here. IIRC, there's a function in the Mips target that returns 0 or 16 as appropriate for the ABI. If it used that instead then I suspect this patch may support N32/N64 too. |
test/CodeGen/Mips/GlobalISel/llvm-ir/call.ll | ||
6 ↗ | (On Diff #142426) | I would suggest not using the first two arguments so that code is emitted to put the arguments in the right place. This test will currently emit the right assembly even if argument passing isn't handled. If you added two dummy arguments in front of these then there would be a mov instruction you can check for. |
21 ↗ | (On Diff #142426) | Similarly, I'd suggest modifying the result before passing it back to the caller so that code using $v0 is emitted. Then you'd be able to check the register is correct. |
lib/Target/Mips/MipsCallLowering.cpp | ||
---|---|---|
222 ↗ | (On Diff #142426) | Fallback if we have more than 4 arguments, var-args or the calling convention is not supported. |
224 ↗ | (On Diff #142426) | Test that we have no 'byval' arguments here, they require some MIPS-specific special handling. See D44296 for the details on how to handle this, but note that clang doesn't currently produce function calls with 'byval'. 'sret' arguments should also provoke fallback as well. |
236 ↗ | (On Diff #142426) | FIXME: Add support for pic calling sequences, long call sequences for O32, N32 and N64. |
279 ↗ | (On Diff #142426) | The MipsABIInfo class knows the fixed portion of the outing argument area, GetCalleeAllocdArgSizeInBytes(). |
lib/Target/Mips/MipsCallLowering.cpp | ||
---|---|---|
222 ↗ | (On Diff #142426) | Add fallback if calling convention is not the default one (CallingConv::C). |
236 ↗ | (On Diff #142426) | Add FIXME comment pic and long call. And as we are adding this comment also add fallback if callee is not a symbol since we have to support callee in register (pointer to function) first. |
279 ↗ | (On Diff #142426) | When we add support for arguments on stack in lowerCall, GetCalleeAllocdArgSizeInBytes will be used to AllocateStack in MipsCCState so it can be used correctly. There is similar work to be done in lowerFormalArguments too. |
test/CodeGen/Mips/GlobalISel/llvm-ir/call.ll | ||
6 ↗ | (On Diff #142426) | Tests are modified so that we can see move from a2,a3($6,$7) to a0,a1($4,$5) when we are preparing arguments for call of function f. |
21 ↗ | (On Diff #142426) | Return value of f is doubled in order to see if value in register v0($2) is used in add instruction. |