• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple i386-apple-darwin9 -verify %s
2 // RUN: %clang_cc1 -triple i386-apple-darwin9 -target-feature +avx -verify %s
3 
4 // <rdar://problem/12415959>
5 // rdar://problem/11846140
6 // rdar://problem/17476970
7 
8 typedef unsigned int u_int32_t;
9 typedef u_int32_t uint32_t;
10 
11 typedef unsigned long long u_int64_t;
12 typedef u_int64_t uint64_t;
13 
14 typedef float __m128 __attribute__ ((vector_size (16)));
15 typedef float __m256 __attribute__ ((vector_size (32)));
16 typedef float __m512 __attribute__ ((vector_size (64)));
17 
18 __m128 val128;
19 __m256 val256;
20 __m512 val512;
21 
func1()22 int func1() {
23   // Error out if size is > 32-bits.
24   uint32_t msr = 0x8b;
25   uint64_t val = 0;
26   __asm__ volatile("wrmsr"
27                    :
28                    : "c" (msr),
29                      "a" ((val & 0xFFFFFFFFUL)), // expected-error {{invalid input size for constraint 'a'}}
30                      "d" (((val >> 32) & 0xFFFFFFFFUL)));
31 
32   // Don't error out if the size of the destination is <= 32 bits.
33   unsigned char data;
34   unsigned int port;
35   __asm__ volatile("outb %0, %w1" : : "a" (data), "Nd" (port)); // No error expected.
36 
37   __asm__ volatile("outb %0, %w1" : : "R" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'R'}}
38   __asm__ volatile("outb %0, %w1" : : "q" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'q'}}
39   __asm__ volatile("outb %0, %w1" : : "Q" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'Q'}}
40   __asm__ volatile("outb %0, %w1" : : "b" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'b'}}
41   __asm__ volatile("outb %0, %w1" : : "c" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'c'}}
42   __asm__ volatile("outb %0, %w1" : : "d" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'd'}}
43   __asm__ volatile("outb %0, %w1" : : "S" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'S'}}
44   __asm__ volatile("outb %0, %w1" : : "D" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'D'}}
45   __asm__ volatile("foo1 %0" : : "A" (val128)); // expected-error {{invalid input size for constraint 'A'}}
46   __asm__ volatile("foo1 %0" : : "f" (val256)); // expected-error {{invalid input size for constraint 'f'}}
47   __asm__ volatile("foo1 %0" : : "t" (val256)); // expected-error {{invalid input size for constraint 't'}}
48   __asm__ volatile("foo1 %0" : : "u" (val256)); // expected-error {{invalid input size for constraint 'u'}}
49   __asm__ volatile("foo1 %0" : : "x" (val512)); // expected-error {{invalid input size for constraint 'x'}}
50 
51   __asm__ volatile("foo1 %0" : "=R" (val)); // expected-error {{invalid output size for constraint '=R'}}
52   __asm__ volatile("foo1 %0" : "=q" (val)); // expected-error {{invalid output size for constraint '=q'}}
53   __asm__ volatile("foo1 %0" : "=Q" (val)); // expected-error {{invalid output size for constraint '=Q'}}
54   __asm__ volatile("foo1 %0" : "=a" (val)); // expected-error {{invalid output size for constraint '=a'}}
55   __asm__ volatile("foo1 %0" : "=b" (val)); // expected-error {{invalid output size for constraint '=b'}}
56   __asm__ volatile("foo1 %0" : "=c" (val)); // expected-error {{invalid output size for constraint '=c'}}
57   __asm__ volatile("foo1 %0" : "=d" (val)); // expected-error {{invalid output size for constraint '=d'}}
58   __asm__ volatile("foo1 %0" : "=S" (val)); // expected-error {{invalid output size for constraint '=S'}}
59   __asm__ volatile("foo1 %0" : "=D" (val)); // expected-error {{invalid output size for constraint '=D'}}
60   __asm__ volatile("foo1 %0" : "=A" (val128)); // expected-error {{invalid output size for constraint '=A'}}
61   __asm__ volatile("foo1 %0" : "=t" (val256)); // expected-error {{invalid output size for constraint '=t'}}
62   __asm__ volatile("foo1 %0" : "=u" (val256)); // expected-error {{invalid output size for constraint '=u'}}
63   __asm__ volatile("foo1 %0" : "=x" (val512)); // expected-error {{invalid output size for constraint '=x'}}
64 
65 #ifdef __AVX__
66   __asm__ volatile("foo1 %0" : : "x" (val256)); // No error.
67   __asm__ volatile("foo1 %0" : "=x" (val256));  // No error.
68 #else
69   __asm__ volatile("foo1 %0" : : "x" (val256)); // expected-error {{invalid input size for constraint 'x'}}
70   __asm__ volatile("foo1 %0" : "=x" (val256)); // expected-error {{invalid output size for constraint '=x'}}
71 #endif
72 }
73