Skip to content

Commit be15ae2

Browse files
committed
Add a isPointerVector legality check
1 parent c08d73b commit be15ae2

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ LegalityPredicate isPointer(unsigned TypeIdx);
292292
/// True iff the specified type index is a pointer with the specified address
293293
/// space.
294294
LegalityPredicate isPointer(unsigned TypeIdx, unsigned AddrSpace);
295+
/// True iff the specified type index is a vector of pointers (with any address
296+
/// space).
297+
LegalityPredicate isPointerVector(unsigned TypeIdx);
295298

296299
/// True if the type index is a vector with element type \p EltTy
297300
LegalityPredicate elementTypeIs(unsigned TypeIdx, LLT EltTy);

llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ LegalityPredicate LegalityPredicates::isPointer(unsigned TypeIdx,
101101
};
102102
}
103103

104+
LegalityPredicate LegalityPredicates::isPointerVector(unsigned TypeIdx) {
105+
return [=](const LegalityQuery &Query) {
106+
return Query.Types[TypeIdx].isPointerVector();
107+
};
108+
}
109+
104110
LegalityPredicate LegalityPredicates::elementTypeIs(unsigned TypeIdx,
105111
LLT EltTy) {
106112
return [=](const LegalityQuery &Query) {

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,15 +1080,11 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
10801080
.clampNumElements(0, v4s16, v8s16)
10811081
.clampNumElements(0, v4s32, v4s32)
10821082
.clampNumElements(0, v2s64, v2s64)
1083-
.bitcastIf(
1084-
// Bitcast pointers vector to i64.
1085-
[=](const LegalityQuery &Query) {
1086-
return Query.Types[0].isPointerVector();
1087-
},
1088-
[=](const LegalityQuery &Query) {
1089-
const LLT DstTy = Query.Types[0];
1090-
return std::pair(0, LLT::vector(DstTy.getElementCount(), 64));
1091-
});
1083+
.bitcastIf(isPointerVector(0), [=](const LegalityQuery &Query) {
1084+
// Bitcast pointers vector to i64.
1085+
const LLT DstTy = Query.Types[0];
1086+
return std::pair(0, LLT::vector(DstTy.getElementCount(), 64));
1087+
});
10921088

10931089
getActionDefinitionsBuilder(G_CONCAT_VECTORS)
10941090
.legalFor({{v4s32, v2s32}, {v8s16, v4s16}, {v16s8, v8s8}})

0 commit comments

Comments
 (0)