[PATCH] D96338: [Analysis] Change VFABI::mangleTLIVectorName to use ElementCount

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 01:38:20 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9700228abc78: [Analysis] Change VFABI::mangleTLIVectorName to use ElementCount (authored by david-arm).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96338/new/

https://reviews.llvm.org/D96338

Files:
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
  llvm/unittests/Analysis/VectorFunctionABITest.cpp


Index: llvm/unittests/Analysis/VectorFunctionABITest.cpp
===================================================================
--- llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -101,9 +101,14 @@
 
 // This test makes sure correct mangling occurs for given string.
 TEST_F(VFABIParserTest, ManglingVectorTLINames) {
-  EXPECT_EQ(VFABI::mangleTLIVectorName("vec", "scalar", 3, 4),
-            "_ZGV_LLVM_N4vvv_scalar(vec)");
-  EXPECT_EQ(VFABI::mangleTLIVectorName("custom.call.v5", "custom.call", 1, 5),
+  EXPECT_EQ(
+      VFABI::mangleTLIVectorName("vec", "scalar", 3, ElementCount::getFixed(4)),
+      "_ZGV_LLVM_N4vvv_scalar(vec)");
+  EXPECT_EQ(VFABI::mangleTLIVectorName("vec", "scalar", 3,
+                                       ElementCount::getScalable(4)),
+            "_ZGV_LLVM_Nxvvv_scalar(vec)");
+  EXPECT_EQ(VFABI::mangleTLIVectorName("custom.call.v5", "custom.call", 1,
+                                       ElementCount::getFixed(5)),
             "_ZGV_LLVM_N5v_custom.call(custom.call.v5)");
 }
 
Index: llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
===================================================================
--- llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
+++ llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
@@ -96,7 +96,8 @@
         std::string(TLI.getVectorizedFunction(ScalarName, VF));
     if (!TLIName.empty()) {
       std::string MangledName = VFABI::mangleTLIVectorName(
-          TLIName, ScalarName, CI.getNumArgOperands(), VF);
+          TLIName, ScalarName, CI.getNumArgOperands(),
+          ElementCount::getFixed(VF));
       if (!OriginalSetOfMappings.count(MangledName)) {
         Mappings.push_back(MangledName);
         ++NumCallInjected;
Index: llvm/lib/Analysis/VectorUtils.cpp
===================================================================
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -1300,10 +1300,14 @@
 
 std::string VFABI::mangleTLIVectorName(StringRef VectorName,
                                        StringRef ScalarName, unsigned numArgs,
-                                       unsigned VF) {
+                                       ElementCount VF) {
   SmallString<256> Buffer;
   llvm::raw_svector_ostream Out(Buffer);
-  Out << "_ZGV" << VFABI::_LLVM_ << "N" << VF;
+  Out << "_ZGV" << VFABI::_LLVM_ << "N";
+  if (VF.isScalable())
+    Out << 'x';
+  else
+    Out << VF.getFixedValue();
   for (unsigned I = 0; I < numArgs; ++I)
     Out << "v";
   Out << "_" << ScalarName << "(" << VectorName << ")";
Index: llvm/include/llvm/Analysis/VectorUtils.h
===================================================================
--- llvm/include/llvm/Analysis/VectorUtils.h
+++ llvm/include/llvm/Analysis/VectorUtils.h
@@ -186,12 +186,13 @@
 /// <isa> = "_LLVM_"
 /// <mask> = "N". Note: TLI does not support masked interfaces.
 /// <vlen> = Number of concurrent lanes, stored in the `VectorizationFactor`
-///          field of the `VecDesc` struct.
+///          field of the `VecDesc` struct. If the number of lanes is scalable
+///          then 'x' is printed instead.
 /// <vparams> = "v", as many as are the numArgs.
 /// <scalarname> = the name of the scalar function.
 /// <vectorname> = the name of the vector function.
 std::string mangleTLIVectorName(StringRef VectorName, StringRef ScalarName,
-                                unsigned numArgs, unsigned VF);
+                                unsigned numArgs, ElementCount VF);
 
 /// Retrieve the `VFParamKind` from a string token.
 VFParamKind getVFParamKindFromString(const StringRef Token);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96338.323249.patch
Type: text/x-patch
Size: 3634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210212/ffe5cb65/attachment.bin>


More information about the llvm-commits mailing list