|
LLVM
10.0.0
|
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
Classes | |
| struct | ArgInfo |
| struct | CallLoweringInfo |
| struct | ValueHandler |
| Argument handling is mostly uniform between the four places that make these decisions: function formal arguments, call instruction args, call instruction returns and function returns. More... | |
Public Member Functions | |
| CallLowering (const TargetLowering *TLI) | |
| virtual | ~CallLowering ()=default |
| virtual bool | supportSwiftError () const |
| virtual bool | lowerReturn (MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< Register > VRegs, Register SwiftErrorVReg) const |
This hook must be implemented to lower outgoing return values, described by Val, into the specified virtual registers VRegs. More... | |
| virtual bool | lowerReturn (MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< Register > VRegs) const |
| This hook behaves as the extended lowerReturn function, but for targets that do not support swifterror value promotion. More... | |
| virtual bool | lowerFormalArguments (MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< ArrayRef< Register >> VRegs) const |
This hook must be implemented to lower the incoming (formal) arguments, described by VRegs, for GlobalISel. More... | |
| virtual bool | lowerCall (MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info) const |
| This hook must be implemented to lower the given call instruction, including argument and return value marshalling. More... | |
| bool | lowerCall (MachineIRBuilder &MIRBuilder, ImmutableCallSite CS, ArrayRef< Register > ResRegs, ArrayRef< ArrayRef< Register >> ArgRegs, Register SwiftErrorVReg, std::function< unsigned()> GetCalleeReg) const |
| Lower the given call instruction, including argument and return value marshalling. More... | |
Protected Member Functions | |
| const TargetLowering * | getTLI () const |
| Getter for generic TargetLowering class. More... | |
| template<class XXXTargetLowering > | |
| const XXXTargetLowering * | getTLI () const |
| Getter for target specific TargetLowering class. More... | |
| template<typename FuncInfoTy > | |
| void | setArgFlags (ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const |
| Register | packRegs (ArrayRef< Register > SrcRegs, Type *PackedTy, MachineIRBuilder &MIRBuilder) const |
Generate instructions for packing SrcRegs into one big register corresponding to the aggregate type PackedTy. More... | |
| void | unpackRegs (ArrayRef< Register > DstRegs, Register SrcReg, Type *PackedTy, MachineIRBuilder &MIRBuilder) const |
Generate instructions for unpacking SrcReg into the DstRegs corresponding to the aggregate type PackedTy. More... | |
| bool | handleAssignments (MachineIRBuilder &MIRBuilder, SmallVectorImpl< ArgInfo > &Args, ValueHandler &Handler) const |
Invoke Handler::assignArg on each of the given Args and then use Callback to move them to the assigned locations. More... | |
| bool | handleAssignments (CCState &CCState, SmallVectorImpl< CCValAssign > &ArgLocs, MachineIRBuilder &MIRBuilder, SmallVectorImpl< ArgInfo > &Args, ValueHandler &Handler) const |
| bool | analyzeArgInfo (CCState &CCState, SmallVectorImpl< ArgInfo > &Args, CCAssignFn &AssignFnFixed, CCAssignFn &AssignFnVarArg) const |
Analyze passed or returned values from a call, supplied in ArgInfo, incorporating info about the passed values into CCState. More... | |
| bool | resultsCompatible (CallLoweringInfo &Info, MachineFunction &MF, SmallVectorImpl< ArgInfo > &InArgs, CCAssignFn &CalleeAssignFnFixed, CCAssignFn &CalleeAssignFnVarArg, CCAssignFn &CallerAssignFnFixed, CCAssignFn &CallerAssignFnVarArg) const |
Definition at line 41 of file CallLowering.h.
|
inline |
Definition at line 246 of file CallLowering.h.
References ~CallLowering().
|
virtualdefault |
Referenced by CallLowering().
|
protected |
Analyze passed or returned values from a call, supplied in ArgInfo, incorporating info about the passed values into CCState.
Used to check if arguments are suitable for tail call lowering.
Definition at line 383 of file CallLowering.cpp.
References llvm::dbgs(), llvm::numbers::e, llvm::CCValAssign::Full, llvm::MVT::getVT(), LLVM_DEBUG, and llvm::SmallVectorBase::size().
Referenced by getAssignFnsForCC(), getCallOpcode(), getTLI(), and resultsCompatible().
|
inlineprotected |
Getter for generic TargetLowering class.
Definition at line 173 of file CallLowering.h.
Referenced by setArgFlags().
|
inlineprotected |
Getter for target specific TargetLowering class.
Definition at line 179 of file CallLowering.h.
References analyzeArgInfo(), Arg, llvm::AMDGPU::HSAMD::Kernel::Key::Args, handleAssignments(), Info, packRegs(), resultsCompatible(), setArgFlags(), and unpackRegs().
|
protected |
Invoke Handler::assignArg on each of the given Args and then use Callback to move them to the assigned locations.
Definition at line 171 of file CallLowering.cpp.
References F(), llvm::Function::getCallingConv(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::MachineIRBuilder::getMF(), and llvm::Function::isVarArg().
Referenced by getCallOpcode(), getTLI(), isSupportedType(), llvm::X86CallLowering::lowerCall(), llvm::ARMCallLowering::lowerCall(), llvm::AArch64CallLowering::lowerCall(), llvm::X86CallLowering::lowerFormalArguments(), llvm::ARMCallLowering::lowerFormalArguments(), llvm::AArch64CallLowering::lowerFormalArguments(), llvm::AMDGPUCallLowering::lowerFormalArguments(), llvm::X86CallLowering::lowerReturn(), llvm::AArch64CallLowering::lowerReturn(), and unpackRegsToOrigType().
|
protected |
Definition at line 181 of file CallLowering.cpp.
References llvm::alignTo(), assert(), llvm::CallLowering::ValueHandler::assignArg(), llvm::CallLowering::ValueHandler::assignCustomValue(), llvm::CallLowering::ValueHandler::assignValueToAddress(), llvm::CallLowering::ValueHandler::assignValueToReg(), llvm::MachineIRBuilder::buildCopy(), llvm::MachineIRBuilder::buildMerge(), llvm::MachineIRBuilder::buildTrunc(), llvm::MachineIRBuilder::buildUnmerge(), llvm::SmallVectorImpl< T >::clear(), llvm::MachineRegisterInfo::createGenericVirtualRegister(), llvm::dbgs(), llvm::numbers::e, F(), llvm::CCValAssign::Full, llvm::Function::getCallingConv(), llvm::Function::getContext(), llvm::Module::getDataLayout(), llvm::MachineFunction::getFunction(), llvm::getLLTForMVT(), llvm::MachineIRBuilder::getMF(), llvm::MachineIRBuilder::getMRI(), llvm::LLT::getNumElements(), llvm::TargetLoweringBase::getNumRegistersForCallingConv(), llvm::GlobalValue::getParent(), llvm::DataLayout::getPointerSize(), getReg(), llvm::TargetLoweringBase::getRegisterTypeForCallingConv(), llvm::MVT::getSizeInBits(), llvm::CallLowering::ValueHandler::getStackAddress(), llvm::MVT::getVectorNumElements(), llvm::MVT::getVT(), llvm::MVT::iPTR, llvm::CallLowering::ValueHandler::isIncomingArgumentHandler(), llvm::MVT::isValid(), llvm::LLT::isVector(), LLVM_DEBUG, llvm::makeArrayRef(), llvm::Align::None(), llvm::SmallVectorTemplateBase< T >::push_back(), Reg, llvm::LLT::scalar(), llvm::ISD::ArgFlagsTy::setOrigAlign(), llvm::ISD::ArgFlagsTy::setSplit(), llvm::ISD::ArgFlagsTy::setSplitEnd(), Size, and llvm::SmallVectorBase::size().
|
inlinevirtual |
This hook must be implemented to lower the given call instruction, including argument and return value marshalling.
Reimplemented in llvm::MipsCallLowering, llvm::AArch64CallLowering, llvm::ARMCallLowering, llvm::X86CallLowering, and llvm::RISCVCallLowering.
Definition at line 302 of file CallLowering.h.
References function.
Referenced by lowerCall().
| bool CallLowering::lowerCall | ( | MachineIRBuilder & | MIRBuilder, |
| ImmutableCallSite | CS, | ||
| ArrayRef< Register > | ResRegs, | ||
| ArrayRef< ArrayRef< Register >> | ArgRegs, | ||
| Register | SwiftErrorVReg, | ||
| std::function< unsigned()> | GetCalleeReg | ||
| ) | const |
Lower the given call instruction, including argument and return value marshalling.
CI is the call/invoke instruction.
ResRegs are the registers where the call's return value should be stored (or 0 if there is no return value). There will be one register for each non-aggregate type, as returned by computeValueLLTs.
ArgRegs is a list of lists of virtual registers containing each argument that needs to be passed (argument i should be placed in ArgRegs[i]). For each argument, there will be one register for each non-aggregate type, as returned by computeValueLLTs.
SwiftErrorVReg is non-zero if the call has a swifterror inout parameter, and contains the vreg that the swifterror should be copied into after the call.
GetCalleeReg is a callback to materialize a register for the callee if the target determines it cannot jump to the destination based purely on CI. This might be because CI is indirect, or because of the limited range of an immediate jump.
Definition at line 32 of file CallLowering.cpp.
References Arg, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::args(), llvm::CallLowering::CallLoweringInfo::CallConv, llvm::CallLowering::CallLoweringInfo::Callee, llvm::MachineOperand::CreateGA(), llvm::MachineOperand::CreateReg(), F(), llvm::AttributeList::FirstArgIndex, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getCallingConv(), llvm::Module::getDataLayout(), llvm::Function::getFnAttribute(), llvm::MachineFunction::getFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getFunctionType(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getInstruction(), llvm::Instruction::getMetadata(), llvm::MachineIRBuilder::getMF(), llvm::FunctionType::getNumParams(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::MachineFunction::getTarget(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getType(), llvm::Attribute::getValueAsString(), Info, llvm::isInTailCallPosition(), llvm::CallLowering::CallLoweringInfo::IsMustTailCall, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::isMustTailCall(), llvm::CallLowering::CallLoweringInfo::IsTailCall, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::isTailCall(), llvm::CallLowering::CallLoweringInfo::IsVarArg, llvm::FunctionType::isVarArg(), llvm::Type::isVoidTy(), llvm::CallLowering::CallLoweringInfo::KnownCallees, lowerCall(), NumFixedArgs, llvm::CallLowering::CallLoweringInfo::OrigArgs, llvm::CallLowering::CallLoweringInfo::OrigRet, llvm::AttributeList::ReturnIndex, setArgFlags(), llvm::CallLowering::CallLoweringInfo::SwiftErrorVReg, and llvm::CallLowering::ArgInfo::Ty.
|
inlinevirtual |
This hook must be implemented to lower the incoming (formal) arguments, described by VRegs, for GlobalISel.
Each argument must end up in the related virtual registers described by VRegs. In other words, the first argument should end up in VRegs[0], the second in VRegs[1], and so on. For each argument, there will be one register for each non-aggregate type, as returned by computeValueLLTs. MIRBuilder is set to the proper insertion for the argument lowering.
Reimplemented in llvm::MipsCallLowering, llvm::AMDGPUCallLowering, llvm::AArch64CallLowering, llvm::ARMCallLowering, llvm::X86CallLowering, and llvm::RISCVCallLowering.
Definition at line 291 of file CallLowering.h.
|
inlinevirtual |
This hook must be implemented to lower outgoing return values, described by Val, into the specified virtual registers VRegs.
This hook is used by GlobalISel.
SwiftErrorVReg is non-zero if the function has a swifterror parameter that needs to be implicitly returned.
Reimplemented in llvm::AArch64CallLowering.
Definition at line 264 of file CallLowering.h.
References assert(), and supportSwiftError().
|
inlinevirtual |
This hook behaves as the extended lowerReturn function, but for targets that do not support swifterror value promotion.
Reimplemented in llvm::MipsCallLowering, llvm::AMDGPUCallLowering, llvm::ARMCallLowering, llvm::X86CallLowering, and llvm::RISCVCallLowering.
Definition at line 276 of file CallLowering.h.
|
protected |
Generate instructions for packing SrcRegs into one big register corresponding to the aggregate type PackedTy.
| SrcRegs | should contain one virtual register for each base type in PackedTy, as returned by computeValueLLTs. |
Definition at line 130 of file CallLowering.cpp.
References assert(), llvm::MachineIRBuilder::buildInsert(), llvm::MachineIRBuilder::buildUndef(), llvm::computeValueLLTs(), llvm::MachineRegisterInfo::createGenericVirtualRegister(), llvm::MachineFunction::getDataLayout(), llvm::getLLTForType(), llvm::MachineIRBuilder::getMF(), llvm::MachineIRBuilder::getMRI(), MRI, llvm::SmallVectorBase::size(), and llvm::ArrayRef< T >::size().
Referenced by getTLI().
|
protected |
Info is the CallLoweringInfo for the call. MF is the MachineFunction for the caller. InArgs contains the results of the call. CalleeAssignFnFixed is the CCAssignFn to be used for the callee for fixed arguments. CalleeAssignFnVarArg is similar, but for varargs. CallerAssignFnFixed is the CCAssignFn to be used for the caller for fixed arguments. CallerAssignFnVarArg is similar, but for varargs.
Definition at line 400 of file CallLowering.cpp.
References analyzeArgInfo(), llvm::CallLowering::CallLoweringInfo::CallConv, llvm::numbers::e, F(), llvm::Function::getCallingConv(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::CCValAssign::getLocMemOffset(), llvm::CCValAssign::getLocReg(), llvm::CCValAssign::isRegLoc(), and llvm::SmallVectorBase::size().
Referenced by getAssignFnsForCC(), and getTLI().
|
protected |
Definition at line 78 of file CallLowering.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, Arg, llvm::AMDGPU::HSAMD::Kernel::Key::Attrs, llvm::CallLowering::ArgInfo::Flags, llvm::DataLayout::getABITypeAlignment(), llvm::AttributeList::getAttribute(), llvm::TargetLoweringBase::getByValTypeAlignment(), getTLI(), llvm::DataLayout::getTypeAllocSize(), llvm::Attribute::getValueAsType(), llvm::AttributeList::hasAttribute(), and llvm::CallLowering::ArgInfo::Ty.
Referenced by getTLI(), isSupportedType(), lowerCall(), llvm::X86CallLowering::lowerFormalArguments(), llvm::ARMCallLowering::lowerFormalArguments(), llvm::AArch64CallLowering::lowerFormalArguments(), llvm::AMDGPUCallLowering::lowerFormalArguments(), llvm::MipsCallLowering::lowerFormalArguments(), llvm::X86CallLowering::lowerReturn(), llvm::AArch64CallLowering::lowerReturn(), llvm::MipsCallLowering::lowerReturn(), and unpackRegsToOrigType().
|
inlinevirtual |
Reimplemented in llvm::AArch64CallLowering.
Definition at line 252 of file CallLowering.h.
Referenced by lowerReturn().
|
protected |
Generate instructions for unpacking SrcReg into the DstRegs corresponding to the aggregate type PackedTy.
| DstRegs | should contain one virtual register for each base type in PackedTy, as returned by computeValueLLTs. |
Definition at line 155 of file CallLowering.cpp.
References assert(), llvm::MachineIRBuilder::buildExtract(), llvm::computeValueLLTs(), llvm::MachineFunction::getDataLayout(), llvm::MachineIRBuilder::getMF(), llvm::SmallVectorBase::size(), and llvm::ArrayRef< T >::size().
Referenced by getTLI(), and llvm::AMDGPUCallLowering::lowerFormalArgumentsKernel().
1.8.13