LLVM 20.0.0git
|
#include "llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h"
Public Types | |
using | SizeAndAction = std::pair< uint16_t, LegacyLegalizeActions::LegacyLegalizeAction > |
using | SizeAndActionsVec = std::vector< SizeAndAction > |
using | SizeChangeStrategy = std::function< SizeAndActionsVec(const SizeAndActionsVec &v)> |
Public Member Functions | |
LegacyLegalizerInfo () | |
void | computeTables () |
Compute any ancillary tables needed to quickly decide how an operation should be handled. | |
void | setAction (const InstrAspect &Aspect, LegacyLegalizeActions::LegacyLegalizeAction Action) |
More friendly way to set an action for common types that have an LLT representation. | |
void | setLegalizeScalarToDifferentSizeStrategy (const unsigned Opcode, const unsigned TypeIdx, SizeChangeStrategy S) |
The setAction calls record the non-size-changing legalization actions to take on specificly-sized types. | |
void | setLegalizeVectorElementToDifferentSizeStrategy (const unsigned Opcode, const unsigned TypeIdx, SizeChangeStrategy S) |
See also setLegalizeScalarToDifferentSizeStrategy. | |
LegacyLegalizeActionStep | getAction (const LegalityQuery &Query) const |
unsigned | getOpcodeIdxForOpcode (unsigned Opcode) const |
Static Public Member Functions | |
static bool | needsLegalizingToDifferentSize (const LegacyLegalizeActions::LegacyLegalizeAction Action) |
static SizeAndActionsVec | unsupportedForDifferentSizes (const SizeAndActionsVec &v) |
A SizeChangeStrategy for the common case where legalization for a particular operation consists of only supporting a specific set of type sizes. | |
static SizeAndActionsVec | widenToLargerTypesAndNarrowToLargest (const SizeAndActionsVec &v) |
A SizeChangeStrategy for the common case where legalization for a particular operation consists of widening the type to a large legal type, unless there is no such type and then instead it should be narrowed to the largest legal type. | |
static SizeAndActionsVec | widenToLargerTypesUnsupportedOtherwise (const SizeAndActionsVec &v) |
static SizeAndActionsVec | narrowToSmallerAndUnsupportedIfTooSmall (const SizeAndActionsVec &v) |
static SizeAndActionsVec | moreToWiderTypesAndLessToWidest (const SizeAndActionsVec &v) |
A SizeChangeStrategy for the common case where legalization for a particular vector operation consists of having more elements in the vector, to a type that is legal. | |
static SizeAndActionsVec | increaseToLargerTypesAndDecreaseToLargest (const SizeAndActionsVec &v, LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction, LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction) |
Helper function to implement many typical SizeChangeStrategy functions. | |
static SizeAndActionsVec | decreaseToSmallerTypesAndIncreaseToSmallest (const SizeAndActionsVec &v, LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction, LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction) |
Helper function to implement many typical SizeChangeStrategy functions. | |
Definition at line 120 of file LegacyLegalizerInfo.h.
using llvm::LegacyLegalizerInfo::SizeAndAction = std::pair<uint16_t, LegacyLegalizeActions::LegacyLegalizeAction> |
Definition at line 122 of file LegacyLegalizerInfo.h.
using llvm::LegacyLegalizerInfo::SizeAndActionsVec = std::vector<SizeAndAction> |
Definition at line 124 of file LegacyLegalizerInfo.h.
using llvm::LegacyLegalizerInfo::SizeChangeStrategy = std::function<SizeAndActionsVec(const SizeAndActionsVec &v)> |
Definition at line 125 of file LegacyLegalizerInfo.h.
LegacyLegalizerInfo::LegacyLegalizerInfo | ( | ) |
Definition at line 67 of file LegacyLegalizerInfo.cpp.
References llvm::IRSimilarity::Legal, llvm::Lower, narrowToSmallerAndUnsupportedIfTooSmall(), setLegalizeScalarToDifferentSizeStrategy(), widenToLargerTypesAndNarrowToLargest(), and widenToLargerTypesUnsupportedOtherwise().
void LegacyLegalizerInfo::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 105 of file LegacyLegalizerInfo.cpp.
References assert(), llvm::IRSimilarity::Legal, moreToWiderTypesAndLessToWidest(), llvm::size(), llvm::sort(), and unsupportedForDifferentSizes().
Referenced by llvm::AArch64LegalizerInfo::AArch64LegalizerInfo(), llvm::BPFLegalizerInfo::BPFLegalizerInfo(), llvm::M68kLegalizerInfo::M68kLegalizerInfo(), llvm::MipsLegalizerInfo::MipsLegalizerInfo(), llvm::PPCLegalizerInfo::PPCLegalizerInfo(), llvm::SPIRVLegalizerInfo::SPIRVLegalizerInfo(), and llvm::X86LegalizerInfo::X86LegalizerInfo().
|
static |
Helper function to implement many typical SizeChangeStrategy functions.
Definition at line 231 of file LegacyLegalizerInfo.cpp.
Referenced by narrowToSmallerAndUnsupportedIfTooSmall().
LegacyLegalizeActionStep LegacyLegalizerInfo::getAction | ( | const LegalityQuery & | Query | ) | const |
Definition at line 373 of file LegacyLegalizerInfo.cpp.
References llvm::dbgs(), llvm::IRSimilarity::Legal, LLVM_DEBUG, llvm::LegalityQuery::Opcode, and llvm::LegalityQuery::Types.
Referenced by llvm::LegalizerInfo::getAction().
Definition at line 366 of file LegacyLegalizerInfo.cpp.
References assert().
|
static |
Helper function to implement many typical SizeChangeStrategy functions.
Definition at line 211 of file LegacyLegalizerInfo.cpp.
Referenced by moreToWiderTypesAndLessToWidest(), unsupportedForDifferentSizes(), widenToLargerTypesAndNarrowToLargest(), and widenToLargerTypesUnsupportedOtherwise().
|
inlinestatic |
A SizeChangeStrategy for the common case where legalization for a particular vector operation consists of having more elements in the vector, to a type that is legal.
Unless there is no such type and then instead it should be legalized towards the widest vector that's still legal. E.g. setAction({G_ADD, LLT::vector(8, 8)}, Legal); setAction({G_ADD, LLT::vector(16, 8)}, Legal); setAction({G_ADD, LLT::vector(2, 32)}, Legal); setAction({G_ADD, LLT::vector(4, 32)}, Legal); setLegalizeVectorElementToDifferentSizeStrategy( G_ADD, 0, moreToWiderTypesAndLessToWidest); will result in the following getAction results:
Definition at line 263 of file LegacyLegalizerInfo.h.
References increaseToLargerTypesAndDecreaseToLargest().
Referenced by computeTables().
|
inlinestatic |
Definition at line 238 of file LegacyLegalizerInfo.h.
References decreaseToSmallerTypesAndIncreaseToSmallest().
Referenced by LegacyLegalizerInfo().
|
inlinestatic |
Definition at line 130 of file LegacyLegalizerInfo.h.
Referenced by setAction().
|
inline |
More friendly way to set an action for common types that have an LLT representation.
The LegacyLegalizeAction must be one for which NeedsLegalizingToDifferentSize returns false.
Definition at line 154 of file LegacyLegalizerInfo.h.
References assert(), llvm::InstrAspect::Idx, needsLegalizingToDifferentSize(), llvm::InstrAspect::Opcode, llvm::size(), and llvm::InstrAspect::Type.
|
inline |
The setAction calls record the non-size-changing legalization actions to take on specificly-sized types.
The SizeChangeStrategy defines what to do when the size of the type needs to be changed to reach a legally sized type (i.e., one that was defined through a setAction call). e.g. setAction ({G_ADD, 0, LLT::scalar(32)}, Legal); setLegalizeScalarToDifferentSizeStrategy( G_ADD, 0, widenToLargerTypesAndNarrowToLargest); will end up defining getAction({G_ADD, 0, T}) to return the following actions for different scalar types T: LLT::scalar(1)..LLT::scalar(31): {WidenScalar, 0, LLT::scalar(32)} LLT::scalar(32): {Legal, 0, LLT::scalar(32)} LLT::scalar(33)..: {NarrowScalar, 0, LLT::scalar(32)}
If no SizeChangeAction gets defined, through this function, the default is unsupportedForDifferentSizes.
Definition at line 180 of file LegacyLegalizerInfo.h.
References llvm::SmallVectorImpl< T >::resize(), and llvm::size().
Referenced by LegacyLegalizerInfo().
|
inline |
See also setLegalizeScalarToDifferentSizeStrategy.
This function allows to set the SizeChangeStrategy for vector elements.
Definition at line 191 of file LegacyLegalizerInfo.h.
References llvm::SmallVectorImpl< T >::resize(), and llvm::size().
|
inlinestatic |
A SizeChangeStrategy for the common case where legalization for a particular operation consists of only supporting a specific set of type sizes.
E.g. setAction ({G_DIV, 0, LLT::scalar(32)}, Legal); setAction ({G_DIV, 0, LLT::scalar(64)}, Legal); setLegalizeScalarToDifferentSizeStrategy( G_DIV, 0, unsupportedForDifferentSizes); will result in getAction({G_DIV, 0, T}) to return Legal for s32 and s64, and Unsupported for all other scalar types T.
Definition at line 210 of file LegacyLegalizerInfo.h.
References increaseToLargerTypesAndDecreaseToLargest().
Referenced by computeTables().
|
inlinestatic |
A SizeChangeStrategy for the common case where legalization for a particular operation consists of widening the type to a large legal type, unless there is no such type and then instead it should be narrowed to the largest legal type.
Definition at line 221 of file LegacyLegalizerInfo.h.
References assert(), and increaseToLargerTypesAndDecreaseToLargest().
Referenced by LegacyLegalizerInfo().
|
inlinestatic |
Definition at line 231 of file LegacyLegalizerInfo.h.
References increaseToLargerTypesAndDecreaseToLargest().
Referenced by LegacyLegalizerInfo().