31 State.PCSections =
nullptr;
34 State.Observer =
nullptr;
61 "Expected inlined-at fields to agree");
64 false, Reg, Variable, Expr));
74 "Expected inlined-at fields to agree");
77 true, Reg, Variable, Expr));
87 "Expected inlined-at fields to agree");
92 .addMetadata(Variable)
103 "Expected inlined-at fields to agree");
106 auto *NumericConstant = [&] () ->
const Constant* {
108 if (CE->getOpcode() == Instruction::IntToPtr)
109 return CE->getOperand(0);
113 bool IsIndirect =
true;
114 int64_t GlobalOffset;
116 if (CI->getBitWidth() > 64)
118 else if (CI->getBitWidth() == 1)
119 MIB.addImm(CI->getZExtValue());
121 MIB.addImm(CI->getSExtValue());
127 NumericConstant, GlobalOffset,
getMF())) {
130 MIB.addGlobalAddress(GV);
158 "Expected inlined-at fields to agree");
162 return MIB.addMetadata(Label);
169 auto MIB =
buildInstr(TargetOpcode::G_DYN_STACKALLOC);
171 Size.addSrcToMIB(MIB);
172 MIB.addImm(Alignment.value());
179 auto MIB =
buildInstr(TargetOpcode::G_FRAME_INDEX);
181 MIB.addFrameIndex(Idx);
190 "address space mismatch");
192 auto MIB =
buildInstr(TargetOpcode::G_GLOBAL_VALUE);
194 MIB.addGlobalAddress(GV);
201 auto MIB =
buildInstr(TargetOpcode::G_CONSTANT_POOL);
203 MIB.addConstantPoolIndex(Idx);
209 return buildInstr(TargetOpcode::G_JUMP_TABLE, {PtrTy}, {})
210 .addJumpTableIndex(JTI);
215 assert((Res == Op0) &&
"type mismatch");
221 assert((Res == Op0 && Res == Op1) &&
"type mismatch");
227 assert((Res == Op0) &&
"type mismatch");
232 const SrcOp &Op1, std::optional<unsigned> Flags) {
237 return buildInstr(TargetOpcode::G_PTR_ADD, {Res}, {Op0, Op1}, Flags);
248std::optional<MachineInstrBuilder>
251 std::optional<unsigned> Flags) {
252 assert(Res == 0 &&
"Res is a result argument");
253 assert(ValueTy.isScalar() &&
"invalid offset type");
262 return buildPtrAdd(Res, Op0, Cst.getReg(0), Flags);
293 "Different vector element types");
295 "Op0 has more elements");
298 for (
auto Op : Unmerge.getInstr()->defs())
302 "Op0 has more size");
308 for (
unsigned i = 0; i < NumberOfPadElts; ++i)
323 "Different vector element types");
326 "Op0 has fewer elements");
350 "Table reg must be a pointer");
368 "creating constant with the wrong size");
370 assert(!Ty.isScalableVector() &&
371 "unexpected scalable vector in buildConstant");
373 if (Ty.isFixedVector()) {
374 auto Const =
buildInstr(TargetOpcode::G_CONSTANT)
380 auto Const =
buildInstr(TargetOpcode::G_CONSTANT);
405 "creating fconstant with the wrong size");
407 assert(!Ty.isPointer() &&
"invalid operand type");
409 assert(!Ty.isScalableVector() &&
410 "unexpected scalable vector in buildFConstant");
412 if (Ty.isFixedVector()) {
413 auto Const =
buildInstr(TargetOpcode::G_FCONSTANT)
420 auto Const =
buildInstr(TargetOpcode::G_FCONSTANT);
423 Const.addFPImm(&Val);
447 auto *CFP = ConstantFP::get(Ctx, Val);
455 auto MIB =
buildInstr(TargetOpcode::G_PTRAUTH_GLOBAL_VALUE);
459 MIB.addUse(AddrDisc);
468 auto MIB =
buildInstr(TargetOpcode::G_BRCOND);
498 MIB.addMemOperand(&MMO);
510 return buildLoad(Dst, BasePtr, *OffsetMMO);
515 auto Ptr =
buildPtrAdd(PtrTy, BasePtr, ConstOffset);
528 MIB.addMemOperand(&MMO);
542 MIB.addMemOperand(&MMO);
572 std::optional<unsigned> Flags) {
573 return buildInstr(TargetOpcode::G_ZEXT, Res,
Op, Flags);
578 switch (
TLI->getBooleanContents(IsVec)) {
580 return TargetOpcode::G_SEXT;
582 return TargetOpcode::G_ZEXT;
584 return TargetOpcode::G_ANYEXT;
598 switch (
TLI->getBooleanContents(IsVector)) {
613 assert((TargetOpcode::G_ANYEXT == ExtOpc || TargetOpcode::G_ZEXT == ExtOpc ||
614 TargetOpcode::G_SEXT == ExtOpc) &&
615 "Expecting Extending Opc");
621 unsigned Opcode = TargetOpcode::COPY;
623 Op.getLLTTy(*
getMRI()).getSizeInBits())
626 Op.getLLTTy(*
getMRI()).getSizeInBits())
627 Opcode = TargetOpcode::G_TRUNC;
630 Op.getLLTTy(*
getMRI()).getSizeInBits());
667 if (SrcTy.isPointerOrPointerVector())
668 Opcode = TargetOpcode::G_PTRTOINT;
670 Opcode = TargetOpcode::G_INTTOPTR;
672 assert(!SrcTy.isPointerOrPointerVector() &&
674 Opcode = TargetOpcode::G_BITCAST;
687 assert(SrcTy.isValid() &&
"invalid operand type");
690 "extracting off end of register");
694 assert(Index == 0 &&
"insertion past the end of a register");
698 auto Extract =
buildInstr(TargetOpcode::G_EXTRACT);
699 Dst.addDefToMIB(*
getMRI(), Extract);
700 Src.addSrcToMIB(Extract);
701 Extract.addImm(Index);
706 return buildInstr(TargetOpcode::G_IMPLICIT_DEF, {Res}, {});
716 return buildInstr(TargetOpcode::G_MERGE_VALUES, Res, TmpVec);
727 return buildInstr(getOpcodeForMerge(Res, TmpVec), Res, TmpVec);
732 std::initializer_list<SrcOp>
Ops) {
737unsigned MachineIRBuilder::getOpcodeForMerge(
const DstOp &
DstOp,
740 if (SrcOps[0].getLLTTy(*
getMRI()).isVector())
741 return TargetOpcode::G_CONCAT_VECTORS;
742 return TargetOpcode::G_BUILD_VECTOR;
745 return TargetOpcode::G_MERGE_VALUES;
755 return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec,
Op);
762 return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec,
Op);
769 unsigned NumRegs =
OpTy.getSizeInBits() / Attrs.Ty.getSizeInBits();
771 return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec,
Op);
781 return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec,
Op);
790 return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
799 for (
const auto &
Op :
Ops)
801 return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
810 for (
const auto &
Op :
Ops)
812 return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
818 return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
828 if (TmpVec[0].getLLTTy(*
getMRI()).getSizeInBits() ==
830 return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
831 return buildInstr(TargetOpcode::G_BUILD_VECTOR_TRUNC, Res, TmpVec);
838 "Expected Src to match Dst elt ty");
849 "Expected Src to match Dst elt ty");
850 return buildInstr(TargetOpcode::G_SPLAT_VECTOR, Res, Src);
863 assert(DstElemTy == ElemTy1 && DstElemTy == ElemTy2);
864 assert(Mask.size() > 1 &&
"Scalar G_SHUFFLE_VECTOR are not supported");
869 return buildInstr(TargetOpcode::G_SHUFFLE_VECTOR, {Res}, {Src1, Src2})
870 .addShuffleMask(MaskAlloc);
879 return buildInstr(TargetOpcode::G_CONCAT_VECTORS, Res, TmpVec);
888 "insertion past the end of a register");
891 Op.getLLTTy(*
getMRI()).getSizeInBits()) {
902 APInt(Bitwidth, Step));
903 auto StepVector =
buildInstr(TargetOpcode::G_STEP_VECTOR);
904 StepVector->setDebugLoc(
DebugLoc());
906 StepVector.addCImm(CI);
921 auto VScale =
buildInstr(TargetOpcode::G_VSCALE);
924 VScale.addCImm(&MinElts);
929 const APInt &MinElts) {
936 if (HasSideEffects && IsConvergent)
937 return TargetOpcode::G_INTRINSIC_CONVERGENT_W_SIDE_EFFECTS;
939 return TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS;
941 return TargetOpcode::G_INTRINSIC_CONVERGENT;
942 return TargetOpcode::G_INTRINSIC;
948 bool HasSideEffects,
bool isConvergent) {
950 for (
Register ResultReg : ResultRegs)
951 MIB.addDef(ResultReg);
952 MIB.addIntrinsicID(ID);
960 bool HasSideEffects = !Attrs.getMemoryEffects().doesNotAccessMemory();
961 bool isConvergent = Attrs.hasAttribute(Attribute::Convergent);
962 return buildIntrinsic(ID, ResultRegs, HasSideEffects, isConvergent);
971 Result.addDefToMIB(*
getMRI(), MIB);
972 MIB.addIntrinsicID(ID);
979 bool HasSideEffects = !Attrs.getMemoryEffects().doesNotAccessMemory();
980 bool isConvergent = Attrs.hasAttribute(Attribute::Convergent);
986 std::optional<unsigned> Flags) {
987 return buildInstr(TargetOpcode::G_TRUNC, Res,
Op, Flags);
992 std::optional<unsigned> Flags) {
993 return buildInstr(TargetOpcode::G_FPTRUNC, Res,
Op, Flags);
1000 std::optional<unsigned> Flags) {
1001 return buildInstr(TargetOpcode::G_ICMP, Res, {Pred, Op0, Op1}, Flags);
1008 std::optional<unsigned> Flags) {
1010 return buildInstr(TargetOpcode::G_FCMP, Res, {Pred, Op0, Op1}, Flags);
1016 return buildInstr(TargetOpcode::G_SCMP, Res, {Op0, Op1});
1022 return buildInstr(TargetOpcode::G_UCMP, Res, {Op0, Op1});
1028 std::optional<unsigned> Flags) {
1030 return buildInstr(TargetOpcode::G_SELECT, {Res}, {Tst, Op0, Op1}, Flags);
1037 return buildInstr(TargetOpcode::G_INSERT_SUBVECTOR, Res,
1044 return buildInstr(TargetOpcode::G_EXTRACT_SUBVECTOR, Res,
1051 return buildInstr(TargetOpcode::G_INSERT_VECTOR_ELT, Res, {Val, Elt, Idx});
1057 return buildInstr(TargetOpcode::G_EXTRACT_VECTOR_ELT, Res, {Val, Idx});
1074 assert(OldValResTy == CmpValTy &&
"type mismatch");
1075 assert(OldValResTy == NewValTy &&
"type mismatch");
1078 auto MIB =
buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG_WITH_SUCCESS);
1084 MIB.addMemOperand(&MMO);
1101 assert(OldValResTy == CmpValTy &&
"type mismatch");
1102 assert(OldValResTy == NewValTy &&
"type mismatch");
1105 auto MIB =
buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG);
1110 MIB.addMemOperand(&MMO);
1115 unsigned Opcode,
const DstOp &OldValRes,
1125 assert(OldValResTy == ValTy &&
"type mismatch");
1133 MIB.addMemOperand(&MMO);
1140 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_XCHG, OldValRes, Addr, Val,
1146 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_ADD, OldValRes, Addr, Val,
1152 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_SUB, OldValRes, Addr, Val,
1158 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_AND, OldValRes, Addr, Val,
1164 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_NAND, OldValRes, Addr, Val,
1171 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_OR, OldValRes, Addr, Val,
1177 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_XOR, OldValRes, Addr, Val,
1183 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_MAX, OldValRes, Addr, Val,
1189 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_MIN, OldValRes, Addr, Val,
1195 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_UMAX, OldValRes, Addr, Val,
1201 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_UMIN, OldValRes, Addr, Val,
1209 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FADD, OldValRes, Addr, Val,
1216 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FSUB, OldValRes, Addr, Val,
1223 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FMAX, OldValRes, Addr, Val,
1230 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FMIN, OldValRes, Addr, Val,
1238 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FMAXIMUM, OldValRes, Addr,
1246 return buildAtomicRMW(TargetOpcode::G_ATOMICRMW_FMINIMUM, OldValRes, Addr,
1262 auto MIB =
buildInstr(TargetOpcode::G_PREFETCH);
1264 MIB.addImm(RW).addImm(Locality).addImm(CacheType);
1265 MIB.addMemOperand(&MMO);
1282 assert(SrcTy.isVector() &&
"mismatched cast between vector and non-vector");
1284 "different number of elements in a trunc/ext");
1286 assert(DstTy.
isScalar() && SrcTy.isScalar() &&
"invalid extend/trunc");
1290 "invalid narrowing extend");
1293 "invalid widening trunc");
1298 const LLT Op0Ty,
const LLT Op1Ty) {
1301 "invalid operand type");
1302 assert((ResTy == Op0Ty && ResTy == Op1Ty) &&
"type mismatch");
1316 std::optional<unsigned> Flags) {
1320 case TargetOpcode::G_SELECT: {
1321 assert(DstOps.
size() == 1 &&
"Invalid select");
1322 assert(SrcOps.
size() == 3 &&
"Invalid select");
1324 DstOps[0].getLLTTy(*
getMRI()), SrcOps[0].getLLTTy(*
getMRI()),
1325 SrcOps[1].getLLTTy(*
getMRI()), SrcOps[2].getLLTTy(*
getMRI()));
1328 case TargetOpcode::G_FNEG:
1329 case TargetOpcode::G_ABS:
1332 assert(SrcOps.
size() == 1 &&
"Invalid Srcs");
1334 SrcOps[0].getLLTTy(*
getMRI()));
1336 case TargetOpcode::G_ADD:
1337 case TargetOpcode::G_AND:
1338 case TargetOpcode::G_MUL:
1339 case TargetOpcode::G_OR:
1340 case TargetOpcode::G_SUB:
1341 case TargetOpcode::G_XOR:
1342 case TargetOpcode::G_UDIV:
1343 case TargetOpcode::G_SDIV:
1344 case TargetOpcode::G_UREM:
1345 case TargetOpcode::G_SREM:
1346 case TargetOpcode::G_SMIN:
1347 case TargetOpcode::G_SMAX:
1348 case TargetOpcode::G_UMIN:
1349 case TargetOpcode::G_UMAX:
1350 case TargetOpcode::G_UADDSAT:
1351 case TargetOpcode::G_SADDSAT:
1352 case TargetOpcode::G_USUBSAT:
1353 case TargetOpcode::G_SSUBSAT: {
1356 assert(SrcOps.
size() == 2 &&
"Invalid Srcs");
1358 SrcOps[0].getLLTTy(*
getMRI()),
1359 SrcOps[1].getLLTTy(*
getMRI()));
1362 case TargetOpcode::G_SHL:
1363 case TargetOpcode::G_ASHR:
1364 case TargetOpcode::G_LSHR:
1365 case TargetOpcode::G_USHLSAT:
1366 case TargetOpcode::G_SSHLSAT: {
1368 assert(SrcOps.
size() == 2 &&
"Invalid Srcs");
1370 SrcOps[0].getLLTTy(*
getMRI()),
1371 SrcOps[1].getLLTTy(*
getMRI()));
1374 case TargetOpcode::G_SEXT:
1375 case TargetOpcode::G_ZEXT:
1376 case TargetOpcode::G_ANYEXT:
1378 assert(SrcOps.
size() == 1 &&
"Invalid Srcs");
1380 SrcOps[0].getLLTTy(*
getMRI()),
true);
1382 case TargetOpcode::G_TRUNC:
1383 case TargetOpcode::G_FPTRUNC: {
1385 assert(SrcOps.
size() == 1 &&
"Invalid Srcs");
1387 SrcOps[0].getLLTTy(*
getMRI()),
false);
1390 case TargetOpcode::G_BITCAST: {
1392 assert(SrcOps.
size() == 1 &&
"Invalid Srcs");
1393 assert(DstOps[0].getLLTTy(*
getMRI()).getSizeInBits() ==
1394 SrcOps[0].getLLTTy(*
getMRI()).getSizeInBits() &&
"invalid bitcast");
1397 case TargetOpcode::COPY:
1402 case TargetOpcode::G_FCMP:
1403 case TargetOpcode::G_ICMP: {
1404 assert(DstOps.
size() == 1 &&
"Invalid Dst Operands");
1405 assert(SrcOps.
size() == 3 &&
"Invalid Src Operands");
1409 "Expecting predicate");
1414 }() &&
"Invalid predicate");
1418 LLT Op0Ty = SrcOps[1].getLLTTy(*
getMRI());
1419 LLT DstTy = DstOps[0].getLLTTy(*
getMRI());
1425 }() &&
"Type Mismatch");
1428 case TargetOpcode::G_UNMERGE_VALUES: {
1429 assert(!DstOps.
empty() &&
"Invalid trivial sequence");
1430 assert(SrcOps.
size() == 1 &&
"Invalid src for Unmerge");
1434 DstOps[0].getLLTTy(*
getMRI());
1436 "type mismatch in output list");
1438 DstOps[0].getLLTTy(*
getMRI()).getSizeInBits() ==
1439 SrcOps[0].getLLTTy(*
getMRI()).getSizeInBits() &&
1440 "input operands do not cover output register");
1443 case TargetOpcode::G_MERGE_VALUES: {
1444 assert(SrcOps.
size() >= 2 &&
"invalid trivial sequence");
1449 SrcOps[0].getLLTTy(*
getMRI());
1451 "type mismatch in input list");
1453 SrcOps[0].getLLTTy(*
getMRI()).getSizeInBits() ==
1454 DstOps[0].getLLTTy(*
getMRI()).getSizeInBits() &&
1455 "input operands do not cover output register");
1457 "vectors should be built with G_CONCAT_VECTOR or G_BUILD_VECTOR");
1460 case TargetOpcode::G_EXTRACT_VECTOR_ELT: {
1461 assert(DstOps.
size() == 1 &&
"Invalid Dst size");
1462 assert(SrcOps.
size() == 2 &&
"Invalid Src size");
1463 assert(SrcOps[0].getLLTTy(*
getMRI()).isVector() &&
"Invalid operand type");
1465 DstOps[0].getLLTTy(*
getMRI()).isPointer()) &&
1466 "Invalid operand type");
1467 assert(SrcOps[1].getLLTTy(*
getMRI()).isScalar() &&
"Invalid operand type");
1468 assert(SrcOps[0].getLLTTy(*
getMRI()).getElementType() ==
1469 DstOps[0].getLLTTy(*
getMRI()) &&
1473 case TargetOpcode::G_INSERT_VECTOR_ELT: {
1474 assert(DstOps.
size() == 1 &&
"Invalid dst size");
1475 assert(SrcOps.
size() == 3 &&
"Invalid src size");
1477 SrcOps[0].getLLTTy(*
getMRI()).isVector() &&
"Invalid operand type");
1478 assert(DstOps[0].getLLTTy(*
getMRI()).getElementType() ==
1479 SrcOps[1].getLLTTy(*
getMRI()) &&
1481 assert(SrcOps[2].getLLTTy(*
getMRI()).isScalar() &&
"Invalid index");
1482 assert(DstOps[0].getLLTTy(*
getMRI()).getElementCount() ==
1483 SrcOps[0].getLLTTy(*
getMRI()).getElementCount() &&
1487 case TargetOpcode::G_INSERT_SUBVECTOR: {
1489 assert(SrcOps.
size() == 3 &&
"Invalid Srcs");
1490 [[maybe_unused]]
LLT DstTy = DstOps[0].getLLTTy(*
getMRI());
1491 [[maybe_unused]]
LLT BigVecTy = SrcOps[0].getLLTTy(*
getMRI());
1493 assert(DstTy == BigVecTy &&
1494 "Dest and insert subvector source types must match!");
1496 "Insert subvector VTs must be vectors!");
1498 "Insert subvector VTs must have the same element type!");
1500 "Cannot insert a scalable vector into a fixed length vector!");
1503 SubVecTy.getElementCount().getKnownMinValue()) &&
1504 "Insert subvector must be from smaller vector to larger vector!");
1506 "Insert subvector index must be constant");
1508 (
SubVecTy.getElementCount().getKnownMinValue() +
1509 (uint64_t)SrcOps[2].getImm()) <=
1511 "Insert subvector overflow!");
1513 SubVecTy.getElementCount().getKnownMinValue() ==
1515 "Insert index is not a multiple of the subvector length");
1518 case TargetOpcode::G_EXTRACT_SUBVECTOR: {
1520 assert(SrcOps.
size() == 2 &&
"Invalid Srcs");
1521 [[maybe_unused]]
LLT DstTy = DstOps[0].getLLTTy(*
getMRI());
1522 [[maybe_unused]]
LLT SrcVecTy = SrcOps[0].getLLTTy(*
getMRI());
1524 "Extract subvector VTs must be vectors!");
1526 "Extract subvector VTs must have the same element type!");
1528 "Cannot extract a scalable vector from a fixed length vector!");
1532 "Extract subvector must be from larger vector to smaller vector!");
1534 "Extract subvector index must be a constant");
1537 (uint64_t)SrcOps[1].getImm()) <=
1539 "Extract subvector overflow!");
1543 "Extract index is not a multiple of the output vector length");
1546 case TargetOpcode::G_BUILD_VECTOR: {
1548 "Must have at least 2 operands");
1549 assert(DstOps.
size() == 1 &&
"Invalid DstOps");
1551 "Res type must be a vector");
1555 SrcOps[0].getLLTTy(*
getMRI());
1557 "type mismatch in input list");
1559 SrcOps[0].getLLTTy(*
getMRI()).getSizeInBits() ==
1560 DstOps[0].getLLTTy(*
getMRI()).getSizeInBits() &&
1561 "input scalars do not exactly cover the output vector register");
1564 case TargetOpcode::G_BUILD_VECTOR_TRUNC: {
1566 "Must have at least 2 operands");
1567 assert(DstOps.
size() == 1 &&
"Invalid DstOps");
1569 "Res type must be a vector");
1573 SrcOps[0].getLLTTy(*
getMRI());
1575 "type mismatch in input list");
1578 case TargetOpcode::G_CONCAT_VECTORS: {
1579 assert(DstOps.
size() == 1 &&
"Invalid DstOps");
1581 "Must have at least 2 operands");
1584 return (
Op.getLLTTy(*
getMRI()).isVector() &&
1586 SrcOps[0].getLLTTy(*
getMRI()));
1588 "type mismatch in input list");
1590 SrcOps[0].getLLTTy(*
getMRI()).getSizeInBits() ==
1591 DstOps[0].getLLTTy(*
getMRI()).getSizeInBits() &&
1592 "input vectors do not exactly cover the output vector register");
1595 case TargetOpcode::G_UADDE: {
1596 assert(DstOps.
size() == 2 &&
"Invalid no of dst operands");
1597 assert(SrcOps.
size() == 3 &&
"Invalid no of src operands");
1598 assert(DstOps[0].getLLTTy(*
getMRI()).isScalar() &&
"Invalid operand");
1600 (DstOps[0].getLLTTy(*
getMRI()) == SrcOps[1].getLLTTy(*
getMRI())) &&
1602 assert(DstOps[1].getLLTTy(*
getMRI()).isScalar() &&
"Invalid operand");
1610 for (
const DstOp &
Op : DstOps)
1612 for (
const SrcOp &
Op : SrcOps)
1613 Op.addSrcToMIB(MIB);
1615 MIB->setFlags(*Flags);
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Function Alias Analysis Results
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static unsigned getIntrinsicOpcode(bool HasSideEffects, bool IsConvergent)
This file declares the MachineIRBuilder class.
Promote Memory to Register
static unsigned getAddressSpace(const Value *V, unsigned MaxLookup)
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
static SymbolRef::Type getType(const Symbol *Sym)
This file describes how to lower LLVM code to machine code.
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
static LLVM_ABI unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
static constexpr roundingMode rmNearestTiesToEven
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
const fltSemantics & getSemantics() const
Class for arbitrary precision integers.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
This class holds the attributes for a particular argument, parameter, function, or return value.
The address of a basic block.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
bool isFPPredicate() const
bool isIntPredicate() const
ConstantFP - Floating Point Values [float, double].
const APFloat & getValueAPF() const
This is the shared class of boolean and integer constants.
static ConstantInt * getSigned(IntegerType *Ty, int64_t V, bool ImplicitTrunc=false)
Return a ConstantInt with the specified value for the specified type.
unsigned getBitWidth() const
getBitWidth - Return the scalar bitwidth of this constant.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
A signed pointer, in the ptrauth sense.
ConstantInt * getKey() const
The Key ID, an i32 constant.
ConstantInt * getDiscriminator() const
The integer discriminator, an i64 constant, or 0.
This is an important base class in LLVM.
static LLVM_ABI void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
static LLVM_ABI DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
void addDefToMIB(MachineRegisterInfo &MRI, MachineInstrBuilder &MIB) const
LLT getLLTTy(const MachineRegisterInfo &MRI) const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
PointerType * getType() const
Global values are always pointers.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
constexpr unsigned getScalarSizeInBits() const
constexpr bool isScalar() const
LLT getScalarType() const
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
constexpr bool isValid() const
constexpr uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
constexpr bool isVector() const
constexpr bool isScalable() const
Returns true if the LLT is a scalable vector.
constexpr TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
constexpr bool isPointer() const
constexpr ElementCount getElementCount() const
constexpr bool isPointerOrPointerVector() const
static LLT integer(unsigned SizeInBits)
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
MachineInstrBundleIterator< MachineInstr > iterator
ArrayRef< int > allocateShuffleMask(ArrayRef< int > Mask)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineInstrBuilder buildBuildVectorFConstant(const DstOp &Res, ArrayRef< APFloat > Ops)
Build and insert Res = G_BUILD_VECTOR Op0, ... where each OpN is built with G_FCONSTANT.
MachineInstrBuilder buildLoadFromOffset(const DstOp &Dst, const SrcOp &BasePtr, MachineMemOperand &BaseMMO, int64_t Offset)
Helper to create a load from a constant offset given a base address.
MachineInstrBuilder buildAtomicRMWFMin(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_FMIN Addr, Val, MMO.
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
MachineInstrBuilder buildAtomicRMWFMaximum(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_FMAXIMUM Addr, Val, MMO.
MachineInstrBuilder buildAtomicRMWXor(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_XOR Addr, Val, MMO.
MachineInstrBuilder buildGlobalValue(const DstOp &Res, const GlobalValue *GV)
Build and insert Res = G_GLOBAL_VALUE GV.
MachineInstrBuilder buildBr(MachineBasicBlock &Dest)
Build and insert G_BR Dest.
LLVMContext & getContext() const
MachineInstrBuilder buildUndef(const DstOp &Res)
Build and insert Res = IMPLICIT_DEF.
Value * getDeactivationSymbol()
MachineInstrBuilder buildUCmp(const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
Build and insert a Res = G_UCMP Op0, Op1.
MachineInstrBuilder buildConstantPool(const DstOp &Res, unsigned Idx)
Build and insert Res = G_CONSTANT_POOL Idx.
MachineInstrBuilder buildJumpTable(const LLT PtrTy, unsigned JTI)
Build and insert Res = G_JUMP_TABLE JTI.
MachineInstrBuilder buildUnmerge(ArrayRef< LLT > Res, const SrcOp &Op)
Build and insert Res0, ... = G_UNMERGE_VALUES Op.
MachineInstrBuilder buildSCmp(const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
Build and insert a Res = G_SCMP Op0, Op1.
MachineInstrBuilder buildFence(unsigned Ordering, unsigned Scope)
Build and insert G_FENCE Ordering, Scope.
MachineInstrBuilder buildSelect(const DstOp &Res, const SrcOp &Tst, const SrcOp &Op0, const SrcOp &Op1, std::optional< unsigned > Flags=std::nullopt)
Build and insert a Res = G_SELECT Tst, Op0, Op1.
MachineInstrBuilder buildAtomicRMWAnd(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_AND Addr, Val, MMO.
MachineInstrBuilder buildZExtInReg(const DstOp &Res, const SrcOp &Op, int64_t ImmOp)
Build and inserts Res = G_AND Op, LowBitsSet(ImmOp) Since there is no G_ZEXT_INREG like G_SEXT_INREG,...
MachineInstrBuilder buildAtomicRMWMin(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_MIN Addr, Val, MMO.
MachineInstrBuilder buildExtract(const DstOp &Res, const SrcOp &Src, uint64_t Index)
Build and insert Res0, ... = G_EXTRACT Src, Idx0.
std::optional< MachineInstrBuilder > materializePtrAdd(Register &Res, Register Op0, const LLT ValueTy, uint64_t Value, std::optional< unsigned > Flags=std::nullopt)
Materialize and insert Res = G_PTR_ADD Op0, (G_CONSTANT Value)
MachineInstrBuilder buildInsertSubvector(const DstOp &Res, const SrcOp &Src0, const SrcOp &Src1, unsigned Index)
Build and insert Res = G_INSERT_SUBVECTOR Src0, Src1, Idx.
MachineInstrBuilder buildAnd(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_AND Op0, Op1.
MachineInstrBuilder buildCast(const DstOp &Dst, const SrcOp &Src)
Build and insert an appropriate cast between two registers of equal size.
const TargetInstrInfo & getTII()
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 buildAtomicRMWNand(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_NAND Addr, Val, MMO.
MachineInstrBuilder buildICmp(CmpInst::Predicate Pred, const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1, std::optional< unsigned > Flags=std::nullopt)
Build and insert a Res = G_ICMP Pred, Op0, Op1.
MachineInstrBuilder buildAnyExtOrTrunc(const DstOp &Res, const SrcOp &Op)
Res = COPY Op depending on the differing sizes of Res and Op.
MachineInstrBuilder buildSExt(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_SEXT Op.
MachineBasicBlock::iterator getInsertPt()
Current insertion point for new instructions.
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...
MachineInstrBuilder buildShuffleSplat(const DstOp &Res, const SrcOp &Src)
Build and insert a vector splat of a scalar Src using a G_INSERT_VECTOR_ELT and G_SHUFFLE_VECTOR idio...
MachineInstrBuilder buildZExt(const DstOp &Res, const SrcOp &Op, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_ZEXT Op.
MachineInstrBuilder buildConcatVectors(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_CONCAT_VECTORS Op0, ...
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 buildIntrinsic(Intrinsic::ID ID, ArrayRef< Register > Res, bool HasSideEffects, bool isConvergent)
Build and insert a G_INTRINSIC instruction.
MDNode * getPCSections()
Get the current instruction's PC sections metadata.
MachineInstrBuilder buildVScale(const DstOp &Res, unsigned MinElts)
Build and insert Res = G_VSCALE MinElts.
MachineInstrBuilder buildSplatBuildVector(const DstOp &Res, const SrcOp &Src)
Build and insert Res = G_BUILD_VECTOR with Src replicated to fill the number of elements.
MachineInstrBuilder buildBoolExt(const DstOp &Res, const SrcOp &Op)
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...
MachineInstrBuilder buildObjectPtrOffset(const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
Build and insert an instruction with appropriate flags for addressing some offset of an object,...
MachineInstrBuilder buildAtomicRMWUmax(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_UMAX Addr, Val, MMO.
MachineInstrBuilder buildBuildVector(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_BUILD_VECTOR Op0, ...
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...
void recordInsertion(MachineInstr *InsertedInstr) const
MachineInstrBuilder buildBrCond(const SrcOp &Tst, MachineBasicBlock &Dest)
Build and insert G_BRCOND Tst, Dest.
std::optional< MachineInstrBuilder > materializeObjectPtrOffset(Register &Res, Register Op0, const LLT ValueTy, uint64_t Value)
Materialize and insert an instruction with appropriate flags for addressing some offset of an object,...
MachineInstrBuilder buildMergeLikeInstr(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_MERGE_VALUES Op0, ... or Res = G_BUILD_VECTOR Op0, ... or Res = G_CONCAT_VEC...
MachineInstrBuilder buildAtomicRMWFMinimum(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_FMINIMUM Addr, Val, MMO.
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.
MachineInstrBuilder buildPtrAdd(const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_PTR_ADD Op0, Op1.
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 buildBuildVectorTrunc(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_BUILD_VECTOR_TRUNC Op0, ...
virtual MachineInstrBuilder buildFConstant(const DstOp &Res, const ConstantFP &Val)
Build and insert Res = G_FCONSTANT Val.
MachineInstrBuilder buildStore(const SrcOp &Val, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
MachineInstrBuilder buildPadVectorWithUndefElements(const DstOp &Res, const SrcOp &Op0)
Build and insert a, b, ..., x = G_UNMERGE_VALUES Op0 Res = G_BUILD_VECTOR a, b, .....
void validateSelectOp(const LLT ResTy, const LLT TstTy, const LLT Op0Ty, const LLT Op1Ty)
MachineInstrBuilder buildFrameIndex(const DstOp &Res, int Idx)
Build and insert Res = G_FRAME_INDEX Idx.
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...
const DebugLoc & getDL()
Getter for DebugLoc.
MachineInstrBuilder buildBuildVectorConstant(const DstOp &Res, ArrayRef< APInt > Ops)
Build and insert Res = G_BUILD_VECTOR Op0, ... where each OpN is built with G_CONSTANT.
MachineInstrBuilder buildAtomicRMWUmin(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_UMIN Addr, Val, MMO.
void validateBinaryOp(const LLT Res, const LLT Op0, const LLT Op1)
void validateShiftOp(const LLT Res, const LLT Op0, const LLT Op1)
MachineFunction & getMF()
Getter for the function we currently build.
MachineInstrBuilder buildDbgLabel(const MDNode *Label)
Build and insert a DBG_LABEL instructions specifying that Label is given.
MachineInstrBuilder buildBrJT(Register TablePtr, unsigned JTI, Register IndexReg)
Build and insert G_BRJT TablePtr, JTI, IndexReg.
MachineInstrBuilder buildInsert(const DstOp &Res, const SrcOp &Src, const SrcOp &Op, unsigned Index)
MachineInstrBuilder buildDynStackAlloc(const DstOp &Res, const SrcOp &Size, Align Alignment)
Build and insert Res = G_DYN_STACKALLOC Size, Align.
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...
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 buildAtomicRMWSub(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_SUB Addr, Val, MMO.
MachineInstrBuilder buildMergeValues(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_MERGE_VALUES Op0, ...
MachineInstrBuilder buildTrunc(const DstOp &Res, const SrcOp &Op, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_TRUNC Op.
MachineInstrBuilder buildAtomicRMWFMax(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_FMAX Addr, Val, MMO.
MachineInstrBuilder buildBoolExtInReg(const DstOp &Res, const SrcOp &Op, bool IsVector)
MachineInstrBuilder buildAtomicRMWOr(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_OR Addr, Val, MMO.
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
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.
MachineInstrBuilder buildAnyExt(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_ANYEXT Op0.
MachineInstrBuilder buildAtomicCmpXchgWithSuccess(const DstOp &OldValRes, const DstOp &SuccessRes, const SrcOp &Addr, const SrcOp &CmpVal, const SrcOp &NewVal, MachineMemOperand &MMO)
Build and insert OldValRes<def>, SuccessRes<def> = / G_ATOMIC_CMPXCHG_WITH_SUCCESS Addr,...
MachineInstrBuilder buildDeleteTrailingVectorElements(const DstOp &Res, const SrcOp &Op0)
Build and insert a, b, ..., x, y, z = G_UNMERGE_VALUES Op0 Res = G_BUILD_VECTOR a,...
MachineRegisterInfo * getMRI()
Getter for MRI.
MachineInstrBuilder buildAtomicRMWAdd(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_ADD Addr, Val, MMO.
MachineInstrBuilder buildFPTrunc(const DstOp &Res, const SrcOp &Op, std::optional< unsigned > Flags=std::nullopt)
Build and insert Res = G_FPTRUNC Op.
MachineInstrBuilder buildAtomicCmpXchg(const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &CmpVal, const SrcOp &NewVal, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMIC_CMPXCHG Addr, CmpVal, NewVal, / MMO.
MachineInstrBuilder buildShuffleVector(const DstOp &Res, const SrcOp &Src1, const SrcOp &Src2, ArrayRef< int > Mask)
Build and insert Res = G_SHUFFLE_VECTOR Src1, Src2, Mask.
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 buildCopy(const DstOp &Res, const SrcOp &Op)
Build and insert Res = COPY Op.
void validateUnaryOp(const LLT Res, const LLT Op0)
MachineInstrBuilder buildBlockAddress(Register Res, const BlockAddress *BA)
Build and insert Res = G_BLOCK_ADDR BA.
MDNode * getMMRAMetadata()
Get the current instruction's MMRA metadata.
MachineInstrBuilder buildAtomicRMWMax(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_MAX Addr, Val, MMO.
MachineInstrBuilder buildPrefetch(const SrcOp &Addr, unsigned RW, unsigned Locality, unsigned CacheType, MachineMemOperand &MMO)
Build and insert G_PREFETCH Addr, RW, Locality, CacheType.
MachineInstrBuilder buildExtractSubvector(const DstOp &Res, const SrcOp &Src, unsigned Index)
Build and insert Res = G_EXTRACT_SUBVECTOR Src, Idx0.
MachineInstrBuilder buildBrIndirect(Register Tgt)
Build and insert G_BRINDIRECT Tgt.
unsigned getBoolExtOp(bool IsVec) const
MachineInstrBuilder buildSplatVector(const DstOp &Res, const SrcOp &Val)
Build and insert Res = G_SPLAT_VECTOR Val.
MachineInstrBuilder buildLoadInstr(unsigned Opcode, const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert Res = <opcode> Addr, MMO.
void setMF(MachineFunction &MF)
MachineInstrBuilder buildStoreInstr(unsigned Opcode, const SrcOp &Val, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert <opcode> Val, Addr, MMO.
MachineInstrBuilder buildStepVector(const DstOp &Res, unsigned Step)
Build and insert Res = G_STEP_VECTOR Step.
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 buildAtomicRMWXchg(Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_XCHG Addr, Val, MMO.
MachineInstrBuilder buildMaskLowPtrBits(const DstOp &Res, const SrcOp &Op0, uint32_t NumBits)
Build and insert Res = G_PTRMASK Op0, G_CONSTANT (1 << NumBits) - 1.
virtual MachineInstrBuilder buildConstant(const DstOp &Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
MachineInstrBuilder buildFCmp(CmpInst::Predicate Pred, const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1, std::optional< unsigned > Flags=std::nullopt)
Build and insert a Res = G_FCMP PredOp0, Op1.
MachineInstrBuilder buildSExtInReg(const DstOp &Res, const SrcOp &Op, int64_t ImmOp)
Build and insert Res = G_SEXT_INREG Op, ImmOp.
MachineInstrBuilder buildConstantPtrAuth(const DstOp &Res, const ConstantPtrAuth *CPA, Register Addr, Register AddrDisc)
Build and insert G_PTRAUTH_GLOBAL_VALUE.
Register getReg(unsigned Idx) const
Get the register for the operand index.
const MachineInstrBuilder & addCImm(const ConstantInt *Val) const
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 & addBlockAddress(const BlockAddress *BA, int64_t Offset=0, unsigned TargetFlags=0) const
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
const MachineInstrBuilder & addJumpTableIndex(unsigned Idx, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
A description of a memory reference used in the backend.
bool isAtomic() const
Returns true if this operation has an atomic ordering requirement of unordered or higher,...
Flags
Flags values. These may be or'd together.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
LLVM_ABI Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Wrapper class representing virtual and physical registers.
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLT getLLTTy(const MachineRegisterInfo &MRI) const
void addSrcToMIB(MachineInstrBuilder &MIB) const
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetLowering * getTargetLowering() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI AttributeSet getFnAttributes(LLVMContext &C, ID id)
Return the function attributes for an intrinsic.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Undef
Value of the register doesn't matter.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI const llvm::fltSemantics & getFltSemanticForLLT(LLT Ty)
Get the appropriate floating point arithmetic semantic based on the bit size of the given scalar LLT.
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
constexpr T maskTrailingZeros(unsigned N)
Create a bitmask with the N right-most bits set to 0, and all other bits set to 1.
DWARFExpression::Operation Op
LLVM_ABI const GlobalValue * getDescribableGlobalAddress(const Constant *C, int64_t &Offset, const MachineFunction &MF)
If C is the address of a global, possibly displaced by a constant, return that global and set Offset ...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
This struct is a compact representation of a valid (non-zero power of two) alignment.
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.