LLVM 24.0.0git
X86PreTileConfig.cpp
Go to the documentation of this file.
1//===-- X86PreTileConfig.cpp - Tile Register Pre-configure-----------------===//
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 Pass to pre-config the shapes of AMX registers
10/// AMX register needs to be configured before use. The shapes of AMX register
11/// are encoded in the 1st and 2nd machine operand of AMX pseudo instructions.
12///
13/// The instruction ldtilecfg is used to config the shapes. It must be reachable
14/// for all variable shapes. ldtilecfg will be inserted more than once if we
15/// cannot find a dominating point for all AMX instructions.
16///
17/// The configure register is caller saved according to ABI. We need to insert
18/// ldtilecfg again after the call instruction if callee clobbers any AMX
19/// registers.
20///
21/// This pass calculates all points that ldtilecfg need to be inserted to and
22/// insert them. It reports error if the reachability conditions aren't met.
23//
24//===----------------------------------------------------------------------===//
25
26#include "X86.h"
27#include "X86InstrBuilder.h"
29#include "X86RegisterInfo.h"
30#include "X86Subtarget.h"
31#include "llvm/ADT/ScopeExit.h"
32#include "llvm/ADT/SmallSet.h"
38#include "llvm/CodeGen/Passes.h"
41#include "llvm/IR/Module.h"
43
44using namespace llvm;
45
46#define DEBUG_TYPE "x86-pre-tile-config"
47
48static void emitErrorMsg(MachineFunction &MF) {
49 LLVMContext &Context = MF.getFunction().getContext();
50 Context.emitError(
51 MF.getName() +
52 ": Failed to config tile register, please define the shape earlier");
53}
54
55namespace {
56
57struct MIRef {
58 MachineInstr *MI = nullptr;
59 MachineBasicBlock *MBB = nullptr;
60 // A virtual position for instruction that will be inserted after MI.
61 size_t Pos = 0;
62 MIRef() = default;
63 MIRef(MachineBasicBlock *MBB) : MBB(MBB) {
64 for (auto I = MBB->begin(), E = MBB->end(); I != E && I->isPHI();
65 ++I, ++Pos)
66 MI = &*I;
67 }
68 MIRef(MachineInstr *MI)
69 : MI(MI), MBB(MI->getParent()),
70 Pos(std::distance(MBB->instr_begin(), ++MI->getIterator())) {}
71 MIRef(MachineInstr *MI, MachineBasicBlock *MBB)
72 : MI(MI), MBB(MBB),
73 Pos(std::distance(MBB->instr_begin(), ++MI->getIterator())) {}
74 MIRef(MachineInstr *MI, MachineBasicBlock *MBB, size_t Pos)
75 : MI(MI), MBB(MBB), Pos(Pos) {}
76 operator bool() const { return MBB != nullptr; }
77 bool operator==(const MIRef &RHS) const {
78 return MI == RHS.MI && MBB == RHS.MBB;
79 }
80 bool operator!=(const MIRef &RHS) const { return !(*this == RHS); }
81 bool operator<(const MIRef &RHS) const {
82 // Comparison between different BBs happens when inserting a MIRef into set.
83 // So we compare MBB first to make the insertion happy.
84 return std::tie(MBB, Pos) < std::tie(RHS.MBB, RHS.Pos);
85 }
86 bool operator>(const MIRef &RHS) const {
87 // Comparison between different BBs happens when inserting a MIRef into set.
88 // So we compare MBB first to make the insertion happy.
89 return std::tie(MBB, Pos) > std::tie(RHS.MBB, RHS.Pos);
90 }
91};
92
93struct BBInfo {
94 MIRef FirstAMX;
95 MIRef LastCall;
96 bool HasAMXRegLiveIn = false;
97 bool TileCfgForbidden = false;
98 bool NeedTileCfgLiveIn = false;
99};
100
101class X86PreTileConfigImpl {
102 std::function<MachineLoopInfo *()> GetMLI;
103 MachineRegisterInfo *MRI = nullptr;
104 const MachineLoopInfo *MLI = nullptr;
105 SmallPtrSet<MachineInstr *, 8> DefVisited;
106 DenseMap<MachineBasicBlock *, BBInfo> BBVisitedInfo;
107 DenseMap<MachineBasicBlock *, SmallVector<MIRef, 8>> ShapeBBs;
108
109 /// Check if the callee will clobber AMX registers.
110 bool isDestructiveCall(MachineInstr &MI, BitVector UsableRegs) {
111 auto Iter = llvm::find_if(
112 MI.operands(), [](MachineOperand &MO) { return MO.isRegMask(); });
113 if (Iter == MI.operands_end())
114 return false;
115 UsableRegs.clearBitsInMask(Iter->getRegMask());
116 return !UsableRegs.none();
117 }
118
119 /// Check if MI is AMX pseudo instruction.
120 bool isAMXInstruction(MachineInstr &MI) {
121 if (MI.isPHI() || MI.isDebugInstr() || MI.getNumOperands() < 3)
122 return false;
123 switch (MI.getOpcode()) {
124 case X86::PTILESTOREDV:
125 case X86::PTCVTROWD2PSrteV:
126 case X86::PTCVTROWD2PSrtiV:
127 case X86::PTCVTROWPS2BF16HrteV:
128 case X86::PTCVTROWPS2BF16HrtiV:
129 case X86::PTCVTROWPS2BF16LrteV:
130 case X86::PTCVTROWPS2BF16LrtiV:
131 case X86::PTCVTROWPS2PHHrteV:
132 case X86::PTCVTROWPS2PHHrtiV:
133 case X86::PTCVTROWPS2PHLrteV:
134 case X86::PTCVTROWPS2PHLrtiV:
135 case X86::PTILEMOVROWrteV:
136 case X86::PTILEMOVROWrtiV:
137 case X86::ACE_PTCVTROWD2PSrteV:
138 case X86::ACE_PTCVTROWD2PSrtiV:
139 case X86::ACE_PTCVTROWPS2BF16HrteV:
140 case X86::ACE_PTCVTROWPS2BF16HrtiV:
141 case X86::ACE_PTCVTROWPS2BF16LrteV:
142 case X86::ACE_PTCVTROWPS2BF16LrtiV:
143 case X86::ACE_PTCVTROWPS2PHHrteV:
144 case X86::ACE_PTCVTROWPS2PHHrtiV:
145 case X86::ACE_PTCVTROWPS2PHLrteV:
146 case X86::ACE_PTCVTROWPS2PHLrtiV:
147 case X86::ACE_PTILEMOVROWrteV:
148 case X86::ACE_PTILEMOVROWrtiV:
149 return true;
150 }
151
152 // We can simply check if it is AMX instruction by its def.
153 // But we should exclude old API which uses physical registers.
154 MachineOperand &MO = MI.getOperand(0);
155 if (!MO.isReg() || !MO.getReg().isVirtual())
156 return false;
157
158 if (MRI->getRegClass(MO.getReg())->getID() != X86::TILERegClassID)
159 return false;
160
161 collectShapeInfo(MI);
162 return true;
163 }
164
165 /// Check if it is an edge from loop bottom to loop head.
166 bool isLoopBackEdge(MachineBasicBlock *Header, MachineBasicBlock *Bottom) {
167 if (!MLI->isLoopHeader(Header))
168 return false;
169 auto *ML = MLI->getLoopFor(Header);
170 if (ML->contains(Bottom) && ML->isLoopLatch(Bottom))
171 return true;
172
173 return false;
174 }
175
176 /// Collect the shape def information for later use.
177 void collectShapeInfo(MachineInstr &MI);
178
179 /// Try to hoist shapes definded below AMX instructions.
180 bool hoistShapesInBB(MachineBasicBlock *MBB, SmallVectorImpl<MIRef> &Shapes) {
181 MIRef &FirstAMX = BBVisitedInfo[MBB].FirstAMX;
182 auto FirstShapeBelowAMX = llvm::lower_bound(Shapes, FirstAMX);
183 auto InsertPoint = FirstAMX.MI->getIterator();
184 for (auto I = FirstShapeBelowAMX, E = Shapes.end(); I != E; ++I) {
185 // Do not hoist instructions that access memory.
186 if (I->MI->mayLoadOrStore())
187 return false;
188 for (auto &MO : I->MI->operands()) {
189 if (MO.isDef())
190 continue;
191 // Do not hoist instructions if the sources' def under AMX instruction.
192 // TODO: We can handle isMoveImmediate MI here.
193 if (MO.isReg() && MIRef(MRI->getVRegDef(MO.getReg())) > FirstAMX)
194 return false;
195 // TODO: Maybe need more checks here.
196 }
197 MBB->insert(InsertPoint, I->MI->removeFromParent());
198 }
199 // We only need to mark the last shape in the BB now.
200 Shapes.clear();
201 Shapes.push_back(MIRef(&*--InsertPoint, MBB));
202 return true;
203 }
204
205 /// Clear MF related structures.
206 void releaseMemory() {
207 ShapeBBs.clear();
208 DefVisited.clear();
209 BBVisitedInfo.clear();
210 }
211
212public:
213 X86PreTileConfigImpl(std::function<MachineLoopInfo *()> GetMLI)
214 : GetMLI(GetMLI) {}
215 bool runOnMachineFunction(MachineFunction &MF);
216};
217
218class X86PreTileConfigLegacy : public MachineFunctionPass {
219public:
220 X86PreTileConfigLegacy() : MachineFunctionPass(ID) {}
221
222 /// Return the pass name.
223 StringRef getPassName() const override {
224 return "Tile Register Pre-configure";
225 }
226
227 /// X86PreTileConfig analysis usage.
228 void getAnalysisUsage(AnalysisUsage &AU) const override {
229 AU.setPreservesAll();
230 AU.addRequired<MachineLoopInfoWrapperPass>();
232 }
233
234 /// Perform ldtilecfg instructions inserting.
235 bool runOnMachineFunction(MachineFunction &MF) override;
236
237 static char ID;
238};
239
240} // end anonymous namespace
241
242char X86PreTileConfigLegacy::ID = 0;
243
244INITIALIZE_PASS_BEGIN(X86PreTileConfigLegacy, "tilepreconfig",
245 "Tile Register Pre-configure", false, false)
247INITIALIZE_PASS_END(X86PreTileConfigLegacy, "tilepreconfig",
248 "Tile Register Pre-configure", false, false)
249
250void X86PreTileConfigImpl::collectShapeInfo(MachineInstr &MI) {
251 auto RecordShape = [&](MachineInstr *MI, MachineBasicBlock *MBB) {
252 MIRef MIR(MI, MBB);
253 auto &Refs = ShapeBBs[MBB];
254 auto I = llvm::lower_bound(Refs, MIR);
255 if (I == Refs.end() || *I != MIR)
256 Refs.insert(I, MIR);
257 };
258
260 {MI.getOperand(1).getReg(), MI.getOperand(2).getReg()});
261 while (!WorkList.empty()) {
262 Register R = WorkList.pop_back_val();
263 MachineInstr *DefMI = MRI->getVRegDef(R);
264 assert(DefMI && "R must has one define instruction");
265 MachineBasicBlock *DefMBB = DefMI->getParent();
266 if (DefMI->isMoveImmediate() || !DefVisited.insert(DefMI).second)
267 continue;
268
269 if (DefMI->isPHI()) {
270 for (unsigned I = 1; I < DefMI->getNumOperands(); I += 2)
271 if (isLoopBackEdge(DefMBB, DefMI->getOperand(I + 1).getMBB()))
272 RecordShape(DefMI, DefMBB); // In this case, PHI is also a shape def.
273 else
274 WorkList.push_back(DefMI->getOperand(I).getReg());
275 } else {
276 RecordShape(DefMI, DefMBB);
277 }
278 }
279}
280
281bool X86PreTileConfigImpl::runOnMachineFunction(MachineFunction &MF) {
282 scope_exit ClearStateOnExit([this] { releaseMemory(); });
283
284 X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
285 // Early exit in the common case of non-AMX/ACE code.
286 if (X86FI->getAMXProgModel() != AMXProgModelEnum::ManagedRA &&
287 X86FI->getACEProgModel() != ACEProgModelEnum::ACE_ManagedRA)
288 return false;
289
290 const X86Subtarget &ST = MF.getSubtarget<X86Subtarget>();
291 const TargetInstrInfo *TII = ST.getInstrInfo();
292 const TargetRegisterInfo *TRI = ST.getRegisterInfo();
293 const TargetRegisterClass *RC = TRI->getRegClass(X86::TILERegClassID);
294
295 BitVector AMXRegs(TRI->getNumRegs());
296 for (unsigned I = 0; I < RC->getNumRegs(); I++)
297 AMXRegs.set(X86::TMM0 + I);
298
299 // Iterate MF to collect information.
300 MRI = &MF.getRegInfo();
301 MLI = GetMLI();
302 SmallSet<MIRef, 8> CfgNeedInsert;
304 for (auto &MBB : MF) {
305 size_t Pos = 0;
306 auto &Info = BBVisitedInfo[&MBB];
307 for (auto &MI : MBB) {
308 ++Pos;
309 if (isAMXInstruction(MI)) {
310 // If there's call before the AMX, we need to reload tile config.
311 if (Info.LastCall)
312 CfgNeedInsert.insert(Info.LastCall);
313 else // Otherwise, we need tile config to live in this BB.
314 Info.NeedTileCfgLiveIn = true;
315 // Always record the first AMX in case there's shape def after it.
316 if (!Info.FirstAMX)
317 Info.FirstAMX = MIRef(&MI, &MBB, Pos);
318 } else if (MI.isCall() && isDestructiveCall(MI, AMXRegs)) {
319 // Record the call only if the callee clobbers all AMX registers.
320 Info.LastCall = MIRef(&MI, &MBB, Pos);
321 }
322 }
323 if (Info.NeedTileCfgLiveIn) {
324 if (&MBB == &MF.front())
325 CfgNeedInsert.insert(MIRef(&MBB));
326 else
327 CfgLiveInBBs.push_back(&MBB);
328 }
329 if (Info.FirstAMX || Info.HasAMXRegLiveIn)
330 for (auto *Succ : MBB.successors())
331 if (!isLoopBackEdge(Succ, &MBB))
332 BBVisitedInfo[Succ].HasAMXRegLiveIn = true;
333 }
334
335 // Update NeedTileCfgLiveIn for predecessors.
336 while (!CfgLiveInBBs.empty()) {
337 MachineBasicBlock *MBB = CfgLiveInBBs.pop_back_val();
338 for (auto *Pred : MBB->predecessors()) {
339 auto &Info = BBVisitedInfo[Pred];
340 if (Info.LastCall) {
341 CfgNeedInsert.insert(Info.LastCall);
342 } else if (!Info.NeedTileCfgLiveIn) {
343 Info.NeedTileCfgLiveIn = true;
344 if (Pred == &MF.front())
345 CfgNeedInsert.insert(MIRef(Pred));
346 else
347 CfgLiveInBBs.push_back(Pred);
348 }
349 }
350 }
351
352 // There's no AMX instruction if we didn't find a tile config live in point.
353 if (CfgNeedInsert.empty())
354 return false;
355
356 // Avoid to insert ldtilecfg before any shape defs.
358 for (auto &I : ShapeBBs) {
359 auto &Info = BBVisitedInfo[I.first];
360 // TODO: We can hoist shapes across BBs here.
361 if (Info.HasAMXRegLiveIn) {
362 // We are not able to config tile registers since the shape to config
363 // is not defined yet. Emit error message and continue. The function
364 // would not config tile registers.
365 emitErrorMsg(MF);
366 return false;
367 }
368 if (Info.FirstAMX && Info.FirstAMX < I.second.back() &&
369 !hoistShapesInBB(I.first, I.second)) {
370 emitErrorMsg(MF);
371 return false;
372 }
373 WorkList.push_back(I.first);
374 }
375 while (!WorkList.empty()) {
376 MachineBasicBlock *MBB = WorkList.pop_back_val();
377 for (auto *Pred : MBB->predecessors()) {
378 auto &Info = BBVisitedInfo[Pred];
379 if (!Info.TileCfgForbidden && !isLoopBackEdge(MBB, Pred)) {
380 Info.TileCfgForbidden = true;
381 WorkList.push_back(Pred);
382 }
383 }
384 }
385
386 DebugLoc DL;
387 SmallSet<MIRef, 8> VisitedOrInserted;
388 int SS = MF.getFrameInfo().CreateStackObject(
389 ST.getTileConfigSize(), ST.getTileConfigAlignment(), false);
390
391 // Try to insert for the tile config live in points.
392 for (const auto &I : CfgNeedInsert) {
393 SmallSet<MIRef, 8> InsertPoints;
394 SmallVector<MIRef, 8> WorkList({I});
395 while (!WorkList.empty()) {
396 MIRef I = WorkList.pop_back_val();
397 if (!VisitedOrInserted.count(I)) {
398 if (!BBVisitedInfo[I.MBB].TileCfgForbidden) {
399 // If the BB is all shapes reachable, stop sink and try to insert.
400 InsertPoints.insert(I);
401 } else {
402 // Avoid the BB to be multi visited.
403 VisitedOrInserted.insert(I);
404 // Sink the inserting point along the chain with NeedTileCfgLiveIn =
405 // true when MBB isn't all shapes reachable.
406 for (auto *Succ : I.MBB->successors())
407 if (BBVisitedInfo[Succ].NeedTileCfgLiveIn)
408 WorkList.push_back(MIRef(Succ));
409 }
410 }
411 }
412
413 // A given point might be forked due to shape conditions are not met.
414 for (MIRef I : InsertPoints) {
415 // Make sure we insert ldtilecfg after the last shape def in MBB.
416 auto It = ShapeBBs.find(I.MBB);
417 if (It != ShapeBBs.end() && I < It->second.back())
418 I = It->second.back();
419 // There're chances the MBB is sunk more than once. Record it to avoid
420 // multi insert.
421 if (VisitedOrInserted.insert(I).second) {
423 I.MI ? std::next(I.MI->getIterator()) : I.MBB->getFirstNonPHI();
424 addFrameReference(BuildMI(*I.MBB, II, DL, TII->get(X86::PLDTILECFGV)),
425 SS)
427 }
428 }
429 }
430
431 // Zero stack slot.
432 MachineBasicBlock &MBB = MF.front();
433 MachineInstr *MI = &*MBB.begin();
434 if (ST.hasAVX512()) {
435 Register Xmm = MRI->createVirtualRegister(&X86::VR128XRegClass);
436 BuildMI(MBB, MI, DL, TII->get(X86::AVX512_128_SET0), Xmm);
437 Register Zmm = MRI->createVirtualRegister(&X86::VR512RegClass);
438 BuildMI(MBB, MI, DL, TII->get(X86::SUBREG_TO_REG), Zmm)
439 .addReg(Xmm)
440 .addImm(X86::sub_xmm);
441 addFrameReference(BuildMI(MBB, MI, DL, TII->get(X86::VMOVUPSZmr)), SS)
442 .addReg(Zmm);
443 } else if (ST.hasAVX2()) {
444 Register Xmm = MRI->createVirtualRegister(&X86::VR128RegClass);
445 BuildMI(MBB, MI, DL, TII->get(X86::V_SET0), Xmm);
446 Register Ymm = MRI->createVirtualRegister(&X86::VR256RegClass);
447 BuildMI(MBB, MI, DL, TII->get(X86::SUBREG_TO_REG), Ymm)
448 .addReg(Xmm)
449 .addImm(X86::sub_xmm);
450 addFrameReference(BuildMI(MBB, MI, DL, TII->get(X86::VMOVUPSYmr)), SS)
451 .addReg(Ymm);
452 addFrameReference(BuildMI(MBB, MI, DL, TII->get(X86::VMOVUPSYmr)), SS, 32)
453 .addReg(Ymm);
454 } else {
455 assert(ST.hasSSE2() && "AMX should assume SSE2 enabled");
456 unsigned StoreOpc = ST.hasAVX() ? X86::VMOVUPSmr : X86::MOVUPSmr;
457 Register Xmm = MRI->createVirtualRegister(&X86::VR128RegClass);
458 BuildMI(MBB, MI, DL, TII->get(X86::V_SET0), Xmm);
459 addFrameReference(BuildMI(MBB, MI, DL, TII->get(StoreOpc)), SS).addReg(Xmm);
460 addFrameReference(BuildMI(MBB, MI, DL, TII->get(StoreOpc)), SS, 16)
461 .addReg(Xmm);
462 addFrameReference(BuildMI(MBB, MI, DL, TII->get(StoreOpc)), SS, 32)
463 .addReg(Xmm);
464 addFrameReference(BuildMI(MBB, MI, DL, TII->get(StoreOpc)), SS, 48)
465 .addReg(Xmm);
466 }
467 // Fill in the palette first.
468 // Use Palette 2 for ACE v1, Palette 1 for AMX.
469 int PaletteId =
470 X86FI->getACEProgModel() == ACEProgModelEnum::ACE_ManagedRA ? 2 : 1;
471 addFrameReference(BuildMI(MBB, MI, DL, TII->get(X86::MOV8mi)), SS)
472 .addImm(PaletteId);
473
474 return true;
475}
476
478 return new X86PreTileConfigLegacy();
479}
480
481bool X86PreTileConfigLegacy::runOnMachineFunction(MachineFunction &MF) {
482 X86PreTileConfigImpl Impl(
483 [this]() { return &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); });
484 return Impl.runOnMachineFunction(MF);
485}
486
487PreservedAnalyses
490 X86PreTileConfigImpl Impl(
491 [&MFAM, &MF]() { return &MFAM.getResult<MachineLoopAnalysis>(MF); });
492 return Impl.runOnMachineFunction(MF)
496}
MachineInstrBuilder MachineInstrBuilder & DefMI
SDValue Pred
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AArch64InstrInfo & TII
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
#define I(x, y, z)
Definition MD5.cpp:57
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
MachineRegisterInfo & MRI
This file defines the scope_exit class, which executes user-defined cleanup logic at scope exit.
This file defines the SmallSet class.
Value * RHS
static void emitErrorMsg(MachineFunction &MF)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
void clearBitsInMask(const uint32_t *Mask, unsigned MaskWords=~0u)
Clear any bits in this vector that are set in Mask.
Definition BitVector.h:749
bool none() const
Returns true if none of the bits are set.
Definition BitVector.h:208
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:312
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition Function.cpp:352
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
LLVM_ABI void emitError(const Instruction *I, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
unsigned getNumRegs() const
getNumRegs - Return the number of registers in this class.
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
iterator_range< succ_iterator > successors()
iterator_range< pred_iterator > predecessors()
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
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 MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Representation of each machine instruction.
void setImplicitPhysRegDefsDead()
Mark the implicit physreg defs named by the instruction description as dead.
Analysis pass that exposes the MachineLoopInfo for a machine function.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
Wrapper class representing virtual and physical registers.
Definition Register.h:20
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Definition Register.h:79
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
Definition SmallSet.h:176
bool empty() const
Definition SmallSet.h:169
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Definition SmallSet.h:184
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
self_iterator getIterator()
Definition ilist_node.h:123
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
Definition APSInt.h:360
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
scope_exit(Callable) -> scope_exit< Callable >
bool operator!=(uint64_t V1, const APInt &V2)
Definition APInt.h:2139
static const MachineInstrBuilder & addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset=0, bool mem=true)
addFrameReference - This function is used to add a reference to the base of an abstract object on the...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
bool operator>(int64_t V1, const APSInt &V2)
Definition APSInt.h:361
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
FunctionPass * createX86PreTileConfigLegacyPass()
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Definition STLExtras.h:2068
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1788
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58