14 #ifndef LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H 15 #define LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H 31 class MachineFunction;
33 class TargetInstrInfo;
34 class GISelChangeObserver;
68 enum class DstType { Ty_LLT, Ty_Reg, Ty_RC };
100 assert(Ty == DstType::Ty_Reg &&
"Not a register");
127 enum class SrcType { Ty_Reg, Ty_MIB, Ty_Predicate };
134 case SrcType::Ty_Predicate:
137 case SrcType::Ty_Reg:
140 case SrcType::Ty_MIB:
141 MIB.
addUse(SrcMIB->getOperand(0).getReg());
148 case SrcType::Ty_Predicate:
150 case SrcType::Ty_Reg:
152 case SrcType::Ty_MIB:
153 return MRI.
getType(SrcMIB->getOperand(0).getReg());
160 case SrcType::Ty_Predicate:
162 case SrcType::Ty_Reg:
164 case SrcType::Ty_MIB:
165 return SrcMIB->getOperand(0).getReg();
172 case SrcType::Ty_Predicate:
202 void validateTruncExt(
const LLT &Dst,
const LLT &Src,
bool IsExtend);
204 void validateBinaryOp(
const LLT &Res,
const LLT &Op0,
const LLT &Op1);
206 void validateSelectOp(
const LLT &ResTy,
const LLT &TstTy,
const LLT &Op0Ty,
223 assert(State.
TII &&
"TargetInstrInfo is not set");
229 assert(State.
MF &&
"MachineFunction is not set");
245 assert(State.
MBB &&
"MachineBasicBlock is not set");
283 void stopObservingChanges();
429 const SrcOp &CarryIn);
731 unsigned Op,
unsigned Index);
744 bool HasSideEffects);
858 buildAtomicCmpXchgWithSuccess(
unsigned OldValRes,
unsigned SuccessRes,
859 unsigned Addr,
unsigned CmpVal,
unsigned NewVal,
877 unsigned CmpVal,
unsigned NewVal,
894 unsigned Addr,
unsigned Val,
1091 return buildInstr(TargetOpcode::G_ADD, {Dst}, {Src0, Src1}, Flags);
1108 return buildInstr(TargetOpcode::G_SUB, {Dst}, {Src0, Src1}, Flags);
1124 return buildInstr(TargetOpcode::G_MUL, {Dst}, {Src0, Src1}, Flags);
1139 const SrcOp &Src1) {
1140 return buildInstr(TargetOpcode::G_AND, {Dst}, {Src0, Src1});
1154 const SrcOp &Src1) {
1155 return buildInstr(TargetOpcode::G_OR, {Dst}, {Src0, Src1});
1164 #endif // LLVM_CODEGEN_GLOBALISEL_MACHINEIRBUILDER_H
MachineBasicBlock & getMBB()
const TargetRegisterClass * RC
void addDefToMIB(MachineRegisterInfo &MRI, MachineInstrBuilder &MIB) const
This class represents lattice values for constants.
DstType getDstOpKind() const
MachineIRBuilder(const MachineIRBuilderState &BState)
GISelChangeObserver * Observer
void setDebugLoc(const DebugLoc &DL)
Set the debug location to DL for all the next build instructions.
MachineInstrBuilder buildOr(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_OR Op0, Op1.
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
const MachineInstrBuilder & addPredicate(CmpInst::Predicate Pred) const
MachineIRBuilder(MachineInstr &MI)
The address of a basic block.
A description of a memory reference used in the backend.
GISelCSEInfo * getCSEInfo()
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
MachineBasicBlock::iterator II
SrcType getSrcOpKind() const
DstOp(const TargetRegisterClass *TRC)
SrcOp(const CmpInst::Predicate P)
MachineFunction & getMF()
Getter for the function we currently build.
MachineInstrBuilder buildSub(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
Build and insert Res = G_SUB Op0, Op1.
Analysis containing CSE Info
Optional< unsigned > getFlags() const
TargetInstrInfo - Interface to description of machine instruction set.
MachineBasicBlock::iterator getInsertPt()
Current insertion point for new instructions.
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.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Class which stores all the state required in a MachineIRBuilder.
ConstantFP - Floating Point Values [float, double].
Helper class to build MachineInstr.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
DebugLoc DL
Debug location to be set to any instruction we create.
MachineIRBuilder(MachineFunction &MF)
SrcOp(const MachineInstrBuilder &MIB)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
const MachineRegisterInfo * getMRI() const
MachineInstrBuilder buildMul(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
Build and insert Res = G_MUL Op0, Op1.
This is the shared class of boolean and integer constants.
const GISelCSEInfo * getCSEInfo() const
const TargetInstrInfo & getTII()
DebugLoc getDebugLoc()
Get the current instruction's debug location.
LLT getLLTTy(const MachineRegisterInfo &MRI) const
This file describes high level types that are used by several passes or APIs involved in the GlobalIS...
LLT getLLTTy(const MachineRegisterInfo &MRI) const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
MachineIRBuilderState & getState()
Getter for the State.
const TargetRegisterClass * getRegClass() const
MachineInstrBuilder buildAdd(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
Build and insert Res = G_ADD Op0, Op1.
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
CmpInst::Predicate getPredicate() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
static Value * buildGEP(IRBuilderTy &IRB, Value *BasePtr, SmallVectorImpl< Value *> &Indices, Twine NamePrefix)
Build a GEP out of a base pointer and indices.
MachineInstrBuilder buildAnd(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_AND Op0, Op1.
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
MachineFunction * MF
MachineFunction under construction.
const DebugLoc & getDL()
Getter for DebugLoc.
MachineInstrBuilder SrcMIB
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
MachineRegisterInfo * MRI
Information used to verify types are consistent and to create virtual registers.