53 bool X86CallLowering::splitToValueTypes(
const ArgInfo &OrigArg,
57 SplitArgTy PerformArgSplit)
const {
64 assert(OrigArg.
Regs.size() == 1 &&
"Can't handle multple regs yet");
84 for (
unsigned i = 0; i < NumParts; ++i) {
87 PartTy, OrigArg.
Flags};
92 PerformArgSplit(SplitRegs);
105 bool isIncomingArgumentHandler()
const override {
return false; }
112 MIRBuilder.
buildCopy(SPReg, STI.getRegisterInfo()->getStackRegister());
135 unsigned PhysRegSize =
139 if (PhysRegSize > ValSize && LocSize == ValSize) {
140 assert((PhysRegSize == 128 || PhysRegSize == 80) &&
"We expect that to be 128 bit");
144 ExtReg = extendRegister(ValVReg, VA);
151 Register ExtReg = extendRegister(ValVReg, VA);
158 bool assignArg(
unsigned ValNo,
MVT ValVT,
MVT LocVT,
162 bool Res = AssignFn(ValNo, ValVT, LocVT, LocInfo, Flags, State);
165 static const MCPhysReg XMMArgRegs[] = {X86::XMM0, X86::XMM1, X86::XMM2,
166 X86::XMM3, X86::XMM4, X86::XMM5,
167 X86::XMM6, X86::XMM7};
174 uint64_t getStackSize() {
return StackSize; }
175 uint64_t getNumXmmRegs() {
return NumXMMRegs; }
179 uint64_t StackSize = 0;
182 unsigned NumXMMRegs = 0;
191 "Return value without a vreg");
194 if (!VRegs.
empty()) {
205 "For each split Type there should be exactly one VReg.");
208 for (
unsigned i = 0; i < SplitEVTs.size(); ++i) {
209 ArgInfo CurArgInfo =
ArgInfo{VRegs[i], SplitEVTs[i].getTypeForEVT(Ctx)};
211 if (!splitToValueTypes(CurArgInfo, SplitArgs, DL, MRI,
218 OutgoingValueHandler Handler(MIRBuilder, MRI, MIB,
RetCC_X86);
235 bool isIncomingArgumentHandler()
const override {
return true; }
254 MIRBuilder.
buildLoad(ValVReg, Addr, *MMO);
259 markPhysRegUsed(PhysReg);
269 unsigned PhysRegSize =
273 if (PhysRegSize > ValSize && LocSize == ValSize) {
282 case CCValAssign::LocInfo::SExt:
283 case CCValAssign::LocInfo::ZExt:
284 case CCValAssign::LocInfo::AExt: {
295 virtual void markPhysRegUsed(
unsigned PhysReg) = 0;
301 struct FormalArgHandler :
public IncomingValueHandler {
304 : IncomingValueHandler(MIRBuilder, MRI, AssignFn) {}
306 void markPhysRegUsed(
unsigned PhysReg)
override {
312 struct CallReturnHandler :
public IncomingValueHandler {
315 : IncomingValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {}
317 void markPhysRegUsed(
unsigned PhysReg)
override {
346 if (
Arg.hasAttribute(Attribute::ByVal) ||
347 Arg.hasAttribute(Attribute::InReg) ||
348 Arg.hasAttribute(Attribute::StructRet) ||
349 Arg.hasAttribute(Attribute::SwiftSelf) ||
350 Arg.hasAttribute(Attribute::SwiftError) ||
351 Arg.hasAttribute(Attribute::Nest) || VRegs[Idx].size() > 1)
356 if (!splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
368 FormalArgHandler Handler(MIRBuilder, MRI,
CC_X86);
393 unsigned AdjStackDown = TII.getCallFrameSetupOpcode();
394 auto CallSeqStart = MIRBuilder.
buildInstr(AdjStackDown);
400 ? (Is64Bit ? X86::CALL64r : X86::CALL32r)
401 : (Is64Bit ? X86::CALL64pcrel32 : X86::CALLpcrel32);
408 for (
const auto &OrigArg : Info.
OrigArgs) {
411 if (OrigArg.
Flags[0].isByVal())
414 if (OrigArg.
Regs.size() > 1)
417 if (!splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
424 OutgoingValueHandler Handler(MIRBuilder, MRI, MIB,
CC_X86);
440 .
addImm(Handler.getNumXmmRegs());
467 if (!splitToValueTypes(Info.
OrigRet, SplitArgs, DL, MRI,
469 NewRegs.assign(Regs.begin(), Regs.end());
473 CallReturnHandler Handler(MIRBuilder, MRI,
RetCC_X86, MIB);
477 if (!NewRegs.
empty())
481 CallSeqStart.
addImm(Handler.getStackSize())
485 unsigned AdjStackUp = TII.getCallFrameDestroyOpcode();
487 .
addImm(Handler.getStackSize())
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set, or Regs.size() if they are all allocated.
virtual MachineInstrBuilder buildConstant(const DstOp &Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
bool is64Bit() const
Is this x86_64? (disregarding specific ABI / programming model)
const MachineInstrBuilder & add(const MachineOperand &MO) const
A parsed version of the target data layout string in and methods for querying it. ...
reference emplace_back(ArgTypes &&... Args)
MachineOperand Callee
Destination of the call.
static LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
MachineInstrBuilder buildUnmerge(ArrayRef< LLT > Res, const SrcOp &Op)
Build and insert Res0, ...
unsigned constrainOperandRegClass(const MachineFunction &MF, const TargetRegisterInfo &TRI, MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const RegisterBankInfo &RBI, MachineInstr &InsertPt, const TargetRegisterClass &RegClass, const MachineOperand &RegMO, unsigned OpIdx)
Constrain the Register operand OpIdx, so that it is now constrained to the TargetRegisterClass passed...
The C convention as specified in the x86-64 supplement to the System V ABI, used on most non-Windows ...
This class represents lattice values for constants.
const X86InstrInfo * getInstrInfo() const override
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
void push_back(const T &Elt)
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 assigne...
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
MachineInstrBuilder buildPtrAdd(const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
Build and insert Res = G_PTR_ADD Op0, Op1.
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...
bool lowerCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info) const override
This hook must be implemented to lower the given call instruction, including argument and return valu...
C - The default llvm calling convention, compatible with C.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
virtual const RegisterBankInfo * getRegBankInfo() const
If the information for the register banks is available, return it.
unsigned const TargetRegisterInfo * TRI
block Block Frequency true
bool CC_X86(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
SmallVector< ISD::ArgFlagsTy, 4 > Flags
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
MachineInstrBuilder buildAnyExt(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_ANYEXT Op0.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
const HexagonInstrInfo * TII
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This file contains the simple types necessary to represent the attributes associated with functions a...
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
LocInfo getLocInfo() const
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
unsigned getNextStackOffset() const
getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment r...
Type * getType() const
All values are typed, get the type of this value.
bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< Register > VRegs) const override
This hook behaves as the extended lowerReturn function, but for targets that do not support swifterro...
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
MachineFunction & getMF()
Getter for the function we currently build.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void setReg(Register Reg)
Change the register this operand corresponds to.
virtual const TargetInstrInfo * getInstrInfo() const
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
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...
Analysis containing CSE Info
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
TargetInstrInfo - Interface to description of machine instruction set.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
bool isVoidTy() const
Return true if this is 'void'.
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
MachineRegisterInfo * getMRI()
Getter for MRI.
const TargetRegisterInfo * getTargetRegisterInfo() const
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
Helper class to build MachineInstr.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
MachineInstrBuilder buildCopy(const DstOp &Res, const SrcOp &Op)
Build and insert Res = COPY Op.
MachineInstrBuilder buildTrunc(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_TRUNC Op.
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.
The memory access writes data.
SmallVector< ArgInfo, 8 > OrigArgs
List of descriptors of the arguments passed to the function.
const X86RegisterInfo * getRegisterInfo() const override
MachineInstrBuilder buildLoad(const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert Res = G_LOAD Addr, MMO.
CCState - This class holds information needed while lowering arguments and return values...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
CCValAssign - Represent assignment of one arg/retval to a location.
MachineInstrBuilder buildFrameIndex(const DstOp &Res, int Idx)
Build and insert Res = G_FRAME_INDEX Idx.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
bool RetCC_X86(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
This file declares the MachineIRBuilder class.
This file describes how to lower LLVM calls to machine code calls.
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.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
CallingConv::ID CallConv
Calling convention to be used for the call.
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
The memory access always returns the same value (or traps).
MachineInstrBuilder buildStore(const SrcOp &Val, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Return the number of registers that this ValueType will eventually require.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
bool isTargetLinux() const
bool isCallingConvWin64(CallingConv::ID CC) const
X86CallLowering(const X86TargetLowering &TLI)
MachineInstrBuilder buildMerge(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_MERGE_VALUES Op0, ...
SmallVector< Register, 4 > Regs
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< ArrayRef< Register >> VRegs) const override
This hook must be implemented to lower the incoming (formal) arguments, described by VRegs...
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
ArgInfo OrigRet
Descriptor for the return type of the function.
iterator_range< arg_iterator > args()
Wrapper class representing virtual and physical registers.
bool empty() const
empty - Check if the array is empty.