LLVM  9.0.0svn
MachineInstrBuilder.h
Go to the documentation of this file.
1 //===- CodeGen/MachineInstrBuilder.h - Simplify creation of MIs --*- 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 // This file exposes a function named BuildMI, which is useful for dramatically
10 // simplifying how MachineInstr's are created. It allows use of code like this:
11 //
12 // M = BuildMI(MBB, MI, DL, TII.get(X86::ADD8rr), Dst)
13 // .addReg(argVal1)
14 // .addReg(argVal2);
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_CODEGEN_MACHINEINSTRBUILDER_H
19 #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H
20 
21 #include "llvm/ADT/ArrayRef.h"
29 #include "llvm/IR/InstrTypes.h"
30 #include "llvm/IR/Intrinsics.h"
32 #include <cassert>
33 #include <cstdint>
34 #include <utility>
35 
36 namespace llvm {
37 
38 class MCInstrDesc;
39 class MDNode;
40 
41 namespace RegState {
42 
43  enum {
44  Define = 0x2,
45  Implicit = 0x4,
46  Kill = 0x8,
47  Dead = 0x10,
48  Undef = 0x20,
49  EarlyClobber = 0x40,
50  Debug = 0x80,
51  InternalRead = 0x100,
52  Renamable = 0x200,
56  };
57 
58 } // end namespace RegState
59 
61  MachineFunction *MF = nullptr;
62  MachineInstr *MI = nullptr;
63 
64 public:
65  MachineInstrBuilder() = default;
66 
67  /// Create a MachineInstrBuilder for manipulating an existing instruction.
68  /// F must be the machine function that was used to allocate I.
71  : MF(&F), MI(&*I) {}
72 
73  /// Allow automatic conversion to the machine instruction we are working on.
74  operator MachineInstr*() const { return MI; }
75  MachineInstr *operator->() const { return MI; }
76  operator MachineBasicBlock::iterator() const { return MI; }
77 
78  /// If conversion operators fail, use this method to get the MachineInstr
79  /// explicitly.
80  MachineInstr *getInstr() const { return MI; }
81 
82  /// Add a new virtual register operand.
83  const MachineInstrBuilder &addReg(unsigned RegNo, unsigned flags = 0,
84  unsigned SubReg = 0) const {
85  assert((flags & 0x1) == 0 &&
86  "Passing in 'true' to addReg is forbidden! Use enums instead.");
88  flags & RegState::Define,
89  flags & RegState::Implicit,
90  flags & RegState::Kill,
91  flags & RegState::Dead,
92  flags & RegState::Undef,
93  flags & RegState::EarlyClobber,
94  SubReg,
95  flags & RegState::Debug,
96  flags & RegState::InternalRead,
97  flags & RegState::Renamable));
98  return *this;
99  }
100 
101  /// Add a virtual register definition operand.
102  const MachineInstrBuilder &addDef(unsigned RegNo, unsigned Flags = 0,
103  unsigned SubReg = 0) const {
104  return addReg(RegNo, Flags | RegState::Define, SubReg);
105  }
106 
107  /// Add a virtual register use operand. It is an error for Flags to contain
108  /// `RegState::Define` when calling this function.
109  const MachineInstrBuilder &addUse(unsigned RegNo, unsigned Flags = 0,
110  unsigned SubReg = 0) const {
111  assert(!(Flags & RegState::Define) &&
112  "Misleading addUse defines register, use addReg instead.");
113  return addReg(RegNo, Flags, SubReg);
114  }
115 
116  /// Add a new immediate operand.
117  const MachineInstrBuilder &addImm(int64_t Val) const {
118  MI->addOperand(*MF, MachineOperand::CreateImm(Val));
119  return *this;
120  }
121 
122  const MachineInstrBuilder &addCImm(const ConstantInt *Val) const {
123  MI->addOperand(*MF, MachineOperand::CreateCImm(Val));
124  return *this;
125  }
126 
127  const MachineInstrBuilder &addFPImm(const ConstantFP *Val) const {
129  return *this;
130  }
131 
133  unsigned char TargetFlags = 0) const {
135  return *this;
136  }
137 
138  const MachineInstrBuilder &addFrameIndex(int Idx) const {
139  MI->addOperand(*MF, MachineOperand::CreateFI(Idx));
140  return *this;
141  }
142 
144  int Offset = 0,
145  unsigned char TargetFlags = 0) const {
147  return *this;
148  }
149 
150  const MachineInstrBuilder &addTargetIndex(unsigned Idx, int64_t Offset = 0,
151  unsigned char TargetFlags = 0) const {
153  TargetFlags));
154  return *this;
155  }
156 
158  unsigned char TargetFlags = 0) const {
160  return *this;
161  }
162 
164  int64_t Offset = 0,
165  unsigned char TargetFlags = 0) const {
167  return *this;
168  }
169 
170  const MachineInstrBuilder &addExternalSymbol(const char *FnName,
171  unsigned char TargetFlags = 0) const {
173  return *this;
174  }
175 
177  int64_t Offset = 0,
178  unsigned char TargetFlags = 0) const {
180  return *this;
181  }
182 
185  return *this;
186  }
187 
189  MI->addMemOperand(*MF, MMO);
190  return *this;
191  }
192 
193  const MachineInstrBuilder &
195  MI->setMemRefs(*MF, MMOs);
196  return *this;
197  }
198 
199  const MachineInstrBuilder &cloneMemRefs(const MachineInstr &OtherMI) const {
200  MI->cloneMemRefs(*MF, OtherMI);
201  return *this;
202  }
203 
204  const MachineInstrBuilder &
206  MI->cloneMergedMemRefs(*MF, OtherMIs);
207  return *this;
208  }
209 
210  const MachineInstrBuilder &add(const MachineOperand &MO) const {
211  MI->addOperand(*MF, MO);
212  return *this;
213  }
214 
216  for (const MachineOperand &MO : MOs) {
217  MI->addOperand(*MF, MO);
218  }
219  return *this;
220  }
221 
222  const MachineInstrBuilder &addMetadata(const MDNode *MD) const {
224  assert((MI->isDebugValue() ? static_cast<bool>(MI->getDebugVariable())
225  : true) &&
226  "first MDNode argument of a DBG_VALUE not a variable");
227  assert((MI->isDebugLabel() ? static_cast<bool>(MI->getDebugLabel())
228  : true) &&
229  "first MDNode argument of a DBG_LABEL not a label");
230  return *this;
231  }
232 
233  const MachineInstrBuilder &addCFIIndex(unsigned CFIIndex) const {
234  MI->addOperand(*MF, MachineOperand::CreateCFIIndex(CFIIndex));
235  return *this;
236  }
237 
240  return *this;
241  }
242 
245  return *this;
246  }
247 
249  unsigned char TargetFlags = 0) const {
251  return *this;
252  }
253 
254  const MachineInstrBuilder &setMIFlags(unsigned Flags) const {
255  MI->setFlags(Flags);
256  return *this;
257  }
258 
260  MI->setFlag(Flag);
261  return *this;
262  }
263 
264  // Add a displacement from an existing MachineOperand with an added offset.
265  const MachineInstrBuilder &addDisp(const MachineOperand &Disp, int64_t off,
266  unsigned char TargetFlags = 0) const {
267  // If caller specifies new TargetFlags then use it, otherwise the
268  // default behavior is to copy the target flags from the existing
269  // MachineOperand. This means if the caller wants to clear the
270  // target flags it needs to do so explicitly.
271  if (0 == TargetFlags)
272  TargetFlags = Disp.getTargetFlags();
273 
274  switch (Disp.getType()) {
275  default:
276  llvm_unreachable("Unhandled operand type in addDisp()");
278  return addImm(Disp.getImm() + off);
280  return addConstantPoolIndex(Disp.getIndex(), Disp.getOffset() + off,
281  TargetFlags);
283  return addGlobalAddress(Disp.getGlobal(), Disp.getOffset() + off,
284  TargetFlags);
285  }
286  }
287 
288  /// Copy all the implicit operands from OtherMI onto this one.
289  const MachineInstrBuilder &
290  copyImplicitOps(const MachineInstr &OtherMI) const {
291  MI->copyImplicitOps(*MF, OtherMI);
292  return *this;
293  }
294 
296  const TargetRegisterInfo &TRI,
297  const RegisterBankInfo &RBI) const {
298  return constrainSelectedInstRegOperands(*MI, TII, TRI, RBI);
299  }
300 };
301 
302 /// Builder interface. Specify how to create the initial instruction itself.
304  const MCInstrDesc &MCID) {
305  return MachineInstrBuilder(MF, MF.CreateMachineInstr(MCID, DL));
306 }
307 
308 /// This version of the builder sets up the first operand as a
309 /// destination virtual register.
311  const MCInstrDesc &MCID, unsigned DestReg) {
312  return MachineInstrBuilder(MF, MF.CreateMachineInstr(MCID, DL))
313  .addReg(DestReg, RegState::Define);
314 }
315 
316 /// This version of the builder inserts the newly-built instruction before
317 /// the given position in the given MachineBasicBlock, and sets up the first
318 /// operand as a destination virtual register.
321  const DebugLoc &DL, const MCInstrDesc &MCID,
322  unsigned DestReg) {
323  MachineFunction &MF = *BB.getParent();
324  MachineInstr *MI = MF.CreateMachineInstr(MCID, DL);
325  BB.insert(I, MI);
326  return MachineInstrBuilder(MF, MI).addReg(DestReg, RegState::Define);
327 }
328 
329 /// This version of the builder inserts the newly-built instruction before
330 /// the given position in the given MachineBasicBlock, and sets up the first
331 /// operand as a destination virtual register.
332 ///
333 /// If \c I is inside a bundle, then the newly inserted \a MachineInstr is
334 /// added to the same bundle.
337  const DebugLoc &DL, const MCInstrDesc &MCID,
338  unsigned DestReg) {
339  MachineFunction &MF = *BB.getParent();
340  MachineInstr *MI = MF.CreateMachineInstr(MCID, DL);
341  BB.insert(I, MI);
342  return MachineInstrBuilder(MF, MI).addReg(DestReg, RegState::Define);
343 }
344 
346  const DebugLoc &DL, const MCInstrDesc &MCID,
347  unsigned DestReg) {
348  // Calling the overload for instr_iterator is always correct. However, the
349  // definition is not available in headers, so inline the check.
350  if (I.isInsideBundle())
351  return BuildMI(BB, MachineBasicBlock::instr_iterator(I), DL, MCID, DestReg);
352  return BuildMI(BB, MachineBasicBlock::iterator(I), DL, MCID, DestReg);
353 }
354 
356  const DebugLoc &DL, const MCInstrDesc &MCID,
357  unsigned DestReg) {
358  return BuildMI(BB, *I, DL, MCID, DestReg);
359 }
360 
361 /// This version of the builder inserts the newly-built instruction before the
362 /// given position in the given MachineBasicBlock, and does NOT take a
363 /// destination register.
366  const DebugLoc &DL,
367  const MCInstrDesc &MCID) {
368  MachineFunction &MF = *BB.getParent();
369  MachineInstr *MI = MF.CreateMachineInstr(MCID, DL);
370  BB.insert(I, MI);
371  return MachineInstrBuilder(MF, MI);
372 }
373 
376  const DebugLoc &DL,
377  const MCInstrDesc &MCID) {
378  MachineFunction &MF = *BB.getParent();
379  MachineInstr *MI = MF.CreateMachineInstr(MCID, DL);
380  BB.insert(I, MI);
381  return MachineInstrBuilder(MF, MI);
382 }
383 
385  const DebugLoc &DL,
386  const MCInstrDesc &MCID) {
387  // Calling the overload for instr_iterator is always correct. However, the
388  // definition is not available in headers, so inline the check.
389  if (I.isInsideBundle())
390  return BuildMI(BB, MachineBasicBlock::instr_iterator(I), DL, MCID);
391  return BuildMI(BB, MachineBasicBlock::iterator(I), DL, MCID);
392 }
393 
395  const DebugLoc &DL,
396  const MCInstrDesc &MCID) {
397  return BuildMI(BB, *I, DL, MCID);
398 }
399 
400 /// This version of the builder inserts the newly-built instruction at the end
401 /// of the given MachineBasicBlock, and does NOT take a destination register.
403  const MCInstrDesc &MCID) {
404  return BuildMI(*BB, BB->end(), DL, MCID);
405 }
406 
407 /// This version of the builder inserts the newly-built instruction at the
408 /// end of the given MachineBasicBlock, and sets up the first operand as a
409 /// destination virtual register.
411  const MCInstrDesc &MCID, unsigned DestReg) {
412  return BuildMI(*BB, BB->end(), DL, MCID, DestReg);
413 }
414 
415 /// This version of the builder builds a DBG_VALUE intrinsic
416 /// for either a value in a register or a register-indirect
417 /// address. The convention is that a DBG_VALUE is indirect iff the
418 /// second operand is an immediate.
420  const MCInstrDesc &MCID, bool IsIndirect,
421  unsigned Reg, const MDNode *Variable,
422  const MDNode *Expr);
423 
424 /// This version of the builder builds a DBG_VALUE intrinsic
425 /// for a MachineOperand.
427  const MCInstrDesc &MCID, bool IsIndirect,
428  MachineOperand &MO, const MDNode *Variable,
429  const MDNode *Expr);
430 
431 /// This version of the builder builds a DBG_VALUE intrinsic
432 /// for either a value in a register or a register-indirect
433 /// address and inserts it at position I.
436  const MCInstrDesc &MCID, bool IsIndirect,
437  unsigned Reg, const MDNode *Variable,
438  const MDNode *Expr);
439 
440 /// This version of the builder builds a DBG_VALUE intrinsic
441 /// for a machine operand and inserts it at position I.
444  const MCInstrDesc &MCID, bool IsIndirect,
445  MachineOperand &MO, const MDNode *Variable,
446  const MDNode *Expr);
447 
448 /// Clone a DBG_VALUE whose value has been spilled to FrameIndex.
451  const MachineInstr &Orig, int FrameIndex);
452 
453 /// Update a DBG_VALUE whose value has been spilled to FrameIndex. Useful when
454 /// modifying an instruction in place while iterating over a basic block.
455 void updateDbgValueForSpill(MachineInstr &Orig, int FrameIndex);
456 
457 inline unsigned getDefRegState(bool B) {
458  return B ? RegState::Define : 0;
459 }
460 inline unsigned getImplRegState(bool B) {
461  return B ? RegState::Implicit : 0;
462 }
463 inline unsigned getKillRegState(bool B) {
464  return B ? RegState::Kill : 0;
465 }
466 inline unsigned getDeadRegState(bool B) {
467  return B ? RegState::Dead : 0;
468 }
469 inline unsigned getUndefRegState(bool B) {
470  return B ? RegState::Undef : 0;
471 }
472 inline unsigned getInternalReadRegState(bool B) {
473  return B ? RegState::InternalRead : 0;
474 }
475 inline unsigned getDebugRegState(bool B) {
476  return B ? RegState::Debug : 0;
477 }
478 inline unsigned getRenamableRegState(bool B) {
479  return B ? RegState::Renamable : 0;
480 }
481 
482 /// Get all register state flags from machine operand \p RegOp.
483 inline unsigned getRegState(const MachineOperand &RegOp) {
484  assert(RegOp.isReg() && "Not a register operand");
485  return getDefRegState(RegOp.isDef()) |
486  getImplRegState(RegOp.isImplicit()) |
487  getKillRegState(RegOp.isKill()) |
488  getDeadRegState(RegOp.isDead()) |
489  getUndefRegState(RegOp.isUndef()) |
491  getDebugRegState(RegOp.isDebug()) |
494  RegOp.isRenamable());
495 }
496 
497 /// Helper class for constructing bundles of MachineInstrs.
498 ///
499 /// MIBundleBuilder can create a bundle from scratch by inserting new
500 /// MachineInstrs one at a time, or it can create a bundle from a sequence of
501 /// existing MachineInstrs in a basic block.
503  MachineBasicBlock &MBB;
506 
507 public:
508  /// Create an MIBundleBuilder that inserts instructions into a new bundle in
509  /// BB above the bundle or instruction at Pos.
511  : MBB(BB), Begin(Pos.getInstrIterator()), End(Begin) {}
512 
513  /// Create a bundle from the sequence of instructions between B and E.
516  : MBB(BB), Begin(B.getInstrIterator()), End(E.getInstrIterator()) {
517  assert(B != E && "No instructions to bundle");
518  ++B;
519  while (B != E) {
520  MachineInstr &MI = *B;
521  ++B;
522  MI.bundleWithPred();
523  }
524  }
525 
526  /// Create an MIBundleBuilder representing an existing instruction or bundle
527  /// that has MI as its head.
529  : MBB(*MI->getParent()), Begin(MI),
530  End(getBundleEnd(MI->getIterator())) {}
531 
532  /// Return a reference to the basic block containing this bundle.
533  MachineBasicBlock &getMBB() const { return MBB; }
534 
535  /// Return true if no instructions have been inserted in this bundle yet.
536  /// Empty bundles aren't representable in a MachineBasicBlock.
537  bool empty() const { return Begin == End; }
538 
539  /// Return an iterator to the first bundled instruction.
540  MachineBasicBlock::instr_iterator begin() const { return Begin; }
541 
542  /// Return an iterator beyond the last bundled instruction.
543  MachineBasicBlock::instr_iterator end() const { return End; }
544 
545  /// Insert MI into this bundle before I which must point to an instruction in
546  /// the bundle, or end().
548  MachineInstr *MI) {
549  MBB.insert(I, MI);
550  if (I == Begin) {
551  if (!empty())
552  MI->bundleWithSucc();
553  Begin = MI->getIterator();
554  return *this;
555  }
556  if (I == End) {
557  MI->bundleWithPred();
558  return *this;
559  }
560  // MI was inserted in the middle of the bundle, so its neighbors' flags are
561  // already fine. Update MI's bundle flags manually.
564  return *this;
565  }
566 
567  /// Insert MI into MBB by prepending it to the instructions in the bundle.
568  /// MI will become the first instruction in the bundle.
570  return insert(begin(), MI);
571  }
572 
573  /// Insert MI into MBB by appending it to the instructions in the bundle.
574  /// MI will become the last instruction in the bundle.
576  return insert(end(), MI);
577  }
578 };
579 
580 } // end namespace llvm
581 
582 #endif // LLVM_CODEGEN_MACHINEINSTRBUILDER_H
unsigned getTargetFlags() const
MachineBasicBlock & getMBB() const
Return a reference to the basic block containing this bundle.
const MachineInstrBuilder & setMemRefs(ArrayRef< MachineMemOperand *> MMOs) const
void bundleWithPred()
Bundle this instruction with its predecessor.
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
const MachineInstrBuilder & add(const MachineOperand &MO) const
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:258
MIBundleBuilder(MachineBasicBlock &BB, MachineBasicBlock::iterator Pos)
Create an MIBundleBuilder that inserts instructions into a new bundle in BB above the bundle or instr...
bool isDebugLabel() const
Definition: MachineInstr.h:997
static MachineOperand CreateCImm(const ConstantInt *CI)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:249
unsigned getRegState(const MachineOperand &RegOp)
Get all register state flags from machine operand RegOp.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static MachineOperand CreateMCSymbol(MCSymbol *Sym, unsigned char TargetFlags=0)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
const MachineInstrBuilder & addIntrinsicID(Intrinsic::ID ID) const
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
static MachineOperand CreateJTI(unsigned Idx, unsigned char TargetFlags=0)
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:163
unsigned getReg() const
getReg - Returns the register number.
unsigned Reg
const MachineInstrBuilder & addPredicate(CmpInst::Predicate Pred) const
unsigned getInternalReadRegState(bool B)
unsigned const TargetRegisterInfo * TRI
A debug info location.
Definition: DebugLoc.h:33
Metadata node.
Definition: Metadata.h:863
F(f)
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
const MachineInstrBuilder & addTargetIndex(unsigned Idx, int64_t Offset=0, unsigned char TargetFlags=0) const
bool isInternalRead() const
static MachineOperand CreateIntrinsicID(Intrinsic::ID ID)
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
MIBundleBuilder(MachineBasicBlock &BB, MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)
Create a bundle from the sequence of instructions between B and E.
The address of a basic block.
Definition: Constants.h:839
Holds all the information related to register banks.
A description of a memory reference used in the backend.
MachineInstr * buildDbgValueForSpill(MachineBasicBlock &BB, MachineBasicBlock::iterator I, const MachineInstr &Orig, int FrameIndex)
Clone a DBG_VALUE whose value has been spilled to FrameIndex.
MachineInstrBuilder(MachineFunction &F, MachineInstr *I)
Create a MachineInstrBuilder for manipulating an existing instruction.
const HexagonInstrInfo * TII
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
unsigned SubReg
void bundleWithSucc()
Bundle this instruction with its successor.
static MachineOperand CreateRegMask(const uint32_t *Mask)
CreateRegMask - Creates a register mask operand referencing Mask.
void copyImplicitOps(MachineFunction &MF, const MachineInstr &MI)
Copy implicit register operands from specified instruction to this instruction.
MIBundleBuilder & prepend(MachineInstr *MI)
Insert MI into MBB by prepending it to the instructions in the bundle.
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
void addMemOperand(MachineFunction &MF, MachineMemOperand *MO)
Add a MachineMemOperand to the machine instruction.
static MachineOperand CreatePredicate(unsigned Pred)
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
bool isInsideBundle() const
Return true if MI is in a bundle (but not the first MI in a bundle).
Definition: MachineInstr.h:349
unsigned getUndefRegState(bool B)
unsigned getKillRegState(bool B)
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:117
unsigned getDebugRegState(bool B)
TargetInstrInfo - Interface to description of machine instruction set.
unsigned getDeadRegState(bool B)
unsigned getDefRegState(bool B)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Address of a global value.
MachineInstrBundleIterator< MachineInstr > iterator
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const MachineInstrBuilder & addBlockAddress(const BlockAddress *BA, int64_t Offset=0, unsigned char TargetFlags=0) const
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned char TargetFlags=0)
const MachineInstrBuilder & addCImm(const ConstantInt *Val) const
static MachineOperand CreateFPImm(const ConstantFP *CFP)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const GlobalValue * getGlobal() const
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:263
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned char TargetFlags=0)
void setFlag(MIFlag Flag)
Set a MI flag.
Definition: MachineInstr.h:299
MachineBasicBlock::instr_iterator begin() const
Return an iterator to the first bundled instruction.
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:645
const DILabel * getDebugLabel() const
Return the debug label referenced by this DBG_LABEL instruction.
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned char TargetFlags=0)
static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset, unsigned char TargetFlags=0)
self_iterator getIterator()
Definition: ilist_node.h:81
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineInstrBuilder & add(ArrayRef< MachineOperand > MOs) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:209
void cloneMemRefs(MachineFunction &MF, const MachineInstr &MI)
Clone another MachineInstr&#39;s memory reference descriptor list and replace ours with it...
static MachineOperand CreateMetadata(const MDNode *Meta)
This is the shared class of boolean and integer constants.
Definition: Constants.h:83
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
unsigned getRenamableRegState(bool B)
MachineBasicBlock::instr_iterator end() const
Return an iterator beyond the last bundled instruction.
void setFlags(unsigned flags)
Definition: MachineInstr.h:303
MachineInstr * operator->() const
bool isDebugValue() const
Definition: MachineInstr.h:996
MachineOperand class - Representation of each machine instruction operand.
bool empty() const
Return true if no instructions have been inserted in this bundle yet.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned char TargetFlags=0) const
const MachineInstrBuilder & addDisp(const MachineOperand &Disp, int64_t off, unsigned char TargetFlags=0) const
void updateDbgValueForSpill(MachineInstr &Orig, int FrameIndex)
Update a DBG_VALUE whose value has been spilled to FrameIndex.
bool constrainSelectedInstRegOperands(MachineInstr &I, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
Mutate the newly-selected instruction I to constrain its (possibly generic) virtual register operands...
Definition: Utils.cpp:87
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly. ...
MIBundleBuilder & insert(MachineBasicBlock::instr_iterator I, MachineInstr *MI)
Insert MI into this bundle before I which must point to an instruction in the bundle, or end().
int64_t getImm() const
static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags=0)
bool isRenamable() const
isRenamable - Returns true if this register may be renamed, i.e.
const MachineInstrBuilder & copyImplicitOps(const MachineInstr &OtherMI) const
Copy all the implicit operands from OtherMI onto this one.
Representation of each machine instruction.
Definition: MachineInstr.h:63
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0)
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
void cloneMergedMemRefs(MachineFunction &MF, ArrayRef< const MachineInstr *> MIs)
Clone the merge of multiple MachineInstrs&#39; memory reference descriptors list and replace ours with it...
static MachineOperand CreateCFIIndex(unsigned CFIIndex)
int64_t getOffset() const
Return the offset from the symbol in this operand.
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned char TargetFlags=0) const
static MachineOperand CreateImm(int64_t Val)
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned getImplRegState(bool B)
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
const MachineInstrBuilder & cloneMergedMemRefs(ArrayRef< const MachineInstr *> OtherMIs) const
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Instructions::iterator instr_iterator
const MachineInstrBuilder & addJumpTableIndex(unsigned Idx, unsigned char TargetFlags=0) const
MIBundleBuilder & append(MachineInstr *MI)
Insert MI into MBB by appending it to the instructions in the bundle.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setMemRefs(MachineFunction &MF, ArrayRef< MachineMemOperand *> MemRefs)
Assign this MachineInstr&#39;s memory reference descriptor list.
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E&#39;s largest value.
Definition: BitmaskEnum.h:80
static const Function * getParent(const Value *V)
IRTranslator LLVM IR MI
Address of indexed Constant in Constant Pool.
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
MachineBasicBlock::instr_iterator getBundleEnd(MachineBasicBlock::instr_iterator I)
Returns an iterator pointing beyond the bundle containing I.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static MachineOperand CreateFI(int Idx)
MachineInstrBuilder(MachineFunction &F, MachineBasicBlock::iterator I)
MIBundleBuilder(MachineInstr *MI)
Create an MIBundleBuilder representing an existing instruction or bundle that has MI as its head...
bool constrainAllUses(const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI) const
Helper class for constructing bundles of MachineInstrs.
bool isImplicit() const