1b8021494Sopenharmony_ci// Copyright 2016, VIXL authors 2b8021494Sopenharmony_ci// All rights reserved. 3b8021494Sopenharmony_ci// 4b8021494Sopenharmony_ci// Redistribution and use in source and binary forms, with or without 5b8021494Sopenharmony_ci// modification, are permitted provided that the following conditions are met: 6b8021494Sopenharmony_ci// 7b8021494Sopenharmony_ci// * Redistributions of source code must retain the above copyright notice, 8b8021494Sopenharmony_ci// this list of conditions and the following disclaimer. 9b8021494Sopenharmony_ci// * Redistributions in binary form must reproduce the above copyright notice, 10b8021494Sopenharmony_ci// this list of conditions and the following disclaimer in the documentation 11b8021494Sopenharmony_ci// and/or other materials provided with the distribution. 12b8021494Sopenharmony_ci// * Neither the name of ARM Limited nor the names of its contributors may be 13b8021494Sopenharmony_ci// used to endorse or promote products derived from this software without 14b8021494Sopenharmony_ci// specific prior written permission. 15b8021494Sopenharmony_ci// 16b8021494Sopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND 17b8021494Sopenharmony_ci// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18b8021494Sopenharmony_ci// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19b8021494Sopenharmony_ci// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20b8021494Sopenharmony_ci// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21b8021494Sopenharmony_ci// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22b8021494Sopenharmony_ci// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23b8021494Sopenharmony_ci// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24b8021494Sopenharmony_ci// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25b8021494Sopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26b8021494Sopenharmony_ci 27b8021494Sopenharmony_ci 28b8021494Sopenharmony_ci// ----------------------------------------------------------------------------- 29b8021494Sopenharmony_ci// This file is auto generated from the 30b8021494Sopenharmony_ci// test/aarch32/config/template-assembler-aarch32.cc.in template file using 31b8021494Sopenharmony_ci// tools/generate_tests.py. 32b8021494Sopenharmony_ci// 33b8021494Sopenharmony_ci// PLEASE DO NOT EDIT. 34b8021494Sopenharmony_ci// ----------------------------------------------------------------------------- 35b8021494Sopenharmony_ci 36b8021494Sopenharmony_ci 37b8021494Sopenharmony_ci#include "test-runner.h" 38b8021494Sopenharmony_ci 39b8021494Sopenharmony_ci#include "test-utils.h" 40b8021494Sopenharmony_ci#include "test-utils-aarch32.h" 41b8021494Sopenharmony_ci 42b8021494Sopenharmony_ci#include "aarch32/assembler-aarch32.h" 43b8021494Sopenharmony_ci#include "aarch32/macro-assembler-aarch32.h" 44b8021494Sopenharmony_ci 45b8021494Sopenharmony_ci#define BUF_SIZE (4096) 46b8021494Sopenharmony_ci 47b8021494Sopenharmony_cinamespace vixl { 48b8021494Sopenharmony_cinamespace aarch32 { 49b8021494Sopenharmony_ci 50b8021494Sopenharmony_ci// List of instruction mnemonics. 51b8021494Sopenharmony_ci#define FOREACH_INSTRUCTION(M) M(add) 52b8021494Sopenharmony_ci 53b8021494Sopenharmony_ci 54b8021494Sopenharmony_ci// The following definitions are defined again in each generated test, therefore 55b8021494Sopenharmony_ci// we need to place them in an anonymous namespace. It expresses that they are 56b8021494Sopenharmony_ci// local to this file only, and the compiler is not allowed to share these types 57b8021494Sopenharmony_ci// across test files during template instantiation. Specifically, `Operands` has 58b8021494Sopenharmony_ci// various layouts across generated tests so it absolutely cannot be shared. 59b8021494Sopenharmony_ci 60b8021494Sopenharmony_ci#ifdef VIXL_INCLUDE_TARGET_T32 61b8021494Sopenharmony_cinamespace { 62b8021494Sopenharmony_ci 63b8021494Sopenharmony_ci// Values to be passed to the assembler to produce the instruction under test. 64b8021494Sopenharmony_cistruct Operands { 65b8021494Sopenharmony_ci Condition cond; 66b8021494Sopenharmony_ci Register rd; 67b8021494Sopenharmony_ci Register rn; 68b8021494Sopenharmony_ci Register rm; 69b8021494Sopenharmony_ci}; 70b8021494Sopenharmony_ci 71b8021494Sopenharmony_ci// This structure contains all data needed to test one specific 72b8021494Sopenharmony_ci// instruction. 73b8021494Sopenharmony_cistruct TestData { 74b8021494Sopenharmony_ci // The `operands` field represents what to pass to the assembler to 75b8021494Sopenharmony_ci // produce the instruction. 76b8021494Sopenharmony_ci Operands operands; 77b8021494Sopenharmony_ci // True if we need to generate an IT instruction for this test to be valid. 78b8021494Sopenharmony_ci bool in_it_block; 79b8021494Sopenharmony_ci // The condition to give the IT instruction, this will be set to "al" by 80b8021494Sopenharmony_ci // default. 81b8021494Sopenharmony_ci Condition it_condition; 82b8021494Sopenharmony_ci // Description of the operands, used for error reporting. 83b8021494Sopenharmony_ci const char* operands_description; 84b8021494Sopenharmony_ci // Unique identifier, used for generating traces. 85b8021494Sopenharmony_ci const char* identifier; 86b8021494Sopenharmony_ci}; 87b8021494Sopenharmony_ci 88b8021494Sopenharmony_cistruct TestResult { 89b8021494Sopenharmony_ci size_t size; 90b8021494Sopenharmony_ci const byte* encoding; 91b8021494Sopenharmony_ci}; 92b8021494Sopenharmony_ci 93b8021494Sopenharmony_ci// Each element of this array produce one instruction encoding. 94b8021494Sopenharmony_ciconst TestData kTests[] = 95b8021494Sopenharmony_ci {{{eq, r0, r13, r0}, true, eq, "eq r0 r13 r0", "eq_r0_r13_r0"}, 96b8021494Sopenharmony_ci {{eq, r1, r13, r1}, true, eq, "eq r1 r13 r1", "eq_r1_r13_r1"}, 97b8021494Sopenharmony_ci {{eq, r2, r13, r2}, true, eq, "eq r2 r13 r2", "eq_r2_r13_r2"}, 98b8021494Sopenharmony_ci {{eq, r3, r13, r3}, true, eq, "eq r3 r13 r3", "eq_r3_r13_r3"}, 99b8021494Sopenharmony_ci {{eq, r4, r13, r4}, true, eq, "eq r4 r13 r4", "eq_r4_r13_r4"}, 100b8021494Sopenharmony_ci {{eq, r5, r13, r5}, true, eq, "eq r5 r13 r5", "eq_r5_r13_r5"}, 101b8021494Sopenharmony_ci {{eq, r6, r13, r6}, true, eq, "eq r6 r13 r6", "eq_r6_r13_r6"}, 102b8021494Sopenharmony_ci {{eq, r7, r13, r7}, true, eq, "eq r7 r13 r7", "eq_r7_r13_r7"}, 103b8021494Sopenharmony_ci {{ne, r0, r13, r0}, true, ne, "ne r0 r13 r0", "ne_r0_r13_r0"}, 104b8021494Sopenharmony_ci {{ne, r1, r13, r1}, true, ne, "ne r1 r13 r1", "ne_r1_r13_r1"}, 105b8021494Sopenharmony_ci {{ne, r2, r13, r2}, true, ne, "ne r2 r13 r2", "ne_r2_r13_r2"}, 106b8021494Sopenharmony_ci {{ne, r3, r13, r3}, true, ne, "ne r3 r13 r3", "ne_r3_r13_r3"}, 107b8021494Sopenharmony_ci {{ne, r4, r13, r4}, true, ne, "ne r4 r13 r4", "ne_r4_r13_r4"}, 108b8021494Sopenharmony_ci {{ne, r5, r13, r5}, true, ne, "ne r5 r13 r5", "ne_r5_r13_r5"}, 109b8021494Sopenharmony_ci {{ne, r6, r13, r6}, true, ne, "ne r6 r13 r6", "ne_r6_r13_r6"}, 110b8021494Sopenharmony_ci {{ne, r7, r13, r7}, true, ne, "ne r7 r13 r7", "ne_r7_r13_r7"}, 111b8021494Sopenharmony_ci {{cs, r0, r13, r0}, true, cs, "cs r0 r13 r0", "cs_r0_r13_r0"}, 112b8021494Sopenharmony_ci {{cs, r1, r13, r1}, true, cs, "cs r1 r13 r1", "cs_r1_r13_r1"}, 113b8021494Sopenharmony_ci {{cs, r2, r13, r2}, true, cs, "cs r2 r13 r2", "cs_r2_r13_r2"}, 114b8021494Sopenharmony_ci {{cs, r3, r13, r3}, true, cs, "cs r3 r13 r3", "cs_r3_r13_r3"}, 115b8021494Sopenharmony_ci {{cs, r4, r13, r4}, true, cs, "cs r4 r13 r4", "cs_r4_r13_r4"}, 116b8021494Sopenharmony_ci {{cs, r5, r13, r5}, true, cs, "cs r5 r13 r5", "cs_r5_r13_r5"}, 117b8021494Sopenharmony_ci {{cs, r6, r13, r6}, true, cs, "cs r6 r13 r6", "cs_r6_r13_r6"}, 118b8021494Sopenharmony_ci {{cs, r7, r13, r7}, true, cs, "cs r7 r13 r7", "cs_r7_r13_r7"}, 119b8021494Sopenharmony_ci {{cc, r0, r13, r0}, true, cc, "cc r0 r13 r0", "cc_r0_r13_r0"}, 120b8021494Sopenharmony_ci {{cc, r1, r13, r1}, true, cc, "cc r1 r13 r1", "cc_r1_r13_r1"}, 121b8021494Sopenharmony_ci {{cc, r2, r13, r2}, true, cc, "cc r2 r13 r2", "cc_r2_r13_r2"}, 122b8021494Sopenharmony_ci {{cc, r3, r13, r3}, true, cc, "cc r3 r13 r3", "cc_r3_r13_r3"}, 123b8021494Sopenharmony_ci {{cc, r4, r13, r4}, true, cc, "cc r4 r13 r4", "cc_r4_r13_r4"}, 124b8021494Sopenharmony_ci {{cc, r5, r13, r5}, true, cc, "cc r5 r13 r5", "cc_r5_r13_r5"}, 125b8021494Sopenharmony_ci {{cc, r6, r13, r6}, true, cc, "cc r6 r13 r6", "cc_r6_r13_r6"}, 126b8021494Sopenharmony_ci {{cc, r7, r13, r7}, true, cc, "cc r7 r13 r7", "cc_r7_r13_r7"}, 127b8021494Sopenharmony_ci {{mi, r0, r13, r0}, true, mi, "mi r0 r13 r0", "mi_r0_r13_r0"}, 128b8021494Sopenharmony_ci {{mi, r1, r13, r1}, true, mi, "mi r1 r13 r1", "mi_r1_r13_r1"}, 129b8021494Sopenharmony_ci {{mi, r2, r13, r2}, true, mi, "mi r2 r13 r2", "mi_r2_r13_r2"}, 130b8021494Sopenharmony_ci {{mi, r3, r13, r3}, true, mi, "mi r3 r13 r3", "mi_r3_r13_r3"}, 131b8021494Sopenharmony_ci {{mi, r4, r13, r4}, true, mi, "mi r4 r13 r4", "mi_r4_r13_r4"}, 132b8021494Sopenharmony_ci {{mi, r5, r13, r5}, true, mi, "mi r5 r13 r5", "mi_r5_r13_r5"}, 133b8021494Sopenharmony_ci {{mi, r6, r13, r6}, true, mi, "mi r6 r13 r6", "mi_r6_r13_r6"}, 134b8021494Sopenharmony_ci {{mi, r7, r13, r7}, true, mi, "mi r7 r13 r7", "mi_r7_r13_r7"}, 135b8021494Sopenharmony_ci {{pl, r0, r13, r0}, true, pl, "pl r0 r13 r0", "pl_r0_r13_r0"}, 136b8021494Sopenharmony_ci {{pl, r1, r13, r1}, true, pl, "pl r1 r13 r1", "pl_r1_r13_r1"}, 137b8021494Sopenharmony_ci {{pl, r2, r13, r2}, true, pl, "pl r2 r13 r2", "pl_r2_r13_r2"}, 138b8021494Sopenharmony_ci {{pl, r3, r13, r3}, true, pl, "pl r3 r13 r3", "pl_r3_r13_r3"}, 139b8021494Sopenharmony_ci {{pl, r4, r13, r4}, true, pl, "pl r4 r13 r4", "pl_r4_r13_r4"}, 140b8021494Sopenharmony_ci {{pl, r5, r13, r5}, true, pl, "pl r5 r13 r5", "pl_r5_r13_r5"}, 141b8021494Sopenharmony_ci {{pl, r6, r13, r6}, true, pl, "pl r6 r13 r6", "pl_r6_r13_r6"}, 142b8021494Sopenharmony_ci {{pl, r7, r13, r7}, true, pl, "pl r7 r13 r7", "pl_r7_r13_r7"}, 143b8021494Sopenharmony_ci {{vs, r0, r13, r0}, true, vs, "vs r0 r13 r0", "vs_r0_r13_r0"}, 144b8021494Sopenharmony_ci {{vs, r1, r13, r1}, true, vs, "vs r1 r13 r1", "vs_r1_r13_r1"}, 145b8021494Sopenharmony_ci {{vs, r2, r13, r2}, true, vs, "vs r2 r13 r2", "vs_r2_r13_r2"}, 146b8021494Sopenharmony_ci {{vs, r3, r13, r3}, true, vs, "vs r3 r13 r3", "vs_r3_r13_r3"}, 147b8021494Sopenharmony_ci {{vs, r4, r13, r4}, true, vs, "vs r4 r13 r4", "vs_r4_r13_r4"}, 148b8021494Sopenharmony_ci {{vs, r5, r13, r5}, true, vs, "vs r5 r13 r5", "vs_r5_r13_r5"}, 149b8021494Sopenharmony_ci {{vs, r6, r13, r6}, true, vs, "vs r6 r13 r6", "vs_r6_r13_r6"}, 150b8021494Sopenharmony_ci {{vs, r7, r13, r7}, true, vs, "vs r7 r13 r7", "vs_r7_r13_r7"}, 151b8021494Sopenharmony_ci {{vc, r0, r13, r0}, true, vc, "vc r0 r13 r0", "vc_r0_r13_r0"}, 152b8021494Sopenharmony_ci {{vc, r1, r13, r1}, true, vc, "vc r1 r13 r1", "vc_r1_r13_r1"}, 153b8021494Sopenharmony_ci {{vc, r2, r13, r2}, true, vc, "vc r2 r13 r2", "vc_r2_r13_r2"}, 154b8021494Sopenharmony_ci {{vc, r3, r13, r3}, true, vc, "vc r3 r13 r3", "vc_r3_r13_r3"}, 155b8021494Sopenharmony_ci {{vc, r4, r13, r4}, true, vc, "vc r4 r13 r4", "vc_r4_r13_r4"}, 156b8021494Sopenharmony_ci {{vc, r5, r13, r5}, true, vc, "vc r5 r13 r5", "vc_r5_r13_r5"}, 157b8021494Sopenharmony_ci {{vc, r6, r13, r6}, true, vc, "vc r6 r13 r6", "vc_r6_r13_r6"}, 158b8021494Sopenharmony_ci {{vc, r7, r13, r7}, true, vc, "vc r7 r13 r7", "vc_r7_r13_r7"}, 159b8021494Sopenharmony_ci {{hi, r0, r13, r0}, true, hi, "hi r0 r13 r0", "hi_r0_r13_r0"}, 160b8021494Sopenharmony_ci {{hi, r1, r13, r1}, true, hi, "hi r1 r13 r1", "hi_r1_r13_r1"}, 161b8021494Sopenharmony_ci {{hi, r2, r13, r2}, true, hi, "hi r2 r13 r2", "hi_r2_r13_r2"}, 162b8021494Sopenharmony_ci {{hi, r3, r13, r3}, true, hi, "hi r3 r13 r3", "hi_r3_r13_r3"}, 163b8021494Sopenharmony_ci {{hi, r4, r13, r4}, true, hi, "hi r4 r13 r4", "hi_r4_r13_r4"}, 164b8021494Sopenharmony_ci {{hi, r5, r13, r5}, true, hi, "hi r5 r13 r5", "hi_r5_r13_r5"}, 165b8021494Sopenharmony_ci {{hi, r6, r13, r6}, true, hi, "hi r6 r13 r6", "hi_r6_r13_r6"}, 166b8021494Sopenharmony_ci {{hi, r7, r13, r7}, true, hi, "hi r7 r13 r7", "hi_r7_r13_r7"}, 167b8021494Sopenharmony_ci {{ls, r0, r13, r0}, true, ls, "ls r0 r13 r0", "ls_r0_r13_r0"}, 168b8021494Sopenharmony_ci {{ls, r1, r13, r1}, true, ls, "ls r1 r13 r1", "ls_r1_r13_r1"}, 169b8021494Sopenharmony_ci {{ls, r2, r13, r2}, true, ls, "ls r2 r13 r2", "ls_r2_r13_r2"}, 170b8021494Sopenharmony_ci {{ls, r3, r13, r3}, true, ls, "ls r3 r13 r3", "ls_r3_r13_r3"}, 171b8021494Sopenharmony_ci {{ls, r4, r13, r4}, true, ls, "ls r4 r13 r4", "ls_r4_r13_r4"}, 172b8021494Sopenharmony_ci {{ls, r5, r13, r5}, true, ls, "ls r5 r13 r5", "ls_r5_r13_r5"}, 173b8021494Sopenharmony_ci {{ls, r6, r13, r6}, true, ls, "ls r6 r13 r6", "ls_r6_r13_r6"}, 174b8021494Sopenharmony_ci {{ls, r7, r13, r7}, true, ls, "ls r7 r13 r7", "ls_r7_r13_r7"}, 175b8021494Sopenharmony_ci {{ge, r0, r13, r0}, true, ge, "ge r0 r13 r0", "ge_r0_r13_r0"}, 176b8021494Sopenharmony_ci {{ge, r1, r13, r1}, true, ge, "ge r1 r13 r1", "ge_r1_r13_r1"}, 177b8021494Sopenharmony_ci {{ge, r2, r13, r2}, true, ge, "ge r2 r13 r2", "ge_r2_r13_r2"}, 178b8021494Sopenharmony_ci {{ge, r3, r13, r3}, true, ge, "ge r3 r13 r3", "ge_r3_r13_r3"}, 179b8021494Sopenharmony_ci {{ge, r4, r13, r4}, true, ge, "ge r4 r13 r4", "ge_r4_r13_r4"}, 180b8021494Sopenharmony_ci {{ge, r5, r13, r5}, true, ge, "ge r5 r13 r5", "ge_r5_r13_r5"}, 181b8021494Sopenharmony_ci {{ge, r6, r13, r6}, true, ge, "ge r6 r13 r6", "ge_r6_r13_r6"}, 182b8021494Sopenharmony_ci {{ge, r7, r13, r7}, true, ge, "ge r7 r13 r7", "ge_r7_r13_r7"}, 183b8021494Sopenharmony_ci {{lt, r0, r13, r0}, true, lt, "lt r0 r13 r0", "lt_r0_r13_r0"}, 184b8021494Sopenharmony_ci {{lt, r1, r13, r1}, true, lt, "lt r1 r13 r1", "lt_r1_r13_r1"}, 185b8021494Sopenharmony_ci {{lt, r2, r13, r2}, true, lt, "lt r2 r13 r2", "lt_r2_r13_r2"}, 186b8021494Sopenharmony_ci {{lt, r3, r13, r3}, true, lt, "lt r3 r13 r3", "lt_r3_r13_r3"}, 187b8021494Sopenharmony_ci {{lt, r4, r13, r4}, true, lt, "lt r4 r13 r4", "lt_r4_r13_r4"}, 188b8021494Sopenharmony_ci {{lt, r5, r13, r5}, true, lt, "lt r5 r13 r5", "lt_r5_r13_r5"}, 189b8021494Sopenharmony_ci {{lt, r6, r13, r6}, true, lt, "lt r6 r13 r6", "lt_r6_r13_r6"}, 190b8021494Sopenharmony_ci {{lt, r7, r13, r7}, true, lt, "lt r7 r13 r7", "lt_r7_r13_r7"}, 191b8021494Sopenharmony_ci {{gt, r0, r13, r0}, true, gt, "gt r0 r13 r0", "gt_r0_r13_r0"}, 192b8021494Sopenharmony_ci {{gt, r1, r13, r1}, true, gt, "gt r1 r13 r1", "gt_r1_r13_r1"}, 193b8021494Sopenharmony_ci {{gt, r2, r13, r2}, true, gt, "gt r2 r13 r2", "gt_r2_r13_r2"}, 194b8021494Sopenharmony_ci {{gt, r3, r13, r3}, true, gt, "gt r3 r13 r3", "gt_r3_r13_r3"}, 195b8021494Sopenharmony_ci {{gt, r4, r13, r4}, true, gt, "gt r4 r13 r4", "gt_r4_r13_r4"}, 196b8021494Sopenharmony_ci {{gt, r5, r13, r5}, true, gt, "gt r5 r13 r5", "gt_r5_r13_r5"}, 197b8021494Sopenharmony_ci {{gt, r6, r13, r6}, true, gt, "gt r6 r13 r6", "gt_r6_r13_r6"}, 198b8021494Sopenharmony_ci {{gt, r7, r13, r7}, true, gt, "gt r7 r13 r7", "gt_r7_r13_r7"}, 199b8021494Sopenharmony_ci {{le, r0, r13, r0}, true, le, "le r0 r13 r0", "le_r0_r13_r0"}, 200b8021494Sopenharmony_ci {{le, r1, r13, r1}, true, le, "le r1 r13 r1", "le_r1_r13_r1"}, 201b8021494Sopenharmony_ci {{le, r2, r13, r2}, true, le, "le r2 r13 r2", "le_r2_r13_r2"}, 202b8021494Sopenharmony_ci {{le, r3, r13, r3}, true, le, "le r3 r13 r3", "le_r3_r13_r3"}, 203b8021494Sopenharmony_ci {{le, r4, r13, r4}, true, le, "le r4 r13 r4", "le_r4_r13_r4"}, 204b8021494Sopenharmony_ci {{le, r5, r13, r5}, true, le, "le r5 r13 r5", "le_r5_r13_r5"}, 205b8021494Sopenharmony_ci {{le, r6, r13, r6}, true, le, "le r6 r13 r6", "le_r6_r13_r6"}, 206b8021494Sopenharmony_ci {{le, r7, r13, r7}, true, le, "le r7 r13 r7", "le_r7_r13_r7"}}; 207b8021494Sopenharmony_ci 208b8021494Sopenharmony_ci// These headers each contain an array of `TestResult` with the reference output 209b8021494Sopenharmony_ci// values. The reference arrays are names `kReference{mnemonic}`. 210b8021494Sopenharmony_ci#include "aarch32/traces/assembler-cond-rd-rn-operand-rm-rn-is-sp-in-it-block-add-t32.h" 211b8021494Sopenharmony_ci 212b8021494Sopenharmony_ci 213b8021494Sopenharmony_ci// The maximum number of errors to report in detail for each test. 214b8021494Sopenharmony_ciconst unsigned kErrorReportLimit = 8; 215b8021494Sopenharmony_ci 216b8021494Sopenharmony_citypedef void (MacroAssembler::*Fn)(Condition cond, 217b8021494Sopenharmony_ci Register rd, 218b8021494Sopenharmony_ci Register rn, 219b8021494Sopenharmony_ci const Operand& op); 220b8021494Sopenharmony_ci 221b8021494Sopenharmony_civoid TestHelper(Fn instruction, 222b8021494Sopenharmony_ci const char* mnemonic, 223b8021494Sopenharmony_ci const TestResult reference[]) { 224b8021494Sopenharmony_ci unsigned total_error_count = 0; 225b8021494Sopenharmony_ci MacroAssembler masm(BUF_SIZE); 226b8021494Sopenharmony_ci 227b8021494Sopenharmony_ci masm.UseT32(); 228b8021494Sopenharmony_ci 229b8021494Sopenharmony_ci for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) { 230b8021494Sopenharmony_ci // Values to pass to the macro-assembler. 231b8021494Sopenharmony_ci Condition cond = kTests[i].operands.cond; 232b8021494Sopenharmony_ci Register rd = kTests[i].operands.rd; 233b8021494Sopenharmony_ci Register rn = kTests[i].operands.rn; 234b8021494Sopenharmony_ci Register rm = kTests[i].operands.rm; 235b8021494Sopenharmony_ci Operand op(rm); 236b8021494Sopenharmony_ci 237b8021494Sopenharmony_ci int32_t start = masm.GetCursorOffset(); 238b8021494Sopenharmony_ci { 239b8021494Sopenharmony_ci // We never generate more that 4 bytes, as IT instructions are only 240b8021494Sopenharmony_ci // allowed for narrow encodings. 241b8021494Sopenharmony_ci ExactAssemblyScope scope(&masm, 4, ExactAssemblyScope::kMaximumSize); 242b8021494Sopenharmony_ci if (kTests[i].in_it_block) { 243b8021494Sopenharmony_ci masm.it(kTests[i].it_condition); 244b8021494Sopenharmony_ci } 245b8021494Sopenharmony_ci (masm.*instruction)(cond, rd, rn, op); 246b8021494Sopenharmony_ci } 247b8021494Sopenharmony_ci int32_t end = masm.GetCursorOffset(); 248b8021494Sopenharmony_ci 249b8021494Sopenharmony_ci const byte* result_ptr = 250b8021494Sopenharmony_ci masm.GetBuffer()->GetOffsetAddress<const byte*>(start); 251b8021494Sopenharmony_ci VIXL_ASSERT(start < end); 252b8021494Sopenharmony_ci uint32_t result_size = end - start; 253b8021494Sopenharmony_ci 254b8021494Sopenharmony_ci if (Test::generate_test_trace()) { 255b8021494Sopenharmony_ci // Print the result bytes. 256b8021494Sopenharmony_ci printf("const byte kInstruction_%s_%s[] = {\n", 257b8021494Sopenharmony_ci mnemonic, 258b8021494Sopenharmony_ci kTests[i].identifier); 259b8021494Sopenharmony_ci for (uint32_t j = 0; j < result_size; j++) { 260b8021494Sopenharmony_ci if (j == 0) { 261b8021494Sopenharmony_ci printf(" 0x%02" PRIx8, result_ptr[j]); 262b8021494Sopenharmony_ci } else { 263b8021494Sopenharmony_ci printf(", 0x%02" PRIx8, result_ptr[j]); 264b8021494Sopenharmony_ci } 265b8021494Sopenharmony_ci } 266b8021494Sopenharmony_ci // This comment is meant to be used by external tools to validate 267b8021494Sopenharmony_ci // the encoding. We can parse the comment to figure out what 268b8021494Sopenharmony_ci // instruction this corresponds to. 269b8021494Sopenharmony_ci if (kTests[i].in_it_block) { 270b8021494Sopenharmony_ci printf(" // It %s; %s %s\n};\n", 271b8021494Sopenharmony_ci kTests[i].it_condition.GetName(), 272b8021494Sopenharmony_ci mnemonic, 273b8021494Sopenharmony_ci kTests[i].operands_description); 274b8021494Sopenharmony_ci } else { 275b8021494Sopenharmony_ci printf(" // %s %s\n};\n", mnemonic, kTests[i].operands_description); 276b8021494Sopenharmony_ci } 277b8021494Sopenharmony_ci } else { 278b8021494Sopenharmony_ci // Check we've emitted the exact same encoding as present in the 279b8021494Sopenharmony_ci // trace file. Only print up to `kErrorReportLimit` errors. 280b8021494Sopenharmony_ci if (((result_size != reference[i].size) || 281b8021494Sopenharmony_ci (memcmp(result_ptr, reference[i].encoding, reference[i].size) != 282b8021494Sopenharmony_ci 0)) && 283b8021494Sopenharmony_ci (++total_error_count <= kErrorReportLimit)) { 284b8021494Sopenharmony_ci printf("Error when testing \"%s\" with operands \"%s\":\n", 285b8021494Sopenharmony_ci mnemonic, 286b8021494Sopenharmony_ci kTests[i].operands_description); 287b8021494Sopenharmony_ci printf(" Expected: "); 288b8021494Sopenharmony_ci for (uint32_t j = 0; j < reference[i].size; j++) { 289b8021494Sopenharmony_ci if (j == 0) { 290b8021494Sopenharmony_ci printf("0x%02" PRIx8, reference[i].encoding[j]); 291b8021494Sopenharmony_ci } else { 292b8021494Sopenharmony_ci printf(", 0x%02" PRIx8, reference[i].encoding[j]); 293b8021494Sopenharmony_ci } 294b8021494Sopenharmony_ci } 295b8021494Sopenharmony_ci printf("\n"); 296b8021494Sopenharmony_ci printf(" Found: "); 297b8021494Sopenharmony_ci for (uint32_t j = 0; j < result_size; j++) { 298b8021494Sopenharmony_ci if (j == 0) { 299b8021494Sopenharmony_ci printf("0x%02" PRIx8, result_ptr[j]); 300b8021494Sopenharmony_ci } else { 301b8021494Sopenharmony_ci printf(", 0x%02" PRIx8, result_ptr[j]); 302b8021494Sopenharmony_ci } 303b8021494Sopenharmony_ci } 304b8021494Sopenharmony_ci printf("\n"); 305b8021494Sopenharmony_ci } 306b8021494Sopenharmony_ci } 307b8021494Sopenharmony_ci } 308b8021494Sopenharmony_ci 309b8021494Sopenharmony_ci masm.FinalizeCode(); 310b8021494Sopenharmony_ci 311b8021494Sopenharmony_ci if (Test::generate_test_trace()) { 312b8021494Sopenharmony_ci // Finalize the trace file by writing the final `TestResult` array 313b8021494Sopenharmony_ci // which links all generated instruction encodings. 314b8021494Sopenharmony_ci printf("const TestResult kReference%s[] = {\n", mnemonic); 315b8021494Sopenharmony_ci for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) { 316b8021494Sopenharmony_ci printf(" {\n"); 317b8021494Sopenharmony_ci printf(" ARRAY_SIZE(kInstruction_%s_%s),\n", 318b8021494Sopenharmony_ci mnemonic, 319b8021494Sopenharmony_ci kTests[i].identifier); 320b8021494Sopenharmony_ci printf(" kInstruction_%s_%s,\n", mnemonic, kTests[i].identifier); 321b8021494Sopenharmony_ci printf(" },\n"); 322b8021494Sopenharmony_ci } 323b8021494Sopenharmony_ci printf("};\n"); 324b8021494Sopenharmony_ci } else { 325b8021494Sopenharmony_ci if (total_error_count > kErrorReportLimit) { 326b8021494Sopenharmony_ci printf("%u other errors follow.\n", 327b8021494Sopenharmony_ci total_error_count - kErrorReportLimit); 328b8021494Sopenharmony_ci } 329b8021494Sopenharmony_ci // Crash if the test failed. 330b8021494Sopenharmony_ci VIXL_CHECK(total_error_count == 0); 331b8021494Sopenharmony_ci } 332b8021494Sopenharmony_ci} 333b8021494Sopenharmony_ci 334b8021494Sopenharmony_ci// Instantiate tests for each instruction in the list. 335b8021494Sopenharmony_ci#define TEST(mnemonic) \ 336b8021494Sopenharmony_ci void Test_##mnemonic() { \ 337b8021494Sopenharmony_ci TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic); \ 338b8021494Sopenharmony_ci } \ 339b8021494Sopenharmony_ci Test test_##mnemonic( \ 340b8021494Sopenharmony_ci "AARCH32_ASSEMBLER_COND_RD_RN_OPERAND_RM_RN_IS_SP_IN_IT_" \ 341b8021494Sopenharmony_ci "BLOCK_" #mnemonic "_T32", \ 342b8021494Sopenharmony_ci &Test_##mnemonic); 343b8021494Sopenharmony_ciFOREACH_INSTRUCTION(TEST) 344b8021494Sopenharmony_ci#undef TEST 345b8021494Sopenharmony_ci 346b8021494Sopenharmony_ci} // namespace 347b8021494Sopenharmony_ci#endif 348b8021494Sopenharmony_ci 349b8021494Sopenharmony_ci} // namespace aarch32 350b8021494Sopenharmony_ci} // namespace vixl 351