[PATCH] TLI: Add addVectorizableFunctionsFromVecLib.

Michael Zolotukhin mzolotukhin at apple.com
Fri Mar 6 17:23:09 PST 2015


Hi hfinkel, aschwaighofer, nadav, jmolloy,

Add a function addVectorizableFunctionsFromVecLib to TLI. It is a wrapper for
addVectorizableFunctions and uses preset tables for known vector-libraries.

http://reviews.llvm.org/D8131

Files:
  include/llvm/Analysis/TargetLibraryInfo.h

Index: include/llvm/Analysis/TargetLibraryInfo.h
===================================================================
--- include/llvm/Analysis/TargetLibraryInfo.h
+++ include/llvm/Analysis/TargetLibraryInfo.h
@@ -71,6 +71,11 @@
   std::vector<VecDesc> ScalarDescs;
 
 public:
+  enum VectorLibrary {
+    NoLibrary, // Don't use any vector library.
+    Accelerate // Use Accelerate framework.
+  };
+
   TargetLibraryInfoImpl();
   explicit TargetLibraryInfoImpl(const Triple &T);
 
@@ -117,6 +122,29 @@
   /// queryable via getVectorizedFunction and getScalarizedFunction.
   void addVectorizableFunctions(ArrayRef<VecDesc> Fns);
 
+  /// Calls addVectorizableFunctions with a known preset of functions for the
+  /// given vector library.
+  void addVectorizableFunctionsFromVecLib(enum VectorLibrary VecLib) {
+    switch (VecLib) {
+      case Accelerate: {
+        const VecDesc VecFuncs[] = {
+          {"expf", "vexpf", 4},
+          {"llvm.exp.f32", "vexpf", 4},
+          {"logf", "vlogf", 4},
+          {"llvm.log.f32", "vlogf", 4},
+          {"sqrtf", "vsqrtf", 4},
+          {"llvm.sqrt.f32", "vsqrtf", 4},
+          {"fabsf", "vfabsf", 4},
+          {"llvm.fabs.f32", "vfabsf", 4},
+        };
+        addVectorizableFunctions(VecFuncs);
+        break;
+      }
+      case NoLibrary:
+        break;
+    }
+  }
+
   /// isFunctionVectorizable - Return true if the function F has a
   /// vector equivalent with vectorization factor VF.
   bool isFunctionVectorizable(StringRef F, unsigned VF) const {

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8131.21412.patch
Type: text/x-patch
Size: 1528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150307/b5cceea5/attachment.bin>


More information about the llvm-commits mailing list