xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/inline-asm-validate-x86.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s
3*0a6a1f1dSLionel Sambuc 
I(int i,int j)4*0a6a1f1dSLionel Sambuc void I(int i, int j) {
5*0a6a1f1dSLionel Sambuc   static const int BelowMin = -1;
6*0a6a1f1dSLionel Sambuc   static const int AboveMax = 32;
7*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
8*0a6a1f1dSLionel Sambuc           : "=r"(i)
9*0a6a1f1dSLionel Sambuc           : "0"(i), "I"(j)); // expected-error{{constraint 'I' expects an integer constant expression}}
10*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
11*0a6a1f1dSLionel Sambuc           : "=r"(i)
12*0a6a1f1dSLionel Sambuc           : "0"(i), "I"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'I'}}
13*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
14*0a6a1f1dSLionel Sambuc           : "=r"(i)
15*0a6a1f1dSLionel Sambuc           : "0"(i), "I"(AboveMax)); // expected-error{{value '32' out of range for constraint 'I'}}
16*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
17*0a6a1f1dSLionel Sambuc           : "=r"(i)
18*0a6a1f1dSLionel Sambuc           : "0"(i), "I"(16)); // expected-no-error
19*0a6a1f1dSLionel Sambuc }
20*0a6a1f1dSLionel Sambuc 
J(int i,int j)21*0a6a1f1dSLionel Sambuc void J(int i, int j) {
22*0a6a1f1dSLionel Sambuc   static const int BelowMin = -1;
23*0a6a1f1dSLionel Sambuc   static const int AboveMax = 64;
24*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
25*0a6a1f1dSLionel Sambuc           : "=r"(i)
26*0a6a1f1dSLionel Sambuc           : "0"(i), "J"(j)); // expected-error{{constraint 'J' expects an integer constant expression}}
27*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
28*0a6a1f1dSLionel Sambuc           : "=r"(i)
29*0a6a1f1dSLionel Sambuc           : "0"(i), "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}
30*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
31*0a6a1f1dSLionel Sambuc           : "=r"(i)
32*0a6a1f1dSLionel Sambuc           : "0"(i), "J"(AboveMax)); // expected-error{{value '64' out of range for constraint 'J'}}
33*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
34*0a6a1f1dSLionel Sambuc           : "=r"(i)
35*0a6a1f1dSLionel Sambuc           : "0"(i), "J"(32)); // expected-no-error
36*0a6a1f1dSLionel Sambuc }
37*0a6a1f1dSLionel Sambuc 
K(int i,int j)38*0a6a1f1dSLionel Sambuc void K(int i, int j) {
39*0a6a1f1dSLionel Sambuc   static const int BelowMin = -129;
40*0a6a1f1dSLionel Sambuc   static const int AboveMax = 128;
41*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
42*0a6a1f1dSLionel Sambuc           : "=r"(i)
43*0a6a1f1dSLionel Sambuc           : "0"(i), "K"(j)); // expected-error{{constraint 'K' expects an integer constant expression}}
44*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
45*0a6a1f1dSLionel Sambuc           : "=r"(i)
46*0a6a1f1dSLionel Sambuc           : "0"(i), "K"(BelowMin)); // expected-error{{value '-129' out of range for constraint 'K'}}
47*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
48*0a6a1f1dSLionel Sambuc           : "=r"(i)
49*0a6a1f1dSLionel Sambuc           : "0"(i), "K"(AboveMax)); // expected-error{{value '128' out of range for constraint 'K'}}
50*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
51*0a6a1f1dSLionel Sambuc           : "=r"(i)
52*0a6a1f1dSLionel Sambuc           : "0"(i), "K"(96)); // expected-no-error
53*0a6a1f1dSLionel Sambuc }
54*0a6a1f1dSLionel Sambuc 
M(int i,int j)55*0a6a1f1dSLionel Sambuc void M(int i, int j) {
56*0a6a1f1dSLionel Sambuc   static const int BelowMin = -1;
57*0a6a1f1dSLionel Sambuc   static const int AboveMax = 4;
58*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
59*0a6a1f1dSLionel Sambuc           : "=r"(i)
60*0a6a1f1dSLionel Sambuc           : "0"(i), "M"(j)); // expected-error{{constraint 'M' expects an integer constant expression}}
61*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
62*0a6a1f1dSLionel Sambuc           : "=r"(i)
63*0a6a1f1dSLionel Sambuc           : "0"(i), "M"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'M'}}
64*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
65*0a6a1f1dSLionel Sambuc           : "=r"(i)
66*0a6a1f1dSLionel Sambuc           : "0"(i), "M"(AboveMax)); // expected-error{{value '4' out of range for constraint 'M'}}
67*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
68*0a6a1f1dSLionel Sambuc           : "=r"(i)
69*0a6a1f1dSLionel Sambuc           : "0"(i), "M"(2)); // expected-no-error
70*0a6a1f1dSLionel Sambuc }
71*0a6a1f1dSLionel Sambuc 
N(int i,int j)72*0a6a1f1dSLionel Sambuc void N(int i, int j) {
73*0a6a1f1dSLionel Sambuc   static const int BelowMin = -1;
74*0a6a1f1dSLionel Sambuc   static const int AboveMax = 256;
75*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
76*0a6a1f1dSLionel Sambuc           : "=r"(i)
77*0a6a1f1dSLionel Sambuc           : "0"(i), "N"(j)); // expected-error{{constraint 'N' expects an integer constant expression}}
78*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
79*0a6a1f1dSLionel Sambuc           : "=r"(i)
80*0a6a1f1dSLionel Sambuc           : "0"(i), "N"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'N'}}
81*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
82*0a6a1f1dSLionel Sambuc           : "=r"(i)
83*0a6a1f1dSLionel Sambuc           : "0"(i), "N"(AboveMax)); // expected-error{{value '256' out of range for constraint 'N'}}
84*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
85*0a6a1f1dSLionel Sambuc           : "=r"(i)
86*0a6a1f1dSLionel Sambuc           : "0"(i), "N"(128)); // expected-no-error
87*0a6a1f1dSLionel Sambuc }
88*0a6a1f1dSLionel Sambuc 
O(int i,int j)89*0a6a1f1dSLionel Sambuc void O(int i, int j) {
90*0a6a1f1dSLionel Sambuc   static const int BelowMin = -1;
91*0a6a1f1dSLionel Sambuc   static const int AboveMax = 128;
92*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
93*0a6a1f1dSLionel Sambuc           : "=r"(i)
94*0a6a1f1dSLionel Sambuc           : "0"(i), "O"(j)); // expected-error{{constraint 'O' expects an integer constant expression}}
95*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
96*0a6a1f1dSLionel Sambuc           : "=r"(i)
97*0a6a1f1dSLionel Sambuc           : "0"(i), "O"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'O'}}
98*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
99*0a6a1f1dSLionel Sambuc           : "=r"(i)
100*0a6a1f1dSLionel Sambuc           : "0"(i), "O"(AboveMax)); // expected-error{{value '128' out of range for constraint 'O'}}
101*0a6a1f1dSLionel Sambuc   __asm__("xorl %0,%2"
102*0a6a1f1dSLionel Sambuc           : "=r"(i)
103*0a6a1f1dSLionel Sambuc           : "0"(i), "O"(64)); // expected-no-error
104*0a6a1f1dSLionel Sambuc }
105*0a6a1f1dSLionel Sambuc 
106