class CSEMIRBuilder

Declaration

class CSEMIRBuilder : public MachineIRBuilder { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEMIRBuilder.h:32

Inherits from: MachineIRBuilder

Method Overview

  • public llvm::MachineInstrBuilder buildConstant(const llvm::DstOp & Res, const llvm::ConstantInt & Val)
  • public llvm::MachineInstrBuilder buildFConstant(const llvm::DstOp & Res, const llvm::ConstantFP & Val)
  • public llvm::MachineInstrBuilder buildInstr(unsigned int Opc, ArrayRef<llvm::DstOp> DstOps, ArrayRef<llvm::SrcOp> SrcOps, Optional<unsigned int> Flag = None)

Inherited from MachineIRBuilder:

Methods

llvm::MachineInstrBuilder buildConstant(
    const llvm::DstOp& Res,
    const llvm::ConstantInt& Val)

Description

Build and insert \p Res = G_CONSTANT \p Val G_CONSTANT is an integer constant with the specified size and value. \p Val will be extended or truncated to the size of \p Reg.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEMIRBuilder.h:100

Parameters

const llvm::DstOp& Res
const llvm::ConstantInt& Val

Returns

The newly created instruction.

llvm::MachineInstrBuilder buildFConstant(
    const llvm::DstOp& Res,
    const llvm::ConstantFP& Val)

Description

Build and insert \p Res = G_FCONSTANT \p Val G_FCONSTANT is a floating-point constant with the specified size and value.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEMIRBuilder.h:105

Parameters

const llvm::DstOp& Res
const llvm::ConstantFP& Val

Returns

The newly created instruction.

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

Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEMIRBuilder.h:94

Parameters

unsigned int Opc
ArrayRef<llvm::DstOp> DstOps
ArrayRef<llvm::SrcOp> SrcOps
Optional<unsigned int> Flag = None