29 #ifndef LLVM_BUILD_GLOBAL_ISEL
30 #error "This shouldn't be built without GISel"
39 : ValueHandler(MIRBuilder, MRI) {}
43 auto &MFI = MIRBuilder.getMF().getFrameInfo();
44 int FI = MFI.CreateFixedObject(Size, Offset,
true);
46 unsigned AddrReg =
MRI.createGenericVirtualRegister(
LLT::pointer(0, 64));
47 MIRBuilder.buildFrameIndex(AddrReg, FI);
53 markPhysRegUsed(PhysReg);
54 MIRBuilder.buildCopy(ValVReg, PhysReg);
60 auto MMO = MIRBuilder.getMF().getMachineMemOperand(
63 MIRBuilder.buildLoad(ValVReg, Addr, *MMO);
69 virtual void markPhysRegUsed(
unsigned PhysReg) = 0;
77 MIRBuilder.getMBB().addLiveIn(PhysReg);
96 : ValueHandler(MIRBuilder, MRI), MIB(MIB) {}
102 unsigned SPReg =
MRI.createGenericVirtualRegister(p0);
103 MIRBuilder.buildCopy(SPReg, AArch64::SP);
105 unsigned OffsetReg =
MRI.createGenericVirtualRegister(s64);
106 MIRBuilder.buildConstant(OffsetReg, Offset);
108 unsigned AddrReg =
MRI.createGenericVirtualRegister(p0);
109 MIRBuilder.buildGEP(AddrReg, SPReg, OffsetReg);
118 unsigned ExtReg = extendRegister(ValVReg, VA);
119 MIRBuilder.buildCopy(PhysReg, ExtReg);
124 auto MMO = MIRBuilder.getMF().getMachineMemOperand(
126 MIRBuilder.buildStore(ValVReg, Addr, *MMO);
132 void AArch64CallLowering::splitToValueTypes(
const ArgInfo &OrigArg,
136 SplitArgTy PerformArgSplit)
const {
144 if (SplitVTs.
size() == 1) {
147 SplitArgs.
emplace_back(OrigArg.Reg, SplitVTs[0].getTypeForEVT(Ctx),
152 unsigned FirstRegIdx = SplitArgs.
size();
153 for (
auto SplitVT : SplitVTs) {
155 Type *SplitTy = SplitVT.getTypeForEVT(Ctx);
162 for (
auto Offset : Offsets)
166 for (
auto I = &SplitArgs[FirstRegIdx];
I != SplitArgs.
end(); ++
I)
169 PerformArgSplit(SplitRegs, BitOffsets);
173 const Value *Val,
unsigned VReg)
const {
178 assert(((Val && VReg) || (!Val && !VReg)) &&
"Return value without a vreg");
190 splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
214 for (
auto &Arg :
Args) {
215 ArgInfo OrigArg{VRegs[
i], Arg.getType()};
217 splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
231 FormalArgHandler Handler(MIRBuilder, MRI);
251 for (
auto &OrigArg : OrigArgs) {
252 splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
271 MIB.addRegMask(TRI->getCallPreservedMask(MF, F.
getCallingConv()));
300 splitToValueTypes(OrigRet, SplitArgs, DL, MRI,
302 std::copy(Offsets.
begin(), Offsets.
end(),
303 std::back_inserter(RegOffsets));
305 std::back_inserter(SplitRegs));
312 if (!RegOffsets.
empty())
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. ...
CCAssignFn * CCAssignFnForReturn(CallingConv::ID CC) const
Selects the correct CCAssignFn for a given CallingConvention value.
unsigned constrainOperandRegClass(const MachineFunction &MF, const TargetRegisterInfo &TRI, MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const RegisterBankInfo &RBI, MachineInstr &InsertPt, const MCInstrDesc &II, unsigned Reg, unsigned OpIdx)
Try to constrain Reg so that it is usable by argument OpIdx of the provided MCInstrDesc II...
OutgoingArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstrBuilder MIB)
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...
static const MCPhysReg VRegs[32]
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
bool lowerCall(MachineIRBuilder &MIRBuilder, const MachineOperand &Callee, const ArgInfo &OrigRet, ArrayRef< ArgInfo > OrigArgs) const override
This hook must be implemented to lower the given call instruction, including argument and return valu...
unsigned createGenericVirtualRegister(LLT Ty)
Create and return a new generic virtual register with low-level type Ty.
IncomingArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
virtual const RegisterBankInfo * getRegBankInfo() const
If the information for the register banks is available, return it.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
LLVM_NODISCARD bool empty() const
MachineInstrBuilder buildExtract(ArrayRef< unsigned > Results, ArrayRef< uint64_t > Indices, unsigned Src)
Build and insert `Res0<def>, ...
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
MachineFunction & getMF()
Getter for the function we currently build.
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...
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset)
Stack pointer relative access.
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.
void assignValueToAddress(unsigned ValVReg, unsigned Addr, uint64_t Size, MachinePointerInfo &MPO, CCValAssign &VA) override
The specified value has been assigned to a stack location.
const MachineOperand & getOperand(unsigned i) const
Helper class to build MachineInstr.
unsigned getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override
Materialize a VReg containing the address of the specified stack-based object.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
void markPhysRegUsed(unsigned PhysReg) override
How the physical register gets marked varies between formal parameters (it's a basic-block live-in)...
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...
The memory access writes data.
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...
MachineOperand class - Representation of each machine instruction operand.
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.
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...
This file declares the MachineIRBuilder class.
CCAssignFn * CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const
Selects the correct CCAssignFn for a given CallingConvention value.
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.
MachineInstrBuilder buildSequence(unsigned Res, ArrayRef< unsigned > Ops, ArrayRef< uint64_t > Indices)
Build and insert Res<def> = G_SEQUENCE Op0, Idx0...
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void emplace_back(ArgTypes &&...Args)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void assignValueToAddress(unsigned ValVReg, unsigned Addr, uint64_t Size, MachinePointerInfo &MPO, CCValAssign &VA) override
The specified value has been assigned to a stack location.
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
void setArgFlags(ArgInfo &Arg, unsigned OpNum, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
The memory access always returns the same value (or traps).
void assignValueToReg(unsigned ValVReg, unsigned PhysReg, CCValAssign &VA) override
The specified value has been assigned to a physical register, handle the appropriate COPY (either to ...
This file describes how to lower LLVM calls to machine code calls.
unsigned getReg() const
getReg - Returns the register number.
unsigned getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override
Materialize a VReg containing the address of the specified stack-based object.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual const TargetInstrInfo * getInstrInfo() const
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.
static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space (defaulting to 0).
const ArgumentListType & getArgumentList() const
Get the underlying elements of the Function...
const MachineInstrBuilder & addOperand(const MachineOperand &MO) const
AArch64CallLowering(const AArch64TargetLowering &TLI)
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool handleAssignments(MachineIRBuilder &MIRBuilder, CCAssignFn *AssignFn, ArrayRef< ArgInfo > Args, ValueHandler &Callback) const
Invoke the AssignFn on each of the given Args and then use Callback to move them to the assigned loca...
void assignValueToReg(unsigned ValVReg, unsigned PhysReg, CCValAssign &VA) override
The specified value has been assigned to a physical register, handle the appropriate COPY (either to ...
CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstrBuilder MIB)