LLVM
8.0.1
|
#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
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 LegalizerInfo & | getLegalizerInfo () const |
Expose LegalizerInfo so the clients can re-use. More... | |
Public Attributes | |
MachineIRBuilder & | MIRBuilder |
Expose MIRBuilder so clients can set their own RecordInsertInstruction functions. More... | |
Definition at line 37 of file LegalizerHelper.h.
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.
LegalizerHelper::LegalizerHelper | ( | MachineFunction & | MF, |
GISelChangeObserver & | Observer, | ||
MachineIRBuilder & | B | ||
) |
Definition at line 33 of file LegalizerHelper.cpp.
References MIRBuilder, llvm::MachineIRBuilder::setChangeObserver(), and llvm::MachineIRBuilder::setMF().
LegalizerHelper::LegalizerHelper | ( | MachineFunction & | MF, |
const LegalizerInfo & | LI, | ||
GISelChangeObserver & | Observer, | ||
MachineIRBuilder & | B | ||
) |
Definition at line 42 of file LegalizerHelper.cpp.
References MIRBuilder, llvm::MachineIRBuilder::setChangeObserver(), and llvm::MachineIRBuilder::setMF().
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().
|
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.
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().
LegalizerHelper::LegalizeResult LegalizerHelper::libcall | ( | MachineInstr & | MI | ) |
Legalize an instruction by emiting a runtime library call instead.
Definition at line 190 of file LegalizerHelper.cpp.
References conversionLibcall(), llvm::MachineInstr::eraseFromParent(), llvm::IntegerType::get(), llvm::Function::getContext(), llvm::Type::getDoubleTy(), llvm::Type::getFloatTy(), llvm::MachineFunction::getFunction(), llvm::Type::getInt32Ty(), llvm::MachineIRBuilder::getMF(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::LLT::getSizeInBits(), llvm::getSizeInBits(), llvm::MachineRegisterInfo::getType(), Legalized, MIRBuilder, llvm::MachineIRBuilder::setInstr(), simpleLibcall(), Size, and UnableToLegalize.
Referenced by legalizeInstrStep().
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 970 of file LegalizerHelper.cpp.
References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addUse(), llvm::MachineIRBuilder::buildAdd(), llvm::MachineIRBuilder::buildAnyExt(), llvm::MachineIRBuilder::buildAtomicCmpXchg(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildFConstant(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildLoad(), llvm::MachineIRBuilder::buildMul(), llvm::MachineIRBuilder::buildSExt(), llvm::MachineIRBuilder::buildSub(), llvm::MachineIRBuilder::buildZExt(), llvm::MachineInstr::eraseFromParent(), llvm::Function::getContext(), llvm::Type::getDoubleTy(), llvm::Type::getFloatTy(), llvm::Type::getFP128Ty(), llvm::MachineFunction::getFunction(), llvm::Type::getHalfTy(), llvm::MachineIRBuilder::getMF(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::LLT::getSizeInBits(), llvm::ConstantFP::getZeroValueForNegation(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_ULT, llvm::LLT::isScalar(), llvm::LLT::isVector(), Legalized, llvm_unreachable, llvm::Lower, llvm::MachineInstr::memoperands_begin(), MIRBuilder, MRI, llvm::LLT::scalar(), llvm::MachineIRBuilder::setInstr(), and UnableToLegalize.
Referenced by legalizeInstrStep().
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.
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().
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().
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().