LLVM  4.0.0
Public Types | Public Member Functions | List of all members
llvm::LegalizerInfo Class Reference

#include <LegalizerInfo.h>

Inheritance diagram for llvm::LegalizerInfo:
[legend]

Public Types

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

Public Member Functions

 LegalizerInfo ()
 
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, LLT
getAction (const MachineInstr &MI, const MachineRegisterInfo &MRI) const
 Determine what action should be taken to legalize the given generic instruction. More...
 
LLT findLegalType (const InstrAspect &Aspect, std::function< 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...
 
LLT findLegalType (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
 

Detailed Description

Definition at line 49 of file LegalizerInfo.h.

Member Enumeration Documentation

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 51 of file LegalizerInfo.h.

Constructor & Destructor Documentation

LegalizerInfo::LegalizerInfo ( )

Definition at line 30 of file LegalizerInfo.cpp.

References Legal, NarrowScalar, and WidenScalar.

Member Function Documentation

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 46 of file LegalizerInfo.cpp.

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

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

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 174 of file LegalizerInfo.h.

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

Referenced by getAction().

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

Definition at line 166 of file LegalizerInfo.h.

References findLegalType().

Referenced by getAction().

LLT llvm::LegalizerInfo::findLegalType ( const InstrAspect Aspect,
std::function< 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 146 of file LegalizerInfo.h.

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

Referenced by findLegalAction(), and findLegalType().

LLT LegalizerInfo::findLegalType ( 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.

Definition at line 155 of file LegalizerInfo.cpp.

References llvm::LLT::doubleElements(), llvm::LLT::doubleScalarSize(), FewerElements, findLegalType(), llvm::LLT::getSizeInBits(), llvm::LLT::halfElements(), llvm::LLT::halfScalarSize(), Legal, Libcall, llvm_unreachable, Lower, MoreElements, NarrowScalar, llvm::LLT::scalar(), llvm::InstrAspect::Type, and WidenScalar.

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 69 of file LegalizerInfo.cpp.

References assert(), 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, MoreElements, NarrowScalar, NotFound, llvm::InstrAspect::Opcode, llvm::InstrAspect::Type, and Unsupported.

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

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 126 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(), i, Legal, llvm::MCInstrDesc::OpInfo, and llvm::SmallBitVector::set().

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

Definition at line 150 of file LegalizerInfo.cpp.

References getAction(), and Legal.

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

More friendly way to set an action for common types that have an LLT representation.

Definition at line 107 of file LegalizerInfo.h.

References llvm::InstrAspect::Idx, llvm::InstrAspect::Opcode, and llvm::InstrAspect::Type.

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

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 120 of file LegalizerInfo.h.

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


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