LLVM  6.0.0svn
Public Member Functions | List of all members
llvm::MachineIRBuilder Class Reference

Helper class to build MachineInstr. More...

#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"

Public Member Functions

 MachineIRBuilder ()=default
 Some constructors for easy use. More...
 
 MachineIRBuilder (MachineFunction &MF)
 
 MachineIRBuilder (MachineInstr &MI)
 
MachineFunctiongetMF ()
 Getter for the function we currently build. More...
 
MachineBasicBlockgetMBB ()
 Getter for the basic block we currently build. More...
 
MachineBasicBlock::iterator getInsertPt ()
 Current insertion point for new instructions. More...
 
void setInsertPt (MachineBasicBlock &MBB, MachineBasicBlock::iterator II)
 Set the insertion point before the specified position. More...
 
void setDebugLoc (const DebugLoc &DL)
 Set the debug location to DL for all the next build instructions. More...
 
DebugLoc getDebugLoc ()
 Get the current instruction's debug location. More...
 
MachineInstrBuilder buildInstr (unsigned Opcode)
 Build and insert <empty> = Opcode <empty>. More...
 
template<typename DstTy , typename... UseArgsTy>
MachineInstrBuilder buildInstr (unsigned Opc, DstTy &&Ty, UseArgsTy &&... Args)
 DAG like Generic method for building arbitrary instructions as above. More...
 
MachineInstrBuilder buildInstrNoInsert (unsigned Opcode)
 Build but don't insert <empty> = Opcode <empty>. More...
 
MachineInstrBuilder insertInstr (MachineInstrBuilder MIB)
 Insert an existing instruction at the insertion point. More...
 
MachineInstrBuilder buildDirectDbgValue (unsigned Reg, const MDNode *Variable, const MDNode *Expr)
 Build and insert a DBG_VALUE instruction expressing the fact that the associated Variable lives in Reg (suitably modified by Expr). More...
 
MachineInstrBuilder buildIndirectDbgValue (unsigned Reg, const MDNode *Variable, const MDNode *Expr)
 Build and insert a DBG_VALUE instruction expressing the fact that the associated Variable lives in memory at Reg (suitably modified by Expr). More...
 
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 the stack slot specified by FI (suitably modified by Expr). More...
 
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 by Expr). More...
 
MachineInstrBuilder buildFrameIndex (unsigned Res, int Idx)
 Build and insert Res<def> = G_FRAME_INDEX Idx. More...
 
MachineInstrBuilder buildGlobalValue (unsigned Res, const GlobalValue *GV)
 Build and insert Res<def> = G_GLOBAL_VALUE GV. More...
 
MachineInstrBuilder buildAdd (unsigned Res, unsigned Op0, unsigned Op1)
 Build and insert Res<def> = G_ADD Op0, Op1. More...
 
template<typename DstTy , typename... UseArgsTy>
MachineInstrBuilder buildAdd (DstTy &&Ty, UseArgsTy &&... UseArgs)
 
MachineInstrBuilder buildSub (unsigned Res, unsigned Op0, unsigned Op1)
 Build and insert Res<def> = G_SUB Op0, Op1. More...
 
MachineInstrBuilder buildMul (unsigned Res, unsigned Op0, unsigned Op1)
 Build and insert Res<def> = G_MUL Op0, Op1. More...
 
MachineInstrBuilder buildGEP (unsigned Res, unsigned Op0, unsigned Op1)
 Build and insert Res<def> = G_GEP Op0, Op1. More...
 
Optional< MachineInstrBuildermaterializeGEP (unsigned &Res, unsigned Op0, const LLT &ValueTy, uint64_t Value)
 Materialize and insert Res<def> = G_GEP Op0, (G_CONSTANT Value) More...
 
MachineInstrBuilder buildPtrMask (unsigned Res, unsigned Op0, uint32_t NumBits)
 Build and insert Res<def> = G_PTR_MASK Op0, NumBits. More...
 
MachineInstrBuilder buildUAdde (unsigned Res, unsigned CarryOut, unsigned Op0, unsigned Op1, unsigned CarryIn)
 Build and insert Res<def>, CarryOut<def> = G_UADDE Op0, Op1, CarryIn. More...
 
template<typename DstTy , typename... UseArgsTy>
MachineInstrBuilder buildAnd (DstTy &&Dst, UseArgsTy &&... UseArgs)
 Build and insert Res<def> = G_AND Op0, Op1. More...
 
MachineInstrBuilder buildAnd (unsigned Res, unsigned Op0, unsigned Op1)
 
MachineInstrBuilder buildOr (unsigned Res, unsigned Op0, unsigned Op1)
 Build and insert Res<def> = G_OR Op0, Op1. More...
 
MachineInstrBuilder buildAnyExt (unsigned Res, unsigned Op)
 Build and insert Res<def> = G_ANYEXT Op0. More...
 
template<typename DstType , typename ArgType >
MachineInstrBuilder buildAnyExt (DstType &&Res, ArgType &&Arg)
 
MachineInstrBuilder buildSExt (unsigned Res, unsigned Op)
 Build and insert Res<def> = G_SEXT Op. More...
 
MachineInstrBuilder buildZExt (unsigned Res, unsigned Op)
 Build and insert Res<def> = G_ZEXT Op. More...
 
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 sizes of Res and Op. More...
 
MachineInstrBuilder buildZExtOrTrunc (unsigned Res, unsigned Op)
 Build and insert Res<def> = G_ZEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes of Res and Op. More...
 
template<typename DstTy , typename UseArgTy >
MachineInstrBuilder buildAnyExtOrTrunc (DstTy &&Dst, UseArgTy &&Use)
 Res = COPY Op depending on the differing sizes of Res and Op. More...
 
MachineInstrBuilder buildAnyExtOrTrunc (unsigned Res, unsigned Op)
 
MachineInstrBuilder buildExtOrTrunc (unsigned ExtOpc, unsigned Res, unsigned Op)
 Build and insert Res<def> = ExtOpc, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes of Res and Op. More...
 
MachineInstrBuilder buildCast (unsigned Dst, unsigned Src)
 Build and insert an appropriate cast between two registers of equal size. More...
 
MachineInstrBuilder buildBr (MachineBasicBlock &BB)
 Build and insert G_BR Dest. More...
 
MachineInstrBuilder buildBrCond (unsigned Tst, MachineBasicBlock &BB)
 Build and insert G_BRCOND Tst, Dest. More...
 
MachineInstrBuilder buildBrIndirect (unsigned Tgt)
 Build and insert G_BRINDIRECT Tgt. More...
 
MachineInstrBuilder buildConstant (unsigned Res, const ConstantInt &Val)
 Build and insert Res = G_CONSTANT Val. More...
 
MachineInstrBuilder buildConstant (unsigned Res, int64_t Val)
 Build and insert Res = G_CONSTANT Val. More...
 
template<typename DstType >
MachineInstrBuilder buildConstant (DstType &&Res, int64_t Val)
 
MachineInstrBuilder buildFConstant (unsigned Res, const ConstantFP &Val)
 Build and insert Res = G_FCONSTANT Val. More...
 
MachineInstrBuilder buildCopy (unsigned Res, unsigned Op)
 Build and insert Res<def> = COPY Op. More...
 
template<typename DstType , typename SrcType >
MachineInstrBuilder buildCopy (DstType &&Res, SrcType &&Src)
 
MachineInstrBuilder buildLoad (unsigned Res, unsigned Addr, MachineMemOperand &MMO)
 Build and insert Res<def> = G_LOAD Addr, MMO. More...
 
MachineInstrBuilder buildStore (unsigned Val, unsigned Addr, MachineMemOperand &MMO)
 Build and insert G_STORE Val, Addr, MMO. More...
 
MachineInstrBuilder buildExtract (unsigned Res, unsigned Src, uint64_t Index)
 Build and insert `Res0<def>, ... More...
 
MachineInstrBuilder buildUndef (unsigned Dst)
 Build and insert Res = IMPLICIT_DEF. More...
 
void buildSequence (unsigned Res, ArrayRef< unsigned > Ops, ArrayRef< uint64_t > Indices)
 Build and insert instructions to put Ops together at the specified p Indices to form a larger register. More...
 
MachineInstrBuilder buildMerge (unsigned Res, ArrayRef< unsigned > Ops)
 Build and insert Res<def> = G_MERGE_VALUES Op0, ... More...
 
MachineInstrBuilder buildUnmerge (ArrayRef< unsigned > Res, unsigned Op)
 Build and insert Res0<def>, ... More...
 
MachineInstrBuilder buildInsert (unsigned Res, unsigned Src, unsigned Op, unsigned Index)
 
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 instruction. More...
 
MachineInstrBuilder buildFPTrunc (unsigned Res, unsigned Op)
 Build and insert Res<def> = G_FPTRUNC Op. More...
 
MachineInstrBuilder buildTrunc (unsigned Res, unsigned Op)
 Build and insert Res<def> = G_TRUNC Op. More...
 
template<typename DstType , typename SrcType >
MachineInstrBuilder buildTrunc (DstType &&Res, SrcType &&Src)
 
MachineInstrBuilder buildICmp (CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
 Build and insert a Res = G_ICMP Pred, Op0, Op1. More...
 
MachineInstrBuilder buildFCmp (CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
 Build and insert a Res = G_FCMP PredOp0, Op1. More...
 
MachineInstrBuilder buildSelect (unsigned Res, unsigned Tst, unsigned Op0, unsigned Op1)
 Build and insert a Res = G_SELECT Tst, Op0, Op1. More...
 
MachineInstrBuilder buildInsertVectorElement (unsigned Res, unsigned Val, unsigned Elt, unsigned Idx)
 Build and insert Res<def> = G_INSERT_VECTOR_ELT Val, Elt, Idx. More...
 
MachineInstrBuilder buildExtractVectorElement (unsigned Res, unsigned Val, unsigned Idx)
 Build and insert Res<def> = G_EXTRACT_VECTOR_ELT Val, Idx. More...
 
Setters for the insertion point.

Set the MachineFunction where to build instructions.

void setMF (MachineFunction &)
 
void setMBB (MachineBasicBlock &MBB)
 Set the insertion point to the end of MBB. More...
 
void setInstr (MachineInstr &MI)
 Set the insertion point to before MI. More...
 
Control where instructions we create are recorded (typically for

visiting again later during legalization).

void recordInsertions (std::function< void(MachineInstr *)> InsertedInstr)
 
void stopRecordingInsertions ()
 

Detailed Description

Helper class to build MachineInstr.

It keeps internally the insertion point and debug location for all the new instructions we want to create. This information can be modify via the related setters.

Definition at line 39 of file MachineIRBuilder.h.

Constructor & Destructor Documentation

◆ MachineIRBuilder() [1/3]

llvm::MachineIRBuilder::MachineIRBuilder ( )
default

Some constructors for easy use.

◆ MachineIRBuilder() [2/3]

llvm::MachineIRBuilder::MachineIRBuilder ( MachineFunction MF)
inline

Definition at line 95 of file MachineIRBuilder.h.

References setMF().

◆ MachineIRBuilder() [3/3]

llvm::MachineIRBuilder::MachineIRBuilder ( MachineInstr MI)
inline

Definition at line 96 of file MachineIRBuilder.h.

References setInstr().

Member Function Documentation

◆ buildAdd() [1/2]

MachineInstrBuilder MachineIRBuilder::buildAdd ( unsigned  Res,
unsigned  Op0,
unsigned  Op1 
)

Build and insert Res<def> = G_ADD Op0, Op1.

G_ADD sets Res to the sum of integer parameters Op0 and Op1, truncated to their width.

Precondition
setBasicBlock or setMI must have been called.
Res, Op0 and Op1 must be generic virtual registers with the same (scalar or vector) type).
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 177 of file MachineIRBuilder.cpp.

Referenced by buildAdd(), buildInstr(), and llvm::LegalizerHelper::fewerElementsVector().

◆ buildAdd() [2/2]

template<typename DstTy , typename... UseArgsTy>
MachineInstrBuilder llvm::MachineIRBuilder::buildAdd ( DstTy &&  Ty,
UseArgsTy &&...  UseArgs 
)
inline

◆ buildAnd() [1/2]

template<typename DstTy , typename... UseArgsTy>
MachineInstrBuilder llvm::MachineIRBuilder::buildAnd ( DstTy &&  Dst,
UseArgsTy &&...  UseArgs 
)
inline

Build and insert Res<def> = G_AND Op0, Op1.

G_AND sets Res to the bitwise and of integer parameters Op0 and Op1.

Precondition
setBasicBlock or setMI must have been called.
Res, Op0 and Op1 must be generic virtual registers with the same (scalar or vector) type).
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 352 of file MachineIRBuilder.h.

References buildAnyExt(), and buildOr().

Referenced by llvm::LegalizerCombiner::tryCombineZExt().

◆ buildAnd() [2/2]

MachineInstrBuilder MachineIRBuilder::buildAnd ( unsigned  Res,
unsigned  Op0,
unsigned  Op1 
)

Definition at line 233 of file MachineIRBuilder.cpp.

◆ buildAnyExt() [1/2]

MachineInstrBuilder MachineIRBuilder::buildAnyExt ( unsigned  Res,
unsigned  Op 
)

Build and insert Res<def> = G_ANYEXT Op0.

G_ANYEXT produces a register of the specified width, with bits 0 to sizeof(Ty) * 8 set to Op. The remaining bits are unspecified (i.e. this is neither zero nor sign-extension). For a vector register, each element is extended individually.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type.
Op must be a generic virtual register with scalar or vector type.
Op must be smaller than Res
Returns
The newly created instruction.

Definition at line 334 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), and buildInstr().

Referenced by buildAnd(), buildAnyExt(), llvm::CallLowering::ValueHandler::extendRegister(), and llvm::LegalizerHelper::widenScalar().

◆ buildAnyExt() [2/2]

template<typename DstType , typename ArgType >
MachineInstrBuilder llvm::MachineIRBuilder::buildAnyExt ( DstType &&  Res,
ArgType &&  Arg 
)
inline

◆ buildAnyExtOrTrunc() [1/2]

template<typename DstTy , typename UseArgTy >
MachineInstrBuilder llvm::MachineIRBuilder::buildAnyExtOrTrunc ( DstTy &&  Dst,
UseArgTy &&  Use 
)
inline

Res = COPY Op depending on the differing sizes of Res and Op.

///

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type.
Op must be a generic virtual register with scalar or vector type.
Returns
The newly created instruction.

Definition at line 447 of file MachineIRBuilder.h.

References buildBr(), buildBrCond(), buildBrIndirect(), buildCast(), buildConstant(), and buildExtOrTrunc().

Referenced by llvm::LegalizerCombiner::tryCombineAnyExt(), llvm::LegalizerCombiner::tryCombineSExt(), llvm::LegalizerCombiner::tryCombineZExt(), and llvm::LegalizerHelper::widenScalar().

◆ buildAnyExtOrTrunc() [2/2]

MachineInstrBuilder MachineIRBuilder::buildAnyExtOrTrunc ( unsigned  Res,
unsigned  Op 
)

Definition at line 378 of file MachineIRBuilder.cpp.

References buildExtOrTrunc().

◆ buildBr()

MachineInstrBuilder MachineIRBuilder::buildBr ( MachineBasicBlock BB)

Build and insert G_BR Dest.

G_BR is an unconditional branch to Dest.

Precondition
setBasicBlock or setMI must have been called.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 243 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addMBB(), and buildInstr().

Referenced by buildAnyExtOrTrunc(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildBrCond()

MachineInstrBuilder MachineIRBuilder::buildBrCond ( unsigned  Tst,
MachineBasicBlock BB 
)

Build and insert G_BRCOND Tst, Dest.

G_BRCOND is a conditional branch to Dest.

Precondition
setBasicBlock or setMI must have been called.
Tst must be a generic virtual register with scalar type. At the beginning of legalization, this will be a single bit (s1). Targets with interesting flags registers may change this. For a wider type, whether the branch is taken must only depend on bit 0 (for now).
Returns
The newly created instruction.

Definition at line 287 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addMBB(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::MachineRegisterInfo::getType(), and llvm::LLT::isScalar().

Referenced by buildAnyExtOrTrunc(), llvm::IRTranslator::getAnalysisUsage(), and llvm::LegalizerHelper::widenScalar().

◆ buildBrIndirect()

MachineInstrBuilder MachineIRBuilder::buildBrIndirect ( unsigned  Tgt)

Build and insert G_BRINDIRECT Tgt.

G_BRINDIRECT is an indirect branch to Tgt.

Precondition
setBasicBlock or setMI must have been called.
Tgt must be a generic virtual register with pointer type.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 247 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::MachineRegisterInfo::getType(), and llvm::LLT::isPointer().

Referenced by buildAnyExtOrTrunc(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildCast()

MachineInstrBuilder MachineIRBuilder::buildCast ( unsigned  Dst,
unsigned  Src 
)

◆ buildConstant() [1/3]

MachineInstrBuilder MachineIRBuilder::buildConstant ( unsigned  Res,
const ConstantInt Val 
)

◆ buildConstant() [2/3]

MachineInstrBuilder MachineIRBuilder::buildConstant ( unsigned  Res,
int64_t  Val 
)

Build and insert Res = G_CONSTANT Val.

G_CONSTANT is an integer constant with the specified size and value.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar type.
Returns
The newly created instruction.

Definition at line 272 of file MachineIRBuilder.cpp.

References buildConstant(), llvm::IntegerType::get(), llvm::ConstantInt::get(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::LLT::getSizeInBits(), and llvm::MachineRegisterInfo::getType().

◆ buildConstant() [3/3]

template<typename DstType >
MachineInstrBuilder llvm::MachineIRBuilder::buildConstant ( DstType &&  Res,
int64_t  Val 
)
inline

Definition at line 523 of file MachineIRBuilder.h.

References buildConstant(), buildCopy(), and buildFConstant().

◆ buildConstDbgValue()

MachineInstrBuilder MachineIRBuilder::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 by Expr).

Definition at line 122 of file MachineIRBuilder.cpp.

References assert(), and buildInstr().

Referenced by buildInstr(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildCopy() [1/2]

MachineInstrBuilder MachineIRBuilder::buildCopy ( unsigned  Res,
unsigned  Op 
)

◆ buildCopy() [2/2]

template<typename DstType , typename SrcType >
MachineInstrBuilder llvm::MachineIRBuilder::buildCopy ( DstType &&  Res,
SrcType &&  Src 
)
inline

◆ buildDirectDbgValue()

MachineInstrBuilder MachineIRBuilder::buildDirectDbgValue ( unsigned  Reg,
const MDNode Variable,
const MDNode Expr 
)

Build and insert a DBG_VALUE instruction expressing the fact that the associated Variable lives in Reg (suitably modified by Expr).

Definition at line 87 of file MachineIRBuilder.cpp.

References assert(), llvm::BuildMI(), getMF(), and insertInstr().

Referenced by buildInstr(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildExtOrTrunc()

MachineInstrBuilder MachineIRBuilder::buildExtOrTrunc ( unsigned  ExtOpc,
unsigned  Res,
unsigned  Op 
)

Build and insert Res<def> = ExtOpc, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes of Res and Op.

///

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type.
Op must be a generic virtual register with scalar or vector type.
Returns
The newly created instruction.

Definition at line 350 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::LLT::getSizeInBits(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isScalar(), and llvm::LLT::isVector().

Referenced by buildAnyExtOrTrunc(), buildSExtOrTrunc(), and buildZExtOrTrunc().

◆ buildExtract()

MachineInstrBuilder MachineIRBuilder::buildExtract ( unsigned  Res,
unsigned  Src,
uint64_t  Index 
)

Build and insert `Res0<def>, ...

= G_EXTRACT Src, Idx0`.

Precondition
setBasicBlock or setMI must have been called.
Res and Src must be generic virtual registers.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 402 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addUse(), assert(), buildCast(), buildInstr(), llvm::LLT::getSizeInBits(), llvm::MachineRegisterInfo::getType(), and llvm::LLT::isValid().

Referenced by buildCopy(), llvm::IRTranslator::getAnalysisUsage(), llvm::AArch64CallLowering::lowerCall(), llvm::AArch64CallLowering::lowerReturn(), and llvm::LegalizerHelper::narrowScalar().

◆ buildExtractVectorElement()

MachineInstrBuilder MachineIRBuilder::buildExtractVectorElement ( unsigned  Res,
unsigned  Val,
unsigned  Idx 
)

Build and insert Res<def> = G_EXTRACT_VECTOR_ELT Val, Idx.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar type.
Val must be a generic virtual register with vector type.
Idx must be a generic virtual register with scalar type.
Returns
The newly created instruction.

Definition at line 642 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::LLT::getElementType(), llvm::LLT::getNumElements(), llvm::LLT::getSizeInBits(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isPointer(), llvm::LLT::isScalar(), and llvm::LLT::isVector().

Referenced by buildTrunc(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildFCmp()

MachineInstrBuilder MachineIRBuilder::buildFCmp ( CmpInst::Predicate  Pred,
unsigned  Res,
unsigned  Op0,
unsigned  Op1 
)

Build and insert a Res = G_FCMP PredOp0, Op1.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type. Typically this starts as s1 or <N x="" s1>="">.
Op0 and Op1 must be generic virtual registers with the same number of elements as Res (or scalar, if Res is scalar).
Pred must be a floating-point predicate.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 571 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addPredicate(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::LLT::getNumElements(), llvm::MachineRegisterInfo::getType(), llvm::CmpInst::isFPPredicate(), llvm::LLT::isScalar(), and llvm::LLT::isVector().

Referenced by buildTrunc(), llvm::IRTranslator::getAnalysisUsage(), and llvm::LegalizerHelper::widenScalar().

◆ buildFConstant()

MachineInstrBuilder MachineIRBuilder::buildFConstant ( unsigned  Res,
const ConstantFP Val 
)

Build and insert Res = G_FCONSTANT Val.

G_FCONSTANT is a floating-point constant with the specified size and value.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar type.
Returns
The newly created instruction.

Definition at line 280 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addFPImm(), assert(), buildInstr(), llvm::MachineRegisterInfo::getType(), and llvm::LLT::isScalar().

Referenced by buildConstant(), llvm::IRTranslator::getAnalysisUsage(), llvm::LegalizerHelper::lower(), and llvm::LegalizerHelper::widenScalar().

◆ buildFIDbgValue()

MachineInstrBuilder MachineIRBuilder::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 the stack slot specified by FI (suitably modified by Expr).

Definition at line 108 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addFrameIndex(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addMetadata(), assert(), and buildInstr().

Referenced by buildInstr().

◆ buildFPTrunc()

MachineInstrBuilder MachineIRBuilder::buildFPTrunc ( unsigned  Res,
unsigned  Op 
)

Build and insert Res<def> = G_FPTRUNC Op.

G_FPTRUNC converts a floating-point value into one with a smaller type.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type.
Op must be a generic virtual register with scalar or vector type.
Res must be smaller than Op
Returns
The newly created instruction.

Definition at line 544 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), and buildInstr().

Referenced by buildCopy(), and llvm::LegalizerHelper::widenScalar().

◆ buildFrameIndex()

MachineInstrBuilder MachineIRBuilder::buildFrameIndex ( unsigned  Res,
int  Idx 
)

Build and insert Res<def> = G_FRAME_INDEX Idx.

G_FRAME_INDEX materializes the address of an alloca value or other stack-based object.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with pointer type.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 145 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addFrameIndex(), assert(), buildInstr(), llvm::MachineRegisterInfo::getType(), and llvm::LLT::isPointer().

Referenced by llvm::AArch64CallLowering::AArch64CallLowering(), buildInstr(), llvm::IRTranslator::getAnalysisUsage(), llvm::X86CallLowering::lowerReturn(), and llvm::ARMCallLowering::lowerReturn().

◆ buildGEP()

MachineInstrBuilder MachineIRBuilder::buildGEP ( unsigned  Res,
unsigned  Op0,
unsigned  Op1 
)

Build and insert Res<def> = G_GEP Op0, Op1.

G_GEP adds Op1 bytes to the pointer specified by Op0, storing the resulting pointer in Res.

Precondition
setBasicBlock or setMI must have been called.
Res and Op0 must be generic virtual registers with pointer type.
Op1 must be a generic virtual register with scalar type.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 182 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isPointer(), and llvm::LLT::isScalar().

Referenced by llvm::AArch64CallLowering::AArch64CallLowering(), buildAdd(), llvm::IRTranslator::getAnalysisUsage(), isSupportedType(), llvm::AArch64LegalizerInfo::legalizeCustom(), llvm::AMDGPUCallLowering::lowerReturn(), materializeGEP(), and llvm::X86CallLowering::X86CallLowering().

◆ buildGlobalValue()

MachineInstrBuilder MachineIRBuilder::buildGlobalValue ( unsigned  Res,
const GlobalValue GV 
)

Build and insert Res<def> = G_GLOBAL_VALUE GV.

G_GLOBAL_VALUE materializes the address of the specified global into Res.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with pointer type in the same address space as GV.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 152 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addGlobalAddress(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::LLT::getAddressSpace(), llvm::PointerType::getAddressSpace(), llvm::GlobalValue::getType(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isPointer(), llvm::LLT::isScalar(), and llvm::LLT::isVector().

Referenced by buildInstr(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildICmp()

MachineInstrBuilder MachineIRBuilder::buildICmp ( CmpInst::Predicate  Pred,
unsigned  Res,
unsigned  Op0,
unsigned  Op1 
)

Build and insert a Res = G_ICMP Pred, Op0, Op1.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type. Typically this starts as s1 or <N x="" s1>="">.
Op0 and Op1 must be generic virtual registers with the same number of elements as Res. If Res is a scalar, Op0 must be either a scalar or pointer.
Pred must be an integer predicate.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 549 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addPredicate(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::LLT::getNumElements(), llvm::MachineRegisterInfo::getType(), llvm::CmpInst::isIntPredicate(), llvm::LLT::isPointer(), llvm::LLT::isScalar(), and llvm::LLT::isVector().

Referenced by buildTrunc(), llvm::IRTranslator::getAnalysisUsage(), llvm::ARMLegalizerInfo::legalizeCustom(), llvm::LegalizerHelper::lower(), and llvm::LegalizerHelper::widenScalar().

◆ buildIndirectDbgValue()

MachineInstrBuilder MachineIRBuilder::buildIndirectDbgValue ( unsigned  Reg,
const MDNode Variable,
const MDNode Expr 
)

Build and insert a DBG_VALUE instruction expressing the fact that the associated Variable lives in memory at Reg (suitably modified by Expr).

Definition at line 98 of file MachineIRBuilder.cpp.

References assert(), llvm::BuildMI(), getMF(), and insertInstr().

Referenced by buildInstr(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildInsert()

MachineInstrBuilder MachineIRBuilder::buildInsert ( unsigned  Res,
unsigned  Src,
unsigned  Op,
unsigned  Index 
)

◆ buildInsertVectorElement()

MachineInstrBuilder MachineIRBuilder::buildInsertVectorElement ( unsigned  Res,
unsigned  Val,
unsigned  Elt,
unsigned  Idx 
)

Build and insert Res<def> = G_INSERT_VECTOR_ELT Val, Elt, Idx.

Precondition
setBasicBlock or setMI must have been called.
Res and Val must be a generic virtual register
Elt and Idx must be a generic virtual register with scalar type.
Returns
The newly created instruction.

Definition at line 620 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::LLT::getElementType(), llvm::LLT::getNumElements(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isScalar(), and llvm::LLT::isVector().

Referenced by buildTrunc(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildInstr() [1/2]

MachineInstrBuilder MachineIRBuilder::buildInstr ( unsigned  Opcode)

◆ buildInstr() [2/2]

template<typename DstTy , typename... UseArgsTy>
MachineInstrBuilder llvm::MachineIRBuilder::buildInstr ( unsigned  Opc,
DstTy &&  Ty,
UseArgsTy &&...  Args 
)
inline

DAG like Generic method for building arbitrary instructions as above.

opcode for the instruction. Either LLT/TargetRegisterClass/unsigned types for Dst Variadic list of uses of types(unsigned/MachineInstrBuilder) Uses of type MachineInstrBuilder will perform getOperand(0).getReg() to convert to register.

Definition at line 166 of file MachineIRBuilder.h.

References llvm::MachineInstrBuilder::addDef(), llvm::AMDGPU::HSAMD::Kernel::Key::Args, buildAdd(), buildConstDbgValue(), buildDirectDbgValue(), buildFIDbgValue(), buildFrameIndex(), buildGlobalValue(), buildIndirectDbgValue(), buildInstr(), buildInstrNoInsert(), C, and insertInstr().

◆ buildInstrNoInsert()

MachineInstrBuilder MachineIRBuilder::buildInstrNoInsert ( unsigned  Opcode)

Build but don't insert <empty> = Opcode <empty>.

Precondition
setMF, setBasicBlock or setMI must have been called.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 73 of file MachineIRBuilder.cpp.

References llvm::BuildMI(), and getMF().

Referenced by buildInstr(), llvm::RegBankSelect::getAnalysisUsage(), llvm::X86CallLowering::lowerCall(), llvm::ARMCallLowering::lowerCall(), llvm::AArch64CallLowering::lowerCall(), llvm::X86CallLowering::lowerReturn(), llvm::ARMCallLowering::lowerReturn(), and llvm::AArch64CallLowering::lowerReturn().

◆ buildIntrinsic()

MachineInstrBuilder MachineIRBuilder::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 instruction.

Its first operand will be the result register definition unless Reg is NoReg (== 0). The second operand will be the intrinsic's ID.

Callers are expected to add the required definitions and uses afterwards.

Precondition
setBasicBlock or setMI must have been called.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 527 of file MachineIRBuilder.cpp.

References buildInstr().

Referenced by buildCopy(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildLoad()

MachineInstrBuilder MachineIRBuilder::buildLoad ( unsigned  Res,
unsigned  Addr,
MachineMemOperand MMO 
)

Build and insert Res<def> = G_LOAD Addr, MMO.

Loads the value stored at Addr. Puts the result in Res.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register.
Addr must be a generic virtual register with pointer type.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 294 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addMemOperand(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isPointer(), and llvm::LLT::isValid().

Referenced by llvm::AArch64CallLowering::AArch64CallLowering(), buildCopy(), llvm::IRTranslator::getAnalysisUsage(), llvm::AArch64LegalizerInfo::legalizeCustom(), llvm::X86CallLowering::lowerReturn(), llvm::ARMCallLowering::lowerReturn(), llvm::AMDGPUCallLowering::lowerReturn(), llvm::LegalizerHelper::narrowScalar(), and llvm::LegalizerHelper::widenScalar().

◆ buildMerge()

MachineInstrBuilder MachineIRBuilder::buildMerge ( unsigned  Res,
ArrayRef< unsigned Ops 
)

Build and insert Res<def> = G_MERGE_VALUES Op0, ...

G_MERGE_VALUES combines the input elements contiguously into a larger register.

Precondition
setBasicBlock or setMI must have been called.
The entire register Res (and no more) must be covered by the input registers.
The type of all Ops registers must be identical.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 467 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), assert(), buildCast(), buildInstr(), llvm::ArrayRef< T >::empty(), llvm::LLT::getSizeInBits(), and llvm::MachineRegisterInfo::getType().

Referenced by buildCopy(), buildSequence(), llvm::LegalizerHelper::fewerElementsVector(), llvm::IRTranslator::getAnalysisUsage(), llvm::X86CallLowering::lowerCall(), llvm::ARMCallLowering::lowerCall(), llvm::X86CallLowering::lowerFormalArguments(), llvm::ARMCallLowering::lowerFormalArguments(), llvm::ARMCallLowering::lowerReturn(), llvm::LegalizerHelper::narrowScalar(), and llvm::LegalizerCombiner::tryCombineMerges().

◆ buildMul()

MachineInstrBuilder MachineIRBuilder::buildMul ( unsigned  Res,
unsigned  Op0,
unsigned  Op1 
)

Build and insert Res<def> = G_MUL Op0, Op1.

G_MUL sets Res to the sum of integer parameters Op0 and Op1, truncated to their width.

Precondition
setBasicBlock or setMI must have been called.
Res, Op0 and Op1 must be generic virtual registers with the same (scalar or vector) type).
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 228 of file MachineIRBuilder.cpp.

Referenced by buildAdd(), llvm::IRTranslator::getAnalysisUsage(), and llvm::LegalizerHelper::lower().

◆ buildOr()

MachineInstrBuilder MachineIRBuilder::buildOr ( unsigned  Res,
unsigned  Op0,
unsigned  Op1 
)

Build and insert Res<def> = G_OR Op0, Op1.

G_OR sets Res to the bitwise or of integer parameters Op0 and Op1.

Precondition
setBasicBlock or setMI must have been called.
Res, Op0 and Op1 must be generic virtual registers with the same (scalar or vector) type).
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 238 of file MachineIRBuilder.cpp.

Referenced by buildAnd(), llvm::ARMLegalizerInfo::legalizeCustom(), and llvm::LegalizerHelper::narrowScalar().

◆ buildPtrMask()

MachineInstrBuilder MachineIRBuilder::buildPtrMask ( unsigned  Res,
unsigned  Op0,
uint32_t  NumBits 
)

Build and insert Res<def> = G_PTR_MASK Op0, NumBits.

G_PTR_MASK clears the low bits of a pointer operand without destroying its pointer properties. This has the effect of rounding the address down to a specified alignment in bits.

Precondition
setBasicBlock or setMI must have been called.
Res and Op0 must be generic virtual registers with pointer type.
NumBits must be an integer representing the number of low bits to be cleared in Op0.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 212 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::MachineRegisterInfo::getType(), and llvm::LLT::isPointer().

Referenced by buildAdd(), llvm::IRTranslator::getAnalysisUsage(), and llvm::AArch64LegalizerInfo::legalizeCustom().

◆ buildSelect()

MachineInstrBuilder MachineIRBuilder::buildSelect ( unsigned  Res,
unsigned  Tst,
unsigned  Op0,
unsigned  Op1 
)

Build and insert a Res = G_SELECT Tst, Op0, Op1.

Precondition
setBasicBlock or setMI must have been called.
Res, Op0 and Op1 must be generic virtual registers with the same type.
Tst must be a generic virtual register with scalar, pointer or vector type. If vector then it must have the same number of elements as the other parameters.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 595 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::LLT::getNumElements(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isPointer(), llvm::LLT::isScalar(), and llvm::LLT::isVector().

Referenced by buildTrunc(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildSequence()

void MachineIRBuilder::buildSequence ( unsigned  Res,
ArrayRef< unsigned Ops,
ArrayRef< uint64_t >  Indices 
)

Build and insert instructions to put Ops together at the specified p Indices to form a larger register.

If the types of the input registers are uniform and cover the entirity of Res then a G_MERGE_VALUES will be produced. Otherwise an IMPLICIT_DEF followed by a sequence of G_INSERT instructions.

Precondition
setBasicBlock or setMI must have been called.
The final element of the sequence must not extend past the end of the destination register.
The bits defined by each Op (derived from index and scalar size) must not overlap.
Indices must be in ascending order of bit position.

Definition at line 423 of file MachineIRBuilder.cpp.

References assert(), llvm::ArrayRef< T >::begin(), buildInsert(), buildMerge(), buildUndef(), llvm::MachineRegisterInfo::createGenericVirtualRegister(), llvm::ArrayRef< T >::empty(), llvm::ArrayRef< T >::end(), llvm::LLT::getSizeInBits(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isValid(), and llvm::ArrayRef< T >::size().

Referenced by buildCopy(), llvm::IRTranslator::getAnalysisUsage(), and llvm::AArch64CallLowering::lowerCall().

◆ buildSExt()

MachineInstrBuilder MachineIRBuilder::buildSExt ( unsigned  Res,
unsigned  Op 
)

Build and insert Res<def> = G_SEXT Op.

G_SEXT produces a register of the specified width, with bits 0 to sizeof(Ty) * 8 set to Op. The remaining bits are duplicated from the high bit of Op (i.e. 2s-complement sign extended).

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type.
Op must be a generic virtual register with scalar or vector type.
Op must be smaller than Res
Returns
The newly created instruction.

Definition at line 339 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), and buildInstr().

Referenced by buildAnyExt(), llvm::CallLowering::ValueHandler::extendRegister(), and llvm::LegalizerHelper::widenScalar().

◆ buildSExtOrTrunc()

MachineInstrBuilder MachineIRBuilder::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 sizes of Res and Op.

///

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type.
Op must be a generic virtual register with scalar or vector type.
Returns
The newly created instruction.

Definition at line 368 of file MachineIRBuilder.cpp.

References buildExtOrTrunc().

Referenced by buildAnyExt(), and llvm::IRTranslator::getAnalysisUsage().

◆ buildStore()

MachineInstrBuilder MachineIRBuilder::buildStore ( unsigned  Val,
unsigned  Addr,
MachineMemOperand MMO 
)

Build and insert G_STORE Val, Addr, MMO.

Stores the value Val to Addr.

Precondition
setBasicBlock or setMI must have been called.
Val must be a generic virtual register.
Addr must be a generic virtual register with pointer type.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 305 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addMemOperand(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isPointer(), and llvm::LLT::isValid().

Referenced by llvm::AArch64CallLowering::AArch64CallLowering(), buildCopy(), llvm::IRTranslator::getAnalysisUsage(), isSupportedType(), llvm::AArch64LegalizerInfo::legalizeCustom(), llvm::LegalizerHelper::narrowScalar(), llvm::LegalizerHelper::widenScalar(), and llvm::X86CallLowering::X86CallLowering().

◆ buildSub()

MachineInstrBuilder MachineIRBuilder::buildSub ( unsigned  Res,
unsigned  Op0,
unsigned  Op1 
)

Build and insert Res<def> = G_SUB Op0, Op1.

G_SUB sets Res to the sum of integer parameters Op0 and Op1, truncated to their width.

Precondition
setBasicBlock or setMI must have been called.
Res, Op0 and Op1 must be generic virtual registers with the same (scalar or vector) type).
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 223 of file MachineIRBuilder.cpp.

Referenced by buildAdd(), and llvm::LegalizerHelper::lower().

◆ buildTrunc() [1/2]

MachineInstrBuilder MachineIRBuilder::buildTrunc ( unsigned  Res,
unsigned  Op 
)

Build and insert Res<def> = G_TRUNC Op.

G_TRUNC extracts the low bits of a type. For a vector type each element is truncated independently before being packed into the destination.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type.
Op must be a generic virtual register with scalar or vector type.
Res must be smaller than Op
Returns
The newly created instruction.

Definition at line 539 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), and buildInstr().

Referenced by llvm::AArch64CallLowering::AArch64CallLowering(), buildCopy(), buildTrunc(), llvm::ARMLegalizerInfo::legalizeCustom(), llvm::X86CallLowering::lowerReturn(), llvm::ARMCallLowering::lowerReturn(), and llvm::LegalizerHelper::widenScalar().

◆ buildTrunc() [2/2]

template<typename DstType , typename SrcType >
MachineInstrBuilder llvm::MachineIRBuilder::buildTrunc ( DstType &&  Res,
SrcType &&  Src 
)
inline

◆ buildUAdde()

MachineInstrBuilder MachineIRBuilder::buildUAdde ( unsigned  Res,
unsigned  CarryOut,
unsigned  Op0,
unsigned  Op1,
unsigned  CarryIn 
)

Build and insert Res<def>, CarryOut<def> = G_UADDE Op0, Op1, CarryIn.

G_UADDE sets Res to Op0 + Op1 + CarryIn (truncated to the bit width) and sets CarryOut to 1 if the result overflowed in unsigned arithmetic.

Precondition
setBasicBlock or setMI must have been called.
Res, Op0 and Op1 must be generic virtual registers with the same scalar type.
CarryOut and CarryIn must be generic virtual registers with the same scalar type (typically s1)
Returns
The newly created instruction.

Definition at line 316 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), assert(), buildInstr(), llvm::MachineRegisterInfo::getType(), and llvm::LLT::isScalar().

Referenced by buildAdd(), and llvm::LegalizerHelper::narrowScalar().

◆ buildUndef()

MachineInstrBuilder MachineIRBuilder::buildUndef ( unsigned  Dst)

◆ buildUnmerge()

MachineInstrBuilder MachineIRBuilder::buildUnmerge ( ArrayRef< unsigned Res,
unsigned  Op 
)

Build and insert Res0<def>, ...

= G_UNMERGE_VALUES Op

G_UNMERGE_VALUES splits contiguous bits of the input into multiple

Precondition
setBasicBlock or setMI must have been called.
The entire register Res (and no more) must be covered by the input registers.
The type of all Res registers must be identical.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 490 of file MachineIRBuilder.cpp.

References assert(), buildInstr(), llvm::ArrayRef< T >::empty(), llvm::LLT::getSizeInBits(), and llvm::MachineRegisterInfo::getType().

Referenced by buildCopy(), isSupportedType(), llvm::ARMLegalizerInfo::legalizeCustom(), llvm::LegalizerHelper::legalizeInstrStep(), llvm::X86CallLowering::lowerCall(), llvm::ARMCallLowering::lowerCall(), llvm::X86CallLowering::lowerReturn(), llvm::LegalizerHelper::narrowScalar(), and llvm::LegalizerCombiner::tryCombineMerges().

◆ buildZExt()

MachineInstrBuilder MachineIRBuilder::buildZExt ( unsigned  Res,
unsigned  Op 
)

Build and insert Res<def> = G_ZEXT Op.

G_ZEXT produces a register of the specified width, with bits 0 to sizeof(Ty) * 8 set to Op. The remaining bits are 0. For a vector register, each element is extended individually.

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type.
Op must be a generic virtual register with scalar or vector type.
Op must be smaller than Res
Returns
The newly created instruction.

Definition at line 344 of file MachineIRBuilder.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), and buildInstr().

Referenced by buildAnyExt(), llvm::CallLowering::ValueHandler::extendRegister(), and llvm::LegalizerHelper::widenScalar().

◆ buildZExtOrTrunc()

MachineInstrBuilder MachineIRBuilder::buildZExtOrTrunc ( unsigned  Res,
unsigned  Op 
)

Build and insert Res<def> = G_ZEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes of Res and Op.

///

Precondition
setBasicBlock or setMI must have been called.
Res must be a generic virtual register with scalar or vector type.
Op must be a generic virtual register with scalar or vector type.
Returns
The newly created instruction.

Definition at line 373 of file MachineIRBuilder.cpp.

References buildExtOrTrunc().

Referenced by buildAnyExt(), and llvm::IRTranslator::getAnalysisUsage().

◆ getDebugLoc()

DebugLoc llvm::MachineIRBuilder::getDebugLoc ( )
inline

Get the current instruction's debug location.

Definition at line 148 of file MachineIRBuilder.h.

References buildInstr().

Referenced by llvm::IRTranslator::getAnalysisUsage().

◆ getInsertPt()

MachineBasicBlock::iterator llvm::MachineIRBuilder::getInsertPt ( )
inline

Current insertion point for new instructions.

Definition at line 113 of file MachineIRBuilder.h.

References function, MI, recordInsertions(), setInsertPt(), setInstr(), setMBB(), setMF(), and stopRecordingInsertions().

Referenced by insertInstr().

◆ getMBB()

MachineBasicBlock& llvm::MachineIRBuilder::getMBB ( )
inline

◆ getMF()

MachineFunction& llvm::MachineIRBuilder::getMF ( )
inline

◆ insertInstr()

MachineInstrBuilder MachineIRBuilder::insertInstr ( MachineInstrBuilder  MIB)

◆ materializeGEP()

Optional< MachineInstrBuilder > MachineIRBuilder::materializeGEP ( unsigned Res,
unsigned  Op0,
const LLT ValueTy,
uint64_t  Value 
)

Materialize and insert Res<def> = G_GEP Op0, (G_CONSTANT Value)

G_GEP adds Value bytes to the pointer specified by Op0, storing the resulting pointer in Res. If Value is zero then no G_GEP or G_CONSTANT will be created and

Precondition
Op0 will be assigned to Res.
setBasicBlock or setMI must have been called.
Op0 must be a generic virtual register with pointer type.
ValueTy must be a scalar type.
Res must be 0. This is to detect confusion between materializeGEP() and buildGEP().
Postcondition
Res will either be a new generic virtual register of the same type as Op0 or Op0 itself.
Returns
a MachineInstrBuilder for the newly created instruction.

Definition at line 195 of file MachineIRBuilder.cpp.

References assert(), buildConstant(), buildGEP(), llvm::MachineRegisterInfo::createGenericVirtualRegister(), llvm::MachineRegisterInfo::getType(), llvm::LLT::isScalar(), and llvm::None.

Referenced by buildAdd(), and llvm::LegalizerHelper::narrowScalar().

◆ recordInsertions()

void MachineIRBuilder::recordInsertions ( std::function< void(MachineInstr *)>  InsertedInstr)

Definition at line 56 of file MachineIRBuilder.cpp.

Referenced by getInsertPt(), and llvm::Legalizer::runOnMachineFunction().

◆ setDebugLoc()

void llvm::MachineIRBuilder::setDebugLoc ( const DebugLoc DL)
inline

Set the debug location to DL for all the next build instructions.

Definition at line 145 of file MachineIRBuilder.h.

Referenced by llvm::IRTranslator::getAnalysisUsage().

◆ setInsertPt()

void MachineIRBuilder::setInsertPt ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  II 
)

Set the insertion point before the specified position.

Precondition
MBB must be in getMF().
II must be a valid iterator in MBB.

Definition at line 48 of file MachineIRBuilder.cpp.

References assert(), getMF(), and llvm::MachineBasicBlock::getParent().

Referenced by getInsertPt(), and llvm::LegalizerHelper::widenScalar().

◆ setInstr()

void MachineIRBuilder::setInstr ( MachineInstr MI)

◆ setMBB()

void MachineIRBuilder::setMBB ( MachineBasicBlock MBB)

◆ setMF()

void MachineIRBuilder::setMF ( MachineFunction MF)

◆ stopRecordingInsertions()

void MachineIRBuilder::stopRecordingInsertions ( )

Definition at line 61 of file MachineIRBuilder.cpp.

Referenced by getInsertPt(), and llvm::Legalizer::runOnMachineFunction().


The documentation for this class was generated from the following files: