• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016, VIXL authors
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 //   * Redistributions of source code must retain the above copyright notice,
8 //     this list of conditions and the following disclaimer.
9 //   * Redistributions in binary form must reproduce the above copyright notice,
10 //     this list of conditions and the following disclaimer in the documentation
11 //     and/or other materials provided with the distribution.
12 //   * Neither the name of ARM Limited nor the names of its contributors may be
13 //     used to endorse or promote products derived from this software without
14 //     specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 
28 // -----------------------------------------------------------------------------
29 // This file is auto generated from the
30 // test/aarch32/config/template-macro-assembler-aarch32.cc.in template file
31 // using tools/generate_tests.py.
32 //
33 // PLEASE DO NOT EDIT.
34 // -----------------------------------------------------------------------------
35 
36 
37 #include <iostream>
38 #include <map>
39 
40 #include "test-runner.h"
41 
42 #include "test-utils.h"
43 #include "test-utils-aarch32.h"
44 
45 #include "aarch32/assembler-aarch32.h"
46 #include "aarch32/disasm-aarch32.h"
47 #include "aarch32/macro-assembler-aarch32.h"
48 
49 #define BUF_SIZE (4096)
50 
51 namespace vixl {
52 namespace aarch32 {
53 
54 // List of instruction mnemonics.
55 #define FOREACH_INSTRUCTION(M) M(Rrx)
56 
57 
58 // The following definitions are defined again in each generated test, therefore
59 // we need to place them in an anomymous namespace. It expresses that they are
60 // local to this file only, and the compiler is not allowed to share these types
61 // across test files during template instantiation. Specifically, `Operands` has
62 // various layouts across generated tests so it absolutely cannot be shared.
63 
64 #ifdef VIXL_INCLUDE_TARGET_A32
65 namespace {
66 
67 // Values to be passed to the assembler to produce the instruction under test.
68 struct Operands {
69   Condition cond;
70   Register rd;
71   Register rn;
72 };
73 
74 // This structure contains all data needed to test one specific
75 // instruction.
76 struct TestData {
77   // The `operands` field represents what to pass to the assembler to
78   // produce the instruction.
79   Operands operands;
80   // Description of the operands, used for error reporting.
81   const char* operands_description;
82   // Unique identifier, used for generating traces.
83   const char* identifier;
84 };
85 
86 // Each element of this array produce one instruction encoding.
87 const TestData kTests[] = {{{eq, r0, r15}, "eq, r0, r15", "eq_r0_r15"},
88                            {{eq, r1, r15}, "eq, r1, r15", "eq_r1_r15"},
89                            {{eq, r2, r15}, "eq, r2, r15", "eq_r2_r15"},
90                            {{eq, r3, r15}, "eq, r3, r15", "eq_r3_r15"},
91                            {{eq, r4, r15}, "eq, r4, r15", "eq_r4_r15"},
92                            {{eq, r5, r15}, "eq, r5, r15", "eq_r5_r15"},
93                            {{eq, r6, r15}, "eq, r6, r15", "eq_r6_r15"},
94                            {{eq, r7, r15}, "eq, r7, r15", "eq_r7_r15"},
95                            {{eq, r8, r15}, "eq, r8, r15", "eq_r8_r15"},
96                            {{eq, r9, r15}, "eq, r9, r15", "eq_r9_r15"},
97                            {{eq, r10, r15}, "eq, r10, r15", "eq_r10_r15"},
98                            {{eq, r11, r15}, "eq, r11, r15", "eq_r11_r15"},
99                            {{eq, r12, r15}, "eq, r12, r15", "eq_r12_r15"},
100                            {{eq, r13, r15}, "eq, r13, r15", "eq_r13_r15"},
101                            {{eq, r14, r15}, "eq, r14, r15", "eq_r14_r15"},
102                            {{eq, r15, r0}, "eq, r15, r0", "eq_r15_r0"},
103                            {{eq, r15, r1}, "eq, r15, r1", "eq_r15_r1"},
104                            {{eq, r15, r2}, "eq, r15, r2", "eq_r15_r2"},
105                            {{eq, r15, r3}, "eq, r15, r3", "eq_r15_r3"},
106                            {{eq, r15, r4}, "eq, r15, r4", "eq_r15_r4"},
107                            {{eq, r15, r5}, "eq, r15, r5", "eq_r15_r5"},
108                            {{eq, r15, r6}, "eq, r15, r6", "eq_r15_r6"},
109                            {{eq, r15, r7}, "eq, r15, r7", "eq_r15_r7"},
110                            {{eq, r15, r8}, "eq, r15, r8", "eq_r15_r8"},
111                            {{eq, r15, r9}, "eq, r15, r9", "eq_r15_r9"},
112                            {{eq, r15, r10}, "eq, r15, r10", "eq_r15_r10"},
113                            {{eq, r15, r11}, "eq, r15, r11", "eq_r15_r11"},
114                            {{eq, r15, r12}, "eq, r15, r12", "eq_r15_r12"},
115                            {{eq, r15, r13}, "eq, r15, r13", "eq_r15_r13"},
116                            {{eq, r15, r14}, "eq, r15, r14", "eq_r15_r14"},
117                            {{eq, r15, r15}, "eq, r15, r15", "eq_r15_r15"},
118                            {{ne, r0, r15}, "ne, r0, r15", "ne_r0_r15"},
119                            {{ne, r1, r15}, "ne, r1, r15", "ne_r1_r15"},
120                            {{ne, r2, r15}, "ne, r2, r15", "ne_r2_r15"},
121                            {{ne, r3, r15}, "ne, r3, r15", "ne_r3_r15"},
122                            {{ne, r4, r15}, "ne, r4, r15", "ne_r4_r15"},
123                            {{ne, r5, r15}, "ne, r5, r15", "ne_r5_r15"},
124                            {{ne, r6, r15}, "ne, r6, r15", "ne_r6_r15"},
125                            {{ne, r7, r15}, "ne, r7, r15", "ne_r7_r15"},
126                            {{ne, r8, r15}, "ne, r8, r15", "ne_r8_r15"},
127                            {{ne, r9, r15}, "ne, r9, r15", "ne_r9_r15"},
128                            {{ne, r10, r15}, "ne, r10, r15", "ne_r10_r15"},
129                            {{ne, r11, r15}, "ne, r11, r15", "ne_r11_r15"},
130                            {{ne, r12, r15}, "ne, r12, r15", "ne_r12_r15"},
131                            {{ne, r13, r15}, "ne, r13, r15", "ne_r13_r15"},
132                            {{ne, r14, r15}, "ne, r14, r15", "ne_r14_r15"},
133                            {{ne, r15, r0}, "ne, r15, r0", "ne_r15_r0"},
134                            {{ne, r15, r1}, "ne, r15, r1", "ne_r15_r1"},
135                            {{ne, r15, r2}, "ne, r15, r2", "ne_r15_r2"},
136                            {{ne, r15, r3}, "ne, r15, r3", "ne_r15_r3"},
137                            {{ne, r15, r4}, "ne, r15, r4", "ne_r15_r4"},
138                            {{ne, r15, r5}, "ne, r15, r5", "ne_r15_r5"},
139                            {{ne, r15, r6}, "ne, r15, r6", "ne_r15_r6"},
140                            {{ne, r15, r7}, "ne, r15, r7", "ne_r15_r7"},
141                            {{ne, r15, r8}, "ne, r15, r8", "ne_r15_r8"},
142                            {{ne, r15, r9}, "ne, r15, r9", "ne_r15_r9"},
143                            {{ne, r15, r10}, "ne, r15, r10", "ne_r15_r10"},
144                            {{ne, r15, r11}, "ne, r15, r11", "ne_r15_r11"},
145                            {{ne, r15, r12}, "ne, r15, r12", "ne_r15_r12"},
146                            {{ne, r15, r13}, "ne, r15, r13", "ne_r15_r13"},
147                            {{ne, r15, r14}, "ne, r15, r14", "ne_r15_r14"},
148                            {{ne, r15, r15}, "ne, r15, r15", "ne_r15_r15"},
149                            {{cs, r0, r15}, "cs, r0, r15", "cs_r0_r15"},
150                            {{cs, r1, r15}, "cs, r1, r15", "cs_r1_r15"},
151                            {{cs, r2, r15}, "cs, r2, r15", "cs_r2_r15"},
152                            {{cs, r3, r15}, "cs, r3, r15", "cs_r3_r15"},
153                            {{cs, r4, r15}, "cs, r4, r15", "cs_r4_r15"},
154                            {{cs, r5, r15}, "cs, r5, r15", "cs_r5_r15"},
155                            {{cs, r6, r15}, "cs, r6, r15", "cs_r6_r15"},
156                            {{cs, r7, r15}, "cs, r7, r15", "cs_r7_r15"},
157                            {{cs, r8, r15}, "cs, r8, r15", "cs_r8_r15"},
158                            {{cs, r9, r15}, "cs, r9, r15", "cs_r9_r15"},
159                            {{cs, r10, r15}, "cs, r10, r15", "cs_r10_r15"},
160                            {{cs, r11, r15}, "cs, r11, r15", "cs_r11_r15"},
161                            {{cs, r12, r15}, "cs, r12, r15", "cs_r12_r15"},
162                            {{cs, r13, r15}, "cs, r13, r15", "cs_r13_r15"},
163                            {{cs, r14, r15}, "cs, r14, r15", "cs_r14_r15"},
164                            {{cs, r15, r0}, "cs, r15, r0", "cs_r15_r0"},
165                            {{cs, r15, r1}, "cs, r15, r1", "cs_r15_r1"},
166                            {{cs, r15, r2}, "cs, r15, r2", "cs_r15_r2"},
167                            {{cs, r15, r3}, "cs, r15, r3", "cs_r15_r3"},
168                            {{cs, r15, r4}, "cs, r15, r4", "cs_r15_r4"},
169                            {{cs, r15, r5}, "cs, r15, r5", "cs_r15_r5"},
170                            {{cs, r15, r6}, "cs, r15, r6", "cs_r15_r6"},
171                            {{cs, r15, r7}, "cs, r15, r7", "cs_r15_r7"},
172                            {{cs, r15, r8}, "cs, r15, r8", "cs_r15_r8"},
173                            {{cs, r15, r9}, "cs, r15, r9", "cs_r15_r9"},
174                            {{cs, r15, r10}, "cs, r15, r10", "cs_r15_r10"},
175                            {{cs, r15, r11}, "cs, r15, r11", "cs_r15_r11"},
176                            {{cs, r15, r12}, "cs, r15, r12", "cs_r15_r12"},
177                            {{cs, r15, r13}, "cs, r15, r13", "cs_r15_r13"},
178                            {{cs, r15, r14}, "cs, r15, r14", "cs_r15_r14"},
179                            {{cs, r15, r15}, "cs, r15, r15", "cs_r15_r15"},
180                            {{cc, r0, r15}, "cc, r0, r15", "cc_r0_r15"},
181                            {{cc, r1, r15}, "cc, r1, r15", "cc_r1_r15"},
182                            {{cc, r2, r15}, "cc, r2, r15", "cc_r2_r15"},
183                            {{cc, r3, r15}, "cc, r3, r15", "cc_r3_r15"},
184                            {{cc, r4, r15}, "cc, r4, r15", "cc_r4_r15"},
185                            {{cc, r5, r15}, "cc, r5, r15", "cc_r5_r15"},
186                            {{cc, r6, r15}, "cc, r6, r15", "cc_r6_r15"},
187                            {{cc, r7, r15}, "cc, r7, r15", "cc_r7_r15"},
188                            {{cc, r8, r15}, "cc, r8, r15", "cc_r8_r15"},
189                            {{cc, r9, r15}, "cc, r9, r15", "cc_r9_r15"},
190                            {{cc, r10, r15}, "cc, r10, r15", "cc_r10_r15"},
191                            {{cc, r11, r15}, "cc, r11, r15", "cc_r11_r15"},
192                            {{cc, r12, r15}, "cc, r12, r15", "cc_r12_r15"},
193                            {{cc, r13, r15}, "cc, r13, r15", "cc_r13_r15"},
194                            {{cc, r14, r15}, "cc, r14, r15", "cc_r14_r15"},
195                            {{cc, r15, r0}, "cc, r15, r0", "cc_r15_r0"},
196                            {{cc, r15, r1}, "cc, r15, r1", "cc_r15_r1"},
197                            {{cc, r15, r2}, "cc, r15, r2", "cc_r15_r2"},
198                            {{cc, r15, r3}, "cc, r15, r3", "cc_r15_r3"},
199                            {{cc, r15, r4}, "cc, r15, r4", "cc_r15_r4"},
200                            {{cc, r15, r5}, "cc, r15, r5", "cc_r15_r5"},
201                            {{cc, r15, r6}, "cc, r15, r6", "cc_r15_r6"},
202                            {{cc, r15, r7}, "cc, r15, r7", "cc_r15_r7"},
203                            {{cc, r15, r8}, "cc, r15, r8", "cc_r15_r8"},
204                            {{cc, r15, r9}, "cc, r15, r9", "cc_r15_r9"},
205                            {{cc, r15, r10}, "cc, r15, r10", "cc_r15_r10"},
206                            {{cc, r15, r11}, "cc, r15, r11", "cc_r15_r11"},
207                            {{cc, r15, r12}, "cc, r15, r12", "cc_r15_r12"},
208                            {{cc, r15, r13}, "cc, r15, r13", "cc_r15_r13"},
209                            {{cc, r15, r14}, "cc, r15, r14", "cc_r15_r14"},
210                            {{cc, r15, r15}, "cc, r15, r15", "cc_r15_r15"},
211                            {{mi, r0, r15}, "mi, r0, r15", "mi_r0_r15"},
212                            {{mi, r1, r15}, "mi, r1, r15", "mi_r1_r15"},
213                            {{mi, r2, r15}, "mi, r2, r15", "mi_r2_r15"},
214                            {{mi, r3, r15}, "mi, r3, r15", "mi_r3_r15"},
215                            {{mi, r4, r15}, "mi, r4, r15", "mi_r4_r15"},
216                            {{mi, r5, r15}, "mi, r5, r15", "mi_r5_r15"},
217                            {{mi, r6, r15}, "mi, r6, r15", "mi_r6_r15"},
218                            {{mi, r7, r15}, "mi, r7, r15", "mi_r7_r15"},
219                            {{mi, r8, r15}, "mi, r8, r15", "mi_r8_r15"},
220                            {{mi, r9, r15}, "mi, r9, r15", "mi_r9_r15"},
221                            {{mi, r10, r15}, "mi, r10, r15", "mi_r10_r15"},
222                            {{mi, r11, r15}, "mi, r11, r15", "mi_r11_r15"},
223                            {{mi, r12, r15}, "mi, r12, r15", "mi_r12_r15"},
224                            {{mi, r13, r15}, "mi, r13, r15", "mi_r13_r15"},
225                            {{mi, r14, r15}, "mi, r14, r15", "mi_r14_r15"},
226                            {{mi, r15, r0}, "mi, r15, r0", "mi_r15_r0"},
227                            {{mi, r15, r1}, "mi, r15, r1", "mi_r15_r1"},
228                            {{mi, r15, r2}, "mi, r15, r2", "mi_r15_r2"},
229                            {{mi, r15, r3}, "mi, r15, r3", "mi_r15_r3"},
230                            {{mi, r15, r4}, "mi, r15, r4", "mi_r15_r4"},
231                            {{mi, r15, r5}, "mi, r15, r5", "mi_r15_r5"},
232                            {{mi, r15, r6}, "mi, r15, r6", "mi_r15_r6"},
233                            {{mi, r15, r7}, "mi, r15, r7", "mi_r15_r7"},
234                            {{mi, r15, r8}, "mi, r15, r8", "mi_r15_r8"},
235                            {{mi, r15, r9}, "mi, r15, r9", "mi_r15_r9"},
236                            {{mi, r15, r10}, "mi, r15, r10", "mi_r15_r10"},
237                            {{mi, r15, r11}, "mi, r15, r11", "mi_r15_r11"},
238                            {{mi, r15, r12}, "mi, r15, r12", "mi_r15_r12"},
239                            {{mi, r15, r13}, "mi, r15, r13", "mi_r15_r13"},
240                            {{mi, r15, r14}, "mi, r15, r14", "mi_r15_r14"},
241                            {{mi, r15, r15}, "mi, r15, r15", "mi_r15_r15"},
242                            {{pl, r0, r15}, "pl, r0, r15", "pl_r0_r15"},
243                            {{pl, r1, r15}, "pl, r1, r15", "pl_r1_r15"},
244                            {{pl, r2, r15}, "pl, r2, r15", "pl_r2_r15"},
245                            {{pl, r3, r15}, "pl, r3, r15", "pl_r3_r15"},
246                            {{pl, r4, r15}, "pl, r4, r15", "pl_r4_r15"},
247                            {{pl, r5, r15}, "pl, r5, r15", "pl_r5_r15"},
248                            {{pl, r6, r15}, "pl, r6, r15", "pl_r6_r15"},
249                            {{pl, r7, r15}, "pl, r7, r15", "pl_r7_r15"},
250                            {{pl, r8, r15}, "pl, r8, r15", "pl_r8_r15"},
251                            {{pl, r9, r15}, "pl, r9, r15", "pl_r9_r15"},
252                            {{pl, r10, r15}, "pl, r10, r15", "pl_r10_r15"},
253                            {{pl, r11, r15}, "pl, r11, r15", "pl_r11_r15"},
254                            {{pl, r12, r15}, "pl, r12, r15", "pl_r12_r15"},
255                            {{pl, r13, r15}, "pl, r13, r15", "pl_r13_r15"},
256                            {{pl, r14, r15}, "pl, r14, r15", "pl_r14_r15"},
257                            {{pl, r15, r0}, "pl, r15, r0", "pl_r15_r0"},
258                            {{pl, r15, r1}, "pl, r15, r1", "pl_r15_r1"},
259                            {{pl, r15, r2}, "pl, r15, r2", "pl_r15_r2"},
260                            {{pl, r15, r3}, "pl, r15, r3", "pl_r15_r3"},
261                            {{pl, r15, r4}, "pl, r15, r4", "pl_r15_r4"},
262                            {{pl, r15, r5}, "pl, r15, r5", "pl_r15_r5"},
263                            {{pl, r15, r6}, "pl, r15, r6", "pl_r15_r6"},
264                            {{pl, r15, r7}, "pl, r15, r7", "pl_r15_r7"},
265                            {{pl, r15, r8}, "pl, r15, r8", "pl_r15_r8"},
266                            {{pl, r15, r9}, "pl, r15, r9", "pl_r15_r9"},
267                            {{pl, r15, r10}, "pl, r15, r10", "pl_r15_r10"},
268                            {{pl, r15, r11}, "pl, r15, r11", "pl_r15_r11"},
269                            {{pl, r15, r12}, "pl, r15, r12", "pl_r15_r12"},
270                            {{pl, r15, r13}, "pl, r15, r13", "pl_r15_r13"},
271                            {{pl, r15, r14}, "pl, r15, r14", "pl_r15_r14"},
272                            {{pl, r15, r15}, "pl, r15, r15", "pl_r15_r15"},
273                            {{vs, r0, r15}, "vs, r0, r15", "vs_r0_r15"},
274                            {{vs, r1, r15}, "vs, r1, r15", "vs_r1_r15"},
275                            {{vs, r2, r15}, "vs, r2, r15", "vs_r2_r15"},
276                            {{vs, r3, r15}, "vs, r3, r15", "vs_r3_r15"},
277                            {{vs, r4, r15}, "vs, r4, r15", "vs_r4_r15"},
278                            {{vs, r5, r15}, "vs, r5, r15", "vs_r5_r15"},
279                            {{vs, r6, r15}, "vs, r6, r15", "vs_r6_r15"},
280                            {{vs, r7, r15}, "vs, r7, r15", "vs_r7_r15"},
281                            {{vs, r8, r15}, "vs, r8, r15", "vs_r8_r15"},
282                            {{vs, r9, r15}, "vs, r9, r15", "vs_r9_r15"},
283                            {{vs, r10, r15}, "vs, r10, r15", "vs_r10_r15"},
284                            {{vs, r11, r15}, "vs, r11, r15", "vs_r11_r15"},
285                            {{vs, r12, r15}, "vs, r12, r15", "vs_r12_r15"},
286                            {{vs, r13, r15}, "vs, r13, r15", "vs_r13_r15"},
287                            {{vs, r14, r15}, "vs, r14, r15", "vs_r14_r15"},
288                            {{vs, r15, r0}, "vs, r15, r0", "vs_r15_r0"},
289                            {{vs, r15, r1}, "vs, r15, r1", "vs_r15_r1"},
290                            {{vs, r15, r2}, "vs, r15, r2", "vs_r15_r2"},
291                            {{vs, r15, r3}, "vs, r15, r3", "vs_r15_r3"},
292                            {{vs, r15, r4}, "vs, r15, r4", "vs_r15_r4"},
293                            {{vs, r15, r5}, "vs, r15, r5", "vs_r15_r5"},
294                            {{vs, r15, r6}, "vs, r15, r6", "vs_r15_r6"},
295                            {{vs, r15, r7}, "vs, r15, r7", "vs_r15_r7"},
296                            {{vs, r15, r8}, "vs, r15, r8", "vs_r15_r8"},
297                            {{vs, r15, r9}, "vs, r15, r9", "vs_r15_r9"},
298                            {{vs, r15, r10}, "vs, r15, r10", "vs_r15_r10"},
299                            {{vs, r15, r11}, "vs, r15, r11", "vs_r15_r11"},
300                            {{vs, r15, r12}, "vs, r15, r12", "vs_r15_r12"},
301                            {{vs, r15, r13}, "vs, r15, r13", "vs_r15_r13"},
302                            {{vs, r15, r14}, "vs, r15, r14", "vs_r15_r14"},
303                            {{vs, r15, r15}, "vs, r15, r15", "vs_r15_r15"},
304                            {{vc, r0, r15}, "vc, r0, r15", "vc_r0_r15"},
305                            {{vc, r1, r15}, "vc, r1, r15", "vc_r1_r15"},
306                            {{vc, r2, r15}, "vc, r2, r15", "vc_r2_r15"},
307                            {{vc, r3, r15}, "vc, r3, r15", "vc_r3_r15"},
308                            {{vc, r4, r15}, "vc, r4, r15", "vc_r4_r15"},
309                            {{vc, r5, r15}, "vc, r5, r15", "vc_r5_r15"},
310                            {{vc, r6, r15}, "vc, r6, r15", "vc_r6_r15"},
311                            {{vc, r7, r15}, "vc, r7, r15", "vc_r7_r15"},
312                            {{vc, r8, r15}, "vc, r8, r15", "vc_r8_r15"},
313                            {{vc, r9, r15}, "vc, r9, r15", "vc_r9_r15"},
314                            {{vc, r10, r15}, "vc, r10, r15", "vc_r10_r15"},
315                            {{vc, r11, r15}, "vc, r11, r15", "vc_r11_r15"},
316                            {{vc, r12, r15}, "vc, r12, r15", "vc_r12_r15"},
317                            {{vc, r13, r15}, "vc, r13, r15", "vc_r13_r15"},
318                            {{vc, r14, r15}, "vc, r14, r15", "vc_r14_r15"},
319                            {{vc, r15, r0}, "vc, r15, r0", "vc_r15_r0"},
320                            {{vc, r15, r1}, "vc, r15, r1", "vc_r15_r1"},
321                            {{vc, r15, r2}, "vc, r15, r2", "vc_r15_r2"},
322                            {{vc, r15, r3}, "vc, r15, r3", "vc_r15_r3"},
323                            {{vc, r15, r4}, "vc, r15, r4", "vc_r15_r4"},
324                            {{vc, r15, r5}, "vc, r15, r5", "vc_r15_r5"},
325                            {{vc, r15, r6}, "vc, r15, r6", "vc_r15_r6"},
326                            {{vc, r15, r7}, "vc, r15, r7", "vc_r15_r7"},
327                            {{vc, r15, r8}, "vc, r15, r8", "vc_r15_r8"},
328                            {{vc, r15, r9}, "vc, r15, r9", "vc_r15_r9"},
329                            {{vc, r15, r10}, "vc, r15, r10", "vc_r15_r10"},
330                            {{vc, r15, r11}, "vc, r15, r11", "vc_r15_r11"},
331                            {{vc, r15, r12}, "vc, r15, r12", "vc_r15_r12"},
332                            {{vc, r15, r13}, "vc, r15, r13", "vc_r15_r13"},
333                            {{vc, r15, r14}, "vc, r15, r14", "vc_r15_r14"},
334                            {{vc, r15, r15}, "vc, r15, r15", "vc_r15_r15"},
335                            {{hi, r0, r15}, "hi, r0, r15", "hi_r0_r15"},
336                            {{hi, r1, r15}, "hi, r1, r15", "hi_r1_r15"},
337                            {{hi, r2, r15}, "hi, r2, r15", "hi_r2_r15"},
338                            {{hi, r3, r15}, "hi, r3, r15", "hi_r3_r15"},
339                            {{hi, r4, r15}, "hi, r4, r15", "hi_r4_r15"},
340                            {{hi, r5, r15}, "hi, r5, r15", "hi_r5_r15"},
341                            {{hi, r6, r15}, "hi, r6, r15", "hi_r6_r15"},
342                            {{hi, r7, r15}, "hi, r7, r15", "hi_r7_r15"},
343                            {{hi, r8, r15}, "hi, r8, r15", "hi_r8_r15"},
344                            {{hi, r9, r15}, "hi, r9, r15", "hi_r9_r15"},
345                            {{hi, r10, r15}, "hi, r10, r15", "hi_r10_r15"},
346                            {{hi, r11, r15}, "hi, r11, r15", "hi_r11_r15"},
347                            {{hi, r12, r15}, "hi, r12, r15", "hi_r12_r15"},
348                            {{hi, r13, r15}, "hi, r13, r15", "hi_r13_r15"},
349                            {{hi, r14, r15}, "hi, r14, r15", "hi_r14_r15"},
350                            {{hi, r15, r0}, "hi, r15, r0", "hi_r15_r0"},
351                            {{hi, r15, r1}, "hi, r15, r1", "hi_r15_r1"},
352                            {{hi, r15, r2}, "hi, r15, r2", "hi_r15_r2"},
353                            {{hi, r15, r3}, "hi, r15, r3", "hi_r15_r3"},
354                            {{hi, r15, r4}, "hi, r15, r4", "hi_r15_r4"},
355                            {{hi, r15, r5}, "hi, r15, r5", "hi_r15_r5"},
356                            {{hi, r15, r6}, "hi, r15, r6", "hi_r15_r6"},
357                            {{hi, r15, r7}, "hi, r15, r7", "hi_r15_r7"},
358                            {{hi, r15, r8}, "hi, r15, r8", "hi_r15_r8"},
359                            {{hi, r15, r9}, "hi, r15, r9", "hi_r15_r9"},
360                            {{hi, r15, r10}, "hi, r15, r10", "hi_r15_r10"},
361                            {{hi, r15, r11}, "hi, r15, r11", "hi_r15_r11"},
362                            {{hi, r15, r12}, "hi, r15, r12", "hi_r15_r12"},
363                            {{hi, r15, r13}, "hi, r15, r13", "hi_r15_r13"},
364                            {{hi, r15, r14}, "hi, r15, r14", "hi_r15_r14"},
365                            {{hi, r15, r15}, "hi, r15, r15", "hi_r15_r15"},
366                            {{ls, r0, r15}, "ls, r0, r15", "ls_r0_r15"},
367                            {{ls, r1, r15}, "ls, r1, r15", "ls_r1_r15"},
368                            {{ls, r2, r15}, "ls, r2, r15", "ls_r2_r15"},
369                            {{ls, r3, r15}, "ls, r3, r15", "ls_r3_r15"},
370                            {{ls, r4, r15}, "ls, r4, r15", "ls_r4_r15"},
371                            {{ls, r5, r15}, "ls, r5, r15", "ls_r5_r15"},
372                            {{ls, r6, r15}, "ls, r6, r15", "ls_r6_r15"},
373                            {{ls, r7, r15}, "ls, r7, r15", "ls_r7_r15"},
374                            {{ls, r8, r15}, "ls, r8, r15", "ls_r8_r15"},
375                            {{ls, r9, r15}, "ls, r9, r15", "ls_r9_r15"},
376                            {{ls, r10, r15}, "ls, r10, r15", "ls_r10_r15"},
377                            {{ls, r11, r15}, "ls, r11, r15", "ls_r11_r15"},
378                            {{ls, r12, r15}, "ls, r12, r15", "ls_r12_r15"},
379                            {{ls, r13, r15}, "ls, r13, r15", "ls_r13_r15"},
380                            {{ls, r14, r15}, "ls, r14, r15", "ls_r14_r15"},
381                            {{ls, r15, r0}, "ls, r15, r0", "ls_r15_r0"},
382                            {{ls, r15, r1}, "ls, r15, r1", "ls_r15_r1"},
383                            {{ls, r15, r2}, "ls, r15, r2", "ls_r15_r2"},
384                            {{ls, r15, r3}, "ls, r15, r3", "ls_r15_r3"},
385                            {{ls, r15, r4}, "ls, r15, r4", "ls_r15_r4"},
386                            {{ls, r15, r5}, "ls, r15, r5", "ls_r15_r5"},
387                            {{ls, r15, r6}, "ls, r15, r6", "ls_r15_r6"},
388                            {{ls, r15, r7}, "ls, r15, r7", "ls_r15_r7"},
389                            {{ls, r15, r8}, "ls, r15, r8", "ls_r15_r8"},
390                            {{ls, r15, r9}, "ls, r15, r9", "ls_r15_r9"},
391                            {{ls, r15, r10}, "ls, r15, r10", "ls_r15_r10"},
392                            {{ls, r15, r11}, "ls, r15, r11", "ls_r15_r11"},
393                            {{ls, r15, r12}, "ls, r15, r12", "ls_r15_r12"},
394                            {{ls, r15, r13}, "ls, r15, r13", "ls_r15_r13"},
395                            {{ls, r15, r14}, "ls, r15, r14", "ls_r15_r14"},
396                            {{ls, r15, r15}, "ls, r15, r15", "ls_r15_r15"},
397                            {{ge, r0, r15}, "ge, r0, r15", "ge_r0_r15"},
398                            {{ge, r1, r15}, "ge, r1, r15", "ge_r1_r15"},
399                            {{ge, r2, r15}, "ge, r2, r15", "ge_r2_r15"},
400                            {{ge, r3, r15}, "ge, r3, r15", "ge_r3_r15"},
401                            {{ge, r4, r15}, "ge, r4, r15", "ge_r4_r15"},
402                            {{ge, r5, r15}, "ge, r5, r15", "ge_r5_r15"},
403                            {{ge, r6, r15}, "ge, r6, r15", "ge_r6_r15"},
404                            {{ge, r7, r15}, "ge, r7, r15", "ge_r7_r15"},
405                            {{ge, r8, r15}, "ge, r8, r15", "ge_r8_r15"},
406                            {{ge, r9, r15}, "ge, r9, r15", "ge_r9_r15"},
407                            {{ge, r10, r15}, "ge, r10, r15", "ge_r10_r15"},
408                            {{ge, r11, r15}, "ge, r11, r15", "ge_r11_r15"},
409                            {{ge, r12, r15}, "ge, r12, r15", "ge_r12_r15"},
410                            {{ge, r13, r15}, "ge, r13, r15", "ge_r13_r15"},
411                            {{ge, r14, r15}, "ge, r14, r15", "ge_r14_r15"},
412                            {{ge, r15, r0}, "ge, r15, r0", "ge_r15_r0"},
413                            {{ge, r15, r1}, "ge, r15, r1", "ge_r15_r1"},
414                            {{ge, r15, r2}, "ge, r15, r2", "ge_r15_r2"},
415                            {{ge, r15, r3}, "ge, r15, r3", "ge_r15_r3"},
416                            {{ge, r15, r4}, "ge, r15, r4", "ge_r15_r4"},
417                            {{ge, r15, r5}, "ge, r15, r5", "ge_r15_r5"},
418                            {{ge, r15, r6}, "ge, r15, r6", "ge_r15_r6"},
419                            {{ge, r15, r7}, "ge, r15, r7", "ge_r15_r7"},
420                            {{ge, r15, r8}, "ge, r15, r8", "ge_r15_r8"},
421                            {{ge, r15, r9}, "ge, r15, r9", "ge_r15_r9"},
422                            {{ge, r15, r10}, "ge, r15, r10", "ge_r15_r10"},
423                            {{ge, r15, r11}, "ge, r15, r11", "ge_r15_r11"},
424                            {{ge, r15, r12}, "ge, r15, r12", "ge_r15_r12"},
425                            {{ge, r15, r13}, "ge, r15, r13", "ge_r15_r13"},
426                            {{ge, r15, r14}, "ge, r15, r14", "ge_r15_r14"},
427                            {{ge, r15, r15}, "ge, r15, r15", "ge_r15_r15"},
428                            {{lt, r0, r15}, "lt, r0, r15", "lt_r0_r15"},
429                            {{lt, r1, r15}, "lt, r1, r15", "lt_r1_r15"},
430                            {{lt, r2, r15}, "lt, r2, r15", "lt_r2_r15"},
431                            {{lt, r3, r15}, "lt, r3, r15", "lt_r3_r15"},
432                            {{lt, r4, r15}, "lt, r4, r15", "lt_r4_r15"},
433                            {{lt, r5, r15}, "lt, r5, r15", "lt_r5_r15"},
434                            {{lt, r6, r15}, "lt, r6, r15", "lt_r6_r15"},
435                            {{lt, r7, r15}, "lt, r7, r15", "lt_r7_r15"},
436                            {{lt, r8, r15}, "lt, r8, r15", "lt_r8_r15"},
437                            {{lt, r9, r15}, "lt, r9, r15", "lt_r9_r15"},
438                            {{lt, r10, r15}, "lt, r10, r15", "lt_r10_r15"},
439                            {{lt, r11, r15}, "lt, r11, r15", "lt_r11_r15"},
440                            {{lt, r12, r15}, "lt, r12, r15", "lt_r12_r15"},
441                            {{lt, r13, r15}, "lt, r13, r15", "lt_r13_r15"},
442                            {{lt, r14, r15}, "lt, r14, r15", "lt_r14_r15"},
443                            {{lt, r15, r0}, "lt, r15, r0", "lt_r15_r0"},
444                            {{lt, r15, r1}, "lt, r15, r1", "lt_r15_r1"},
445                            {{lt, r15, r2}, "lt, r15, r2", "lt_r15_r2"},
446                            {{lt, r15, r3}, "lt, r15, r3", "lt_r15_r3"},
447                            {{lt, r15, r4}, "lt, r15, r4", "lt_r15_r4"},
448                            {{lt, r15, r5}, "lt, r15, r5", "lt_r15_r5"},
449                            {{lt, r15, r6}, "lt, r15, r6", "lt_r15_r6"},
450                            {{lt, r15, r7}, "lt, r15, r7", "lt_r15_r7"},
451                            {{lt, r15, r8}, "lt, r15, r8", "lt_r15_r8"},
452                            {{lt, r15, r9}, "lt, r15, r9", "lt_r15_r9"},
453                            {{lt, r15, r10}, "lt, r15, r10", "lt_r15_r10"},
454                            {{lt, r15, r11}, "lt, r15, r11", "lt_r15_r11"},
455                            {{lt, r15, r12}, "lt, r15, r12", "lt_r15_r12"},
456                            {{lt, r15, r13}, "lt, r15, r13", "lt_r15_r13"},
457                            {{lt, r15, r14}, "lt, r15, r14", "lt_r15_r14"},
458                            {{lt, r15, r15}, "lt, r15, r15", "lt_r15_r15"},
459                            {{gt, r0, r15}, "gt, r0, r15", "gt_r0_r15"},
460                            {{gt, r1, r15}, "gt, r1, r15", "gt_r1_r15"},
461                            {{gt, r2, r15}, "gt, r2, r15", "gt_r2_r15"},
462                            {{gt, r3, r15}, "gt, r3, r15", "gt_r3_r15"},
463                            {{gt, r4, r15}, "gt, r4, r15", "gt_r4_r15"},
464                            {{gt, r5, r15}, "gt, r5, r15", "gt_r5_r15"},
465                            {{gt, r6, r15}, "gt, r6, r15", "gt_r6_r15"},
466                            {{gt, r7, r15}, "gt, r7, r15", "gt_r7_r15"},
467                            {{gt, r8, r15}, "gt, r8, r15", "gt_r8_r15"},
468                            {{gt, r9, r15}, "gt, r9, r15", "gt_r9_r15"},
469                            {{gt, r10, r15}, "gt, r10, r15", "gt_r10_r15"},
470                            {{gt, r11, r15}, "gt, r11, r15", "gt_r11_r15"},
471                            {{gt, r12, r15}, "gt, r12, r15", "gt_r12_r15"},
472                            {{gt, r13, r15}, "gt, r13, r15", "gt_r13_r15"},
473                            {{gt, r14, r15}, "gt, r14, r15", "gt_r14_r15"},
474                            {{gt, r15, r0}, "gt, r15, r0", "gt_r15_r0"},
475                            {{gt, r15, r1}, "gt, r15, r1", "gt_r15_r1"},
476                            {{gt, r15, r2}, "gt, r15, r2", "gt_r15_r2"},
477                            {{gt, r15, r3}, "gt, r15, r3", "gt_r15_r3"},
478                            {{gt, r15, r4}, "gt, r15, r4", "gt_r15_r4"},
479                            {{gt, r15, r5}, "gt, r15, r5", "gt_r15_r5"},
480                            {{gt, r15, r6}, "gt, r15, r6", "gt_r15_r6"},
481                            {{gt, r15, r7}, "gt, r15, r7", "gt_r15_r7"},
482                            {{gt, r15, r8}, "gt, r15, r8", "gt_r15_r8"},
483                            {{gt, r15, r9}, "gt, r15, r9", "gt_r15_r9"},
484                            {{gt, r15, r10}, "gt, r15, r10", "gt_r15_r10"},
485                            {{gt, r15, r11}, "gt, r15, r11", "gt_r15_r11"},
486                            {{gt, r15, r12}, "gt, r15, r12", "gt_r15_r12"},
487                            {{gt, r15, r13}, "gt, r15, r13", "gt_r15_r13"},
488                            {{gt, r15, r14}, "gt, r15, r14", "gt_r15_r14"},
489                            {{gt, r15, r15}, "gt, r15, r15", "gt_r15_r15"},
490                            {{le, r0, r15}, "le, r0, r15", "le_r0_r15"},
491                            {{le, r1, r15}, "le, r1, r15", "le_r1_r15"},
492                            {{le, r2, r15}, "le, r2, r15", "le_r2_r15"},
493                            {{le, r3, r15}, "le, r3, r15", "le_r3_r15"},
494                            {{le, r4, r15}, "le, r4, r15", "le_r4_r15"},
495                            {{le, r5, r15}, "le, r5, r15", "le_r5_r15"},
496                            {{le, r6, r15}, "le, r6, r15", "le_r6_r15"},
497                            {{le, r7, r15}, "le, r7, r15", "le_r7_r15"},
498                            {{le, r8, r15}, "le, r8, r15", "le_r8_r15"},
499                            {{le, r9, r15}, "le, r9, r15", "le_r9_r15"},
500                            {{le, r10, r15}, "le, r10, r15", "le_r10_r15"},
501                            {{le, r11, r15}, "le, r11, r15", "le_r11_r15"},
502                            {{le, r12, r15}, "le, r12, r15", "le_r12_r15"},
503                            {{le, r13, r15}, "le, r13, r15", "le_r13_r15"},
504                            {{le, r14, r15}, "le, r14, r15", "le_r14_r15"},
505                            {{le, r15, r0}, "le, r15, r0", "le_r15_r0"},
506                            {{le, r15, r1}, "le, r15, r1", "le_r15_r1"},
507                            {{le, r15, r2}, "le, r15, r2", "le_r15_r2"},
508                            {{le, r15, r3}, "le, r15, r3", "le_r15_r3"},
509                            {{le, r15, r4}, "le, r15, r4", "le_r15_r4"},
510                            {{le, r15, r5}, "le, r15, r5", "le_r15_r5"},
511                            {{le, r15, r6}, "le, r15, r6", "le_r15_r6"},
512                            {{le, r15, r7}, "le, r15, r7", "le_r15_r7"},
513                            {{le, r15, r8}, "le, r15, r8", "le_r15_r8"},
514                            {{le, r15, r9}, "le, r15, r9", "le_r15_r9"},
515                            {{le, r15, r10}, "le, r15, r10", "le_r15_r10"},
516                            {{le, r15, r11}, "le, r15, r11", "le_r15_r11"},
517                            {{le, r15, r12}, "le, r15, r12", "le_r15_r12"},
518                            {{le, r15, r13}, "le, r15, r13", "le_r15_r13"},
519                            {{le, r15, r14}, "le, r15, r14", "le_r15_r14"},
520                            {{le, r15, r15}, "le, r15, r15", "le_r15_r15"},
521                            {{al, r0, r15}, "al, r0, r15", "al_r0_r15"},
522                            {{al, r1, r15}, "al, r1, r15", "al_r1_r15"},
523                            {{al, r2, r15}, "al, r2, r15", "al_r2_r15"},
524                            {{al, r3, r15}, "al, r3, r15", "al_r3_r15"},
525                            {{al, r4, r15}, "al, r4, r15", "al_r4_r15"},
526                            {{al, r5, r15}, "al, r5, r15", "al_r5_r15"},
527                            {{al, r6, r15}, "al, r6, r15", "al_r6_r15"},
528                            {{al, r7, r15}, "al, r7, r15", "al_r7_r15"},
529                            {{al, r8, r15}, "al, r8, r15", "al_r8_r15"},
530                            {{al, r9, r15}, "al, r9, r15", "al_r9_r15"},
531                            {{al, r10, r15}, "al, r10, r15", "al_r10_r15"},
532                            {{al, r11, r15}, "al, r11, r15", "al_r11_r15"},
533                            {{al, r12, r15}, "al, r12, r15", "al_r12_r15"},
534                            {{al, r13, r15}, "al, r13, r15", "al_r13_r15"},
535                            {{al, r14, r15}, "al, r14, r15", "al_r14_r15"},
536                            {{al, r15, r0}, "al, r15, r0", "al_r15_r0"},
537                            {{al, r15, r1}, "al, r15, r1", "al_r15_r1"},
538                            {{al, r15, r2}, "al, r15, r2", "al_r15_r2"},
539                            {{al, r15, r3}, "al, r15, r3", "al_r15_r3"},
540                            {{al, r15, r4}, "al, r15, r4", "al_r15_r4"},
541                            {{al, r15, r5}, "al, r15, r5", "al_r15_r5"},
542                            {{al, r15, r6}, "al, r15, r6", "al_r15_r6"},
543                            {{al, r15, r7}, "al, r15, r7", "al_r15_r7"},
544                            {{al, r15, r8}, "al, r15, r8", "al_r15_r8"},
545                            {{al, r15, r9}, "al, r15, r9", "al_r15_r9"},
546                            {{al, r15, r10}, "al, r15, r10", "al_r15_r10"},
547                            {{al, r15, r11}, "al, r15, r11", "al_r15_r11"},
548                            {{al, r15, r12}, "al, r15, r12", "al_r15_r12"},
549                            {{al, r15, r13}, "al, r15, r13", "al_r15_r13"},
550                            {{al, r15, r14}, "al, r15, r14", "al_r15_r14"},
551                            {{al, r15, r15}, "al, r15, r15", "al_r15_r15"}};
552 
553 typedef void (MacroAssembler::*Fn)(Condition cond, Register rd, Register rn);
554 
555 // Use a customised disassembler to label test cases.
556 typedef std::map<uint32_t, int> TestCaseSymbolMap;
557 
558 class TestDisassembler : public PrintDisassembler {
559  public:
TestDisassembler(std::ostream & os,const TestCaseSymbolMap & symbols,const char * mnemonic)560   TestDisassembler(std::ostream& os,  // NOLINT(runtime/references)
561                    const TestCaseSymbolMap& symbols,
562                    const char* mnemonic)
563       : PrintDisassembler(os), symbols_(symbols), mnemonic_(mnemonic) {}
564 
PrintCodeAddress(uint32_t pc)565   virtual void PrintCodeAddress(uint32_t pc) VIXL_OVERRIDE {
566     // Label test cases.
567     TestCaseSymbolMap::const_iterator symbol = symbols_.find(pc);
568     if (symbol != symbols_.end()) {
569       int n = symbol->second;
570       os().os() << "// " << mnemonic_ << "(" << kTests[n].operands_description
571                 << ")" << std::endl;
572     }
573     // Print the code address as normal.
574     PrintDisassembler::PrintCodeAddress(pc);
575   }
576 
577  private:
578   const TestCaseSymbolMap& symbols_;
579   const char* mnemonic_;
580 };
581 
TestHelper(Fn instruction,const char * mnemonic)582 void TestHelper(Fn instruction, const char* mnemonic) {
583   MacroAssembler masm(BUF_SIZE);
584 
585   masm.UseA32();
586 
587   TestCaseSymbolMap symbols;
588 
589   for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
590     if (Test::disassemble()) {
591       // TODO: This will fail if the MacroAssembler generates no code. We can
592       // fix this with multimap but then we must take care to print the labels
593       // in the correct order. (Insertion order is only preserved for C++11.)
594       symbols.insert(std::pair<uint32_t, int>(masm.GetCursorOffset(), i));
595     }
596 
597     // Values to pass to the macro-assembler.
598     UseScratchRegisterScope scratch_registers(&masm);
599     Condition cond = kTests[i].operands.cond;
600     Register rd = kTests[i].operands.rd;
601     Register rn = kTests[i].operands.rn;
602     scratch_registers.Exclude(rd);
603     scratch_registers.Exclude(rn);
604 
605     (masm.*instruction)(cond, rd, rn);
606 
607     // For now, these test don't currently produce (or check) any trace; we just
608     // check that the MacroAssembler didn't crash.
609     // TODO: We could generate disassembly as a trace here, to check for sane
610     // output, though the trace would need to be manually checked.
611   }
612 
613   masm.FinalizeCode();
614 
615   if (Test::disassemble()) {
616     // Disassemble to stdout if given --disassemble on the command line.
617     TestDisassembler dis(std::cout, symbols, mnemonic);
618     if (masm.IsUsingT32()) {
619       dis.DisassembleT32Buffer(masm.GetBuffer()->GetStartAddress<uint16_t*>(),
620                                masm.GetCursorOffset());
621     } else {
622       dis.DisassembleA32Buffer(masm.GetBuffer()->GetStartAddress<uint32_t*>(),
623                                masm.GetCursorOffset());
624     }
625   }
626 }
627 
628 // Instantiate tests for each instruction in the list.
629 #define TEST(mnemonic)                                                         \
630   void Test_##mnemonic() { TestHelper(&MacroAssembler::mnemonic, #mnemonic); } \
631   Test test_##mnemonic("AARCH32_MACRO_ASSEMBLER_COND_RD_RN_PC_A32_" #mnemonic, \
632                        &Test_##mnemonic);
633 FOREACH_INSTRUCTION(TEST)
634 #undef TEST
635 
636 }  // namespace
637 #endif
638 
639 }  // namespace aarch32
640 }  // namespace vixl
641