Skip to content

[ARM][GlobalISel] Remove legacy legalizer rules #82619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 9 additions & 47 deletions llvm/lib/Target/ARM/ARMLegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,6 @@
using namespace llvm;
using namespace LegalizeActions;

/// FIXME: The following static functions are SizeChangeStrategy functions
/// that are meant to temporarily mimic the behaviour of the old legalization
/// based on doubling/halving non-legal types as closely as possible. This is
/// not entirly possible as only legalizing the types that are exactly a power
/// of 2 times the size of the legal types would require specifying all those
/// sizes explicitly.
/// In practice, not specifying those isn't a problem, and the below functions
/// should disappear quickly as we add support for legalizing non-power-of-2
/// sized types further.
static void addAndInterleaveWithUnsupported(
LegacyLegalizerInfo::SizeAndActionsVec &result,
const LegacyLegalizerInfo::SizeAndActionsVec &v) {
for (unsigned i = 0; i < v.size(); ++i) {
result.push_back(v[i]);
if (i + 1 < v[i].first && i + 1 < v.size() &&
v[i + 1].first != v[i].first + 1)
result.push_back({v[i].first + 1, LegacyLegalizeActions::Unsupported});
}
}

static LegacyLegalizerInfo::SizeAndActionsVec
widen_8_16(const LegacyLegalizerInfo::SizeAndActionsVec &v) {
assert(v.size() >= 1);
assert(v[0].first > 17);
LegacyLegalizerInfo::SizeAndActionsVec result = {
{1, LegacyLegalizeActions::Unsupported},
{8, LegacyLegalizeActions::WidenScalar},
{9, LegacyLegalizeActions::Unsupported},
{16, LegacyLegalizeActions::WidenScalar},
{17, LegacyLegalizeActions::Unsupported}};
addAndInterleaveWithUnsupported(result, v);
auto Largest = result.back().first;
result.push_back({Largest + 1, LegacyLegalizeActions::Unsupported});
return result;
}

static bool AEABI(const ARMSubtarget &ST) {
return ST.isTargetAEABI() || ST.isTargetGNUAEABI() || ST.isTargetMuslAEABI();
}
Expand Down Expand Up @@ -118,15 +82,14 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
.libcallFor({s32})
.clampScalar(0, s32, s32);

for (unsigned Op : {G_SREM, G_UREM}) {
LegacyInfo.setLegalizeScalarToDifferentSizeStrategy(Op, 0, widen_8_16);
if (HasHWDivide)
LegacyInfo.setAction({Op, s32}, LegacyLegalizeActions::Lower);
else if (AEABI(ST))
LegacyInfo.setAction({Op, s32}, LegacyLegalizeActions::Custom);
else
LegacyInfo.setAction({Op, s32}, LegacyLegalizeActions::Libcall);
}
auto &REMBuilder =
getActionDefinitionsBuilder({G_SREM, G_UREM}).minScalar(0, s32);
if (HasHWDivide)
REMBuilder.lowerFor({s32});
else if (AEABI(ST))
REMBuilder.customFor({s32});
else
REMBuilder.libcallFor({s32});

getActionDefinitionsBuilder(G_INTTOPTR)
.legalFor({{p0, s32}})
Expand Down Expand Up @@ -202,8 +165,7 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {

LoadStoreBuilder.maxScalar(0, s32);

for (auto Ty : {s32, s64})
LegacyInfo.setAction({G_FNEG, Ty}, LegacyLegalizeActions::Lower);
getActionDefinitionsBuilder(G_FNEG).lowerFor({s32, s64});

getActionDefinitionsBuilder(G_FCONSTANT).customFor({s32, s64});

Expand Down