LLVM 22.0.0git
MipsCallLowering.cpp
Go to the documentation of this file.
1//===- MipsCallLowering.cpp -------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// This file implements the lowering of LLVM calls to machine code calls for
11/// GlobalISel.
12//
13//===----------------------------------------------------------------------===//
14
15#include "MipsCallLowering.h"
16#include "MipsCCState.h"
17#include "MipsMachineFunction.h"
18#include "MipsTargetMachine.h"
22
23using namespace llvm;
24
26 : CallLowering(&TLI) {}
27
28namespace {
29class MipsIncomingValueHandler : public CallLowering::IncomingValueHandler {
30 const MipsSubtarget &STI;
31
32public:
33 MipsIncomingValueHandler(MachineIRBuilder &MIRBuilder,
35 : IncomingValueHandler(MIRBuilder, MRI),
36 STI(MIRBuilder.getMF().getSubtarget<MipsSubtarget>()) {}
37
38private:
39 void assignValueToReg(Register ValVReg, Register PhysReg,
40 const CCValAssign &VA) override;
41
42 Register getStackAddress(uint64_t Size, int64_t Offset,
44 ISD::ArgFlagsTy Flags) override;
45 void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy,
46 const MachinePointerInfo &MPO,
47 const CCValAssign &VA) override;
48
49 unsigned assignCustomValue(CallLowering::ArgInfo &Arg,
51 std::function<void()> *Thunk = nullptr) override;
52
53 virtual void markPhysRegUsed(unsigned PhysReg) {
54 MIRBuilder.getMRI()->addLiveIn(PhysReg);
55 MIRBuilder.getMBB().addLiveIn(PhysReg);
56 }
57};
58
59class CallReturnHandler : public MipsIncomingValueHandler {
60public:
61 CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
63 : MipsIncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {}
64
65private:
66 void markPhysRegUsed(unsigned PhysReg) override {
67 MIB.addDef(PhysReg, RegState::Implicit);
68 }
69
71};
72
73} // end anonymous namespace
74
75void MipsIncomingValueHandler::assignValueToReg(Register ValVReg,
76 Register PhysReg,
77 const CCValAssign &VA) {
78 markPhysRegUsed(PhysReg);
79 IncomingValueHandler::assignValueToReg(ValVReg, PhysReg, VA);
80}
81
82Register MipsIncomingValueHandler::getStackAddress(uint64_t Size,
83 int64_t Offset,
85 ISD::ArgFlagsTy Flags) {
86
87 MachineFunction &MF = MIRBuilder.getMF();
89
90 // FIXME: This should only be immutable for non-byval memory arguments.
91 int FI = MFI.CreateFixedObject(Size, Offset, true);
92 MPO = MachinePointerInfo::getFixedStack(MIRBuilder.getMF(), FI);
93
94 return MIRBuilder.buildFrameIndex(LLT::pointer(0, 32), FI).getReg(0);
95}
96
97void MipsIncomingValueHandler::assignValueToAddress(
98 Register ValVReg, Register Addr, LLT MemTy, const MachinePointerInfo &MPO,
99 const CCValAssign &VA) {
100 MachineFunction &MF = MIRBuilder.getMF();
101 auto MMO = MF.getMachineMemOperand(MPO, MachineMemOperand::MOLoad, MemTy,
102 inferAlignFromPtrInfo(MF, MPO));
103 MIRBuilder.buildLoad(ValVReg, Addr, *MMO);
104}
105
106/// Handle cases when f64 is split into 2 32-bit GPRs. This is a custom
107/// assignment because generic code assumes getNumRegistersForCallingConv is
108/// accurate. In this case it is not because the type/number are context
109/// dependent on other arguments.
110unsigned
111MipsIncomingValueHandler::assignCustomValue(CallLowering::ArgInfo &Arg,
113 std::function<void()> *Thunk) {
114 const CCValAssign &VALo = VAs[0];
115 const CCValAssign &VAHi = VAs[1];
116
117 assert(VALo.getLocVT() == MVT::i32 && VAHi.getLocVT() == MVT::i32 &&
118 VALo.getValVT() == MVT::f64 && VAHi.getValVT() == MVT::f64 &&
119 "unexpected custom value");
120
121 auto CopyLo = MIRBuilder.buildCopy(LLT::scalar(32), VALo.getLocReg());
122 auto CopyHi = MIRBuilder.buildCopy(LLT::scalar(32), VAHi.getLocReg());
123 if (!STI.isLittle())
124 std::swap(CopyLo, CopyHi);
125
126 Arg.OrigRegs.assign(Arg.Regs.begin(), Arg.Regs.end());
127 Arg.Regs = { CopyLo.getReg(0), CopyHi.getReg(0) };
128 MIRBuilder.buildMergeLikeInstr(Arg.OrigRegs[0], {CopyLo, CopyHi});
129
130 markPhysRegUsed(VALo.getLocReg());
131 markPhysRegUsed(VAHi.getLocReg());
132 return 2;
133}
134
135namespace {
136class MipsOutgoingValueHandler : public CallLowering::OutgoingValueHandler {
137 const MipsSubtarget &STI;
138
139public:
140 MipsOutgoingValueHandler(MachineIRBuilder &MIRBuilder,
142 : OutgoingValueHandler(MIRBuilder, MRI),
143 STI(MIRBuilder.getMF().getSubtarget<MipsSubtarget>()), MIB(MIB) {}
144
145private:
146 void assignValueToReg(Register ValVReg, Register PhysReg,
147 const CCValAssign &VA) override;
148
149 Register getStackAddress(uint64_t Size, int64_t Offset,
151 ISD::ArgFlagsTy Flags) override;
152
153 void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy,
154 const MachinePointerInfo &MPO,
155 const CCValAssign &VA) override;
156 unsigned assignCustomValue(CallLowering::ArgInfo &Arg,
158 std::function<void()> *Thunk) override;
159
161};
162} // end anonymous namespace
163
164void MipsOutgoingValueHandler::assignValueToReg(Register ValVReg,
165 Register PhysReg,
166 const CCValAssign &VA) {
167 Register ExtReg = extendRegister(ValVReg, VA);
168 MIRBuilder.buildCopy(PhysReg, ExtReg);
169 MIB.addUse(PhysReg, RegState::Implicit);
170}
171
172Register MipsOutgoingValueHandler::getStackAddress(uint64_t Size,
173 int64_t Offset,
175 ISD::ArgFlagsTy Flags) {
176 MachineFunction &MF = MIRBuilder.getMF();
178
179 LLT p0 = LLT::pointer(0, 32);
180 LLT s32 = LLT::scalar(32);
181 auto SPReg = MIRBuilder.buildCopy(p0, Register(Mips::SP));
182
183 auto OffsetReg = MIRBuilder.buildConstant(s32, Offset);
184 auto AddrReg = MIRBuilder.buildPtrAdd(p0, SPReg, OffsetReg);
185 return AddrReg.getReg(0);
186}
187
188void MipsOutgoingValueHandler::assignValueToAddress(
189 Register ValVReg, Register Addr, LLT MemTy, const MachinePointerInfo &MPO,
190 const CCValAssign &VA) {
191 MachineFunction &MF = MIRBuilder.getMF();
192 uint64_t LocMemOffset = VA.getLocMemOffset();
193
194 auto MMO = MF.getMachineMemOperand(
195 MPO, MachineMemOperand::MOStore, MemTy,
196 commonAlignment(STI.getStackAlignment(), LocMemOffset));
197
198 Register ExtReg = extendRegister(ValVReg, VA);
199 MIRBuilder.buildStore(ExtReg, Addr, *MMO);
200}
201
202unsigned
203MipsOutgoingValueHandler::assignCustomValue(CallLowering::ArgInfo &Arg,
205 std::function<void()> *Thunk) {
206 const CCValAssign &VALo = VAs[0];
207 const CCValAssign &VAHi = VAs[1];
208
209 assert(VALo.getLocVT() == MVT::i32 && VAHi.getLocVT() == MVT::i32 &&
210 VALo.getValVT() == MVT::f64 && VAHi.getValVT() == MVT::f64 &&
211 "unexpected custom value");
212
213 auto Unmerge =
214 MIRBuilder.buildUnmerge({LLT::scalar(32), LLT::scalar(32)}, Arg.Regs[0]);
215 Register Lo = Unmerge.getReg(0);
216 Register Hi = Unmerge.getReg(1);
217
218 Arg.OrigRegs.assign(Arg.Regs.begin(), Arg.Regs.end());
219 Arg.Regs = { Lo, Hi };
220 if (!STI.isLittle())
221 std::swap(Lo, Hi);
222
223 // If we can return a thunk, just include the register copies. The unmerge can
224 // be emitted earlier.
225 if (Thunk) {
226 *Thunk = [=]() {
227 MIRBuilder.buildCopy(VALo.getLocReg(), Lo);
228 MIRBuilder.buildCopy(VAHi.getLocReg(), Hi);
229 };
230 return 2;
231 }
232 MIRBuilder.buildCopy(VALo.getLocReg(), Lo);
233 MIRBuilder.buildCopy(VAHi.getLocReg(), Hi);
234 return 2;
235}
236
238 if (T->isIntegerTy())
239 return true;
240 if (T->isPointerTy())
241 return true;
242 if (T->isFloatingPointTy())
243 return true;
244 return false;
245}
246
248 if (T->isIntegerTy())
249 return true;
250 if (T->isPointerTy())
251 return true;
252 if (T->isFloatingPointTy())
253 return true;
254 if (T->isAggregateType())
255 return true;
256 return false;
257}
258
260 const Value *Val, ArrayRef<Register> VRegs,
261 FunctionLoweringInfo &FLI) const {
262
263 MachineInstrBuilder Ret = MIRBuilder.buildInstrNoInsert(Mips::RetRA);
264
265 if (Val != nullptr && !isSupportedReturnType(Val->getType()))
266 return false;
267
268 if (!VRegs.empty()) {
269 MachineFunction &MF = MIRBuilder.getMF();
270 const Function &F = MF.getFunction();
271 const DataLayout &DL = MF.getDataLayout();
272 const MipsTargetLowering &TLI = *getTLI<MipsTargetLowering>();
273
275
276 ArgInfo ArgRetInfo(VRegs, *Val, 0);
278 splitToValueTypes(ArgRetInfo, RetInfos, DL, F.getCallingConv());
279
281
282 MipsCCState CCInfo(F.getCallingConv(), F.isVarArg(), MF, ArgLocs,
283 F.getContext());
284
285 MipsOutgoingValueHandler RetHandler(MIRBuilder, MF.getRegInfo(), Ret);
287
288 if (!determineAssignments(Assigner, RetInfos, CCInfo))
289 return false;
290
291 if (!handleAssignments(RetHandler, RetInfos, CCInfo, ArgLocs, MIRBuilder))
292 return false;
293 }
294
295 MIRBuilder.insertInstr(Ret);
296 return true;
297}
298
300 const Function &F,
302 FunctionLoweringInfo &FLI) const {
303
304 // Quick exit if there aren't any args.
305 if (F.arg_empty())
306 return true;
307
308 for (auto &Arg : F.args()) {
309 if (!isSupportedArgumentType(Arg.getType()))
310 return false;
311 }
312
313 MachineFunction &MF = MIRBuilder.getMF();
314 const DataLayout &DL = MF.getDataLayout();
315 const MipsTargetLowering &TLI = *getTLI<MipsTargetLowering>();
316
318 unsigned i = 0;
319 for (auto &Arg : F.args()) {
320 ArgInfo AInfo(VRegs[i], Arg, i);
322
323 splitToValueTypes(AInfo, ArgInfos, DL, F.getCallingConv());
324 ++i;
325 }
326
328 MipsCCState CCInfo(F.getCallingConv(), F.isVarArg(), MF, ArgLocs,
329 F.getContext());
330
331 const MipsTargetMachine &TM =
332 static_cast<const MipsTargetMachine &>(MF.getTarget());
333 const MipsABIInfo &ABI = TM.getABI();
334 CCInfo.AllocateStack(ABI.GetCalleeAllocdArgSizeInBytes(F.getCallingConv()),
335 Align(1));
336
338 if (!determineAssignments(Assigner, ArgInfos, CCInfo))
339 return false;
340
341 MipsIncomingValueHandler Handler(MIRBuilder, MF.getRegInfo());
342 if (!handleAssignments(Handler, ArgInfos, CCInfo, ArgLocs, MIRBuilder))
343 return false;
344
345 if (F.isVarArg()) {
346 ArrayRef<MCPhysReg> ArgRegs =
347 ABI.getVarArgRegs(MF.getSubtarget<MipsSubtarget>().isGP64bit());
348 unsigned Idx = CCInfo.getFirstUnallocated(ArgRegs);
349
350 int VaArgOffset;
351 unsigned RegSize = 4;
352 if (ArgRegs.size() == Idx)
353 VaArgOffset = alignTo(CCInfo.getStackSize(), RegSize);
354 else {
355 VaArgOffset =
356 (int)ABI.GetCalleeAllocdArgSizeInBytes(CCInfo.getCallingConv()) -
357 (int)(RegSize * (ArgRegs.size() - Idx));
358 }
359
360 MachineFrameInfo &MFI = MF.getFrameInfo();
361 int FI = MFI.CreateFixedObject(RegSize, VaArgOffset, true);
362 MF.getInfo<MipsFunctionInfo>()->setVarArgsFrameIndex(FI);
363
364 for (unsigned I = Idx; I < ArgRegs.size(); ++I, VaArgOffset += RegSize) {
365 MIRBuilder.getMBB().addLiveIn(ArgRegs[I]);
366 LLT RegTy = LLT::scalar(RegSize * 8);
368 MIRBuilder.buildCopy(RegTy, Register(ArgRegs[I]));
369 FI = MFI.CreateFixedObject(RegSize, VaArgOffset, true);
371
372 const LLT PtrTy = LLT::pointer(MPO.getAddrSpace(), 32);
373 auto FrameIndex = MIRBuilder.buildFrameIndex(PtrTy, FI);
376 MIRBuilder.buildStore(Copy, FrameIndex, *MMO);
377 }
378 }
379
380 return true;
381}
382
384 CallLoweringInfo &Info) const {
385
386 if (Info.CallConv != CallingConv::C)
387 return false;
388
389 for (auto &Arg : Info.OrigArgs) {
390 if (!isSupportedArgumentType(Arg.Ty))
391 return false;
392 if (Arg.Flags[0].isByVal())
393 return false;
394 if (Arg.Flags[0].isSRet() && !Arg.Ty->isPointerTy())
395 return false;
396 }
397
398 if (!Info.OrigRet.Ty->isVoidTy() && !isSupportedReturnType(Info.OrigRet.Ty))
399 return false;
400
401 MachineFunction &MF = MIRBuilder.getMF();
402 const Function &F = MF.getFunction();
403 const DataLayout &DL = MF.getDataLayout();
404 const MipsTargetLowering &TLI = *getTLI<MipsTargetLowering>();
405 const MipsTargetMachine &TM =
406 static_cast<const MipsTargetMachine &>(MF.getTarget());
407 const MipsABIInfo &ABI = TM.getABI();
408
409 MachineInstrBuilder CallSeqStart =
410 MIRBuilder.buildInstr(Mips::ADJCALLSTACKDOWN);
411
412 const bool IsCalleeGlobalPIC =
413 Info.Callee.isGlobal() && TM.isPositionIndependent();
414
416 Info.Callee.isReg() || IsCalleeGlobalPIC ? Mips::JALRPseudo : Mips::JAL);
417 MIB.addDef(Mips::SP, RegState::Implicit);
418 if (IsCalleeGlobalPIC) {
419 Register CalleeReg =
421 MachineInstr *CalleeGlobalValue =
422 MIRBuilder.buildGlobalValue(CalleeReg, Info.Callee.getGlobal());
423 if (!Info.Callee.getGlobal()->hasLocalLinkage())
424 CalleeGlobalValue->getOperand(1).setTargetFlags(MipsII::MO_GOT_CALL);
425 MIB.addUse(CalleeReg);
426 } else
427 MIB.add(Info.Callee);
429 MIB.addRegMask(TRI->getCallPreservedMask(MF, Info.CallConv));
430
431 TargetLowering::ArgListTy FuncOrigArgs;
432 FuncOrigArgs.reserve(Info.OrigArgs.size());
433
435 for (auto &Arg : Info.OrigArgs)
436 splitToValueTypes(Arg, ArgInfos, DL, Info.CallConv);
437
439 bool IsCalleeVarArg = false;
440 if (Info.Callee.isGlobal()) {
441 const Function *CF = static_cast<const Function *>(Info.Callee.getGlobal());
442 IsCalleeVarArg = CF->isVarArg();
443 }
444
445 // FIXME: Should use MipsCCState::getSpecialCallingConvForCallee, but it
446 // depends on looking directly at the call target.
447 MipsCCState CCInfo(Info.CallConv, IsCalleeVarArg, MF, ArgLocs,
448 F.getContext());
449
450 CCInfo.AllocateStack(ABI.GetCalleeAllocdArgSizeInBytes(Info.CallConv),
451 Align(1));
452
454 if (!determineAssignments(Assigner, ArgInfos, CCInfo))
455 return false;
456
457 MipsOutgoingValueHandler ArgHandler(MIRBuilder, MF.getRegInfo(), MIB);
458 if (!handleAssignments(ArgHandler, ArgInfos, CCInfo, ArgLocs, MIRBuilder))
459 return false;
460
461 unsigned StackSize = CCInfo.getStackSize();
462 unsigned StackAlignment = F.getParent()->getOverrideStackAlignment();
463 if (!StackAlignment) {
465 StackAlignment = TFL->getStackAlignment();
466 }
467 StackSize = alignTo(StackSize, StackAlignment);
468 CallSeqStart.addImm(StackSize).addImm(0);
469
470 if (IsCalleeGlobalPIC) {
471 MIRBuilder.buildCopy(
472 Register(Mips::GP),
474 MIB.addDef(Mips::GP, RegState::Implicit);
475 }
476 MIRBuilder.insertInstr(MIB);
477 if (MIB->getOpcode() == Mips::JALRPseudo) {
478 const MipsSubtarget &STI = MIRBuilder.getMF().getSubtarget<MipsSubtarget>();
479 MIB.constrainAllUses(MIRBuilder.getTII(), *STI.getRegisterInfo(),
480 *STI.getRegBankInfo());
481 }
482
483 if (!Info.OrigRet.Ty->isVoidTy()) {
484 ArgInfos.clear();
485
486 CallLowering::splitToValueTypes(Info.OrigRet, ArgInfos, DL,
487 F.getCallingConv());
488
491 CallReturnHandler RetHandler(MIRBuilder, MF.getRegInfo(), MIB);
492
493 MipsCCState CCInfo(F.getCallingConv(), F.isVarArg(), MF, ArgLocs,
494 F.getContext());
495
496 if (!determineAssignments(Assigner, ArgInfos, CCInfo))
497 return false;
498
499 if (!handleAssignments(RetHandler, ArgInfos, CCInfo, ArgLocs, MIRBuilder))
500 return false;
501 }
502
503 MIRBuilder.buildInstr(Mips::ADJCALLSTACKUP).addImm(StackSize).addImm(0);
504
505 return true;
506}
unsigned const MachineRegisterInfo * MRI
unsigned RegSize
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint64_t Addr
uint64_t Size
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This file declares the MachineIRBuilder class.
Register const TargetRegisterInfo * TRI
static bool isSupportedReturnType(Type *T)
static bool isSupportedArgumentType(Type *T)
This file describes how to lower LLVM calls to machine code calls.
static constexpr MCPhysReg SPReg
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:147
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:142
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set,...
CallingConv::ID getCallingConv() const
int64_t AllocateStack(unsigned Size, Align Alignment)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
uint64_t getStackSize() const
Returns the size of the currently allocated portion of the stack.
CCValAssign - Represent assignment of one arg/retval to a location.
Register getLocReg() const
int64_t getLocMemOffset() const
bool handleAssignments(ValueHandler &Handler, SmallVectorImpl< ArgInfo > &Args, CCState &CCState, SmallVectorImpl< CCValAssign > &ArgLocs, MachineIRBuilder &MIRBuilder, ArrayRef< Register > ThisReturnRegs={}) const
Use Handler to insert code to handle the argument/return values represented by Args.
void splitToValueTypes(const ArgInfo &OrigArgInfo, SmallVectorImpl< ArgInfo > &SplitArgs, const DataLayout &DL, CallingConv::ID CallConv, SmallVectorImpl< uint64_t > *Offsets=nullptr) const
Break OrigArgInfo into one or more pieces the calling convention can process, returned in SplitArgs.
bool determineAssignments(ValueAssigner &Assigner, SmallVectorImpl< ArgInfo > &Args, CCState &CCInfo) const
Analyze the argument list in Args, using Assigner to populate CCInfo.
void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Definition: Function.h:227
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
Definition: LowLevelType.h:43
static constexpr LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
Definition: LowLevelType.h:58
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
LLVM_ABI 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 TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, Align 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.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Helper class to build MachineInstr.
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
MachineInstrBuilder buildGlobalValue(const DstOp &Res, const GlobalValue *GV)
Build and insert Res = G_GLOBAL_VALUE GV.
const TargetInstrInfo & getTII()
MachineInstrBuilder buildStore(const SrcOp &Val, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
MachineInstrBuilder buildFrameIndex(const DstOp &Res, int Idx)
Build and insert Res = G_FRAME_INDEX Idx.
MachineFunction & getMF()
Getter for the function we currently build.
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
MachineInstrBuilder buildCopy(const DstOp &Res, const SrcOp &Op)
Build and insert Res = COPY Op.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
bool constrainAllUses(const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI) const
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
Definition: MachineInstr.h:72
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:587
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:595
A description of a memory reference used in the backend.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
void setTargetFlags(unsigned F)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
MipsCallLowering(const MipsTargetLowering &TLI)
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< ArrayRef< Register > > VRegs, FunctionLoweringInfo &FLI) const override
This hook must be implemented to lower the incoming (formal) arguments, described by VRegs,...
bool lowerCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info) const override
This hook must be implemented to lower the given call instruction, including argument and return valu...
bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< Register > VRegs, FunctionLoweringInfo &FLI) const override
This hook behaves as the extended lowerReturn function, but for targets that do not support swifterro...
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
Register getGlobalBaseRegForGlobalISel(MachineFunction &MF)
bool isLittle() const
const MipsRegisterInfo * getRegisterInfo() const override
const RegisterBankInfo * getRegBankInfo() const override
bool isGP64bit() const
Align getStackAlignment() const
CCAssignFn * CCAssignFnForReturn() const
CCAssignFn * CCAssignFnForCall() const
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
Information about stack frame layout on the target.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
std::vector< ArgListEntry > ArgListTy
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetFrameLowering * getFrameLowering() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:267
LLVM Value Representation.
Definition: Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
@ Implicit
Not emitted register (e.g. carry, or temporary result).
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:155
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
Definition: Alignment.h:212
LLVM_ABI Align inferAlignFromPtrInfo(MachineFunction &MF, const MachinePointerInfo &MPO)
Definition: Utils.cpp:899
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:858
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
SmallVector< Register, 4 > Regs
Definition: CallLowering.h:62
SmallVector< Register, 2 > OrigRegs
Definition: CallLowering.h:66
SmallVector< ISD::ArgFlagsTy, 4 > Flags
Definition: CallLowering.h:52
Base class for ValueHandlers used for arguments coming into the current function, or for return value...
Definition: CallLowering.h:329
Base class for ValueHandlers used for arguments passed to a function call, or for return values.
Definition: CallLowering.h:345
This class contains a discriminated union of information about pointers in memory operands,...
LLVM_ABI unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
static LLVM_ABI MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.