31 this->InsertedInstr =
nullptr;
38 "Basic block is in a different function");
50 "Basic block is in a different function");
57 InsertedInstr = Inserted;
61 InsertedInstr =
nullptr;
97 "address space mismatch");
99 return buildInstr(TargetOpcode::G_GLOBAL_VALUE)
107 "invalid operand type");
132 "invalid operand type");
145 "invalid operand type");
223 unsigned Op0,
unsigned Op1,
240 validateTruncExt(Res, Op,
true);
245 validateTruncExt(Res, Op,
true);
250 validateTruncExt(Res, Op,
true);
256 unsigned Opcode = TargetOpcode::COPY;
258 Opcode = TargetOpcode::G_SEXT;
260 Opcode = TargetOpcode::G_TRUNC;
269 assert(Results.
size() == Indices.
size() &&
"inconsistent number of regs");
270 assert(!Results.
empty() &&
"invalid trivial extract");
272 "extract offsets must be in ascending order");
275 for (
auto Res : Results)
279 auto MIB =
BuildMI(
getMF(), DL, getTII().
get(TargetOpcode::G_EXTRACT));
280 for (
auto Res : Results)
285 for (
auto Idx : Indices)
301 assert(!Ops.
empty() &&
"invalid trivial sequence");
303 "sequence offsets must be in ascending order");
312 for (
unsigned i = 0;
i < Ops.size(); ++
i) {
314 MIB.addImm(Indices[i]);
321 bool HasSideEffects) {
323 buildInstr(HasSideEffects ? TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS
324 : TargetOpcode::G_INTRINSIC);
327 MIB.addIntrinsicID(ID);
332 validateTruncExt(Res, Op,
false);
337 validateTruncExt(Res, Op,
false);
342 unsigned Res,
unsigned Op0,
364 unsigned Res,
unsigned Op0,
368 "invalid operand type");
388 unsigned Op0,
unsigned Op1) {
392 "invalid operand type");
411 void MachineIRBuilder::validateTruncExt(
unsigned Dst,
unsigned Src,
418 assert(SrcTy.
isVector() &&
"mismatched cast between vecot and non-vector");
420 "different number of elements in a trunc/ext");
426 "invalid narrowing extend");
429 "invalid widening trunc");
MachineBasicBlock & getMBB()
Getter for the basic block we currently build.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
MachineInstrBuilder buildGEP(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_GEP Op0, Op1.
LLT getType(unsigned VReg) const
Get the low-level type of VReg or LLT{} if VReg is not a generic (target independent) virtual registe...
MachineInstrBuilder buildZExt(unsigned Res, unsigned Op)
Build and insert Res<def> = G_ZEXT Op.
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
Function Alias Analysis Results
MachineInstrBuilder buildTrunc(unsigned Res, unsigned Op)
Build and insert Res<def> = G_TRUNC Op.
MachineInstrBundleIterator< MachineInstr > iterator
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
MachineInstrBuilder buildSub(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_SUB Op0, Op1.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
MachineInstrBuilder buildAnyExt(unsigned Res, unsigned Op)
Build and insert Res<def> = G_ANYEXT Op0.
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
MachineInstrBuilder buildFPTrunc(unsigned Res, unsigned Op)
Build and insert Res<def> = G_FPTRUNC Op.
MachineInstrBuilder buildSelect(unsigned Res, unsigned Tst, unsigned Op0, unsigned Op1)
Build and insert a Res = G_SELECT Tst, Op0, Op1.
MachineInstrBuilder buildFCmp(CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
Build and insert a Res = G_FCMP PredOp0, Op1.
MachineInstrBuilder buildStore(unsigned Val, unsigned Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
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.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
unsigned getAddressSpace() const
const APInt & getValue() const
Return the constant as an APInt value reference.
MachineInstrBuilder buildFConstant(unsigned Res, const ConstantFP &Val)
Build and insert Res = G_FCONSTANT Val.
MachineInstrBuilder buildExtract(ArrayRef< unsigned > Results, ArrayRef< uint64_t > Indices, unsigned Src)
Build and insert `Res0<def>, ...
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
MachineFunction & getMF()
Getter for the function we currently build.
void recordInsertions(std::function< void(MachineInstr *)> InsertedInstr)
Control where instructions we create are recorded (typically for visiting again later during legaliza...
size_t size() const
size - Get the array size.
const MachineBasicBlock * getParent() const
MachineBasicBlock::iterator getInsertPt()
Current insertion point for new instructions.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
MachineInstrBuilder buildBr(MachineBasicBlock &BB)
Build and insert G_BR Dest.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
ConstantFP - Floating Point Values [float, double].
MachineInstrBuilder buildIntrinsic(Intrinsic::ID ID, unsigned Res, bool HasSideEffects)
Build and insert either a G_INTRINSIC (if HasSideEffects is false) or G_INTRINSIC_W_SIDE_EFFECTS inst...
bool isIntPredicate() const
MachineInstrBuilder buildICmp(CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
Build and insert a Res = G_ICMP Pred, Op0, Op1.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
const MachineInstrBuilder & addPredicate(CmpInst::Predicate Pred) const
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
self_iterator getIterator()
void setMF(MachineFunction &)
Setters for the insertion point.
bool empty() const
empty - Check if the array is empty.
MachineInstrBuilder buildSExtOrTrunc(unsigned Res, unsigned Op)
Build and insert Res<def> = G_SEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing ...
MachineInstrBuilder buildUAdde(unsigned Res, unsigned CarryOut, unsigned Op0, unsigned Op1, unsigned CarryIn)
Build and insert Res<def>, CarryOut<def> = G_UADDE Op0, Op1, CarryIn.
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
void stopRecordingInsertions()
MachineInstrBuilder buildFrameIndex(unsigned Res, int Idx)
Build and insert Res<def> = G_FRAME_INDEX Idx.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
This is the shared class of boolean and integer constants.
MachineInstrBuilder buildCopy(unsigned Res, unsigned Op)
Build and insert Res<def> = COPY Op.
const MachineInstrBuilder & addCImm(const ConstantInt *Val) const
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.
const MachineInstrBuilder & addFrameIndex(int Idx) const
This file declares the MachineIRBuilder class.
MachineInstrBuilder buildSExt(unsigned Res, unsigned Op)
Build and insert Res<def> = G_SEXT Op.
bool isFPPredicate() const
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
MachineInstrBuilder buildSequence(unsigned Res, ArrayRef< unsigned > Ops, ArrayRef< uint64_t > Indices)
Build and insert Res<def> = G_SEQUENCE Op0, Idx0...
Representation of each machine instruction.
PointerType * getType() const
Global values are always pointers.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MachineInstrBuilder buildAdd(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_ADD Op0, Op1.
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
MachineInstrBuilder buildConstant(unsigned Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
MachineInstrBuilder buildMul(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_MUL Op0, Op1.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
virtual const TargetInstrInfo * getInstrInfo() const
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
MachineInstrBuilder buildLoad(unsigned Res, unsigned Addr, MachineMemOperand &MMO)
Build and insert Res<def> = G_LOAD Addr, MMO.
print Print MemDeps of function
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
MachineInstrBuilder buildGlobalValue(unsigned Res, const GlobalValue *GV)
Build and insert Res<def> = G_GLOBAL_VALUE GV.
MachineInstrBuilder buildBrCond(unsigned Tst, MachineBasicBlock &BB)
Build and insert G_BRCOND Tst, Dest.