LLVM  13.0.0git
Public Member Functions | List of all members
llvm::CSEMIRBuilder Class Reference

Defines a builder that does CSE of MachineInstructions using GISelCSEInfo. More...

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

Inheritance diagram for llvm::CSEMIRBuilder:
Inheritance graph
[legend]
Collaboration diagram for llvm::CSEMIRBuilder:
Collaboration graph
[legend]

Public Member Functions

MachineInstrBuilder buildInstr (unsigned Opc, ArrayRef< DstOp > DstOps, ArrayRef< SrcOp > SrcOps, Optional< unsigned > Flag=None) override
 
MachineInstrBuilder buildConstant (const DstOp &Res, const ConstantInt &Val) override
 Build and insert Res = G_CONSTANT Val. More...
 
MachineInstrBuilder buildFConstant (const DstOp &Res, const ConstantFP &Val) override
 Build and insert Res = G_FCONSTANT Val. More...
 
 MachineIRBuilder ()=default
 Some constructors for easy use. More...
 
 MachineIRBuilder (MachineFunction &MF)
 
 MachineIRBuilder (MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt)
 
 MachineIRBuilder (MachineInstr &MI)
 
 MachineIRBuilder (MachineInstr &MI, GISelChangeObserver &Observer)
 
 MachineIRBuilder (const MachineIRBuilderState &BState)
 
virtual MachineInstrBuilder buildConstant (const DstOp &Res, const ConstantInt &Val)
 Build and insert Res = G_CONSTANT Val. More...
 
MachineInstrBuilder buildConstant (const DstOp &Res, int64_t Val)
 Build and insert Res = G_CONSTANT Val. More...
 
MachineInstrBuilder buildConstant (const DstOp &Res, const APInt &Val)
 
virtual MachineInstrBuilder buildFConstant (const DstOp &Res, const ConstantFP &Val)
 Build and insert Res = G_FCONSTANT Val. More...
 
MachineInstrBuilder buildFConstant (const DstOp &Res, double Val)
 
MachineInstrBuilder buildFConstant (const DstOp &Res, const APFloat &Val)
 
- Public Member Functions inherited from llvm::MachineIRBuilder
 MachineIRBuilder ()=default
 Some constructors for easy use. More...
 
 MachineIRBuilder (MachineFunction &MF)
 
 MachineIRBuilder (MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt)
 
 MachineIRBuilder (MachineInstr &MI)
 
 MachineIRBuilder (MachineInstr &MI, GISelChangeObserver &Observer)
 
virtual ~MachineIRBuilder ()=default
 
 MachineIRBuilder (const MachineIRBuilderState &BState)
 
const TargetInstrInfogetTII ()
 
MachineFunctiongetMF ()
 Getter for the function we currently build. More...
 
const MachineFunctiongetMF () const
 
const DataLayoutgetDataLayout () const
 
const DebugLocgetDL ()
 Getter for DebugLoc. More...
 
MachineRegisterInfogetMRI ()
 Getter for MRI. More...
 
const MachineRegisterInfogetMRI () const
 
MachineIRBuilderStategetState ()
 Getter for the State. More...
 
const MachineBasicBlockgetMBB () const
 Getter for the basic block we currently build. More...
 
MachineBasicBlockgetMBB ()
 
GISelCSEInfogetCSEInfo ()
 
const GISelCSEInfogetCSEInfo () const
 
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 setCSEInfo (GISelCSEInfo *Info)
 
void setInstrAndDebugLoc (MachineInstr &MI)
 Set the insertion point to before MI, and set the debug loc to MI's loc. More...
 
void setChangeObserver (GISelChangeObserver &Observer)
 
void stopObservingChanges ()
 
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...
 
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 (Register 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 (Register 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 buildDbgLabel (const MDNode *Label)
 Build and insert a DBG_LABEL instructions specifying that Label is given. More...
 
MachineInstrBuilder buildDynStackAlloc (const DstOp &Res, const SrcOp &Size, Align Alignment)
 Build and insert Res = G_DYN_STACKALLOC Size, Align. More...
 
MachineInstrBuilder buildFrameIndex (const DstOp &Res, int Idx)
 Build and insert Res = G_FRAME_INDEX Idx. More...
 
MachineInstrBuilder buildGlobalValue (const DstOp &Res, const GlobalValue *GV)
 Build and insert Res = G_GLOBAL_VALUE GV. More...
 
MachineInstrBuilder buildPtrAdd (const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
 Build and insert Res = G_PTR_ADD Op0, Op1. More...
 
Optional< MachineInstrBuildermaterializePtrAdd (Register &Res, Register Op0, const LLT ValueTy, uint64_t Value)
 Materialize and insert Res = G_PTR_ADD Op0, (G_CONSTANT Value) More...
 
MachineInstrBuilder buildPtrMask (const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
 Build and insert Res = G_PTRMASK Op0, Op1. More...
 
MachineInstrBuilder buildMaskLowPtrBits (const DstOp &Res, const SrcOp &Op0, uint32_t NumBits)
 Build and insert Res = G_PTRMASK Op0, G_CONSTANT (1 << NumBits) - 1. More...
 
MachineInstrBuilder buildUAddo (const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
 Build and insert Res, CarryOut = G_UADDO Op0, Op1. More...
 
MachineInstrBuilder buildUSubo (const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
 Build and insert Res, CarryOut = G_USUBO Op0, Op1. More...
 
MachineInstrBuilder buildSAddo (const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
 Build and insert Res, CarryOut = G_SADDO Op0, Op1. More...
 
MachineInstrBuilder buildSSubo (const DstOp &Res, const DstOp &CarryOut, const SrcOp &Op0, const SrcOp &Op1)
 Build and insert Res, CarryOut = G_SUBO Op0, Op1. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
MachineInstrBuilder buildAnyExt (const DstOp &Res, const SrcOp &Op)
 Build and insert Res = G_ANYEXT Op0. More...
 
MachineInstrBuilder buildSExt (const DstOp &Res, const SrcOp &Op)
 Build and insert Res = G_SEXT Op. More...
 
MachineInstrBuilder buildSExtInReg (const DstOp &Res, const SrcOp &Op, int64_t ImmOp)
 Build and insert Res = G_SEXT_INREG Op, ImmOp. More...
 
MachineInstrBuilder buildFPExt (const DstOp &Res, const SrcOp &Op, Optional< unsigned > Flags=None)
 Build and insert Res = G_FPEXT Op. More...
 
MachineInstrBuilder buildPtrToInt (const DstOp &Dst, const SrcOp &Src)
 Build and insert a G_PTRTOINT instruction. More...
 
MachineInstrBuilder buildIntToPtr (const DstOp &Dst, const SrcOp &Src)
 Build and insert a G_INTTOPTR instruction. More...
 
MachineInstrBuilder buildBitcast (const DstOp &Dst, const SrcOp &Src)
 Build and insert Dst = G_BITCAST Src. More...
 
MachineInstrBuilder buildAddrSpaceCast (const DstOp &Dst, const SrcOp &Src)
 Build and insert Dst = G_ADDRSPACE_CAST Src. More...
 
unsigned getBoolExtOp (bool IsVec, bool IsFP) const
 
MachineInstrBuilder buildBoolExt (const DstOp &Res, const SrcOp &Op, bool IsFP)
 
MachineInstrBuilder buildZExt (const DstOp &Res, const SrcOp &Op)
 Build and insert Res = G_ZEXT Op. More...
 
MachineInstrBuilder buildSExtOrTrunc (const DstOp &Res, const SrcOp &Op)
 Build and insert Res = G_SEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes of Res and Op. More...
 
MachineInstrBuilder buildZExtOrTrunc (const DstOp &Res, const SrcOp &Op)
 Build and insert Res = G_ZEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes of Res and Op. More...
 
MachineInstrBuilder buildAnyExtOrTrunc (const DstOp &Res, const SrcOp &Op)
 Res = COPY Op depending on the differing sizes of Res and Op. More...
 
MachineInstrBuilder buildExtOrTrunc (unsigned ExtOpc, const DstOp &Res, const SrcOp &Op)
 Build and insert Res = ExtOpc, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes of Res and Op. More...
 
MachineInstrBuilder buildZExtInReg (const DstOp &Res, const SrcOp &Op, int64_t ImmOp)
 Build and inserts Res = G_AND Op, LowBitsSet(ImmOp) Since there is no G_ZEXT_INREG like G_SEXT_INREG, the instruction is emulated using G_AND. More...
 
MachineInstrBuilder buildCast (const DstOp &Dst, const SrcOp &Src)
 Build and insert an appropriate cast between two registers of equal size. More...
 
MachineInstrBuilder buildBr (MachineBasicBlock &Dest)
 Build and insert G_BR Dest. More...
 
MachineInstrBuilder buildBrCond (const SrcOp &Tst, MachineBasicBlock &Dest)
 Build and insert G_BRCOND Tst, Dest. More...
 
MachineInstrBuilder buildBrIndirect (Register Tgt)
 Build and insert G_BRINDIRECT Tgt. More...
 
MachineInstrBuilder buildBrJT (Register TablePtr, unsigned JTI, Register IndexReg)
 Build and insert G_BRJT TablePtr, JTI, IndexReg. More...
 
MachineInstrBuilder buildConstant (const DstOp &Res, int64_t Val)
 Build and insert Res = G_CONSTANT Val. More...
 
MachineInstrBuilder buildConstant (const DstOp &Res, const APInt &Val)
 
MachineInstrBuilder buildFConstant (const DstOp &Res, double Val)
 
MachineInstrBuilder buildFConstant (const DstOp &Res, const APFloat &Val)
 
MachineInstrBuilder buildCopy (const DstOp &Res, const SrcOp &Op)
 Build and insert Res = COPY Op. More...
 
MachineInstrBuilder buildAssertZExt (const DstOp &Res, const SrcOp &Op, unsigned Size)
 Build and insert Res = G_ASSERT_ZEXT Op, Size. More...
 
MachineInstrBuilder buildAssertSExt (const DstOp &Res, const SrcOp &Op, unsigned Size)
 Build and insert Res = G_ASSERT_SEXT Op, Size. More...
 
MachineInstrBuilder buildLoad (const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
 Build and insert Res = G_LOAD Addr, MMO. More...
 
MachineInstrBuilder buildLoad (const DstOp &Res, const SrcOp &Addr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
 Build and insert a G_LOAD instruction, while constructing the MachineMemOperand. More...
 
MachineInstrBuilder buildLoadInstr (unsigned Opcode, const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
 Build and insert Res = <opcode> Addr, MMO. More...
 
MachineInstrBuilder buildLoadFromOffset (const DstOp &Dst, const SrcOp &BasePtr, MachineMemOperand &BaseMMO, int64_t Offset)
 Helper to create a load from a constant offset given a base address. More...
 
MachineInstrBuilder buildStore (const SrcOp &Val, const SrcOp &Addr, MachineMemOperand &MMO)
 Build and insert G_STORE Val, Addr, MMO. More...
 
MachineInstrBuilder buildStore (const SrcOp &Val, const SrcOp &Addr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
 Build and insert a G_STORE instruction, while constructing the MachineMemOperand. More...
 
MachineInstrBuilder buildExtract (const DstOp &Res, const SrcOp &Src, uint64_t Index)
 Build and insert Res0, ... More...
 
MachineInstrBuilder buildUndef (const DstOp &Res)
 Build and insert Res = IMPLICIT_DEF. More...
 
void buildSequence (Register Res, ArrayRef< Register > 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 (const DstOp &Res, ArrayRef< Register > Ops)
 Build and insert Res = G_MERGE_VALUES Op0, ... More...
 
MachineInstrBuilder buildMerge (const DstOp &Res, std::initializer_list< SrcOp > Ops)
 
MachineInstrBuilder buildUnmerge (ArrayRef< LLT > Res, const SrcOp &Op)
 Build and insert Res0, ... More...
 
MachineInstrBuilder buildUnmerge (ArrayRef< Register > Res, const SrcOp &Op)
 
MachineInstrBuilder buildUnmerge (LLT Res, const SrcOp &Op)
 Build and insert an unmerge of Res sized pieces to cover Op. More...
 
MachineInstrBuilder buildBuildVector (const DstOp &Res, ArrayRef< Register > Ops)
 Build and insert Res = G_BUILD_VECTOR Op0, ... More...
 
MachineInstrBuilder buildSplatVector (const DstOp &Res, const SrcOp &Src)
 Build and insert Res = G_BUILD_VECTOR with Src replicated to fill the number of elements. More...
 
MachineInstrBuilder buildBuildVectorTrunc (const DstOp &Res, ArrayRef< Register > Ops)
 Build and insert Res = G_BUILD_VECTOR_TRUNC Op0, ... More...
 
MachineInstrBuilder buildShuffleSplat (const DstOp &Res, const SrcOp &Src)
 Build and insert a vector splat of a scalar Src using a G_INSERT_VECTOR_ELT and G_SHUFFLE_VECTOR idiom. More...
 
MachineInstrBuilder buildShuffleVector (const DstOp &Res, const SrcOp &Src1, const SrcOp &Src2, ArrayRef< int > Mask)
 Build and insert Res = G_SHUFFLE_VECTOR Src1, Src2, Mask. More...
 
MachineInstrBuilder buildConcatVectors (const DstOp &Res, ArrayRef< Register > Ops)
 Build and insert Res = G_CONCAT_VECTORS Op0, ... More...
 
MachineInstrBuilder buildInsert (const DstOp &Res, const SrcOp &Src, const SrcOp &Op, unsigned Index)
 
MachineInstrBuilder buildIntrinsic (Intrinsic::ID ID, ArrayRef< Register > Res, bool HasSideEffects)
 Build and insert either a G_INTRINSIC (if HasSideEffects is false) or G_INTRINSIC_W_SIDE_EFFECTS instruction. More...
 
MachineInstrBuilder buildIntrinsic (Intrinsic::ID ID, ArrayRef< DstOp > Res, bool HasSideEffects)
 
MachineInstrBuilder buildFPTrunc (const DstOp &Res, const SrcOp &Op, Optional< unsigned > Flags=None)
 Build and insert Res = G_FPTRUNC Op. More...
 
MachineInstrBuilder buildTrunc (const DstOp &Res, const SrcOp &Op)
 Build and insert Res = G_TRUNC Op. More...
 
MachineInstrBuilder buildICmp (CmpInst::Predicate Pred, const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1)
 Build and insert a Res = G_ICMP Pred, Op0, Op1. More...
 
MachineInstrBuilder buildFCmp (CmpInst::Predicate Pred, const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1, Optional< unsigned > Flags=None)
 Build and insert a Res = G_FCMP PredOp0, Op1. More...
 
MachineInstrBuilder buildSelect (const DstOp &Res, const SrcOp &Tst, const SrcOp &Op0, const SrcOp &Op1, Optional< unsigned > Flags=None)
 Build and insert a Res = G_SELECT Tst, Op0, Op1. More...
 
MachineInstrBuilder buildInsertVectorElement (const DstOp &Res, const SrcOp &Val, const SrcOp &Elt, const SrcOp &Idx)
 Build and insert Res = G_INSERT_VECTOR_ELT Val, Elt, Idx. More...
 
MachineInstrBuilder buildExtractVectorElement (const DstOp &Res, const SrcOp &Val, const SrcOp &Idx)
 Build and insert Res = G_EXTRACT_VECTOR_ELT Val, Idx. More...
 
MachineInstrBuilder buildAtomicCmpXchgWithSuccess (Register OldValRes, Register SuccessRes, Register Addr, Register CmpVal, Register NewVal, MachineMemOperand &MMO)
 Build and insert OldValRes<def>, SuccessRes<def> = G_ATOMIC_CMPXCHG_WITH_SUCCESS Addr, CmpVal, NewVal, MMO. More...
 
MachineInstrBuilder buildAtomicCmpXchg (Register OldValRes, Register Addr, Register CmpVal, Register NewVal, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMIC_CMPXCHG Addr, CmpVal, NewVal, MMO. More...
 
MachineInstrBuilder buildAtomicRMW (unsigned Opcode, const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_<Opcode> Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWXchg (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_XCHG Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWAdd (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_ADD Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWSub (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_SUB Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWAnd (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_AND Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWNand (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_NAND Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWOr (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_OR Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWXor (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_XOR Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWMax (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_MAX Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWMin (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_MIN Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWUmax (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_UMAX Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWUmin (Register OldValRes, Register Addr, Register Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_UMIN Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWFAdd (const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_FADD Addr, Val, MMO. More...
 
MachineInstrBuilder buildAtomicRMWFSub (const DstOp &OldValRes, const SrcOp &Addr, const SrcOp &Val, MachineMemOperand &MMO)
 Build and insert OldValRes<def> = G_ATOMICRMW_FSUB Addr, Val, MMO. More...
 
MachineInstrBuilder buildFence (unsigned Ordering, unsigned Scope)
 Build and insert G_FENCE Ordering, Scope. More...
 
MachineInstrBuilder buildFreeze (const DstOp &Dst, const SrcOp &Src)
 Build and insert Dst = G_FREEZE Src. More...
 
MachineInstrBuilder buildBlockAddress (Register Res, const BlockAddress *BA)
 Build and insert Res = G_BLOCK_ADDR BA. More...
 
MachineInstrBuilder buildAdd (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 Build and insert Res = G_ADD Op0, Op1. More...
 
MachineInstrBuilder buildSub (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 Build and insert Res = G_SUB Op0, Op1. More...
 
MachineInstrBuilder buildMul (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 Build and insert Res = G_MUL Op0, Op1. More...
 
MachineInstrBuilder buildUMulH (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildSMulH (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildURem (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 Build and insert Res = G_UREM Op0, Op1. More...
 
MachineInstrBuilder buildFMul (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildFMinNum (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildFMaxNum (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildFMinNumIEEE (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildFMaxNumIEEE (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildShl (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildLShr (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildAShr (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 
MachineInstrBuilder buildAnd (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
 Build and insert Res = G_AND Op0, Op1. More...
 
MachineInstrBuilder buildOr (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 Build and insert Res = G_OR Op0, Op1. More...
 
MachineInstrBuilder buildXor (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
 Build and insert Res = G_XOR Op0, Op1. More...
 
MachineInstrBuilder buildNot (const DstOp &Dst, const SrcOp &Src0)
 Build and insert a bitwise not, NegOne = G_CONSTANT -1 Res = G_OR Op0, NegOne. More...
 
MachineInstrBuilder buildCTPOP (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Res = G_CTPOP Op0, Src0. More...
 
MachineInstrBuilder buildCTLZ (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Res = G_CTLZ Op0, Src0. More...
 
MachineInstrBuilder buildCTLZ_ZERO_UNDEF (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Res = G_CTLZ_ZERO_UNDEF Op0, Src0. More...
 
MachineInstrBuilder buildCTTZ (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Res = G_CTTZ Op0, Src0. More...
 
MachineInstrBuilder buildCTTZ_ZERO_UNDEF (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Res = G_CTTZ_ZERO_UNDEF Op0, Src0. More...
 
MachineInstrBuilder buildBSwap (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Dst = G_BSWAP Src0. More...
 
MachineInstrBuilder buildFAdd (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 Build and insert Res = G_FADD Op0, Op1. More...
 
MachineInstrBuilder buildFSub (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 Build and insert Res = G_FSUB Op0, Op1. More...
 
MachineInstrBuilder buildFDiv (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 Build and insert Res = G_FDIV Op0, Op1. More...
 
MachineInstrBuilder buildFMA (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, const SrcOp &Src2, Optional< unsigned > Flags=None)
 Build and insert Res = G_FMA Op0, Op1, Op2. More...
 
MachineInstrBuilder buildFMAD (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, const SrcOp &Src2, Optional< unsigned > Flags=None)
 Build and insert Res = G_FMAD Op0, Op1, Op2. More...
 
MachineInstrBuilder buildFNeg (const DstOp &Dst, const SrcOp &Src0, Optional< unsigned > Flags=None)
 Build and insert Res = G_FNEG Op0. More...
 
MachineInstrBuilder buildFAbs (const DstOp &Dst, const SrcOp &Src0, Optional< unsigned > Flags=None)
 Build and insert Res = G_FABS Op0. More...
 
MachineInstrBuilder buildFCanonicalize (const DstOp &Dst, const SrcOp &Src0, Optional< unsigned > Flags=None)
 Build and insert Dst = G_FCANONICALIZE Src0. More...
 
MachineInstrBuilder buildIntrinsicTrunc (const DstOp &Dst, const SrcOp &Src0, Optional< unsigned > Flags=None)
 Build and insert Dst = G_INTRINSIC_TRUNC Src0. More...
 
MachineInstrBuilder buildFFloor (const DstOp &Dst, const SrcOp &Src0, Optional< unsigned > Flags=None)
 Build and insert Res = GFFLOOR Op0, Op1. More...
 
MachineInstrBuilder buildFLog (const DstOp &Dst, const SrcOp &Src, Optional< unsigned > Flags=None)
 Build and insert Dst = G_FLOG Src. More...
 
MachineInstrBuilder buildFLog2 (const DstOp &Dst, const SrcOp &Src, Optional< unsigned > Flags=None)
 Build and insert Dst = G_FLOG2 Src. More...
 
MachineInstrBuilder buildFExp2 (const DstOp &Dst, const SrcOp &Src, Optional< unsigned > Flags=None)
 Build and insert Dst = G_FEXP2 Src. More...
 
MachineInstrBuilder buildFPow (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1, Optional< unsigned > Flags=None)
 Build and insert Dst = G_FPOW Src0, Src1. More...
 
MachineInstrBuilder buildFCopysign (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
 Build and insert Res = G_FCOPYSIGN Op0, Op1. More...
 
MachineInstrBuilder buildUITOFP (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Res = G_UITOFP Src0. More...
 
MachineInstrBuilder buildSITOFP (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Res = G_SITOFP Src0. More...
 
MachineInstrBuilder buildFPTOUI (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Res = G_FPTOUI Src0. More...
 
MachineInstrBuilder buildFPTOSI (const DstOp &Dst, const SrcOp &Src0)
 Build and insert Res = G_FPTOSI Src0. More...
 
MachineInstrBuilder buildSMin (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
 Build and insert Res = G_SMIN Op0, Op1. More...
 
MachineInstrBuilder buildSMax (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
 Build and insert Res = G_SMAX Op0, Op1. More...
 
MachineInstrBuilder buildUMin (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
 Build and insert Res = G_UMIN Op0, Op1. More...
 
MachineInstrBuilder buildUMax (const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
 Build and insert Res = G_UMAX Op0, Op1. More...
 
MachineInstrBuilder buildAbs (const DstOp &Dst, const SrcOp &Src)
 Build and insert Dst = G_ABS Src. More...
 
MachineInstrBuilder buildJumpTable (const LLT PtrTy, unsigned JTI)
 Build and insert Res = G_JUMP_TABLE JTI. More...
 
MachineInstrBuilder buildVecReduceSeqFAdd (const DstOp &Dst, const SrcOp &ScalarIn, const SrcOp &VecIn)
 Build and insert Res = G_VECREDUCE_SEQ_FADD ScalarIn, VecIn. More...
 
MachineInstrBuilder buildVecReduceSeqFMul (const DstOp &Dst, const SrcOp &ScalarIn, const SrcOp &VecIn)
 Build and insert Res = G_VECREDUCE_SEQ_FMUL ScalarIn, VecIn. More...
 
MachineInstrBuilder buildVecReduceFAdd (const DstOp &Dst, const SrcOp &ScalarIn, const SrcOp &VecIn)
 Build and insert Res = G_VECREDUCE_FADD Src. More...
 
MachineInstrBuilder buildVecReduceFMul (const DstOp &Dst, const SrcOp &ScalarIn, const SrcOp &VecIn)
 Build and insert Res = G_VECREDUCE_FMUL Src. More...
 
MachineInstrBuilder buildVecReduceFMax (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_FMAX Src. More...
 
MachineInstrBuilder buildVecReduceFMin (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_FMIN Src. More...
 
MachineInstrBuilder buildVecReduceAdd (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_ADD Src. More...
 
MachineInstrBuilder buildVecReduceMul (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_MUL Src. More...
 
MachineInstrBuilder buildVecReduceAnd (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_AND Src. More...
 
MachineInstrBuilder buildVecReduceOr (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_OR Src. More...
 
MachineInstrBuilder buildVecReduceXor (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_XOR Src. More...
 
MachineInstrBuilder buildVecReduceSMax (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_SMAX Src. More...
 
MachineInstrBuilder buildVecReduceSMin (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_SMIN Src. More...
 
MachineInstrBuilder buildVecReduceUMax (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_UMAX Src. More...
 
MachineInstrBuilder buildVecReduceUMin (const DstOp &Dst, const SrcOp &Src)
 Build and insert Res = G_VECREDUCE_UMIN Src. More...
 
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. More...
 
MachineInstrBuilder buildMemCpy (const SrcOp &DstPtr, const SrcOp &SrcPtr, const SrcOp &Size, MachineMemOperand &DstMMO, MachineMemOperand &SrcMMO)
 
MachineInstrBuilder buildSbfx (const DstOp &Dst, const SrcOp &Src, const SrcOp &LSB, const SrcOp &Width)
 Build and insert Dst = G_SBFX Src, LSB, Width. More...
 
MachineInstrBuilder buildUbfx (const DstOp &Dst, const SrcOp &Src, const SrcOp &LSB, const SrcOp &Width)
 Build and insert Dst = G_UBFX Src, LSB, Width. More...
 
MachineInstrBuilder buildRotateRight (const DstOp &Dst, const SrcOp &Src, const SrcOp &Amt)
 Build and insert Dst = G_ROTR Src, Amt. More...
 
MachineInstrBuilder buildRotateLeft (const DstOp &Dst, const SrcOp &Src, const SrcOp &Amt)
 Build and insert Dst = G_ROTL Src, Amt. More...
 
void setMF (MachineFunction &MF)
 
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...
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::MachineIRBuilder
void validateTruncExt (const LLT Dst, const LLT Src, bool IsExtend)
 
void validateUnaryOp (const LLT Res, const LLT Op0)
 
void validateBinaryOp (const LLT Res, const LLT Op0, const LLT Op1)
 
void validateShiftOp (const LLT Res, const LLT Op0, const LLT Op1)
 
void validateSelectOp (const LLT ResTy, const LLT TstTy, const LLT Op0Ty, const LLT Op1Ty)
 
void recordInsertion (MachineInstr *InsertedInstr) const
 

Detailed Description

Defines a builder that does CSE of MachineInstructions using GISelCSEInfo.

Eg usage.

GISelCSEInfo *Info = &getAnalysis<GISelCSEAnalysisWrapperPass>().getCSEInfo(); CSEMIRBuilder CB(Builder.getState()); CB.setCSEInfo(Info); auto A = CB.buildConstant(s32, 42); auto B = CB.buildConstant(s32, 42); assert(A == B); unsigned CReg = MRI.createGenericVirtualRegister(s32); auto C = CB.buildConstant(CReg, 42); assert(C->getOpcode() == TargetOpcode::COPY); Explicitly passing in a register would materialize a copy if possible. CSEMIRBuilder also does trivial constant folding for binary ops.

Definition at line 32 of file CSEMIRBuilder.h.

Member Function Documentation

◆ buildConstant() [1/4]

MachineInstrBuilder MachineIRBuilder::buildConstant

Definition at line 310 of file MachineIRBuilder.cpp.

◆ buildConstant() [2/4]

MachineInstrBuilder MachineIRBuilder::buildConstant

Build and insert Res = G_CONSTANT Val.

G_CONSTANT is an integer constant with the specified size and value. Val will be extended or truncated to the size of Reg.

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

Definition at line 255 of file MachineIRBuilder.cpp.

◆ buildConstant() [3/4]

MachineInstrBuilder CSEMIRBuilder::buildConstant ( const DstOp Res,
const ConstantInt Val 
)
overridevirtual

Build and insert Res = G_CONSTANT Val.

G_CONSTANT is an integer constant with the specified size and value. Val will be extended or truncated to the size of Reg.

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

Reimplemented from llvm::MachineIRBuilder.

Definition at line 234 of file CSEMIRBuilder.cpp.

References llvm::GISelInstProfileBuilder::addNodeIDMachineOperand(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildSplatVector(), llvm::MachineOperand::CreateCImm(), llvm::LLT::getElementType(), llvm::DstOp::getLLTTy(), llvm::MachineIRBuilder::getMRI(), and llvm::LLT::isVector().

Referenced by buildInstr().

◆ buildConstant() [4/4]

MachineInstrBuilder MachineIRBuilder::buildConstant

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 276 of file MachineIRBuilder.cpp.

◆ buildFConstant() [1/4]

MachineInstrBuilder MachineIRBuilder::buildFConstant

Definition at line 325 of file MachineIRBuilder.cpp.

◆ buildFConstant() [2/4]

MachineInstrBuilder MachineIRBuilder::buildFConstant

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 284 of file MachineIRBuilder.cpp.

◆ buildFConstant() [3/4]

MachineInstrBuilder CSEMIRBuilder::buildFConstant ( const DstOp Res,
const ConstantFP Val 
)
overridevirtual

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.

Reimplemented from llvm::MachineIRBuilder.

Definition at line 261 of file CSEMIRBuilder.cpp.

References llvm::GISelInstProfileBuilder::addNodeIDMachineOperand(), llvm::MachineIRBuilder::buildFConstant(), llvm::MachineIRBuilder::buildSplatVector(), llvm::MachineOperand::CreateFPImm(), llvm::LLT::getElementType(), llvm::DstOp::getLLTTy(), llvm::MachineIRBuilder::getMRI(), and llvm::LLT::isVector().

◆ buildFConstant() [4/4]

MachineInstrBuilder MachineIRBuilder::buildFConstant

Definition at line 316 of file MachineIRBuilder.cpp.

◆ buildInstr()

MachineInstrBuilder CSEMIRBuilder::buildInstr ( unsigned  Opc,
ArrayRef< DstOp DstOps,
ArrayRef< SrcOp SrcOps,
Optional< unsigned >  Flag = None 
)
overridevirtual

◆ MachineIRBuilder() [1/6]

llvm::MachineIRBuilder::MachineIRBuilder
default

Some constructors for easy use.

◆ MachineIRBuilder() [2/6]

llvm::MachineIRBuilder::MachineIRBuilder
inline

Definition at line 262 of file MachineIRBuilder.h.

◆ MachineIRBuilder() [3/6]

llvm::MachineIRBuilder::MachineIRBuilder
inline

Definition at line 244 of file MachineIRBuilder.h.

◆ MachineIRBuilder() [4/6]

llvm::MachineIRBuilder::MachineIRBuilder
inline

Definition at line 242 of file MachineIRBuilder.h.

◆ MachineIRBuilder() [5/6]

llvm::MachineIRBuilder::MachineIRBuilder
inline

Definition at line 249 of file MachineIRBuilder.h.

◆ MachineIRBuilder() [6/6]

llvm::MachineIRBuilder::MachineIRBuilder
inline

Definition at line 255 of file MachineIRBuilder.h.


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