LLVM  8.0.1
Public Types | Public Member Functions | Public Attributes | List of all members
llvm::LegalizerHelper Class Reference

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

Collaboration diagram for llvm::LegalizerHelper:
Collaboration graph
[legend]

Public Types

enum  LegalizeResult { AlreadyLegal, Legalized, UnableToLegalize }
 

Public Member Functions

 LegalizerHelper (MachineFunction &MF, GISelChangeObserver &Observer, MachineIRBuilder &B)
 
 LegalizerHelper (MachineFunction &MF, const LegalizerInfo &LI, GISelChangeObserver &Observer, MachineIRBuilder &B)
 
LegalizeResult legalizeInstrStep (MachineInstr &MI)
 Replace MI by a sequence of legal instructions that can implement the same operation. More...
 
LegalizeResult libcall (MachineInstr &MI)
 Legalize an instruction by emiting a runtime library call instead. More...
 
LegalizeResult narrowScalar (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 Legalize an instruction by reducing the width of the underlying scalar type. More...
 
LegalizeResult widenScalar (MachineInstr &MI, unsigned TypeIdx, LLT WideTy)
 Legalize an instruction by performing the operation on a wider scalar type (for example a 16-bit addition can be safely performed at 32-bits precision, ignoring the unused bits). More...
 
LegalizeResult lower (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 Legalize an instruction by splitting it into simpler parts, hopefully understood by the target. More...
 
LegalizeResult fewerElementsVector (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 Legalize a vector instruction by splitting into multiple components, each acting on the same scalar type as the original but with fewer elements. More...
 
LegalizeResult moreElementsVector (MachineInstr &MI, unsigned TypeIdx, LLT WideTy)
 Legalize a vector instruction by increasing the number of vector elements involved and ignoring the added elements later. More...
 
const LegalizerInfogetLegalizerInfo () const
 Expose LegalizerInfo so the clients can re-use. More...
 

Public Attributes

MachineIRBuilderMIRBuilder
 Expose MIRBuilder so clients can set their own RecordInsertInstruction functions. More...
 

Detailed Description

Definition at line 37 of file LegalizerHelper.h.

Member Enumeration Documentation

◆ LegalizeResult

Enumerator
AlreadyLegal 

Instruction was already legal and no change was made to the MachineFunction.

Legalized 

Instruction has been legalized and the MachineFunction changed.

UnableToLegalize 

Some kind of error has occurred and we could not legalize this instruction.

Definition at line 39 of file LegalizerHelper.h.

Constructor & Destructor Documentation

◆ LegalizerHelper() [1/2]

LegalizerHelper::LegalizerHelper ( MachineFunction MF,
GISelChangeObserver Observer,
MachineIRBuilder B 
)

◆ LegalizerHelper() [2/2]

LegalizerHelper::LegalizerHelper ( MachineFunction MF,
const LegalizerInfo LI,
GISelChangeObserver Observer,
MachineIRBuilder B 
)

Member Function Documentation

◆ fewerElementsVector()

LegalizerHelper::LegalizeResult LegalizerHelper::fewerElementsVector ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

Legalize a vector instruction by splitting into multiple components, each acting on the same scalar type as the original but with fewer elements.

Definition at line 1167 of file LegalizerHelper.cpp.

References llvm::MachineIRBuilder::buildAdd(), llvm::MachineIRBuilder::buildBuildVector(), llvm::MachineIRBuilder::buildConcatVectors(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildLoad(), llvm::MachineIRBuilder::buildSelect(), llvm::MachineIRBuilder::buildStore(), llvm::MachineIRBuilder::buildUndef(), llvm::LegalizeActions::Custom, llvm::MachineInstr::eraseFromParent(), llvm::MachineMemOperand::getAlignment(), llvm::MachineMemOperand::getFlags(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineInstr::getMF(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineMemOperand::getPointerInfo(), llvm::MachineOperand::getReg(), llvm::LLT::getSizeInBits(), llvm::MachineFunction::getSubtarget(), llvm::MachinePointerInfo::getWithOffset(), llvm::CmpInst::ICMP_EQ, llvm::LLT::isVector(), llvm::LegalizeActions::Legal, Legalized, llvm::MachineIRBuilder::materializeGEP(), llvm::MachineInstr::memoperands_begin(), llvm::MinAlign(), MIRBuilder, MRI, llvm::PowerOf2Ceil(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LLT::scalar(), llvm::MachineInstr::setDesc(), llvm::MachineIRBuilder::setInstr(), llvm::MachineOperand::setReg(), Size, TII, and UnableToLegalize.

Referenced by legalizeInstrStep().

◆ getLegalizerInfo()

const LegalizerInfo& llvm::LegalizerHelper::getLegalizerInfo ( ) const
inline

Expose LegalizerInfo so the clients can re-use.

Definition at line 97 of file LegalizerHelper.h.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::createLibcall(), MI, MIRBuilder, and Reg.

◆ legalizeInstrStep()

LegalizerHelper::LegalizeResult LegalizerHelper::legalizeInstrStep ( MachineInstr MI)

Replace MI by a sequence of legal instructions that can implement the same operation.

Note that this means MI may be deleted, so any iterator steps should be performed before calling this function. Helper should be initialized to the MachineFunction containing MI.

Considered as an opaque blob, the legal code will use and define the same registers as MI.

Definition at line 50 of file LegalizerHelper.cpp.

References AlreadyLegal, llvm::MachineIRBuilder::buildUnmerge(), llvm::MachineRegisterInfo::createGenericVirtualRegister(), llvm::LegalizeActions::Custom, llvm::dbgs(), llvm::LegalizeActions::FewerElements, fewerElementsVector(), llvm::LegalizerInfo::getAction(), llvm::LegalizeActions::Legal, llvm::LegalizerInfo::legalizeCustom(), Legalized, libcall(), LLVM_DEBUG, llvm::Lower, lower(), MIRBuilder, llvm::LegalizeActions::NarrowScalar, narrowScalar(), llvm::MachineInstr::print(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), Reg, UnableToLegalize, llvm::LegalizeActions::WidenScalar, and widenScalar().

◆ libcall()

LegalizerHelper::LegalizeResult LegalizerHelper::libcall ( MachineInstr MI)

◆ lower()

LegalizerHelper::LegalizeResult LegalizerHelper::lower ( MachineInstr MI,
unsigned  TypeIdx,
LLT  Ty 
)

◆ moreElementsVector()

LegalizeResult llvm::LegalizerHelper::moreElementsVector ( MachineInstr MI,
unsigned  TypeIdx,
LLT  WideTy 
)

Legalize a vector instruction by increasing the number of vector elements involved and ignoring the added elements later.

◆ narrowScalar()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar ( MachineInstr MI,
unsigned  TypeIdx,
LLT  NarrowTy 
)

Legalize an instruction by reducing the width of the underlying scalar type.

Definition at line 283 of file LegalizerHelper.cpp.

References assert(), llvm::MachineIRBuilder::buildBuildVector(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildExtract(), llvm::MachineIRBuilder::buildInsert(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildLoad(), llvm::MachineIRBuilder::buildMerge(), llvm::MachineIRBuilder::buildStore(), llvm::MachineIRBuilder::buildUAdde(), llvm::MachineIRBuilder::buildUndef(), llvm::MachineIRBuilder::buildUnmerge(), llvm::MachineRegisterInfo::createGenericVirtualRegister(), llvm::MachineInstr::eraseFromParent(), llvm::ConstantInt::get(), llvm::MachineOperand::getCImm(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::MachineOperand::getImm(), llvm::MachineIRBuilder::getInsertPt(), llvm::MachineFunction::getMachineMemOperand(), llvm::MachineIRBuilder::getMBB(), llvm::MachineIRBuilder::getMF(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), getScalarSizeInBits(), llvm::LLT::getSizeInBits(), llvm::getSizeInBits(), llvm::MachineRegisterInfo::getType(), llvm::ConstantInt::getValue(), llvm::LLT::isVector(), Legalized, llvm::APInt::lshr(), llvm::MachineIRBuilder::materializeGEP(), llvm::MachineInstr::memoperands_begin(), MI, llvm::MinAlign(), MIRBuilder, llvm::NotAtomic, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LLT::scalar(), llvm::MachineIRBuilder::setInsertPt(), llvm::MachineIRBuilder::setInstr(), llvm::MachineOperand::setReg(), llvm::SmallVectorBase::size(), llvm::APInt::trunc(), and UnableToLegalize.

Referenced by legalizeInstrStep().

◆ widenScalar()

LegalizerHelper::LegalizeResult LegalizerHelper::widenScalar ( MachineInstr MI,
unsigned  TypeIdx,
LLT  WideTy 
)

Legalize an instruction by performing the operation on a wider scalar type (for example a 16-bit addition can be safely performed at 32-bits precision, ignoring the unused bits).

Definition at line 656 of file LegalizerHelper.cpp.

References llvm::alignTo(), assert(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildTrunc(), llvm::MachineIRBuilder::buildZExt(), llvm::GISelChangeObserver::changedInstr(), llvm::GISelChangeObserver::changingInstr(), llvm::APFloat::convert(), llvm::MachineInstr::eraseFromParent(), llvm::ConstantInt::get(), llvm::ConstantFP::get(), llvm::APInt::getAllOnesValue(), llvm::MachineOperand::getCImm(), llvm::Function::getContext(), llvm::MachineBasicBlock::getFirstNonPHI(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::MachineOperand::getFPImm(), llvm::MachineFunction::getFunction(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineOperand::getMBB(), llvm::MachineIRBuilder::getMF(), llvm::MachineInstr::getMF(), llvm::MachineInstr::getNumOperands(), llvm::APInt::getOneBitSet(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getPredicate(), llvm::MachineOperand::getReg(), llvm::LLT::getSizeInBits(), llvm::getSizeInBits(), llvm::MachineFunction::getSubtarget(), llvm::MachineRegisterInfo::getType(), llvm::ConstantInt::getValue(), llvm::ConstantFP::getValueAPF(), llvm::APInt::getZExtValue(), I, llvm::CmpInst::ICMP_NE, llvm::APFloatBase::IEEEdouble(), llvm::APFloatBase::IEEEsingle(), llvm::CmpInst::isSigned(), Legalized, LLVM_FALLTHROUGH, llvm_unreachable, llvm::BitmaskEnumDetail::Mask(), MIRBuilder, llvm::APFloatBase::rmTowardZero, llvm::LLT::scalar(), llvm::MachineOperand::setCImm(), llvm::MachineInstr::setDesc(), llvm::MachineOperand::setFPImm(), llvm::MachineIRBuilder::setInsertPt(), llvm::MachineIRBuilder::setInstr(), llvm::MachineOperand::setReg(), llvm::APInt::sext(), TII, and UnableToLegalize.

Referenced by legalizeInstrStep().

Member Data Documentation

◆ MIRBuilder

MachineIRBuilder& llvm::LegalizerHelper::MIRBuilder

Expose MIRBuilder so clients can set their own RecordInsertInstruction functions.

Definition at line 94 of file LegalizerHelper.h.

Referenced by fewerElementsVector(), getLegalizerInfo(), legalizeInstrStep(), LegalizerHelper(), libcall(), lower(), narrowScalar(), and widenScalar().


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