[PATCH] D29117: SPARC: allow usage of floating-point registers in inline ASM

Patrick Boettcher via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 25 01:00:11 PST 2017


pboettch updated this revision to Diff 85708.
pboettch added a comment.

Added  test-code.


https://reviews.llvm.org/D29117

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/sparcv8-inline-asm.c


Index: test/CodeGen/sparcv8-inline-asm.c
===================================================================
--- /dev/null
+++ test/CodeGen/sparcv8-inline-asm.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: define float @fabsf(float %a) #0 {
+// CHECK: %2 = call float asm sideeffect "fabss  $1, $0;", "=f,f"(float %1) #1
+float fabsf(float a) {
+  float res;
+  __asm __volatile__("fabss  %1, %0;"
+                     : /* reg out*/ "=f"(res)
+                     : /* reg in */ "f"(a));
+  return res;
+}
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6707,6 +6707,10 @@
     case 'N': // Same as 'K' but zext (required for SIMode)
     case 'O': // The constant 4096
       return true;
+
+    case 'f':
+      info.setAllowsRegister();
+      return true;
     }
     return false;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29117.85708.patch
Type: text/x-patch
Size: 968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170125/fd4026cc/attachment.bin>


More information about the cfe-commits mailing list