Skip to content

Commit 569ad7c

Browse files
committed
[AArch64][GlobalISel] Move UseOutlineAtomics to a bool check. NFC
Similar to #111287, this moves the UseOutlineAtomics legalization rules to a boolean predicate as opposed to needing the be nested functions. There appeared to be a pair of redundant customIfs for s128 sizes (assuming only scalars are supported).
1 parent b238c2b commit 569ad7c

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,12 @@ class LegalizeRuleSet {
760760
return actionFor(LegalizeAction::Libcall, Types);
761761
}
762762
LegalizeRuleSet &
763+
libcallFor(bool Pred, std::initializer_list<std::pair<LLT, LLT>> Types) {
764+
if (!Pred)
765+
return *this;
766+
return actionFor(LegalizeAction::Libcall, Types);
767+
}
768+
LegalizeRuleSet &
763769
libcallForCartesianProduct(std::initializer_list<LLT> Types) {
764770
return actionForCartesianProduct(LegalizeAction::Libcall, Types);
765771
}

llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -848,29 +848,21 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
848848
.lowerIf(
849849
all(typeInSet(0, {s8, s16, s32, s64, s128}), typeIs(2, p0)));
850850

851-
LegalityPredicate UseOutlineAtomics = [&ST](const LegalityQuery &Query) {
852-
return ST.outlineAtomics() && !ST.hasLSE();
853-
};
851+
bool UseOutlineAtomics = ST.outlineAtomics() && !ST.hasLSE();
854852

855853
getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG)
856-
.legalIf(all(typeInSet(0, {s32, s64}), typeIs(1, p0),
857-
predNot(UseOutlineAtomics)))
858-
.customIf(all(typeIs(0, s128), predNot(UseOutlineAtomics)))
859-
.customIf([UseOutlineAtomics](const LegalityQuery &Query) {
860-
return Query.Types[0].getSizeInBits() == 128 &&
861-
!UseOutlineAtomics(Query);
862-
})
863-
.libcallIf(all(typeInSet(0, {s8, s16, s32, s64, s128}), typeIs(1, p0),
864-
UseOutlineAtomics))
854+
.legalFor(!UseOutlineAtomics, {{s32, p0}, {s64, p0}})
855+
.customFor(!UseOutlineAtomics, {{s128, p0}})
856+
.libcallFor(UseOutlineAtomics,
857+
{{s8, p0}, {s16, p0}, {s32, p0}, {s64, p0}, {s128, p0}})
865858
.clampScalar(0, s32, s64);
866859

867860
getActionDefinitionsBuilder({G_ATOMICRMW_XCHG, G_ATOMICRMW_ADD,
868861
G_ATOMICRMW_SUB, G_ATOMICRMW_AND, G_ATOMICRMW_OR,
869862
G_ATOMICRMW_XOR})
870-
.legalIf(all(typeInSet(0, {s32, s64}), typeIs(1, p0),
871-
predNot(UseOutlineAtomics)))
872-
.libcallIf(all(typeInSet(0, {s8, s16, s32, s64}), typeIs(1, p0),
873-
UseOutlineAtomics))
863+
.legalFor(!UseOutlineAtomics, {{s32, p0}, {s64, p0}})
864+
.libcallFor(UseOutlineAtomics,
865+
{{s8, p0}, {s16, p0}, {s32, p0}, {s64, p0}})
874866
.clampScalar(0, s32, s64);
875867

876868
// Do not outline these atomics operations, as per comment in

llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -205,34 +205,34 @@
205205
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
206206
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
207207
# DEBUG-NEXT: G_ATOMIC_CMPXCHG (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
208-
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
209-
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
208+
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
209+
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
210210
# DEBUG-NEXT: G_ATOMICRMW_XCHG (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
211-
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
212-
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
211+
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
212+
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
213213
# DEBUG-NEXT: G_ATOMICRMW_ADD (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
214214
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
215-
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
216-
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
215+
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
216+
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
217217
# DEBUG-NEXT: G_ATOMICRMW_SUB (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
218218
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
219-
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
220-
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
219+
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
220+
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
221221
# DEBUG-NEXT: G_ATOMICRMW_AND (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
222222
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
223-
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
224-
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
223+
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
224+
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
225225
# DEBUG-NEXT: G_ATOMICRMW_NAND (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
226226
# DEBUG-NEXT: .. type index coverage check SKIPPED: no rules defined
227227
# DEBUG-NEXT: .. imm index coverage check SKIPPED: no rules defined
228228
# DEBUG-NEXT: G_ATOMICRMW_OR (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
229229
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
230-
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
231-
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
230+
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
231+
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
232232
# DEBUG-NEXT: G_ATOMICRMW_XOR (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
233233
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
234-
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
235-
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
234+
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
235+
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
236236
# DEBUG-NEXT: G_ATOMICRMW_MAX (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
237237
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
238238
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected

0 commit comments

Comments
 (0)