[PATCH] D89788: [RISCV] Add GHC calling convention

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 18:26:14 PST 2020


jrtc27 added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1964-2003
+static bool CC_RISCV_GHC(unsigned ValNo, MVT ValVT, MVT LocVT,
+			 CCValAssign::LocInfo LocInfo,
+			 ISD::ArgFlagsTy ArgFlags, CCState &State) {
+
+  if (LocVT == MVT::i64) {
+    // Pass in STG registers: Base, Sp, Hp, R1, R2, R3, R4, R5, R6, R7, SpLim
+    static const MCPhysReg GPRList[] = {
----------------
StephenFan wrote:
> jrtc27 wrote:
> > lenary wrote:
> > > Is this doable with the declarative Calling Convention system in LLVM (an example of this is in `llvm/lib/Target/ARM/ARMCallingConv.td`)
> > > 
> > > We haven't been able to do this for RISC-V's normal calling convention yet, but this convention seems a lot simpler, so I hope it should be doable.
> > We deliberately went with C++ rather than TableGen for Fast, as it's far more readable (and flexible).
> In the CallingConvLower.h, the CCAssignFn is a function pointer that represent the function that deal with the calling convention, and this function can be used in many other places, for example, In globalisel's ValueHandler. So I think use the TableGen rather than C++ is more convenient.
If GlobalISel can’t work with what’s already there then it needs to be fixed, because the current code is rather complex and won’t be being converted any time soon, and as a downstream consumer of the backend who extensively adds to the calling convention that would cause serious headache (and depending on how the rewriting is done may not even support our use case without additional downstream changes to TableGen, something that would be a real pain to do). IMO GlobalISel as a new framework needs to adapt to fit the existing backends unless there is a good reason why it fundamentally cannot.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89788/new/

https://reviews.llvm.org/D89788



More information about the llvm-commits mailing list