[llvm] 076af82 - [GlobalISel] Remove LegacyLegalizerInfo (#197308)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 5 10:47:53 PDT 2026
Author: David Green
Date: 2026-07-05T18:47:48+01:00
New Revision: 076af822d2bfba95e5d62e15d0f11216956b1cb4
URL: https://github.com/llvm/llvm-project/commit/076af822d2bfba95e5d62e15d0f11216956b1cb4
DIFF: https://github.com/llvm/llvm-project/commit/076af822d2bfba95e5d62e15d0f11216956b1cb4.diff
LOG: [GlobalISel] Remove LegacyLegalizerInfo (#197308)
After #197238, #197370, #197371, #197374, #197375, #197377, #197378 and
#197379, this removes the legacy rules from global isel.
The above patches attempt to make all _tested_ operations legal, but
have only gone through the operations that have llvm tests. If more
fallbacks are now found to be happening, the other operations from
#197238 might be needed.
Added:
Modified:
llvm/docs/GlobalISel/Legalizer.rst
llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
llvm/lib/CodeGen/GlobalISel/CMakeLists.txt
llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
llvm/lib/Target/ARM/ARMLegalizerInfo.cpp
llvm/lib/Target/BPF/GISel/BPFLegalizerInfo.cpp
llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp
llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
llvm/lib/Target/PowerPC/GISel/PPCLegalizerInfo.cpp
llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp
llvm/lib/Target/WebAssembly/GISel/WebAssemblyLegalizerInfo.cpp
llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
llvm/utils/gn/secondary/llvm/lib/CodeGen/GlobalISel/BUILD.gn
Removed:
llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h
llvm/lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp
################################################################################
diff --git a/llvm/docs/GlobalISel/Legalizer.rst b/llvm/docs/GlobalISel/Legalizer.rst
index 74e83aef80ab2..0f35574b441ab 100644
--- a/llvm/docs/GlobalISel/Legalizer.rst
+++ b/llvm/docs/GlobalISel/Legalizer.rst
@@ -196,9 +196,6 @@ few actions in common:
if the predicate is satisfied and indicates that there is no way to make it
legal and the compiler should fail.
-* ``fallback()`` falls back on an older API and should only be used while porting
- existing code from that API.
-
Rule Predicates
"""""""""""""""
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h
deleted file mode 100644
index c4ceb99588906..0000000000000
--- a/llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h
+++ /dev/null
@@ -1,466 +0,0 @@
-//===- llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h ------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-/// \file
-/// Interface for Targets to specify which operations they can successfully
-/// select and how the others should be expanded most efficiently.
-/// This implementation has been deprecated for a long time but it still in use
-/// in a few places.
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CODEGEN_GLOBALISEL_LEGACYLEGALIZERINFO_H
-#define LLVM_CODEGEN_GLOBALISEL_LEGACYLEGALIZERINFO_H
-
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/CodeGen/TargetOpcodes.h"
-#include "llvm/CodeGenTypes/LowLevelType.h"
-#include "llvm/Support/Compiler.h"
-#include <vector>
-
-namespace llvm {
-struct LegalityQuery;
-
-namespace LegacyLegalizeActions {
-enum LegacyLegalizeAction : std::uint8_t {
- /// The operation is expected to be selectable directly by the target, and
- /// no transformation is necessary.
- Legal,
-
- /// 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.
- NarrowScalar,
-
- /// 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).
- WidenScalar,
-
- /// 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.
- FewerElements,
-
- /// 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.
- MoreElements,
-
- /// Perform the operation on a
diff erent, but equivalently sized type.
- Bitcast,
-
- /// The operation itself must be expressed in terms of simpler actions on
- /// this target. E.g. a SREM replaced by an SDIV and subtraction.
- Lower,
-
- /// 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.
- Libcall,
-
- /// The target wants to do something special with this combination of
- /// operand and type. A callback will be issued when it is needed.
- Custom,
-
- /// This operation is completely unsupported on the target. A programming
- /// error has occurred.
- Unsupported,
-
- /// Sentinel value for when no action was found in the specified table.
- NotFound,
-};
-} // end namespace LegacyLegalizeActions
-LLVM_ABI raw_ostream &
-operator<<(raw_ostream &OS, LegacyLegalizeActions::LegacyLegalizeAction Action);
-
-/// Legalization is decided based on an instruction's opcode, which type slot
-/// we're considering, and what the existing type is. These aspects are gathered
-/// together for convenience in the InstrAspect class.
-struct InstrAspect {
- unsigned Opcode;
- unsigned Idx = 0;
- LLT Type;
-
- InstrAspect(unsigned Opcode, LLT Type) : Opcode(Opcode), Type(Type) {}
- InstrAspect(unsigned Opcode, unsigned Idx, LLT Type)
- : Opcode(Opcode), Idx(Idx), Type(Type) {}
-
- bool operator==(const InstrAspect &RHS) const {
- return Opcode == RHS.Opcode && Idx == RHS.Idx && Type == RHS.Type;
- }
-};
-
-/// The result of a query. It either indicates a final answer of Legal or
-/// Unsupported or describes an action that must be taken to make an operation
-/// more legal.
-struct LegacyLegalizeActionStep {
- /// The action to take or the final answer.
- LegacyLegalizeActions::LegacyLegalizeAction Action;
- /// If describing an action, the type index to change. Otherwise zero.
- unsigned TypeIdx;
- /// If describing an action, the new type for TypeIdx. Otherwise LLT{}.
- LLT NewType;
-
- LegacyLegalizeActionStep(LegacyLegalizeActions::LegacyLegalizeAction Action,
- unsigned TypeIdx, const LLT NewType)
- : Action(Action), TypeIdx(TypeIdx), NewType(NewType) {}
-
- bool operator==(const LegacyLegalizeActionStep &RHS) const {
- return std::tie(Action, TypeIdx, NewType) ==
- std::tie(RHS.Action, RHS.TypeIdx, RHS.NewType);
- }
-};
-
-
-class LegacyLegalizerInfo {
-public:
- using SizeAndAction =
- std::pair<uint16_t, LegacyLegalizeActions::LegacyLegalizeAction>;
- using SizeAndActionsVec = std::vector<SizeAndAction>;
- using SizeChangeStrategy =
- std::function<SizeAndActionsVec(const SizeAndActionsVec &v)>;
-
- LLVM_ABI LegacyLegalizerInfo();
-
- static bool needsLegalizingToDifferentSize(
- const LegacyLegalizeActions::LegacyLegalizeAction Action) {
- using namespace LegacyLegalizeActions;
- switch (Action) {
- case NarrowScalar:
- case WidenScalar:
- case FewerElements:
- case MoreElements:
- case Unsupported:
- return true;
- default:
- return false;
- }
- }
-
- /// 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.
- LLVM_ABI void computeTables();
-
- /// 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.
- void setAction(const InstrAspect &Aspect,
- LegacyLegalizeActions::LegacyLegalizeAction Action) {
- assert(!needsLegalizingToDifferentSize(Action));
- TablesInitialized = false;
- const unsigned OpcodeIdx = Aspect.Opcode - FirstOp;
- if (SpecifiedActions[OpcodeIdx].size() <= Aspect.Idx)
- SpecifiedActions[OpcodeIdx].resize(Aspect.Idx + 1);
- SpecifiedActions[OpcodeIdx][Aspect.Idx][Aspect.Type] = Action;
- }
-
- /// 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
diff erent 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.
- void setLegalizeScalarToDifferentSizeStrategy(const unsigned Opcode,
- const unsigned TypeIdx,
- SizeChangeStrategy S) {
- const unsigned OpcodeIdx = Opcode - FirstOp;
- if (ScalarSizeChangeStrategies[OpcodeIdx].size() <= TypeIdx)
- ScalarSizeChangeStrategies[OpcodeIdx].resize(TypeIdx + 1);
- ScalarSizeChangeStrategies[OpcodeIdx][TypeIdx] = S;
- }
-
- /// See also setLegalizeScalarToDifferentSizeStrategy.
- /// This function allows to set the SizeChangeStrategy for vector elements.
- void setLegalizeVectorElementToDifferentSizeStrategy(const unsigned Opcode,
- const unsigned TypeIdx,
- SizeChangeStrategy S) {
- const unsigned OpcodeIdx = Opcode - FirstOp;
- if (VectorElementSizeChangeStrategies[OpcodeIdx].size() <= TypeIdx)
- VectorElementSizeChangeStrategies[OpcodeIdx].resize(TypeIdx + 1);
- VectorElementSizeChangeStrategies[OpcodeIdx][TypeIdx] = S;
- }
-
- /// 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.
- static SizeAndActionsVec
- unsupportedForDifferentSizes(const SizeAndActionsVec &v) {
- using namespace LegacyLegalizeActions;
- return increaseToLargerTypesAndDecreaseToLargest(v, Unsupported,
- Unsupported);
- }
-
- /// 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
- widenToLargerTypesAndNarrowToLargest(const SizeAndActionsVec &v) {
- using namespace LegacyLegalizeActions;
- assert(v.size() > 0 &&
- "At least one size that can be legalized towards is needed"
- " for this SizeChangeStrategy");
- return increaseToLargerTypesAndDecreaseToLargest(v, WidenScalar,
- NarrowScalar);
- }
-
- static SizeAndActionsVec
- widenToLargerTypesUnsupportedOtherwise(const SizeAndActionsVec &v) {
- using namespace LegacyLegalizeActions;
- return increaseToLargerTypesAndDecreaseToLargest(v, WidenScalar,
- Unsupported);
- }
-
- static SizeAndActionsVec
- narrowToSmallerAndUnsupportedIfTooSmall(const SizeAndActionsVec &v) {
- using namespace LegacyLegalizeActions;
- return decreaseToSmallerTypesAndIncreaseToSmallest(v, NarrowScalar,
- Unsupported);
- }
-
- /// 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)).
- static SizeAndActionsVec
- moreToWiderTypesAndLessToWidest(const SizeAndActionsVec &v) {
- using namespace LegacyLegalizeActions;
- return increaseToLargerTypesAndDecreaseToLargest(v, MoreElements,
- FewerElements);
- }
-
- /// Helper function to implement many typical SizeChangeStrategy functions.
- LLVM_ABI static SizeAndActionsVec increaseToLargerTypesAndDecreaseToLargest(
- const SizeAndActionsVec &v,
- LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction,
- LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction);
- /// Helper function to implement many typical SizeChangeStrategy functions.
- LLVM_ABI static SizeAndActionsVec decreaseToSmallerTypesAndIncreaseToSmallest(
- const SizeAndActionsVec &v,
- LegacyLegalizeActions::LegacyLegalizeAction DecreaseAction,
- LegacyLegalizeActions::LegacyLegalizeAction IncreaseAction);
-
- LLVM_ABI LegacyLegalizeActionStep getAction(const LegalityQuery &Query) const;
-
- LLVM_ABI unsigned getOpcodeIdxForOpcode(unsigned Opcode) const;
-
-private:
- /// 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.
- std::pair<LegacyLegalizeActions::LegacyLegalizeAction, LLT>
- getAspectAction(const InstrAspect &Aspect) const;
-
- /// 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[
- /// });
- void setScalarAction(const unsigned Opcode, const unsigned TypeIndex,
- const SizeAndActionsVec &SizeAndActions) {
- const unsigned OpcodeIdx = Opcode - FirstOp;
- SmallVector<SizeAndActionsVec, 1> &Actions = ScalarActions[OpcodeIdx];
- setActions(TypeIndex, Actions, SizeAndActions);
- }
- void setPointerAction(const unsigned Opcode, const unsigned TypeIndex,
- const unsigned AddressSpace,
- const SizeAndActionsVec &SizeAndActions) {
- const unsigned OpcodeIdx = Opcode - FirstOp;
- SmallVector<SizeAndActionsVec, 1> &Actions =
- AddrSpace2PointerActions[OpcodeIdx][AddressSpace];
- setActions(TypeIndex, Actions, SizeAndActions);
- }
-
- /// 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.
- void setScalarInVectorAction(const unsigned Opcode, const unsigned TypeIndex,
- const SizeAndActionsVec &SizeAndActions) {
- unsigned OpcodeIdx = Opcode - FirstOp;
- SmallVector<SizeAndActionsVec, 1> &Actions =
- ScalarInVectorActions[OpcodeIdx];
- setActions(TypeIndex, Actions, SizeAndActions);
- }
-
- /// See also setScalarInVectorAction.
- /// This function let's you specify the number of elements in a vector that
- /// are legal for a legal element size.
- void setVectorNumElementAction(const unsigned Opcode,
- const unsigned TypeIndex,
- const unsigned ElementSize,
- const SizeAndActionsVec &SizeAndActions) {
- const unsigned OpcodeIdx = Opcode - FirstOp;
- SmallVector<SizeAndActionsVec, 1> &Actions =
- NumElements2Actions[OpcodeIdx][ElementSize];
- setActions(TypeIndex, Actions, SizeAndActions);
- }
-
- /// A partial SizeAndActionsVec potentially doesn't cover all bit sizes,
- /// i.e. it's OK if it doesn't start from size 1.
- static void checkPartialSizeAndActionsVector(const SizeAndActionsVec& v) {
- using namespace LegacyLegalizeActions;
-#ifndef NDEBUG
- // The sizes should be in increasing order
- int prev_size = -1;
- for(auto SizeAndAction: v) {
- assert(SizeAndAction.first > prev_size);
- prev_size = SizeAndAction.first;
- }
- // - for every Widen action, there should be a larger bitsize that
- // can be legalized towards (e.g. Legal, Lower, Libcall or Custom
- // action).
- // - for every Narrow action, there should be a smaller bitsize that
- // can be legalized towards.
- int SmallestNarrowIdx = -1;
- int LargestWidenIdx = -1;
- int SmallestLegalizableToSameSizeIdx = -1;
- int LargestLegalizableToSameSizeIdx = -1;
- for(size_t i=0; i<v.size(); ++i) {
- switch (v[i].second) {
- case FewerElements:
- case NarrowScalar:
- if (SmallestNarrowIdx == -1)
- SmallestNarrowIdx = i;
- break;
- case WidenScalar:
- case MoreElements:
- LargestWidenIdx = i;
- break;
- case Unsupported:
- break;
- default:
- if (SmallestLegalizableToSameSizeIdx == -1)
- SmallestLegalizableToSameSizeIdx = i;
- LargestLegalizableToSameSizeIdx = i;
- }
- }
- if (SmallestNarrowIdx != -1) {
- assert(SmallestLegalizableToSameSizeIdx != -1);
- assert(SmallestNarrowIdx > SmallestLegalizableToSameSizeIdx);
- }
- if (LargestWidenIdx != -1)
- assert(LargestWidenIdx < LargestLegalizableToSameSizeIdx);
-#endif
- }
-
- /// A full SizeAndActionsVec must cover all bit sizes, i.e. must start with
- /// from size 1.
- static void checkFullSizeAndActionsVector(const SizeAndActionsVec& v) {
-#ifndef NDEBUG
- // Data structure invariant: The first bit size must be size 1.
- assert(v.size() >= 1);
- assert(v[0].first == 1);
- checkPartialSizeAndActionsVector(v);
-#endif
- }
-
- /// Sets actions for all bit sizes on a particular generic opcode, type
- /// index and scalar or pointer type.
- void setActions(unsigned TypeIndex,
- SmallVector<SizeAndActionsVec, 1> &Actions,
- const SizeAndActionsVec &SizeAndActions) {
- checkFullSizeAndActionsVector(SizeAndActions);
- if (Actions.size() <= TypeIndex)
- Actions.resize(TypeIndex + 1);
- Actions[TypeIndex] = SizeAndActions;
- }
-
- static SizeAndAction findAction(const SizeAndActionsVec &Vec,
- const uint32_t Size);
-
- /// 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[
- /// });
- std::pair<LegacyLegalizeActions::LegacyLegalizeAction, LLT>
- findScalarLegalAction(const InstrAspect &Aspect) const;
-
- /// Returns the next action needed towards legalizing the vector type.
- std::pair<LegacyLegalizeActions::LegacyLegalizeAction, LLT>
- findVectorLegalAction(const InstrAspect &Aspect) const;
-
- static const int FirstOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_START;
- static const int LastOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END;
-
- // Data structures used temporarily during construction of legality data:
- using TypeMap = DenseMap<LLT, LegacyLegalizeActions::LegacyLegalizeAction>;
- SmallVector<TypeMap, 1> SpecifiedActions[LastOp - FirstOp + 1];
- SmallVector<SizeChangeStrategy, 1>
- ScalarSizeChangeStrategies[LastOp - FirstOp + 1];
- SmallVector<SizeChangeStrategy, 1>
- VectorElementSizeChangeStrategies[LastOp - FirstOp + 1];
- bool TablesInitialized = false;
-
- // Data structures used by getAction:
- SmallVector<SizeAndActionsVec, 1> ScalarActions[LastOp - FirstOp + 1];
- SmallVector<SizeAndActionsVec, 1> ScalarInVectorActions[LastOp - FirstOp + 1];
- DenseMap<uint16_t, SmallVector<SizeAndActionsVec, 1>>
- AddrSpace2PointerActions[LastOp - FirstOp + 1];
- DenseMap<uint16_t, SmallVector<SizeAndActionsVec, 1>>
- NumElements2Actions[LastOp - FirstOp + 1];
-};
-
-} // end namespace llvm
-
-#endif // LLVM_CODEGEN_GLOBALISEL_LEGACYLEGALIZERINFO_H
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
index 92ecd74f68482..0f44830b24027 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -16,7 +16,6 @@
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGenTypes/LowLevelType.h"
@@ -93,10 +92,6 @@ enum LegalizeAction : std::uint8_t {
/// Sentinel value for when no action was found in the specified table.
NotFound,
-
- /// Fall back onto the old rules.
- /// TODO: Remove this once we've migrated
- UseLegacyRules,
};
} // end namespace LegalizeActions
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
@@ -154,45 +149,6 @@ struct LegalizeActionStep {
const LLT NewType)
: Action(Action), TypeIdx(TypeIdx), NewType(NewType) {}
- LegalizeActionStep(LegacyLegalizeActionStep Step)
- : TypeIdx(Step.TypeIdx), NewType(Step.NewType) {
- switch (Step.Action) {
- case LegacyLegalizeActions::Legal:
- Action = LegalizeActions::Legal;
- break;
- case LegacyLegalizeActions::NarrowScalar:
- Action = LegalizeActions::NarrowScalar;
- break;
- case LegacyLegalizeActions::WidenScalar:
- Action = LegalizeActions::WidenScalar;
- break;
- case LegacyLegalizeActions::FewerElements:
- Action = LegalizeActions::FewerElements;
- break;
- case LegacyLegalizeActions::MoreElements:
- Action = LegalizeActions::MoreElements;
- break;
- case LegacyLegalizeActions::Bitcast:
- Action = LegalizeActions::Bitcast;
- break;
- case LegacyLegalizeActions::Lower:
- Action = LegalizeActions::Lower;
- break;
- case LegacyLegalizeActions::Libcall:
- Action = LegalizeActions::Libcall;
- break;
- case LegacyLegalizeActions::Custom:
- Action = LegalizeActions::Custom;
- break;
- case LegacyLegalizeActions::Unsupported:
- Action = LegalizeActions::Unsupported;
- break;
- case LegacyLegalizeActions::NotFound:
- Action = LegalizeActions::NotFound;
- break;
- }
- }
-
bool operator==(const LegalizeActionStep &RHS) const {
return std::tie(Action, TypeIdx, NewType) ==
std::tie(RHS.Action, RHS.TypeIdx, RHS.NewType);
@@ -1354,13 +1310,6 @@ class LegalizeRuleSet {
.clampMaxNumElements(TypeIdx, EltTy, NumElts);
}
- /// Fallback on the previous implementation. This should only be used while
- /// porting a rule.
- LegalizeRuleSet &fallback() {
- add({always, LegalizeAction::UseLegacyRules});
- return *this;
- }
-
/// Check if there is no type index which is obviously not handled by the
/// LegalizeRuleSet in any way at all.
/// \pre Type indices of the opcode form a dense [0, \p NumTypeIdxs) set.
@@ -1378,11 +1327,6 @@ class LLVM_ABI LegalizerInfo {
public:
virtual ~LegalizerInfo() = default;
- const LegacyLegalizerInfo &getLegacyLegalizerInfo() const {
- return LegacyInfo;
- }
- LegacyLegalizerInfo &getLegacyLegalizerInfo() { return LegacyInfo; }
-
unsigned getOpcodeIdxForOpcode(unsigned Opcode) const;
unsigned getActionDefinitionsIdx(unsigned Opcode) const;
@@ -1470,7 +1414,6 @@ class LLVM_ABI LegalizerInfo {
static const int LastOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END;
LegalizeRuleSet RulesForOpcode[LastOp - FirstOp + 1];
- LegacyLegalizerInfo LegacyInfo;
};
#ifndef NDEBUG
diff --git a/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt b/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt
index 27b6ea745921a..e28dc010816c4 100644
--- a/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt
+++ b/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt
@@ -21,7 +21,6 @@ add_llvm_component_library(LLVMGlobalISel
Legalizer.cpp
LegalizerHelper.cpp
LegalizerInfo.cpp
- LegacyLegalizerInfo.cpp
LoadStoreOpt.cpp
Localizer.cpp
LostDebugLocObserver.cpp
diff --git a/llvm/lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp b/llvm/lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp
deleted file mode 100644
index 05923e5fc97cc..0000000000000
--- a/llvm/lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp
+++ /dev/null
@@ -1,385 +0,0 @@
-//===- lib/CodeGen/GlobalISel/LegacyLegalizerInfo.cpp - Legalizer ---------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Implement an interface to specify and query how an illegal operation on a
-// given type should be expanded.
-//
-// Issues to be resolved:
-// + Make it fast.
-// + Support weird types like i3, <7 x i3>, ...
-// + Operations with more than one type (ICMP, CMPXCHG, intrinsics, ...)
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h"
-#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
-#include <map>
-
-using namespace llvm;
-using namespace LegacyLegalizeActions;
-
-#define DEBUG_TYPE "legalizer-info"
-
-raw_ostream &llvm::operator<<(raw_ostream &OS, LegacyLegalizeAction Action) {
- switch (Action) {
- case Legal:
- OS << "Legal";
- break;
- case NarrowScalar:
- OS << "NarrowScalar";
- break;
- case WidenScalar:
- OS << "WidenScalar";
- break;
- case FewerElements:
- OS << "FewerElements";
- break;
- case MoreElements:
- OS << "MoreElements";
- break;
- case Bitcast:
- OS << "Bitcast";
- break;
- case Lower:
- OS << "Lower";
- break;
- case Libcall:
- OS << "Libcall";
- break;
- case Custom:
- OS << "Custom";
- break;
- case Unsupported:
- OS << "Unsupported";
- break;
- case NotFound:
- OS << "NotFound";
- break;
- }
- return OS;
-}
-
-LegacyLegalizerInfo::LegacyLegalizerInfo() {
- // Set defaults.
- // FIXME: these two (G_ANYEXT and G_TRUNC?) can be legalized to the
- // fundamental load/store Jakob proposed. Once loads & stores are supported.
- setScalarAction(TargetOpcode::G_ANYEXT, 1, {{1, Legal}});
- setScalarAction(TargetOpcode::G_ZEXT, 1, {{1, Legal}});
- setScalarAction(TargetOpcode::G_SEXT, 1, {{1, Legal}});
- setScalarAction(TargetOpcode::G_TRUNC, 0, {{1, Legal}});
- setScalarAction(TargetOpcode::G_TRUNC, 1, {{1, Legal}});
-
- setScalarAction(TargetOpcode::G_INTRINSIC, 0, {{1, Legal}});
- setScalarAction(TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS, 0, {{1, Legal}});
- setScalarAction(TargetOpcode::G_INTRINSIC_CONVERGENT, 0, {{1, Legal}});
- setScalarAction(TargetOpcode::G_INTRINSIC_CONVERGENT_W_SIDE_EFFECTS, 0,
- {{1, Legal}});
-
- setLegalizeScalarToDifferentSizeStrategy(
- TargetOpcode::G_IMPLICIT_DEF, 0, narrowToSmallerAndUnsupportedIfTooSmall);
- setLegalizeScalarToDifferentSizeStrategy(
- TargetOpcode::G_ADD, 0, widenToLargerTypesAndNarrowToLargest);
- setLegalizeScalarToDifferentSizeStrategy(
- TargetOpcode::G_OR, 0, widenToLargerTypesAndNarrowToLargest);
- setLegalizeScalarToDifferentSizeStrategy(
- TargetOpcode::G_LOAD, 0, narrowToSmallerAndUnsupportedIfTooSmall);
- setLegalizeScalarToDifferentSizeStrategy(
- TargetOpcode::G_STORE, 0, narrowToSmallerAndUnsupportedIfTooSmall);
-
- setLegalizeScalarToDifferentSizeStrategy(
- TargetOpcode::G_BRCOND, 0, widenToLargerTypesUnsupportedOtherwise);
- setLegalizeScalarToDifferentSizeStrategy(
- TargetOpcode::G_INSERT, 0, narrowToSmallerAndUnsupportedIfTooSmall);
- setLegalizeScalarToDifferentSizeStrategy(
- TargetOpcode::G_EXTRACT, 0, narrowToSmallerAndUnsupportedIfTooSmall);
- setLegalizeScalarToDifferentSizeStrategy(
- TargetOpcode::G_EXTRACT, 1, narrowToSmallerAndUnsupportedIfTooSmall);
- setScalarAction(TargetOpcode::G_FNEG, 0, {{1, Lower}});
-}
-
-void LegacyLegalizerInfo::computeTables() {
- assert(TablesInitialized == false);
-
- for (unsigned OpcodeIdx = 0; OpcodeIdx <= LastOp - FirstOp; ++OpcodeIdx) {
- const unsigned Opcode = FirstOp + OpcodeIdx;
- for (unsigned TypeIdx = 0; TypeIdx != SpecifiedActions[OpcodeIdx].size();
- ++TypeIdx) {
- // 0. Collect information specified through the setAction API, i.e.
- // for specific bit sizes.
- // For scalar types:
- SizeAndActionsVec ScalarSpecifiedActions;
- // For pointer types:
- std::map<uint16_t, SizeAndActionsVec> AddressSpace2SpecifiedActions;
- // For vector types:
- std::map<uint16_t, SizeAndActionsVec> ElemSize2SpecifiedActions;
- for (auto LLT2Action : SpecifiedActions[OpcodeIdx][TypeIdx]) {
- const LLT Type = LLT2Action.first;
- const LegacyLegalizeAction Action = LLT2Action.second;
-
- auto SizeAction = std::make_pair(Type.getSizeInBits(), Action);
- if (Type.isPointer())
- AddressSpace2SpecifiedActions[Type.getAddressSpace()].push_back(
- SizeAction);
- else if (Type.isVector())
- ElemSize2SpecifiedActions[Type.getElementType().getSizeInBits()]
- .push_back(SizeAction);
- else
- ScalarSpecifiedActions.push_back(SizeAction);
- }
-
- // 1. Handle scalar types
- {
- // Decide how to handle bit sizes for which no explicit specification
- // was given.
- SizeChangeStrategy S = &unsupportedForDifferentSizes;
- if (TypeIdx < ScalarSizeChangeStrategies[OpcodeIdx].size() &&
- ScalarSizeChangeStrategies[OpcodeIdx][TypeIdx] != nullptr)
- S = ScalarSizeChangeStrategies[OpcodeIdx][TypeIdx];
- llvm::sort(ScalarSpecifiedActions);
- checkPartialSizeAndActionsVector(ScalarSpecifiedActions);
- setScalarAction(Opcode, TypeIdx, S(ScalarSpecifiedActions));
- }
-
- // 2. Handle pointer types
- for (auto PointerSpecifiedActions : AddressSpace2SpecifiedActions) {
- llvm::sort(PointerSpecifiedActions.second);
- checkPartialSizeAndActionsVector(PointerSpecifiedActions.second);
- // For pointer types, we assume that there isn't a meaningfull way
- // to change the number of bits used in the pointer.
- setPointerAction(
- Opcode, TypeIdx, PointerSpecifiedActions.first,
- unsupportedForDifferentSizes(PointerSpecifiedActions.second));
- }
-
- // 3. Handle vector types
- SizeAndActionsVec ElementSizesSeen;
- for (auto VectorSpecifiedActions : ElemSize2SpecifiedActions) {
- llvm::sort(VectorSpecifiedActions.second);
- const uint16_t ElementSize = VectorSpecifiedActions.first;
- ElementSizesSeen.push_back({ElementSize, Legal});
- checkPartialSizeAndActionsVector(VectorSpecifiedActions.second);
- // For vector types, we assume that the best way to adapt the number
- // of elements is to the next larger number of elements type for which
- // the vector type is legal, unless there is no such type. In that case,
- // legalize towards a vector type with a smaller number of elements.
- SizeAndActionsVec NumElementsActions;
- for (SizeAndAction BitsizeAndAction : VectorSpecifiedActions.second) {
- assert(BitsizeAndAction.first % ElementSize == 0);
- const uint16_t NumElements = BitsizeAndAction.first / ElementSize;
- NumElementsActions.push_back({NumElements, BitsizeAndAction.second});
- }
- setVectorNumElementAction(
- Opcode, TypeIdx, ElementSize,
- moreToWiderTypesAndLessToWidest(NumElementsActions));
- }
- llvm::sort(ElementSizesSeen);
- SizeChangeStrategy VectorElementSizeChangeStrategy =
- &unsupportedForDifferentSizes;
- if (TypeIdx < VectorElementSizeChangeStrategies[OpcodeIdx].size() &&
- VectorElementSizeChangeStrategies[OpcodeIdx][TypeIdx] != nullptr)
- VectorElementSizeChangeStrategy =
- VectorElementSizeChangeStrategies[OpcodeIdx][TypeIdx];
- setScalarInVectorAction(
- Opcode, TypeIdx, VectorElementSizeChangeStrategy(ElementSizesSeen));
- }
- }
-
- TablesInitialized = true;
-}
-
-// FIXME: inefficient implementation for now. Without ComputeValueVTs we're
-// probably going to need specialized lookup structures for various types before
-// we have any hope of doing well with something like <13 x i3>. Even the common
-// cases should do better than what we have now.
-std::pair<LegacyLegalizeAction, LLT>
-LegacyLegalizerInfo::getAspectAction(const InstrAspect &Aspect) const {
- assert(TablesInitialized && "backend forgot to call computeTables");
- // These *have* to be implemented for now, they're the fundamental basis of
- // how everything else is transformed.
- if (Aspect.Type.isScalar() || Aspect.Type.isPointer())
- return findScalarLegalAction(Aspect);
- assert(Aspect.Type.isVector());
- return findVectorLegalAction(Aspect);
-}
-
-LegacyLegalizerInfo::SizeAndActionsVec
-LegacyLegalizerInfo::increaseToLargerTypesAndDecreaseToLargest(
- const SizeAndActionsVec &v, LegacyLegalizeAction IncreaseAction,
- LegacyLegalizeAction DecreaseAction) {
- SizeAndActionsVec result;
- unsigned LargestSizeSoFar = 0;
- if (v.size() >= 1 && v[0].first != 1)
- result.push_back({1, IncreaseAction});
- for (size_t i = 0; i < v.size(); ++i) {
- result.push_back(v[i]);
- LargestSizeSoFar = v[i].first;
- if (i + 1 < v.size() && v[i + 1].first != v[i].first + 1) {
- result.push_back({LargestSizeSoFar + 1, IncreaseAction});
- LargestSizeSoFar = v[i].first + 1;
- }
- }
- result.push_back({LargestSizeSoFar + 1, DecreaseAction});
- return result;
-}
-
-LegacyLegalizerInfo::SizeAndActionsVec
-LegacyLegalizerInfo::decreaseToSmallerTypesAndIncreaseToSmallest(
- const SizeAndActionsVec &v, LegacyLegalizeAction DecreaseAction,
- LegacyLegalizeAction IncreaseAction) {
- SizeAndActionsVec result;
- if (v.size() == 0 || v[0].first != 1)
- result.push_back({1, IncreaseAction});
- for (size_t i = 0; i < v.size(); ++i) {
- result.push_back(v[i]);
- if (i + 1 == v.size() || v[i + 1].first != v[i].first + 1) {
- result.push_back({v[i].first + 1, DecreaseAction});
- }
- }
- return result;
-}
-
-LegacyLegalizerInfo::SizeAndAction
-LegacyLegalizerInfo::findAction(const SizeAndActionsVec &Vec, const uint32_t Size) {
- assert(Size >= 1);
- // Find the last element in Vec that has a bitsize equal to or smaller than
- // the requested bit size.
- // That is the element just before the first element that is bigger than Size.
- auto It = partition_point(
- Vec, [=](const SizeAndAction &A) { return A.first <= Size; });
- assert(It != Vec.begin() && "Does Vec not start with size 1?");
- int VecIdx = It - Vec.begin() - 1;
-
- LegacyLegalizeAction Action = Vec[VecIdx].second;
- switch (Action) {
- case Legal:
- case Bitcast:
- case Lower:
- case Libcall:
- case Custom:
- return {Size, Action};
- case FewerElements:
- // FIXME: is this special case still needed and correct?
- // Special case for scalarization:
- if (Vec == SizeAndActionsVec({{1, FewerElements}}))
- return {1, FewerElements};
- [[fallthrough]];
- case NarrowScalar: {
- // The following needs to be a loop, as for now, we do allow needing to
- // go over "Unsupported" bit sizes before finding a legalizable bit size.
- // e.g. (s8, WidenScalar), (s9, Unsupported), (s32, Legal). if Size==8,
- // we need to iterate over s9, and then to s32 to return (s32, Legal).
- // If we want to get rid of the below loop, we should have stronger asserts
- // when building the SizeAndActionsVecs, probably not allowing
- // "Unsupported" unless at the ends of the vector.
- for (int i = VecIdx - 1; i >= 0; --i)
- if (!needsLegalizingToDifferentSize(Vec[i].second) &&
- Vec[i].second != Unsupported)
- return {Vec[i].first, Action};
- llvm_unreachable("");
- }
- case WidenScalar:
- case MoreElements: {
- // See above, the following needs to be a loop, at least for now.
- for (std::size_t i = VecIdx + 1; i < Vec.size(); ++i)
- if (!needsLegalizingToDifferentSize(Vec[i].second) &&
- Vec[i].second != Unsupported)
- return {Vec[i].first, Action};
- llvm_unreachable("");
- }
- case Unsupported:
- return {Size, Unsupported};
- case NotFound:
- llvm_unreachable("NotFound");
- }
- llvm_unreachable("Action has an unknown enum value");
-}
-
-std::pair<LegacyLegalizeAction, LLT>
-LegacyLegalizerInfo::findScalarLegalAction(const InstrAspect &Aspect) const {
- assert(Aspect.Type.isScalar() || Aspect.Type.isPointer());
- if (Aspect.Opcode < FirstOp || Aspect.Opcode > LastOp)
- return {NotFound, LLT()};
- const unsigned OpcodeIdx = getOpcodeIdxForOpcode(Aspect.Opcode);
- ArrayRef<SizeAndActionsVec> Actions;
- if (Aspect.Type.isPointer()) {
- auto &PA = AddrSpace2PointerActions[OpcodeIdx];
- auto It = PA.find(Aspect.Type.getAddressSpace());
- if (It == PA.end())
- return {NotFound, LLT()};
- Actions = It->second;
- } else {
- Actions = ScalarActions[OpcodeIdx];
- }
- if (Aspect.Idx >= Actions.size())
- return {NotFound, LLT()};
- const SizeAndActionsVec &Vec = Actions[Aspect.Idx];
- // FIXME: speed up this search, e.g. by using a results cache for repeated
- // queries?
- auto SizeAndAction = findAction(Vec, Aspect.Type.getSizeInBits());
- return {SizeAndAction.second,
- Aspect.Type.isScalar() ? LLT::scalar(SizeAndAction.first)
- : LLT::pointer(Aspect.Type.getAddressSpace(),
- SizeAndAction.first)};
-}
-
-std::pair<LegacyLegalizeAction, LLT>
-LegacyLegalizerInfo::findVectorLegalAction(const InstrAspect &Aspect) const {
- assert(Aspect.Type.isVector());
- // First legalize the vector element size, then legalize the number of
- // lanes in the vector.
- if (Aspect.Opcode < FirstOp || Aspect.Opcode > LastOp)
- return {NotFound, Aspect.Type};
- const unsigned OpcodeIdx = getOpcodeIdxForOpcode(Aspect.Opcode);
- const unsigned TypeIdx = Aspect.Idx;
- if (TypeIdx >= ScalarInVectorActions[OpcodeIdx].size())
- return {NotFound, Aspect.Type};
- const SizeAndActionsVec &ElemSizeVec =
- ScalarInVectorActions[OpcodeIdx][TypeIdx];
-
- LLT IntermediateType;
- auto ElementSizeAndAction =
- findAction(ElemSizeVec, Aspect.Type.getScalarSizeInBits());
- IntermediateType = LLT::fixed_vector(Aspect.Type.getNumElements(),
- ElementSizeAndAction.first);
- if (ElementSizeAndAction.second != Legal)
- return {ElementSizeAndAction.second, IntermediateType};
-
- auto i = NumElements2Actions[OpcodeIdx].find(
- IntermediateType.getScalarSizeInBits());
- if (i == NumElements2Actions[OpcodeIdx].end()) {
- return {NotFound, IntermediateType};
- }
- const SizeAndActionsVec &NumElementsVec = (*i).second[TypeIdx];
- auto NumElementsAndAction =
- findAction(NumElementsVec, IntermediateType.getNumElements());
- return {NumElementsAndAction.second,
- LLT::fixed_vector(NumElementsAndAction.first,
- IntermediateType.getScalarSizeInBits())};
-}
-
-unsigned LegacyLegalizerInfo::getOpcodeIdxForOpcode(unsigned Opcode) const {
- assert(Opcode >= FirstOp && Opcode <= LastOp && "Unsupported opcode");
- return Opcode - FirstOp;
-}
-
-
-LegacyLegalizeActionStep
-LegacyLegalizerInfo::getAction(const LegalityQuery &Query) const {
- for (unsigned i = 0; i < Query.Types.size(); ++i) {
- auto Action = getAspectAction({Query.Opcode, i, Query.Types[i]});
- if (Action.first != Legal) {
- LLVM_DEBUG(dbgs() << ".. (legacy) Type " << i << " Action="
- << Action.first << ", " << Action.second << "\n");
- return {Action.first, i, Action.second};
- } else
- LLVM_DEBUG(dbgs() << ".. (legacy) Type " << i << " Legal\n");
- }
- LLVM_DEBUG(dbgs() << ".. (legacy) Legal\n");
- return {Legal, 0, LLT{}};
-}
-
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
index c2d474fdde696..3e5bbbcf853e8 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
@@ -75,9 +75,6 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, LegalizeAction Action) {
case NotFound:
OS << "NotFound";
break;
- case UseLegacyRules:
- OS << "UseLegacyRules";
- break;
}
return OS;
}
@@ -193,10 +190,6 @@ static bool mutationIsSane(const LegalizeRule &Rule,
LegalizeActionStep LegalizeRuleSet::apply(const LegalityQuery &Query) const {
LLVM_DEBUG(dbgs() << "Applying legalizer ruleset to: "; Query.print(dbgs());
dbgs() << "\n");
- if (Rules.empty()) {
- LLVM_DEBUG(dbgs() << ".. fallback to legacy rules (no rules defined)\n");
- return {LegalizeAction::UseLegacyRules, 0, LLT{}};
- }
for (const LegalizeRule &Rule : Rules) {
if (Rule.match(Query)) {
LLVM_DEBUG(dbgs() << ".. match\n");
@@ -343,12 +336,7 @@ void LegalizerInfo::aliasActionDefinitions(unsigned OpcodeTo,
LegalizeActionStep
LegalizerInfo::getAction(const LegalityQuery &Query) const {
- LegalizeActionStep Step = getActionDefinitions(Query.Opcode).apply(Query);
- if (Step.Action != LegalizeAction::UseLegacyRules) {
- return Step;
- }
-
- return getLegacyLegalizerInfo().getAction(Query);
+ return getActionDefinitions(Query.Opcode).apply(Query);
}
LegalizeActionStep
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index 1d08ce1312263..d6bf8af931422 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -117,10 +117,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
const TargetMachine &TM = ST.getTargetLowering()->getTargetMachine();
// FIXME: support subtargets which have neon/fp-armv8 disabled.
- if (!ST.hasNEON() || !ST.hasFPARMv8()) {
- getLegacyLegalizerInfo().computeTables();
+ if (!ST.hasNEON() || !ST.hasFPARMv8())
return;
- }
// Some instructions only support s16 if the subtarget has full 16-bit FP
// support.
@@ -1514,7 +1512,6 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
getActionDefinitionsBuilder(G_FENCE).alwaysLegal();
getActionDefinitionsBuilder(G_INVOKE_REGION_START).alwaysLegal();
- getLegacyLegalizerInfo().computeTables();
verify(*ST.getInstrInfo());
}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
index 40dfa3aca26b6..c57ef9392a4ca 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
@@ -2302,7 +2302,6 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
G_INTRINSIC_CONVERGENT_W_SIDE_EFFECTS})
.alwaysLegal();
- getLegacyLegalizerInfo().computeTables();
verify(*ST.getInstrInfo());
}
diff --git a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp
index f7d03119d9b93..c2e2f0c551175 100644
--- a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp
@@ -40,10 +40,8 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) : ST(ST) {
const LLT s32 = LLT::scalar(32);
const LLT s64 = LLT::scalar(64);
- auto &LegacyInfo = getLegacyLegalizerInfo();
if (ST.isThumb1Only()) {
// Thumb1 is not supported yet.
- LegacyInfo.computeTables();
verify(*ST.getInstrInfo());
return;
}
@@ -230,7 +228,6 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) : ST(ST) {
.clampScalar(0, s32, s32);
}
- LegacyInfo.computeTables();
verify(*ST.getInstrInfo());
}
diff --git a/llvm/lib/Target/BPF/GISel/BPFLegalizerInfo.cpp b/llvm/lib/Target/BPF/GISel/BPFLegalizerInfo.cpp
index 7c95ecc075f36..92e86fb142253 100644
--- a/llvm/lib/Target/BPF/GISel/BPFLegalizerInfo.cpp
+++ b/llvm/lib/Target/BPF/GISel/BPFLegalizerInfo.cpp
@@ -17,5 +17,4 @@ using namespace llvm;
using namespace LegalizeActions;
BPFLegalizerInfo::BPFLegalizerInfo(const BPFSubtarget &ST) {
- getLegacyLegalizerInfo().computeTables();
}
diff --git a/llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp b/llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp
index 79e9ad4dd1d2a..6e712c3825d50 100644
--- a/llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp
+++ b/llvm/lib/Target/M68k/GISel/M68kLegalizerInfo.cpp
@@ -47,6 +47,4 @@ M68kLegalizerInfo::M68kLegalizerInfo(const M68kSubtarget &ST) {
.clampScalar(0, s8, s32);
getActionDefinitionsBuilder(G_PTR_ADD).legalFor({{p0, s32}});
-
- getLegacyLegalizerInfo().computeTables();
}
diff --git a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
index e1c77849bbb72..b697ca827daa8 100644
--- a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
+++ b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
@@ -331,7 +331,6 @@ MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) {
getActionDefinitionsBuilder(G_FENCE).alwaysLegal();
getActionDefinitionsBuilder({G_TRAP, G_DEBUGTRAP, G_UBSANTRAP}).alwaysLegal();
- getLegacyLegalizerInfo().computeTables();
verify(*ST.getInstrInfo());
}
diff --git a/llvm/lib/Target/PowerPC/GISel/PPCLegalizerInfo.cpp b/llvm/lib/Target/PowerPC/GISel/PPCLegalizerInfo.cpp
index 40d61f33c94b1..dbf81230c9dbb 100644
--- a/llvm/lib/Target/PowerPC/GISel/PPCLegalizerInfo.cpp
+++ b/llvm/lib/Target/PowerPC/GISel/PPCLegalizerInfo.cpp
@@ -88,6 +88,4 @@ PPCLegalizerInfo::PPCLegalizerInfo(const PPCSubtarget &ST) {
getActionDefinitionsBuilder({G_INTRINSIC, G_INTRINSIC_W_SIDE_EFFECTS})
.alwaysLegal();
-
- getLegacyLegalizerInfo().computeTables();
}
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index 2e51c7b069873..6acb66c449dd8 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -767,7 +767,6 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
getActionDefinitionsBuilder({G_TRAP, G_DEBUGTRAP, G_UBSANTRAP}).alwaysLegal();
- getLegacyLegalizerInfo().computeTables();
verify(*ST.getInstrInfo());
}
diff --git a/llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp b/llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp
index e2e4a4a6ae799..1bb01f8591a00 100644
--- a/llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp
@@ -557,7 +557,6 @@ SPIRVLegalizerInfo::SPIRVLegalizerInfo(const SPIRVSubtarget &ST) {
getActionDefinitionsBuilder(G_FENCE).alwaysLegal();
getActionDefinitionsBuilder({G_TRAP, G_DEBUGTRAP, G_UBSANTRAP}).alwaysLegal();
- getLegacyLegalizerInfo().computeTables();
verify(*ST.getInstrInfo());
}
diff --git a/llvm/lib/Target/WebAssembly/GISel/WebAssemblyLegalizerInfo.cpp b/llvm/lib/Target/WebAssembly/GISel/WebAssemblyLegalizerInfo.cpp
index d91ec459397ba..956432a78fb50 100644
--- a/llvm/lib/Target/WebAssembly/GISel/WebAssemblyLegalizerInfo.cpp
+++ b/llvm/lib/Target/WebAssembly/GISel/WebAssemblyLegalizerInfo.cpp
@@ -146,8 +146,6 @@ WebAssemblyLegalizerInfo::WebAssemblyLegalizerInfo(
.widenScalarToNextPow2(0)
.clampScalar(0, s32, s64)
.clampScalar(1, s32, s32);
-
- getLegacyLegalizerInfo().computeTables();
}
bool WebAssemblyLegalizerInfo::legalizeCustom(
diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
index 09c2c6ab5f0af..cffba4d43abad 100644
--- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
@@ -625,7 +625,6 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
getActionDefinitionsBuilder({G_TRAP, G_DEBUGTRAP, G_UBSANTRAP}).alwaysLegal();
getActionDefinitionsBuilder(G_INVOKE_REGION_START).alwaysLegal();
- getLegacyLegalizerInfo().computeTables();
verify(*STI.getInstrInfo());
}
diff --git a/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h b/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
index dbea3f608a881..dcb0ae1d6766e 100644
--- a/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
+++ b/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
@@ -170,7 +170,6 @@ class AMDGPUGISelMITest : public GISelMITest {
(void)s128; \
do \
SettingUpActionsBlock while (0); \
- getLegacyLegalizerInfo().computeTables(); \
verify(*ST.getInstrInfo()); \
} \
};
diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
index 0e9f571ed5175..41669ffb72360 100644
--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
@@ -1435,7 +1435,6 @@ TEST_F(AArch64GISelMITest, MoreElementsAnd) {
LI.getActionDefinitionsBuilder(TargetOpcode::G_AND)
.legalFor({v6s32})
.clampMinNumElements(0, s32, 6);
- LI.getLegacyLegalizerInfo().computeTables();
DummyGISelObserver Observer;
LegalizerHelper Helper(*MF, LI, Observer, B);
@@ -1487,7 +1486,6 @@ TEST_F(AArch64GISelMITest, FewerElementsPhi) {
LI.getActionDefinitionsBuilder(TargetOpcode::G_PHI)
.legalFor({v2s32})
.clampMinNumElements(0, s32, 2);
- LI.getLegacyLegalizerInfo().computeTables();
LLT PhiTy = v5s32;
DummyGISelObserver Observer;
diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
index 04cd66c7acb2a..578be1c7e247d 100644
--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
@@ -32,7 +32,6 @@ operator<<(std::ostream &OS, const LegalizeAction Act) {
case Bitcast: OS << "Bitcast"; break;
case Unsupported: OS << "Unsupported"; break;
case NotFound: OS << "NotFound"; break;
- case UseLegacyRules: OS << "UseLegacyRules"; break;
}
return OS;
}
@@ -44,175 +43,6 @@ std::ostream &operator<<(std::ostream &OS, const llvm::LegalizeActionStep Ty) {
}
}
-namespace {
-
-
-TEST(LegalizerInfoTest, ScalarRISC) {
- using namespace TargetOpcode;
- LegalizerInfo L;
- auto &LegacyInfo = L.getLegacyLegalizerInfo();
- // Typical RISCy set of operations based on AArch64.
- for (unsigned Op : {G_ADD, G_SUB}) {
- for (unsigned Size : {32, 64})
- LegacyInfo.setAction({Op, 0, LLT::scalar(Size)},
- LegacyLegalizeActions::Legal);
- LegacyInfo.setLegalizeScalarToDifferentSizeStrategy(
- Op, 0, LegacyLegalizerInfo::widenToLargerTypesAndNarrowToLargest);
- }
-
- LegacyInfo.computeTables();
-
- for (unsigned opcode : {G_ADD, G_SUB}) {
- // Check we infer the correct types and actually do what we're told.
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(8)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(32)));
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(16)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(32)));
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(32)}}),
- LegalizeActionStep(Legal, 0, LLT{}));
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(64)}}),
- LegalizeActionStep(Legal, 0, LLT{}));
-
- // Make sure the default for over-sized types applies.
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(128)}}),
- LegalizeActionStep(NarrowScalar, 0, LLT::scalar(64)));
- // Make sure we also handle unusual sizes
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(1)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(32)));
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(31)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(32)));
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(33)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(64)));
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(63)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(64)));
- EXPECT_EQ(L.getAction({opcode, {LLT::scalar(65)}}),
- LegalizeActionStep(NarrowScalar, 0, LLT::scalar(64)));
- }
-}
-
-TEST(LegalizerInfoTest, VectorRISC) {
- using namespace TargetOpcode;
- LegalizerInfo L;
- auto &LegacyInfo = L.getLegacyLegalizerInfo();
- // Typical RISCy set of operations based on ARM.
- LegacyInfo.setAction({G_ADD, LLT::fixed_vector(8, 8)},
- LegacyLegalizeActions::Legal);
- LegacyInfo.setAction({G_ADD, LLT::fixed_vector(16, 8)},
- LegacyLegalizeActions::Legal);
- LegacyInfo.setAction({G_ADD, LLT::fixed_vector(4, 16)},
- LegacyLegalizeActions::Legal);
- LegacyInfo.setAction({G_ADD, LLT::fixed_vector(8, 16)},
- LegacyLegalizeActions::Legal);
- LegacyInfo.setAction({G_ADD, LLT::fixed_vector(2, 32)},
- LegacyLegalizeActions::Legal);
- LegacyInfo.setAction({G_ADD, LLT::fixed_vector(4, 32)},
- LegacyLegalizeActions::Legal);
-
- LegacyInfo.setLegalizeVectorElementToDifferentSizeStrategy(
- G_ADD, 0, LegacyLegalizerInfo::widenToLargerTypesUnsupportedOtherwise);
-
- LegacyInfo.setAction({G_ADD, 0, LLT::scalar(32)},
- LegacyLegalizeActions::Legal);
-
- LegacyInfo.computeTables();
-
- // Check we infer the correct types and actually do what we're told for some
- // simple cases.
- EXPECT_EQ(L.getAction({G_ADD, {LLT::fixed_vector(8, 8)}}),
- LegalizeActionStep(Legal, 0, LLT{}));
- EXPECT_EQ(L.getAction({G_ADD, {LLT::fixed_vector(8, 7)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::fixed_vector(8, 8)));
- EXPECT_EQ(L.getAction({G_ADD, {LLT::fixed_vector(2, 8)}}),
- LegalizeActionStep(MoreElements, 0, LLT::fixed_vector(8, 8)));
- EXPECT_EQ(L.getAction({G_ADD, {LLT::fixed_vector(8, 32)}}),
- LegalizeActionStep(FewerElements, 0, LLT::fixed_vector(4, 32)));
- // Check a few non-power-of-2 sizes:
- EXPECT_EQ(L.getAction({G_ADD, {LLT::fixed_vector(3, 3)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::fixed_vector(3, 8)));
- EXPECT_EQ(L.getAction({G_ADD, {LLT::fixed_vector(3, 8)}}),
- LegalizeActionStep(MoreElements, 0, LLT::fixed_vector(8, 8)));
-}
-
-TEST(LegalizerInfoTest, MultipleTypes) {
- using namespace TargetOpcode;
- LegalizerInfo L;
- auto &LegacyInfo = L.getLegacyLegalizerInfo();
- LLT p0 = LLT::pointer(0, 64);
- LLT s64 = LLT::scalar(64);
-
- // Typical RISCy set of operations based on AArch64.
- LegacyInfo.setAction({G_PTRTOINT, 0, s64}, LegacyLegalizeActions::Legal);
- LegacyInfo.setAction({G_PTRTOINT, 1, p0}, LegacyLegalizeActions::Legal);
-
- LegacyInfo.setLegalizeScalarToDifferentSizeStrategy(
- G_PTRTOINT, 0, LegacyLegalizerInfo::widenToLargerTypesAndNarrowToLargest);
-
- LegacyInfo.computeTables();
-
- // Check we infer the correct types and actually do what we're told.
- EXPECT_EQ(L.getAction({G_PTRTOINT, {s64, p0}}),
- LegalizeActionStep(Legal, 0, LLT{}));
-
- // Make sure we also handle unusual sizes
- EXPECT_EQ(
- L.getAction({G_PTRTOINT, {LLT::scalar(65), s64}}),
- LegalizeActionStep(NarrowScalar, 0, s64));
- EXPECT_EQ(
- L.getAction({G_PTRTOINT, {s64, LLT::pointer(0, 32)}}),
- LegalizeActionStep(Unsupported, 1, LLT::pointer(0, 32)));
-}
-
-TEST(LegalizerInfoTest, MultipleSteps) {
- using namespace TargetOpcode;
- LegalizerInfo L;
- auto &LegacyInfo = L.getLegacyLegalizerInfo();
- LLT s32 = LLT::scalar(32);
- LLT s64 = LLT::scalar(64);
-
- LegacyInfo.setLegalizeScalarToDifferentSizeStrategy(
- G_UREM, 0, LegacyLegalizerInfo::widenToLargerTypesUnsupportedOtherwise);
- LegacyInfo.setAction({G_UREM, 0, s32}, LegacyLegalizeActions::Lower);
- LegacyInfo.setAction({G_UREM, 0, s64}, LegacyLegalizeActions::Lower);
-
- LegacyInfo.computeTables();
-
- EXPECT_EQ(L.getAction({G_UREM, {LLT::scalar(16)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(32)));
- EXPECT_EQ(L.getAction({G_UREM, {LLT::scalar(32)}}),
- LegalizeActionStep(Lower, 0, LLT::scalar(32)));
-}
-
-TEST(LegalizerInfoTest, SizeChangeStrategy) {
- using namespace TargetOpcode;
- LegalizerInfo L;
- auto &LegacyInfo = L.getLegacyLegalizerInfo();
- for (unsigned Size : {1, 8, 16, 32})
- LegacyInfo.setAction({G_UREM, 0, LLT::scalar(Size)},
- LegacyLegalizeActions::Legal);
-
- LegacyInfo.setLegalizeScalarToDifferentSizeStrategy(
- G_UREM, 0, LegacyLegalizerInfo::widenToLargerTypesUnsupportedOtherwise);
- LegacyInfo.computeTables();
-
- // Check we infer the correct types and actually do what we're told.
- for (unsigned Size : {1, 8, 16, 32}) {
- EXPECT_EQ(L.getAction({G_UREM, {LLT::scalar(Size)}}),
- LegalizeActionStep(Legal, 0, LLT{}));
- }
- EXPECT_EQ(L.getAction({G_UREM, {LLT::scalar(2)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(8)));
- EXPECT_EQ(L.getAction({G_UREM, {LLT::scalar(7)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(8)));
- EXPECT_EQ(L.getAction({G_UREM, {LLT::scalar(9)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(16)));
- EXPECT_EQ(L.getAction({G_UREM, {LLT::scalar(17)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(32)));
- EXPECT_EQ(L.getAction({G_UREM, {LLT::scalar(31)}}),
- LegalizeActionStep(WidenScalar, 0, LLT::scalar(32)));
- EXPECT_EQ(L.getAction({G_UREM, {LLT::scalar(33)}}),
- LegalizeActionStep(Unsupported, 0, LLT::scalar(33)));
-}
-}
#define EXPECT_ACTION(Action, Index, Type, Query) \
do { \
@@ -251,12 +81,10 @@ TEST(LegalizerInfoTest, RuleSets) {
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_IMPLICIT_DEF)
.legalFor({v4s32, v4p0})
.moreElementsToNextPow2(0);
- LegacyInfo.computeTables();
EXPECT_ACTION(Unsupported, 0, LLT(), LegalityQuery(G_IMPLICIT_DEF, {s32}));
EXPECT_ACTION(Unsupported, 0, LLT(), LegalityQuery(G_IMPLICIT_DEF, {v2s32}));
@@ -267,11 +95,9 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test minScalarOrElt
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_OR)
.legalFor({s32})
.minScalarOrElt(0, s32);
- LegacyInfo.computeTables();
EXPECT_ACTION(WidenScalar, 0, s32, LegalityQuery(G_OR, {s16}));
EXPECT_ACTION(WidenScalar, 0, v2s32, LegalityQuery(G_OR, {v2s16}));
@@ -280,11 +106,9 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test maxScalarOrELt
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_AND)
.legalFor({s16})
.maxScalarOrElt(0, s16);
- LegacyInfo.computeTables();
EXPECT_ACTION(NarrowScalar, 0, s16, LegalityQuery(G_AND, {s32}));
EXPECT_ACTION(NarrowScalar, 0, v2s16, LegalityQuery(G_AND, {v2s32}));
@@ -293,11 +117,9 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test clampScalarOrElt
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_XOR)
.legalFor({s16})
.clampScalarOrElt(0, s16, s32);
- LegacyInfo.computeTables();
EXPECT_ACTION(NarrowScalar, 0, s32, LegalityQuery(G_XOR, {s64}));
EXPECT_ACTION(WidenScalar, 0, s16, LegalityQuery(G_XOR, {s8}));
@@ -310,11 +132,9 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test minScalar
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_OR)
.legalFor({s32})
.minScalar(0, s32);
- LegacyInfo.computeTables();
// Only handle scalars, ignore vectors.
EXPECT_ACTION(WidenScalar, 0, s32, LegalityQuery(G_OR, {s16}));
@@ -325,13 +145,11 @@ TEST(LegalizerInfoTest, RuleSets) {
{
bool IfCond = true;
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_OR)
.legalFor({s32})
.minScalarIf([&](const LegalityQuery &Query) {
return IfCond;
}, 0, s32);
- LegacyInfo.computeTables();
// Only handle scalars, ignore vectors.
EXPECT_ACTION(WidenScalar, 0, s32, LegalityQuery(G_OR, {s16}));
@@ -345,11 +163,9 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test maxScalar
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_AND)
.legalFor({s16})
.maxScalar(0, s16);
- LegacyInfo.computeTables();
// Only handle scalars, ignore vectors.
EXPECT_ACTION(NarrowScalar, 0, s16, LegalityQuery(G_AND, {s32}));
@@ -359,12 +175,10 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test clampScalar
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_XOR)
.legalFor({s16})
.clampScalar(0, s16, s32);
- LegacyInfo.computeTables();
EXPECT_ACTION(NarrowScalar, 0, s32, LegalityQuery(G_XOR, {s64}));
EXPECT_ACTION(WidenScalar, 0, s16, LegalityQuery(G_XOR, {s8}));
@@ -377,12 +191,10 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test widenScalarOrEltToNextPow2
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_AND)
.legalFor({s32})
.widenScalarOrEltToNextPow2(0, 32);
- LegacyInfo.computeTables();
// Handle scalars and vectors
EXPECT_ACTION(WidenScalar, 0, s32, LegalityQuery(G_AND, {s5}));
@@ -394,12 +206,10 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test widenScalarToNextPow2
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_AND)
.legalFor({s32})
.widenScalarToNextPow2(0, 32);
- LegacyInfo.computeTables();
EXPECT_ACTION(WidenScalar, 0, s32, LegalityQuery(G_AND, {s5}));
EXPECT_ACTION(WidenScalar, 0, s64, LegalityQuery(G_AND, {s33}));
@@ -412,7 +222,6 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test changeElementCountTo
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
// Type index form
LI.getActionDefinitionsBuilder(G_SELECT)
@@ -429,7 +238,6 @@ TEST(LegalizerInfoTest, RuleSets) {
.fewerElementsIf(typeIs(0, LLT::scalable_vector(8, s16)),
changeElementCountTo(0, ElementCount::getFixed(1)));
- LegacyInfo.computeTables();
EXPECT_ACTION(MoreElements, 1, v4s1, LegalityQuery(G_SELECT, {v4s32, s1}));
EXPECT_ACTION(MoreElements, 1, v2s1, LegalityQuery(G_SELECT, {v2s32, s1}));
@@ -455,11 +263,9 @@ TEST(LegalizerInfoTest, RuleSets) {
// Test minScalarEltSameAsIf
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_SELECT).minScalarEltSameAsIf(
all(isVector(0), isVector(1)), 1, 0);
- LegacyInfo.computeTables();
LLT p1 = LLT::pointer(1, 32);
LLT v2p1 = LLT::fixed_vector(2, p1);
@@ -476,11 +282,9 @@ TEST(LegalizerInfoTest, MMOAlignment) {
{
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_LOAD)
.legalForTypesWithMemDesc({{s32, p0, s32, 32}});
- LegacyInfo.computeTables();
EXPECT_ACTION(
Legal, 0, LLT(),
@@ -505,11 +309,9 @@ TEST(LegalizerInfoTest, MMOAlignment) {
const uint64_t MaxAlignment = UINT64_C(1) << 29;
const uint64_t MaxAlignInBits = 8 * MaxAlignment;
LegalizerInfo LI;
- auto &LegacyInfo = LI.getLegacyLegalizerInfo();
LI.getActionDefinitionsBuilder(G_LOAD)
.legalForTypesWithMemDesc({{s32, p0, s32, MaxAlignInBits}});
- LegacyInfo.computeTables();
EXPECT_ACTION(
Legal, 0, LLT(),
diff --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/GlobalISel/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/CodeGen/GlobalISel/BUILD.gn
index cf66738e3ad06..5f86839bb90d1 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/GlobalISel/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/GlobalISel/BUILD.gn
@@ -29,7 +29,6 @@ static_library("GlobalISel") {
"InlineAsmLowering.cpp",
"InstructionSelect.cpp",
"InstructionSelector.cpp",
- "LegacyLegalizerInfo.cpp",
"LegalityPredicates.cpp",
"LegalizeMutations.cpp",
"Legalizer.cpp",
More information about the llvm-commits
mailing list