Lowering the ABI with GlobalISel
The target hooks required to lower the ABI are all gathered in one helper class in GlobalISel. Indeed, to implement the lowering of the ABI in GlobalISel, you need to supply a target-specific version of the CallLowering
class, from the GlobalISel
library.
To implement this class, you need to override the following four methods: lowerFormalArguments
, lowerReturn
, lowerCall
, and canLowerReturn
. Just from their names, you should have an idea of what each of them needs to do!
In the signature of the lowerFormalArguments
and lowerReturn
methods, you will find an instance of the FunctionLoweringInfo
class that, as you know, holds some information about the LLVM IR function being lowered, and for the lowerCall
method, an instance of the CallLoweringInfo
class, which holds some information about the call instruction being lowered, such as the calling convention used, whether this can be optimized as a tail call, and so on.
Taking each method one...