1/* Tests the l.ext{b,h}{s,z} instructions. 2 3 Copyright (C) 2017-2024 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 18# mach: or1k 19# output: report(0x0000007f);\n 20# output: report(0x0000007f);\n 21# output: report(0x00000053);\n 22# output: report(0x00000053);\n 23# output: report(0x0000ff53);\n 24# output: report(0x00000053);\n 25# output: report(0x00001234);\n 26# output: report(0x00000034);\n 27# output: report(0x000000ff);\n 28# output: report(0xffffffff);\n 29# output: report(0x00000080);\n 30# output: report(0xffffff80);\n 31# output: report(0x0000ff80);\n 32# output: report(0xffffff80);\n 33# output: report(0x00007f80);\n 34# output: report(0xffffff80);\n 35# output: report(0x00007fff);\n 36# output: report(0xffffffff);\n 37# output: report(0x0000007f);\n 38# output: report(0x0000007f);\n 39# output: report(0x00000053);\n 40# output: report(0x00000053);\n 41# output: report(0x0000ff53);\n 42# output: report(0x00000053);\n 43# output: report(0x00001234);\n 44# output: report(0x00000034);\n 45# output: report(0x000000ff);\n 46# output: report(0x000000ff);\n 47# output: report(0x00000080);\n 48# output: report(0x00000080);\n 49# output: report(0x0000ff80);\n 50# output: report(0x00000080);\n 51# output: report(0x00007f80);\n 52# output: report(0x00000080);\n 53# output: report(0x00007fff);\n 54# output: report(0x000000ff);\n 55# output: report(0x00007fff);\n 56# output: report(0x00007fff);\n 57# output: report(0x00005233);\n 58# output: report(0x00005233);\n 59# output: report(0xffff2f53);\n 60# output: report(0x00002f53);\n 61# output: report(0x12345678);\n 62# output: report(0x00005678);\n 63# output: report(0x0000ffff);\n 64# output: report(0xffffffff);\n 65# output: report(0x00008000);\n 66# output: report(0xffff8000);\n 67# output: report(0x0000ff80);\n 68# output: report(0xffffff80);\n 69# output: report(0x80008000);\n 70# output: report(0xffff8000);\n 71# output: report(0x7fffffff);\n 72# output: report(0xffffffff);\n 73# output: report(0x00007fff);\n 74# output: report(0x00007fff);\n 75# output: report(0x00005233);\n 76# output: report(0x00005233);\n 77# output: report(0xffff2f53);\n 78# output: report(0x00002f53);\n 79# output: report(0x12345678);\n 80# output: report(0x00005678);\n 81# output: report(0x0000ffff);\n 82# output: report(0x0000ffff);\n 83# output: report(0x00008000);\n 84# output: report(0x00008000);\n 85# output: report(0x0000ff80);\n 86# output: report(0x0000ff80);\n 87# output: report(0x80008000);\n 88# output: report(0x00008000);\n 89# output: report(0x7fffffff);\n 90# output: report(0x0000ffff);\n 91# output: report(0xffffffff);\n 92# output: report(0xffffffff);\n 93# output: report(0x7fffffff);\n 94# output: report(0x7fffffff);\n 95# output: report(0x7fff7fff);\n 96# output: report(0x7fff7fff);\n 97# output: report(0xffff7f7f);\n 98# output: report(0xffff7f7f);\n 99# output: report(0xffffff7f);\n 100# output: report(0xffffff7f);\n 101# output: report(0xffff7fff);\n 102# output: report(0xffff7fff);\n 103# output: report(0x7fff7f7f);\n 104# output: report(0x7fff7f7f);\n 105# output: report(0x12345678);\n 106# output: report(0x12345678);\n 107# output: report(0xffffffff);\n 108# output: report(0xffffffff);\n 109# output: report(0x7fffffff);\n 110# output: report(0x7fffffff);\n 111# output: report(0x7fff7fff);\n 112# output: report(0x7fff7fff);\n 113# output: report(0xffff7f7f);\n 114# output: report(0xffff7f7f);\n 115# output: report(0xffffff7f);\n 116# output: report(0xffffff7f);\n 117# output: report(0xffff7fff);\n 118# output: report(0xffff7fff);\n 119# output: report(0x7fff7f7f);\n 120# output: report(0x7fff7f7f);\n 121# output: report(0x12345678);\n 122# output: report(0x12345678);\n 123# output: exit(0)\n 124 125#include "or1k-asm-test-env.h" 126 127 .macro CHECK_EXT insn, val, mask, high_mask 128 LOAD_IMMEDIATE r4, \val 129 REPORT_REG_TO_CONSOLE r4 130 \insn r5, r4 131 REPORT_REG_TO_CONSOLE r5 132 LOAD_IMMEDIATE r6, \mask 133 l.xori r7, r6, -1 134 l.and r8, r4, r6 135 l.and r9, r5, r6 136 l.sfne r8, r9 137 OR1K_DELAYED_NOP (l.bf ext_fail) 138 l.and r8, r5, r7 139 LOAD_IMMEDIATE r7, \high_mask 140 l.sfne r8, r7 141 OR1K_DELAYED_NOP (l.bf ext_fail) 142 .endm 143 144#define CHECK_HIGH3_CLEAR(insn, val) CHECK_EXT insn, val, 0x000000ff, 0 145#define CHECK_HIGH3_SET(val) CHECK_EXT l.extbs, val, 0x000000ff, 0xffffff00 146#define CHECK_HIGH2_CLEAR(insn, val) CHECK_EXT insn, val, 0x0000ffff, 0 147#define CHECK_HIGH2_SET(val) CHECK_EXT l.exths, val, 0x0000ffff, 0xffff0000 148 149 .macro CHECK_MOVE insn, val 150 LOAD_IMMEDIATE r4, \val 151 REPORT_REG_TO_CONSOLE r4 152 \insn r5, r4 153 REPORT_REG_TO_CONSOLE r5 154 l.sfne r5, r4 155 OR1K_DELAYED_NOP (l.bf ext_fail) 156 .endm 157 158 STANDARD_TEST_ENVIRONMENT 159 160 .section .text 161start_tests: 162 PUSH LINK_REGISTER_R9 163 164 /* Test l.extbs */ 165 CHECK_HIGH3_CLEAR ( l.extbs, 0x7f ) 166 CHECK_HIGH3_CLEAR ( l.extbs, 0x53 ) 167 CHECK_HIGH3_CLEAR ( l.extbs, 0xff53 ) 168 CHECK_HIGH3_CLEAR ( l.extbs, 0x1234 ) 169 170 CHECK_HIGH3_SET (0xff) 171 CHECK_HIGH3_SET (0x80) 172 CHECK_HIGH3_SET (0xff80) 173 CHECK_HIGH3_SET (0x7f80) 174 CHECK_HIGH3_SET (0x7fff) 175 176 /* Test l.extbz */ 177 CHECK_HIGH3_CLEAR (l.extbz, 0x7f) 178 CHECK_HIGH3_CLEAR (l.extbz, 0x53) 179 CHECK_HIGH3_CLEAR (l.extbz, 0xff53) 180 CHECK_HIGH3_CLEAR (l.extbz, 0x1234) 181 182 CHECK_HIGH3_CLEAR (l.extbz, 0xff) 183 CHECK_HIGH3_CLEAR (l.extbz, 0x80) 184 CHECK_HIGH3_CLEAR (l.extbz, 0xff80) 185 CHECK_HIGH3_CLEAR (l.extbz, 0x7f80) 186 CHECK_HIGH3_CLEAR (l.extbz, 0x7fff) 187 188 /* Test l.exths */ 189 CHECK_HIGH2_CLEAR (l.exths, 0x7fff) 190 CHECK_HIGH2_CLEAR (l.exths, 0x5233) 191 CHECK_HIGH2_CLEAR (l.exths, 0xffff2f53) 192 CHECK_HIGH2_CLEAR (l.exths, 0x12345678) 193 194 CHECK_HIGH2_SET (0xffff) 195 CHECK_HIGH2_SET (0x8000) 196 CHECK_HIGH2_SET (0xff80) 197 CHECK_HIGH2_SET (0x80008000) 198 CHECK_HIGH2_SET (0x7fffffff) 199 200 /* Test l.exthz */ 201 CHECK_HIGH2_CLEAR (l.exthz, 0x7fff) 202 CHECK_HIGH2_CLEAR (l.exthz, 0x5233) 203 CHECK_HIGH2_CLEAR (l.exthz, 0xffff2f53) 204 CHECK_HIGH2_CLEAR (l.exthz, 0x12345678) 205 206 CHECK_HIGH2_CLEAR (l.exthz, 0xffff) 207 CHECK_HIGH2_CLEAR (l.exthz, 0x8000) 208 CHECK_HIGH2_CLEAR (l.exthz, 0xff80) 209 CHECK_HIGH2_CLEAR (l.exthz, 0x80008000) 210 CHECK_HIGH2_CLEAR (l.exthz, 0x7fffffff) 211 212 /* Test l.extws */ 213 CHECK_MOVE l.extws, 0xffffffff 214 CHECK_MOVE l.extws, 0x7fffffff 215 CHECK_MOVE l.extws, 0x7fff7fff 216 CHECK_MOVE l.extws, 0xffff7f7f 217 CHECK_MOVE l.extws, 0xffffff7f 218 CHECK_MOVE l.extws, 0xffff7fff 219 CHECK_MOVE l.extws, 0x7fff7f7f 220 CHECK_MOVE l.extws, 0x12345678 221 222 /* Test l.extwz */ 223 CHECK_MOVE l.extwz, 0xffffffff 224 CHECK_MOVE l.extwz, 0x7fffffff 225 CHECK_MOVE l.extwz, 0x7fff7fff 226 CHECK_MOVE l.extwz, 0xffff7f7f 227 CHECK_MOVE l.extwz, 0xffffff7f 228 CHECK_MOVE l.extwz, 0xffff7fff 229 CHECK_MOVE l.extwz, 0x7fff7f7f 230 CHECK_MOVE l.extwz, 0x12345678 231 232 POP LINK_REGISTER_R9 233 RETURN_TO_LINK_REGISTER_R9 234 235ext_fail: 236 EXIT_SIMULATION_WITH_IMMEDIATE_EXIT_CODE SEC_GENERIC_ERROR 237