40 "Basic block is in a different function");
54 "Basic block is in a different function");
92 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
93 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
95 cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(
getDL()) &&
96 "Expected inlined-at fields to agree");
98 getTII().
get(TargetOpcode::DBG_VALUE),
99 false, Reg, Variable, Expr));
105 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
106 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
108 cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(
getDL()) &&
109 "Expected inlined-at fields to agree");
111 getTII().
get(TargetOpcode::DBG_VALUE),
112 true, Reg, Variable, Expr));
118 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
119 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
121 cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(
getDL()) &&
122 "Expected inlined-at fields to agree");
133 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
134 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
136 cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(
getDL()) &&
137 "Expected inlined-at fields to agree");
138 auto MIB =
buildInstr(TargetOpcode::DBG_VALUE);
139 if (
auto *CI = dyn_cast<ConstantInt>(&C)) {
140 if (CI->getBitWidth() > 64)
143 MIB.addImm(CI->getZExtValue());
144 }
else if (
auto *CFP = dyn_cast<ConstantFP>(&C)) {
151 return MIB.addImm(0).addMetadata(Variable).addMetadata(Expr);
155 assert(isa<DILabel>(Label) &&
"not a label");
156 assert(cast<DILabel>(Label)->isValidLocationForIntrinsic(State.
DL) &&
157 "Expected inlined-at fields to agree");
158 auto MIB =
buildInstr(TargetOpcode::DBG_LABEL);
160 return MIB.addMetadata(Label);
167 auto MIB =
buildInstr(TargetOpcode::G_DYN_STACKALLOC);
177 auto MIB =
buildInstr(TargetOpcode::G_FRAME_INDEX);
179 MIB.addFrameIndex(Idx);
188 "address space mismatch");
190 auto MIB =
buildInstr(TargetOpcode::G_GLOBAL_VALUE);
192 MIB.addGlobalAddress(GV);
198 return buildInstr(TargetOpcode::G_JUMP_TABLE, {PtrTy}, {})
199 .addJumpTableIndex(JTI);
205 assert((Res == Op0 && Res == Op1) &&
"type mismatch");
211 assert((Res == Op0) &&
"type mismatch");
221 return buildInstr(TargetOpcode::G_PTR_ADD, {Res}, {Op0, Op1});
226 const LLT &ValueTy, uint64_t
Value) {
227 assert(Res == 0 &&
"Res is a result argument");
246 auto MIB =
buildInstr(TargetOpcode::G_PTR_MASK);
266 "Table reg must be a pointer");
275 return buildInstr(TargetOpcode::COPY, Res, Op);
283 "creating constant with the wrong size");
286 auto Const =
buildInstr(TargetOpcode::G_CONSTANT)
292 auto Const =
buildInstr(TargetOpcode::G_CONSTANT);
313 "creating fconstant with the wrong size");
318 auto Const =
buildInstr(TargetOpcode::G_FCONSTANT)
325 auto Const =
buildInstr(TargetOpcode::G_FCONSTANT);
327 Const.addFPImm(&Val);
376 MIB.addMemOperand(&MMO);
389 MIB.addMemOperand(&MMO);
394 const DstOp &CarryOut,
397 return buildInstr(TargetOpcode::G_UADDO, {Res, CarryOut}, {Op0, Op1});
401 const DstOp &CarryOut,
404 const SrcOp &CarryIn) {
405 return buildInstr(TargetOpcode::G_UADDE, {Res, CarryOut},
406 {Op0, Op1, CarryIn});
411 return buildInstr(TargetOpcode::G_ANYEXT, Res, Op);
416 return buildInstr(TargetOpcode::G_SEXT, Res, Op);
421 return buildInstr(TargetOpcode::G_ZEXT, Res, Op);
426 switch (TLI->getBooleanContents(IsVec, IsFP)) {
428 return TargetOpcode::G_SEXT;
430 return TargetOpcode::G_ZEXT;
432 return TargetOpcode::G_ANYEXT;
446 assert((TargetOpcode::G_ANYEXT == ExtOpc || TargetOpcode::G_ZEXT == ExtOpc ||
447 TargetOpcode::G_SEXT == ExtOpc) &&
448 "Expecting Extending Opc");
454 unsigned Opcode = TargetOpcode::COPY;
460 Opcode = TargetOpcode::G_TRUNC;
491 Opcode = TargetOpcode::G_PTRTOINT;
493 Opcode = TargetOpcode::G_INTTOPTR;
496 Opcode = TargetOpcode::G_BITCAST;
512 "extracting off end of register");
516 assert(Index == 0 &&
"insertion past the end of a register");
520 auto Extract =
buildInstr(TargetOpcode::G_EXTRACT);
523 Extract.addImm(Index);
531 assert(!Ops.
empty() &&
"invalid trivial sequence");
533 "sequence offsets must be in ascending order");
543 bool MaybeMerge =
true;
544 for (
unsigned i = 0; i < Ops.size(); ++i) {
545 if (
getMRI()->
getType(Ops[i]) != OpTy || Indices[i] != i * OpSize) {
551 if (MaybeMerge && Ops.size() * OpSize == ResTy.
getSizeInBits()) {
559 for (
unsigned i = 0; i < Ops.size(); ++i) {
560 Register ResOut = i + 1 == Ops.size()
569 return buildInstr(TargetOpcode::G_IMPLICIT_DEF, {Res}, {});
578 assert(TmpVec.size() > 1);
579 return buildInstr(TargetOpcode::G_MERGE_VALUES, Res, TmpVec);
588 assert(TmpVec.size() > 1);
589 return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec, Op);
596 for (
unsigned I = 0;
I != NumReg; ++
I)
607 assert(TmpVec.size() > 1);
608 return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec, Op);
617 return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
623 return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
633 return buildInstr(TargetOpcode::G_BUILD_VECTOR_TRUNC, Res, TmpVec);
642 return buildInstr(TargetOpcode::G_CONCAT_VECTORS, Res, TmpVec);
649 "insertion past the end of a register");
665 bool HasSideEffects) {
667 buildInstr(HasSideEffects ? TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS
668 : TargetOpcode::G_INTRINSIC);
669 for (
unsigned ResultReg : ResultRegs)
670 MIB.addDef(ResultReg);
671 MIB.addIntrinsicID(ID);
677 bool HasSideEffects) {
679 buildInstr(HasSideEffects ? TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS
680 : TargetOpcode::G_INTRINSIC);
681 for (
DstOp Result : Results)
682 Result.addDefToMIB(*
getMRI(), MIB);
683 MIB.addIntrinsicID(ID);
689 return buildInstr(TargetOpcode::G_TRUNC, Res, Op);
695 return buildInstr(TargetOpcode::G_FPTRUNC, Res, Op, Flags);
702 return buildInstr(TargetOpcode::G_ICMP, Res, {Pred, Op0, Op1});
711 return buildInstr(TargetOpcode::G_FCMP, Res, {Pred, Op0, Op1}, Flags);
720 return buildInstr(TargetOpcode::G_SELECT, {Res}, {Tst, Op0, Op1}, Flags);
726 return buildInstr(TargetOpcode::G_INSERT_VECTOR_ELT, Res, {Val, Elt, Idx});
732 return buildInstr(TargetOpcode::G_EXTRACT_VECTOR_ELT, Res, {Val, Idx});
749 assert(OldValResTy == CmpValTy &&
"type mismatch");
750 assert(OldValResTy == NewValTy &&
"type mismatch");
753 return buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG_WITH_SUCCESS)
775 assert(OldValResTy == CmpValTy &&
"type mismatch");
776 assert(OldValResTy == NewValTy &&
"type mismatch");
779 return buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG)
788 unsigned Opcode,
const DstOp &OldValRes,
799 assert(OldValResTy == ValTy &&
"type mismatch");
807 MIB.addMemOperand(&MMO);
814 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_XCHG, OldValRes, Addr, Val,
820 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_ADD, OldValRes, Addr, Val,
826 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_SUB, OldValRes, Addr, Val,
832 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_AND, OldValRes, Addr, Val,
838 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_NAND, OldValRes, Addr, Val,
845 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_OR, OldValRes, Addr, Val,
851 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_XOR, OldValRes, Addr, Val,
857 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_MAX, OldValRes, Addr, Val,
863 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_MIN, OldValRes, Addr, Val,
869 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_UMAX, OldValRes, Addr, Val,
875 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_UMIN, OldValRes, Addr, Val,
883 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FADD, OldValRes, Addr, Val,
890 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FSUB, OldValRes, Addr, Val,
914 assert(SrcTy.
isVector() &&
"mismatched cast between vector and non-vector");
916 "different number of elements in a trunc/ext");
922 "invalid narrowing extend");
925 "invalid widening trunc");
930 const LLT &Op0Ty,
const LLT &Op1Ty) {
933 "invalid operand type");
934 assert((ResTy == Op0Ty && ResTy == Op1Ty) &&
"type mismatch");
952 case TargetOpcode::G_SELECT: {
953 assert(DstOps.
size() == 1 &&
"Invalid select");
954 assert(SrcOps.
size() == 3 &&
"Invalid select");
956 DstOps[0].getLLTTy(*
getMRI()), SrcOps[0].getLLTTy(*
getMRI()),
957 SrcOps[1].getLLTTy(*
getMRI()), SrcOps[2].getLLTTy(*
getMRI()));
960 case TargetOpcode::G_ADD:
961 case TargetOpcode::G_AND:
962 case TargetOpcode::G_MUL:
963 case TargetOpcode::G_OR:
964 case TargetOpcode::G_SUB:
965 case TargetOpcode::G_XOR:
966 case TargetOpcode::G_UDIV:
967 case TargetOpcode::G_SDIV:
968 case TargetOpcode::G_UREM:
969 case TargetOpcode::G_SREM:
970 case TargetOpcode::G_SMIN:
971 case TargetOpcode::G_SMAX:
972 case TargetOpcode::G_UMIN:
973 case TargetOpcode::G_UMAX: {
978 SrcOps[0].getLLTTy(*
getMRI()),
979 SrcOps[1].getLLTTy(*
getMRI()));
982 case TargetOpcode::G_SHL:
983 case TargetOpcode::G_ASHR:
984 case TargetOpcode::G_LSHR: {
988 SrcOps[0].getLLTTy(*
getMRI()),
989 SrcOps[1].getLLTTy(*
getMRI()));
992 case TargetOpcode::G_SEXT:
993 case TargetOpcode::G_ZEXT:
994 case TargetOpcode::G_ANYEXT:
998 SrcOps[0].getLLTTy(*
getMRI()),
true);
1000 case TargetOpcode::G_TRUNC:
1001 case TargetOpcode::G_FPTRUNC: {
1003 assert(SrcOps.
size() == 1 &&
"Invalid Srcs");
1005 SrcOps[0].getLLTTy(*
getMRI()),
false);
1008 case TargetOpcode::COPY:
1013 case TargetOpcode::G_FCMP:
1014 case TargetOpcode::G_ICMP: {
1015 assert(DstOps.
size() == 1 &&
"Invalid Dst Operands");
1016 assert(SrcOps.
size() == 3 &&
"Invalid Src Operands");
1020 "Expecting predicate");
1025 }() &&
"Invalid predicate");
1029 LLT Op0Ty = SrcOps[1].getLLTTy(*
getMRI());
1030 LLT DstTy = DstOps[0].getLLTTy(*
getMRI());
1036 }() &&
"Type Mismatch");
1039 case TargetOpcode::G_UNMERGE_VALUES: {
1040 assert(!DstOps.
empty() &&
"Invalid trivial sequence");
1041 assert(SrcOps.
size() == 1 &&
"Invalid src for Unmerge");
1045 DstOps[0].getLLTTy(*
getMRI());
1047 "type mismatch in output list");
1049 SrcOps[0].getLLTTy(*
getMRI()).getSizeInBits() &&
1050 "input operands do not cover output register");
1053 case TargetOpcode::G_MERGE_VALUES: {
1054 assert(!SrcOps.
empty() &&
"invalid trivial sequence");
1059 SrcOps[0].getLLTTy(*
getMRI());
1061 "type mismatch in input list");
1063 DstOps[0].getLLTTy(*
getMRI()).getSizeInBits() &&
1064 "input operands do not cover output register");
1065 if (SrcOps.
size() == 1)
1067 if (DstOps[0].getLLTTy(*
getMRI()).isVector()) {
1068 if (SrcOps[0].getLLTTy(*
getMRI()).isVector())
1069 return buildInstr(TargetOpcode::G_CONCAT_VECTORS, DstOps, SrcOps);
1070 return buildInstr(TargetOpcode::G_BUILD_VECTOR, DstOps, SrcOps);
1074 case TargetOpcode::G_EXTRACT_VECTOR_ELT: {
1075 assert(DstOps.
size() == 1 &&
"Invalid Dst size");
1076 assert(SrcOps.
size() == 2 &&
"Invalid Src size");
1080 "Invalid operand type");
1082 assert(SrcOps[0].getLLTTy(*
getMRI()).getElementType() ==
1083 DstOps[0].getLLTTy(*
getMRI()) &&
1087 case TargetOpcode::G_INSERT_VECTOR_ELT: {
1088 assert(DstOps.
size() == 1 &&
"Invalid dst size");
1089 assert(SrcOps.
size() == 3 &&
"Invalid src size");
1091 SrcOps[0].getLLTTy(*
getMRI()).
isVector() &&
"Invalid operand type");
1092 assert(DstOps[0].getLLTTy(*
getMRI()).getElementType() ==
1093 SrcOps[1].getLLTTy(*
getMRI()) &&
1096 assert(DstOps[0].getLLTTy(*
getMRI()).getNumElements() ==
1097 SrcOps[0].getLLTTy(*
getMRI()).getNumElements() &&
1101 case TargetOpcode::G_BUILD_VECTOR: {
1103 "Must have at least 2 operands");
1104 assert(DstOps.
size() == 1 &&
"Invalid DstOps");
1106 "Res type must be a vector");
1110 SrcOps[0].getLLTTy(*
getMRI());
1112 "type mismatch in input list");
1114 DstOps[0].getLLTTy(*
getMRI()).getSizeInBits() &&
1115 "input scalars do not exactly cover the output vector register");
1118 case TargetOpcode::G_BUILD_VECTOR_TRUNC: {
1120 "Must have at least 2 operands");
1121 assert(DstOps.
size() == 1 &&
"Invalid DstOps");
1123 "Res type must be a vector");
1127 SrcOps[0].getLLTTy(*
getMRI());
1129 "type mismatch in input list");
1132 return buildInstr(TargetOpcode::G_BUILD_VECTOR, DstOps, SrcOps);
1135 case TargetOpcode::G_CONCAT_VECTORS: {
1136 assert(DstOps.
size() == 1 &&
"Invalid DstOps");
1138 "Must have at least 2 operands");
1141 return (
Op.getLLTTy(*
getMRI()).isVector() &&
1143 SrcOps[0].getLLTTy(*
getMRI()));
1145 "type mismatch in input list");
1147 DstOps[0].getLLTTy(*
getMRI()).getSizeInBits() &&
1148 "input vectors do not exactly cover the output vector register");
1151 case TargetOpcode::G_UADDE: {
1152 assert(DstOps.
size() == 2 &&
"Invalid no of dst operands");
1153 assert(SrcOps.
size() == 3 &&
"Invalid no of src operands");
1156 (DstOps[0].getLLTTy(*
getMRI()) == SrcOps[1].getLLTTy(*
getMRI())) &&
1166 for (
const DstOp &
Op : DstOps)
1168 for (
const SrcOp &
Op : SrcOps)
1169 Op.addSrcToMIB(MIB);
1171 MIB->setFlags(*Flags);
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface ...
MachineInstrBuilder buildDirectDbgValue(Register Reg, const MDNode *Variable, const MDNode *Expr)
Build and insert a DBG_VALUE instruction expressing the fact that the associated Variable lives in Re...
bool isFPPredicate() const
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
virtual MachineInstrBuilder buildConstant(const DstOp &Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
MachineInstrBuilder buildAtomicRMWFAdd(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_FADD Addr, Val, MMO.
MachineInstrBuilder buildJumpTable(const LLT PtrTy, unsigned JTI)
Build and insert Res = G_JUMP_TABLE JTI.
void addDefToMIB(MachineRegisterInfo &MRI, MachineInstrBuilder &MIB) const
MachineInstrBuilder buildZExtOrTrunc(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_ZEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes...
MachineInstrBuilder buildBlockAddress(Register Res, const BlockAddress *BA)
Build and insert Res = G_BLOCK_ADDR BA.
MachineInstrBuilder buildUnmerge(ArrayRef< LLT > Res, const SrcOp &Op)
Build and insert Res0, ...
MachineInstrBuilder buildBrCond(Register Tst, MachineBasicBlock &Dest)
Build and insert G_BRCOND Tst, Dest.
This class represents lattice values for constants.
MachineInstrBuilder buildInsert(Register Res, Register Src, Register Op, unsigned Index)
MachineInstrBuilder buildSExtOrTrunc(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_SEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes...
Optional< MachineInstrBuilder > materializePtrAdd(Register &Res, Register Op0, const LLT &ValueTy, uint64_t Value)
Materialize and insert Res = G_PTR_ADD Op0, (G_CONSTANT Value)
unsigned getScalarSizeInBits() const
unsigned getSizeInBits(Register Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
void push_back(const T &Elt)
GISelChangeObserver * Observer
MachineInstrBuilder buildCast(const DstOp &Dst, const SrcOp &Src)
Build and insert an appropriate cast between two registers of equal size.
MachineInstrBuilder buildPtrAdd(const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
Build and insert Res = G_PTR_ADD Op0, Op1.
const MachineInstrBuilder & addJumpTableIndex(unsigned Idx, unsigned TargetFlags=0) const
virtual const TargetLowering * getTargetLowering() const
LLT getScalarType() const
Function Alias Analysis Results
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
void addSrcToMIB(MachineInstrBuilder &MIB) const
static unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
void buildSequence(Register Res, ArrayRef< Register > Ops, ArrayRef< uint64_t > Indices)
Build and insert instructions to put Ops together at the specified p Indices to form a larger registe...
const fltSemantics & getSemantics() const
MachineInstrBuilder buildAtomicRMW(unsigned Opcode, const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_<Opcode> Addr, Val, MMO.
MachineInstrBuilder buildDynStackAlloc(const DstOp &Res, const SrcOp &Size, unsigned Align)
Build and insert Res = G_DYN_STACKALLOC Size, Align.
void validateSelectOp(const LLT &ResTy, const LLT &TstTy, const LLT &Op0Ty, const LLT &Op1Ty)
MachineInstrBuilder buildUAddo(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
Build and insert Res, CarryOut = G_UADDO Op0, Op1.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
LegalityPredicate isPointer(unsigned TypeIdx)
True iff the specified type index is a pointer (with any address space).
LegalityPredicate isVector(unsigned TypeIdx)
True iff the specified type index is a vector.
MachineInstrBuilder buildBrJT(Register TablePtr, unsigned JTI, Register IndexReg)
Build and insert G_BRJT TablePtr, JTI, IndexReg.
MachineInstrBuilder buildExtract(const DstOp &Res, const SrcOp &Src, uint64_t Index)
Build and insert `Res0, ...
MachineInstrBuilder buildFPTrunc(const DstOp &Res, const SrcOp &Op, Optional< unsigned > FLags=None)
Build and insert Res = G_FPTRUNC Op.
bool isAtomic() const
Returns true if this operation has an atomic ordering requirement of unordered or higher...
MachineInstrBuilder buildAtomicRMWXor(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_XOR Addr, Val, MMO.
void setMF(MachineFunction &MF)
The address of a basic block.
A description of a memory reference used in the backend.
void setInsertPt(MachineBasicBlock &MBB, MachineBasicBlock::iterator II)
Set the insertion point before the specified position.
MachineInstrBuilder buildAnyExt(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_ANYEXT Op0.
MachineInstrBuilder buildExtOrTrunc(unsigned ExtOpc, const DstOp &Res, const SrcOp &Op)
Build and insert Res = ExtOpc, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes of...
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 validateTruncExt(const LLT &Dst, const LLT &Src, bool IsExtend)
MachineInstrBuilder buildAnyExtOrTrunc(const DstOp &Res, const SrcOp &Op)
Res = COPY Op depending on the differing sizes of Res and Op.
MachineBasicBlock::iterator II
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
void recordInsertion(MachineInstr *MI) const
APFloat getAPFloatFromSize(double Val, unsigned Size)
Returns an APFloat from Val converted to the appropriate size.
MachineInstrBuilder buildLoadInstr(unsigned Opcode, const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert Res = <opcode> Addr, MMO.
MachineInstrBuilder buildFence(unsigned Ordering, unsigned Scope)
Build and insert G_FENCE Ordering, Scope.
MachineInstrBuilder buildBrIndirect(Register Tgt)
Build and insert G_BRINDIRECT Tgt.
MachineInstrBuilder buildSelect(const DstOp &Res, const SrcOp &Tst, const SrcOp &Op0, const SrcOp &Op1, Optional< unsigned > Flags=None)
Build and insert a Res = G_SELECT Tst, Op0, Op1.
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
void validateBinaryOp(const LLT &Res, const LLT &Op0, const LLT &Op1)
MachineFunction & getMF()
Getter for the function we currently build.
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
virtual const TargetInstrInfo * getInstrInfo() const
MachineInstrBuilder buildAtomicRMWUmax(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_UMAX Addr, Val, MMO.
static Function * getFunction(Constant *C)
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
MachineInstrBuilder buildAtomicRMWFSub(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_FSUB Addr, Val, MMO.
MachineInstrBuilder buildExtractVectorElement(const DstOp &Res, const SrcOp &Val, const SrcOp &Idx)
Build and insert Res = G_EXTRACT_VECTOR_ELT Val, Idx.
Analysis containing CSE Info
void setChangeObserver(GISelChangeObserver &Observer)
MachineBasicBlock::iterator getInsertPt()
Current insertion point for new instructions.
MachineInstrBuilder buildDbgLabel(const MDNode *Label)
Build and insert a DBG_LABEL instructions specifying that Label is given.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
MachineInstrBundleIterator< MachineInstr > iterator
MachineInstrBuilder buildSExt(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_SEXT Op.
void validateShiftOp(const LLT &Res, const LLT &Op0, const LLT &Op1)
MachineRegisterInfo * getMRI()
Getter for MRI.
Abstract class that contains various methods for clients to notify about changes. ...
const TargetInstrInfo * TII
Information used to access the description of the opcodes.
const MachineInstrBuilder & addCImm(const ConstantInt *Val) const
MachineInstrBuilder buildAtomicRMWMax(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_MAX Addr, Val, MMO.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
size_t size() const
size - Get the array size.
MachineInstrBuilder buildZExt(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_ZEXT Op.
This is an important base class in LLVM.
MachineInstrBuilder buildBuildVector(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_BUILD_VECTOR Op0, ...
MachineInstrBuilder buildAtomicRMWXchg(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_XCHG Addr, Val, MMO.
virtual void createdInstr(MachineInstr &MI)=0
An instruction has been created and inserted into the function.
ConstantFP - Floating Point Values [float, double].
void stopObservingChanges()
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
MachineInstrBuilder buildGlobalValue(const DstOp &Res, const GlobalValue *GV)
Build and insert Res = G_GLOBAL_VALUE GV.
MachineInstrBuilder buildFIDbgValue(int FI, const MDNode *Variable, const MDNode *Expr)
Build and insert a DBG_VALUE instruction expressing the fact that the associated Variable lives in th...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
DebugLoc DL
Debug location to be set to any instruction we create.
self_iterator getIterator()
unsigned getAddressSpace() const
const MachineInstrBuilder & addFrameIndex(int Idx) const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
MachineInstrBuilder buildCopy(const DstOp &Res, const SrcOp &Op)
Build and insert Res = COPY Op.
MachineInstrBuilder buildTrunc(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_TRUNC Op.
static wasm::ValType getType(const TargetRegisterClass *RC)
MachineInstrBuilder buildAtomicRMWAdd(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_ADD Addr, Val, MMO.
This struct is a compact representation of a valid (non-zero power of two) alignment.
MachineInstrBuilder buildBuildVectorTrunc(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_BUILD_VECTOR_TRUNC Op0, ...
MachineInstrBuilder buildIntrinsic(Intrinsic::ID ID, ArrayRef< Register > Res, bool HasSideEffects)
Build and insert either a G_INTRINSIC (if HasSideEffects is false) or G_INTRINSIC_W_SIDE_EFFECTS inst...
const APFloat & getValueAPF() const
MachineInstrBuilder buildBr(MachineBasicBlock &Dest)
Build and insert G_BR Dest.
MachineInstrBuilder buildConstDbgValue(const Constant &C, const MDNode *Variable, const MDNode *Expr)
Build and insert a DBG_VALUE instructions specifying that Variable is given by C (suitably modified b...
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
MachineInstrBuilder buildLoad(const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert Res = G_LOAD Addr, MMO.
MachineInstrBuilder buildICmp(CmpInst::Predicate Pred, const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
Build and insert a Res = G_ICMP Pred, Op0, Op1.
This is the shared class of boolean and integer constants.
MachineInstrBuilder buildAtomicRMWSub(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_SUB Addr, Val, MMO.
virtual MachineInstrBuilder buildFConstant(const DstOp &Res, const ConstantFP &Val)
Build and insert Res = G_FCONSTANT Val.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
MachineInstrBuilder buildFrameIndex(const DstOp &Res, int Idx)
Build and insert Res = G_FRAME_INDEX Idx.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
MachineInstrBuilder buildAtomicRMWOr(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_OR Addr, Val, MMO.
MachineInstrBuilder buildAtomicRMWUmin(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_UMIN Addr, Val, MMO.
const TargetInstrInfo & getTII()
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
LegalityPredicate isScalar(unsigned TypeIdx)
True iff the specified type index is a scalar.
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
MachineInstrBuilder buildPtrMask(const DstOp &Res, const SrcOp &Op0, uint32_t NumBits)
Build and insert Res = G_PTR_MASK Op0, NumBits.
LLT getLLTTy(const MachineRegisterInfo &MRI) const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
void setCSEInfo(GISelCSEInfo *Info)
This file declares the MachineIRBuilder class.
MachineInstrBuilder buildFCmp(CmpInst::Predicate Pred, const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1, Optional< unsigned > Flags=None)
Build and insert a Res = G_FCMP PredOp0, Op1.
MachineInstrBuilder buildInsertVectorElement(const DstOp &Res, const SrcOp &Val, const SrcOp &Elt, const SrcOp &Idx)
Build and insert Res = G_INSERT_VECTOR_ELT Val, Elt, Idx.
bool isIntPredicate() const
Class for arbitrary precision integers.
MachineInstrBuilder buildAtomicCmpXchgWithSuccess(Register OldValRes, Register SuccessRes, Register Addr, Register CmpVal, Register NewVal, MachineMemOperand &MMO)
Build and insert OldValRes<def>, SuccessRes<def> = G_ATOMIC_CMPXCHG_WITH_SUCCESS Addr, CmpVal, NewVal, MMO.
unsigned getBoolExtOp(bool IsVec, bool IsFP) const
LLT getLLTTy(const MachineRegisterInfo &MRI) const
MachineInstrBuilder buildAtomicRMWAnd(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_AND Addr, Val, MMO.
const MachineBasicBlock * getParent() const
MachineInstrBuilder buildAtomicRMWNand(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_NAND Addr, Val, MMO.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MachineInstrBuilder buildIndirectDbgValue(Register Reg, const MDNode *Variable, const MDNode *Expr)
Build and insert a DBG_VALUE instruction expressing the fact that the associated Variable lives in me...
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
MachineInstrBuilder buildBoolExt(const DstOp &Res, const SrcOp &Op, bool IsFP)
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
MachineInstrBuilder buildStore(const SrcOp &Val, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
MachineInstrBuilder buildAtomicRMWMin(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_MIN Addr, Val, MMO.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
LLVM Value Representation.
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
MachineInstrBuilder buildMerge(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_MERGE_VALUES Op0, ...
MachineInstrBuilder buildUndef(const DstOp &Res)
Build and insert Res = IMPLICIT_DEF.
Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
MachineFunction * MF
MachineFunction under construction.
MachineInstrBuilder buildConcatVectors(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_CONCAT_VECTORS Op0, ...
MachineInstrBuilder buildSplatVector(const DstOp &Res, const SrcOp &Src)
Build and insert Res = G_BUILD_VECTOR with Src replicated to fill the number of elements.
const DebugLoc & getDL()
Getter for DebugLoc.
MachineInstrBuilder buildAtomicCmpXchg(Register OldValRes, Register Addr, Register CmpVal, Register NewVal, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMIC_CMPXCHG Addr, CmpVal, NewVal, MMO.
PointerType * getType() const
Global values are always pointers.
Wrapper class representing virtual and physical registers.
bool empty() const
empty - Check if the array is empty.
This file describes how to lower LLVM code to machine code.
const MachineInstrBuilder & addBlockAddress(const BlockAddress *BA, int64_t Offset=0, unsigned TargetFlags=0) const
MachineRegisterInfo * MRI
Information used to verify types are consistent and to create virtual registers.