[llvm-dev] Options for custom CCState, CCAssignFn, and GlobalISel
Alex Bradbury via llvm-dev
llvm-dev at lists.llvm.org
Mon Jan 22 07:30:23 PST 2018
On 4 January 2018 at 17:10, Daniel Sanders via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I haven't dug into the GlobalISel calling convention code much but I can comment on the MipsCCState.
>
>> On 3 Jan 2018, at 14:00, Alex Bradbury via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>
>> This question came about through reviewing work from Leslie Zhai on GlobalISel
>> support for RISC-V, which also motivated me to revisit code which I've always
>> felt was a bit clunky.
>>
>> Calling convention lowering in LLVM is typically handled by functions
>> conforming to the CCAssignFn typedef:
>>
>> typedef bool CCAssignFn(unsigned ValNo, MVT ValVT,
>> MVT LocVT, CCValAssign::LocInfo LocInfo,
>> ISD::ArgFlagsTy ArgFlags, CCState &State);
>>
>> Notably, these functions are called after type legalisation so an argument/ret
>> has been split to legal value types. In some cases you want more information
>> than is available through this function interface, which leads to a number of
>> backends creating their own CCState subclass:
>>
>> * MipsCCState: adds bool vectors OriginalArgWasF128, OriginalArgWasFloat,
>> OriginalArgWasFloatVector, OriginalRetWasFloatVector, CallOperandIsFixed. Also
>> a SpeciallCallingConv field. Provides its own implementation of
>> AnalyzeFormalArguments etc that fill these vectors.
>
> CallOperandIsFixed was needed because the CCIf* classes could tell whether the argument list was variable or not, but couldn't tell whether a particular argument was part of the variable portion of the argument list. At the time, it struck me as odd that this information wasn't part of ArgFlagsTy but I didn't want to add it there because it appeared to be full and I didn't want to make everyone have a 65-bit ArgFlagsTy just because of a Mips quirk. I see Reid Kleckner changed this object last year and found that it wasn't actually full so maybe we should move OutputArg::IsFixed into ArgFlagsTy now.
>
> I think SpeciallCallingConv ought to be eliminated and Mips16's calling convention be given it's own CallingConv def instead. If I remember rightly, I left it there because I didn't want to change Mips16 at the time.
As a starting point. I've put a patch up for comment which adds
IsFixed to ISD::ArgFlagsTy and ensures it is set correctly, as well as
updating backends to use it <https://reviews.llvm.org/D42374>. This
patch allows HexagonCCState to be removed completely. As noted in the
patch description, further improvements could be made such as modify
AArch64 calling conventions to make use of CCIfFixed and so calling
AArch64ISelLowering::CCAssignFnForCall once per function rather than
once per arg.
Comments and review very welcome.
Best,
Alex
More information about the llvm-dev
mailing list