[AArch64] Add v8.1a atomic instructions
[oota-llvm.git] / test / MC / AArch64 / armv8.1a-atomic.s
1 // RUN: not llvm-mc -triple aarch64-none-linux-gnu -mattr=+v8.1a -show-encoding < %s 2> %t | FileCheck %s
2 // RUN: FileCheck --check-prefix=CHECK-ERROR <%t %s
3   .text
4
5   //8 bits
6   casb   w0, w1, [x2]
7   casab  w0, w1, [x2]
8   caslb  w0, w1, [x2]
9   casalb   w0, w1, [x2]
10
11 //CHECK:  casb   w0, w1, [x2]        //      encoding: [0x41,0x7c,0xa0,0x08]
12 //CHECK:  casab  w0, w1, [x2]        //      encoding: [0x41,0x7c,0xe0,0x08]
13 //CHECK:  caslb   w0, w1, [x2]       //      encoding: [0x41,0xfc,0xa0,0x08]
14 //CHECK:  casalb   w0, w1, [x2]      //      encoding: [0x41,0xfc,0xe0,0x08]
15
16   casb w0, w1, [w2]
17   casalb x0, x1, [x2]
18 //CHECK-ERROR: error: invalid operand for instruction
19 //CHECK-ERROR:   casb w0, w1, [w2]
20 //CHECK-ERROR:                 ^
21 //CHECK-ERROR: error: invalid operand for instruction
22 //CHECK-ERROR:   casalb x0, x1, [x2]
23 //CHECK-ERROR:          ^
24
25   //16 bits
26   cash   w0, w1, [x2]
27   casah  w0, w1, [x2]
28   caslh  w0, w1, [x2]
29   casalh   w0, w1, [x2]
30
31 //CHECK:  cash   w0, w1, [x2]        //      encoding: [0x41,0x7c,0xa0,0x48]
32 //CHECK:  casah  w0, w1, [x2]        //      encoding: [0x41,0x7c,0xe0,0x48]
33 //CHECK:  caslh   w0, w1, [x2]       //      encoding: [0x41,0xfc,0xa0,0x48]
34 //CHECK:  casalh   w0, w1, [x2]      //      encoding: [0x41,0xfc,0xe0,0x48]
35
36   //32 bits
37   cas   w0, w1, [x2]
38   casa  w0, w1, [x2]
39   casl  w0, w1, [x2]
40   casal   w0, w1, [x2]
41
42 //CHECK:  cas   w0, w1, [x2]        //      encoding: [0x41,0x7c,0xa0,0x88]
43 //CHECK:  casa  w0, w1, [x2]        //      encoding: [0x41,0x7c,0xe0,0x88]
44 //CHECK:  casl   w0, w1, [x2]       //      encoding: [0x41,0xfc,0xa0,0x88]
45 //CHECK:  casal   w0, w1, [x2]      //      encoding: [0x41,0xfc,0xe0,0x88]
46
47   cas   w0, w1, [w2]
48   casl  w0, x1, [x2]
49
50 //CHECK-ERROR: error: invalid operand for instruction
51 //CHECK-ERROR:   cas   w0, w1, [w2]
52 //CHECK-ERROR:                  ^
53 //CHECK-ERROR: error: invalid operand for instruction
54 //CHECK-ERROR:   casl  w0, x1, [x2]
55 //CHECK-ERROR:             ^
56
57   //64 bits
58   cas   x0, x1, [x2]
59   casa  x0, x1, [x2]
60   casl   x0, x1, [x2]
61   casal   x0, x1, [x2]
62
63 //CHECK:  cas   x0, x1, [x2]        //      encoding: [0x41,0x7c,0xa0,0xc8]
64 //CHECK:  casa  x0, x1, [x2]        //      encoding: [0x41,0x7c,0xe0,0xc8]
65 //CHECK:  casl   x0, x1, [x2]       //      encoding: [0x41,0xfc,0xa0,0xc8]
66 //CHECK:  casal   x0, x1, [x2]      //      encoding: [0x41,0xfc,0xe0,0xc8]
67
68   casa   x0, x1, [w2]
69   casal  x0, w1, [x2]
70
71 //CHECK-ERROR: error: invalid operand for instruction
72 //CHECK-ERROR:   casa   x0, x1, [w2]
73 //CHECK-ERROR:                   ^
74 //CHECK-ERROR: error: invalid operand for instruction
75 //CHECK-ERROR:   casal  x0, w1, [x2]
76 //CHECK-ERROR:              ^
77
78   // LD<OP> intructions
79   ldadda x0, x1, [x2]
80   ldclrl x0, x1, [x2]
81   ldeoral x0, x1, [x2]
82   ldset x0, x1, [x2]
83   ldsmaxa w0, w1, [x2]
84   ldsminlb w0, w1, [x2]
85   ldumaxalh w0, w1, [x2]
86   ldumin w0, w1, [x2]
87 //CHECK: ldadda     x0, x1, [x2]  // encoding: [0x41,0x00,0xa0,0xf8]
88 //CHECK: ldclrl     x0, x1, [x2]  // encoding: [0x41,0x10,0x60,0xf8]
89 //CHECK: ldeoral    x0, x1, [x2]  // encoding: [0x41,0x20,0xe0,0xf8]
90 //CHECK: ldset      x0, x1, [x2]  // encoding: [0x41,0x30,0x20,0xf8]
91 //CHECK: ldsmaxa    w0, w1, [x2]  // encoding: [0x41,0x40,0xa0,0xb8]
92 //CHECK: ldsminlb   w0, w1, [x2]  // encoding: [0x41,0x50,0x60,0x38]
93 //CHECK: ldumaxalh  w0, w1, [x2]  // encoding: [0x41,0x60,0xe0,0x78]
94 //CHECK: ldumin     w0, w1, [x2]  // encoding: [0x41,0x70,0x20,0xb8]
95
96   // ST<OP> intructions: aliases to LD<OP>
97   stADDlb w0, [x2]
98   stclrlh w0, [x2]
99   steorl  w0, [x2]
100   stsetl  x0, [x2]
101   stsmaxb  w0, [x2]
102   stsminh  w0, [x2]
103   stumax   w0, [x2]
104   stumin   x0, [x2]
105 //CHECK: staddlb    w0, [x2]  // encoding: [0x5f,0x00,0x60,0x38]
106 //CHECK: stclrlh    w0, [x2]  // encoding: [0x5f,0x10,0x60,0x78]
107 //CHECK: steorl     w0, [x2]  // encoding: [0x5f,0x20,0x60,0xb8]
108 //CHECK: stsetl     x0, [x2]  // encoding: [0x5f,0x30,0x60,0xf8]
109 //CHECK: stsmaxb     w0, [x2]  // encoding: [0x5f,0x40,0x20,0x38]
110 //CHECK: stsminh     w0, [x2]  // encoding: [0x5f,0x50,0x20,0x78]
111 //CHECK: stumax      w0, [x2]  // encoding: [0x5f,0x60,0x20,0xb8]
112 //CHECK: stumin      x0, [x2]  // encoding: [0x5f,0x70,0x20,0xf8]
113
114   ldsmax x0, x1, [w2]
115   ldeorl w0, w1, [w2]
116 //CHECK-ERROR: error: invalid operand for instruction
117 //CHECK-ERROR:   ldsmax x0, x1, [w2]
118 //CHECK-ERROR:                   ^
119 //CHECK-ERROR: error: invalid operand for instruction
120 //CHECK-ERROR:   ldeorl w0, w1, [w2]
121 //CHECK-ERROR:                   ^
122
123   //SWP instruction
124   swp   x0, x1, [x2]
125   swpb  w0, w1, [x2]
126   swplh w0, w1, [x2]
127   swpal x0, x1, [sp]
128 //CHECK: swp   x0, x1, [x2]       // encoding: [0x41,0x80,0x20,0xf8]
129 //CHECK: swpb  w0, w1, [x2]       // encoding: [0x41,0x80,0x20,0x38]
130 //CHECK: swplh w0, w1, [x2]       // encoding: [0x41,0x80,0x60,0x78]
131 //CHECK: swpal x0, x1, [sp]       // encoding: [0xe1,0x83,0xe0,0xf8]
132
133   swp   x0, x1, [w2]
134   swp   x0, x1, [xzr]
135 //CHECK-ERROR: error: invalid operand for instruction
136 //CHECK-ERROR:   swp   x0, x1, [w2]
137 //CHECK-ERROR:                  ^
138 //CHECK-ERROR: error: invalid operand for instruction
139 //CHECK-ERROR:   swp   x0, x1, [xzr]
140 //CHECK-ERROR:                  ^
141
142   //CASP instruction
143   casp x0, x1, x2, x3, [x4]
144   casp w0, w1, w2, w3, [x4]
145 //CHECK: casp x0, x1, x2, x3, [x4]      // encoding: [0x82,0x7c,0x20,0x48]
146 //CHECK: casp w0, w1, w2, w3, [x4]      // encoding: [0x82,0x7c,0x20,0x08]
147
148   casp x1, x2, x4, x5, [x6]
149   casp x0, x1, x3, x4, [x5]
150   casp x0, x2, x4, x5, [x6]
151   casp x0, x1, x2, x4, [x5]
152   casp x0, w1, x2, x3, [x5]
153   casp w0, x1, x2, x3, [x5]
154   casp w0, x1, w2, w3, [x5]
155   casp x0, x1, w2, w3, [x5]
156 //CHECK-ERROR: error: expected first even register of a consecutive same-size even/odd register pair
157 //CHECK-ERROR:  casp x1, x2, x4, x5, [x6]
158 //CHECK-ERROR:       ^
159 //CHECK-ERROR: error: expected first even register of a consecutive same-size even/odd register pair
160 //CHECK-ERROR:  casp x0, x1, x3, x4, [x5]
161 //CHECK-ERROR:               ^
162 //CHECK-ERROR: error:  expected second odd register of a consecutive same-size even/odd register pair
163 //CHECK-ERROR:  casp x0, x2, x4, x5, [x6]
164 //CHECK-ERROR:           ^
165 //CHECK-ERROR: error: expected second odd register of a consecutive same-size even/odd register pair
166 //CHECK-ERROR:  casp x0, x1, x2, x4, [x5]
167 //CHECK-ERROR:                   ^
168 //CHECK-ERROR: error: expected second odd register of a consecutive same-size even/odd register pair
169 //CHECK-ERROR:  casp x0, w1, x2, x3, [x5]
170 //CHECK-ERROR:           ^
171 //CHECK-ERROR: error: expected second odd register of a consecutive same-size even/odd register pair
172 //CHECK-ERROR:  casp w0, x1, x2, x3, [x5]
173 //CHECK-ERROR:           ^
174 //CHECK-ERROR: error: expected second odd register of a consecutive same-size even/odd register pair
175 //CHECK-ERROR:  casp w0, x1, w2, w3, [x5]
176 //CHECK-ERROR:           ^
177 //CHECK-ERROR: error: invalid operand for instruction
178 //CHECK-ERROR:  casp x0, x1, w2, w3, [x5]
179 //CHECK-ERROR:               ^