63 auto StructT = cast<StructType>(
T);
64 for (
unsigned i = 1,
e = StructT->getNumElements(); i !=
e; ++i)
65 if (StructT->getElementType(i) != StructT->getElementType(0))
71 if (!VT.isSimple() || VT.isVector() ||
72 !(VT.isInteger() || VT.isFloatingPoint()))
79 return VT.isFloatingPoint();
81 return VTSize == 1 || VTSize == 8 || VTSize == 16 || VTSize == 32;
91 : ValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {}
93 bool isIncomingArgumentHandler()
const override {
return false; }
97 assert((Size == 1 || Size == 2 || Size == 4 || Size == 8) &&
123 Register ExtReg = extendRegister(ValVReg, VA);
130 assert((Size == 1 || Size == 2 || Size == 4 || Size == 8) &&
133 Register ExtReg = extendRegister(ValVReg, VA);
142 assert(Arg.
Regs.size() == 1 &&
"Can't handle multple regs yet");
145 assert(VA.needsCustom() &&
"Value doesn't need custom handling");
149 assert(NextVA.needsCustom() &&
"Value doesn't need custom handling");
152 assert(VA.getValNo() == NextVA.getValNo() &&
153 "Values belong to different arguments");
155 assert(VA.isRegLoc() &&
"Value should be in reg");
156 assert(NextVA.isRegLoc() &&
"Value should be in reg");
166 assignValueToReg(NewRegs[0], VA.getLocReg(), VA);
167 assignValueToReg(NewRegs[1], NextVA.getLocReg(), NextVA);
172 bool assignArg(
unsigned ValNo,
MVT ValVT,
MVT LocVT,
176 if (AssignFn(ValNo, ValVT, LocVT, LocInfo, Flags, State))
185 uint64_t StackSize = 0;
190 void ARMCallLowering::splitToValueTypes(
const ArgInfo &OrigArg,
200 assert(OrigArg.Regs.size() == SplitVTs.
size() &&
"Regs / types mismatch");
202 if (SplitVTs.
size() == 1) {
205 auto Flags = OrigArg.Flags[0];
207 SplitArgs.
emplace_back(OrigArg.Regs[0], SplitVTs[0].getTypeForEVT(Ctx),
208 Flags, OrigArg.IsFixed);
213 for (
unsigned i = 0,
e = SplitVTs.
size(); i !=
e; ++i) {
214 EVT SplitVT = SplitVTs[i];
216 auto Flags = OrigArg.Flags[0];
220 bool NeedsConsecutiveRegisters =
223 if (NeedsConsecutiveRegisters) {
224 Flags.setInConsecutiveRegs();
226 Flags.setInConsecutiveRegsLast();
231 SplitArgs.
emplace_back(PartReg, SplitTy, Flags, OrigArg.IsFixed);
244 auto &MF = MIRBuilder.
getMF();
248 auto &TLI = *getTLI<ARMTargetLowering>();
252 ArgInfo OrigRetInfo(VRegs, Val->
getType());
256 splitToValueTypes(OrigRetInfo, SplitRetInfos, MF);
259 TLI.CCAssignFnForReturn(
F.getCallingConv(),
F.isVarArg());
261 OutgoingValueHandler RetHandler(MIRBuilder, MF.
getRegInfo(),
Ret, AssignFn);
268 assert(!Val == VRegs.
empty() &&
"Return value without a vreg");
274 if (!lowerReturnVal(MIRBuilder, Val, VRegs, Ret))
290 bool isIncomingArgumentHandler()
const override {
return true; }
294 assert((Size == 1 || Size == 2 || Size == 4 || Size == 8) &&
311 assert((Size == 1 || Size == 2 || Size == 4 || Size == 8) &&
322 buildLoad(LoadVReg, Addr, Size, 1, MPO);
326 buildLoad(ValVReg, Addr, Size, 1, MPO);
330 void buildLoad(
Register Val,
Register Addr, uint64_t Size,
unsigned Alignment,
345 assert(ValSize <= 64 &&
"Unsupported value size");
346 assert(LocSize <= 64 &&
"Unsupported location size");
348 markPhysRegUsed(PhysReg);
349 if (ValSize == LocSize) {
352 assert(ValSize < LocSize &&
"Extensions not supported");
359 MIRBuilder.
buildCopy(PhysRegToVReg, PhysReg);
360 MIRBuilder.
buildTrunc(ValVReg, PhysRegToVReg);
366 assert(Arg.
Regs.size() == 1 &&
"Can't handle multple regs yet");
369 assert(VA.needsCustom() &&
"Value doesn't need custom handling");
373 assert(NextVA.needsCustom() &&
"Value doesn't need custom handling");
376 assert(VA.getValNo() == NextVA.getValNo() &&
377 "Values belong to different arguments");
379 assert(VA.isRegLoc() &&
"Value should be in reg");
380 assert(NextVA.isRegLoc() &&
"Value should be in reg");
385 assignValueToReg(NewRegs[0], VA.getLocReg(), VA);
386 assignValueToReg(NewRegs[1], NextVA.getLocReg(), NextVA);
400 virtual void markPhysRegUsed(
unsigned PhysReg) = 0;
403 struct FormalArgHandler :
public IncomingValueHandler {
406 : IncomingValueHandler(MIRBuilder, MRI, AssignFn) {}
408 void markPhysRegUsed(
unsigned PhysReg)
override {
419 auto &TLI = *getTLI<ARMTargetLowering>();
420 auto Subtarget = TLI.getSubtarget();
422 if (Subtarget->isThumb1Only())
432 auto &MF = MIRBuilder.
getMF();
433 auto &MBB = MIRBuilder.
getMBB();
439 if (
Arg.hasByValOrInAllocaAttr())
446 FormalArgHandler ArgHandler(MIRBuilder, MIRBuilder.
getMF().
getRegInfo(),
452 ArgInfo OrigArgInfo(VRegs[Idx],
Arg.getType());
455 splitToValueTypes(OrigArgInfo, SplitArgInfos, MF);
473 struct CallReturnHandler :
public IncomingValueHandler {
476 : IncomingValueHandler(MIRBuilder, MRI, AssignFn), MIB(MIB) {}
478 void markPhysRegUsed(
unsigned PhysReg)
override {
499 return ARM::BMOVPCRX_CALL;
505 const auto &TLI = *getTLI<ARMTargetLowering>();
511 if (STI.genLongCalls())
514 if (STI.isThumb1Only())
517 auto CallSeqStart = MIRBuilder.
buildInstr(ARM::ADJCALLSTACKDOWN);
525 bool IsThumb = STI.isThumb();
533 unsigned CalleeIdx = IsThumb ? 2 : 0;
535 MF, *TRI, MRI, *STI.getInstrInfo(), *STI.getRegBankInfo(),
536 *MIB.getInstr(), MIB->getDesc(), Info.
Callee, CalleeIdx));
540 MIB.addRegMask(TRI->getCallPreservedMask(MF, Info.
CallConv));
542 bool IsVarArg =
false;
551 if (
Arg.Flags[0].isByVal())
554 splitToValueTypes(
Arg, ArgInfos, MF);
557 auto ArgAssignFn = TLI.CCAssignFnForCall(Info.
CallConv, IsVarArg);
558 OutgoingValueHandler ArgHandler(MIRBuilder, MRI, MIB, ArgAssignFn);
570 splitToValueTypes(Info.
OrigRet, ArgInfos, MF);
571 auto RetAssignFn = TLI.CCAssignFnForReturn(Info.
CallConv, IsVarArg);
572 CallReturnHandler RetHandler(MIRBuilder, MRI, MIB, RetAssignFn);
579 CallSeqStart.addImm(ArgHandler.StackSize).addImm(0).add(
predOps(
ARMCC::AL));
582 .
addImm(ArgHandler.StackSize)
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.
virtual MachineInstrBuilder buildConstant(const DstOp &Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
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)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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...
This class represents lattice values for constants.
Register getLocReg() const
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
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.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
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...
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
unsigned const TargetRegisterInfo * TRI
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...
unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
static unsigned getCallOpcode(const Function &CallerF, bool IsIndirect, bool IsTailCall)
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
ARMCallLowering(const ARMTargetLowering &TLI)
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.
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
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)...
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.
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.
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.
Helper class to build MachineInstr.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
bool lowerCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info) const override
This hook must be implemented to lower the given call instruction, including argument and return valu...
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.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
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...
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
The memory access writes data.
SmallVector< ArgInfo, 8 > OrigArgs
List of descriptors of the arguments passed to the function.
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...
Align max(MaybeAlign Lhs, Align Rhs)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
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.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Promote Memory to Register
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
This file declares the MachineIRBuilder class.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
unsigned getReturnOpcode() const
Returns the correct return opcode for the current feature set.
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.
CallingConv::ID CallConv
Calling convention to be used for the call.
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
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...
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
MachineInstrBuilder buildStore(const SrcOp &Val, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
static bool isSupportedType(const DataLayout &DL, const ARMTargetLowering &TLI, Type *T)
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.
LLVM Value Representation.
bool functionArgumentNeedsConsecutiveRegisters(Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override
Returns true if an argument of type Ty needs to be passed in a contiguous block of registers in calli...
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.
Type * getArrayElementType() const
This file describes how to lower LLVM calls to machine code calls.
Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
Register getReg() const
getReg - Returns the register number.
ArgInfo OrigRet
Descriptor for the return type of the function.
iterator_range< arg_iterator > args()
Wrapper class representing virtual and physical registers.
bool isStructTy() const
True if this is an instance of StructType.
bool empty() const
empty - Check if the array is empty.
bool isArrayTy() const
True if this is an instance of ArrayType.