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