class LegacyLegalizerInfo

Declaration

class LegacyLegalizerInfo { /* full declaration omitted */ };

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:119

Member Variables

private SmallVector<llvm::LegacyLegalizerInfo::TypeMap, 1>[202] SpecifiedActions
private SmallVector< llvm::LegacyLegalizerInfo::SizeChangeStrategy, 1>[202] ScalarSizeChangeStrategies
private SmallVector< llvm::LegacyLegalizerInfo::SizeChangeStrategy, 1>[202] VectorElementSizeChangeStrategies
private bool TablesInitialized = false
private SmallVector< llvm::LegacyLegalizerInfo::SizeAndActionsVec, 1>[202] ScalarActions
private SmallVector< llvm::LegacyLegalizerInfo::SizeAndActionsVec, 1>[202] ScalarInVectorActions
private std::unordered_map< uint16_t, SmallVector<SizeAndActionsVec, 1>>[202] AddrSpace2PointerActions
private std::unordered_map< uint16_t, SmallVector<SizeAndActionsVec, 1>>[202] NumElements2Actions
private static const int FirstOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_START
private static const int LastOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END

Method Overview

  • public LegacyLegalizerInfo()
  • private static void checkFullSizeAndActionsVector(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v)
  • private static void checkPartialSizeAndActionsVector(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v)
  • public void computeTables()
  • public static llvm::LegacyLegalizerInfo::SizeAndActionsVec decreaseToSmallerTypesAndIncreaseToSmallest(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v, LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction, LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction)
  • private static llvm::LegacyLegalizerInfo::SizeAndAction findAction(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & Vec, const uint32_t Size)
  • private std::pair<LegacyLegalizeActions::LegacyLegalizeAction, LLT> findScalarLegalAction(const llvm::InstrAspect & Aspect) const
  • private std::pair<LegacyLegalizeActions::LegacyLegalizeAction, LLT> findVectorLegalAction(const llvm::InstrAspect & Aspect) const
  • public llvm::LegacyLegalizeActionStep getAction(const llvm::LegalityQuery & Query) const
  • private std::pair<LegacyLegalizeActions::LegacyLegalizeAction, LLT> getAspectAction(const llvm::InstrAspect & Aspect) const
  • public unsigned int getOpcodeIdxForOpcode(unsigned int Opcode) const
  • public static llvm::LegacyLegalizerInfo::SizeAndActionsVec increaseToLargerTypesAndDecreaseToLargest(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v, LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction, LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction)
  • public static llvm::LegacyLegalizerInfo::SizeAndActionsVec moreToWiderTypesAndLessToWidest(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v)
  • public static llvm::LegacyLegalizerInfo::SizeAndActionsVec narrowToSmallerAndUnsupportedIfTooSmall(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v)
  • public static llvm::LegacyLegalizerInfo::SizeAndActionsVec narrowToSmallerAndWidenToSmallest(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v)
  • public static bool needsLegalizingToDifferentSize(const LegacyLegalizeActions::LegacyLegalizeAction Action)
  • public void setAction(const llvm::InstrAspect & Aspect, LegacyLegalizeActions::LegacyLegalizeAction Action)
  • private void setActions(unsigned int TypeIndex, SmallVector<llvm::LegacyLegalizerInfo::SizeAndActionsVec, 1> & Actions, const llvm::LegacyLegalizerInfo::SizeAndActionsVec & SizeAndActions)
  • public void setLegalizeScalarToDifferentSizeStrategy(const unsigned int Opcode, const unsigned int TypeIdx, llvm::LegacyLegalizerInfo::SizeChangeStrategy S)
  • public void setLegalizeVectorElementToDifferentSizeStrategy(const unsigned int Opcode, const unsigned int TypeIdx, llvm::LegacyLegalizerInfo::SizeChangeStrategy S)
  • private void setPointerAction(const unsigned int Opcode, const unsigned int TypeIndex, const unsigned int AddressSpace, const llvm::LegacyLegalizerInfo::SizeAndActionsVec & SizeAndActions)
  • private void setScalarAction(const unsigned int Opcode, const unsigned int TypeIndex, const llvm::LegacyLegalizerInfo::SizeAndActionsVec & SizeAndActions)
  • private void setScalarInVectorAction(const unsigned int Opcode, const unsigned int TypeIndex, const llvm::LegacyLegalizerInfo::SizeAndActionsVec & SizeAndActions)
  • private void setVectorNumElementAction(const unsigned int Opcode, const unsigned int TypeIndex, const unsigned int ElementSize, const llvm::LegacyLegalizerInfo::SizeAndActionsVec & SizeAndActions)
  • public static llvm::LegacyLegalizerInfo::SizeAndActionsVec unsupportedForDifferentSizes(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v)
  • public static llvm::LegacyLegalizerInfo::SizeAndActionsVec widenToLargerTypesAndNarrowToLargest(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v)
  • public static llvm::LegacyLegalizerInfo::SizeAndActionsVec widenToLargerTypesUnsupportedOtherwise(const llvm::LegacyLegalizerInfo::SizeAndActionsVec & v)

Methods

LegacyLegalizerInfo()

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:127

static void checkFullSizeAndActionsVector(
    const llvm::LegacyLegalizerInfo::
        SizeAndActionsVec& v)

Description

A full SizeAndActionsVec must cover all bit sizes, i.e. must start with from size 1.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:417

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v

static void checkPartialSizeAndActionsVector(
    const llvm::LegacyLegalizerInfo::
        SizeAndActionsVec& v)

Description

A partial SizeAndActionsVec potentially doesn't cover all bit sizes, i.e. it's OK if it doesn't start from size 1.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:369

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v

void computeTables()

Description

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.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:147

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

Description

Helper function to implement many typical SizeChangeStrategy functions.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:284

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v
LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction
LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction

static llvm::LegacyLegalizerInfo::SizeAndAction
findAction(const llvm::LegacyLegalizerInfo::
               SizeAndActionsVec& Vec,
           const uint32_t Size)

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:437

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& Vec
const uint32_t Size

std::pair<
    LegacyLegalizeActions::LegacyLegalizeAction,
    LLT>
findScalarLegalAction(
    const llvm::InstrAspect& Aspect) const

Description

Returns the next action needed to get the scalar or pointer type closer to being legal E.g. findLegalAction({G_REM, 13}) should return (WidenScalar, 32). After that, findLegalAction({G_REM, 32}) will probably be called, which should return (Lower, 32). This is assuming the setScalarAction on G_REM was something like: setScalarAction(G_REM, 0, {{1, WidenScalar}, // bit sizes [ 1, 31[ {32, Lower}, // bit sizes [32, 33[ {33, NarrowScalar} // bit sizes [65, +inf[ });

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:452

Parameters

const llvm::InstrAspect& Aspect

std::pair<
    LegacyLegalizeActions::LegacyLegalizeAction,
    LLT>
findVectorLegalAction(
    const llvm::InstrAspect& Aspect) const

Description

Returns the next action needed towards legalizing the vector type.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:456

Parameters

const llvm::InstrAspect& Aspect

llvm::LegacyLegalizeActionStep getAction(
    const llvm::LegalityQuery& Query) const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:289

Parameters

const llvm::LegalityQuery& Query

std::pair<
    LegacyLegalizeActions::LegacyLegalizeAction,
    LLT>
getAspectAction(
    const llvm::InstrAspect& Aspect) const

Description

Determine what action should be taken to legalize the given generic instruction opcode, type-index and type. Requires computeTables to have been called.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:301

Parameters

const llvm::InstrAspect& Aspect

Returns

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

unsigned int getOpcodeIdxForOpcode(
    unsigned int Opcode) const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:291

Parameters

unsigned int Opcode

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

Description

Helper function to implement many typical SizeChangeStrategy functions.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:279

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v
LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction
LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction

static llvm::LegacyLegalizerInfo::
    SizeAndActionsVec
    moreToWiderTypesAndLessToWidest(
        const llvm::LegacyLegalizerInfo::
            SizeAndActionsVec& v)

Description

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)).

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:272

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v

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

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:237

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v

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

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:244

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v

static bool needsLegalizingToDifferentSize(
    const LegacyLegalizeActions::
        LegacyLegalizeAction Action)

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:129

Parameters

const LegacyLegalizeActions::LegacyLegalizeAction Action

void setAction(
    const llvm::InstrAspect& Aspect,
    LegacyLegalizeActions::LegacyLegalizeAction
        Action)

Description

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.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:153

Parameters

const llvm::InstrAspect& Aspect
LegacyLegalizeActions::LegacyLegalizeAction Action

void setActions(
    unsigned int TypeIndex,
    SmallVector<llvm::LegacyLegalizerInfo::
                    SizeAndActionsVec,
                1>& Actions,
    const llvm::LegacyLegalizerInfo::
        SizeAndActionsVec& SizeAndActions)

Description

Sets actions for all bit sizes on a particular generic opcode, type index and scalar or pointer type.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:428

Parameters

unsigned int TypeIndex
SmallVector< llvm::LegacyLegalizerInfo::SizeAndActionsVec, 1>& Actions
const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& SizeAndActions

void setLegalizeScalarToDifferentSizeStrategy(
    const unsigned int Opcode,
    const unsigned int TypeIdx,
    llvm::LegacyLegalizerInfo::SizeChangeStrategy
        S)

Description

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.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:179

Parameters

const unsigned int Opcode
const unsigned int TypeIdx
llvm::LegacyLegalizerInfo::SizeChangeStrategy S

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

Description

See also setLegalizeScalarToDifferentSizeStrategy. This function allows to set the SizeChangeStrategy for vector elements.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:190

Parameters

const unsigned int Opcode
const unsigned int TypeIdx
llvm::LegacyLegalizerInfo::SizeChangeStrategy S

void setPointerAction(
    const unsigned int Opcode,
    const unsigned int TypeIndex,
    const unsigned int AddressSpace,
    const llvm::LegacyLegalizerInfo::
        SizeAndActionsVec& SizeAndActions)

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:326

Parameters

const unsigned int Opcode
const unsigned int TypeIndex
const unsigned int AddressSpace
const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& SizeAndActions

void setScalarAction(
    const unsigned int Opcode,
    const unsigned int TypeIndex,
    const llvm::LegacyLegalizerInfo::
        SizeAndActionsVec& SizeAndActions)

Description

The SizeAndActionsVec is a representation mapping between all natural numbers and an Action. The natural number represents the bit size of the InstrAspect. For example, for a target with native support for 32-bit and 64-bit additions, you'd express that as: setScalarAction(G_ADD, 0, {{1, WidenScalar}, // bit sizes [ 1, 31[ {32, Legal}, // bit sizes [32, 33[ {33, WidenScalar}, // bit sizes [33, 64[ {64, Legal}, // bit sizes [64, 65[ {65, NarrowScalar} // bit sizes [65, +inf[ }); It may be that only 64-bit pointers are supported on your target: setPointerAction(G_PTR_ADD, 0, LLT:pointer(1), {{1, Unsupported}, // bit sizes [ 1, 63[ {64, Legal}, // bit sizes [64, 65[ {65, Unsupported}, // bit sizes [65, +inf[ });

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:320

Parameters

const unsigned int Opcode
const unsigned int TypeIndex
const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& SizeAndActions

void setScalarInVectorAction(
    const unsigned int Opcode,
    const unsigned int TypeIndex,
    const llvm::LegacyLegalizerInfo::
        SizeAndActionsVec& SizeAndActions)

Description

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.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:343

Parameters

const unsigned int Opcode
const unsigned int TypeIndex
const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& SizeAndActions

void setVectorNumElementAction(
    const unsigned int Opcode,
    const unsigned int TypeIndex,
    const unsigned int ElementSize,
    const llvm::LegacyLegalizerInfo::
        SizeAndActionsVec& SizeAndActions)

Description

See also setScalarInVectorAction. This function let's you specify the number of elements in a vector that are legal for a legal element size.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:354

Parameters

const unsigned int Opcode
const unsigned int TypeIndex
const unsigned int ElementSize
const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& SizeAndActions

static llvm::LegacyLegalizerInfo::
    SizeAndActionsVec
    unsupportedForDifferentSizes(
        const llvm::LegacyLegalizerInfo::
            SizeAndActionsVec& v)

Description

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.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:209

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v

static llvm::LegacyLegalizerInfo::
    SizeAndActionsVec
    widenToLargerTypesAndNarrowToLargest(
        const llvm::LegacyLegalizerInfo::
            SizeAndActionsVec& v)

Description

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.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:220

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v

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

Declared at: llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h:230

Parameters

const llvm::LegacyLegalizerInfo:: SizeAndActionsVec& v