LLVM 23.0.0git
MachineIRBuilder.h
Go to the documentation of this file.
1//===-- llvm/CodeGen/GlobalISel/MachineIRBuilder.h - MIBuilder --*- 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/// \file
9/// This file declares the MachineIRBuilder class.
10/// This is a helper class to build MachineInstr.
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H
14#define LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H
15
22#include "llvm/IR/DebugLoc.h"
23#include "llvm/IR/Module.h"
25
26namespace llvm {
27
28// Forward declarations.
29class APInt;
30class BlockAddress;
31class Constant;
32class ConstantFP;
33class ConstantInt;
34class DataLayout;
35class GISelCSEInfo;
36class GlobalValue;
37class MCRegisterClass;
39class MachineFunction;
40class MachineInstr;
41class TargetInstrInfo;
43
44/// Class which stores all the state required in a MachineIRBuilder.
45/// Since MachineIRBuilders will only store state in this object, it allows
46/// to transfer BuilderState between different kinds of MachineIRBuilders.
48 /// MachineFunction under construction.
49 MachineFunction *MF = nullptr;
50 /// Information used to access the description of the opcodes.
51 const TargetInstrInfo *TII = nullptr;
52 /// Information used to verify types are consistent and to create virtual registers.
54 /// Debug location to be set to any instruction we create.
56 /// PC sections metadata to be set to any instruction we create.
57 MDNode *PCSections = nullptr;
58 /// MMRA Metadata to be set on any instruction we create.
59 MDNode *MMRA = nullptr;
60 Value *DS = nullptr;
61
62 /// \name Fields describing the insertion point.
63 /// @{
66 /// @}
67
69
71};
72
73class DstOp {
74 union {
79 };
80
81public:
83 DstOp(unsigned R) : Reg(R), Ty(DstType::Ty_Reg) {}
84 DstOp(Register R) : Reg(R), Ty(DstType::Ty_Reg) {}
86 DstOp(const LLT T) : LLTTy(T), Ty(DstType::Ty_LLT) {}
87 DstOp(const TargetRegisterClass *TRC) : RC(TRC), Ty(DstType::Ty_RC) {}
91 : Attrs({RCOrRB, Ty}), Ty(DstType::Ty_VRegAttrs) {}
92
94 switch (Ty) {
95 case DstType::Ty_Reg:
96 MIB.addDef(Reg);
97 break;
98 case DstType::Ty_LLT:
100 break;
101 case DstType::Ty_RC:
103 break;
106 break;
107 }
108 }
109
110 LLT getLLTTy(const MachineRegisterInfo &MRI) const {
111 switch (Ty) {
112 case DstType::Ty_RC:
113 return LLT{};
114 case DstType::Ty_LLT:
115 return LLTTy;
116 case DstType::Ty_Reg:
117 return MRI.getType(Reg);
119 return Attrs.Ty;
120 }
121 llvm_unreachable("Unrecognised DstOp::DstType enum");
122 }
123
124 Register getReg() const {
125 assert(Ty == DstType::Ty_Reg && "Not a register");
126 return Reg;
127 }
128
130 assert(Ty == DstType::Ty_RC && "Not a RC Operand");
131 return RC;
132 }
133
135 assert(Ty == DstType::Ty_VRegAttrs && "Not a VRegAttrs Operand");
136 return Attrs;
137 }
138
139 DstType getDstOpKind() const { return Ty; }
140
141private:
142 DstType Ty;
143};
144
145class SrcOp {
146 union {
150 int64_t Imm;
151 };
152
153public:
155 SrcOp(Register R) : Reg(R), Ty(SrcType::Ty_Reg) {}
157 SrcOp(const MachineInstrBuilder &MIB) : SrcMIB(MIB), Ty(SrcType::Ty_MIB) {}
159 /// Use of registers held in unsigned integer variables (or more rarely signed
160 /// integers) is no longer permitted to avoid ambiguity with upcoming support
161 /// for immediates.
162 SrcOp(unsigned) = delete;
163 SrcOp(int) = delete;
164 SrcOp(uint64_t V) : Imm(V), Ty(SrcType::Ty_Imm) {}
165 SrcOp(int64_t V) : Imm(V), Ty(SrcType::Ty_Imm) {}
166
168 switch (Ty) {
170 MIB.addPredicate(Pred);
171 break;
172 case SrcType::Ty_Reg:
173 MIB.addUse(Reg);
174 break;
175 case SrcType::Ty_MIB:
176 MIB.addUse(SrcMIB->getOperand(0).getReg());
177 break;
178 case SrcType::Ty_Imm:
179 MIB.addImm(Imm);
180 break;
181 }
182 }
183
184 LLT getLLTTy(const MachineRegisterInfo &MRI) const {
185 switch (Ty) {
187 case SrcType::Ty_Imm:
188 llvm_unreachable("Not a register operand");
189 case SrcType::Ty_Reg:
190 return MRI.getType(Reg);
191 case SrcType::Ty_MIB:
192 return MRI.getType(SrcMIB->getOperand(0).getReg());
193 }
194 llvm_unreachable("Unrecognised SrcOp::SrcType enum");
195 }
196
197 Register getReg() const {
198 switch (Ty) {
200 case SrcType::Ty_Imm:
201 llvm_unreachable("Not a register operand");
202 case SrcType::Ty_Reg:
203 return Reg;
204 case SrcType::Ty_MIB:
205 return SrcMIB->getOperand(0).getReg();
206 }
207 llvm_unreachable("Unrecognised SrcOp::SrcType enum");
208 }
209
211 switch (Ty) {
213 return Pred;
214 default:
215 llvm_unreachable("Not a register operand");
216 }
217 }
218
219 int64_t getImm() const {
220 switch (Ty) {
221 case SrcType::Ty_Imm:
222 return Imm;
223 default:
224 llvm_unreachable("Not an immediate");
225 }
226 }
227
228 SrcType getSrcOpKind() const { return Ty; }
229
230private:
231 SrcType Ty;
232};
233
234/// Helper class to build MachineInstr.
235/// It keeps internally the insertion point and debug location for all
236/// the new instructions we want to create.
237/// This information can be modified via the related setters.
239
241
242 unsigned getOpcodeForMerge(const DstOp &DstOp, ArrayRef<SrcOp> SrcOps) const;
243
244protected:
245 void validateTruncExt(const LLT Dst, const LLT Src, bool IsExtend);
246
247 void validateUnaryOp(const LLT Res, const LLT Op0);
248 void validateBinaryOp(const LLT Res, const LLT Op0, const LLT Op1);
249 void validateShiftOp(const LLT Res, const LLT Op0, const LLT Op1);
250
251 void validateSelectOp(const LLT ResTy, const LLT TstTy, const LLT Op0Ty,
252 const LLT Op1Ty);
253
254 void recordInsertion(MachineInstr *InsertedInstr) const {
255 if (State.Observer)
256 State.Observer->createdInstr(*InsertedInstr);
257 }
258
259public:
260 /// Some constructors for easy use.
261 MachineIRBuilder() = default;
263
268
270 MachineIRBuilder(*MI.getParent(), MI.getIterator()) {
271 setInstr(MI);
272 setDebugLoc(MI.getDebugLoc());
273 }
274
279
280 virtual ~MachineIRBuilder() = default;
281
282 MachineIRBuilder(const MachineIRBuilderState &BState) : State(BState) {}
283
285 assert(State.TII && "TargetInstrInfo is not set");
286 return *State.TII;
287 }
288
289 /// Getter for the function we currently build.
291 assert(State.MF && "MachineFunction is not set");
292 return *State.MF;
293 }
294
295 const MachineFunction &getMF() const {
296 assert(State.MF && "MachineFunction is not set");
297 return *State.MF;
298 }
299
300 const DataLayout &getDataLayout() const {
301 return getMF().getFunction().getDataLayout();
302 }
303
305 return getMF().getFunction().getContext();
306 }
307
308 /// Getter for DebugLoc
309 const DebugLoc &getDL() { return State.DL; }
310
311 /// Getter for MRI
312 MachineRegisterInfo *getMRI() { return State.MRI; }
313 const MachineRegisterInfo *getMRI() const { return State.MRI; }
314
315 /// Getter for the State
316 MachineIRBuilderState &getState() { return State; }
317
318 /// Setter for the State
319 void setState(const MachineIRBuilderState &NewState) { State = NewState; }
320
321 /// Getter for the basic block we currently build.
322 const MachineBasicBlock &getMBB() const {
323 assert(State.MBB && "MachineBasicBlock is not set");
324 return *State.MBB;
325 }
326
328 return const_cast<MachineBasicBlock &>(
329 const_cast<const MachineIRBuilder *>(this)->getMBB());
330 }
331
332 GISelCSEInfo *getCSEInfo() { return State.CSEInfo; }
333 const GISelCSEInfo *getCSEInfo() const { return State.CSEInfo; }
334
335 /// Current insertion point for new instructions.
337
338 /// Set the insertion point before the specified position.
339 /// \pre MBB must be in getMF().
340 /// \pre II must be a valid iterator in MBB.
342 assert(MBB.getParent() == &getMF() &&
343 "Basic block is in a different function");
344 State.MBB = &MBB;
345 State.II = II;
346 }
347
348 /// @}
349
350 void setCSEInfo(GISelCSEInfo *Info) { State.CSEInfo = Info; }
351
352 /// \name Setters for the insertion point.
353 /// @{
354 /// Set the MachineFunction where to build instructions.
355 void setMF(MachineFunction &MF);
356
357 /// Set the insertion point to the end of \p MBB.
358 /// \pre \p MBB must be contained by getMF().
360 State.MBB = &MBB;
361 State.II = MBB.end();
362 assert(&getMF() == MBB.getParent() &&
363 "Basic block is in a different function");
364 }
365
366 /// Set the insertion point to before MI.
367 /// \pre MI must be in getMF().
369 assert(MI.getParent() && "Instruction is not part of a basic block");
370 setMBB(*MI.getParent());
371 State.II = MI.getIterator();
372 setPCSections(MI.getPCSections());
373 setMMRAMetadata(MI.getMMRAMetadata());
374 setDeactivationSymbol(MI.getDeactivationSymbol());
375 }
376 /// @}
377
378 /// Set the insertion point to before MI, and set the debug loc to MI's loc.
379 /// \pre MI must be in getMF().
381 setInstr(MI);
382 setDebugLoc(MI.getDebugLoc());
383 }
384
386 State.Observer = &Observer;
387 }
388
389 GISelChangeObserver *getObserver() { return State.Observer; }
390
391 void stopObservingChanges() { State.Observer = nullptr; }
392
393 bool isObservingChanges() const { return State.Observer != nullptr; }
394 /// @}
395
396 /// Set the debug location to \p DL for all the next build instructions.
397 void setDebugLoc(const DebugLoc &DL) { this->State.DL = DL; }
398
399 /// Get the current instruction's debug location.
400 const DebugLoc &getDebugLoc() { return State.DL; }
401
402 /// Set the PC sections metadata to \p MD for all the next build instructions.
403 void setPCSections(MDNode *MD) { State.PCSections = MD; }
404
405 /// Get the current instruction's PC sections metadata.
406 MDNode *getPCSections() { return State.PCSections; }
407
408 /// Set the PC sections metadata to \p MD for all the next build instructions.
409 void setMMRAMetadata(MDNode *MMRA) { State.MMRA = MMRA; }
410
411 Value *getDeactivationSymbol() { return State.DS; }
412 void setDeactivationSymbol(Value *DS) { State.DS = DS; }
413
414 /// Get the current instruction's MMRA metadata.
415 MDNode *getMMRAMetadata() { return State.MMRA; }
416
417 /// Build and insert <empty> = \p Opcode <empty>.
418 /// The insertion point is the one set by the last call of either
419 /// setBasicBlock or setMI.
420 ///
421 /// \pre setBasicBlock or setMI must have been called.
422 ///
423 /// \return a MachineInstrBuilder for the newly created instruction.
425 return insertInstr(buildInstrNoInsert(Opcode));
426 }
427
428 /// Build but don't insert <empty> = \p Opcode <empty>.
429 ///
430 /// \pre setMF, setBasicBlock or setMI must have been called.
431 ///
432 /// \return a MachineInstrBuilder for the newly created instruction.
433 MachineInstrBuilder buildInstrNoInsert(unsigned Opcode);
434
435 /// Insert an existing instruction at the insertion point.
437
438 /// Build and insert a DBG_VALUE instruction expressing the fact that the
439 /// associated \p Variable lives in \p Reg (suitably modified by \p Expr).
440 MachineInstrBuilder buildDirectDbgValue(Register Reg, const MDNode *Variable,
441 const MDNode *Expr);
442
443 /// Build and insert a DBG_VALUE instruction expressing the fact that the
444 /// associated \p Variable lives in memory at \p Reg (suitably modified by \p
445 /// Expr).
446 MachineInstrBuilder buildIndirectDbgValue(Register Reg,
447 const MDNode *Variable,
448 const MDNode *Expr);
449
450 /// Build and insert a DBG_VALUE instruction expressing the fact that the
451 /// associated \p Variable lives in the stack slot specified by \p FI
452 /// (suitably modified by \p Expr).
453 MachineInstrBuilder buildFIDbgValue(int FI, const MDNode *Variable,
454 const MDNode *Expr);
455
456 /// Build and insert a DBG_VALUE instructions specifying that \p Variable is
457 /// given by \p C (suitably modified by \p Expr).
458 MachineInstrBuilder buildConstDbgValue(const Constant &C,
459 const MDNode *Variable,
460 const MDNode *Expr);
461
462 /// Build and insert a DBG_LABEL instructions specifying that \p Label is
463 /// given. Convert "llvm.dbg.label Label" to "DBG_LABEL Label".
464 MachineInstrBuilder buildDbgLabel(const MDNode *Label);
465
466 /// Build and insert \p Res = G_DYN_STACKALLOC \p Size, \p Align
467 ///
468 /// G_DYN_STACKALLOC does a dynamic stack allocation and writes the address of
469 /// the allocated memory into \p Res.
470 /// \pre setBasicBlock or setMI must have been called.
471 /// \pre \p Res must be a generic virtual register with pointer type.
472 ///
473 /// \return a MachineInstrBuilder for the newly created instruction.
474 MachineInstrBuilder buildDynStackAlloc(const DstOp &Res, const SrcOp &Size,
475 Align Alignment);
476
477 /// Build and insert \p Res = G_FRAME_INDEX \p Idx
478 ///
479 /// G_FRAME_INDEX materializes the address of an alloca value or other
480 /// stack-based object.
481 ///
482 /// \pre setBasicBlock or setMI must have been called.
483 /// \pre \p Res must be a generic virtual register with pointer type.
484 ///
485 /// \return a MachineInstrBuilder for the newly created instruction.
486 MachineInstrBuilder buildFrameIndex(const DstOp &Res, int Idx);
487
488 /// Build and insert \p Res = G_GLOBAL_VALUE \p GV
489 ///
490 /// G_GLOBAL_VALUE materializes the address of the specified global
491 /// into \p Res.
492 ///
493 /// \pre setBasicBlock or setMI must have been called.
494 /// \pre \p Res must be a generic virtual register with pointer type
495 /// in the same address space as \p GV.
496 ///
497 /// \return a MachineInstrBuilder for the newly created instruction.
498 MachineInstrBuilder buildGlobalValue(const DstOp &Res, const GlobalValue *GV);
499
500 /// Build and insert \p Res = G_CONSTANT_POOL \p Idx
501 ///
502 /// G_CONSTANT_POOL materializes the address of an object in the constant
503 /// pool.
504 ///
505 /// \pre setBasicBlock or setMI must have been called.
506 /// \pre \p Res must be a generic virtual register with pointer type.
507 ///
508 /// \return a MachineInstrBuilder for the newly created instruction.
509 MachineInstrBuilder buildConstantPool(const DstOp &Res, unsigned Idx);
510
511 /// Build and insert \p Res = G_PTR_ADD \p Op0, \p Op1
512 ///
513 /// G_PTR_ADD adds \p Op1 addressible units to the pointer specified by \p Op0,
514 /// storing the resulting pointer in \p Res. Addressible units are typically
515 /// bytes but this can vary between targets.
516 ///
517 /// \pre setBasicBlock or setMI must have been called.
518 /// \pre \p Res and \p Op0 must be generic virtual registers with pointer
519 /// type.
520 /// \pre \p Op1 must be a generic virtual register with scalar type.
521 ///
522 /// \return a MachineInstrBuilder for the newly created instruction.
523 MachineInstrBuilder buildPtrAdd(const DstOp &Res, const SrcOp &Op0,
524 const SrcOp &Op1,
525 std::optional<unsigned> Flags = std::nullopt);
526
527 /// Build and insert an instruction with appropriate flags for addressing some
528 /// offset of an object, i.e.: \p Res = nuw inbounds G_PTR_ADD \p Op0, \p Op1
529 /// The value of \p Op0 must be a pointer into or just after an object, adding
530 /// the value of \p Op1 to it must yield to a pointer into or just after the
531 /// same object.
532 ///
533 /// \pre setBasicBlock or setMI must have been called.
534 /// \pre \p Res and \p Op0 must be generic virtual registers with pointer
535 /// type.
536 /// \pre \p Op1 must be a generic virtual register with scalar type.
537 ///
538 /// \return a MachineInstrBuilder for the newly created instruction.
539 MachineInstrBuilder buildObjectPtrOffset(const DstOp &Res, const SrcOp &Op0,
540 const SrcOp &Op1);
541
542 /// Materialize and insert \p Res = G_PTR_ADD \p Op0, (G_CONSTANT \p Value)
543 ///
544 /// G_PTR_ADD adds \p Value bytes to the pointer specified by \p Op0,
545 /// storing the resulting pointer in \p Res. If \p Value is zero then no
546 /// G_PTR_ADD or G_CONSTANT will be created and \pre Op0 will be assigned to
547 /// \p Res.
548 ///
549 /// \pre setBasicBlock or setMI must have been called.
550 /// \pre \p Op0 must be a generic virtual register with pointer type.
551 /// \pre \p ValueTy must be a scalar type.
552 /// \pre \p Res must be 0. This is to detect confusion between
553 /// materializePtrAdd() and buildPtrAdd().
554 /// \post \p Res will either be a new generic virtual register of the same
555 /// type as \p Op0 or \p Op0 itself.
556 ///
557 /// \return a MachineInstrBuilder for the newly created instruction.
558 std::optional<MachineInstrBuilder>
559 materializePtrAdd(Register &Res, Register Op0, const LLT ValueTy,
561 std::optional<unsigned> Flags = std::nullopt);
562
563 /// Materialize and insert an instruction with appropriate flags for
564 /// addressing some offset of an object, i.e.:
565 /// \p Res = nuw inbounds G_PTR_ADD \p Op0, (G_CONSTANT \p Value)
566 /// The value of \p Op0 must be a pointer into or just after an object, adding
567 /// \p Value to it must yield to a pointer into or just after the same object.
568 ///
569 /// \pre setBasicBlock or setMI must have been called.
570 /// \pre \p Op0 must be a generic virtual register with pointer type.
571 /// \pre \p ValueTy must be a scalar type.
572 /// \pre \p Res must be 0. This is to detect confusion between
573 /// materializeObjectPtrOffset() and buildObjectPtrOffset().
574 /// \post \p Res will either be a new generic virtual register of the same
575 /// type as \p Op0 or \p Op0 itself.
576 ///
577 /// \return a MachineInstrBuilder for the newly created instruction.
578 std::optional<MachineInstrBuilder>
579 materializeObjectPtrOffset(Register &Res, Register Op0, const LLT ValueTy,
581
582 /// Build and insert \p Res = G_PTRMASK \p Op0, \p Op1
584 const SrcOp &Op1) {
585 return buildInstr(TargetOpcode::G_PTRMASK, {Res}, {Op0, Op1});
586 }
587
588 /// Build and insert \p Res = G_PTRMASK \p Op0, \p G_CONSTANT (1 << NumBits) - 1
589 ///
590 /// This clears the low bits of a pointer operand without destroying its
591 /// pointer properties. This has the effect of rounding the address *down* to
592 /// a specified alignment in bits.
593 ///
594 /// \pre setBasicBlock or setMI must have been called.
595 /// \pre \p Res and \p Op0 must be generic virtual registers with pointer
596 /// type.
597 /// \pre \p NumBits must be an integer representing the number of low bits to
598 /// be cleared in \p Op0.
599 ///
600 /// \return a MachineInstrBuilder for the newly created instruction.
601 MachineInstrBuilder buildMaskLowPtrBits(const DstOp &Res, const SrcOp &Op0,
602 uint32_t NumBits);
603
604 /// Build and insert
605 /// a, b, ..., x = G_UNMERGE_VALUES \p Op0
606 /// \p Res = G_BUILD_VECTOR a, b, ..., x, undef, ..., undef
607 ///
608 /// Pad \p Op0 with undef elements to match number of elements in \p Res.
609 ///
610 /// \pre setBasicBlock or setMI must have been called.
611 /// \pre \p Res and \p Op0 must be generic virtual registers with vector type,
612 /// same vector element type and Op0 must have fewer elements then Res.
613 ///
614 /// \return a MachineInstrBuilder for the newly created build vector instr.
615 MachineInstrBuilder buildPadVectorWithUndefElements(const DstOp &Res,
616 const SrcOp &Op0);
617
618 /// Build and insert
619 /// a, b, ..., x, y, z = G_UNMERGE_VALUES \p Op0
620 /// \p Res = G_BUILD_VECTOR a, b, ..., x
621 ///
622 /// Delete trailing elements in \p Op0 to match number of elements in \p Res.
623 ///
624 /// \pre setBasicBlock or setMI must have been called.
625 /// \pre \p Res and \p Op0 must be generic virtual registers with vector type,
626 /// same vector element type and Op0 must have more elements then Res.
627 ///
628 /// \return a MachineInstrBuilder for the newly created build vector instr.
629 MachineInstrBuilder buildDeleteTrailingVectorElements(const DstOp &Res,
630 const SrcOp &Op0);
631
632 /// Build and insert \p Res, \p CarryOut = G_UADDO \p Op0, \p Op1
633 ///
634 /// G_UADDO sets \p Res to \p Op0 + \p Op1 (truncated to the bit width) and
635 /// sets \p CarryOut to 1 if the result overflowed in unsigned arithmetic.
636 ///
637 /// \pre setBasicBlock or setMI must have been called.
638 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers with the
639 /// same scalar type.
640 ////\pre \p CarryOut must be generic virtual register with scalar type
641 ///(typically s1)
642 ///
643 /// \return The newly created instruction.
644 MachineInstrBuilder buildUAddo(const DstOp &Res, const DstOp &CarryOut,
645 const SrcOp &Op0, const SrcOp &Op1) {
646 return buildInstr(TargetOpcode::G_UADDO, {Res, CarryOut}, {Op0, Op1});
647 }
648
649 /// Build and insert \p Res, \p CarryOut = G_USUBO \p Op0, \p Op1
650 MachineInstrBuilder buildUSubo(const DstOp &Res, const DstOp &CarryOut,
651 const SrcOp &Op0, const SrcOp &Op1) {
652 return buildInstr(TargetOpcode::G_USUBO, {Res, CarryOut}, {Op0, Op1});
653 }
654
655 /// Build and insert \p Res, \p CarryOut = G_SADDO \p Op0, \p Op1
656 MachineInstrBuilder buildSAddo(const DstOp &Res, const DstOp &CarryOut,
657 const SrcOp &Op0, const SrcOp &Op1) {
658 return buildInstr(TargetOpcode::G_SADDO, {Res, CarryOut}, {Op0, Op1});
659 }
660
661 /// Build and insert \p Res, \p CarryOut = G_SUBO \p Op0, \p Op1
662 MachineInstrBuilder buildSSubo(const DstOp &Res, const DstOp &CarryOut,
663 const SrcOp &Op0, const SrcOp &Op1) {
664 return buildInstr(TargetOpcode::G_SSUBO, {Res, CarryOut}, {Op0, Op1});
665 }
666
667 /// Build and insert \p Res, \p CarryOut = G_UADDE \p Op0,
668 /// \p Op1, \p CarryIn
669 ///
670 /// G_UADDE sets \p Res to \p Op0 + \p Op1 + \p CarryIn (truncated to the bit
671 /// width) and sets \p CarryOut to 1 if the result overflowed in unsigned
672 /// arithmetic.
673 ///
674 /// \pre setBasicBlock or setMI must have been called.
675 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
676 /// with the same scalar type.
677 /// \pre \p CarryOut and \p CarryIn must be generic virtual
678 /// registers with the same scalar type (typically s1)
679 ///
680 /// \return The newly created instruction.
681 MachineInstrBuilder buildUAdde(const DstOp &Res, const DstOp &CarryOut,
682 const SrcOp &Op0, const SrcOp &Op1,
683 const SrcOp &CarryIn) {
684 return buildInstr(TargetOpcode::G_UADDE, {Res, CarryOut},
685 {Op0, Op1, CarryIn});
686 }
687
688 /// Build and insert \p Res, \p CarryOut = G_USUBE \p Op0, \p Op1, \p CarryInp
689 MachineInstrBuilder buildUSube(const DstOp &Res, const DstOp &CarryOut,
690 const SrcOp &Op0, const SrcOp &Op1,
691 const SrcOp &CarryIn) {
692 return buildInstr(TargetOpcode::G_USUBE, {Res, CarryOut},
693 {Op0, Op1, CarryIn});
694 }
695
696 /// Build and insert \p Res, \p CarryOut = G_SADDE \p Op0, \p Op1, \p CarryInp
697 MachineInstrBuilder buildSAdde(const DstOp &Res, const DstOp &CarryOut,
698 const SrcOp &Op0, const SrcOp &Op1,
699 const SrcOp &CarryIn) {
700 return buildInstr(TargetOpcode::G_SADDE, {Res, CarryOut},
701 {Op0, Op1, CarryIn});
702 }
703
704 /// Build and insert \p Res, \p CarryOut = G_SSUBE \p Op0, \p Op1, \p CarryInp
705 MachineInstrBuilder buildSSube(const DstOp &Res, const DstOp &CarryOut,
706 const SrcOp &Op0, const SrcOp &Op1,
707 const SrcOp &CarryIn) {
708 return buildInstr(TargetOpcode::G_SSUBE, {Res, CarryOut},
709 {Op0, Op1, CarryIn});
710 }
711
712 /// Build and insert \p Res = G_ANYEXT \p Op0
713 ///
714 /// G_ANYEXT produces a register of the specified width, with bits 0 to
715 /// sizeof(\p Ty) * 8 set to \p Op. The remaining bits are unspecified
716 /// (i.e. this is neither zero nor sign-extension). For a vector register,
717 /// each element is extended individually.
718 ///
719 /// \pre setBasicBlock or setMI must have been called.
720 /// \pre \p Res must be a generic virtual register with scalar or vector type.
721 /// \pre \p Op must be a generic virtual register with scalar or vector type.
722 /// \pre \p Op must be smaller than \p Res
723 ///
724 /// \return The newly created instruction.
725
726 MachineInstrBuilder buildAnyExt(const DstOp &Res, const SrcOp &Op);
727
728 /// Build and insert \p Res = G_SEXT \p Op
729 ///
730 /// G_SEXT produces a register of the specified width, with bits 0 to
731 /// sizeof(\p Ty) * 8 set to \p Op. The remaining bits are duplicated from the
732 /// high bit of \p Op (i.e. 2s-complement sign extended).
733 ///
734 /// \pre setBasicBlock or setMI must have been called.
735 /// \pre \p Res must be a generic virtual register with scalar or vector type.
736 /// \pre \p Op must be a generic virtual register with scalar or vector type.
737 /// \pre \p Op must be smaller than \p Res
738 ///
739 /// \return The newly created instruction.
740 MachineInstrBuilder buildSExt(const DstOp &Res, const SrcOp &Op);
741
742 /// Build and insert \p Res = G_SEXT_INREG \p Op, ImmOp
743 MachineInstrBuilder buildSExtInReg(const DstOp &Res, const SrcOp &Op, int64_t ImmOp) {
744 return buildInstr(TargetOpcode::G_SEXT_INREG, {Res}, {Op, SrcOp(ImmOp)});
745 }
746
747 /// Build and insert \p Res = G_FPEXT \p Op
749 std::optional<unsigned> Flags = std::nullopt) {
750 return buildInstr(TargetOpcode::G_FPEXT, {Res}, {Op}, Flags);
751 }
752
753 /// Build and insert a G_PTRTOINT instruction.
755 return buildInstr(TargetOpcode::G_PTRTOINT, {Dst}, {Src});
756 }
757
758 /// Build and insert a G_INTTOPTR instruction.
760 return buildInstr(TargetOpcode::G_INTTOPTR, {Dst}, {Src});
761 }
762
763 /// Build and insert \p Dst = G_BITCAST \p Src
764 MachineInstrBuilder buildBitcast(const DstOp &Dst, const SrcOp &Src) {
765 return buildInstr(TargetOpcode::G_BITCAST, {Dst}, {Src});
766 }
767
768 /// Build and insert \p Dst = G_ADDRSPACE_CAST \p Src
770 return buildInstr(TargetOpcode::G_ADDRSPACE_CAST, {Dst}, {Src});
771 }
772
773 /// \return The opcode of the extension the target wants to use for boolean
774 /// values.
775 unsigned getBoolExtOp(bool IsVec, bool IsFP) const;
776
777 // Build and insert \p Res = G_ANYEXT \p Op, \p Res = G_SEXT \p Op, or \p Res
778 // = G_ZEXT \p Op depending on how the target wants to extend boolean values.
779 MachineInstrBuilder buildBoolExt(const DstOp &Res, const SrcOp &Op,
780 bool IsFP);
781
782 // Build and insert \p Res = G_SEXT_INREG \p Op, 1 or \p Res = G_AND \p Op, 1,
783 // or COPY depending on how the target wants to extend boolean values, using
784 // the original register size.
785 MachineInstrBuilder buildBoolExtInReg(const DstOp &Res, const SrcOp &Op,
786 bool IsVector,
787 bool IsFP);
788
789 /// Build and insert \p Res = G_ZEXT \p Op
790 ///
791 /// G_ZEXT produces a register of the specified width, with bits 0 to
792 /// sizeof(\p Ty) * 8 set to \p Op. The remaining bits are 0. For a vector
793 /// register, each element is extended individually.
794 ///
795 /// \pre setBasicBlock or setMI must have been called.
796 /// \pre \p Res must be a generic virtual register with scalar or vector type.
797 /// \pre \p Op must be a generic virtual register with scalar or vector type.
798 /// \pre \p Op must be smaller than \p Res
799 ///
800 /// \return The newly created instruction.
801 MachineInstrBuilder buildZExt(const DstOp &Res, const SrcOp &Op,
802 std::optional<unsigned> Flags = std::nullopt);
803
804 /// Build and insert \p Res = G_SEXT \p Op, \p Res = G_TRUNC \p Op, or
805 /// \p Res = COPY \p Op depending on the differing sizes of \p Res and \p Op.
806 ///
807 /// \pre setBasicBlock or setMI must have been called.
808 /// \pre \p Res must be a generic virtual register with scalar or vector type.
809 /// \pre \p Op must be a generic virtual register with scalar or vector type.
810 ///
811 /// \return The newly created instruction.
812 MachineInstrBuilder buildSExtOrTrunc(const DstOp &Res, const SrcOp &Op);
813
814 /// Build and insert \p Res = G_ZEXT \p Op, \p Res = G_TRUNC \p Op, or
815 /// \p Res = COPY \p Op depending on the differing sizes of \p Res and \p Op.
816 ///
817 /// \pre setBasicBlock or setMI must have been called.
818 /// \pre \p Res must be a generic virtual register with scalar or vector type.
819 /// \pre \p Op must be a generic virtual register with scalar or vector type.
820 ///
821 /// \return The newly created instruction.
822 MachineInstrBuilder buildZExtOrTrunc(const DstOp &Res, const SrcOp &Op);
823
824 // Build and insert \p Res = G_ANYEXT \p Op, \p Res = G_TRUNC \p Op, or
825 /// \p Res = COPY \p Op depending on the differing sizes of \p Res and \p Op.
826 ///
827 /// \pre setBasicBlock or setMI must have been called.
828 /// \pre \p Res must be a generic virtual register with scalar or vector type.
829 /// \pre \p Op must be a generic virtual register with scalar or vector type.
830 ///
831 /// \return The newly created instruction.
832 MachineInstrBuilder buildAnyExtOrTrunc(const DstOp &Res, const SrcOp &Op);
833
834 /// Build and insert \p Res = \p ExtOpc, \p Res = G_TRUNC \p
835 /// Op, or \p Res = COPY \p Op depending on the differing sizes of \p Res and
836 /// \p Op.
837 ///
838 /// \pre setBasicBlock or setMI must have been called.
839 /// \pre \p Res must be a generic virtual register with scalar or vector type.
840 /// \pre \p Op must be a generic virtual register with scalar or vector type.
841 ///
842 /// \return The newly created instruction.
843 MachineInstrBuilder buildExtOrTrunc(unsigned ExtOpc, const DstOp &Res,
844 const SrcOp &Op);
845
846 /// Build and inserts \p Res = \p G_AND \p Op, \p LowBitsSet(ImmOp)
847 /// Since there is no G_ZEXT_INREG like G_SEXT_INREG, the instruction is
848 /// emulated using G_AND.
849 MachineInstrBuilder buildZExtInReg(const DstOp &Res, const SrcOp &Op,
850 int64_t ImmOp);
851
852 /// Build and insert \p Res = \p G_TRUNC_SSAT_S \p Op
853 ///
854 /// G_TRUNC_SSAT_S truncates the signed input, \p Op, to a signed result with
855 /// saturation.
856 ///
857 /// \pre setBasicBlock or setMI must have been called.
858 /// \pre \p Res must be a generic virtual register with scalar or vector type.
859 /// \pre \p Op must be a generic virtual register with scalar or vector type.
860 ///
861 /// \return The newly created instruction.
863 return buildInstr(TargetOpcode::G_TRUNC_SSAT_S, {Res}, {Op});
864 }
865
866 /// Build and insert \p Res = \p G_TRUNC_SSAT_U \p Op
867 ///
868 /// G_TRUNC_SSAT_U truncates the signed input, \p Op, to an unsigned result
869 /// with saturation.
870 ///
871 /// \pre setBasicBlock or setMI must have been called.
872 /// \pre \p Res must be a generic virtual register with scalar or vector type.
873 /// \pre \p Op must be a generic virtual register with scalar or vector type.
874 ///
875 /// \return The newly created instruction.
877 return buildInstr(TargetOpcode::G_TRUNC_SSAT_U, {Res}, {Op});
878 }
879
880 /// Build and insert \p Res = \p G_TRUNC_USAT_U \p Op
881 ///
882 /// G_TRUNC_USAT_U truncates the unsigned input, \p Op, to an unsigned result
883 /// with saturation.
884 ///
885 /// \pre setBasicBlock or setMI must have been called.
886 /// \pre \p Res must be a generic virtual register with scalar or vector type.
887 /// \pre \p Op must be a generic virtual register with scalar or vector type.
888 ///
889 /// \return The newly created instruction.
891 return buildInstr(TargetOpcode::G_TRUNC_USAT_U, {Res}, {Op});
892 }
893
894 /// Build and insert an appropriate cast between two registers of equal size.
895 MachineInstrBuilder buildCast(const DstOp &Dst, const SrcOp &Src);
896
897 /// Build and insert G_BR \p Dest
898 ///
899 /// G_BR is an unconditional branch to \p Dest.
900 ///
901 /// \pre setBasicBlock or setMI must have been called.
902 ///
903 /// \return a MachineInstrBuilder for the newly created instruction.
905
906 /// Build and insert G_BRCOND \p Tst, \p Dest
907 ///
908 /// G_BRCOND is a conditional branch to \p Dest.
909 ///
910 /// \pre setBasicBlock or setMI must have been called.
911 /// \pre \p Tst must be a generic virtual register with scalar
912 /// type. At the beginning of legalization, this will be a single
913 /// bit (s1). Targets with interesting flags registers may change
914 /// this. For a wider type, whether the branch is taken must only
915 /// depend on bit 0 (for now).
916 ///
917 /// \return The newly created instruction.
918 MachineInstrBuilder buildBrCond(const SrcOp &Tst, MachineBasicBlock &Dest);
919
920 /// Build and insert G_BRINDIRECT \p Tgt
921 ///
922 /// G_BRINDIRECT is an indirect branch to \p Tgt.
923 ///
924 /// \pre setBasicBlock or setMI must have been called.
925 /// \pre \p Tgt must be a generic virtual register with pointer type.
926 ///
927 /// \return a MachineInstrBuilder for the newly created instruction.
928 MachineInstrBuilder buildBrIndirect(Register Tgt);
929
930 /// Build and insert G_BRJT \p TablePtr, \p JTI, \p IndexReg
931 ///
932 /// G_BRJT is a jump table branch using a table base pointer \p TablePtr,
933 /// jump table index \p JTI and index \p IndexReg
934 ///
935 /// \pre setBasicBlock or setMI must have been called.
936 /// \pre \p TablePtr must be a generic virtual register with pointer type.
937 /// \pre \p JTI must be a jump table index.
938 /// \pre \p IndexReg must be a generic virtual register with pointer type.
939 ///
940 /// \return a MachineInstrBuilder for the newly created instruction.
941 MachineInstrBuilder buildBrJT(Register TablePtr, unsigned JTI,
942 Register IndexReg);
943
944 /// Build and insert \p Res = G_CONSTANT \p Val
945 ///
946 /// G_CONSTANT is an integer constant with the specified size and value. \p
947 /// Val will be extended or truncated to the size of \p Reg.
948 ///
949 /// \pre setBasicBlock or setMI must have been called.
950 /// \pre \p Res must be a generic virtual register with scalar or pointer
951 /// type.
952 ///
953 /// \return The newly created instruction.
954 virtual MachineInstrBuilder buildConstant(const DstOp &Res,
955 const ConstantInt &Val);
956
957 /// Build and insert \p Res = G_CONSTANT \p Val
958 ///
959 /// G_CONSTANT is an integer constant with the specified size and value.
960 ///
961 /// \pre setBasicBlock or setMI must have been called.
962 /// \pre \p Res must be a generic virtual register with scalar type.
963 ///
964 /// \return The newly created instruction.
965 MachineInstrBuilder buildConstant(const DstOp &Res, int64_t Val);
966 MachineInstrBuilder buildConstant(const DstOp &Res, const APInt &Val);
967
968 /// Build and insert \p Res = G_FCONSTANT \p Val
969 ///
970 /// G_FCONSTANT is a floating-point constant with the specified size and
971 /// value.
972 ///
973 /// \pre setBasicBlock or setMI must have been called.
974 /// \pre \p Res must be a generic virtual register with scalar type.
975 ///
976 /// \return The newly created instruction.
977 virtual MachineInstrBuilder buildFConstant(const DstOp &Res,
978 const ConstantFP &Val);
979
980 MachineInstrBuilder buildFConstant(const DstOp &Res, double Val);
981 MachineInstrBuilder buildFConstant(const DstOp &Res, const APFloat &Val);
982
983 /// Build and insert G_PTRAUTH_GLOBAL_VALUE
984 ///
985 /// \return a MachineInstrBuilder for the newly created instruction.
986 MachineInstrBuilder buildConstantPtrAuth(const DstOp &Res,
987 const ConstantPtrAuth *CPA,
988 Register Addr, Register AddrDisc);
989
990 /// Build and insert \p Res = COPY Op
991 ///
992 /// Register-to-register COPY sets \p Res to \p Op.
993 ///
994 /// \pre setBasicBlock or setMI must have been called.
995 ///
996 /// \return a MachineInstrBuilder for the newly created instruction.
997 MachineInstrBuilder buildCopy(const DstOp &Res, const SrcOp &Op);
998
999
1000 /// Build and insert G_ASSERT_SEXT, G_ASSERT_ZEXT, or G_ASSERT_ALIGN
1001 ///
1002 /// \return a MachineInstrBuilder for the newly created instruction.
1004 const SrcOp &Op, unsigned Val) {
1005 return buildInstr(Opc, Res, Op).addImm(Val);
1006 }
1007
1008 /// Build and insert \p Res = G_ASSERT_ZEXT Op, Size
1009 ///
1010 /// \return a MachineInstrBuilder for the newly created instruction.
1012 unsigned Size) {
1013 return buildAssertInstr(TargetOpcode::G_ASSERT_ZEXT, Res, Op, Size);
1014 }
1015
1016 /// Build and insert \p Res = G_ASSERT_SEXT Op, Size
1017 ///
1018 /// \return a MachineInstrBuilder for the newly created instruction.
1020 unsigned Size) {
1021 return buildAssertInstr(TargetOpcode::G_ASSERT_SEXT, Res, Op, Size);
1022 }
1023
1024 /// Build and insert \p Res = G_ASSERT_ALIGN Op, AlignVal
1025 ///
1026 /// \return a MachineInstrBuilder for the newly created instruction.
1028 Align AlignVal) {
1029 return buildAssertInstr(TargetOpcode::G_ASSERT_ALIGN, Res, Op,
1030 AlignVal.value());
1031 }
1032
1033 /// Build and insert `Res = G_LOAD Addr, MMO`.
1034 ///
1035 /// Loads the value stored at \p Addr. Puts the result in \p Res.
1036 ///
1037 /// \pre setBasicBlock or setMI must have been called.
1038 /// \pre \p Res must be a generic virtual register.
1039 /// \pre \p Addr must be a generic virtual register with pointer type.
1040 ///
1041 /// \return a MachineInstrBuilder for the newly created instruction.
1042 MachineInstrBuilder buildLoad(const DstOp &Res, const SrcOp &Addr,
1043 MachineMemOperand &MMO) {
1044 return buildLoadInstr(TargetOpcode::G_LOAD, Res, Addr, MMO);
1045 }
1046
1047 /// Build and insert a G_LOAD instruction, while constructing the
1048 /// MachineMemOperand.
1050 buildLoad(const DstOp &Res, const SrcOp &Addr, MachinePointerInfo PtrInfo,
1051 Align Alignment,
1053 const AAMDNodes &AAInfo = AAMDNodes());
1054
1055 /// Build and insert `Res = <opcode> Addr, MMO`.
1056 ///
1057 /// Loads the value stored at \p Addr. Puts the result in \p Res.
1058 ///
1059 /// \pre setBasicBlock or setMI must have been called.
1060 /// \pre \p Res must be a generic virtual register.
1061 /// \pre \p Addr must be a generic virtual register with pointer type.
1062 ///
1063 /// \return a MachineInstrBuilder for the newly created instruction.
1064 MachineInstrBuilder buildLoadInstr(unsigned Opcode, const DstOp &Res,
1065 const SrcOp &Addr, MachineMemOperand &MMO);
1066
1067 /// Helper to create a load from a constant offset given a base address. Load
1068 /// the type of \p Dst from \p Offset from the given base address and memory
1069 /// operand.
1070 MachineInstrBuilder buildLoadFromOffset(const DstOp &Dst,
1071 const SrcOp &BasePtr,
1072 MachineMemOperand &BaseMMO,
1073 int64_t Offset);
1074
1075 /// Build and insert `G_STORE Val, Addr, MMO`.
1076 ///
1077 /// Stores the value \p Val to \p Addr.
1078 ///
1079 /// \pre setBasicBlock or setMI must have been called.
1080 /// \pre \p Val must be a generic virtual register.
1081 /// \pre \p Addr must be a generic virtual register with pointer type.
1082 ///
1083 /// \return a MachineInstrBuilder for the newly created instruction.
1084 MachineInstrBuilder buildStore(const SrcOp &Val, const SrcOp &Addr,
1085 MachineMemOperand &MMO);
1086
1087 /// Build and insert `<opcode> Val, Addr, MMO`.
1088 ///
1089 /// Stores the value \p Val to \p Addr.
1090 ///
1091 /// \pre setBasicBlock or setMI must have been called.
1092 /// \pre \p Val must be a generic virtual register.
1093 /// \pre \p Addr must be a generic virtual register with pointer type.
1094 ///
1095 /// \return a MachineInstrBuilder for the newly created instruction.
1096 MachineInstrBuilder buildStoreInstr(unsigned Opcode, const SrcOp &Val,
1097 const SrcOp &Addr,
1098 MachineMemOperand &MMO);
1099
1100 /// Build and insert a G_STORE instruction, while constructing the
1101 /// MachineMemOperand.
1103 buildStore(const SrcOp &Val, const SrcOp &Addr, MachinePointerInfo PtrInfo,
1104 Align Alignment,
1106 const AAMDNodes &AAInfo = AAMDNodes());
1107
1108 /// Build and insert `Res0, ... = G_EXTRACT Src, Idx0`.
1109 ///
1110 /// \pre setBasicBlock or setMI must have been called.
1111 /// \pre \p Res and \p Src must be generic virtual registers.
1112 ///
1113 /// \return a MachineInstrBuilder for the newly created instruction.
1114 MachineInstrBuilder buildExtract(const DstOp &Res, const SrcOp &Src, uint64_t Index);
1115
1116 /// Build and insert \p Res = IMPLICIT_DEF.
1117 MachineInstrBuilder buildUndef(const DstOp &Res);
1118
1119 /// Build and insert \p Res = G_MERGE_VALUES \p Op0, ...
1120 ///
1121 /// G_MERGE_VALUES combines the input elements contiguously into a larger
1122 /// register. It should only be used when the destination register is not a
1123 /// vector.
1124 ///
1125 /// \pre setBasicBlock or setMI must have been called.
1126 /// \pre The entire register \p Res (and no more) must be covered by the input
1127 /// registers.
1128 /// \pre The type of all \p Ops registers must be identical.
1129 ///
1130 /// \return a MachineInstrBuilder for the newly created instruction.
1131 MachineInstrBuilder buildMergeValues(const DstOp &Res,
1133
1134 /// Build and insert \p Res = G_MERGE_VALUES \p Op0, ...
1135 /// or \p Res = G_BUILD_VECTOR \p Op0, ...
1136 /// or \p Res = G_CONCAT_VECTORS \p Op0, ...
1137 ///
1138 /// G_MERGE_VALUES combines the input elements contiguously into a larger
1139 /// register. It is used when the destination register is not a vector.
1140 /// G_BUILD_VECTOR combines scalar inputs into a vector register.
1141 /// G_CONCAT_VECTORS combines vector inputs into a vector register.
1142 ///
1143 /// \pre setBasicBlock or setMI must have been called.
1144 /// \pre The entire register \p Res (and no more) must be covered by the input
1145 /// registers.
1146 /// \pre The type of all \p Ops registers must be identical.
1147 ///
1148 /// \return a MachineInstrBuilder for the newly created instruction. The
1149 /// opcode of the new instruction will depend on the types of both
1150 /// the destination and the sources.
1151 MachineInstrBuilder buildMergeLikeInstr(const DstOp &Res,
1153 MachineInstrBuilder buildMergeLikeInstr(const DstOp &Res,
1154 std::initializer_list<SrcOp> Ops);
1155
1156 /// Build and insert \p Res0, ... = G_UNMERGE_VALUES \p Op
1157 ///
1158 /// G_UNMERGE_VALUES splits contiguous bits of the input into multiple
1159 ///
1160 /// \pre setBasicBlock or setMI must have been called.
1161 /// \pre The entire register \p Res (and no more) must be covered by the input
1162 /// registers.
1163 /// \pre The type of all \p Res registers must be identical.
1164 ///
1165 /// \return a MachineInstrBuilder for the newly created instruction.
1166 MachineInstrBuilder buildUnmerge(ArrayRef<LLT> Res, const SrcOp &Op);
1167 MachineInstrBuilder buildUnmerge(ArrayRef<Register> Res, const SrcOp &Op);
1168
1169 /// Build and insert an unmerge of \p Res sized pieces to cover \p Op
1170 MachineInstrBuilder buildUnmerge(LLT Res, const SrcOp &Op);
1171
1172 /// Build and insert an unmerge of pieces with \p Attrs register attributes to
1173 /// cover \p Op
1175 const SrcOp &Op);
1176
1177 /// Build and insert \p Res = G_BUILD_VECTOR \p Op0, ...
1178 ///
1179 /// G_BUILD_VECTOR creates a vector value from multiple scalar registers.
1180 /// \pre setBasicBlock or setMI must have been called.
1181 /// \pre The entire register \p Res (and no more) must be covered by the
1182 /// input scalar registers.
1183 /// \pre The type of all \p Ops registers must be identical.
1184 ///
1185 /// \return a MachineInstrBuilder for the newly created instruction.
1186 MachineInstrBuilder buildBuildVector(const DstOp &Res,
1188
1189 /// Build and insert \p Res = G_BUILD_VECTOR \p Op0, ... where each OpN is
1190 /// built with G_CONSTANT.
1191 MachineInstrBuilder buildBuildVectorConstant(const DstOp &Res,
1193
1194 /// Build and insert \p Res = G_BUILD_VECTOR with \p Src replicated to fill
1195 /// the number of elements
1196 MachineInstrBuilder buildSplatBuildVector(const DstOp &Res, const SrcOp &Src);
1197
1198 /// Build and insert \p Res = G_BUILD_VECTOR_TRUNC \p Op0, ...
1199 ///
1200 /// G_BUILD_VECTOR_TRUNC creates a vector value from multiple scalar registers
1201 /// which have types larger than the destination vector element type, and
1202 /// truncates the values to fit.
1203 ///
1204 /// If the operands given are already the same size as the vector elt type,
1205 /// then this method will instead create a G_BUILD_VECTOR instruction.
1206 ///
1207 /// \pre setBasicBlock or setMI must have been called.
1208 /// \pre The type of all \p Ops registers must be identical.
1209 ///
1210 /// \return a MachineInstrBuilder for the newly created instruction.
1211 MachineInstrBuilder buildBuildVectorTrunc(const DstOp &Res,
1213
1214 /// Build and insert a vector splat of a scalar \p Src using a
1215 /// G_INSERT_VECTOR_ELT and G_SHUFFLE_VECTOR idiom.
1216 ///
1217 /// \pre setBasicBlock or setMI must have been called.
1218 /// \pre \p Src must have the same type as the element type of \p Dst
1219 ///
1220 /// \return a MachineInstrBuilder for the newly created instruction.
1221 MachineInstrBuilder buildShuffleSplat(const DstOp &Res, const SrcOp &Src);
1222
1223 /// Build and insert \p Res = G_SHUFFLE_VECTOR \p Src1, \p Src2, \p Mask
1224 ///
1225 /// \pre setBasicBlock or setMI must have been called.
1226 ///
1227 /// \return a MachineInstrBuilder for the newly created instruction.
1228 MachineInstrBuilder buildShuffleVector(const DstOp &Res, const SrcOp &Src1,
1229 const SrcOp &Src2, ArrayRef<int> Mask);
1230
1231 /// Build and insert \p Res = G_SPLAT_VECTOR \p Val
1232 ///
1233 /// \pre setBasicBlock or setMI must have been called.
1234 /// \pre \p Res must be a generic virtual register with vector type.
1235 /// \pre \p Val must be a generic virtual register with scalar type.
1236 ///
1237 /// \return a MachineInstrBuilder for the newly created instruction.
1238 MachineInstrBuilder buildSplatVector(const DstOp &Res, const SrcOp &Val);
1239
1240 /// Build and insert \p Res = G_CONCAT_VECTORS \p Op0, ...
1241 ///
1242 /// G_CONCAT_VECTORS creates a vector from the concatenation of 2 or more
1243 /// vectors.
1244 ///
1245 /// \pre setBasicBlock or setMI must have been called.
1246 /// \pre The entire register \p Res (and no more) must be covered by the input
1247 /// registers.
1248 /// \pre The type of all source operands must be identical.
1249 ///
1250 /// \return a MachineInstrBuilder for the newly created instruction.
1251 MachineInstrBuilder buildConcatVectors(const DstOp &Res,
1253
1254 /// Build and insert `Res = G_INSERT_SUBVECTOR Src0, Src1, Idx`.
1255 ///
1256 /// \pre setBasicBlock or setMI must have been called.
1257 /// \pre \p Res, \p Src0, and \p Src1 must be generic virtual registers with
1258 /// vector type.
1259 ///
1260 /// \return a MachineInstrBuilder for the newly created instruction.
1261 MachineInstrBuilder buildInsertSubvector(const DstOp &Res, const SrcOp &Src0,
1262 const SrcOp &Src1, unsigned Index);
1263
1264 /// Build and insert `Res = G_EXTRACT_SUBVECTOR Src, Idx0`.
1265 ///
1266 /// \pre setBasicBlock or setMI must have been called.
1267 /// \pre \p Res and \p Src must be generic virtual registers with vector type.
1268 ///
1269 /// \return a MachineInstrBuilder for the newly created instruction.
1270 MachineInstrBuilder buildExtractSubvector(const DstOp &Res, const SrcOp &Src,
1271 unsigned Index);
1272
1273 MachineInstrBuilder buildInsert(const DstOp &Res, const SrcOp &Src,
1274 const SrcOp &Op, unsigned Index);
1275
1276 /// Build and insert \p Res = G_STEP_VECTOR \p Step
1277 ///
1278 /// G_STEP_VECTOR returns a scalable vector of linear sequence of step \p Step
1279 /// into \p Res.
1280 ///
1281 /// \pre setBasicBlock or setMI must have been called.
1282 /// \pre \p Res must be a generic virtual register with scalable vector type.
1283 ///
1284 /// \return a MachineInstrBuilder for the newly created instruction.
1285 MachineInstrBuilder buildStepVector(const DstOp &Res, unsigned Step);
1286
1287 /// Build and insert \p Res = G_VSCALE \p MinElts
1288 ///
1289 /// G_VSCALE puts the value of the runtime vscale multiplied by \p MinElts
1290 /// into \p Res.
1291 ///
1292 /// \pre setBasicBlock or setMI must have been called.
1293 /// \pre \p Res must be a generic virtual register with scalar type.
1294 ///
1295 /// \return a MachineInstrBuilder for the newly created instruction.
1296 MachineInstrBuilder buildVScale(const DstOp &Res, unsigned MinElts);
1297
1298 /// Build and insert \p Res = G_VSCALE \p MinElts
1299 ///
1300 /// G_VSCALE puts the value of the runtime vscale multiplied by \p MinElts
1301 /// into \p Res.
1302 ///
1303 /// \pre setBasicBlock or setMI must have been called.
1304 /// \pre \p Res must be a generic virtual register with scalar type.
1305 ///
1306 /// \return a MachineInstrBuilder for the newly created instruction.
1307 MachineInstrBuilder buildVScale(const DstOp &Res, const ConstantInt &MinElts);
1308
1309 /// Build and insert \p Res = G_VSCALE \p MinElts
1310 ///
1311 /// G_VSCALE puts the value of the runtime vscale multiplied by \p MinElts
1312 /// into \p Res.
1313 ///
1314 /// \pre setBasicBlock or setMI must have been called.
1315 /// \pre \p Res must be a generic virtual register with scalar type.
1316 ///
1317 /// \return a MachineInstrBuilder for the newly created instruction.
1318 MachineInstrBuilder buildVScale(const DstOp &Res, const APInt &MinElts);
1319
1320 /// Build and insert a G_INTRINSIC instruction.
1321 ///
1322 /// There are four different opcodes based on combinations of whether the
1323 /// intrinsic has side effects and whether it is convergent. These properties
1324 /// can be specified as explicit parameters, or else they are retrieved from
1325 /// the MCID for the intrinsic.
1326 ///
1327 /// The parameter \p Res provides the Registers or MOs that will be defined by
1328 /// this instruction.
1329 ///
1330 /// \pre setBasicBlock or setMI must have been called.
1331 ///
1332 /// \return a MachineInstrBuilder for the newly created instruction.
1334 bool HasSideEffects, bool isConvergent);
1337 bool HasSideEffects, bool isConvergent);
1339
1340 /// Build and insert \p Res = G_FPTRUNC \p Op
1341 ///
1342 /// G_FPTRUNC converts a floating-point value into one with a smaller type.
1343 ///
1344 /// \pre setBasicBlock or setMI must have been called.
1345 /// \pre \p Res must be a generic virtual register with scalar or vector type.
1346 /// \pre \p Op must be a generic virtual register with scalar or vector type.
1347 /// \pre \p Res must be smaller than \p Op
1348 ///
1349 /// \return The newly created instruction.
1351 buildFPTrunc(const DstOp &Res, const SrcOp &Op,
1352 std::optional<unsigned> Flags = std::nullopt);
1353
1354 /// Build and insert \p Res = G_TRUNC \p Op
1355 ///
1356 /// G_TRUNC extracts the low bits of a type. For a vector type each element is
1357 /// truncated independently before being packed into the destination.
1358 ///
1359 /// \pre setBasicBlock or setMI must have been called.
1360 /// \pre \p Res must be a generic virtual register with scalar or vector type.
1361 /// \pre \p Op must be a generic virtual register with scalar or vector type.
1362 /// \pre \p Res must be smaller than \p Op
1363 ///
1364 /// \return The newly created instruction.
1365 MachineInstrBuilder buildTrunc(const DstOp &Res, const SrcOp &Op,
1366 std::optional<unsigned> Flags = std::nullopt);
1367
1368 /// Build and insert a \p Res = G_ICMP \p Pred, \p Op0, \p Op1
1369 ///
1370 /// \pre setBasicBlock or setMI must have been called.
1371
1372 /// \pre \p Res must be a generic virtual register with scalar or
1373 /// vector type. Typically this starts as s1 or <N x s1>.
1374 /// \pre \p Op0 and Op1 must be generic virtual registers with the
1375 /// same number of elements as \p Res. If \p Res is a scalar,
1376 /// \p Op0 must be either a scalar or pointer.
1377 /// \pre \p Pred must be an integer predicate.
1378 ///
1379 /// \return a MachineInstrBuilder for the newly created instruction.
1380 MachineInstrBuilder buildICmp(CmpInst::Predicate Pred, const DstOp &Res,
1381 const SrcOp &Op0, const SrcOp &Op1,
1382 std::optional<unsigned> Flags = std::nullopt);
1383
1384 /// Build and insert a \p Res = G_FCMP \p Pred\p Op0, \p Op1
1385 ///
1386 /// \pre setBasicBlock or setMI must have been called.
1387
1388 /// \pre \p Res must be a generic virtual register with scalar or
1389 /// vector type. Typically this starts as s1 or <N x s1>.
1390 /// \pre \p Op0 and Op1 must be generic virtual registers with the
1391 /// same number of elements as \p Res (or scalar, if \p Res is
1392 /// scalar).
1393 /// \pre \p Pred must be a floating-point predicate.
1394 ///
1395 /// \return a MachineInstrBuilder for the newly created instruction.
1396 MachineInstrBuilder buildFCmp(CmpInst::Predicate Pred, const DstOp &Res,
1397 const SrcOp &Op0, const SrcOp &Op1,
1398 std::optional<unsigned> Flags = std::nullopt);
1399
1400 /// Build and insert a \p Res = G_SCMP \p Op0, \p Op1
1401 ///
1402 /// \pre setBasicBlock or setMI must have been called.
1403
1404 /// \pre \p Res must be a generic virtual register with scalar or
1405 /// vector type. Typically this starts as s2 or <N x s2>.
1406 /// \pre \p Op0 and Op1 must be generic virtual registers with the
1407 /// same number of elements as \p Res. If \p Res is a scalar,
1408 /// \p Op0 must be a scalar.
1409 ///
1410 /// \return a MachineInstrBuilder for the newly created instruction.
1411 MachineInstrBuilder buildSCmp(const DstOp &Res, const SrcOp &Op0,
1412 const SrcOp &Op1);
1413
1414 /// Build and insert a \p Res = G_UCMP \p Op0, \p Op1
1415 ///
1416 /// \pre setBasicBlock or setMI must have been called.
1417
1418 /// \pre \p Res must be a generic virtual register with scalar or
1419 /// vector type. Typically this starts as s2 or <N x s2>.
1420 /// \pre \p Op0 and Op1 must be generic virtual registers with the
1421 /// same number of elements as \p Res. If \p Res is a scalar,
1422 /// \p Op0 must be a scalar.
1423 ///
1424 /// \return a MachineInstrBuilder for the newly created instruction.
1425 MachineInstrBuilder buildUCmp(const DstOp &Res, const SrcOp &Op0,
1426 const SrcOp &Op1);
1427
1428 /// Build and insert a \p Res = G_IS_FPCLASS \p Src, \p Mask
1430 unsigned Mask) {
1431 return buildInstr(TargetOpcode::G_IS_FPCLASS, {Res},
1432 {Src, SrcOp(static_cast<int64_t>(Mask))});
1433 }
1434
1435 /// Build and insert a \p Res = G_SELECT \p Tst, \p Op0, \p Op1
1436 ///
1437 /// \pre setBasicBlock or setMI must have been called.
1438 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
1439 /// with the same type.
1440 /// \pre \p Tst must be a generic virtual register with scalar, pointer or
1441 /// vector type. If vector then it must have the same number of
1442 /// elements as the other parameters.
1443 ///
1444 /// \return a MachineInstrBuilder for the newly created instruction.
1445 MachineInstrBuilder buildSelect(const DstOp &Res, const SrcOp &Tst,
1446 const SrcOp &Op0, const SrcOp &Op1,
1447 std::optional<unsigned> Flags = std::nullopt);
1448
1449 /// Build and insert \p Res = G_INSERT_VECTOR_ELT \p Val,
1450 /// \p Elt, \p Idx
1451 ///
1452 /// \pre setBasicBlock or setMI must have been called.
1453 /// \pre \p Res and \p Val must be a generic virtual register
1454 // with the same vector type.
1455 /// \pre \p Elt and \p Idx must be a generic virtual register
1456 /// with scalar type.
1457 ///
1458 /// \return The newly created instruction.
1459 MachineInstrBuilder buildInsertVectorElement(const DstOp &Res,
1460 const SrcOp &Val,
1461 const SrcOp &Elt,
1462 const SrcOp &Idx);
1463
1464 /// Build and insert \p Res = G_EXTRACT_VECTOR_ELT \p Val, \p Idx
1465 ///
1466 /// \pre setBasicBlock or setMI must have been called.
1467 /// \pre \p Res must be a generic virtual register with scalar type.
1468 /// \pre \p Val must be a generic virtual register with vector type.
1469 ///
1470 /// \return The newly created instruction.
1472 const SrcOp &Val,
1473 const int Idx) {
1474 const TargetLowering *TLI = getMF().getSubtarget().getTargetLowering();
1475 LLT IdxTy = TLI->getVectorIdxLLT(getDataLayout());
1476 return buildExtractVectorElement(Res, Val, buildConstant(IdxTy, Idx));
1477 }
1478
1479 /// Build and insert \p Res = G_EXTRACT_VECTOR_ELT \p Val, \p Idx
1480 ///
1481 /// \pre setBasicBlock or setMI must have been called.
1482 /// \pre \p Res must be a generic virtual register with scalar type.
1483 /// \pre \p Val must be a generic virtual register with vector type.
1484 /// \pre \p Idx must be a generic virtual register with scalar type.
1485 ///
1486 /// \return The newly created instruction.
1487 MachineInstrBuilder buildExtractVectorElement(const DstOp &Res,
1488 const SrcOp &Val,
1489 const SrcOp &Idx);
1490
1491 /// Build and insert `OldValRes<def>, SuccessRes<def> =
1492 /// G_ATOMIC_CMPXCHG_WITH_SUCCESS Addr, CmpVal, NewVal, MMO`.
1493 ///
1494 /// Atomically replace the value at \p Addr with \p NewVal if it is currently
1495 /// \p CmpVal otherwise leaves it unchanged. Puts the original value from \p
1496 /// Addr in \p Res, along with an s1 indicating whether it was replaced.
1497 ///
1498 /// \pre setBasicBlock or setMI must have been called.
1499 /// \pre \p OldValRes must be a generic virtual register of scalar type.
1500 /// \pre \p SuccessRes must be a generic virtual register of scalar type. It
1501 /// will be assigned 0 on failure and 1 on success.
1502 /// \pre \p Addr must be a generic virtual register with pointer type.
1503 /// \pre \p OldValRes, \p CmpVal, and \p NewVal must be generic virtual
1504 /// registers of the same type.
1505 ///
1506 /// \return a MachineInstrBuilder for the newly created instruction.
1508 buildAtomicCmpXchgWithSuccess(const DstOp &OldValRes, const DstOp &SuccessRes,
1509 const SrcOp &Addr, const SrcOp &CmpVal,
1510 const SrcOp &NewVal, MachineMemOperand &MMO);
1511
1512 /// Build and insert `OldValRes<def> = G_ATOMIC_CMPXCHG Addr, CmpVal, NewVal,
1513 /// MMO`.
1514 ///
1515 /// Atomically replace the value at \p Addr with \p NewVal if it is currently
1516 /// \p CmpVal otherwise leaves it unchanged. Puts the original value from \p
1517 /// Addr in \p Res.
1518 ///
1519 /// \pre setBasicBlock or setMI must have been called.
1520 /// \pre \p OldValRes must be a generic virtual register of scalar type.
1521 /// \pre \p Addr must be a generic virtual register with pointer type.
1522 /// \pre \p OldValRes, \p CmpVal, and \p NewVal must be generic virtual
1523 /// registers of the same type.
1524 ///
1525 /// \return a MachineInstrBuilder for the newly created instruction.
1526 MachineInstrBuilder buildAtomicCmpXchg(const DstOp &OldValRes,
1527 const SrcOp &Addr, const SrcOp &CmpVal,
1528 const SrcOp &NewVal,
1529 MachineMemOperand &MMO);
1530
1531 /// Build and insert `OldValRes<def> = G_ATOMICRMW_<Opcode> Addr, Val, MMO`.
1532 ///
1533 /// Atomically read-modify-update the value at \p Addr with \p Val. Puts the
1534 /// original value from \p Addr in \p OldValRes. The modification is
1535 /// determined by the opcode.
1536 ///
1537 /// \pre setBasicBlock or setMI must have been called.
1538 /// \pre \p OldValRes must be a generic virtual register.
1539 /// \pre \p Addr must be a generic virtual register with pointer type.
1540 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1541 /// same type.
1542 ///
1543 /// \return a MachineInstrBuilder for the newly created instruction.
1544 MachineInstrBuilder buildAtomicRMW(unsigned Opcode, const DstOp &OldValRes,
1545 const SrcOp &Addr, const SrcOp &Val,
1546 MachineMemOperand &MMO);
1547
1548 /// Build and insert `OldValRes<def> = G_ATOMICRMW_XCHG Addr, Val, MMO`.
1549 ///
1550 /// Atomically replace the value at \p Addr with \p Val. Puts the original
1551 /// value from \p Addr in \p OldValRes.
1552 ///
1553 /// \pre setBasicBlock or setMI must have been called.
1554 /// \pre \p OldValRes must be a generic virtual register.
1555 /// \pre \p Addr must be a generic virtual register with pointer type.
1556 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1557 /// same type.
1558 ///
1559 /// \return a MachineInstrBuilder for the newly created instruction.
1560 MachineInstrBuilder buildAtomicRMWXchg(Register OldValRes, Register Addr,
1561 Register Val, MachineMemOperand &MMO);
1562
1563 /// Build and insert `OldValRes<def> = G_ATOMICRMW_ADD Addr, Val, MMO`.
1564 ///
1565 /// Atomically replace the value at \p Addr with the addition of \p Val and
1566 /// the original value. Puts the original value from \p Addr in \p OldValRes.
1567 ///
1568 /// \pre setBasicBlock or setMI must have been called.
1569 /// \pre \p OldValRes must be a generic virtual register.
1570 /// \pre \p Addr must be a generic virtual register with pointer type.
1571 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1572 /// same type.
1573 ///
1574 /// \return a MachineInstrBuilder for the newly created instruction.
1575 MachineInstrBuilder buildAtomicRMWAdd(Register OldValRes, Register Addr,
1576 Register Val, MachineMemOperand &MMO);
1577
1578 /// Build and insert `OldValRes<def> = G_ATOMICRMW_SUB Addr, Val, MMO`.
1579 ///
1580 /// Atomically replace the value at \p Addr with the subtraction of \p Val and
1581 /// the original value. Puts the original value from \p Addr in \p OldValRes.
1582 ///
1583 /// \pre setBasicBlock or setMI must have been called.
1584 /// \pre \p OldValRes must be a generic virtual register.
1585 /// \pre \p Addr must be a generic virtual register with pointer type.
1586 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1587 /// same type.
1588 ///
1589 /// \return a MachineInstrBuilder for the newly created instruction.
1590 MachineInstrBuilder buildAtomicRMWSub(Register OldValRes, Register Addr,
1591 Register Val, MachineMemOperand &MMO);
1592
1593 /// Build and insert `OldValRes<def> = G_ATOMICRMW_AND Addr, Val, MMO`.
1594 ///
1595 /// Atomically replace the value at \p Addr with the bitwise and of \p Val and
1596 /// the original value. Puts the original value from \p Addr in \p OldValRes.
1597 ///
1598 /// \pre setBasicBlock or setMI must have been called.
1599 /// \pre \p OldValRes must be a generic virtual register.
1600 /// \pre \p Addr must be a generic virtual register with pointer type.
1601 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1602 /// same type.
1603 ///
1604 /// \return a MachineInstrBuilder for the newly created instruction.
1605 MachineInstrBuilder buildAtomicRMWAnd(Register OldValRes, Register Addr,
1606 Register Val, MachineMemOperand &MMO);
1607
1608 /// Build and insert `OldValRes<def> = G_ATOMICRMW_NAND Addr, Val, MMO`.
1609 ///
1610 /// Atomically replace the value at \p Addr with the bitwise nand of \p Val
1611 /// and the original value. Puts the original value from \p Addr in \p
1612 /// OldValRes.
1613 ///
1614 /// \pre setBasicBlock or setMI must have been called.
1615 /// \pre \p OldValRes must be a generic virtual register.
1616 /// \pre \p Addr must be a generic virtual register with pointer type.
1617 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1618 /// same type.
1619 ///
1620 /// \return a MachineInstrBuilder for the newly created instruction.
1621 MachineInstrBuilder buildAtomicRMWNand(Register OldValRes, Register Addr,
1622 Register Val, MachineMemOperand &MMO);
1623
1624 /// Build and insert `OldValRes<def> = G_ATOMICRMW_OR Addr, Val, MMO`.
1625 ///
1626 /// Atomically replace the value at \p Addr with the bitwise or of \p Val and
1627 /// the original value. Puts the original value from \p Addr in \p OldValRes.
1628 ///
1629 /// \pre setBasicBlock or setMI must have been called.
1630 /// \pre \p OldValRes must be a generic virtual register.
1631 /// \pre \p Addr must be a generic virtual register with pointer type.
1632 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1633 /// same type.
1634 ///
1635 /// \return a MachineInstrBuilder for the newly created instruction.
1636 MachineInstrBuilder buildAtomicRMWOr(Register OldValRes, Register Addr,
1637 Register Val, MachineMemOperand &MMO);
1638
1639 /// Build and insert `OldValRes<def> = G_ATOMICRMW_XOR Addr, Val, MMO`.
1640 ///
1641 /// Atomically replace the value at \p Addr with the bitwise xor of \p Val and
1642 /// the original value. Puts the original value from \p Addr in \p OldValRes.
1643 ///
1644 /// \pre setBasicBlock or setMI must have been called.
1645 /// \pre \p OldValRes must be a generic virtual register.
1646 /// \pre \p Addr must be a generic virtual register with pointer type.
1647 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1648 /// same type.
1649 ///
1650 /// \return a MachineInstrBuilder for the newly created instruction.
1651 MachineInstrBuilder buildAtomicRMWXor(Register OldValRes, Register Addr,
1652 Register Val, MachineMemOperand &MMO);
1653
1654 /// Build and insert `OldValRes<def> = G_ATOMICRMW_MAX Addr, Val, MMO`.
1655 ///
1656 /// Atomically replace the value at \p Addr with the signed maximum of \p
1657 /// Val and the original value. Puts the original value from \p Addr in \p
1658 /// OldValRes.
1659 ///
1660 /// \pre setBasicBlock or setMI must have been called.
1661 /// \pre \p OldValRes must be a generic virtual register.
1662 /// \pre \p Addr must be a generic virtual register with pointer type.
1663 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1664 /// same type.
1665 ///
1666 /// \return a MachineInstrBuilder for the newly created instruction.
1667 MachineInstrBuilder buildAtomicRMWMax(Register OldValRes, Register Addr,
1668 Register Val, MachineMemOperand &MMO);
1669
1670 /// Build and insert `OldValRes<def> = G_ATOMICRMW_MIN Addr, Val, MMO`.
1671 ///
1672 /// Atomically replace the value at \p Addr with the signed minimum of \p
1673 /// Val and the original value. Puts the original value from \p Addr in \p
1674 /// OldValRes.
1675 ///
1676 /// \pre setBasicBlock or setMI must have been called.
1677 /// \pre \p OldValRes must be a generic virtual register.
1678 /// \pre \p Addr must be a generic virtual register with pointer type.
1679 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1680 /// same type.
1681 ///
1682 /// \return a MachineInstrBuilder for the newly created instruction.
1683 MachineInstrBuilder buildAtomicRMWMin(Register OldValRes, Register Addr,
1684 Register Val, MachineMemOperand &MMO);
1685
1686 /// Build and insert `OldValRes<def> = G_ATOMICRMW_UMAX Addr, Val, MMO`.
1687 ///
1688 /// Atomically replace the value at \p Addr with the unsigned maximum of \p
1689 /// Val and the original value. Puts the original value from \p Addr in \p
1690 /// OldValRes.
1691 ///
1692 /// \pre setBasicBlock or setMI must have been called.
1693 /// \pre \p OldValRes must be a generic virtual register.
1694 /// \pre \p Addr must be a generic virtual register with pointer type.
1695 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1696 /// same type.
1697 ///
1698 /// \return a MachineInstrBuilder for the newly created instruction.
1699 MachineInstrBuilder buildAtomicRMWUmax(Register OldValRes, Register Addr,
1700 Register Val, MachineMemOperand &MMO);
1701
1702 /// Build and insert `OldValRes<def> = G_ATOMICRMW_UMIN Addr, Val, MMO`.
1703 ///
1704 /// Atomically replace the value at \p Addr with the unsigned minimum of \p
1705 /// Val and the original value. Puts the original value from \p Addr in \p
1706 /// OldValRes.
1707 ///
1708 /// \pre setBasicBlock or setMI must have been called.
1709 /// \pre \p OldValRes must be a generic virtual register.
1710 /// \pre \p Addr must be a generic virtual register with pointer type.
1711 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1712 /// same type.
1713 ///
1714 /// \return a MachineInstrBuilder for the newly created instruction.
1715 MachineInstrBuilder buildAtomicRMWUmin(Register OldValRes, Register Addr,
1716 Register Val, MachineMemOperand &MMO);
1717
1718 /// Build and insert `OldValRes<def> = G_ATOMICRMW_FADD Addr, Val, MMO`.
1719 MachineInstrBuilder buildAtomicRMWFAdd(
1720 const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val,
1721 MachineMemOperand &MMO);
1722
1723 /// Build and insert `OldValRes<def> = G_ATOMICRMW_FSUB Addr, Val, MMO`.
1724 MachineInstrBuilder buildAtomicRMWFSub(
1725 const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val,
1726 MachineMemOperand &MMO);
1727
1728 /// Build and insert `OldValRes<def> = G_ATOMICRMW_FMAX Addr, Val, MMO`.
1729 ///
1730 /// Atomically replace the value at \p Addr with the floating point maximum of
1731 /// \p Val and the original value. Puts the original value from \p Addr in \p
1732 /// OldValRes.
1733 ///
1734 /// \pre setBasicBlock or setMI must have been called.
1735 /// \pre \p OldValRes must be a generic virtual register.
1736 /// \pre \p Addr must be a generic virtual register with pointer type.
1737 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1738 /// same type.
1739 ///
1740 /// \return a MachineInstrBuilder for the newly created instruction.
1741 MachineInstrBuilder buildAtomicRMWFMax(
1742 const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val,
1743 MachineMemOperand &MMO);
1744
1745 /// Build and insert `OldValRes<def> = G_ATOMICRMW_FMIN Addr, Val, MMO`.
1746 ///
1747 /// Atomically replace the value at \p Addr with the floating point minimum of
1748 /// \p Val and the original value. Puts the original value from \p Addr in \p
1749 /// OldValRes.
1750 ///
1751 /// \pre setBasicBlock or setMI must have been called.
1752 /// \pre \p OldValRes must be a generic virtual register.
1753 /// \pre \p Addr must be a generic virtual register with pointer type.
1754 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1755 /// same type.
1756 ///
1757 /// \return a MachineInstrBuilder for the newly created instruction.
1758 MachineInstrBuilder buildAtomicRMWFMin(
1759 const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val,
1760 MachineMemOperand &MMO);
1761
1762 /// Build and insert `OldValRes<def> = G_ATOMICRMW_FMAXIMUM Addr, Val, MMO`.
1763 ///
1764 /// Atomically replace the value at \p Addr with the floating point maximum of
1765 /// \p Val and the original value. Puts the original value from \p Addr in \p
1766 /// OldValRes.
1767 ///
1768 /// \pre setBasicBlock or setMI must have been called.
1769 /// \pre \p OldValRes must be a generic virtual register.
1770 /// \pre \p Addr must be a generic virtual register with pointer type.
1771 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1772 /// same type.
1773 ///
1774 /// \return a MachineInstrBuilder for the newly created instruction.
1775 MachineInstrBuilder buildAtomicRMWFMaximum(const DstOp &OldValRes,
1776 const SrcOp &Addr,
1777 const SrcOp &Val,
1778 MachineMemOperand &MMO);
1779
1780 /// Build and insert `OldValRes<def> = G_ATOMICRMW_FMINIMUM Addr, Val, MMO`.
1781 ///
1782 /// Atomically replace the value at \p Addr with the floating point minimum of
1783 /// \p Val and the original value. Puts the original value from \p Addr in \p
1784 /// OldValRes.
1785 ///
1786 /// \pre setBasicBlock or setMI must have been called.
1787 /// \pre \p OldValRes must be a generic virtual register.
1788 /// \pre \p Addr must be a generic virtual register with pointer type.
1789 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1790 /// same type.
1791 ///
1792 /// \return a MachineInstrBuilder for the newly created instruction.
1793 MachineInstrBuilder buildAtomicRMWFMinimum(const DstOp &OldValRes,
1794 const SrcOp &Addr,
1795 const SrcOp &Val,
1796 MachineMemOperand &MMO);
1797
1798 /// Build and insert `OldValRes<def> = G_ATOMICRMW_USUB_COND Addr, Val, MMO`.
1799 ///
1800 /// Atomically replace the value at \p Addr with the original value minus \p
1801 /// Val if the original value is greater than or equal to \p Val, or leaves it
1802 /// unchanged otherwise. Puts the original value from \p Addr in \p OldValRes.
1803 ///
1804 /// \pre setBasicBlock or setMI must have been called.
1805 /// \pre \p OldValRes must be a generic virtual register.
1806 /// \pre \p Addr must be a generic virtual register with pointer type.
1807 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1808 /// same type.
1809 ///
1810 /// \return a MachineInstrBuilder for the newly created instruction.
1812 const SrcOp &Addr,
1813 const SrcOp &Val,
1814 MachineMemOperand &MMO);
1815
1816 /// Build and insert `OldValRes<def> = G_ATOMICRMW_USUB_SAT Addr, Val, MMO`.
1817 ///
1818 /// Atomically replace the value at \p Addr with the original value minus \p
1819 /// Val, with clamping to zero if the unsigned subtraction would overflow.
1820 /// Puts the original value from \p Addr in \p OldValRes.
1821 ///
1822 /// \pre setBasicBlock or setMI must have been called.
1823 /// \pre \p OldValRes must be a generic virtual register.
1824 /// \pre \p Addr must be a generic virtual register with pointer type.
1825 /// \pre \p OldValRes, and \p Val must be generic virtual registers of the
1826 /// same type.
1827 ///
1828 /// \return a MachineInstrBuilder for the newly created instruction.
1830 const SrcOp &Addr, const SrcOp &Val,
1831 MachineMemOperand &MMO);
1832
1833 /// Build and insert `G_FENCE Ordering, Scope`.
1834 MachineInstrBuilder buildFence(unsigned Ordering, unsigned Scope);
1835
1836 /// Build and insert G_PREFETCH \p Addr, \p RW, \p Locality, \p CacheType
1837 MachineInstrBuilder buildPrefetch(const SrcOp &Addr, unsigned RW,
1838 unsigned Locality, unsigned CacheType,
1839 MachineMemOperand &MMO);
1840
1841 /// Build and insert \p Dst = G_FREEZE \p Src
1842 MachineInstrBuilder buildFreeze(const DstOp &Dst, const SrcOp &Src) {
1843 return buildInstr(TargetOpcode::G_FREEZE, {Dst}, {Src});
1844 }
1845
1846 /// Build and insert \p Res = G_BLOCK_ADDR \p BA
1847 ///
1848 /// G_BLOCK_ADDR computes the address of a basic block.
1849 ///
1850 /// \pre setBasicBlock or setMI must have been called.
1851 /// \pre \p Res must be a generic virtual register of a pointer type.
1852 ///
1853 /// \return The newly created instruction.
1854 MachineInstrBuilder buildBlockAddress(Register Res, const BlockAddress *BA);
1855
1856 /// Build and insert \p Res = G_ADD \p Op0, \p Op1
1857 ///
1858 /// G_ADD sets \p Res to the sum of integer parameters \p Op0 and \p Op1,
1859 /// truncated to their width.
1860 ///
1861 /// \pre setBasicBlock or setMI must have been called.
1862 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
1863 /// with the same (scalar or vector) type).
1864 ///
1865 /// \return a MachineInstrBuilder for the newly created instruction.
1866
1867 MachineInstrBuilder buildAdd(const DstOp &Dst, const SrcOp &Src0,
1868 const SrcOp &Src1,
1869 std::optional<unsigned> Flags = std::nullopt) {
1870 return buildInstr(TargetOpcode::G_ADD, {Dst}, {Src0, Src1}, Flags);
1871 }
1872
1873 /// Build and insert \p Res = G_SUB \p Op0, \p Op1
1874 ///
1875 /// G_SUB sets \p Res to the difference of integer parameters \p Op0 and
1876 /// \p Op1, truncated to their width.
1877 ///
1878 /// \pre setBasicBlock or setMI must have been called.
1879 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
1880 /// with the same (scalar or vector) type).
1881 ///
1882 /// \return a MachineInstrBuilder for the newly created instruction.
1883
1884 MachineInstrBuilder buildSub(const DstOp &Dst, const SrcOp &Src0,
1885 const SrcOp &Src1,
1886 std::optional<unsigned> Flags = std::nullopt) {
1887 return buildInstr(TargetOpcode::G_SUB, {Dst}, {Src0, Src1}, Flags);
1888 }
1889
1890 /// Build and insert \p Res = G_MUL \p Op0, \p Op1
1891 ///
1892 /// G_MUL sets \p Res to the product of integer parameters \p Op0 and \p Op1,
1893 /// truncated to their width.
1894 ///
1895 /// \pre setBasicBlock or setMI must have been called.
1896 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
1897 /// with the same (scalar or vector) type).
1898 ///
1899 /// \return a MachineInstrBuilder for the newly created instruction.
1900 MachineInstrBuilder buildMul(const DstOp &Dst, const SrcOp &Src0,
1901 const SrcOp &Src1,
1902 std::optional<unsigned> Flags = std::nullopt) {
1903 return buildInstr(TargetOpcode::G_MUL, {Dst}, {Src0, Src1}, Flags);
1904 }
1905
1906 /// Build and insert \p Res = G_ABDS \p Op0, \p Op1
1907 ///
1908 /// G_ABDS return the signed absolute difference of \p Op0 and \p Op1.
1909 ///
1910 /// \pre setBasicBlock or setMI must have been called.
1911 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
1912 /// with the same (scalar or vector) type).
1913 ///
1914 /// \return a MachineInstrBuilder for the newly created instruction.
1915 MachineInstrBuilder buildAbds(const DstOp &Dst, const SrcOp &Src0,
1916 const SrcOp &Src1) {
1917 return buildInstr(TargetOpcode::G_ABDS, {Dst}, {Src0, Src1});
1918 }
1919
1920 /// Build and insert \p Res = G_ABDU \p Op0, \p Op1
1921 ///
1922 /// G_ABDU return the unsigned absolute difference of \p Op0 and \p Op1.
1923 ///
1924 /// \pre setBasicBlock or setMI must have been called.
1925 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
1926 /// with the same (scalar or vector) type).
1927 ///
1928 /// \return a MachineInstrBuilder for the newly created instruction.
1929 MachineInstrBuilder buildAbdu(const DstOp &Dst, const SrcOp &Src0,
1930 const SrcOp &Src1) {
1931 return buildInstr(TargetOpcode::G_ABDU, {Dst}, {Src0, Src1});
1932 }
1933
1935 const SrcOp &Src1,
1936 std::optional<unsigned> Flags = std::nullopt) {
1937 return buildInstr(TargetOpcode::G_UMULH, {Dst}, {Src0, Src1}, Flags);
1938 }
1939
1941 const SrcOp &Src1,
1942 std::optional<unsigned> Flags = std::nullopt) {
1943 return buildInstr(TargetOpcode::G_SMULH, {Dst}, {Src0, Src1}, Flags);
1944 }
1945
1946 /// Build and insert \p Res = G_UREM \p Op0, \p Op1
1947 MachineInstrBuilder buildURem(const DstOp &Dst, const SrcOp &Src0,
1948 const SrcOp &Src1,
1949 std::optional<unsigned> Flags = std::nullopt) {
1950 return buildInstr(TargetOpcode::G_UREM, {Dst}, {Src0, Src1}, Flags);
1951 }
1952
1953 MachineInstrBuilder buildFMul(const DstOp &Dst, const SrcOp &Src0,
1954 const SrcOp &Src1,
1955 std::optional<unsigned> Flags = std::nullopt) {
1956 return buildInstr(TargetOpcode::G_FMUL, {Dst}, {Src0, Src1}, Flags);
1957 }
1958
1960 buildFMinNum(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1,
1961 std::optional<unsigned> Flags = std::nullopt) {
1962 return buildInstr(TargetOpcode::G_FMINNUM, {Dst}, {Src0, Src1}, Flags);
1963 }
1964
1966 buildFMaxNum(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1,
1967 std::optional<unsigned> Flags = std::nullopt) {
1968 return buildInstr(TargetOpcode::G_FMAXNUM, {Dst}, {Src0, Src1}, Flags);
1969 }
1970
1972 buildFMinNumIEEE(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1,
1973 std::optional<unsigned> Flags = std::nullopt) {
1974 return buildInstr(TargetOpcode::G_FMINNUM_IEEE, {Dst}, {Src0, Src1}, Flags);
1975 }
1976
1978 buildFMaxNumIEEE(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1,
1979 std::optional<unsigned> Flags = std::nullopt) {
1980 return buildInstr(TargetOpcode::G_FMAXNUM_IEEE, {Dst}, {Src0, Src1}, Flags);
1981 }
1982
1983 MachineInstrBuilder buildShl(const DstOp &Dst, const SrcOp &Src0,
1984 const SrcOp &Src1,
1985 std::optional<unsigned> Flags = std::nullopt) {
1986 return buildInstr(TargetOpcode::G_SHL, {Dst}, {Src0, Src1}, Flags);
1987 }
1988
1989 MachineInstrBuilder buildLShr(const DstOp &Dst, const SrcOp &Src0,
1990 const SrcOp &Src1,
1991 std::optional<unsigned> Flags = std::nullopt) {
1992 return buildInstr(TargetOpcode::G_LSHR, {Dst}, {Src0, Src1}, Flags);
1993 }
1994
1995 MachineInstrBuilder buildAShr(const DstOp &Dst, const SrcOp &Src0,
1996 const SrcOp &Src1,
1997 std::optional<unsigned> Flags = std::nullopt) {
1998 return buildInstr(TargetOpcode::G_ASHR, {Dst}, {Src0, Src1}, Flags);
1999 }
2000
2001 /// Build and insert \p Res = G_AND \p Op0, \p Op1
2002 ///
2003 /// G_AND sets \p Res to the bitwise and of integer parameters \p Op0 and \p
2004 /// Op1.
2005 ///
2006 /// \pre setBasicBlock or setMI must have been called.
2007 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
2008 /// with the same (scalar or vector) type).
2009 ///
2010 /// \return a MachineInstrBuilder for the newly created instruction.
2011
2012 MachineInstrBuilder buildAnd(const DstOp &Dst, const SrcOp &Src0,
2013 const SrcOp &Src1) {
2014 return buildInstr(TargetOpcode::G_AND, {Dst}, {Src0, Src1});
2015 }
2016
2017 /// Build and insert \p Res = G_OR \p Op0, \p Op1
2018 ///
2019 /// G_OR sets \p Res to the bitwise or of integer parameters \p Op0 and \p
2020 /// Op1.
2021 ///
2022 /// \pre setBasicBlock or setMI must have been called.
2023 /// \pre \p Res, \p Op0 and \p Op1 must be generic virtual registers
2024 /// with the same (scalar or vector) type).
2025 ///
2026 /// \return a MachineInstrBuilder for the newly created instruction.
2027 MachineInstrBuilder buildOr(const DstOp &Dst, const SrcOp &Src0,
2028 const SrcOp &Src1,
2029 std::optional<unsigned> Flags = std::nullopt) {
2030 return buildInstr(TargetOpcode::G_OR, {Dst}, {Src0, Src1}, Flags);
2031 }
2032
2033 /// Build and insert \p Res = G_XOR \p Op0, \p Op1
2034 MachineInstrBuilder buildXor(const DstOp &Dst, const SrcOp &Src0,
2035 const SrcOp &Src1) {
2036 return buildInstr(TargetOpcode::G_XOR, {Dst}, {Src0, Src1});
2037 }
2038
2039 /// Build and insert a bitwise not,
2040 /// \p NegOne = G_CONSTANT -1
2041 /// \p Res = G_OR \p Op0, NegOne
2042 MachineInstrBuilder buildNot(const DstOp &Dst, const SrcOp &Src0) {
2043 auto NegOne = buildConstant(Dst.getLLTTy(*getMRI()), -1);
2044 return buildInstr(TargetOpcode::G_XOR, {Dst}, {Src0, NegOne});
2045 }
2046
2047 /// Build and insert integer negation
2048 /// \p Zero = G_CONSTANT 0
2049 /// \p Res = G_SUB Zero, \p Op0
2050 MachineInstrBuilder buildNeg(const DstOp &Dst, const SrcOp &Src0) {
2051 auto Zero = buildConstant(Dst.getLLTTy(*getMRI()), 0);
2052 return buildInstr(TargetOpcode::G_SUB, {Dst}, {Zero, Src0});
2053 }
2054
2055 /// Build and insert \p Res = G_CTPOP \p Op0, \p Src0
2056 MachineInstrBuilder buildCTPOP(const DstOp &Dst, const SrcOp &Src0) {
2057 return buildInstr(TargetOpcode::G_CTPOP, {Dst}, {Src0});
2058 }
2059
2060 /// Build and insert \p Res = G_CTLZ \p Op0, \p Src0
2061 MachineInstrBuilder buildCTLZ(const DstOp &Dst, const SrcOp &Src0) {
2062 return buildInstr(TargetOpcode::G_CTLZ, {Dst}, {Src0});
2063 }
2064
2065 /// Build and insert \p Res = G_CTLZ_ZERO_POISON \p Op0, \p Src0
2067 const SrcOp &Src0) {
2068 return buildInstr(TargetOpcode::G_CTLZ_ZERO_POISON, {Dst}, {Src0});
2069 }
2070
2071 /// Build and insert \p Res = G_CTTZ \p Op0, \p Src0
2072 MachineInstrBuilder buildCTTZ(const DstOp &Dst, const SrcOp &Src0) {
2073 return buildInstr(TargetOpcode::G_CTTZ, {Dst}, {Src0});
2074 }
2075
2076 /// Build and insert \p Res = G_CTTZ_ZERO_POISON \p Op0, \p Src0
2078 const SrcOp &Src0) {
2079 return buildInstr(TargetOpcode::G_CTTZ_ZERO_POISON, {Dst}, {Src0});
2080 }
2081
2082 /// Build and insert \p Res = G_CTLS \p Op0, \p Src0
2083 MachineInstrBuilder buildCTLS(const DstOp &Dst, const SrcOp &Src0) {
2084 return buildInstr(TargetOpcode::G_CTLS, {Dst}, {Src0});
2085 }
2086
2087 /// Build and insert \p Dst = G_BSWAP \p Src0
2088 MachineInstrBuilder buildBSwap(const DstOp &Dst, const SrcOp &Src0) {
2089 return buildInstr(TargetOpcode::G_BSWAP, {Dst}, {Src0});
2090 }
2091
2092 /// Build and insert \p Res = G_FADD \p Op0, \p Op1
2093 MachineInstrBuilder buildFAdd(const DstOp &Dst, const SrcOp &Src0,
2094 const SrcOp &Src1,
2095 std::optional<unsigned> Flags = std::nullopt) {
2096 return buildInstr(TargetOpcode::G_FADD, {Dst}, {Src0, Src1}, Flags);
2097 }
2098
2099 /// Build and insert \p Res = G_STRICT_FADD \p Op0, \p Op1
2101 buildStrictFAdd(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1,
2102 std::optional<unsigned> Flags = std::nullopt) {
2103 return buildInstr(TargetOpcode::G_STRICT_FADD, {Dst}, {Src0, Src1}, Flags);
2104 }
2105
2106 /// Build and insert \p Res = G_FSUB \p Op0, \p Op1
2107 MachineInstrBuilder buildFSub(const DstOp &Dst, const SrcOp &Src0,
2108 const SrcOp &Src1,
2109 std::optional<unsigned> Flags = std::nullopt) {
2110 return buildInstr(TargetOpcode::G_FSUB, {Dst}, {Src0, Src1}, Flags);
2111 }
2112
2113 /// Build and insert \p Res = G_FDIV \p Op0, \p Op1
2114 MachineInstrBuilder buildFDiv(const DstOp &Dst, const SrcOp &Src0,
2115 const SrcOp &Src1,
2116 std::optional<unsigned> Flags = std::nullopt) {
2117 return buildInstr(TargetOpcode::G_FDIV, {Dst}, {Src0, Src1}, Flags);
2118 }
2119
2120 /// Build and insert \p Res = G_FMA \p Op0, \p Op1, \p Op2
2121 MachineInstrBuilder buildFMA(const DstOp &Dst, const SrcOp &Src0,
2122 const SrcOp &Src1, const SrcOp &Src2,
2123 std::optional<unsigned> Flags = std::nullopt) {
2124 return buildInstr(TargetOpcode::G_FMA, {Dst}, {Src0, Src1, Src2}, Flags);
2125 }
2126
2127 /// Build and insert \p Res = G_FMAD \p Op0, \p Op1, \p Op2
2128 MachineInstrBuilder buildFMAD(const DstOp &Dst, const SrcOp &Src0,
2129 const SrcOp &Src1, const SrcOp &Src2,
2130 std::optional<unsigned> Flags = std::nullopt) {
2131 return buildInstr(TargetOpcode::G_FMAD, {Dst}, {Src0, Src1, Src2}, Flags);
2132 }
2133
2134 /// Build and insert \p Res = G_FNEG \p Op0
2135 MachineInstrBuilder buildFNeg(const DstOp &Dst, const SrcOp &Src0,
2136 std::optional<unsigned> Flags = std::nullopt) {
2137 return buildInstr(TargetOpcode::G_FNEG, {Dst}, {Src0}, Flags);
2138 }
2139
2140 /// Build and insert \p Res = G_FABS \p Op0
2141 MachineInstrBuilder buildFAbs(const DstOp &Dst, const SrcOp &Src0,
2142 std::optional<unsigned> Flags = std::nullopt) {
2143 return buildInstr(TargetOpcode::G_FABS, {Dst}, {Src0}, Flags);
2144 }
2145
2146 /// Build and insert \p Dst = G_FCANONICALIZE \p Src0
2148 buildFCanonicalize(const DstOp &Dst, const SrcOp &Src0,
2149 std::optional<unsigned> Flags = std::nullopt) {
2150 return buildInstr(TargetOpcode::G_FCANONICALIZE, {Dst}, {Src0}, Flags);
2151 }
2152
2153 /// Build and insert \p Dst = G_INTRINSIC_TRUNC \p Src0
2155 buildIntrinsicTrunc(const DstOp &Dst, const SrcOp &Src0,
2156 std::optional<unsigned> Flags = std::nullopt) {
2157 return buildInstr(TargetOpcode::G_INTRINSIC_TRUNC, {Dst}, {Src0}, Flags);
2158 }
2159
2160 /// Build and insert \p Res = GFFLOOR \p Op0, \p Op1
2162 buildFFloor(const DstOp &Dst, const SrcOp &Src0,
2163 std::optional<unsigned> Flags = std::nullopt) {
2164 return buildInstr(TargetOpcode::G_FFLOOR, {Dst}, {Src0}, Flags);
2165 }
2166
2167 /// Build and insert \p Dst = G_FLOG \p Src
2169 std::optional<unsigned> Flags = std::nullopt) {
2170 return buildInstr(TargetOpcode::G_FLOG, {Dst}, {Src}, Flags);
2171 }
2172
2173 /// Build and insert \p Dst = G_FLOG2 \p Src
2175 std::optional<unsigned> Flags = std::nullopt) {
2176 return buildInstr(TargetOpcode::G_FLOG2, {Dst}, {Src}, Flags);
2177 }
2178
2179 /// Build and insert \p Dst = G_FEXP2 \p Src
2181 std::optional<unsigned> Flags = std::nullopt) {
2182 return buildInstr(TargetOpcode::G_FEXP2, {Dst}, {Src}, Flags);
2183 }
2184
2185 /// Build and insert \p Dst = G_FPOW \p Src0, \p Src1
2186 MachineInstrBuilder buildFPow(const DstOp &Dst, const SrcOp &Src0,
2187 const SrcOp &Src1,
2188 std::optional<unsigned> Flags = std::nullopt) {
2189 return buildInstr(TargetOpcode::G_FPOW, {Dst}, {Src0, Src1}, Flags);
2190 }
2191
2192 /// Build and insert \p Dst = G_FLDEXP \p Src0, \p Src1
2194 buildFLdexp(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1,
2195 std::optional<unsigned> Flags = std::nullopt) {
2196 return buildInstr(TargetOpcode::G_FLDEXP, {Dst}, {Src0, Src1}, Flags);
2197 }
2198
2199 /// Build and insert \p Fract, \p Exp = G_FFREXP \p Src
2201 buildFFrexp(const DstOp &Fract, const DstOp &Exp, const SrcOp &Src,
2202 std::optional<unsigned> Flags = std::nullopt) {
2203 return buildInstr(TargetOpcode::G_FFREXP, {Fract, Exp}, {Src}, Flags);
2204 }
2205
2206 /// Build and insert \p Sin, \p Cos = G_FSINCOS \p Src
2208 buildFSincos(const DstOp &Sin, const DstOp &Cos, const SrcOp &Src,
2209 std::optional<unsigned> Flags = std::nullopt) {
2210 return buildInstr(TargetOpcode::G_FSINCOS, {Sin, Cos}, {Src}, Flags);
2211 }
2212
2213 /// Build and insert \p Fract, \p Int = G_FMODF \p Src
2215 const SrcOp &Src,
2216 std::optional<unsigned> Flags = std::nullopt) {
2217 return buildInstr(TargetOpcode::G_FMODF, {Fract, Int}, {Src}, Flags);
2218 }
2219
2220 /// Build and insert \p Res = G_FCOPYSIGN \p Op0, \p Op1
2222 buildFCopysign(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1,
2223 std::optional<unsigned> Flags = std::nullopt) {
2224 return buildInstr(TargetOpcode::G_FCOPYSIGN, {Dst}, {Src0, Src1}, Flags);
2225 }
2226
2227 /// Build and insert \p Res = G_UITOFP \p Src0
2228 MachineInstrBuilder buildUITOFP(const DstOp &Dst, const SrcOp &Src0) {
2229 return buildInstr(TargetOpcode::G_UITOFP, {Dst}, {Src0});
2230 }
2231
2232 /// Build and insert \p Res = G_SITOFP \p Src0
2233 MachineInstrBuilder buildSITOFP(const DstOp &Dst, const SrcOp &Src0) {
2234 return buildInstr(TargetOpcode::G_SITOFP, {Dst}, {Src0});
2235 }
2236
2237 /// Build and insert \p Res = G_FPTOUI \p Src0
2238 MachineInstrBuilder buildFPTOUI(const DstOp &Dst, const SrcOp &Src0) {
2239 return buildInstr(TargetOpcode::G_FPTOUI, {Dst}, {Src0});
2240 }
2241
2242 /// Build and insert \p Res = G_FPTOSI \p Src0
2243 MachineInstrBuilder buildFPTOSI(const DstOp &Dst, const SrcOp &Src0) {
2244 return buildInstr(TargetOpcode::G_FPTOSI, {Dst}, {Src0});
2245 }
2246
2247 /// Build and insert \p Res = G_FPTOUI_SAT \p Src0
2249 return buildInstr(TargetOpcode::G_FPTOUI_SAT, {Dst}, {Src0});
2250 }
2251
2252 /// Build and insert \p Res = G_FPTOSI_SAT \p Src0
2254 return buildInstr(TargetOpcode::G_FPTOSI_SAT, {Dst}, {Src0});
2255 }
2256
2257 /// Build and insert \p Dst = G_FRINT \p Src0
2259 std::optional<unsigned> Flags = std::nullopt) {
2260 return buildInstr(TargetOpcode::G_FRINT, {Dst}, {Src0}, Flags);
2261 }
2262
2263 /// Build and insert \p Dst = G_INTRINSIC_ROUNDEVEN \p Src0, \p Src1
2265 buildIntrinsicRoundeven(const DstOp &Dst, const SrcOp &Src0,
2266 std::optional<unsigned> Flags = std::nullopt) {
2267 return buildInstr(TargetOpcode::G_INTRINSIC_ROUNDEVEN, {Dst}, {Src0},
2268 Flags);
2269 }
2270
2271 /// Build and insert \p Res = G_SMIN \p Op0, \p Op1
2272 MachineInstrBuilder buildSMin(const DstOp &Dst, const SrcOp &Src0,
2273 const SrcOp &Src1) {
2274 return buildInstr(TargetOpcode::G_SMIN, {Dst}, {Src0, Src1});
2275 }
2276
2277 /// Build and insert \p Res = G_SMAX \p Op0, \p Op1
2278 MachineInstrBuilder buildSMax(const DstOp &Dst, const SrcOp &Src0,
2279 const SrcOp &Src1) {
2280 return buildInstr(TargetOpcode::G_SMAX, {Dst}, {Src0, Src1});
2281 }
2282
2283 /// Build and insert \p Res = G_UMIN \p Op0, \p Op1
2284 MachineInstrBuilder buildUMin(const DstOp &Dst, const SrcOp &Src0,
2285 const SrcOp &Src1) {
2286 return buildInstr(TargetOpcode::G_UMIN, {Dst}, {Src0, Src1});
2287 }
2288
2289 /// Build and insert \p Res = G_UMAX \p Op0, \p Op1
2290 MachineInstrBuilder buildUMax(const DstOp &Dst, const SrcOp &Src0,
2291 const SrcOp &Src1) {
2292 return buildInstr(TargetOpcode::G_UMAX, {Dst}, {Src0, Src1});
2293 }
2294
2295 /// Build and insert \p Dst = G_ABS \p Src
2296 MachineInstrBuilder buildAbs(const DstOp &Dst, const SrcOp &Src) {
2297 return buildInstr(TargetOpcode::G_ABS, {Dst}, {Src});
2298 }
2299
2300 /// Build and insert \p Res = G_JUMP_TABLE \p JTI
2301 ///
2302 /// G_JUMP_TABLE sets \p Res to the address of the jump table specified by
2303 /// the jump table index \p JTI.
2304 ///
2305 /// \return a MachineInstrBuilder for the newly created instruction.
2306 MachineInstrBuilder buildJumpTable(const LLT PtrTy, unsigned JTI);
2307
2308 /// Build and insert \p Res = G_VECREDUCE_SEQ_FADD \p ScalarIn, \p VecIn
2309 ///
2310 /// \p ScalarIn is the scalar accumulator input to start the sequential
2311 /// reduction operation of \p VecIn.
2313 const SrcOp &ScalarIn,
2314 const SrcOp &VecIn) {
2315 return buildInstr(TargetOpcode::G_VECREDUCE_SEQ_FADD, {Dst},
2316 {ScalarIn, {VecIn}});
2317 }
2318
2319 /// Build and insert \p Res = G_VECREDUCE_SEQ_FMUL \p ScalarIn, \p VecIn
2320 ///
2321 /// \p ScalarIn is the scalar accumulator input to start the sequential
2322 /// reduction operation of \p VecIn.
2324 const SrcOp &ScalarIn,
2325 const SrcOp &VecIn) {
2326 return buildInstr(TargetOpcode::G_VECREDUCE_SEQ_FMUL, {Dst},
2327 {ScalarIn, {VecIn}});
2328 }
2329
2330 /// Build and insert \p Res = G_VECREDUCE_FADD \p Src
2331 ///
2332 /// \p ScalarIn is the scalar accumulator input to the reduction operation of
2333 /// \p VecIn.
2335 const SrcOp &ScalarIn,
2336 const SrcOp &VecIn) {
2337 return buildInstr(TargetOpcode::G_VECREDUCE_FADD, {Dst}, {ScalarIn, VecIn});
2338 }
2339
2340 /// Build and insert \p Res = G_VECREDUCE_FMUL \p Src
2341 ///
2342 /// \p ScalarIn is the scalar accumulator input to the reduction operation of
2343 /// \p VecIn.
2345 const SrcOp &ScalarIn,
2346 const SrcOp &VecIn) {
2347 return buildInstr(TargetOpcode::G_VECREDUCE_FMUL, {Dst}, {ScalarIn, VecIn});
2348 }
2349
2350 /// Build and insert \p Res = G_VECREDUCE_FMAX \p Src
2352 return buildInstr(TargetOpcode::G_VECREDUCE_FMAX, {Dst}, {Src});
2353 }
2354
2355 /// Build and insert \p Res = G_VECREDUCE_FMIN \p Src
2357 return buildInstr(TargetOpcode::G_VECREDUCE_FMIN, {Dst}, {Src});
2358 }
2359
2360 /// Build and insert \p Res = G_VECREDUCE_FMAXIMUM \p Src
2362 const SrcOp &Src) {
2363 return buildInstr(TargetOpcode::G_VECREDUCE_FMAXIMUM, {Dst}, {Src});
2364 }
2365
2366 /// Build and insert \p Res = G_VECREDUCE_FMINIMUM \p Src
2368 const SrcOp &Src) {
2369 return buildInstr(TargetOpcode::G_VECREDUCE_FMINIMUM, {Dst}, {Src});
2370 }
2371
2372 /// Build and insert \p Res = G_VECREDUCE_ADD \p Src
2374 return buildInstr(TargetOpcode::G_VECREDUCE_ADD, {Dst}, {Src});
2375 }
2376
2377 /// Build and insert \p Res = G_VECREDUCE_MUL \p Src
2379 return buildInstr(TargetOpcode::G_VECREDUCE_MUL, {Dst}, {Src});
2380 }
2381
2382 /// Build and insert \p Res = G_VECREDUCE_AND \p Src
2384 return buildInstr(TargetOpcode::G_VECREDUCE_AND, {Dst}, {Src});
2385 }
2386
2387 /// Build and insert \p Res = G_VECREDUCE_OR \p Src
2389 return buildInstr(TargetOpcode::G_VECREDUCE_OR, {Dst}, {Src});
2390 }
2391
2392 /// Build and insert \p Res = G_VECREDUCE_XOR \p Src
2394 return buildInstr(TargetOpcode::G_VECREDUCE_XOR, {Dst}, {Src});
2395 }
2396
2397 /// Build and insert \p Res = G_VECREDUCE_SMAX \p Src
2399 return buildInstr(TargetOpcode::G_VECREDUCE_SMAX, {Dst}, {Src});
2400 }
2401
2402 /// Build and insert \p Res = G_VECREDUCE_SMIN \p Src
2404 return buildInstr(TargetOpcode::G_VECREDUCE_SMIN, {Dst}, {Src});
2405 }
2406
2407 /// Build and insert \p Res = G_VECREDUCE_UMAX \p Src
2409 return buildInstr(TargetOpcode::G_VECREDUCE_UMAX, {Dst}, {Src});
2410 }
2411
2412 /// Build and insert \p Res = G_VECREDUCE_UMIN \p Src
2414 return buildInstr(TargetOpcode::G_VECREDUCE_UMIN, {Dst}, {Src});
2415 }
2416
2417 /// Build and insert G_MEMCPY or G_MEMMOVE
2418 MachineInstrBuilder buildMemTransferInst(unsigned Opcode, const SrcOp &DstPtr,
2419 const SrcOp &SrcPtr,
2420 const SrcOp &Size,
2421 MachineMemOperand &DstMMO,
2422 MachineMemOperand &SrcMMO) {
2423 auto MIB = buildInstr(
2424 Opcode, {}, {DstPtr, SrcPtr, Size, SrcOp(INT64_C(0) /*isTailCall*/)});
2425 MIB.addMemOperand(&DstMMO);
2426 MIB.addMemOperand(&SrcMMO);
2427 return MIB;
2428 }
2429
2430 MachineInstrBuilder buildMemCpy(const SrcOp &DstPtr, const SrcOp &SrcPtr,
2431 const SrcOp &Size, MachineMemOperand &DstMMO,
2432 MachineMemOperand &SrcMMO) {
2433 return buildMemTransferInst(TargetOpcode::G_MEMCPY, DstPtr, SrcPtr, Size,
2434 DstMMO, SrcMMO);
2435 }
2436
2437 /// Build and insert G_TRAP or G_DEBUGTRAP
2439 return buildInstr(Debug ? TargetOpcode::G_DEBUGTRAP : TargetOpcode::G_TRAP);
2440 }
2441
2442 /// Build and insert \p Dst = G_SBFX \p Src, \p LSB, \p Width.
2444 const SrcOp &LSB, const SrcOp &Width) {
2445 return buildInstr(TargetOpcode::G_SBFX, {Dst}, {Src, LSB, Width});
2446 }
2447
2448 /// Build and insert \p Dst = G_UBFX \p Src, \p LSB, \p Width.
2450 const SrcOp &LSB, const SrcOp &Width) {
2451 return buildInstr(TargetOpcode::G_UBFX, {Dst}, {Src, LSB, Width});
2452 }
2453
2454 /// Build and insert \p Dst = G_ROTR \p Src, \p Amt
2456 const SrcOp &Amt) {
2457 return buildInstr(TargetOpcode::G_ROTR, {Dst}, {Src, Amt});
2458 }
2459
2460 /// Build and insert \p Dst = G_ROTL \p Src, \p Amt
2462 const SrcOp &Amt) {
2463 return buildInstr(TargetOpcode::G_ROTL, {Dst}, {Src, Amt});
2464 }
2465
2466 /// Build and insert \p Dst = G_BITREVERSE \p Src
2468 return buildInstr(TargetOpcode::G_BITREVERSE, {Dst}, {Src});
2469 }
2470
2471 /// Build and insert \p Dst = G_GET_FPENV
2473 return buildInstr(TargetOpcode::G_GET_FPENV, {Dst}, {});
2474 }
2475
2476 /// Build and insert G_SET_FPENV \p Src
2478 return buildInstr(TargetOpcode::G_SET_FPENV, {}, {Src});
2479 }
2480
2481 /// Build and insert G_RESET_FPENV
2483 return buildInstr(TargetOpcode::G_RESET_FPENV, {}, {});
2484 }
2485
2486 /// Build and insert \p Dst = G_GET_FPMODE
2488 return buildInstr(TargetOpcode::G_GET_FPMODE, {Dst}, {});
2489 }
2490
2491 /// Build and insert G_SET_FPMODE \p Src
2493 return buildInstr(TargetOpcode::G_SET_FPMODE, {}, {Src});
2494 }
2495
2496 /// Build and insert G_RESET_FPMODE
2498 return buildInstr(TargetOpcode::G_RESET_FPMODE, {}, {});
2499 }
2500
2501 /// Build and insert \p Dst = G_GET_ROUNDING
2503 return buildInstr(TargetOpcode::G_GET_ROUNDING, {Dst}, {});
2504 }
2505
2506 /// Build and insert G_SET_ROUNDING
2508 return buildInstr(TargetOpcode::G_SET_ROUNDING, {}, {Src});
2509 }
2510
2511 virtual MachineInstrBuilder
2512 buildInstr(unsigned Opc, ArrayRef<DstOp> DstOps, ArrayRef<SrcOp> SrcOps,
2513 std::optional<unsigned> Flags = std::nullopt);
2514};
2515
2516} // End namespace llvm.
2517#endif // LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
#define LLVM_ABI
Definition Compiler.h:215
This contains common code to allow clients to notify changes to machine instr.
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register Reg
#define T
uint64_t IntrinsicInst * II
#define P(N)
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
The address of a basic block.
Definition Constants.h:1088
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
ConstantFP - Floating Point Values [float, double].
Definition Constants.h:420
This is the shared class of boolean and integer constants.
Definition Constants.h:87
A signed pointer, in the ptrauth sense.
Definition Constants.h:1223
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
A debug info location.
Definition DebugLoc.h:126
DstOp(const LLT T)
DstOp(unsigned R)
DstOp(Register R)
void addDefToMIB(MachineRegisterInfo &MRI, MachineInstrBuilder &MIB) const
LLT getLLTTy(const MachineRegisterInfo &MRI) const
MachineRegisterInfo::VRegAttrs Attrs
DstOp(MachineRegisterInfo::VRegAttrs Attrs)
DstOp(const MachineOperand &Op)
MachineRegisterInfo::VRegAttrs getVRegAttrs() const
DstType getDstOpKind() const
const TargetRegisterClass * RC
const TargetRegisterClass * getRegClass() const
DstOp(const TargetRegisterClass *TRC)
DstOp(RegClassOrRegBank RCOrRB, LLT Ty)
Register getReg() const
The CSE Analysis object.
Definition CSEInfo.h:72
Abstract class that contains various methods for clients to notify about changes.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
MCRegisterClass - Base class of TargetRegisterClass.
Metadata node.
Definition Metadata.h:1069
MachineInstrBundleIterator< MachineInstr > iterator
MachineInstrBuilder buildFPTOUI_SAT(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_FPTOUI_SAT Src0.
MachineInstrBuilder buildFSub(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FSUB Op0, Op1.
MachineInstrBuilder buildFPTOSI(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_FPTOSI Src0.
GISelChangeObserver * getObserver()
MachineInstrBuilder buildFMul(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
MachineInstrBuilder buildFLdexp(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Dst = G_FLDEXP Src0, Src1.
MachineInstrBuilder buildFreeze(const DstOp &Dst, const SrcOp &Src)
Build and insert Dst = G_FREEZE Src.
MachineInstrBuilder buildTruncUSatU(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_TRUNC_USAT_U Op.
MachineInstrBuilder buildModf(const DstOp &Fract, const DstOp &Int, const SrcOp &Src, std::optional< unsigned > Flags=std::nullopt)
Build and insert Fract, Int = G_FMODF Src.
void setInsertPt(MachineBasicBlock &MBB, MachineBasicBlock::iterator II)
Set the insertion point before the specified position.
const MachineFunction & getMF() const
LLVMContext & getContext() const
MachineInstrBuilder buildAdd(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_ADD Op0, Op1.
MachineInstrBuilder buildResetFPMode()
Build and insert G_RESET_FPMODE.
MachineInstrBuilder buildFPExt(const DstOp &Res, const SrcOp &Op, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FPEXT Op.
MachineInstrBuilder buildNot(const DstOp &Dst, const SrcOp &Src0)
Build and insert a bitwise not, NegOne = G_CONSTANT -1 Res = G_OR Op0, NegOne.
MachineInstrBuilder buildFPTOSI_SAT(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_FPTOSI_SAT Src0.
MachineInstrBuilder buildVecReduceSeqFAdd(const DstOp &Dst, const SrcOp &ScalarIn, const SrcOp &VecIn)
Build and insert Res = G_VECREDUCE_SEQ_FADD ScalarIn, VecIn.
MachineInstrBuilder buildAtomicRMWUSubSat(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_USUB_SAT Addr, Val, MMO.
MachineInstrBuilder buildRotateRight(const DstOp &Dst, const SrcOp &Src, const SrcOp &Amt)
Build and insert Dst = G_ROTR Src, Amt.
MachineInstrBuilder buildCTTZ(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_CTTZ Op0, Src0.
virtual ~MachineIRBuilder()=default
MachineInstrBuilder buildVecReduceOr(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_OR Src.
MachineInstrBuilder buildFLog2(const DstOp &Dst, const SrcOp &Src, std::optional< unsigned > Flags=std::nullopt)
Build and insert Dst = G_FLOG2 Src.
MachineInstrBuilder buildAShr(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
MachineInstrBuilder buildGetRounding(const DstOp &Dst)
Build and insert Dst = G_GET_ROUNDING.
MachineInstrBuilder buildFAbs(const DstOp &Dst, const SrcOp &Src0, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FABS Op0.
MachineInstrBuilder buildFence(unsigned Ordering, unsigned Scope)
Build and insert G_FENCE Ordering, Scope.
MachineInstrBuilder buildFMinNumIEEE(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
MachineInstrBuilder buildFMA(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, const SrcOp &Src2, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FMA Op0, Op1, Op2.
MachineInstrBuilder buildGetFPMode(const DstOp &Dst)
Build and insert Dst = G_GET_FPMODE.
MachineInstrBuilder buildSMulH(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
GISelCSEInfo * getCSEInfo()
MachineInstrBuilder buildVecReduceFMax(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_FMAX Src.
MachineInstrBuilder buildMul(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_MUL Op0, Op1.
MachineInstrBuilder buildAnd(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_AND Op0, Op1.
const TargetInstrInfo & getTII()
MachineInstrBuilder buildSAdde(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1, const SrcOp &CarryIn)
Build and insert Res, CarryOut = G_SADDE Op0, Op1, CarryInp.
MachineInstrBuilder buildTruncSSatU(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_TRUNC_SSAT_U Op.
MachineInstrBuilder buildURem(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_UREM Op0, Op1.
MachineInstrBuilder buildSAddo(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
Build and insert Res, CarryOut = G_SADDO Op0, Op1.
MachineInstrBuilder buildFPTOUI(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_FPTOUI Src0.
MachineInstrBuilder buildLShr(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
MachineInstrBuilder buildFPow(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Dst = G_FPOW Src0, Src1.
MachineInstrBuilder buildIntrinsicTrunc(const DstOp &Dst, const SrcOp &Src0, std::optional< unsigned > Flags=std::nullopt)
Build and insert Dst = G_INTRINSIC_TRUNC Src0.
MachineBasicBlock::iterator getInsertPt()
Current insertion point for new instructions.
MachineInstrBuilder buildVecReduceSeqFMul(const DstOp &Dst, const SrcOp &ScalarIn, const SrcOp &VecIn)
Build and insert Res = G_VECREDUCE_SEQ_FMUL ScalarIn, VecIn.
MachineInstrBuilder buildAtomicRMWUSubCond(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_USUB_COND Addr, Val, MMO.
MachineInstrBuilder buildSub(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_SUB Op0, Op1.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
MDNode * getPCSections()
Get the current instruction's PC sections metadata.
MachineInstrBuilder buildBSwap(const DstOp &Dst, const SrcOp &Src0)
Build and insert Dst = G_BSWAP Src0.
MachineInstrBuilder buildVecReduceFMul(const DstOp &Dst, const SrcOp &ScalarIn, const SrcOp &VecIn)
Build and insert Res = G_VECREDUCE_FMUL Src.
MachineInstrBuilder buildCTLZ_ZERO_POISON(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_CTLZ_ZERO_POISON Op0, Src0.
MachineInstrBuilder buildAddrSpaceCast(const DstOp &Dst, const SrcOp &Src)
Build and insert Dst = G_ADDRSPACE_CAST Src.
MachineInstrBuilder buildFExp2(const DstOp &Dst, const SrcOp &Src, std::optional< unsigned > Flags=std::nullopt)
Build and insert Dst = G_FEXP2 Src.
MachineInstrBuilder buildSetFPMode(const SrcOp &Src)
Build and insert G_SET_FPMODE Src.
MachineInstrBuilder buildIntToPtr(const DstOp &Dst, const SrcOp &Src)
Build and insert a G_INTTOPTR instruction.
MachineInstrBuilder buildUSubo(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
Build and insert Res, CarryOut = G_USUBO Op0, Op1.
MachineInstrBuilder buildVecReduceFAdd(const DstOp &Dst, const SrcOp &ScalarIn, const SrcOp &VecIn)
Build and insert Res = G_VECREDUCE_FADD Src.
MachineIRBuilder(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt)
MachineInstrBuilder buildAbdu(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_ABDU Op0, Op1.
MachineInstrBuilder buildVecReduceFMinimum(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_FMINIMUM Src.
MachineInstrBuilder buildNeg(const DstOp &Dst, const SrcOp &Src0)
Build and insert integer negation Zero = G_CONSTANT 0 Res = G_SUB Zero, Op0.
MachineInstrBuilder buildVecReduceSMin(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_SMIN Src.
MachineInstrBuilder buildCTLZ(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_CTLZ Op0, Src0.
MachineInstrBuilder buildSMax(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_SMAX Op0, Op1.
MachineInstrBuilder buildAssertZExt(const DstOp &Res, const SrcOp &Op, unsigned Size)
Build and insert Res = G_ASSERT_ZEXT Op, Size.
void recordInsertion(MachineInstr *InsertedInstr) const
MachineInstrBuilder buildUMulH(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
MachineInstrBuilder buildStrictFAdd(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_STRICT_FADD Op0, Op1.
MachineInstrBuilder buildVecReduceXor(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_XOR Src.
MachineInstrBuilder buildVecReduceFMin(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_FMIN Src.
MachineInstrBuilder buildFDiv(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FDIV Op0, Op1.
const GISelCSEInfo * getCSEInfo() const
MachineInstrBuilder buildSetRounding(const SrcOp &Src)
Build and insert G_SET_ROUNDING.
MachineInstrBuilder buildExtractVectorElement(const DstOp &Res, const SrcOp &Val, const SrcOp &Idx)
Build and insert Res = G_EXTRACT_VECTOR_ELT Val, Idx.
MachineInstrBuilder buildLoad(const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert Res = G_LOAD Addr, MMO.
MachineBasicBlock & getMBB()
MachineIRBuilder(MachineInstr &MI)
MachineInstrBuilder buildExtractVectorElementConstant(const DstOp &Res, const SrcOp &Val, const int Idx)
Build and insert Res = G_EXTRACT_VECTOR_ELT Val, Idx.
MachineInstrBuilder buildBitReverse(const DstOp &Dst, const SrcOp &Src)
Build and insert Dst = G_BITREVERSE Src.
MachineInstrBuilder buildShl(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
MachineInstrBuilder buildUITOFP(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_UITOFP Src0.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
MachineInstrBuilder buildSITOFP(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_SITOFP Src0.
MachineIRBuilder(MachineInstr &MI, GISelChangeObserver &Observer)
MachineInstrBuilder buildFMAD(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, const SrcOp &Src2, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FMAD Op0, Op1, Op2.
MachineInstrBuilder buildAbds(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_ABDS Op0, Op1.
MachineInstrBuilder buildFLog(const DstOp &Dst, const SrcOp &Src, std::optional< unsigned > Flags=std::nullopt)
Build and insert Dst = G_FLOG Src.
void validateSelectOp(const LLT ResTy, const LLT TstTy, const LLT Op0Ty, const LLT Op1Ty)
MachineInstrBuilder buildVecReduceUMax(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_UMAX Src.
const DebugLoc & getDL()
Getter for DebugLoc.
MachineInstrBuilder buildUbfx(const DstOp &Dst, const SrcOp &Src, const SrcOp &LSB, const SrcOp &Width)
Build and insert Dst = G_UBFX Src, LSB, Width.
const MachineRegisterInfo * getMRI() const
MachineInstrBuilder buildCTLS(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_CTLS Op0, Src0.
MachineInstrBuilder buildCTPOP(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_CTPOP Op0, Src0.
MachineInstrBuilder buildAbs(const DstOp &Dst, const SrcOp &Src)
Build and insert Dst = G_ABS Src.
void validateBinaryOp(const LLT Res, const LLT Op0, const LLT Op1)
MachineInstrBuilder buildVecReduceAnd(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_AND Src.
MachineInstrBuilder buildVecReduceFMaximum(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_FMAXIMUM Src.
void validateShiftOp(const LLT Res, const LLT Op0, const LLT Op1)
MachineFunction & getMF()
Getter for the function we currently build.
MachineInstrBuilder buildFCopysign(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FCOPYSIGN Op0, Op1.
MachineIRBuilder(MachineFunction &MF)
MachineIRBuilder(const MachineIRBuilderState &BState)
MachineInstrBuilder buildTruncSSatS(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_TRUNC_SSAT_S Op.
MachineInstrBuilder buildMemCpy(const SrcOp &DstPtr, const SrcOp &SrcPtr, const SrcOp &Size, MachineMemOperand &DstMMO, MachineMemOperand &SrcMMO)
MachineInstrBuilder buildAssertAlign(const DstOp &Res, const SrcOp &Op, Align AlignVal)
Build and insert Res = G_ASSERT_ALIGN Op, AlignVal.
MachineInstrBuilder buildFRint(const DstOp &Dst, const SrcOp &Src0, std::optional< unsigned > Flags=std::nullopt)
Build and insert Dst = G_FRINT Src0.
MachineInstrBuilder buildSbfx(const DstOp &Dst, const SrcOp &Src, const SrcOp &LSB, const SrcOp &Width)
Build and insert Dst = G_SBFX Src, LSB, Width.
MachineInstrBuilder buildFMaxNum(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
MachineInstrBuilder buildSMin(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_SMIN Op0, Op1.
MachineInstrBuilder buildFMinNum(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
MachineInstrBuilder buildVecReduceUMin(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_UMIN Src.
void setInstrAndDebugLoc(MachineInstr &MI)
Set the insertion point to before MI, and set the debug loc to MI's loc.
void setMMRAMetadata(MDNode *MMRA)
Set the PC sections metadata to MD for all the next build instructions.
MachineInstrBuilder buildSSube(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1, const SrcOp &CarryIn)
Build and insert Res, CarryOut = G_SSUBE Op0, Op1, CarryInp.
void setDeactivationSymbol(Value *DS)
MachineInstrBuilder buildIntrinsicRoundeven(const DstOp &Dst, const SrcOp &Src0, std::optional< unsigned > Flags=std::nullopt)
Build and insert Dst = G_INTRINSIC_ROUNDEVEN Src0, Src1.
MachineInstrBuilder buildResetFPEnv()
Build and insert G_RESET_FPENV.
void setPCSections(MDNode *MD)
Set the PC sections metadata to MD for all the next build instructions.
MachineInstrBuilder buildVecReduceAdd(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_ADD Src.
MachineInstrBuilder buildIsFPClass(const DstOp &Res, const SrcOp &Src, unsigned Mask)
Build and insert a Res = G_IS_FPCLASS Src, Mask.
MachineInstrBuilder buildUAdde(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1, const SrcOp &CarryIn)
Build and insert Res, CarryOut = G_UADDE Op0, Op1, CarryIn.
void setDebugLoc(const DebugLoc &DL)
Set the debug location to DL for all the next build instructions.
MachineInstrBuilder buildGetFPEnv(const DstOp &Dst)
Build and insert Dst = G_GET_FPENV.
MachineInstrBuilder buildSSubo(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
Build and insert Res, CarryOut = G_SUBO Op0, Op1.
MachineInstrBuilder buildUSube(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1, const SrcOp &CarryIn)
Build and insert Res, CarryOut = G_USUBE Op0, Op1, CarryInp.
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
MachineInstrBuilder buildFNeg(const DstOp &Dst, const SrcOp &Src0, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FNEG Op0.
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
MachineInstrBuilder buildBitcast(const DstOp &Dst, const SrcOp &Src)
Build and insert Dst = G_BITCAST Src.
const DebugLoc & getDebugLoc()
Get the current instruction's debug location.
MachineInstrBuilder buildUAddo(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
Build and insert Res, CarryOut = G_UADDO Op0, Op1.
void setCSEInfo(GISelCSEInfo *Info)
MachineInstrBuilder buildFMaxNumIEEE(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
MachineInstrBuilder buildTrap(bool Debug=false)
Build and insert G_TRAP or G_DEBUGTRAP.
MachineInstrBuilder buildFFloor(const DstOp &Dst, const SrcOp &Src0, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = GFFLOOR Op0, Op1.
MachineInstrBuilder buildFFrexp(const DstOp &Fract, const DstOp &Exp, const SrcOp &Src, std::optional< unsigned > Flags=std::nullopt)
Build and insert Fract, Exp = G_FFREXP Src.
MachineIRBuilder()=default
Some constructors for easy use.
MachineRegisterInfo * getMRI()
Getter for MRI.
MachineInstrBuilder buildOr(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_OR Op0, Op1.
MachineInstrBuilder buildFSincos(const DstOp &Sin, const DstOp &Cos, const SrcOp &Src, std::optional< unsigned > Flags=std::nullopt)
Build and insert Sin, Cos = G_FSINCOS Src.
MachineIRBuilderState & getState()
Getter for the State.
MachineInstrBuilder buildAssertInstr(unsigned Opc, const DstOp &Res, const SrcOp &Op, unsigned Val)
Build and insert G_ASSERT_SEXT, G_ASSERT_ZEXT, or G_ASSERT_ALIGN.
void validateTruncExt(const LLT Dst, const LLT Src, bool IsExtend)
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
MachineInstrBuilder buildPtrMask(const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
Build and insert Res = G_PTRMASK Op0, Op1.
MachineInstrBuilder buildVecReduceSMax(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_SMAX Src.
MachineInstrBuilder buildMemTransferInst(unsigned Opcode, const SrcOp &DstPtr, const SrcOp &SrcPtr, const SrcOp &Size, MachineMemOperand &DstMMO, MachineMemOperand &SrcMMO)
Build and insert G_MEMCPY or G_MEMMOVE.
void validateUnaryOp(const LLT Res, const LLT Op0)
MDNode * getMMRAMetadata()
Get the current instruction's MMRA metadata.
MachineInstrBuilder buildPrefetch(const SrcOp &Addr, unsigned RW, unsigned Locality, unsigned CacheType, MachineMemOperand &MMO)
Build and insert G_PREFETCH Addr, RW, Locality, CacheType.
const DataLayout & getDataLayout() const
MachineInstrBuilder buildLoadInstr(unsigned Opcode, const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert Res = <opcode> Addr, MMO.
MachineInstrBuilder buildCTTZ_ZERO_POISON(const DstOp &Dst, const SrcOp &Src0)
Build and insert Res = G_CTTZ_ZERO_POISON Op0, Src0.
void setMF(MachineFunction &MF)
MachineInstrBuilder buildAssertSExt(const DstOp &Res, const SrcOp &Op, unsigned Size)
Build and insert Res = G_ASSERT_SEXT Op, Size.
MachineInstrBuilder buildXor(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_XOR Op0, Op1.
void setState(const MachineIRBuilderState &NewState)
Setter for the State.
void setChangeObserver(GISelChangeObserver &Observer)
virtual MachineInstrBuilder buildConstant(const DstOp &Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
MachineInstrBuilder buildVecReduceMul(const DstOp &Dst, const SrcOp &Src)
Build and insert Res = G_VECREDUCE_MUL Src.
MachineInstrBuilder buildUMin(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_UMIN Op0, Op1.
MachineInstrBuilder buildUMax(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_UMAX Op0, Op1.
MachineInstrBuilder buildFAdd(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FADD Op0, Op1.
MachineInstrBuilder buildSetFPEnv(const SrcOp &Src)
Build and insert G_SET_FPENV Src.
MachineInstrBuilder buildPtrToInt(const DstOp &Dst, const SrcOp &Src)
Build and insert a G_PTRTOINT instruction.
MachineInstrBuilder buildFCanonicalize(const DstOp &Dst, const SrcOp &Src0, std::optional< unsigned > Flags=std::nullopt)
Build and insert Dst = G_FCANONICALIZE Src0.
MachineInstrBuilder buildSExtInReg(const DstOp &Res, const SrcOp &Op, int64_t ImmOp)
Build and insert Res = G_SEXT_INREG Op, ImmOp.
MachineInstrBuilder buildRotateLeft(const DstOp &Dst, const SrcOp &Src, const SrcOp &Amt)
Build and insert Dst = G_ROTL Src, Amt.
const MachineInstrBuilder & addUse(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addPredicate(CmpInst::Predicate Pred) const
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
LLT getType(Register Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register.
LLVM_ABI Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
SrcOp(const MachineInstrBuilder &MIB)
SrcOp(int64_t V)
SrcOp(const CmpInst::Predicate P)
SrcOp(uint64_t V)
SrcOp(int)=delete
MachineInstrBuilder SrcMIB
CmpInst::Predicate getPredicate() const
SrcType getSrcOpKind() const
CmpInst::Predicate Pred
int64_t getImm() const
LLT getLLTTy(const MachineRegisterInfo &MRI) const
SrcOp(const MachineOperand &Op)
void addSrcToMIB(MachineInstrBuilder &MIB) const
SrcOp(unsigned)=delete
Use of registers held in unsigned integer variables (or more rarely signed integers) is no longer per...
Register getReg() const
SrcOp(Register R)
TargetInstrInfo - Interface to description of machine instruction set.
LLT getVectorIdxLLT(const DataLayout &DL) const
Returns the type to be used for the index operand of: G_INSERT_VECTOR_ELT, G_EXTRACT_VECTOR_ELT,...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
LLVM Value Representation.
Definition Value.h:75
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:573
PointerUnion< const TargetRegisterClass *, const RegisterBank * > RegClassOrRegBank
Convenient type to represent either a register class or a register bank.
@ Debug
Register 'use' is for debugging purpose.
DWARFExpression::Operation Op
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition Metadata.h:763
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
Definition Alignment.h:77
Class which stores all the state required in a MachineIRBuilder.
MachineFunction * MF
MachineFunction under construction.
MDNode * MMRA
MMRA Metadata to be set on any instruction we create.
DebugLoc DL
Debug location to be set to any instruction we create.
const TargetInstrInfo * TII
Information used to access the description of the opcodes.
MDNode * PCSections
PC sections metadata to be set to any instruction we create.
MachineBasicBlock::iterator II
MachineRegisterInfo * MRI
Information used to verify types are consistent and to create virtual registers.
GISelChangeObserver * Observer
This class contains a discriminated union of information about pointers in memory operands,...
All attributes(register class or bank and low-level type) a virtual register can have.