[llvm-commits] [llvm] r119367 - /llvm/trunk/utils/TableGen/NeonEmitter.cpp

Bob Wilson bob.wilson at apple.com
Tue Nov 16 11:16:06 PST 2010


Author: bwilson
Date: Tue Nov 16 13:16:06 2010
New Revision: 119367

URL: http://llvm.org/viewvc/llvm-project?rev=119367&view=rev
Log:
Reapply "Stop using struct wrappers for Neon vector types in <arm_neon.h>."
I've temporarily disabled the failing clang test.

Modified:
    llvm/trunk/utils/TableGen/NeonEmitter.cpp

Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=119367&r1=119366&r2=119367&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Tue Nov 16 13:16:06 2010
@@ -535,10 +535,8 @@
 }
 
 // Generate the definition for this intrinsic, e.g. "a + b" for OpAdd.
-// If structTypes is true, the NEON types are structs of vector types rather
-// than vector types, and the call becomes "a.val + b.val"
 static std::string GenOpString(OpKind op, const std::string &proto,
-                               StringRef typestr, bool structTypes = true) {
+                               StringRef typestr) {
   bool dummy, quad = false;
   char type = ClassifyType(typestr, quad, dummy, dummy);
   unsigned nElts = 0;
@@ -557,100 +555,95 @@
     s = "union { " + ts + " r; double d; } u; u.d";
   } else {
     s = ts + " r; r";
-    if (structTypes)
-      s += ".val";
   }
   
   s += " = ";
 
-  std::string a, b, c;
-  if (proto.size() > 1)
-    a = (structTypes && proto[1] != 'l' && proto[1] != 's') ? "a.val" : "a";
-  b = structTypes ? "b.val" : "b";
-  c = structTypes ? "c.val" : "c";
-  
   switch(op) {
   case OpAdd:
-    s += a + " + " + b;
+    s += "a + b";
     break;
   case OpSub:
-    s += a + " - " + b;
+    s += "a - b";
     break;
   case OpMulN:
-    b = Duplicate(nElts << (int)quad, typestr, "b");
+    s += "a * " + Duplicate(nElts << (int)quad, typestr, "b");
+    break;
   case OpMul:
-    s += a + " * " + b;
+    s += "a * b";
     break;
   case OpMlaN:
-    c = Duplicate(nElts << (int)quad, typestr, "c");
+    s += "a + (b * " + Duplicate(nElts << (int)quad, typestr, "c") + ")";
+    break;
   case OpMla:
-    s += a + " + ( " + b + " * " + c + " )";
+    s += "a + (b * c)";
     break;
   case OpMlsN:
-    c = Duplicate(nElts << (int)quad, typestr, "c");
+    s += "a - (b * " + Duplicate(nElts << (int)quad, typestr, "c") + ")";
+    break;
   case OpMls:
-    s += a + " - ( " + b + " * " + c + " )";
+    s += "a - (b * c)";
     break;
   case OpEq:
-    s += "(__neon_" + ts + ")(" + a + " == " + b + ")";
+    s += "(__neon_" + ts + ")(a == b)";
     break;
   case OpGe:
-    s += "(__neon_" + ts + ")(" + a + " >= " + b + ")";
+    s += "(__neon_" + ts + ")(a >= b)";
     break;
   case OpLe:
-    s += "(__neon_" + ts + ")(" + a + " <= " + b + ")";
+    s += "(__neon_" + ts + ")(a <= b)";
     break;
   case OpGt:
-    s += "(__neon_" + ts + ")(" + a + " > " + b + ")";
+    s += "(__neon_" + ts + ")(a > b)";
     break;
   case OpLt:
-    s += "(__neon_" + ts + ")(" + a + " < " + b + ")";
+    s += "(__neon_" + ts + ")(a < b)";
     break;
   case OpNeg:
-    s += " -" + a;
+    s += " -a";
     break;
   case OpNot:
-    s += " ~" + a;
+    s += " ~a";
     break;
   case OpAnd:
-    s += a + " & " + b;
+    s += "a & b";
     break;
   case OpOr:
-    s += a + " | " + b;
+    s += "a | b";
     break;
   case OpXor:
-    s += a + " ^ " + b;
+    s += "a ^ b";
     break;
   case OpAndNot:
-    s += a + " & ~" + b;
+    s += "a & ~b";
     break;
   case OpOrNot:
-    s += a + " | ~" + b;
+    s += "a | ~b";
     break;
   case OpCast:
-    s += "(__neon_" + ts + ")" + a;
+    s += "(__neon_" + ts + ")a";
     break;
   case OpConcat:
-    s += "__builtin_shufflevector((__neon_int64x1_t)" + a;
-    s += ", (__neon_int64x1_t)" + b + ", 0, 1)";
+    s += "__builtin_shufflevector((__neon_int64x1_t)a";
+    s += ", (__neon_int64x1_t)b, 0, 1)";
     break;
   case OpHi:
-    s += "(((__neon_float64x2_t)" + a + ")[1])";
+    s += "(((__neon_float64x2_t)a)[1])";
     break;
   case OpLo:
-    s += "(((__neon_float64x2_t)" + a + ")[0])";
+    s += "(((__neon_float64x2_t)a)[0])";
     break;
   case OpDup:
-    s += Duplicate(nElts << (int)quad, typestr, a);
+    s += Duplicate(nElts << (int)quad, typestr, "a");
     break;
   case OpSelect:
     // ((0 & 1) | (~0 & 2))
     ts = TypeString(proto[1], typestr);
-    s += "( " + a + " & (__neon_" + ts + ")" + b + ") | ";
-    s += "(~" + a + " & (__neon_" + ts + ")" + c + ")";
+    s += "(a & (__neon_" + ts + ")b) | ";
+    s += "(~a & (__neon_" + ts + ")c)";
     break;
   case OpRev16:
-    s += "__builtin_shufflevector(" + a + ", " + a;
+    s += "__builtin_shufflevector(a, a";
     for (unsigned i = 2; i <= nElts << (int)quad; i += 2)
       for (unsigned j = 0; j != 2; ++j)
         s += ", " + utostr(i - j - 1);
@@ -658,14 +651,14 @@
     break;
   case OpRev32:
     nElts >>= 1;
-    s += "__builtin_shufflevector(" + a + ", " + a;
+    s += "__builtin_shufflevector(a, a";
     for (unsigned i = nElts; i <= nElts << (1 + (int)quad); i += nElts)
       for (unsigned j = 0; j != nElts; ++j)
         s += ", " + utostr(i - j - 1);
     s += ")";
     break;
   case OpRev64:
-    s += "__builtin_shufflevector(" + a + ", " + a;
+    s += "__builtin_shufflevector(a, a";
     for (unsigned i = nElts; i <= nElts << (int)quad; i += nElts)
       for (unsigned j = 0; j != nElts; ++j)
         s += ", " + utostr(i - j - 1);
@@ -734,11 +727,8 @@
 }
 
 // Generate the definition for this intrinsic, e.g. __builtin_neon_cls(a)
-// If structTypes is true, the NEON types are structs of vector types rather
-// than vector types, and the call becomes __builtin_neon_cls(a.val)
 static std::string GenBuiltin(const std::string &name, const std::string &proto,
-                              StringRef typestr, ClassKind ck,
-                              bool structTypes = true) {
+                              StringRef typestr, ClassKind ck) {
   bool dummy, quad = false;
   char type = ClassifyType(typestr, quad, dummy, dummy);
   unsigned nElts = 0;
@@ -777,15 +767,11 @@
       if (sret)
         s += "({ " + ts + " r; ";
       else if (proto[0] != 's')
-        s += "(" + ts + "){(__neon_" + ts + ")";
+        s += "(" + ts + ")";
     } else if (sret) {
       s += ts + " r; ";
     } else {
-      s += ts + " r; r";
-      if (structTypes && proto[0] != 's' && proto[0] != 'i' && proto[0] != 'l')
-        s += ".val";
-      
-      s += " = ";
+      s += ts + " r; r = ";
     }
   }
   
@@ -812,9 +798,9 @@
     
     // Handle multiple-vector values specially, emitting each subvector as an
     // argument to the __builtin.
-    if (structTypes && (proto[i] == '2' || proto[i] == '3' || proto[i] == '4')){
+    if (proto[i] == '2' || proto[i] == '3' || proto[i] == '4') {
       for (unsigned vi = 0, ve = proto[i] - '0'; vi != ve; ++vi) {
-        s += args + ".val[" + utostr(vi) + "].val";
+        s += args + ".val[" + utostr(vi) + "]";
         if ((vi + 1) < ve)
           s += ", ";
       }
@@ -828,11 +814,6 @@
       s += Duplicate(nElts, typestr, args);
     else
       s += args;
-    
-    if (structTypes && proto[i] != 's' && proto[i] != 'i' && proto[i] != 'l' &&
-        proto[i] != 'p' && proto[i] != 'c' && proto[i] != 'a') {
-      s += ".val";
-    }
     if ((i + 1) < e)
       s += ", ";
   }
@@ -850,8 +831,6 @@
     if (define) {
       if (sret)
         s += "; r; })";
-      else if (proto[0] != 's')
-        s += "}";
     } else {
       s += " return r;";
     }
@@ -942,11 +921,15 @@
       std::string ts = TypeString('d', TDTypeVec[i], vi == 1);
       std::string vs = TypeString((vi > 1) ? '0' + vi : 'd', TDTypeVec[i]);
       std::string tag = (vi > 1) ? vs : StructTag(TDTypeVec[i]);
-      OS << "typedef struct " << tag << " {\n";
-      OS << "  " << ts << " val";
-      if (vi > 1)
+      if (vi > 1) {
+        OS << "typedef struct " << tag << " {\n";
+        OS << "  " << ts << " val";
         OS << "[" << utostr(vi) << "]";
-      OS << ";\n} " << vs << ";\n\n";
+        OS << ";\n} ";
+      } else {
+        OS << "typedef " << ts << " ";
+      }
+      OS << vs << ";\n\n";
     }
   }
   





More information about the llvm-commits mailing list