r179636 - [3/6] ARM Neon Intrinsic Tablegen Test Generator.

Michael Gottesman mgottesman at apple.com
Tue Apr 16 15:07:31 PDT 2013


Author: mgottesman
Date: Tue Apr 16 17:07:30 2013
New Revision: 179636

URL: http://llvm.org/viewvc/llvm-project?rev=179636&view=rev
Log:
[3/6] ARM Neon Intrinsic Tablegen Test Generator.

Refactored out the method InstructionTypeCode from MangleName for use in
further patches which perform neon tablegen test generation.

Reviewed by Bob Wilson.

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

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=179636&r1=179635&r2=179636&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Tue Apr 16 17:07:30 2013
@@ -588,73 +588,89 @@ static std::string BuiltinTypeString(con
   return quad ? "V16Sc" : "V8Sc";
 }
 
-/// MangleName - Append a type or width suffix to a base neon function name,
-/// and insert a 'q' in the appropriate location if the operation works on
-/// 128b rather than 64b.   E.g. turn "vst2_lane" into "vst2q_lane_f32", etc.
-static std::string MangleName(const std::string &name, StringRef typestr,
-                              ClassKind ck) {
-  if (name == "vcvt_f32_f16")
-    return name;
-
-  bool quad = false;
+/// InstructionTypeCode - Computes the ARM argument character code and
+/// quad status for a specific type string and ClassKind.
+static void InstructionTypeCode(const StringRef &typeStr,
+                                const ClassKind ck,
+                                bool &quad,
+                                std::string &typeCode) {
   bool poly = false;
   bool usgn = false;
-  char type = ClassifyType(typestr, quad, poly, usgn);
-
-  std::string s = name;
+  char type = ClassifyType(typeStr, quad, poly, usgn);
 
   switch (type) {
   case 'c':
     switch (ck) {
-    case ClassS: s += poly ? "_p8" : usgn ? "_u8" : "_s8"; break;
-    case ClassI: s += "_i8"; break;
-    case ClassW: s += "_8"; break;
+    case ClassS: typeCode = poly ? "p8" : usgn ? "u8" : "s8"; break;
+    case ClassI: typeCode = "i8"; break;
+    case ClassW: typeCode = "8"; break;
     default: break;
     }
     break;
   case 's':
     switch (ck) {
-    case ClassS: s += poly ? "_p16" : usgn ? "_u16" : "_s16"; break;
-    case ClassI: s += "_i16"; break;
-    case ClassW: s += "_16"; break;
+    case ClassS: typeCode = poly ? "p16" : usgn ? "u16" : "s16"; break;
+    case ClassI: typeCode = "i16"; break;
+    case ClassW: typeCode = "16"; break;
     default: break;
     }
     break;
   case 'i':
     switch (ck) {
-    case ClassS: s += usgn ? "_u32" : "_s32"; break;
-    case ClassI: s += "_i32"; break;
-    case ClassW: s += "_32"; break;
+    case ClassS: typeCode = usgn ? "u32" : "s32"; break;
+    case ClassI: typeCode = "i32"; break;
+    case ClassW: typeCode = "32"; break;
     default: break;
     }
     break;
   case 'l':
     switch (ck) {
-    case ClassS: s += usgn ? "_u64" : "_s64"; break;
-    case ClassI: s += "_i64"; break;
-    case ClassW: s += "_64"; break;
+    case ClassS: typeCode = usgn ? "u64" : "s64"; break;
+    case ClassI: typeCode = "i64"; break;
+    case ClassW: typeCode = "64"; break;
     default: break;
     }
     break;
   case 'h':
     switch (ck) {
     case ClassS:
-    case ClassI: s += "_f16"; break;
-    case ClassW: s += "_16"; break;
+    case ClassI: typeCode = "f16"; break;
+    case ClassW: typeCode = "16"; break;
     default: break;
     }
     break;
   case 'f':
     switch (ck) {
     case ClassS:
-    case ClassI: s += "_f32"; break;
-    case ClassW: s += "_32"; break;
+    case ClassI: typeCode = "f32"; break;
+    case ClassW: typeCode = "32"; break;
     default: break;
     }
     break;
   default:
     PrintFatalError("unhandled type!");
   }
+}
+
+/// MangleName - Append a type or width suffix to a base neon function name,
+/// and insert a 'q' in the appropriate location if the operation works on
+/// 128b rather than 64b.   E.g. turn "vst2_lane" into "vst2q_lane_f32", etc.
+static std::string MangleName(const std::string &name, StringRef typestr,
+                              ClassKind ck) {
+  if (name == "vcvt_f32_f16")
+    return name;
+
+  bool quad = false;
+  std::string typeCode = "";
+
+  InstructionTypeCode(typestr, ck, quad, typeCode);
+
+  std::string s = name;
+
+  if (typeCode.size() > 0) {
+    s += "_" + typeCode;
+  }
+
   if (ck == ClassB)
     s += "_v";
 





More information about the cfe-commits mailing list