[llvm-dev] ABI-specific Stack Pointer Register?

Aaron Smith via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 4 12:39:48 PST 2019


Try changing AArch64RegisterInfo::getFrameRegister() [1].

if (MF->getFunction().getCallingConv() == CallingConv::GHC)
  return AArch64::GHCSP;

[1] https://github.com/llvm/llvm-project/blob/master/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp#L294


On Wed, Dec 4, 2019 at 12:16 PM Kavon Farvardin via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> Hi,
>
> In the runtime system for GHC Haskell, the stack pointer register is not the same as the one defined by the operating system ABI, and it's difficult for GHC to change that. Following the example of CoreCLR in LLVM, it seems one way to remedy this situation is to define a new ABI (i.e., a new llvm::Triple::EnvironmentType ) and modify the code generator as-needed to respect to our ABI, through our own definition of an MCAsmInfo class for each architecture, etc.
>
> My question is: how feasible is it to extend MCAsmInfo with an override for the stack pointer register and have that fact be respected by the code generator?
>
> Currently, MCAsmInfo only specifies the stack direction, and from what I've seen in the x86 backend (and instruction selection), RSP is assumed to be the stack-pointer register and is hard-coded in a number of places.
>
> Any other suggestions of alternate ways to achieve this change in LLVM code generation for both ARM64 and x86-64 are welcomed!
>
> Thanks,
> Kavon
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list