30 #include "X86GenCallingConv.inc"
32 #ifndef LLVM_BUILD_GLOBAL_ISEL
33 #error "This shouldn't be built without GISel"
39 bool X86CallLowering::splitToValueTypes(
const ArgInfo &OrigArg,
43 SplitArgTy PerformArgSplit)
const {
52 if (SplitVTs.
size() != 1) {
63 OrigArg.Flags, OrigArg.IsFixed);
72 for (
unsigned i = 0; i < NumParts; ++i) {
75 PartTy, OrigArg.Flags};
80 PerformArgSplit(SplitRegs);
88 : ValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {}
90 unsigned getStackAddress(uint64_t
Size, int64_t
Offset,
95 void assignValueToReg(
unsigned ValVReg,
unsigned PhysReg,
98 unsigned ExtReg = extendRegister(ValVReg, VA);
99 MIRBuilder.buildCopy(PhysReg, ExtReg);
102 void assignValueToAddress(
unsigned ValVReg,
unsigned Addr, uint64_t
Size,
112 const Value *Val,
unsigned VReg)
const {
114 assert(((Val && VReg) || (!Val && !VReg)) &&
"Return value without a vreg");
128 if (!splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
134 FuncReturnHandler Handler(MIRBuilder, MRI, MIB, RetCC_X86);
147 : ValueHandler(MIRBuilder, MRI, AssignFn), DL(DL) {}
149 unsigned getStackAddress(uint64_t
Size, int64_t
Offset,
152 auto &MFI = MIRBuilder.getMF().getFrameInfo();
153 int FI = MFI.CreateFixedObject(Size, Offset,
true);
158 MIRBuilder.buildFrameIndex(AddrReg, FI);
162 void assignValueToAddress(
unsigned ValVReg,
unsigned Addr, uint64_t Size,
165 auto MMO = MIRBuilder.getMF().getMachineMemOperand(
168 MIRBuilder.buildLoad(ValVReg, Addr, *MMO);
171 void assignValueToReg(
unsigned ValVReg,
unsigned PhysReg,
173 MIRBuilder.getMBB().addLiveIn(PhysReg);
174 MIRBuilder.buildCopy(ValVReg, PhysReg);
197 for (
auto &Arg : F.
args()) {
200 if (Arg.hasAttribute(Attribute::ByVal) ||
201 Arg.hasAttribute(Attribute::InReg) ||
202 Arg.hasAttribute(Attribute::StructRet) ||
203 Arg.hasAttribute(Attribute::SwiftSelf) ||
204 Arg.hasAttribute(Attribute::SwiftError) ||
205 Arg.hasAttribute(Attribute::Nest))
208 ArgInfo OrigArg(VRegs[Idx], Arg.getType());
210 if (!splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
222 FormalArgHandler Handler(MIRBuilder, MRI, CC_X86, DL);
MachineBasicBlock & getMBB()
Getter for the basic block we currently build.
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Return the number of registers that this ValueType will eventually require.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change...
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< unsigned > VRegs) const override
This hook must be implemented to lower the incoming (formal) arguments, described by Args...
static const MCPhysReg VRegs[32]
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
unsigned createGenericVirtualRegister(LLT Ty)
Create and return a new generic virtual register with low-level type Ty.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
MachineFunction & getMF()
Getter for the function we currently build.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
bool lowerReturn(MachineIRBuilder &MIRBuiler, const Value *Val, unsigned VReg) const override
This hook must be implemented to lower outgoing return values, described by Val, into the specified v...
unsigned const MachineRegisterInfo * MRI
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
Helper class to build MachineInstr.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
Argument handling is mostly uniform between the four places that make these decisions: function forma...
This class contains a discriminated union of information about pointers in memory operands...
LLT getLLTForType(Type &Ty, const DataLayout &DL)
Construct a low-level type based on an LLVM type.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
CCValAssign - Represent assignment of one arg/retval to a location.
This file declares the MachineIRBuilder class.
This file describes how to lower LLVM calls to machine code calls.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
void emplace_back(ArgTypes &&...Args)
bool handleAssignments(MachineIRBuilder &MIRBuilder, ArrayRef< ArgInfo > Args, ValueHandler &Callback) const
Invoke Handler::assignArg on each of the given Args and then use Callback to move them to the assigne...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
void setArgFlags(ArgInfo &Arg, unsigned OpNum, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
The memory access always returns the same value (or traps).
MachineInstrBuilder buildUnmerge(ArrayRef< unsigned > Res, unsigned Op)
Build and insert Res0<def>, ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
LLVM Value Representation.
static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space (defaulting to 0).
X86CallLowering(const X86TargetLowering &TLI)
MachineInstrBuilder buildMerge(unsigned Res, ArrayRef< unsigned > Ops)
Build and insert Res<def> = G_MERGE_VALUES Op0, ...
iterator_range< arg_iterator > args()