LLVM  13.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::LegacyLegalizerInfo Class Reference

#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. More...
 
void setAction (const InstrAspect &Aspect, LegacyLegalizeActions::LegacyLegalizeAction Action)
 More friendly way to set an action for common types that have an LLT representation. More...
 
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. More...
 
void setLegalizeVectorElementToDifferentSizeStrategy (const unsigned Opcode, const unsigned TypeIdx, SizeChangeStrategy S)
 See also setLegalizeScalarToDifferentSizeStrategy. More...
 
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. More...
 
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. More...
 
static SizeAndActionsVec widenToLargerTypesUnsupportedOtherwise (const SizeAndActionsVec &v)
 
static SizeAndActionsVec narrowToSmallerAndUnsupportedIfTooSmall (const SizeAndActionsVec &v)
 
static SizeAndActionsVec narrowToSmallerAndWidenToSmallest (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. More...
 
static SizeAndActionsVec increaseToLargerTypesAndDecreaseToLargest (const SizeAndActionsVec &v, LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction, LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction)
 Helper function to implement many typical SizeChangeStrategy functions. More...
 
static SizeAndActionsVec decreaseToSmallerTypesAndIncreaseToSmallest (const SizeAndActionsVec &v, LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction, LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction)
 Helper function to implement many typical SizeChangeStrategy functions. More...
 

Detailed Description

Definition at line 119 of file LegacyLegalizerInfo.h.

Member Typedef Documentation

◆ SizeAndAction

Definition at line 122 of file LegacyLegalizerInfo.h.

◆ SizeAndActionsVec

Definition at line 123 of file LegacyLegalizerInfo.h.

◆ SizeChangeStrategy

Definition at line 125 of file LegacyLegalizerInfo.h.

Constructor & Destructor Documentation

◆ LegacyLegalizerInfo()

LegacyLegalizerInfo::LegacyLegalizerInfo ( )

Member Function Documentation

◆ computeTables()

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 102 of file LegacyLegalizerInfo.cpp.

References assert(), llvm::IRSimilarity::Legal, moreToWiderTypesAndLessToWidest(), S, llvm::size(), llvm::sort(), and unsupportedForDifferentSizes().

Referenced by llvm::AArch64LegalizerInfo::AArch64LegalizerInfo(), llvm::M68kLegalizerInfo::M68kLegalizerInfo(), llvm::MipsLegalizerInfo::MipsLegalizerInfo(), and llvm::RISCVLegalizerInfo::RISCVLegalizerInfo().

◆ decreaseToSmallerTypesAndIncreaseToSmallest()

LegacyLegalizerInfo::SizeAndActionsVec LegacyLegalizerInfo::decreaseToSmallerTypesAndIncreaseToSmallest ( const SizeAndActionsVec v,
LegacyLegalizeActions::LegacyLegalizeAction  DecreaseAction,
LegacyLegalizeActions::LegacyLegalizeAction  IncreaseAction 
)
static

Helper function to implement many typical SizeChangeStrategy functions.

Definition at line 228 of file LegacyLegalizerInfo.cpp.

References i, and result.

Referenced by narrowToSmallerAndUnsupportedIfTooSmall(), and narrowToSmallerAndWidenToSmallest().

◆ getAction()

LegacyLegalizeActionStep LegacyLegalizerInfo::getAction ( const LegalityQuery Query) const

◆ getOpcodeIdxForOpcode()

unsigned LegacyLegalizerInfo::getOpcodeIdxForOpcode ( unsigned  Opcode) const

Definition at line 363 of file LegacyLegalizerInfo.cpp.

References assert().

◆ increaseToLargerTypesAndDecreaseToLargest()

LegacyLegalizerInfo::SizeAndActionsVec LegacyLegalizerInfo::increaseToLargerTypesAndDecreaseToLargest ( const SizeAndActionsVec v,
LegacyLegalizeActions::LegacyLegalizeAction  IncreaseAction,
LegacyLegalizeActions::LegacyLegalizeAction  DecreaseAction 
)
static

Helper function to implement many typical SizeChangeStrategy functions.

Definition at line 208 of file LegacyLegalizerInfo.cpp.

References i, and result.

Referenced by moreToWiderTypesAndLessToWidest(), unsupportedForDifferentSizes(), widenToLargerTypesAndNarrowToLargest(), and widenToLargerTypesUnsupportedOtherwise().

◆ moreToWiderTypesAndLessToWidest()

static SizeAndActionsVec llvm::LegacyLegalizerInfo::moreToWiderTypesAndLessToWidest ( const SizeAndActionsVec v)
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:

  • getAction({G_ADD, LLT::vector(8,8)}) returns (Legal, vector(8,8)).
  • getAction({G_ADD, LLT::vector(9,8)}) returns (MoreElements, vector(16,8)).
  • getAction({G_ADD, LLT::vector(8,32)}) returns (FewerElements, vector(4,32)).

Definition at line 272 of file LegacyLegalizerInfo.h.

References llvm::LegacyLegalizeActions::FewerElements, increaseToLargerTypesAndDecreaseToLargest(), and llvm::LegacyLegalizeActions::MoreElements.

Referenced by computeTables().

◆ narrowToSmallerAndUnsupportedIfTooSmall()

static SizeAndActionsVec llvm::LegacyLegalizerInfo::narrowToSmallerAndUnsupportedIfTooSmall ( const SizeAndActionsVec v)
inlinestatic

◆ narrowToSmallerAndWidenToSmallest()

static SizeAndActionsVec llvm::LegacyLegalizerInfo::narrowToSmallerAndWidenToSmallest ( const SizeAndActionsVec v)
inlinestatic

◆ needsLegalizingToDifferentSize()

static bool llvm::LegacyLegalizerInfo::needsLegalizingToDifferentSize ( const LegacyLegalizeActions::LegacyLegalizeAction  Action)
inlinestatic

◆ setAction()

void llvm::LegacyLegalizerInfo::setAction ( const InstrAspect Aspect,
LegacyLegalizeActions::LegacyLegalizeAction  Action 
)
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 153 of file LegacyLegalizerInfo.h.

References assert(), llvm::InstrAspect::Idx, needsLegalizingToDifferentSize(), llvm::InstrAspect::Opcode, llvm::size(), and llvm::InstrAspect::Type.

◆ setLegalizeScalarToDifferentSizeStrategy()

void llvm::LegacyLegalizerInfo::setLegalizeScalarToDifferentSizeStrategy ( const unsigned  Opcode,
const unsigned  TypeIdx,
SizeChangeStrategy  S 
)
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 179 of file LegacyLegalizerInfo.h.

References llvm::SmallVectorImpl< T >::resize(), S, and llvm::size().

Referenced by LegacyLegalizerInfo().

◆ setLegalizeVectorElementToDifferentSizeStrategy()

void llvm::LegacyLegalizerInfo::setLegalizeVectorElementToDifferentSizeStrategy ( const unsigned  Opcode,
const unsigned  TypeIdx,
SizeChangeStrategy  S 
)
inline

See also setLegalizeScalarToDifferentSizeStrategy.

This function allows to set the SizeChangeStrategy for vector elements.

Definition at line 190 of file LegacyLegalizerInfo.h.

References llvm::SmallVectorImpl< T >::resize(), S, and llvm::size().

◆ unsupportedForDifferentSizes()

static SizeAndActionsVec llvm::LegacyLegalizerInfo::unsupportedForDifferentSizes ( const SizeAndActionsVec v)
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 209 of file LegacyLegalizerInfo.h.

References increaseToLargerTypesAndDecreaseToLargest().

Referenced by computeTables().

◆ widenToLargerTypesAndNarrowToLargest()

static SizeAndActionsVec llvm::LegacyLegalizerInfo::widenToLargerTypesAndNarrowToLargest ( const SizeAndActionsVec v)
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 220 of file LegacyLegalizerInfo.h.

References assert(), increaseToLargerTypesAndDecreaseToLargest(), llvm::LegacyLegalizeActions::NarrowScalar, and llvm::LegacyLegalizeActions::WidenScalar.

Referenced by LegacyLegalizerInfo(), and llvm::X86LegalizerInfo::X86LegalizerInfo().

◆ widenToLargerTypesUnsupportedOtherwise()

static SizeAndActionsVec llvm::LegacyLegalizerInfo::widenToLargerTypesUnsupportedOtherwise ( const SizeAndActionsVec v)
inlinestatic

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