[SPARC] Support 'f' and 'e' inline asm constraints.
authorJames Y Knight <jyknight@google.com>
Fri, 12 May 2017 16:01:23 +0000 (16:01 +0000)
committerJames Y Knight <jyknight@google.com>
Fri, 12 May 2017 16:01:23 +0000 (16:01 +0000)
Patch by Patrick Boettcher.

Differential Revision: https://reviews.llvm.org/D29117

llvm-svn: 302913

clang/lib/Basic/Targets.cpp
clang/test/CodeGen/sparcv8-inline-asm.c [new file with mode: 0644]

index 33eb0b0..92c561a 100644 (file)
@@ -6862,6 +6862,11 @@ public:
     case 'N': // Same as 'K' but zext (required for SIMode)
     case 'O': // The constant 4096
       return true;
+
+    case 'f':
+    case 'e':
+      info.setAllowsRegister();
+      return true;
     }
     return false;
   }
diff --git a/clang/test/CodeGen/sparcv8-inline-asm.c b/clang/test/CodeGen/sparcv8-inline-asm.c
new file mode 100644 (file)
index 0000000..711a2a0
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: define float @fabsf(float %a)
+// CHECK: %{{.*}} = call float asm sideeffect "fabss $1, $0;", "=e,f"(float %{{.*}}) #1
+float fabsf(float a) {
+  float res;
+  __asm __volatile__("fabss  %1, %0;"
+                     : /* reg out*/ "=e"(res)
+                     : /* reg in */ "f"(a));
+  return res;
+}