LLVM  6.0.0svn
MachineInstrBuilder.h
Go to the documentation of this file.
1 //===- CodeGen/MachineInstrBuilder.h - Simplify creation of MIs --*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file exposes a function named BuildMI, which is useful for dramatically
11 // simplifying how MachineInstr's are created. It allows use of code like this:
12 //
13 // M = BuildMI(MBB, MI, DL, TII.get(X86::ADD8rr), Dst)
14 // .addReg(argVal1)
15 // .addReg(argVal2);
16 //
17 //===----------------------------------------------------------------------===//
18 
19 #ifndef LLVM_CODEGEN_MACHINEINSTRBUILDER_H
20 #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H
21 
22 #include "llvm/ADT/ArrayRef.h"
28 #include "llvm/IR/InstrTypes.h"
29 #include "llvm/IR/Intrinsics.h"
31 #include <cassert>
32 #include <cstdint>
33 #include <utility>
34 
35 namespace llvm {
36 
37 class MCInstrDesc;
38 class MDNode;
39 
40 namespace RegState {
41 
42  enum {
43  Define = 0x2,
44  Implicit = 0x4,
45  Kill = 0x8,
46  Dead = 0x10,
47  Undef = 0x20,
48  EarlyClobber = 0x40,
49  Debug = 0x80,
50  InternalRead = 0x100,
54  };
55 
56 } // end namespace RegState
57 
59  MachineFunction *MF = nullptr;
60  MachineInstr *MI = nullptr;
61 
62 public:
63  MachineInstrBuilder() = default;
64 
65  /// Create a MachineInstrBuilder for manipulating an existing instruction.
66  /// F must be the machine function that was used to allocate I.
69  : MF(&F), MI(&*I) {}
70 
71  /// Allow automatic conversion to the machine instruction we are working on.
72  operator MachineInstr*() const { return MI; }
73  MachineInstr *operator->() const { return MI; }
74  operator MachineBasicBlock::iterator() const { return MI; }
75 
76  /// If conversion operators fail, use this method to get the MachineInstr
77  /// explicitly.
78  MachineInstr *getInstr() const { return MI; }
79 
80  /// Add a new virtual register operand.
81  const MachineInstrBuilder &addReg(unsigned RegNo, unsigned flags = 0,
82  unsigned SubReg = 0) const {
83  assert((flags & 0x1) == 0 &&
84  "Passing in 'true' to addReg is forbidden! Use enums instead.");
86  flags & RegState::Define,
87  flags & RegState::Implicit,
88  flags & RegState::Kill,
89  flags & RegState::Dead,
90  flags & RegState::Undef,
91  flags & RegState::EarlyClobber,
92  SubReg,
93  flags & RegState::Debug,
94  flags & RegState::InternalRead));
95  return *this;
96  }
97 
98  /// Add a virtual register definition operand.
99  const MachineInstrBuilder &addDef(unsigned RegNo, unsigned Flags = 0,
100  unsigned SubReg = 0) const {
101  return addReg(RegNo, Flags | RegState::Define, SubReg);
102  }
103 
104  /// Add a virtual register use operand. It is an error for Flags to contain
105  /// `RegState::Define` when calling this function.
106  const MachineInstrBuilder &addUse(unsigned RegNo, unsigned Flags = 0,
107  unsigned SubReg = 0) const {
108  assert(!(Flags & RegState::Define) &&
109  "Misleading addUse defines register, use addReg instead.");
110  return addReg(RegNo, Flags, SubReg);
111  }
112 
113  /// Add a new immediate operand.
114  const MachineInstrBuilder &addImm(int64_t Val) const {
115  MI->addOperand(*MF, MachineOperand::CreateImm(Val));
116  return *this;
117  }
118 
119  const MachineInstrBuilder &addCImm(const ConstantInt *Val) const {
120  MI->addOperand(*MF, MachineOperand::CreateCImm(Val));
121  return *this;
122  }
123 
124  const MachineInstrBuilder &addFPImm(const ConstantFP *Val) const {
126  return *this;
127  }
128 
130  unsigned char TargetFlags = 0) const {
132  return *this;
133  }
134 
135  const MachineInstrBuilder &addFrameIndex(int Idx) const {
136  MI->addOperand(*MF, MachineOperand::CreateFI(Idx));
137  return *this;
138  }
139 
141  int Offset = 0,
142  unsigned char TargetFlags = 0) const {
144  return *this;
145  }
146 
147  const MachineInstrBuilder &addTargetIndex(unsigned Idx, int64_t Offset = 0,
148  unsigned char TargetFlags = 0) const {
150  TargetFlags));
151  return *this;
152  }
153 
155  unsigned char TargetFlags = 0) const {
157  return *this;
158  }
159 
161  int64_t Offset = 0,
162  unsigned char TargetFlags = 0) const {
164  return *this;
165  }
166 
167  const MachineInstrBuilder &addExternalSymbol(const char *FnName,
168  unsigned char TargetFlags = 0) const {
170  return *this;
171  }
172 
174  int64_t Offset = 0,
175  unsigned char TargetFlags = 0) const {
177  return *this;
178  }
179 
182  return *this;
183  }
184 
186  MI->addMemOperand(*MF, MMO);
187  return *this;
188  }
189 
191  MachineInstr::mmo_iterator e) const {
192  MI->setMemRefs(b, e);
193  return *this;
194  }
195 
197  unsigned> MemOperandsRef) const {
198  MI->setMemRefs(MemOperandsRef);
199  return *this;
200  }
201 
202  const MachineInstrBuilder &add(const MachineOperand &MO) const {
203  MI->addOperand(*MF, MO);
204  return *this;
205  }
206 
208  for (const MachineOperand &MO : MOs) {
209  MI->addOperand(*MF, MO);
210  }
211  return *this;
212  }
213 
214  const MachineInstrBuilder &addMetadata(const MDNode *MD) const {
216  assert((MI->isDebugValue() ? static_cast<bool>(MI->getDebugVariable())
217  : true) &&
218  "first MDNode argument of a DBG_VALUE not a variable");
219  return *this;
220  }
221 
222  const MachineInstrBuilder &addCFIIndex(unsigned CFIIndex) const {
223  MI->addOperand(*MF, MachineOperand::CreateCFIIndex(CFIIndex));
224  return *this;
225  }
226 
229  return *this;
230  }
231 
234  return *this;
235  }
236 
238  unsigned char TargetFlags = 0) const {
240  return *this;
241  }
242 
243  const MachineInstrBuilder &setMIFlags(unsigned Flags) const {
244  MI->setFlags(Flags);
245  return *this;
246  }
247 
249  MI->setFlag(Flag);
250  return *this;
251  }
252 
253  // Add a displacement from an existing MachineOperand with an added offset.
254  const MachineInstrBuilder &addDisp(const MachineOperand &Disp, int64_t off,
255  unsigned char TargetFlags = 0) const {
256  // If caller specifies new TargetFlags then use it, otherwise the
257  // default behavior is to copy the target flags from the existing
258  // MachineOperand. This means if the caller wants to clear the
259  // target flags it needs to do so explicitly.
260  if (0 == TargetFlags)
261  TargetFlags = Disp.getTargetFlags();
262 
263  switch (Disp.getType()) {
264  default:
265  llvm_unreachable("Unhandled operand type in addDisp()");
267  return addImm(Disp.getImm() + off);
269  return addConstantPoolIndex(Disp.getIndex(), Disp.getOffset() + off,
270  TargetFlags);
272  return addGlobalAddress(Disp.getGlobal(), Disp.getOffset() + off,
273  TargetFlags);
274  }
275  }
276 
277  /// Copy all the implicit operands from OtherMI onto this one.
278  const MachineInstrBuilder &
279  copyImplicitOps(const MachineInstr &OtherMI) const {
280  MI->copyImplicitOps(*MF, OtherMI);
281  return *this;
282  }
283 };
284 
285 /// Builder interface. Specify how to create the initial instruction itself.
287  const MCInstrDesc &MCID) {
288  return MachineInstrBuilder(MF, MF.CreateMachineInstr(MCID, DL));
289 }
290 
291 /// This version of the builder sets up the first operand as a
292 /// destination virtual register.
294  const MCInstrDesc &MCID, unsigned DestReg) {
295  return MachineInstrBuilder(MF, MF.CreateMachineInstr(MCID, DL))
296  .addReg(DestReg, RegState::Define);
297 }
298 
299 /// This version of the builder inserts the newly-built instruction before
300 /// the given position in the given MachineBasicBlock, and sets up the first
301 /// operand as a destination virtual register.
304  const DebugLoc &DL, const MCInstrDesc &MCID,
305  unsigned DestReg) {
306  MachineFunction &MF = *BB.getParent();
307  MachineInstr *MI = MF.CreateMachineInstr(MCID, DL);
308  BB.insert(I, MI);
309  return MachineInstrBuilder(MF, MI).addReg(DestReg, RegState::Define);
310 }
311 
312 /// This version of the builder inserts the newly-built instruction before
313 /// the given position in the given MachineBasicBlock, and sets up the first
314 /// operand as a destination virtual register.
315 ///
316 /// If \c I is inside a bundle, then the newly inserted \a MachineInstr is
317 /// added to the same bundle.
320  const DebugLoc &DL, const MCInstrDesc &MCID,
321  unsigned DestReg) {
322  MachineFunction &MF = *BB.getParent();
323  MachineInstr *MI = MF.CreateMachineInstr(MCID, DL);
324  BB.insert(I, MI);
325  return MachineInstrBuilder(MF, MI).addReg(DestReg, RegState::Define);
326 }
327 
329  const DebugLoc &DL, const MCInstrDesc &MCID,
330  unsigned DestReg) {
331  // Calling the overload for instr_iterator is always correct. However, the
332  // definition is not available in headers, so inline the check.
333  if (I.isInsideBundle())
334  return BuildMI(BB, MachineBasicBlock::instr_iterator(I), DL, MCID, DestReg);
335  return BuildMI(BB, MachineBasicBlock::iterator(I), DL, MCID, DestReg);
336 }
337 
339  const DebugLoc &DL, const MCInstrDesc &MCID,
340  unsigned DestReg) {
341  return BuildMI(BB, *I, DL, MCID, DestReg);
342 }
343 
344 /// This version of the builder inserts the newly-built instruction before the
345 /// given position in the given MachineBasicBlock, and does NOT take a
346 /// destination register.
349  const DebugLoc &DL,
350  const MCInstrDesc &MCID) {
351  MachineFunction &MF = *BB.getParent();
352  MachineInstr *MI = MF.CreateMachineInstr(MCID, DL);
353  BB.insert(I, MI);
354  return MachineInstrBuilder(MF, MI);
355 }
356 
359  const DebugLoc &DL,
360  const MCInstrDesc &MCID) {
361  MachineFunction &MF = *BB.getParent();
362  MachineInstr *MI = MF.CreateMachineInstr(MCID, DL);
363  BB.insert(I, MI);
364  return MachineInstrBuilder(MF, MI);
365 }
366 
368  const DebugLoc &DL,
369  const MCInstrDesc &MCID) {
370  // Calling the overload for instr_iterator is always correct. However, the
371  // definition is not available in headers, so inline the check.
372  if (I.isInsideBundle())
373  return BuildMI(BB, MachineBasicBlock::instr_iterator(I), DL, MCID);
374  return BuildMI(BB, MachineBasicBlock::iterator(I), DL, MCID);
375 }
376 
378  const DebugLoc &DL,
379  const MCInstrDesc &MCID) {
380  return BuildMI(BB, *I, DL, MCID);
381 }
382 
383 /// This version of the builder inserts the newly-built instruction at the end
384 /// of the given MachineBasicBlock, and does NOT take a destination register.
386  const MCInstrDesc &MCID) {
387  return BuildMI(*BB, BB->end(), DL, MCID);
388 }
389 
390 /// This version of the builder inserts the newly-built instruction at the
391 /// end of the given MachineBasicBlock, and sets up the first operand as a
392 /// destination virtual register.
394  const MCInstrDesc &MCID, unsigned DestReg) {
395  return BuildMI(*BB, BB->end(), DL, MCID, DestReg);
396 }
397 
398 /// This version of the builder builds a DBG_VALUE intrinsic
399 /// for either a value in a register or a register-indirect
400 /// address. The convention is that a DBG_VALUE is indirect iff the
401 /// second operand is an immediate.
403  const MCInstrDesc &MCID, bool IsIndirect,
404  unsigned Reg, const MDNode *Variable,
405  const MDNode *Expr);
406 
407 /// This version of the builder builds a DBG_VALUE intrinsic
408 /// for either a value in a register or a register-indirect
409 /// address and inserts it at position I.
412  const MCInstrDesc &MCID, bool IsIndirect,
413  unsigned Reg, const MDNode *Variable,
414  const MDNode *Expr);
415 
416 /// Clone a DBG_VALUE whose value has been spilled to FrameIndex.
419  const MachineInstr &Orig, int FrameIndex);
420 
421 /// Update a DBG_VALUE whose value has been spilled to FrameIndex. Useful when
422 /// modifying an instruction in place while iterating over a basic block.
423 void updateDbgValueForSpill(MachineInstr &Orig, int FrameIndex);
424 
425 inline unsigned getDefRegState(bool B) {
426  return B ? RegState::Define : 0;
427 }
428 inline unsigned getImplRegState(bool B) {
429  return B ? RegState::Implicit : 0;
430 }
431 inline unsigned getKillRegState(bool B) {
432  return B ? RegState::Kill : 0;
433 }
434 inline unsigned getDeadRegState(bool B) {
435  return B ? RegState::Dead : 0;
436 }
437 inline unsigned getUndefRegState(bool B) {
438  return B ? RegState::Undef : 0;
439 }
440 inline unsigned getInternalReadRegState(bool B) {
441  return B ? RegState::InternalRead : 0;
442 }
443 inline unsigned getDebugRegState(bool B) {
444  return B ? RegState::Debug : 0;
445 }
446 
447 /// Get all register state flags from machine operand \p RegOp.
448 inline unsigned getRegState(const MachineOperand &RegOp) {
449  assert(RegOp.isReg() && "Not a register operand");
450  return getDefRegState(RegOp.isDef()) |
451  getImplRegState(RegOp.isImplicit()) |
452  getKillRegState(RegOp.isKill()) |
453  getDeadRegState(RegOp.isDead()) |
454  getUndefRegState(RegOp.isUndef()) |
456  getDebugRegState(RegOp.isDebug());
457 }
458 
459 /// Helper class for constructing bundles of MachineInstrs.
460 ///
461 /// MIBundleBuilder can create a bundle from scratch by inserting new
462 /// MachineInstrs one at a time, or it can create a bundle from a sequence of
463 /// existing MachineInstrs in a basic block.
465  MachineBasicBlock &MBB;
468 
469 public:
470  /// Create an MIBundleBuilder that inserts instructions into a new bundle in
471  /// BB above the bundle or instruction at Pos.
473  : MBB(BB), Begin(Pos.getInstrIterator()), End(Begin) {}
474 
475  /// Create a bundle from the sequence of instructions between B and E.
478  : MBB(BB), Begin(B.getInstrIterator()), End(E.getInstrIterator()) {
479  assert(B != E && "No instructions to bundle");
480  ++B;
481  while (B != E) {
482  MachineInstr &MI = *B;
483  ++B;
484  MI.bundleWithPred();
485  }
486  }
487 
488  /// Create an MIBundleBuilder representing an existing instruction or bundle
489  /// that has MI as its head.
491  : MBB(*MI->getParent()), Begin(MI),
492  End(getBundleEnd(MI->getIterator())) {}
493 
494  /// Return a reference to the basic block containing this bundle.
495  MachineBasicBlock &getMBB() const { return MBB; }
496 
497  /// Return true if no instructions have been inserted in this bundle yet.
498  /// Empty bundles aren't representable in a MachineBasicBlock.
499  bool empty() const { return Begin == End; }
500 
501  /// Return an iterator to the first bundled instruction.
502  MachineBasicBlock::instr_iterator begin() const { return Begin; }
503 
504  /// Return an iterator beyond the last bundled instruction.
506 
507  /// Insert MI into this bundle before I which must point to an instruction in
508  /// the bundle, or end().
510  MachineInstr *MI) {
511  MBB.insert(I, MI);
512  if (I == Begin) {
513  if (!empty())
514  MI->bundleWithSucc();
515  Begin = MI->getIterator();
516  return *this;
517  }
518  if (I == End) {
519  MI->bundleWithPred();
520  return *this;
521  }
522  // MI was inserted in the middle of the bundle, so its neighbors' flags are
523  // already fine. Update MI's bundle flags manually.
526  return *this;
527  }
528 
529  /// Insert MI into MBB by prepending it to the instructions in the bundle.
530  /// MI will become the first instruction in the bundle.
532  return insert(begin(), MI);
533  }
534 
535  /// Insert MI into MBB by appending it to the instructions in the bundle.
536  /// MI will become the last instruction in the bundle.
538  return insert(end(), MI);
539  }
540 };
541 
542 } // end namespace llvm
543 
544 #endif // LLVM_CODEGEN_MACHINEINSTRBUILDER_H
unsigned getTargetFlags() const
MachineBasicBlock & getMBB() const
Return a reference to the basic block containing this bundle.
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:244
MIBundleBuilder(MachineBasicBlock &BB, MachineBasicBlock::iterator Pos)
Create an MIBundleBuilder that inserts instructions into a new bundle in BB above the bundle or instr...
static MachineOperand CreateCImm(const ConstantInt *CI)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:235
unsigned getRegState(const MachineOperand &RegOp)
Get all register state flags from machine operand RegOp.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
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:42
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
const MachineInstrBuilder & addPredicate(CmpInst::Predicate Pred) const
unsigned getInternalReadRegState(bool B)
A debug info location.
Definition: DebugLoc.h:34
Metadata node.
Definition: Metadata.h:862
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
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:813
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.
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)
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
unsigned SubReg
Reg
All possible values of the reg field in the ModR/M byte.
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:33
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:235
unsigned getUndefRegState(bool B)
unsigned getKillRegState(bool B)
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:121
unsigned getDebugRegState(bool B)
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:264
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned char TargetFlags=0)
void setFlag(MIFlag Flag)
Set a MI flag.
Definition: MachineInstr.h:185
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:853
static const unsigned End
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:82
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & add(ArrayRef< MachineOperand > MOs) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static MachineOperand CreateMetadata(const MDNode *Meta)
This is the shared class of boolean and integer constants.
Definition: Constants.h:84
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
MachineBasicBlock::instr_iterator end() const
Return an iterator beyond the last bundled instruction.
void setFlags(unsigned flags)
Definition: MachineInstr.h:189
MachineInstr * operator->() const
bool isDebugValue() const
Definition: MachineInstr.h:816
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.
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)
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:59
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & setMemRefs(std::pair< MachineInstr::mmo_iterator, unsigned > MemOperandsRef) const
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
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 & 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())
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:81
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
const MachineInstrBuilder & setMemRefs(MachineInstr::mmo_iterator b, MachineInstr::mmo_iterator e) const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static MachineOperand CreateFI(int Idx)
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineInstr&#39;s memory reference descriptor list.
MachineInstrBuilder(MachineFunction &F, MachineBasicBlock::iterator I)
MIBundleBuilder(MachineInstr *MI)
Create an MIBundleBuilder representing an existing instruction or bundle that has MI as its head...
Helper class for constructing bundles of MachineInstrs.
bool isImplicit() const