forked from OSchip/llvm-project
[ARM GlobalISel] Modernize LegalizerInfo. NFCI
Start using the new LegalizerInfo API introduced in r323681. Keep the old API for opcodes that need Lowering in some circumstances (G_FNEG and G_UREM/G_SREM). llvm-svn: 323876
This commit is contained in:
parent
3f34f33148
commit
1d4421f6a6
|
@ -313,6 +313,9 @@ public:
|
||||||
LegalizeRuleSet &customIf(LegalityPredicate Predicate) {
|
LegalizeRuleSet &customIf(LegalityPredicate Predicate) {
|
||||||
return actionIf(LegalizeAction::Custom, Predicate);
|
return actionIf(LegalizeAction::Custom, Predicate);
|
||||||
}
|
}
|
||||||
|
LegalizeRuleSet &customFor(std::initializer_list<LLT> Types) {
|
||||||
|
return actionFor(LegalizeAction::Custom, Types);
|
||||||
|
}
|
||||||
LegalizeRuleSet &customForCartesianProduct(std::initializer_list<LLT> Types) {
|
LegalizeRuleSet &customForCartesianProduct(std::initializer_list<LLT> Types) {
|
||||||
return actionForCartesianProduct(LegalizeAction::Custom, Types);
|
return actionForCartesianProduct(LegalizeAction::Custom, Types);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,20 +60,6 @@ widen_8_16(const LegalizerInfo::SizeAndActionsVec &v) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LegalizerInfo::SizeAndActionsVec
|
|
||||||
widen_1_8_16_narrowToLargest(const LegalizerInfo::SizeAndActionsVec &v) {
|
|
||||||
assert(v.size() >= 1);
|
|
||||||
assert(v[0].first > 17);
|
|
||||||
LegalizerInfo::SizeAndActionsVec result = {
|
|
||||||
{1, WidenScalar}, {2, Unsupported},
|
|
||||||
{8, WidenScalar}, {9, Unsupported},
|
|
||||||
{16, WidenScalar}, {17, Unsupported}};
|
|
||||||
addAndInterleaveWithUnsupported(result, v);
|
|
||||||
auto Largest = result.back().first;
|
|
||||||
result.push_back({Largest + 1, NarrowScalar});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool AEABI(const ARMSubtarget &ST) {
|
static bool AEABI(const ARMSubtarget &ST) {
|
||||||
return ST.isTargetAEABI() || ST.isTargetGNUAEABI() || ST.isTargetMuslAEABI();
|
return ST.isTargetAEABI() || ST.isTargetGNUAEABI() || ST.isTargetMuslAEABI();
|
||||||
}
|
}
|
||||||
|
@ -89,30 +75,21 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
|
||||||
const LLT s32 = LLT::scalar(32);
|
const LLT s32 = LLT::scalar(32);
|
||||||
const LLT s64 = LLT::scalar(64);
|
const LLT s64 = LLT::scalar(64);
|
||||||
|
|
||||||
setAction({G_GLOBAL_VALUE, p0}, Legal);
|
getActionDefinitionsBuilder(G_GLOBAL_VALUE).legalFor({p0});
|
||||||
setAction({G_FRAME_INDEX, p0}, Legal);
|
getActionDefinitionsBuilder(G_FRAME_INDEX).legalFor({p0});
|
||||||
|
|
||||||
for (unsigned Op : {G_LOAD, G_STORE}) {
|
getActionDefinitionsBuilder({G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR})
|
||||||
for (auto Ty : {s1, s8, s16, s32, p0})
|
.legalFor({s32})
|
||||||
setAction({Op, Ty}, Legal);
|
.minScalar(0, s32);
|
||||||
setAction({Op, 1, p0}, Legal);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned Op : {G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR}) {
|
if (ST.hasDivideInARMMode())
|
||||||
if (Op != G_ADD)
|
getActionDefinitionsBuilder({G_SDIV, G_UDIV})
|
||||||
setLegalizeScalarToDifferentSizeStrategy(
|
.legalFor({s32})
|
||||||
Op, 0, widenToLargerTypesUnsupportedOtherwise);
|
.clampScalar(0, s32, s32);
|
||||||
setAction({Op, s32}, Legal);
|
else
|
||||||
}
|
getActionDefinitionsBuilder({G_SDIV, G_UDIV})
|
||||||
|
.libcallFor({s32})
|
||||||
for (unsigned Op : {G_SDIV, G_UDIV}) {
|
.clampScalar(0, s32, s32);
|
||||||
setLegalizeScalarToDifferentSizeStrategy(Op, 0,
|
|
||||||
widenToLargerTypesUnsupportedOtherwise);
|
|
||||||
if (ST.hasDivideInARMMode())
|
|
||||||
setAction({Op, s32}, Legal);
|
|
||||||
else
|
|
||||||
setAction({Op, s32}, Libcall);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned Op : {G_SREM, G_UREM}) {
|
for (unsigned Op : {G_SREM, G_UREM}) {
|
||||||
setLegalizeScalarToDifferentSizeStrategy(Op, 0, widen_8_16);
|
setLegalizeScalarToDifferentSizeStrategy(Op, 0, widen_8_16);
|
||||||
|
@ -124,127 +101,92 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
|
||||||
setAction({Op, s32}, Libcall);
|
setAction({Op, s32}, Libcall);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned Op : {G_SEXT, G_ZEXT, G_ANYEXT}) {
|
getActionDefinitionsBuilder({G_SEXT, G_ZEXT, G_ANYEXT}).legalFor({s32});
|
||||||
setAction({Op, s32}, Legal);
|
|
||||||
}
|
|
||||||
|
|
||||||
setAction({G_INTTOPTR, p0}, Legal);
|
getActionDefinitionsBuilder(G_INTTOPTR).legalFor({{p0, s32}});
|
||||||
setAction({G_INTTOPTR, 1, s32}, Legal);
|
getActionDefinitionsBuilder(G_PTRTOINT).legalFor({{s32, p0}});
|
||||||
|
|
||||||
setAction({G_PTRTOINT, s32}, Legal);
|
getActionDefinitionsBuilder({G_ASHR, G_LSHR, G_SHL}).legalFor({s32});
|
||||||
setAction({G_PTRTOINT, 1, p0}, Legal);
|
|
||||||
|
|
||||||
for (unsigned Op : {G_ASHR, G_LSHR, G_SHL})
|
getActionDefinitionsBuilder(G_GEP).legalFor({{p0, s32}});
|
||||||
setAction({Op, s32}, Legal);
|
|
||||||
|
|
||||||
setAction({G_GEP, p0}, Legal);
|
getActionDefinitionsBuilder(G_SELECT).legalForCartesianProduct({s32, p0},
|
||||||
setAction({G_GEP, 1, s32}, Legal);
|
{s1});
|
||||||
|
|
||||||
setAction({G_SELECT, s32}, Legal);
|
getActionDefinitionsBuilder(G_BRCOND).legalFor({s1});
|
||||||
setAction({G_SELECT, p0}, Legal);
|
|
||||||
setAction({G_SELECT, 1, s1}, Legal);
|
|
||||||
|
|
||||||
setAction({G_BRCOND, s1}, Legal);
|
getActionDefinitionsBuilder(G_CONSTANT)
|
||||||
|
.legalFor({s32, p0})
|
||||||
|
.clampScalar(0, s32, s32);
|
||||||
|
|
||||||
for (auto Ty : {s32, p0})
|
getActionDefinitionsBuilder(G_ICMP)
|
||||||
setAction({G_PHI, Ty}, Legal);
|
.legalForCartesianProduct({s1}, {s32, p0})
|
||||||
setLegalizeScalarToDifferentSizeStrategy(
|
.minScalar(1, s32);
|
||||||
G_PHI, 0, widenToLargerTypesUnsupportedOtherwise);
|
|
||||||
|
|
||||||
setAction({G_CONSTANT, s32}, Legal);
|
// We're keeping these builders around because we'll want to add support for
|
||||||
setAction({G_CONSTANT, p0}, Legal);
|
// floating point to them.
|
||||||
setLegalizeScalarToDifferentSizeStrategy(G_CONSTANT, 0,
|
auto &LoadStoreBuilder = getActionDefinitionsBuilder({G_LOAD, G_STORE}).legalForCartesianProduct(
|
||||||
widen_1_8_16_narrowToLargest);
|
{s1, s8, s16, s32, p0}, {p0});
|
||||||
|
|
||||||
setAction({G_ICMP, s1}, Legal);
|
auto &PhiBuilder = getActionDefinitionsBuilder(G_PHI)
|
||||||
setLegalizeScalarToDifferentSizeStrategy(G_ICMP, 1,
|
.legalFor({s32, p0})
|
||||||
widenToLargerTypesUnsupportedOtherwise);
|
.minScalar(0, s32);
|
||||||
for (auto Ty : {s32, p0})
|
|
||||||
setAction({G_ICMP, 1, Ty}, Legal);
|
|
||||||
|
|
||||||
if (!ST.useSoftFloat() && ST.hasVFP2()) {
|
if (!ST.useSoftFloat() && ST.hasVFP2()) {
|
||||||
for (unsigned Op : {G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FCONSTANT, G_FNEG})
|
getActionDefinitionsBuilder(
|
||||||
for (auto Ty : {s32, s64})
|
{G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FCONSTANT, G_FNEG})
|
||||||
setAction({Op, Ty}, Legal);
|
.legalFor({s32, s64});
|
||||||
|
|
||||||
setAction({G_LOAD, s64}, Legal);
|
LoadStoreBuilder.legalFor({{s64, p0}});
|
||||||
setAction({G_STORE, s64}, Legal);
|
PhiBuilder.legalFor({s64});
|
||||||
|
|
||||||
setAction({G_PHI, s64}, Legal);
|
getActionDefinitionsBuilder(G_FCMP).legalForCartesianProduct({s1},
|
||||||
|
{s32, s64});
|
||||||
|
|
||||||
setAction({G_FCMP, s1}, Legal);
|
getActionDefinitionsBuilder(G_MERGE_VALUES).legalFor({{s64, s32}});
|
||||||
setAction({G_FCMP, 1, s32}, Legal);
|
getActionDefinitionsBuilder(G_UNMERGE_VALUES).legalFor({{s32, s64}});
|
||||||
setAction({G_FCMP, 1, s64}, Legal);
|
|
||||||
|
|
||||||
setAction({G_MERGE_VALUES, s64}, Legal);
|
getActionDefinitionsBuilder(G_FPEXT).legalFor({{s64, s32}});
|
||||||
setAction({G_MERGE_VALUES, 1, s32}, Legal);
|
getActionDefinitionsBuilder(G_FPTRUNC).legalFor({{s32, s64}});
|
||||||
setAction({G_UNMERGE_VALUES, s32}, Legal);
|
|
||||||
setAction({G_UNMERGE_VALUES, 1, s64}, Legal);
|
|
||||||
|
|
||||||
setAction({G_FPEXT, s64}, Legal);
|
getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
|
||||||
setAction({G_FPEXT, 1, s32}, Legal);
|
.legalForCartesianProduct({s32}, {s32, s64});
|
||||||
|
getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
|
||||||
setAction({G_FPTRUNC, s32}, Legal);
|
.legalForCartesianProduct({s32, s64}, {s32});
|
||||||
setAction({G_FPTRUNC, 1, s64}, Legal);
|
|
||||||
|
|
||||||
for (unsigned Op : {G_FPTOSI, G_FPTOUI}) {
|
|
||||||
setAction({Op, s32}, Legal);
|
|
||||||
for (auto Ty : {s32, s64})
|
|
||||||
setAction({Op, 1, Ty}, Legal);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned Op : {G_SITOFP, G_UITOFP}) {
|
|
||||||
setAction({Op, 1, s32}, Legal);
|
|
||||||
for (auto Ty : {s32, s64})
|
|
||||||
setAction({Op, Ty}, Legal);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV})
|
getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV})
|
||||||
for (auto Ty : {s32, s64})
|
.libcallFor({s32, s64});
|
||||||
setAction({BinOp, Ty}, Libcall);
|
|
||||||
|
|
||||||
for (auto Ty : {s32, s64}) {
|
LoadStoreBuilder.maxScalar(0, s32);
|
||||||
|
|
||||||
|
for (auto Ty : {s32, s64})
|
||||||
setAction({G_FNEG, Ty}, Lower);
|
setAction({G_FNEG, Ty}, Lower);
|
||||||
setAction({G_FCONSTANT, Ty}, Custom);
|
|
||||||
}
|
|
||||||
|
|
||||||
setAction({G_FCMP, s1}, Legal);
|
getActionDefinitionsBuilder(G_FCONSTANT).customFor({s32, s64});
|
||||||
setAction({G_FCMP, 1, s32}, Custom);
|
|
||||||
setAction({G_FCMP, 1, s64}, Custom);
|
|
||||||
|
|
||||||
setAction({G_FPEXT, s64}, Legal);
|
getActionDefinitionsBuilder(G_FCMP).customForCartesianProduct({s1},
|
||||||
setAction({G_FPEXT, 1, s32}, Libcall);
|
{s32, s64});
|
||||||
|
|
||||||
setAction({G_FPTRUNC, s32}, Legal);
|
|
||||||
setAction({G_FPTRUNC, 1, s64}, Libcall);
|
|
||||||
|
|
||||||
for (unsigned Op : {G_FPTOSI, G_FPTOUI}) {
|
|
||||||
setAction({Op, s32}, Legal);
|
|
||||||
setAction({Op, 1, s32}, Libcall);
|
|
||||||
setAction({Op, 1, s64}, Libcall);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned Op : {G_SITOFP, G_UITOFP}) {
|
|
||||||
for (auto Ty : {s32, s64})
|
|
||||||
setAction({Op, Ty}, Libcall);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AEABI(ST))
|
if (AEABI(ST))
|
||||||
setFCmpLibcallsAEABI();
|
setFCmpLibcallsAEABI();
|
||||||
else
|
else
|
||||||
setFCmpLibcallsGNU();
|
setFCmpLibcallsGNU();
|
||||||
|
|
||||||
|
getActionDefinitionsBuilder(G_FPEXT).libcallFor({s64, s32});
|
||||||
|
getActionDefinitionsBuilder(G_FPTRUNC).libcallFor({s32, s64});
|
||||||
|
|
||||||
|
getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
|
||||||
|
.libcallForCartesianProduct({s32}, {s32, s64});
|
||||||
|
getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
|
||||||
|
.libcallForCartesianProduct({s32, s64}, {s32});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ST.useSoftFloat() && ST.hasVFP4())
|
if (!ST.useSoftFloat() && ST.hasVFP4())
|
||||||
for (auto Ty : {s32, s64})
|
getActionDefinitionsBuilder(G_FMA).legalFor({s32, s64});
|
||||||
setAction({G_FMA, Ty}, Legal);
|
|
||||||
else
|
else
|
||||||
for (auto Ty : {s32, s64})
|
getActionDefinitionsBuilder(G_FMA).libcallFor({s32, s64});
|
||||||
setAction({G_FMA, Ty}, Libcall);
|
|
||||||
|
|
||||||
for (unsigned Op : {G_FREM, G_FPOW})
|
getActionDefinitionsBuilder({G_FREM, G_FPOW}).libcallFor({s32, s64});
|
||||||
for (auto Ty : {s32, s64})
|
|
||||||
setAction({Op, Ty}, Libcall);
|
|
||||||
|
|
||||||
computeTables();
|
computeTables();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue