LLVM  4.0.0
MachineIRBuilder.h
Go to the documentation of this file.
1 //===-- llvm/CodeGen/GlobalISel/MachineIRBuilder.h - MIBuilder --*- 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 /// \file
10 /// This file declares the MachineIRBuilder class.
11 /// This is a helper class to build MachineInstr.
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H
15 #define LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H
16 
18 
22 #include "llvm/IR/Constants.h"
23 #include "llvm/IR/DebugLoc.h"
24 
25 #include <queue>
26 
27 namespace llvm {
28 
29 // Forward declarations.
30 class MachineFunction;
31 class MachineInstr;
32 class TargetInstrInfo;
33 
34 /// Helper class to build MachineInstr.
35 /// It keeps internally the insertion point and debug location for all
36 /// the new instructions we want to create.
37 /// This information can be modify via the related setters.
39  /// MachineFunction under construction.
40  MachineFunction *MF;
41  /// Information used to access the description of the opcodes.
42  const TargetInstrInfo *TII;
43  /// Information used to verify types are consistent.
44  const MachineRegisterInfo *MRI;
45  /// Debug location to be set to any instruction we create.
46  DebugLoc DL;
47 
48  /// Fields describing the insertion point.
49  /// @{
50  MachineBasicBlock *MBB;
52  /// @}
53 
54  std::function<void(MachineInstr *)> InsertedInstr;
55 
56  const TargetInstrInfo &getTII() {
57  assert(TII && "TargetInstrInfo is not set");
58  return *TII;
59  }
60 
61  void validateTruncExt(unsigned Dst, unsigned Src, bool IsExtend);
62 
63 public:
64  /// Getter for the function we currently build.
66  assert(MF && "MachineFunction is not set");
67  return *MF;
68  }
69 
70  /// Getter for the basic block we currently build.
72  assert(MBB && "MachineBasicBlock is not set");
73  return *MBB;
74  }
75 
76  /// Current insertion point for new instructions.
78  return II;
79  }
80 
81  /// Set the insertion point before the specified position.
82  /// \pre MBB must be in getMF().
83  /// \pre II must be a valid iterator in MBB.
85  /// @}
86 
87  /// Setters for the insertion point.
88  /// @{
89  /// Set the MachineFunction where to build instructions.
90  void setMF(MachineFunction &);
91 
92  /// Set the insertion point to the end of \p MBB.
93  /// \pre \p MBB must be contained by getMF().
94  void setMBB(MachineBasicBlock &MBB);
95 
96  /// Set the insertion point to before MI.
97  /// \pre MI must be in getMF().
98  void setInstr(MachineInstr &MI);
99  /// @}
100 
101  /// Control where instructions we create are recorded (typically for
102  /// visiting again later during legalization).
103  /// @{
104  void recordInsertions(std::function<void(MachineInstr *)> InsertedInstr);
106  /// @}
107 
108  /// Set the debug location to \p DL for all the next build instructions.
109  void setDebugLoc(const DebugLoc &DL) { this->DL = DL; }
110 
111  /// Build and insert <empty> = \p Opcode <empty>.
112  /// The insertion point is the one set by the last call of either
113  /// setBasicBlock or setMI.
114  ///
115  /// \pre setBasicBlock or setMI must have been called.
116  ///
117  /// \return a MachineInstrBuilder for the newly created instruction.
118  MachineInstrBuilder buildInstr(unsigned Opcode);
119 
120  /// Build but don't insert <empty> = \p Opcode <empty>.
121  ///
122  /// \pre setMF, setBasicBlock or setMI must have been called.
123  ///
124  /// \return a MachineInstrBuilder for the newly created instruction.
125  MachineInstrBuilder buildInstrNoInsert(unsigned Opcode);
126 
127  /// Insert an existing instruction at the insertion point.
129 
130  /// Build and insert \p Res<def> = G_FRAME_INDEX \p Idx
131  ///
132  /// G_FRAME_INDEX materializes the address of an alloca value or other
133  /// stack-based object.
134  ///
135  /// \pre setBasicBlock or setMI must have been called.
136  /// \pre \p Res must be a generic virtual register with pointer type.
137  ///
138  /// \return a MachineInstrBuilder for the newly created instruction.
139  MachineInstrBuilder buildFrameIndex(unsigned Res, int Idx);
140 
141  /// Build and insert \p Res<def> = G_GLOBAL_VALUE \p GV
142  ///
143  /// G_GLOBAL_VALUE materializes the address of the specified global
144  /// into \p Res.
145  ///
146  /// \pre setBasicBlock or setMI must have been called.
147  /// \pre \p Res must be a generic virtual register with pointer type
148  /// in the same address space as \p GV.
149  ///
150  /// \return a MachineInstrBuilder for the newly created instruction.
151  MachineInstrBuilder buildGlobalValue(unsigned Res, const GlobalValue *GV);
152 
153  /// Build and insert \p Res<def> = G_ADD \p Op0, \p Op1
154  ///
155  /// G_ADD sets \p Res to the sum of integer parameters \p Op0 and \p Op1,
156  /// truncated to their width.
157  ///
158  /// \pre setBasicBlock or setMI must have been called.
159  /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
160  /// with the same (scalar or vector) type).
161  ///
162  /// \return a MachineInstrBuilder for the newly created instruction.
163  MachineInstrBuilder buildAdd(unsigned Res, unsigned Op0,
164  unsigned Op1);
165 
166  /// Build and insert \p Res<def> = G_SUB \p Op0, \p Op1
167  ///
168  /// G_SUB sets \p Res to the sum of integer parameters \p Op0 and \p Op1,
169  /// truncated to their width.
170  ///
171  /// \pre setBasicBlock or setMI must have been called.
172  /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
173  /// with the same (scalar or vector) type).
174  ///
175  /// \return a MachineInstrBuilder for the newly created instruction.
176  MachineInstrBuilder buildSub(unsigned Res, unsigned Op0,
177  unsigned Op1);
178 
179  /// Build and insert \p Res<def> = G_MUL \p Op0, \p Op1
180  ///
181  /// G_MUL sets \p Res to the sum of integer parameters \p Op0 and \p Op1,
182  /// truncated to their width.
183  ///
184  /// \pre setBasicBlock or setMI must have been called.
185  /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
186  /// with the same (scalar or vector) type).
187  ///
188  /// \return a MachineInstrBuilder for the newly created instruction.
189  MachineInstrBuilder buildMul(unsigned Res, unsigned Op0,
190  unsigned Op1);
191 
192  /// Build and insert \p Res<def> = G_GEP \p Op0, \p Op1
193  ///
194  /// G_GEP adds \p Op1 bytes to the pointer specified by \p Op0,
195  /// storing the resulting pointer in \p Res.
196  ///
197  /// \pre setBasicBlock or setMI must have been called.
198  /// \pre \p Res and \p Op0 must be generic virtual registers with pointer
199  /// type.
200  /// \pre \p Op1 must be a generic virtual register with scalar type.
201  ///
202  /// \return a MachineInstrBuilder for the newly created instruction.
203  MachineInstrBuilder buildGEP(unsigned Res, unsigned Op0,
204  unsigned Op1);
205 
206  /// Build and insert \p Res<def>, \p CarryOut<def> = G_UADDE \p Op0,
207  /// \p Op1, \p CarryIn
208  ///
209  /// G_UADDE sets \p Res to \p Op0 + \p Op1 + \p CarryIn (truncated to the bit
210  /// width) and sets \p CarryOut to 1 if the result overflowed in unsigned
211  /// arithmetic.
212  ///
213  /// \pre setBasicBlock or setMI must have been called.
214  /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
215  /// with the same scalar type.
216  /// \pre \p CarryOut and \p CarryIn must be generic virtual
217  /// registers with the same scalar type (typically s1)
218  ///
219  /// \return The newly created instruction.
220  MachineInstrBuilder buildUAdde(unsigned Res, unsigned CarryOut, unsigned Op0,
221  unsigned Op1, unsigned CarryIn);
222 
223  /// Build and insert \p Res<def> = G_ANYEXT \p Op0
224  ///
225  /// G_ANYEXT produces a register of the specified width, with bits 0 to
226  /// sizeof(\p Ty) * 8 set to \p Op. The remaining bits are unspecified
227  /// (i.e. this is neither zero nor sign-extension). For a vector register,
228  /// each element is extended individually.
229  ///
230  /// \pre setBasicBlock or setMI must have been called.
231  /// \pre \p Res must be a generic virtual register with scalar or vector type.
232  /// \pre \p Op must be a generic virtual register with scalar or vector type.
233  /// \pre \p Op must be smaller than \p Res
234  ///
235  /// \return The newly created instruction.
236  MachineInstrBuilder buildAnyExt(unsigned Res, unsigned Op);
237 
238  /// Build and insert \p Res<def> = G_SEXT \p Op
239  ///
240  /// G_SEXT produces a register of the specified width, with bits 0 to
241  /// sizeof(\p Ty) * 8 set to \p Op. The remaining bits are duplicated from the
242  /// high bit of \p Op (i.e. 2s-complement sign extended).
243  ///
244  /// \pre setBasicBlock or setMI must have been called.
245  /// \pre \p Res must be a generic virtual register with scalar or vector type.
246  /// \pre \p Op must be a generic virtual register with scalar or vector type.
247  /// \pre \p Op must be smaller than \p Res
248  ///
249  /// \return The newly created instruction.
250  MachineInstrBuilder buildSExt(unsigned Res, unsigned Op);
251 
252  /// Build and insert \p Res<def> = G_ZEXT \p Op
253  ///
254  /// G_ZEXT produces a register of the specified width, with bits 0 to
255  /// sizeof(\p Ty) * 8 set to \p Op. The remaining bits are 0. For a vector
256  /// register, each element is extended individually.
257  ///
258  /// \pre setBasicBlock or setMI must have been called.
259  /// \pre \p Res must be a generic virtual register with scalar or vector type.
260  /// \pre \p Op must be a generic virtual register with scalar or vector type.
261  /// \pre \p Op must be smaller than \p Res
262  ///
263  /// \return The newly created instruction.
264  MachineInstrBuilder buildZExt(unsigned Res, unsigned Op);
265 
266  /// Build and insert \p Res<def> = G_SEXT \p Op, \p Res = G_TRUNC \p Op, or
267  /// \p Res = COPY \p Op depending on the differing sizes of \p Res and \p Op.
268  /// ///
269  /// \pre setBasicBlock or setMI must have been called.
270  /// \pre \p Res must be a generic virtual register with scalar or vector type.
271  /// \pre \p Op must be a generic virtual register with scalar or vector type.
272  ///
273  /// \return The newly created instruction.
274  MachineInstrBuilder buildSExtOrTrunc(unsigned Res, unsigned Op);
275 
276  /// Build and insert G_BR \p Dest
277  ///
278  /// G_BR is an unconditional branch to \p Dest.
279  ///
280  /// \pre setBasicBlock or setMI must have been called.
281  ///
282  /// \return a MachineInstrBuilder for the newly created instruction.
284 
285  /// Build and insert G_BRCOND \p Tst, \p Dest
286  ///
287  /// G_BRCOND is a conditional branch to \p Dest.
288  ///
289  /// \pre setBasicBlock or setMI must have been called.
290  /// \pre \p Tst must be a generic virtual register with scalar
291  /// type. At the beginning of legalization, this will be a single
292  /// bit (s1). Targets with interesting flags registers may change
293  /// this. For a wider type, whether the branch is taken must only
294  /// depend on bit 0 (for now).
295  ///
296  /// \return The newly created instruction.
298 
299  /// Build and insert \p Res = G_CONSTANT \p Val
300  ///
301  /// G_CONSTANT is an integer constant with the specified size and value. \p
302  /// Val will be extended or truncated to the size of \p Reg.
303  ///
304  /// \pre setBasicBlock or setMI must have been called.
305  /// \pre \p Res must be a generic virtual register with scalar or pointer
306  /// type.
307  ///
308  /// \return The newly created instruction.
309  MachineInstrBuilder buildConstant(unsigned Res, const ConstantInt &Val);
310 
311  /// Build and insert \p Res = G_CONSTANT \p Val
312  ///
313  /// G_CONSTANT is an integer constant with the specified size and value.
314  ///
315  /// \pre setBasicBlock or setMI must have been called.
316  /// \pre \p Res must be a generic virtual register with scalar type.
317  ///
318  /// \return The newly created instruction.
319  MachineInstrBuilder buildConstant(unsigned Res, int64_t Val);
320 
321  /// Build and insert \p Res = G_FCONSTANT \p Val
322  ///
323  /// G_FCONSTANT is a floating-point constant with the specified size and
324  /// value.
325  ///
326  /// \pre setBasicBlock or setMI must have been called.
327  /// \pre \p Res must be a generic virtual register with scalar type.
328  ///
329  /// \return The newly created instruction.
330  MachineInstrBuilder buildFConstant(unsigned Res, const ConstantFP &Val);
331 
332  /// Build and insert \p Res<def> = COPY Op
333  ///
334  /// Register-to-register COPY sets \p Res to \p Op.
335  ///
336  /// \pre setBasicBlock or setMI must have been called.
337  ///
338  /// \return a MachineInstrBuilder for the newly created instruction.
339  MachineInstrBuilder buildCopy(unsigned Res, unsigned Op);
340 
341  /// Build and insert `Res<def> = G_LOAD Addr, MMO`.
342  ///
343  /// Loads the value stored at \p Addr. Puts the result in \p Res.
344  ///
345  /// \pre setBasicBlock or setMI must have been called.
346  /// \pre \p Res must be a generic virtual register.
347  /// \pre \p Addr must be a generic virtual register with pointer type.
348  ///
349  /// \return a MachineInstrBuilder for the newly created instruction.
350  MachineInstrBuilder buildLoad(unsigned Res, unsigned Addr,
351  MachineMemOperand &MMO);
352 
353  /// Build and insert `G_STORE Val, Addr, MMO`.
354  ///
355  /// Stores the value \p Val to \p Addr.
356  ///
357  /// \pre setBasicBlock or setMI must have been called.
358  /// \pre \p Val must be a generic virtual register.
359  /// \pre \p Addr must be a generic virtual register with pointer type.
360  ///
361  /// \return a MachineInstrBuilder for the newly created instruction.
362  MachineInstrBuilder buildStore(unsigned Val, unsigned Addr,
363  MachineMemOperand &MMO);
364 
365  /// Build and insert `Res0<def>, ... = G_EXTRACT Src, Idx0, ...`.
366  ///
367  /// If \p Res[i] has size N bits, G_EXTRACT sets \p Res[i] to bits `[Idxs[i],
368  /// Idxs[i] + N)` of \p Src.
369  ///
370  /// \pre setBasicBlock or setMI must have been called.
371  /// \pre Indices must be in ascending order of bit position.
372  /// \pre Each member of \p Results and \p Src must be a generic
373  /// virtual register.
374  ///
375  /// \return a MachineInstrBuilder for the newly created instruction.
377  ArrayRef<uint64_t> Indices, unsigned Src);
378 
379  /// Build and insert \p Res<def> = G_SEQUENCE \p Op0, \p Idx0...
380  ///
381  /// G_SEQUENCE inserts each element of Ops into an IMPLICIT_DEF register,
382  /// where each entry starts at the bit-index specified by \p Indices.
383  ///
384  /// \pre setBasicBlock or setMI must have been called.
385  /// \pre The final element of the sequence must not extend past the end of the
386  /// destination register.
387  /// \pre The bits defined by each Op (derived from index and scalar size) must
388  /// not overlap.
389  /// \pre \p Indices must be in ascending order of bit position.
390  ///
391  /// \return a MachineInstrBuilder for the newly created instruction.
392  MachineInstrBuilder buildSequence(unsigned Res,
393  ArrayRef<unsigned> Ops,
394  ArrayRef<uint64_t> Indices);
395 
397 
398  template <typename... ArgTys>
400  unsigned BitIndex, ArgTys... Args) {
401  MIB.addUse(Reg).addImm(BitIndex);
402  addUsesWithIndices(MIB, Args...);
403  }
404 
405  template <typename... ArgTys>
406  MachineInstrBuilder buildSequence(unsigned Res, unsigned Op,
407  unsigned Index, ArgTys... Args) {
408  MachineInstrBuilder MIB =
409  buildInstr(TargetOpcode::G_SEQUENCE).addDef(Res);
410  addUsesWithIndices(MIB, Op, Index, Args...);
411  return MIB;
412  }
413 
414  template <typename... ArgTys>
415  MachineInstrBuilder buildInsert(unsigned Res, unsigned Src,
416  unsigned Op, unsigned Index, ArgTys... Args) {
417  MachineInstrBuilder MIB =
418  buildInstr(TargetOpcode::G_INSERT).addDef(Res).addUse(Src);
419  addUsesWithIndices(MIB, Op, Index, Args...);
420  return MIB;
421  }
422 
423  /// Build and insert either a G_INTRINSIC (if \p HasSideEffects is false) or
424  /// G_INTRINSIC_W_SIDE_EFFECTS instruction. Its first operand will be the
425  /// result register definition unless \p Reg is NoReg (== 0). The second
426  /// operand will be the intrinsic's ID.
427  ///
428  /// Callers are expected to add the required definitions and uses afterwards.
429  ///
430  /// \pre setBasicBlock or setMI must have been called.
431  ///
432  /// \return a MachineInstrBuilder for the newly created instruction.
434  bool HasSideEffects);
435 
436  /// Build and insert \p Res<def> = G_FPTRUNC \p Op
437  ///
438  /// G_FPTRUNC converts a floating-point value into one with a smaller type.
439  ///
440  /// \pre setBasicBlock or setMI must have been called.
441  /// \pre \p Res must be a generic virtual register with scalar or vector type.
442  /// \pre \p Op must be a generic virtual register with scalar or vector type.
443  /// \pre \p Res must be smaller than \p Op
444  ///
445  /// \return The newly created instruction.
446  MachineInstrBuilder buildFPTrunc(unsigned Res, unsigned Op);
447 
448  /// Build and insert \p Res<def> = G_TRUNC \p Op
449  ///
450  /// G_TRUNC extracts the low bits of a type. For a vector type each element is
451  /// truncated independently before being packed into the destination.
452  ///
453  /// \pre setBasicBlock or setMI must have been called.
454  /// \pre \p Res must be a generic virtual register with scalar or vector type.
455  /// \pre \p Op must be a generic virtual register with scalar or vector type.
456  /// \pre \p Res must be smaller than \p Op
457  ///
458  /// \return The newly created instruction.
459  MachineInstrBuilder buildTrunc(unsigned Res, unsigned Op);
460 
461  /// Build and insert a \p Res = G_ICMP \p Pred, \p Op0, \p Op1
462  ///
463  /// \pre setBasicBlock or setMI must have been called.
464 
465  /// \pre \p Res must be a generic virtual register with scalar or
466  /// vector type. Typically this starts as s1 or <N x s1>.
467  /// \pre \p Op0 and Op1 must be generic virtual registers with the
468  /// same number of elements as \p Res. If \p Res is a scalar,
469  /// \p Op0 must be either a scalar or pointer.
470  /// \pre \p Pred must be an integer predicate.
471  ///
472  /// \return a MachineInstrBuilder for the newly created instruction.
474  unsigned Res, unsigned Op0, unsigned Op1);
475 
476  /// Build and insert a \p Res = G_FCMP \p Pred\p Op0, \p Op1
477  ///
478  /// \pre setBasicBlock or setMI must have been called.
479 
480  /// \pre \p Res must be a generic virtual register with scalar or
481  /// vector type. Typically this starts as s1 or <N x s1>.
482  /// \pre \p Op0 and Op1 must be generic virtual registers with the
483  /// same number of elements as \p Res (or scalar, if \p Res is
484  /// scalar).
485  /// \pre \p Pred must be a floating-point predicate.
486  ///
487  /// \return a MachineInstrBuilder for the newly created instruction.
489  unsigned Res, unsigned Op0, unsigned Op1);
490 
491  /// Build and insert a \p Res = G_SELECT \p Tst, \p Op0, \p Op1
492  ///
493  /// \pre setBasicBlock or setMI must have been called.
494  /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
495  /// with the same type.
496  /// \pre \p Tst must be a generic virtual register with scalar, pointer or
497  /// vector type. If vector then it must have the same number of
498  /// elements as the other parameters.
499  ///
500  /// \return a MachineInstrBuilder for the newly created instruction.
501  MachineInstrBuilder buildSelect(unsigned Res, unsigned Tst,
502  unsigned Op0, unsigned Op1);
503 };
504 
505 } // End namespace llvm.
506 #endif // LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H
MachineBasicBlock & getMBB()
Getter for the basic block we currently build.
MachineInstrBuilder buildGEP(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_GEP Op0, Op1.
MachineInstrBuilder buildZExt(unsigned Res, unsigned Op)
Build and insert Res<def> = G_ZEXT Op.
void setDebugLoc(const DebugLoc &DL)
Set the debug location to DL for all the next build instructions.
Function Alias Analysis Results
MachineInstrBuilder buildTrunc(unsigned Res, unsigned Op)
Build and insert Res<def> = G_TRUNC Op.
A debug info location.
Definition: DebugLoc.h:34
MachineInstrBuilder buildSub(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_SUB Op0, Op1.
MachineInstrBuilder buildAnyExt(unsigned Res, unsigned Op)
Build and insert Res<def> = G_ANYEXT Op0.
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
MachineInstrBuilder buildFPTrunc(unsigned Res, unsigned Op)
Build and insert Res<def> = G_FPTRUNC Op.
MachineInstrBuilder buildSelect(unsigned Res, unsigned Tst, unsigned Op0, unsigned Op1)
Build and insert a Res = G_SELECT Tst, Op0, Op1.
MachineInstrBuilder buildFCmp(CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
Build and insert a Res = G_FCMP PredOp0, Op1.
MachineInstrBuilder buildSequence(unsigned Res, unsigned Op, unsigned Index, ArgTys...Args)
MachineInstrBuilder buildStore(unsigned Val, unsigned Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
A description of a memory reference used in the backend.
void setInsertPt(MachineBasicBlock &MBB, MachineBasicBlock::iterator II)
Set the insertion point before the specified position.
MachineInstrBuilder buildFConstant(unsigned Res, const ConstantFP &Val)
Build and insert Res = G_FCONSTANT Val.
Reg
All possible values of the reg field in the ModR/M byte.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineInstrBuilder buildExtract(ArrayRef< unsigned > Results, ArrayRef< uint64_t > Indices, unsigned Src)
Build and insert `Res0<def>, ...
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
MachineFunction & getMF()
Getter for the function we currently build.
void recordInsertions(std::function< void(MachineInstr *)> InsertedInstr)
Control where instructions we create are recorded (typically for visiting again later during legaliza...
TargetInstrInfo - Interface to description of machine instruction set.
MachineBasicBlock::iterator getInsertPt()
Current insertion point for new instructions.
MachineInstrBuilder buildBr(MachineBasicBlock &BB)
Build and insert G_BR Dest.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:269
MachineInstrBuilder buildIntrinsic(Intrinsic::ID ID, unsigned Res, bool HasSideEffects)
Build and insert either a G_INTRINSIC (if HasSideEffects is false) or G_INTRINSIC_W_SIDE_EFFECTS inst...
Helper class to build MachineInstr.
void addUsesWithIndices(MachineInstrBuilder MIB)
MachineInstrBuilder buildICmp(CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
Build and insert a Res = G_ICMP Pred, Op0, Op1.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:880
void setMF(MachineFunction &)
Setters for the insertion point.
MachineInstrBuilder buildSExtOrTrunc(unsigned Res, unsigned Op)
Build and insert Res<def> = G_SEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing ...
MachineInstrBuilder buildUAdde(unsigned Res, unsigned CarryOut, unsigned Op0, unsigned Op1, unsigned CarryIn)
Build and insert Res<def>, CarryOut<def> = G_UADDE Op0, Op1, CarryIn.
MachineInstrBuilder buildFrameIndex(unsigned Res, int Idx)
Build and insert Res<def> = G_FRAME_INDEX Idx.
This is the shared class of boolean and integer constants.
Definition: Constants.h:88
MachineInstrBuilder buildCopy(unsigned Res, unsigned Op)
Build and insert Res<def> = COPY Op.
This file describes high level types that are used by several passes or APIs involved in the GlobalIS...
MachineInstrBuilder buildSExt(unsigned Res, unsigned Op)
Build and insert Res<def> = G_SEXT Op.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
MachineInstrBuilder buildSequence(unsigned Res, ArrayRef< unsigned > Ops, ArrayRef< uint64_t > Indices)
Build and insert Res<def> = G_SEQUENCE Op0, Idx0...
Representation of each machine instruction.
Definition: MachineInstr.h:52
MachineInstrBuilder buildInsert(unsigned Res, unsigned Src, unsigned Op, unsigned Index, ArgTys...Args)
MachineInstrBuilder buildAdd(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_ADD Op0, Op1.
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
MachineInstrBuilder buildConstant(unsigned Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
MachineInstrBuilder buildMul(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_MUL Op0, Op1.
void addUsesWithIndices(MachineInstrBuilder MIB, unsigned Reg, unsigned BitIndex, ArgTys...Args)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
MachineInstrBuilder buildLoad(unsigned Res, unsigned Addr, MachineMemOperand &MMO)
Build and insert Res<def> = G_LOAD Addr, MMO.
print Print MemDeps of function
IRTranslator LLVM IR MI
MachineInstrBuilder buildGlobalValue(unsigned Res, const GlobalValue *GV)
Build and insert Res<def> = G_GLOBAL_VALUE GV.
MachineInstrBuilder buildBrCond(unsigned Tst, MachineBasicBlock &BB)
Build and insert G_BRCOND Tst, Dest.