LLVM  10.0.0svn
Classes | Public Member Functions | Protected Member Functions | List of all members
llvm::CallLowering Class Reference

#include "llvm/CodeGen/GlobalISel/CallLowering.h"

Inheritance diagram for llvm::CallLowering:
Inheritance graph
[legend]

Classes

struct  ArgInfo
 
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, CallingConv::ID CallConv, const MachineOperand &Callee, const ArgInfo &OrigRet, ArrayRef< ArgInfo > OrigArgs, Register SwiftErrorVReg) const
 This hook must be implemented to lower the given call instruction, including argument and return value marshalling. More...
 
virtual bool lowerCall (MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv, const MachineOperand &Callee, const ArgInfo &OrigRet, ArrayRef< ArgInfo > OrigArgs) const
 This hook behaves as the extended lowerCall function, but for targets that do not support swifterror value promotion. 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 TargetLoweringgetTLI () 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, ArrayRef< 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, ArrayRef< ArgInfo > Args, ValueHandler &Handler) const
 

Detailed Description

Definition at line 41 of file CallLowering.h.

Constructor & Destructor Documentation

◆ CallLowering()

llvm::CallLowering::CallLowering ( const TargetLowering TLI)
inline

Definition at line 172 of file CallLowering.h.

References ~CallLowering().

◆ ~CallLowering()

virtual llvm::CallLowering::~CallLowering ( )
virtualdefault

Referenced by CallLowering().

Member Function Documentation

◆ getTLI() [1/2]

const TargetLowering* llvm::CallLowering::getTLI ( ) const
inlineprotected

Getter for generic TargetLowering class.

Definition at line 129 of file CallLowering.h.

Referenced by setArgFlags().

◆ getTLI() [2/2]

template<class XXXTargetLowering >
const XXXTargetLowering* llvm::CallLowering::getTLI ( ) const
inlineprotected

Getter for target specific TargetLowering class.

Definition at line 135 of file CallLowering.h.

References Arg, llvm::AMDGPU::HSAMD::Kernel::Key::Args, handleAssignments(), packRegs(), setArgFlags(), and unpackRegs().

◆ handleAssignments() [1/2]

bool CallLowering::handleAssignments ( MachineIRBuilder MIRBuilder,
ArrayRef< ArgInfo Args,
ValueHandler Handler 
) const
protected

◆ handleAssignments() [2/2]

bool CallLowering::handleAssignments ( CCState CCState,
SmallVectorImpl< CCValAssign > &  ArgLocs,
MachineIRBuilder MIRBuilder,
ArrayRef< ArgInfo Args,
ValueHandler Handler 
) const
protected

◆ lowerCall() [1/3]

virtual bool llvm::CallLowering::lowerCall ( MachineIRBuilder MIRBuilder,
CallingConv::ID  CallConv,
const MachineOperand Callee,
const ArgInfo OrigRet,
ArrayRef< ArgInfo OrigArgs,
Register  SwiftErrorVReg 
) const
inlinevirtual

This hook must be implemented to lower the given call instruction, including argument and return value marshalling.

CallConv is the calling convention to be used for the call.

Callee is the destination of the call. It should be either a register, globaladdress, or externalsymbol.

OrigRet is a descriptor for the return type of the function.

OrigArgs is a list of descriptors of the arguments passed to the function.

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.

Returns
true if the lowering succeeded, false otherwise.

Reimplemented in llvm::AArch64CallLowering.

Definition at line 241 of file CallLowering.h.

References assert(), and supportSwiftError().

Referenced by lowerCall().

◆ lowerCall() [2/3]

virtual bool llvm::CallLowering::lowerCall ( MachineIRBuilder MIRBuilder,
CallingConv::ID  CallConv,
const MachineOperand Callee,
const ArgInfo OrigRet,
ArrayRef< ArgInfo OrigArgs 
) const
inlinevirtual

This hook behaves as the extended lowerCall function, but for targets that do not support swifterror value promotion.

Reimplemented in llvm::MipsCallLowering, llvm::AArch64CallLowering, llvm::ARMCallLowering, and llvm::X86CallLowering.

Definition at line 254 of file CallLowering.h.

References function, and lowerCall().

◆ lowerCall() [3/3]

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.

Returns
true if the lowering succeeded, false otherwise.

Definition at line 30 of file CallLowering.cpp.

References Arg, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::args(), Callee, llvm::MachineOperand::CreateGA(), llvm::MachineOperand::CreateImm(), 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::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getFunctionType(), llvm::FunctionType::getNumParams(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getType(), lowerCall(), NumFixedArgs, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::AttributeList::ReturnIndex, and setArgFlags().

◆ lowerFormalArguments()

virtual bool llvm::CallLowering::lowerFormalArguments ( MachineIRBuilder MIRBuilder,
const Function F,
ArrayRef< ArrayRef< Register >>  VRegs 
) const
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.

Returns
True if the lowering succeeded, false otherwise.

Reimplemented in llvm::MipsCallLowering, llvm::AMDGPUCallLowering, llvm::AArch64CallLowering, llvm::ARMCallLowering, and llvm::X86CallLowering.

Definition at line 217 of file CallLowering.h.

◆ lowerReturn() [1/2]

virtual bool llvm::CallLowering::lowerReturn ( MachineIRBuilder MIRBuilder,
const Value Val,
ArrayRef< Register VRegs,
Register  SwiftErrorVReg 
) const
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.

Returns
True if the lowering succeeds, false otherwise.

Reimplemented in llvm::AArch64CallLowering.

Definition at line 190 of file CallLowering.h.

References assert(), and supportSwiftError().

◆ lowerReturn() [2/2]

virtual bool llvm::CallLowering::lowerReturn ( MachineIRBuilder MIRBuilder,
const Value Val,
ArrayRef< Register VRegs 
) const
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, and llvm::X86CallLowering.

Definition at line 202 of file CallLowering.h.

◆ packRegs()

Register CallLowering::packRegs ( ArrayRef< Register SrcRegs,
Type PackedTy,
MachineIRBuilder MIRBuilder 
) const
protected

Generate instructions for packing SrcRegs into one big register corresponding to the aggregate type PackedTy.

Parameters
SrcRegsshould contain one virtual register for each base type in PackedTy, as returned by computeValueLLTs.
Returns
The packed register.

Definition at line 120 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().

◆ setArgFlags()

template<typename FuncInfoTy >
template void CallLowering::setArgFlags< CallInst > ( ArgInfo Arg,
unsigned  OpIdx,
const DataLayout DL,
const FuncInfoTy &  FuncInfo 
) const
protected

◆ supportSwiftError()

virtual bool llvm::CallLowering::supportSwiftError ( ) const
inlinevirtual
Returns
true if the target is capable of handling swifterror values that have been promoted to a specified register. The extended versions of lowerReturn and lowerCall should be implemented.

Reimplemented in llvm::AArch64CallLowering.

Definition at line 178 of file CallLowering.h.

Referenced by lowerCall(), and lowerReturn().

◆ unpackRegs()

void CallLowering::unpackRegs ( ArrayRef< Register DstRegs,
Register  SrcReg,
Type PackedTy,
MachineIRBuilder MIRBuilder 
) const
protected

Generate instructions for unpacking SrcReg into the DstRegs corresponding to the aggregate type PackedTy.

Parameters
DstRegsshould contain one virtual register for each base type in PackedTy, as returned by computeValueLLTs.

Definition at line 145 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().


The documentation for this class was generated from the following files: