Add new built-in operations for vmull and vmull_n
authorBob Wilson <bob.wilson@apple.com>
Tue, 7 Dec 2010 20:02:45 +0000 (20:02 +0000)
committerBob Wilson <bob.wilson@apple.com>
Tue, 7 Dec 2010 20:02:45 +0000 (20:02 +0000)
so they can be implemented without requiring clang builtins.
Radar 8446238.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121173 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/NeonEmitter.cpp
utils/TableGen/NeonEmitter.h

index 3752db0f4d004d72abed56b0226343429a958849..7fdc1cacd69b434688440a8632b15819d0077536 100644 (file)
@@ -508,6 +508,15 @@ static std::string GenMacroLocals(const std::string &proto, StringRef typestr) {
   return s;
 }
 
+// Use the vmovl builtin to sign-extend or zero-extend a vector.
+static std::string Extend(const std::string &proto, StringRef typestr,
+                          const std::string &a) {
+  std::string s;
+  s = MangleName("vmovl", typestr, ClassS);
+  s += "(" + a + ")";
+  return s;
+}
+
 static std::string Duplicate(unsigned nElts, StringRef typestr,
                              const std::string &a) {
   std::string s;
@@ -587,6 +596,15 @@ static std::string GenOpString(OpKind op, const std::string &proto,
   case OpMul:
     s += "__a * __b;";
     break;
+  case OpMullN:
+    s += Extend(proto, typestr, "__a") + " * " +
+      Extend(proto, typestr,
+             Duplicate(nElts << (int)quad, typestr, "__b")) + ";";
+    break;
+  case OpMull:
+    s += Extend(proto, typestr, "__a") + " * " +
+      Extend(proto, typestr, "__b") + ";";
+    break;
   case OpMlaN:
     s += "__a + (__b * " + Duplicate(nElts, typestr, "__c") + ");";
     break;
index 3d122ffbba9e55613176727bdca02265074fc584..0ee856c26bdffebfc66554b0e7d2a04180df8793 100644 (file)
@@ -26,9 +26,11 @@ enum OpKind {
   OpAdd,
   OpSub,
   OpMul,
+  OpMull,
   OpMla,
   OpMls,
   OpMulN,
+  OpMullN,
   OpMlaN,
   OpMlsN,
   OpMulLane,
@@ -79,9 +81,11 @@ namespace llvm {
       OpMap["OP_ADD"]   = OpAdd;
       OpMap["OP_SUB"]   = OpSub;
       OpMap["OP_MUL"]   = OpMul;
+      OpMap["OP_MULL"]  = OpMull;
       OpMap["OP_MLA"]   = OpMla;
       OpMap["OP_MLS"]   = OpMls;
       OpMap["OP_MUL_N"] = OpMulN;
+      OpMap["OP_MULL_N"]= OpMullN;
       OpMap["OP_MLA_N"] = OpMlaN;
       OpMap["OP_MLS_N"] = OpMlsN;
       OpMap["OP_MUL_LN"]= OpMulLane;