Skip to content

Commit 2ae8bee

Browse files
authored
[ARM][GlobalISel] Remove legacy legalizer rules (#82619)
I've been looking at LegacyLegalizerInfo and what its place in GISel is. It seems like it's very close to being deleted so I'm checking if we can remove the last remaining uses of it. Looks like we can do a drop-in replacement with the new legalizer for ARM.
1 parent b13c8e5 commit 2ae8bee

File tree

1 file changed

+9
-47
lines changed

1 file changed

+9
-47
lines changed

llvm/lib/Target/ARM/ARMLegalizerInfo.cpp

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,6 @@
2525
using namespace llvm;
2626
using namespace LegalizeActions;
2727

28-
/// FIXME: The following static functions are SizeChangeStrategy functions
29-
/// that are meant to temporarily mimic the behaviour of the old legalization
30-
/// based on doubling/halving non-legal types as closely as possible. This is
31-
/// not entirly possible as only legalizing the types that are exactly a power
32-
/// of 2 times the size of the legal types would require specifying all those
33-
/// sizes explicitly.
34-
/// In practice, not specifying those isn't a problem, and the below functions
35-
/// should disappear quickly as we add support for legalizing non-power-of-2
36-
/// sized types further.
37-
static void addAndInterleaveWithUnsupported(
38-
LegacyLegalizerInfo::SizeAndActionsVec &result,
39-
const LegacyLegalizerInfo::SizeAndActionsVec &v) {
40-
for (unsigned i = 0; i < v.size(); ++i) {
41-
result.push_back(v[i]);
42-
if (i + 1 < v[i].first && i + 1 < v.size() &&
43-
v[i + 1].first != v[i].first + 1)
44-
result.push_back({v[i].first + 1, LegacyLegalizeActions::Unsupported});
45-
}
46-
}
47-
48-
static LegacyLegalizerInfo::SizeAndActionsVec
49-
widen_8_16(const LegacyLegalizerInfo::SizeAndActionsVec &v) {
50-
assert(v.size() >= 1);
51-
assert(v[0].first > 17);
52-
LegacyLegalizerInfo::SizeAndActionsVec result = {
53-
{1, LegacyLegalizeActions::Unsupported},
54-
{8, LegacyLegalizeActions::WidenScalar},
55-
{9, LegacyLegalizeActions::Unsupported},
56-
{16, LegacyLegalizeActions::WidenScalar},
57-
{17, LegacyLegalizeActions::Unsupported}};
58-
addAndInterleaveWithUnsupported(result, v);
59-
auto Largest = result.back().first;
60-
result.push_back({Largest + 1, LegacyLegalizeActions::Unsupported});
61-
return result;
62-
}
63-
6428
static bool AEABI(const ARMSubtarget &ST) {
6529
return ST.isTargetAEABI() || ST.isTargetGNUAEABI() || ST.isTargetMuslAEABI();
6630
}
@@ -118,15 +82,14 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
11882
.libcallFor({s32})
11983
.clampScalar(0, s32, s32);
12084

121-
for (unsigned Op : {G_SREM, G_UREM}) {
122-
LegacyInfo.setLegalizeScalarToDifferentSizeStrategy(Op, 0, widen_8_16);
123-
if (HasHWDivide)
124-
LegacyInfo.setAction({Op, s32}, LegacyLegalizeActions::Lower);
125-
else if (AEABI(ST))
126-
LegacyInfo.setAction({Op, s32}, LegacyLegalizeActions::Custom);
127-
else
128-
LegacyInfo.setAction({Op, s32}, LegacyLegalizeActions::Libcall);
129-
}
85+
auto &REMBuilder =
86+
getActionDefinitionsBuilder({G_SREM, G_UREM}).minScalar(0, s32);
87+
if (HasHWDivide)
88+
REMBuilder.lowerFor({s32});
89+
else if (AEABI(ST))
90+
REMBuilder.customFor({s32});
91+
else
92+
REMBuilder.libcallFor({s32});
13093

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

203166
LoadStoreBuilder.maxScalar(0, s32);
204167

205-
for (auto Ty : {s32, s64})
206-
LegacyInfo.setAction({G_FNEG, Ty}, LegacyLegalizeActions::Lower);
168+
getActionDefinitionsBuilder(G_FNEG).lowerFor({s32, s64});
207169

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

0 commit comments

Comments
 (0)