Lowering instructions
In this chapter, we will see the implementation of 3 things – Function call calling convention, Formal argument calling convention, and Return value calling convention. We create a file TOYISelLowering.cpp
, and implement Instructions Lowering in it.
First, let's look at how a call calling convention can be implemented.
SDValue TOYTar-getLoweing::LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl<SDValue> &InVals) const { SelectionDAG &DAG = CLI.DAG; SDLoc &Loc = CLI.DL; SmallVectorImpl<ISD::OutputArg> &Outs = CLI.Outs; SmallVectorImpl<SDValue> &OutVals = CLI.OutVals; SmallVectorImpl<ISD::InputArg> &Ins = CLI.Ins; SDValue Chain = CLI.Chain; SDValue Callee = CLI.Callee; CallingConv::ID CallConv = CLI.CallConv; const bool isVarArg = CLI.IsVarArg; CLI.IsTailCall = false; if (isVarArg) { llvm_unreachable("Unimplemented"); } // Analyze operands of the call, assigning locations...