r218082 - [X86, inlineasm] Do not allow using constraint 'x' for a variable larger than

Akira Hatanaka ahatanaka at apple.com
Thu Sep 18 14:58:55 PDT 2014


Author: ahatanak
Date: Thu Sep 18 16:58:54 2014
New Revision: 218082

URL: http://llvm.org/viewvc/llvm-project?rev=218082&view=rev
Log:
[X86, inlineasm] Do not allow using constraint 'x' for a variable larger than
128-bit unless the target CPU supports AVX.

rdar://problem/11846140

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/test/CodeGen/x86_32-inline-asm.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=218082&r1=218081&r2=218082&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Sep 18 16:58:54 2014
@@ -3084,7 +3084,8 @@ bool X86TargetInfo::validateOperandSize(
   case 'u':
     return Size <= 128;
   case 'x':
-    return Size <= 256;
+    // 256-bit ymm registers can be used if target supports AVX.
+    return Size <= (SSELevel >= AVX ? 256 : 128);
   }
 
   return true;

Modified: cfe/trunk/test/CodeGen/x86_32-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-inline-asm.c?rev=218082&r1=218081&r2=218082&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/x86_32-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/x86_32-inline-asm.c Thu Sep 18 16:58:54 2014
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i386-apple-darwin9 -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -target-feature +avx -verify %s
 
 // <rdar://problem/12415959>
 // rdar://problem/11846140
@@ -45,7 +46,6 @@ int func1() {
   __asm__ volatile("foo1 %0" : : "f" (val256)); // expected-error {{invalid input size for constraint 'f'}}
   __asm__ volatile("foo1 %0" : : "t" (val256)); // expected-error {{invalid input size for constraint 't'}}
   __asm__ volatile("foo1 %0" : : "u" (val256)); // expected-error {{invalid input size for constraint 'u'}}
-  __asm__ volatile("foo1 %0" : : "x" (val256)); // No error.
   __asm__ volatile("foo1 %0" : : "x" (val512)); // expected-error {{invalid input size for constraint 'x'}}
 
   __asm__ volatile("foo1 %0" : "=R" (val)); // expected-error {{invalid output size for constraint '=R'}}
@@ -60,6 +60,13 @@ int func1() {
   __asm__ volatile("foo1 %0" : "=A" (val128)); // expected-error {{invalid output size for constraint '=A'}}
   __asm__ volatile("foo1 %0" : "=t" (val256)); // expected-error {{invalid output size for constraint '=t'}}
   __asm__ volatile("foo1 %0" : "=u" (val256)); // expected-error {{invalid output size for constraint '=u'}}
-  __asm__ volatile("foo1 %0" : "=x" (val256)); // No error.
   __asm__ volatile("foo1 %0" : "=x" (val512)); // expected-error {{invalid output size for constraint '=x'}}
+
+#ifdef __AVX__
+  __asm__ volatile("foo1 %0" : : "x" (val256)); // No error.
+  __asm__ volatile("foo1 %0" : "=x" (val256));  // No error.
+#else
+  __asm__ volatile("foo1 %0" : : "x" (val256)); // expected-error {{invalid input size for constraint 'x'}}
+  __asm__ volatile("foo1 %0" : "=x" (val256)); // expected-error {{invalid output size for constraint '=x'}}
+#endif
 }





More information about the cfe-commits mailing list