LLVM  10.0.0svn
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 MoreTy)
 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...
 
LegalizeResult fewerElementsVectorImplicitDef (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LegalizeResult fewerElementsVectorBasic (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 Legalize a simple vector instruction where all operands are the same type by splitting into multiple components. More...
 
LegalizeResult fewerElementsVectorMultiEltType (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 Legalize a instruction with a vector type where each operand may have a different element type. More...
 
LegalizeResult fewerElementsVectorCasts (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LegalizeResult fewerElementsVectorCmp (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LegalizeResult fewerElementsVectorSelect (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LegalizeResult fewerElementsVectorPhi (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LegalizeResult moreElementsVectorPhi (MachineInstr &MI, unsigned TypeIdx, LLT MoreTy)
 
LegalizeResult fewerElementsVectorUnmergeValues (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LegalizeResult reduceLoadStoreWidth (MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
 
LegalizeResult narrowScalarShiftByConstant (MachineInstr &MI, const APInt &Amt, LLT HalfTy, LLT ShiftAmtTy)
 
LegalizeResult narrowScalarShift (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult narrowScalarMul (MachineInstr &MI, LLT Ty)
 
LegalizeResult narrowScalarExtract (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult narrowScalarInsert (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult narrowScalarBasic (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult narrowScalarSelect (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult lowerBitCount (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult lowerU64ToF32BitOps (MachineInstr &MI)
 
LegalizeResult lowerUITOFP (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult lowerSITOFP (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult lowerFPTOUI (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult lowerMinMax (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult lowerFCopySign (MachineInstr &MI, unsigned TypeIdx, LLT Ty)
 
LegalizeResult lowerFMinNumMaxNum (MachineInstr &MI)
 
LegalizeResult lowerFMad (MachineInstr &MI)
 
LegalizeResult lowerUnmergeValues (MachineInstr &MI)
 
LegalizeResult lowerShuffleVector (MachineInstr &MI)
 
LegalizeResult lowerDynStackAlloc (MachineInstr &MI)
 

Public Attributes

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

Detailed Description

Definition at line 36 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 38 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 
)

◆ fewerElementsVectorBasic()

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

◆ fewerElementsVectorCasts()

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

◆ fewerElementsVectorCmp()

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

◆ fewerElementsVectorImplicitDef()

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

◆ fewerElementsVectorMultiEltType()

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

◆ fewerElementsVectorPhi()

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

◆ fewerElementsVectorSelect()

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

◆ fewerElementsVectorUnmergeValues()

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

◆ getLegalizerInfo()

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

◆ legalizeInstrStep()

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

◆ libcall()

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

◆ lower()

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

Legalize an instruction by splitting it into simpler parts, hopefully understood by the target.

Definition at line 1880 of file LegalizerHelper.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), assert(), llvm::MachineIRBuilder::buildAdd(), llvm::MachineIRBuilder::buildAnyExt(), llvm::MachineIRBuilder::buildAtomicCmpXchg(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildFConstant(), llvm::MachineIRBuilder::buildGEP(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildLoad(), llvm::MachineIRBuilder::buildLShr(), llvm::MachineIRBuilder::buildMul(), llvm::MachineIRBuilder::buildOr(), llvm::MachineIRBuilder::buildSelect(), llvm::MachineIRBuilder::buildSExt(), llvm::MachineIRBuilder::buildShl(), llvm::MachineIRBuilder::buildStore(), llvm::MachineIRBuilder::buildSub(), llvm::MachineIRBuilder::buildTrunc(), llvm::MachineIRBuilder::buildZExt(), llvm::MachineInstr::eraseFromParent(), llvm::Function::getContext(), llvm::Type::getDoubleTy(), llvm::MachineInstr::getFlags(), llvm::Type::getFloatTy(), llvm::Type::getFP128Ty(), llvm::MachineFunction::getFunction(), llvm::Type::getHalfTy(), llvm::MachineOperand::getImm(), llvm::MachineFunction::getMachineMemOperand(), llvm::MachineIRBuilder::getMF(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::getSizeInBits(), llvm::MachineMemOperand::getSizeInBits(), llvm::ConstantFP::getZeroValueForNegation(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_ULT, llvm::MachineOperand::isImm(), llvm::isPowerOf2_32(), llvm::LLT::isScalar(), llvm::LLT::isVector(), Legalized, llvm_unreachable, llvm::Lower, lowerBitCount(), lowerDynStackAlloc(), lowerFCopySign(), lowerFMad(), lowerFMinNumMaxNum(), lowerFPTOUI(), lowerMinMax(), lowerShuffleVector(), lowerSITOFP(), lowerUITOFP(), lowerUnmergeValues(), llvm::MachineInstr::memoperands_begin(), MIRBuilder, MRI, llvm::NextPowerOf2(), llvm::PowerOf2Floor(), llvm::LLT::scalar(), llvm::MachineIRBuilder::setInstr(), and UnableToLegalize.

Referenced by extractDLC(), and legalizeInstrStep().

◆ lowerBitCount()

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

◆ lowerDynStackAlloc()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerDynStackAlloc ( MachineInstr MI)

◆ lowerFCopySign()

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

◆ lowerFMad()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFMad ( MachineInstr MI)

◆ lowerFMinNumMaxNum()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerFMinNumMaxNum ( MachineInstr MI)

◆ lowerFPTOUI()

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

◆ lowerMinMax()

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

◆ lowerShuffleVector()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerShuffleVector ( MachineInstr MI)

◆ lowerSITOFP()

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

◆ lowerU64ToF32BitOps()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerU64ToF32BitOps ( MachineInstr MI)

◆ lowerUITOFP()

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

◆ lowerUnmergeValues()

LegalizerHelper::LegalizeResult LegalizerHelper::lowerUnmergeValues ( MachineInstr MI)

◆ moreElementsVector()

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

◆ moreElementsVectorPhi()

LegalizerHelper::LegalizeResult LegalizerHelper::moreElementsVectorPhi ( MachineInstr MI,
unsigned  TypeIdx,
LLT  MoreTy 
)

◆ 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 595 of file LegalizerHelper.cpp.

References llvm::MachineInstrBuilder::add(), llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addMemOperand(), llvm::MachineInstrBuilder::addUse(), assert(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::MachineIRBuilder::buildAnyExt(), llvm::MachineIRBuilder::buildAnyExtOrTrunc(), llvm::MachineIRBuilder::buildAShr(), llvm::MachineIRBuilder::buildBuildVector(), llvm::MachineIRBuilder::buildConcatVectors(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildCopy(), llvm::MachineIRBuilder::buildExtract(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInsert(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildIntToPtr(), llvm::MachineIRBuilder::buildLoad(), llvm::MachineIRBuilder::buildLShr(), llvm::MachineIRBuilder::buildMerge(), llvm::MachineIRBuilder::buildOr(), llvm::MachineIRBuilder::buildPtrToInt(), llvm::MachineIRBuilder::buildSelect(), llvm::MachineIRBuilder::buildSExt(), llvm::MachineIRBuilder::buildShl(), llvm::MachineIRBuilder::buildStore(), llvm::MachineIRBuilder::buildTrunc(), llvm::MachineIRBuilder::buildUAdde(), llvm::MachineIRBuilder::buildUAddo(), llvm::MachineIRBuilder::buildUndef(), llvm::MachineIRBuilder::buildUnmerge(), llvm::MachineIRBuilder::buildXor(), llvm::MachineIRBuilder::buildZExt(), llvm::GISelChangeObserver::changedInstr(), llvm::GISelChangeObserver::changingInstr(), Concat, llvm::MachineRegisterInfo::createGenericVirtualRegister(), llvm::dbgs(), llvm::ArrayRef< T >::drop_front(), E, llvm::MachineInstr::eraseFromParent(), llvm::LLT::getAddressSpace(), llvm::MachineOperand::getCImm(), llvm::MachineIRBuilder::getDataLayout(), llvm::LLT::getElementType(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::MachineOperand::getImm(), llvm::MachineIRBuilder::getInsertPt(), llvm::MachineIRBuilder::getMBB(), llvm::MachineOperand::getMBB(), llvm::LLT::getNumElements(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getPredicate(), llvm::MachineInstrBuilder::getReg(), llvm::MachineOperand::getReg(), getReg(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::getScalarType(), llvm::LLT::getSizeInBits(), llvm::getSizeInBits(), llvm::MachineRegisterInfo::getType(), llvm::ICmpInst::getUnsignedPredicate(), llvm::ConstantInt::getValue(), llvm::greatestCommonDivisor(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::MachineOperand::isImm(), llvm::DataLayout::isNonIntegralAddressSpace(), llvm::LLT::isPointer(), llvm::LLT::isScalar(), llvm::LLT::isVector(), Legalized, LLVM_DEBUG, llvm::APInt::lshr(), llvm::MachineInstr::memoperands_begin(), Merge, MI, MIRBuilder, narrowScalarBasic(), narrowScalarExtract(), narrowScalarInsert(), narrowScalarMul(), narrowScalarSelect(), narrowScalarShift(), llvm::SmallVectorTemplateBase< T >::push_back(), reduceLoadStoreWidth(), llvm::SmallVectorImpl< T >::resize(), llvm::LLT::scalar(), llvm::MachineOperand::setImm(), llvm::MachineIRBuilder::setInsertPt(), llvm::MachineIRBuilder::setInstr(), llvm::MachineOperand::setReg(), llvm::SmallVectorBase::size(), llvm::APInt::trunc(), and UnableToLegalize.

Referenced by llvm::MipsRegisterBankInfo::applyMappingImpl(), and legalizeInstrStep().

◆ narrowScalarBasic()

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

◆ narrowScalarExtract()

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

◆ narrowScalarInsert()

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

◆ narrowScalarMul()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarMul ( MachineInstr MI,
LLT  Ty 
)

◆ narrowScalarSelect()

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

◆ narrowScalarShift()

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

◆ narrowScalarShiftByConstant()

LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalarShiftByConstant ( MachineInstr MI,
const APInt Amt,
LLT  HalfTy,
LLT  ShiftAmtTy 
)

◆ reduceLoadStoreWidth()

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

◆ 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 1405 of file LegalizerHelper.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), assert(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildLShr(), llvm::MachineIRBuilder::buildOr(), llvm::MachineIRBuilder::buildTrunc(), llvm::MachineIRBuilder::buildZExt(), llvm::MachineIRBuilder::buildZExtOrTrunc(), llvm::GISelChangeObserver::changedInstr(), llvm::GISelChangeObserver::changingInstr(), llvm::APFloat::convert(), llvm::MachineRegisterInfo::createGenericVirtualRegister(), E, llvm::MachineInstr::eraseFromParent(), llvm::ConstantInt::get(), llvm::ConstantFP::get(), llvm::APInt::getAllOnesValue(), llvm::MachineIRBuilder::getBoolExtOp(), llvm::MachineOperand::getCImm(), llvm::Function::getContext(), llvm::LLT::getElementType(), llvm::MachineBasicBlock::getFirstNonPHI(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::MachineOperand::getFPImm(), llvm::MachineFunction::getFunction(), llvm::MachineIRBuilder::getInsertPt(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineIRBuilder::getMBB(), llvm::MachineOperand::getMBB(), llvm::MachineIRBuilder::getMF(), llvm::MachineInstr::getMF(), llvm::LLT::getNumElements(), llvm::MachineInstr::getNumOperands(), llvm::APInt::getOneBitSet(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getPredicate(), llvm::MachineOperand::getReg(), llvm::LLT::getScalarSizeInBits(), llvm::LLT::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::isPowerOf2_32(), llvm::CmpInst::isSigned(), llvm::LegalityPredicates::isVector(), Legalized, llvm::BitmaskEnumDetail::Mask(), MIRBuilder, llvm::APFloatBase::rmNearestTiesToEven, llvm::MachineOperand::setCImm(), llvm::MachineInstr::setDesc(), llvm::MachineOperand::setFPImm(), llvm::MachineIRBuilder::setInsertPt(), llvm::MachineIRBuilder::setInstr(), llvm::MachineOperand::setReg(), llvm::APInt::sext(), TII, UnableToLegalize, and llvm::LLT::vector().

Referenced by extractDLC(), and legalizeInstrStep().

Member Data Documentation

◆ MIRBuilder

MachineIRBuilder& llvm::LegalizerHelper::MIRBuilder

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