LLVM  8.0.1
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 lowerReturn (MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< unsigned > VRegs) const
 This hook must be implemented to lower outgoing return values, described by Val, into the specified virtual registers VRegs. More...
 
virtual bool lowerFormalArguments (MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< unsigned > VRegs) const
 This hook must be implemented to lower the incoming (formal) arguments, described by Args, for GlobalISel. More...
 
virtual bool lowerCall (MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv, const MachineOperand &Callee, const ArgInfo &OrigRet, ArrayRef< ArgInfo > OrigArgs) 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, unsigned ResReg, ArrayRef< unsigned > ArgRegs, 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
 
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...
 

Detailed Description

Definition at line 40 of file CallLowering.h.

Constructor & Destructor Documentation

◆ CallLowering()

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

Definition at line 141 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 119 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 125 of file CallLowering.h.

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

◆ handleAssignments()

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

◆ lowerCall() [1/2]

virtual bool llvm::CallLowering::lowerCall ( MachineIRBuilder MIRBuilder,
CallingConv::ID  CallConv,
const MachineOperand Callee,
const ArgInfo OrigRet,
ArrayRef< ArgInfo OrigArgs 
) 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.

ResTy is the type returned by the function

ResReg is the generic virtual register that the returned value should be lowered into.

ArgTys is a list of the types each member of ArgRegs has; used by the target to decide which register/stack slot should be allocated.

ArgRegs is a list of virtual registers containing each argument that needs to be passed.

Returns
true if the lowering succeeded, false otherwise.

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

Definition at line 189 of file CallLowering.h.

References function.

Referenced by lowerCall().

◆ lowerCall() [2/2]

bool CallLowering::lowerCall ( MachineIRBuilder MIRBuilder,
ImmutableCallSite  CS,
unsigned  ResReg,
ArrayRef< unsigned ArgRegs,
std::function< unsigned()>  GetCalleeReg 
) const

Lower the given call instruction, including argument and return value marshalling.

CI is the call/invoke instruction.

ResReg is a register where the call's return value should be stored (or 0 if there is no return value).

ArgRegs is a list of virtual registers containing each argument that needs to be passed.

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 28 of file CallLowering.cpp.

References Arg, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, 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, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCallingConv(), llvm::Module::getDataLayout(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getFunctionType(), llvm::FunctionType::getNumParams(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::Value::getType(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, 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< unsigned VRegs 
) const
inlinevirtual

This hook must be implemented to lower the incoming (formal) arguments, described by Args, for GlobalISel.

Each argument must end up in the related virtual register described by VRegs. In other words, the first argument should end up in VRegs[0], the second in VRegs[1], and so on. MIRBuilder is set to the proper insertion for the argument lowering.

Returns
True if the lowering succeeded, false otherwise.

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

Definition at line 163 of file CallLowering.h.

◆ lowerReturn()

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

Returns
True if the lowering succeeds, false otherwise.

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

Definition at line 149 of file CallLowering.h.

◆ setArgFlags()

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

Definition at line 64 of file CallLowering.cpp.

References Arg, llvm::AMDGPU::HSAMD::Kernel::Key::Attrs, llvm::Attribute::ByVal, llvm::CallLowering::ArgInfo::Flags, llvm::DataLayout::getABITypeAlignment(), llvm::TargetLoweringBase::getByValTypeAlignment(), getTLI(), llvm::DataLayout::getTypeAllocSize(), llvm::AttributeList::hasAttribute(), llvm::Attribute::InAlloca, llvm::Attribute::InReg, llvm::ISD::ArgFlagsTy::isByVal(), llvm::ISD::ArgFlagsTy::isInAlloca(), llvm::Attribute::Nest, llvm::ISD::ArgFlagsTy::setByVal(), llvm::ISD::ArgFlagsTy::setByValAlign(), llvm::ISD::ArgFlagsTy::setByValSize(), llvm::ISD::ArgFlagsTy::setInAlloca(), llvm::ISD::ArgFlagsTy::setInReg(), llvm::ISD::ArgFlagsTy::setNest(), llvm::ISD::ArgFlagsTy::setOrigAlign(), llvm::ISD::ArgFlagsTy::setSExt(), llvm::ISD::ArgFlagsTy::setSRet(), llvm::ISD::ArgFlagsTy::setSwiftError(), llvm::ISD::ArgFlagsTy::setSwiftSelf(), llvm::ISD::ArgFlagsTy::setZExt(), llvm::Attribute::SExt, llvm::Attribute::StructRet, llvm::Attribute::SwiftError, llvm::Attribute::SwiftSelf, llvm::CallLowering::ArgInfo::Ty, and llvm::Attribute::ZExt.

Referenced by getTLI(), isSupportedType(), lowerCall(), llvm::X86CallLowering::lowerFormalArguments(), llvm::AMDGPUCallLowering::lowerFormalArguments(), llvm::ARMCallLowering::lowerFormalArguments(), llvm::AArch64CallLowering::lowerFormalArguments(), llvm::MipsCallLowering::lowerFormalArguments(), llvm::X86CallLowering::lowerReturn(), llvm::AArch64CallLowering::lowerReturn(), and llvm::MipsCallLowering::lowerReturn().


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