|
25 | 25 | using namespace llvm;
|
26 | 26 | using namespace LegalizeActions;
|
27 | 27 |
|
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 |
| - |
64 | 28 | static bool AEABI(const ARMSubtarget &ST) {
|
65 | 29 | return ST.isTargetAEABI() || ST.isTargetGNUAEABI() || ST.isTargetMuslAEABI();
|
66 | 30 | }
|
@@ -118,15 +82,14 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
|
118 | 82 | .libcallFor({s32})
|
119 | 83 | .clampScalar(0, s32, s32);
|
120 | 84 |
|
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}); |
130 | 93 |
|
131 | 94 | getActionDefinitionsBuilder(G_INTTOPTR)
|
132 | 95 | .legalFor({{p0, s32}})
|
@@ -202,8 +165,7 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
|
202 | 165 |
|
203 | 166 | LoadStoreBuilder.maxScalar(0, s32);
|
204 | 167 |
|
205 |
| - for (auto Ty : {s32, s64}) |
206 |
| - LegacyInfo.setAction({G_FNEG, Ty}, LegacyLegalizeActions::Lower); |
| 168 | + getActionDefinitionsBuilder(G_FNEG).lowerFor({s32, s64}); |
207 | 169 |
|
208 | 170 | getActionDefinitionsBuilder(G_FCONSTANT).customFor({s32, s64});
|
209 | 171 |
|
|
0 commit comments