[PATCH] D93060: [TTI] Add supportsScalableVectors target hook

Cullen Rhodes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 12:51:07 PST 2020


c-rhodes created this revision.
c-rhodes added reviewers: sdesmalen, ctetreau, dmgreen, efriedma.
Herald added subscribers: hiraditya, kristof.beyls.
c-rhodes requested review of this revision.
Herald added a project: LLVM.

This is split off from D91718 <https://reviews.llvm.org/D91718> and adds a new target hook
supportsScalableVectors that can be queried to check if scalable vectors
are supported by the backend. For AArch64 this returns true if SVE is
enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93060

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h


Index: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
===================================================================
--- llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -228,6 +228,8 @@
     return 2;
   }
 
+  bool supportsScalableVectors() const { return ST->hasSVE(); }
+
   bool useReductionIntrinsic(unsigned Opcode, Type *Ty,
                              TTI::ReductionFlags Flags) const;
 
Index: llvm/lib/Analysis/TargetTransformInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetTransformInfo.cpp
+++ llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1051,6 +1051,10 @@
   return TTIImpl->getGISelRematGlobalCost();
 }
 
+bool TargetTransformInfo::supportsScalableVectors() const {
+  return TTIImpl->supportsScalableVectors();
+}
+
 int TargetTransformInfo::getInstructionLatency(const Instruction *I) const {
   return TTIImpl->getInstructionLatency(I);
 }
Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -683,6 +683,8 @@
 
   unsigned getGISelRematGlobalCost() const { return 1; }
 
+  bool supportsScalableVectors() const { return false; }
+
   bool hasActiveVectorLength() const { return false; }
 
 protected:
Index: llvm/include/llvm/Analysis/TargetTransformInfo.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1329,6 +1329,9 @@
   /// to a stack reload.
   unsigned getGISelRematGlobalCost() const;
 
+  /// \returns True if the target supports scalable vectors.
+  bool supportsScalableVectors() const;
+
   /// \name Vector Predication Information
   /// @{
   /// Whether the target supports the %evl parameter of VP intrinsic efficiently
@@ -1622,6 +1625,7 @@
                                                ReductionFlags) const = 0;
   virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0;
   virtual unsigned getGISelRematGlobalCost() const = 0;
+  virtual bool supportsScalableVectors() const = 0;
   virtual bool hasActiveVectorLength() const = 0;
   virtual int getInstructionLatency(const Instruction *I) = 0;
 };
@@ -2148,6 +2152,10 @@
     return Impl.getGISelRematGlobalCost();
   }
 
+  bool supportsScalableVectors() const override {
+    return Impl.supportsScalableVectors();
+  }
+
   bool hasActiveVectorLength() const override {
     return Impl.hasActiveVectorLength();
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93060.310990.patch
Type: text/x-patch
Size: 2687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201210/59d2fdc5/attachment.bin>


More information about the llvm-commits mailing list