LLVM  6.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)
 
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...
 

Public Attributes

MachineIRBuilder MIRBuilder
 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()

LegalizerHelper::LegalizerHelper ( MachineFunction MF)

Definition at line 31 of file LegalizerHelper.cpp.

References MIRBuilder, and llvm::MachineIRBuilder::setMF().

Member Function Documentation

◆ fewerElementsVector()

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

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

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

Referenced by llvm::Legalizer::runOnMachineFunction().

◆ 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 
)

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

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::MachineInstrBuilder::addUse(), llvm::alignTo(), assert(), llvm::MachineIRBuilder::buildAnyExt(), llvm::MachineIRBuilder::buildAnyExtOrTrunc(), llvm::MachineIRBuilder::buildBrCond(), llvm::MachineIRBuilder::buildConstant(), llvm::MachineIRBuilder::buildFCmp(), llvm::MachineIRBuilder::buildFConstant(), llvm::MachineIRBuilder::buildFPTrunc(), llvm::MachineIRBuilder::buildICmp(), llvm::MachineIRBuilder::buildInsert(), llvm::MachineIRBuilder::buildInstr(), llvm::MachineIRBuilder::buildLoad(), llvm::MachineIRBuilder::buildSExt(), llvm::MachineIRBuilder::buildStore(), llvm::MachineIRBuilder::buildTrunc(), llvm::MachineIRBuilder::buildZExt(), llvm::MachineRegisterInfo::createGenericVirtualRegister(), DefMI, llvm::MachineInstr::eraseFromParent(), llvm::TargetLoweringBase::getBooleanContents(), llvm::MachineOperand::getCImm(), llvm::MachineOperand::getFPImm(), llvm::MachineOperand::getImm(), llvm::MachineOperand::getMBB(), llvm::MachineIRBuilder::getMF(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getPredicate(), llvm::MachineOperand::getReg(), llvm::LLT::getSizeInBits(), llvm::getSizeInBits(), llvm::MachineFunction::getSubtarget(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::MachineRegisterInfo::getType(), llvm::MachineRegisterInfo::getVRegDef(), llvm::CmpInst::isSigned(), Legalized, llvm::MachineInstr::memoperands_begin(), MIRBuilder, llvm::MachineInstr::operands_begin(), llvm::MachineInstr::operands_end(), llvm::LLT::scalar(), llvm::MachineIRBuilder::setInsertPt(), llvm::MachineIRBuilder::setInstr(), llvm::MachineOperand::setReg(), UnableToLegalize, llvm::TargetLoweringBase::ZeroOrNegativeOneBooleanContent, and llvm::TargetLoweringBase::ZeroOrOneBooleanContent.

Referenced by legalizeInstrStep().

Member Data Documentation

◆ MIRBuilder

MachineIRBuilder llvm::LegalizerHelper::MIRBuilder

Expose MIRBuilder so clients can set their own RecordInsertInstruction functions.

Definition at line 90 of file LegalizerHelper.h.

Referenced by fewerElementsVector(), legalizeInstrStep(), LegalizerHelper(), libcall(), lower(), narrowScalar(), llvm::Legalizer::runOnMachineFunction(), and widenScalar().


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