[PATCH] D137495: [LoongArch] Add GHC Calling Convention

wanglei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 7 01:04:04 PST 2022


wangleiat added a comment.

In D137495#3911535 <https://reviews.llvm.org/D137495#3911535>, @lrzlin wrote:

> In D137495#3911433 <https://reviews.llvm.org/D137495#3911433>, @wangleiat wrote:
>
>> In D137495#3911248 <https://reviews.llvm.org/D137495#3911248>, @lrzlin wrote:
>>
>>> @wangleiat 
>>> I have consulted the RISC-V codemodel here, which `CodeModel::Small` is represented by `addi (lui %hi(sym)) %lo(sym)`, using for accessing the first 2GiB of address space, I think it could be implemented in LoongArch also, or LoongArch have a different codemodel here?
>>
>> RISC-V only distinguishes when `relocation-model=static` is specified, but it is not required on LoongArch. On LoongArch, regardless of `relocation-model=everything`, it is sufficient to use pc-relative instructions.
>
> Without the `isPositionIndepent()` and code-model check, original `getAddr()` will map the `PseudoLA_GOT` pattern in GHC calling convention (in `ghc-cc.ll`), which is obviously incorrect (should be `LA_PCREL`). In case that all relocation-models are sufficient to use pc-relative instructions, both `CodeModel=Small` and `CodeModel=Medium` could keep being `LA_PCREL`.

Personally I think using GOT or PCREL should have nothing to do with isPositionIndependent . If this test case uses -relocation-model=pic on RISC-V, it should also generate got related instructions.
In addition, I really don't understand the calling convention of ghc, is it not allowed to use got with ghc?


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

https://reviews.llvm.org/D137495



More information about the llvm-commits mailing list