LLVM 22.0.0git
llvm::LegacyLegalizerInfo Class Reference

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

Public Types

using SizeAndAction
using SizeAndActionsVec = std::vector<SizeAndAction>
using SizeChangeStrategy

Public Member Functions

LLVM_ABI LegacyLegalizerInfo ()
LLVM_ABI 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.
LLVM_ABI LegacyLegalizeActionStep getAction (const LegalityQuery &Query) const
LLVM_ABI 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 LLVM_ABI SizeAndActionsVec increaseToLargerTypesAndDecreaseToLargest (const SizeAndActionsVec &v, LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction, LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction)
 Helper function to implement many typical SizeChangeStrategy functions.
static LLVM_ABI SizeAndActionsVec decreaseToSmallerTypesAndIncreaseToSmallest (const SizeAndActionsVec &v, LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction, LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction)
 Helper function to implement many typical SizeChangeStrategy functions.

Detailed Description

Definition at line 121 of file LegacyLegalizerInfo.h.

Member Typedef Documentation

◆ SizeAndAction

Initial value:
std::pair<uint16_t, LegacyLegalizeActions::LegacyLegalizeAction>

Definition at line 123 of file LegacyLegalizerInfo.h.

◆ SizeAndActionsVec

Definition at line 125 of file LegacyLegalizerInfo.h.

◆ SizeChangeStrategy

Initial value:
std::function<SizeAndActionsVec(const SizeAndActionsVec &v)>
std::vector< SizeAndAction > SizeAndActionsVec

Definition at line 126 of file LegacyLegalizerInfo.h.

Constructor & Destructor Documentation

◆ LegacyLegalizerInfo()

Member Function Documentation

◆ computeTables()

void LegacyLegalizerInfo::computeTables ( )

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

Referenced by narrowToSmallerAndUnsupportedIfTooSmall().

◆ getAction()

◆ getOpcodeIdxForOpcode()

unsigned LegacyLegalizerInfo::getOpcodeIdxForOpcode ( unsigned Opcode) const

Definition at line 365 of file LegacyLegalizerInfo.cpp.

References assert().

◆ increaseToLargerTypesAndDecreaseToLargest()

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

◆ moreToWiderTypesAndLessToWidest()

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 264 of file LegacyLegalizerInfo.h.

References increaseToLargerTypesAndDecreaseToLargest().

Referenced by computeTables().

◆ narrowToSmallerAndUnsupportedIfTooSmall()

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

Definition at line 239 of file LegacyLegalizerInfo.h.

References decreaseToSmallerTypesAndIncreaseToSmallest().

Referenced by LegacyLegalizerInfo().

◆ needsLegalizingToDifferentSize()

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

Definition at line 131 of file LegacyLegalizerInfo.h.

Referenced by setAction().

◆ 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 155 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 181 of file LegacyLegalizerInfo.h.

References 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 192 of file LegacyLegalizerInfo.h.

References llvm::size().

◆ unsupportedForDifferentSizes()

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 211 of file LegacyLegalizerInfo.h.

References increaseToLargerTypesAndDecreaseToLargest().

Referenced by computeTables().

◆ widenToLargerTypesAndNarrowToLargest()

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 222 of file LegacyLegalizerInfo.h.

References assert(), and increaseToLargerTypesAndDecreaseToLargest().

Referenced by LegacyLegalizerInfo().

◆ widenToLargerTypesUnsupportedOtherwise()

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

Definition at line 232 of file LegacyLegalizerInfo.h.

References increaseToLargerTypesAndDecreaseToLargest().

Referenced by LegacyLegalizerInfo().


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