13#ifndef LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H
14#define LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H
37class TargetRegisterClass;
41class GISelChangeObserver;
243 void validateTruncExt(
const LLT Dst,
const LLT Src,
bool IsExtend);
245 void validateUnaryOp(
const LLT Res,
const LLT Op0);
246 void validateBinaryOp(
const LLT Res,
const LLT Op0,
const LLT Op1);
247 void validateShiftOp(
const LLT Res,
const LLT Op0,
const LLT Op1);
249 void validateSelectOp(
const LLT ResTy,
const LLT TstTy,
const LLT Op0Ty,
254 State.Observer->createdInstr(*InsertedInstr);
263 setMF(*
MBB.getParent());
264 setInsertPt(
MBB, InsPt);
270 setDebugLoc(
MI.getDebugLoc());
275 setChangeObserver(Observer);
283 assert(State.TII &&
"TargetInstrInfo is not set");
289 assert(State.MF &&
"MachineFunction is not set");
294 assert(State.MF &&
"MachineFunction is not set");
299 return getMF().getFunction().getDataLayout();
303 return getMF().getFunction().getContext();
321 assert(State.MBB &&
"MachineBasicBlock is not set");
341 "Basic block is in a different function");
359 State.II =
MBB.end();
361 "Basic block is in a different function");
367 assert(
MI.getParent() &&
"Instruction is not part of a basic block");
368 setMBB(*
MI.getParent());
369 State.II =
MI.getIterator();
370 setPCSections(
MI.getPCSections());
371 setMMRAMetadata(
MI.getMMRAMetadata());
379 setDebugLoc(
MI.getDebugLoc());
383 State.Observer = &Observer;
419 return insertInstr(buildInstrNoInsert(Opcode));
519 std::optional<unsigned> Flags = std::nullopt);
552 std::optional<MachineInstrBuilder>
555 std::optional<unsigned> Flags = std::nullopt);
572 std::optional<MachineInstrBuilder>
579 return buildInstr(TargetOpcode::G_PTRMASK, {Res}, {Op0, Op1});
640 return buildInstr(TargetOpcode::G_UADDO, {Res, CarryOut}, {Op0, Op1});
646 return buildInstr(TargetOpcode::G_USUBO, {Res, CarryOut}, {Op0, Op1});
652 return buildInstr(TargetOpcode::G_SADDO, {Res, CarryOut}, {Op0, Op1});
658 return buildInstr(TargetOpcode::G_SSUBO, {Res, CarryOut}, {Op0, Op1});
677 const SrcOp &CarryIn) {
678 return buildInstr(TargetOpcode::G_UADDE, {Res, CarryOut},
679 {Op0, Op1, CarryIn});
685 const SrcOp &CarryIn) {
686 return buildInstr(TargetOpcode::G_USUBE, {Res, CarryOut},
687 {Op0, Op1, CarryIn});
693 const SrcOp &CarryIn) {
694 return buildInstr(TargetOpcode::G_SADDE, {Res, CarryOut},
695 {Op0, Op1, CarryIn});
701 const SrcOp &CarryIn) {
702 return buildInstr(TargetOpcode::G_SSUBE, {Res, CarryOut},
703 {Op0, Op1, CarryIn});
738 return buildInstr(TargetOpcode::G_SEXT_INREG, {Res}, {
Op,
SrcOp(ImmOp)});
743 std::optional<unsigned> Flags = std::nullopt) {
744 return buildInstr(TargetOpcode::G_FPEXT, {Res}, {
Op}, Flags);
749 return buildInstr(TargetOpcode::G_PTRTOINT, {Dst}, {Src});
754 return buildInstr(TargetOpcode::G_INTTOPTR, {Dst}, {Src});
759 return buildInstr(TargetOpcode::G_BITCAST, {Dst}, {Src});
764 return buildInstr(TargetOpcode::G_ADDRSPACE_CAST, {Dst}, {Src});
769 unsigned getBoolExtOp(
bool IsVec,
bool IsFP)
const;
796 std::optional<unsigned> Flags = std::nullopt);
857 return buildInstr(TargetOpcode::G_TRUNC_SSAT_S, {Res}, {
Op});
871 return buildInstr(TargetOpcode::G_TRUNC_SSAT_U, {Res}, {
Op});
885 return buildInstr(TargetOpcode::G_TRUNC_USAT_U, {Res}, {
Op});
998 const SrcOp &
Op,
unsigned Val) {
1007 return buildAssertInstr(TargetOpcode::G_ASSERT_ZEXT, Res,
Op,
Size);
1015 return buildAssertInstr(TargetOpcode::G_ASSERT_SEXT, Res,
Op,
Size);
1023 return buildAssertInstr(TargetOpcode::G_ASSERT_ALIGN, Res,
Op,
1038 return buildLoadInstr(TargetOpcode::G_LOAD, Res,
Addr, MMO);
1065 const SrcOp &BasePtr,
1135 std::initializer_list<SrcOp> Ops);
1315 bool HasSideEffects,
bool isConvergent);
1318 bool HasSideEffects,
bool isConvergent);
1333 std::optional<unsigned> Flags = std::nullopt);
1347 std::optional<unsigned> Flags = std::nullopt);
1363 std::optional<unsigned> Flags = std::nullopt);
1379 std::optional<unsigned> Flags = std::nullopt);
1412 return buildInstr(TargetOpcode::G_IS_FPCLASS, {Res},
1413 {Src,
SrcOp(
static_cast<int64_t
>(Mask))});
1428 std::optional<unsigned> Flags = std::nullopt);
1455 const TargetLowering *TLI = getMF().getSubtarget().getTargetLowering();
1457 return buildExtractVectorElement(Res, Val, buildConstant(IdxTy,
Idx));
1489 buildAtomicCmpXchgWithSuccess(
const DstOp &OldValRes,
const DstOp &SuccessRes,
1509 const SrcOp &NewVal,
1819 unsigned Locality,
unsigned CacheType,
1824 return buildInstr(TargetOpcode::G_FREEZE, {Dst}, {Src});
1850 std::optional<unsigned> Flags = std::nullopt) {
1851 return buildInstr(TargetOpcode::G_ADD, {Dst}, {Src0, Src1}, Flags);
1867 std::optional<unsigned> Flags = std::nullopt) {
1868 return buildInstr(TargetOpcode::G_SUB, {Dst}, {Src0, Src1}, Flags);
1883 std::optional<unsigned> Flags = std::nullopt) {
1884 return buildInstr(TargetOpcode::G_MUL, {Dst}, {Src0, Src1}, Flags);
1897 const SrcOp &Src1) {
1898 return buildInstr(TargetOpcode::G_ABDS, {Dst}, {Src0, Src1});
1911 const SrcOp &Src1) {
1912 return buildInstr(TargetOpcode::G_ABDU, {Dst}, {Src0, Src1});
1917 std::optional<unsigned> Flags = std::nullopt) {
1918 return buildInstr(TargetOpcode::G_UMULH, {Dst}, {Src0, Src1}, Flags);
1923 std::optional<unsigned> Flags = std::nullopt) {
1924 return buildInstr(TargetOpcode::G_SMULH, {Dst}, {Src0, Src1}, Flags);
1930 std::optional<unsigned> Flags = std::nullopt) {
1931 return buildInstr(TargetOpcode::G_UREM, {Dst}, {Src0, Src1}, Flags);
1936 std::optional<unsigned> Flags = std::nullopt) {
1937 return buildInstr(TargetOpcode::G_FMUL, {Dst}, {Src0, Src1}, Flags);
1942 std::optional<unsigned> Flags = std::nullopt) {
1943 return buildInstr(TargetOpcode::G_FMINNUM, {Dst}, {Src0, Src1}, Flags);
1948 std::optional<unsigned> Flags = std::nullopt) {
1949 return buildInstr(TargetOpcode::G_FMAXNUM, {Dst}, {Src0, Src1}, Flags);
1954 std::optional<unsigned> Flags = std::nullopt) {
1955 return buildInstr(TargetOpcode::G_FMINNUM_IEEE, {Dst}, {Src0, Src1}, Flags);
1960 std::optional<unsigned> Flags = std::nullopt) {
1961 return buildInstr(TargetOpcode::G_FMAXNUM_IEEE, {Dst}, {Src0, Src1}, Flags);
1966 std::optional<unsigned> Flags = std::nullopt) {
1967 return buildInstr(TargetOpcode::G_SHL, {Dst}, {Src0, Src1}, Flags);
1972 std::optional<unsigned> Flags = std::nullopt) {
1973 return buildInstr(TargetOpcode::G_LSHR, {Dst}, {Src0, Src1}, Flags);
1978 std::optional<unsigned> Flags = std::nullopt) {
1979 return buildInstr(TargetOpcode::G_ASHR, {Dst}, {Src0, Src1}, Flags);
1994 const SrcOp &Src1) {
1995 return buildInstr(TargetOpcode::G_AND, {Dst}, {Src0, Src1});
2010 std::optional<unsigned> Flags = std::nullopt) {
2011 return buildInstr(TargetOpcode::G_OR, {Dst}, {Src0, Src1}, Flags);
2016 const SrcOp &Src1) {
2017 return buildInstr(TargetOpcode::G_XOR, {Dst}, {Src0, Src1});
2024 auto NegOne = buildConstant(Dst.getLLTTy(*getMRI()), -1);
2025 return buildInstr(TargetOpcode::G_XOR, {Dst}, {Src0, NegOne});
2032 auto Zero = buildConstant(Dst.getLLTTy(*getMRI()), 0);
2033 return buildInstr(TargetOpcode::G_SUB, {Dst}, {Zero, Src0});
2038 return buildInstr(TargetOpcode::G_CTPOP, {Dst}, {Src0});
2043 return buildInstr(TargetOpcode::G_CTLZ, {Dst}, {Src0});
2048 return buildInstr(TargetOpcode::G_CTLZ_ZERO_UNDEF, {Dst}, {Src0});
2053 return buildInstr(TargetOpcode::G_CTTZ, {Dst}, {Src0});
2058 return buildInstr(TargetOpcode::G_CTTZ_ZERO_UNDEF, {Dst}, {Src0});
2063 return buildInstr(TargetOpcode::G_BSWAP, {Dst}, {Src0});
2069 std::optional<unsigned> Flags = std::nullopt) {
2070 return buildInstr(TargetOpcode::G_FADD, {Dst}, {Src0, Src1}, Flags);
2076 std::optional<unsigned> Flags = std::nullopt) {
2077 return buildInstr(TargetOpcode::G_STRICT_FADD, {Dst}, {Src0, Src1}, Flags);
2083 std::optional<unsigned> Flags = std::nullopt) {
2084 return buildInstr(TargetOpcode::G_FSUB, {Dst}, {Src0, Src1}, Flags);
2090 std::optional<unsigned> Flags = std::nullopt) {
2091 return buildInstr(TargetOpcode::G_FDIV, {Dst}, {Src0, Src1}, Flags);
2097 std::optional<unsigned> Flags = std::nullopt) {
2098 return buildInstr(TargetOpcode::G_FMA, {Dst}, {Src0, Src1, Src2}, Flags);
2104 std::optional<unsigned> Flags = std::nullopt) {
2105 return buildInstr(TargetOpcode::G_FMAD, {Dst}, {Src0, Src1, Src2}, Flags);
2110 std::optional<unsigned> Flags = std::nullopt) {
2111 return buildInstr(TargetOpcode::G_FNEG, {Dst}, {Src0}, Flags);
2116 std::optional<unsigned> Flags = std::nullopt) {
2117 return buildInstr(TargetOpcode::G_FABS, {Dst}, {Src0}, Flags);
2123 std::optional<unsigned> Flags = std::nullopt) {
2124 return buildInstr(TargetOpcode::G_FCANONICALIZE, {Dst}, {Src0}, Flags);
2130 std::optional<unsigned> Flags = std::nullopt) {
2131 return buildInstr(TargetOpcode::G_INTRINSIC_TRUNC, {Dst}, {Src0}, Flags);
2137 std::optional<unsigned> Flags = std::nullopt) {
2138 return buildInstr(TargetOpcode::G_FFLOOR, {Dst}, {Src0}, Flags);
2143 std::optional<unsigned> Flags = std::nullopt) {
2144 return buildInstr(TargetOpcode::G_FLOG, {Dst}, {Src}, Flags);
2149 std::optional<unsigned> Flags = std::nullopt) {
2150 return buildInstr(TargetOpcode::G_FLOG2, {Dst}, {Src}, Flags);
2155 std::optional<unsigned> Flags = std::nullopt) {
2156 return buildInstr(TargetOpcode::G_FEXP2, {Dst}, {Src}, Flags);
2162 std::optional<unsigned> Flags = std::nullopt) {
2163 return buildInstr(TargetOpcode::G_FPOW, {Dst}, {Src0, Src1}, Flags);
2169 std::optional<unsigned> Flags = std::nullopt) {
2170 return buildInstr(TargetOpcode::G_FLDEXP, {Dst}, {Src0, Src1}, Flags);
2176 std::optional<unsigned> Flags = std::nullopt) {
2177 return buildInstr(TargetOpcode::G_FFREXP, {Fract, Exp}, {Src}, Flags);
2183 std::optional<unsigned> Flags = std::nullopt) {
2184 return buildInstr(TargetOpcode::G_FSINCOS, {Sin, Cos}, {Src}, Flags);
2189 const SrcOp &Src1) {
2190 return buildInstr(TargetOpcode::G_FCOPYSIGN, {Dst}, {Src0, Src1});
2195 return buildInstr(TargetOpcode::G_UITOFP, {Dst}, {Src0});
2200 return buildInstr(TargetOpcode::G_SITOFP, {Dst}, {Src0});
2205 return buildInstr(TargetOpcode::G_FPTOUI, {Dst}, {Src0});
2210 return buildInstr(TargetOpcode::G_FPTOSI, {Dst}, {Src0});
2215 return buildInstr(TargetOpcode::G_FPTOUI_SAT, {Dst}, {Src0});
2220 return buildInstr(TargetOpcode::G_FPTOSI_SAT, {Dst}, {Src0});
2226 std::optional<unsigned> Flags = std::nullopt) {
2227 return buildInstr(TargetOpcode::G_INTRINSIC_ROUNDEVEN, {Dst}, {Src0},
2233 const SrcOp &Src1) {
2234 return buildInstr(TargetOpcode::G_SMIN, {Dst}, {Src0, Src1});
2239 const SrcOp &Src1) {
2240 return buildInstr(TargetOpcode::G_SMAX, {Dst}, {Src0, Src1});
2245 const SrcOp &Src1) {
2246 return buildInstr(TargetOpcode::G_UMIN, {Dst}, {Src0, Src1});
2251 const SrcOp &Src1) {
2252 return buildInstr(TargetOpcode::G_UMAX, {Dst}, {Src0, Src1});
2257 return buildInstr(TargetOpcode::G_ABS, {Dst}, {Src});
2273 const SrcOp &ScalarIn,
2274 const SrcOp &VecIn) {
2275 return buildInstr(TargetOpcode::G_VECREDUCE_SEQ_FADD, {Dst},
2276 {ScalarIn, {VecIn}});
2284 const SrcOp &ScalarIn,
2285 const SrcOp &VecIn) {
2286 return buildInstr(TargetOpcode::G_VECREDUCE_SEQ_FMUL, {Dst},
2287 {ScalarIn, {VecIn}});
2295 const SrcOp &ScalarIn,
2296 const SrcOp &VecIn) {
2297 return buildInstr(TargetOpcode::G_VECREDUCE_FADD, {Dst}, {ScalarIn, VecIn});
2305 const SrcOp &ScalarIn,
2306 const SrcOp &VecIn) {
2307 return buildInstr(TargetOpcode::G_VECREDUCE_FMUL, {Dst}, {ScalarIn, VecIn});
2312 return buildInstr(TargetOpcode::G_VECREDUCE_FMAX, {Dst}, {Src});
2317 return buildInstr(TargetOpcode::G_VECREDUCE_FMIN, {Dst}, {Src});
2323 return buildInstr(TargetOpcode::G_VECREDUCE_FMAXIMUM, {Dst}, {Src});
2329 return buildInstr(TargetOpcode::G_VECREDUCE_FMINIMUM, {Dst}, {Src});
2334 return buildInstr(TargetOpcode::G_VECREDUCE_ADD, {Dst}, {Src});
2339 return buildInstr(TargetOpcode::G_VECREDUCE_MUL, {Dst}, {Src});
2344 return buildInstr(TargetOpcode::G_VECREDUCE_AND, {Dst}, {Src});
2349 return buildInstr(TargetOpcode::G_VECREDUCE_OR, {Dst}, {Src});
2354 return buildInstr(TargetOpcode::G_VECREDUCE_XOR, {Dst}, {Src});
2359 return buildInstr(TargetOpcode::G_VECREDUCE_SMAX, {Dst}, {Src});
2364 return buildInstr(TargetOpcode::G_VECREDUCE_SMIN, {Dst}, {Src});
2369 return buildInstr(TargetOpcode::G_VECREDUCE_UMAX, {Dst}, {Src});
2374 return buildInstr(TargetOpcode::G_VECREDUCE_UMIN, {Dst}, {Src});
2379 const SrcOp &SrcPtr,
2383 auto MIB = buildInstr(
2384 Opcode, {}, {DstPtr, SrcPtr,
Size,
SrcOp(INT64_C(0) )});
2393 return buildMemTransferInst(TargetOpcode::G_MEMCPY, DstPtr, SrcPtr,
Size,
2399 return buildInstr(
Debug ? TargetOpcode::G_DEBUGTRAP : TargetOpcode::G_TRAP);
2405 return buildInstr(TargetOpcode::G_SBFX, {Dst}, {Src, LSB, Width});
2411 return buildInstr(TargetOpcode::G_UBFX, {Dst}, {Src, LSB, Width});
2417 return buildInstr(TargetOpcode::G_ROTR, {Dst}, {Src, Amt});
2423 return buildInstr(TargetOpcode::G_ROTL, {Dst}, {Src, Amt});
2428 return buildInstr(TargetOpcode::G_BITREVERSE, {Dst}, {Src});
2433 return buildInstr(TargetOpcode::G_GET_FPENV, {Dst}, {});
2438 return buildInstr(TargetOpcode::G_SET_FPENV, {}, {Src});
2443 return buildInstr(TargetOpcode::G_RESET_FPENV, {}, {});
2448 return buildInstr(TargetOpcode::G_GET_FPMODE, {Dst}, {});
2453 return buildInstr(TargetOpcode::G_SET_FPMODE, {}, {Src});
2458 return buildInstr(TargetOpcode::G_RESET_FPMODE, {}, {});
2463 return buildInstr(TargetOpcode::G_GET_ROUNDING, {Dst}, {});
2468 std::optional<unsigned> Flags = std::nullopt);
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
Analysis containing CSE Info
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
This contains common code to allow clients to notify changes to machine instr.
Module.h This file contains the declarations for the Module class.
uint64_t IntrinsicInst * II
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
The address of a basic block.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
ConstantFP - Floating Point Values [float, double].
This is the shared class of boolean and integer constants.
A signed pointer, in the ptrauth sense.
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
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)
Abstract class that contains various methods for clients to notify about changes.
This is an important class for using LLVM in a threaded context.
Helper class to build MachineInstr.
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 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.
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 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 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.
void stopObservingChanges()
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.
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 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.
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.
MachineFunction & getMF()
Getter for the function we currently build.
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 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.
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 buildFCopysign(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_FCOPYSIGN Op0, Op1.
MachineInstrBuilder buildSSubo(const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
Build and insert Res, CarryOut = G_SUBO Op0, Op1.
bool isObservingChanges() const
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.
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.
MDNode * getMMRAMetadata()
Get the current instruction's MMRA metadata.
const DataLayout & getDataLayout() const
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)
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 & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addPredicate(CmpInst::Predicate Pred) const
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
const MachineOperand & getOperand(unsigned i) const
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.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
SrcOp(const MachineInstrBuilder &MIB)
SrcOp(const CmpInst::Predicate P)
MachineInstrBuilder SrcMIB
CmpInst::Predicate getPredicate() const
SrcType getSrcOpKind() 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...
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
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.
uint64_t value() const
This is a hole in the type system and should not be abused.
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.