]> granicus.if.org Git - llvm/commitdiff
GlobalISel: Add isPointer legality predicates
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sun, 20 Jan 2019 19:45:14 +0000 (19:45 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Sun, 20 Jan 2019 19:45:14 +0000 (19:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351699 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
lib/CodeGen/GlobalISel/LegalityPredicates.cpp

index e60d64510a0f42bd4da215a96963eb7f436de9a5..c738fd1352cdd4750df76d60d4b892adf76bb0dd 100644 (file)
@@ -204,6 +204,12 @@ LegalityPredicate typePairAndMemSizeInSet(
     std::initializer_list<TypePairAndMemSize> TypesAndMemSizeInit);
 /// True iff the specified type index is a scalar.
 LegalityPredicate isScalar(unsigned TypeIdx);
+/// True iff the specified type index is a pointer (with any address space).
+LegalityPredicate isPointer(unsigned TypeIdx);
+/// True iff the specified type index is a pointer with the specified address
+/// space.
+LegalityPredicate isPointer(unsigned TypeIdx, unsigned AddrSpace);
+
 /// True iff the specified type index is a scalar that's narrower than the given
 /// size.
 LegalityPredicate narrowerThan(unsigned TypeIdx, unsigned Size);
index 6148bbe2074ddf685ddd53c4c2056712fda413b7..5e3f38d3ca5939a16c44069eb17cd23ca034c3be 100644 (file)
@@ -56,6 +56,20 @@ LegalityPredicate LegalityPredicates::isScalar(unsigned TypeIdx) {
   };
 }
 
+LegalityPredicate LegalityPredicates::isPointer(unsigned TypeIdx) {
+  return [=](const LegalityQuery &Query) {
+    return Query.Types[TypeIdx].isPointer();
+  };
+}
+
+LegalityPredicate LegalityPredicates::isPointer(unsigned TypeIdx,
+                                                unsigned AddrSpace) {
+  return [=](const LegalityQuery &Query) {
+    LLT Ty = Query.Types[TypeIdx];
+    return Ty.isPointer() && Ty.getAddressSpace() == AddrSpace;
+  };
+}
+
 LegalityPredicate LegalityPredicates::narrowerThan(unsigned TypeIdx,
                                                    unsigned Size) {
   return [=](const LegalityQuery &Query) {