[PATCH] D56956: GlobalISel: Add isPointer legality predicates

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 18 21:58:50 PST 2019


arsenm created this revision.
arsenm added reviewers: dsanders, aditya_nandakumar, aemerson, volkan.
Herald added subscribers: kristof.beyls, rovka, wdng.

https://reviews.llvm.org/D56956

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


Index: lib/CodeGen/GlobalISel/LegalityPredicates.cpp
===================================================================
--- lib/CodeGen/GlobalISel/LegalityPredicates.cpp
+++ lib/CodeGen/GlobalISel/LegalityPredicates.cpp
@@ -63,6 +63,20 @@
   };
 }
 
+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) {
Index: include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
===================================================================
--- include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -207,6 +207,12 @@
 LegalityPredicate isScalar(unsigned TypeIdx);
 /// True iff the specified type index is a vector.
 LegalityPredicate isVector(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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56956.182666.patch
Type: text/x-patch
Size: 1674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190119/882c284a/attachment.bin>


More information about the llvm-commits mailing list