LLVM  6.0.0svn
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::LegalizerInfo Class Reference

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

Inheritance diagram for llvm::LegalizerInfo:
Inheritance graph
[legend]

Public Types

enum  LegalizeAction : std::uint8_t {
  Legal, NarrowScalar, WidenScalar, FewerElements,
  MoreElements, Lower, Libcall, Custom,
  Unsupported, NotFound
}
 

Public Member Functions

 LegalizerInfo ()
 
virtual ~LegalizerInfo ()=default
 
void computeTables ()
 Compute any ancillary tables needed to quickly decide how an operation should be handled. More...
 
void setAction (const InstrAspect &Aspect, LegalizeAction Action)
 More friendly way to set an action for common types that have an LLT representation. More...
 
void setScalarInVectorAction (unsigned Opcode, LLT ScalarTy, LegalizeAction Action)
 If an operation on a given vector type (say <M x="" in>="">) isn't explicitly specified, we proceed in 2 stages. More...
 
std::pair< LegalizeAction, LLTgetAction (const InstrAspect &Aspect) const
 Determine what action should be taken to legalize the given generic instruction opcode, type-index and type. More...
 
std::tuple< LegalizeAction, unsigned, LLTgetAction (const MachineInstr &MI, const MachineRegisterInfo &MRI) const
 Determine what action should be taken to legalize the given generic instruction. More...
 
Optional< LLTfindLegalizableSize (const InstrAspect &Aspect, function_ref< LLT(LLT)> NextType) const
 Iterate the given function (typically something like doubling the width) on Ty until we find a legal type for this operation. More...
 
Optional< LLTfindLegalType (const InstrAspect &Aspect, LegalizeAction Action) const
 Find what type it's actually OK to perform the given operation on, given the general approach we've decided to take. More...
 
std::pair< LegalizeAction, LLTfindLegalAction (const InstrAspect &Aspect, LegalizeAction Action) const
 
LegalizeAction findInActions (const InstrAspect &Aspect) const
 Find the specified Aspect in the primary (explicitly set) Actions table. More...
 
bool isLegal (const MachineInstr &MI, const MachineRegisterInfo &MRI) const
 
virtual bool legalizeCustom (MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &MIRBuilder) const
 

Static Public Member Functions

static bool needsLegalizingToDifferentSize (const LegalizeAction Action)
 

Detailed Description

Definition at line 53 of file LegalizerInfo.h.

Member Enumeration Documentation

◆ LegalizeAction

Enumerator
Legal 

The operation is expected to be selectable directly by the target, and no transformation is necessary.

NarrowScalar 

The operation should be synthesized from multiple instructions acting on a narrower scalar base-type.

For example a 64-bit add might be implemented in terms of 32-bit add-with-carry.

WidenScalar 

The operation should be implemented in terms of a wider scalar base-type.

For example a <2 x s8> add could be implemented as a <2 x s32> add (ignoring the high bits).

FewerElements 

The (vector) operation should be implemented by splitting it into sub-vectors where the operation is legal.

For example a <8 x s64> add might be implemented as 4 separate <2 x s64> adds.

MoreElements 

The (vector) operation should be implemented by widening the input vector and ignoring the lanes added by doing so.

For example <2 x i8> is rarely legal, but you might perform an <8 x i8> and then only look at the first two results.

Lower 

The operation itself must be expressed in terms of simpler actions on this target.

E.g. a SREM replaced by an SDIV and subtraction.

Libcall 

The operation should be implemented as a call to some kind of runtime support library.

For example this usually happens on machines that don't support floating-point operations natively.

Custom 

The target wants to do something special with this combination of operand and type.

A callback will be issued when it is needed.

Unsupported 

This operation is completely unsupported on the target.

A programming error has occurred.

NotFound 

Sentinel value for when no action was found in the specified table.

Definition at line 55 of file LegalizerInfo.h.

Constructor & Destructor Documentation

◆ LegalizerInfo()

LegalizerInfo::LegalizerInfo ( )

Definition at line 37 of file LegalizerInfo.cpp.

References Legal, Lower, NarrowScalar, and WidenScalar.

◆ ~LegalizerInfo()

virtual llvm::LegalizerInfo::~LegalizerInfo ( )
virtualdefault

Member Function Documentation

◆ computeTables()

void LegalizerInfo::computeTables ( )

Compute any ancillary tables needed to quickly decide how an operation should be handled.

This must be called after all "set*Action"methods but before any query is made or incorrect results may be returned.

Definition at line 59 of file LegalizerInfo.cpp.

References llvm::WebAssembly::End, llvm::LLT::getElementType(), llvm::LLT::getNumElements(), llvm::LLT::isVector(), and llvm::max().

Referenced by llvm::AArch64LegalizerInfo::AArch64LegalizerInfo(), llvm::AMDGPULegalizerInfo::AMDGPULegalizerInfo(), llvm::ARMLegalizerInfo::ARMLegalizerInfo(), and llvm::X86LegalizerInfo::X86LegalizerInfo().

◆ findInActions()

LegalizeAction llvm::LegalizerInfo::findInActions ( const InstrAspect Aspect) const
inline

Find the specified Aspect in the primary (explicitly set) Actions table.

Returns either the action the target requested or NotFound if there was no setAction call.

Definition at line 200 of file LegalizerInfo.h.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::InstrAspect::Idx, llvm::InstrAspect::Opcode, and llvm::InstrAspect::Type.

Referenced by getAction().

◆ findLegalAction()

std::pair<LegalizeAction, LLT> llvm::LegalizerInfo::findLegalAction ( const InstrAspect Aspect,
LegalizeAction  Action 
) const
inline

Definition at line 189 of file LegalizerInfo.h.

Referenced by getAction().

◆ findLegalizableSize()

Optional<LLT> llvm::LegalizerInfo::findLegalizableSize ( const InstrAspect Aspect,
function_ref< LLT(LLT)>  NextType 
) const
inline

Iterate the given function (typically something like doubling the width) on Ty until we find a legal type for this operation.

Definition at line 163 of file LegalizerInfo.h.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::InstrAspect::Idx, llvm::None, llvm::InstrAspect::Opcode, and llvm::InstrAspect::Type.

Referenced by findLegalType().

◆ findLegalType()

Optional< LLT > LegalizerInfo::findLegalType ( const InstrAspect Aspect,
LegalizeAction  Action 
) const

◆ getAction() [1/2]

std::pair< LegalizerInfo::LegalizeAction, LLT > LegalizerInfo::getAction ( const InstrAspect Aspect) const

Determine what action should be taken to legalize the given generic instruction opcode, type-index and type.

Requires computeTables to have been called.

Returns
a pair consisting of the kind of legalization that should be performed and the destination type.

Definition at line 82 of file LegalizerInfo.cpp.

References assert(), Custom, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), FewerElements, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), findInActions(), findLegalAction(), llvm::LLT::getElementType(), llvm::LLT::getNumElements(), llvm::LLT::getSizeInBits(), llvm::isPowerOf2_64(), llvm::LLT::isVector(), Legal, Lower, MoreElements, NarrowScalar, NotFound, llvm::InstrAspect::Opcode, llvm::InstrAspect::Type, and Unsupported.

Referenced by getAction(), isLegal(), and llvm::LegalizerHelper::legalizeInstrStep().

◆ getAction() [2/2]

std::tuple< LegalizerInfo::LegalizeAction, unsigned, LLT > LegalizerInfo::getAction ( const MachineInstr MI,
const MachineRegisterInfo MRI 
) const

Determine what action should be taken to legalize the given generic instruction.

Returns
a tuple consisting of the LegalizeAction that should be performed, the type-index it should be performed on and the destination type.

Definition at line 145 of file LegalizerInfo.cpp.

References getAction(), llvm::MachineInstr::getDesc(), llvm::MCOperandInfo::getGenericTypeIndex(), llvm::MCInstrDesc::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineRegisterInfo::getType(), Legal, llvm::MCInstrDesc::OpInfo, and llvm::SmallBitVector::set().

◆ isLegal()

bool LegalizerInfo::isLegal ( const MachineInstr MI,
const MachineRegisterInfo MRI 
) const

Definition at line 170 of file LegalizerInfo.cpp.

References getAction(), and Legal.

◆ legalizeCustom()

bool LegalizerInfo::legalizeCustom ( MachineInstr MI,
MachineRegisterInfo MRI,
MachineIRBuilder MIRBuilder 
) const
virtual

◆ needsLegalizingToDifferentSize()

static bool llvm::LegalizerInfo::needsLegalizingToDifferentSize ( const LegalizeAction  Action)
inlinestatic

Definition at line 110 of file LegalizerInfo.h.

◆ setAction()

void llvm::LegalizerInfo::setAction ( const InstrAspect Aspect,
LegalizeAction  Action 
)
inline

◆ setScalarInVectorAction()

void llvm::LegalizerInfo::setScalarInVectorAction ( unsigned  Opcode,
LLT  ScalarTy,
LegalizeAction  Action 
)
inline

If an operation on a given vector type (say <M x="" in>="">) isn't explicitly specified, we proceed in 2 stages.

First we legalize the underlying scalar (so that there's at least one legal vector with that scalar), then we adjust the number of elements in the vector so that it is legal. The desired action in the first step is controlled by this function.

Definition at line 138 of file LegalizerInfo.h.

References assert(), llvm::LLT::isVector(), MI, and MRI.


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