1 /* bitfield-bfm.s Test file for AArch64 bitfield instructions
2 sbfm, bfm and ubfm mnemonics.
4 Copyright (C) 2011-2014 Free Software Foundation, Inc.
5 Contributed by ARM Ltd.
7 This file is part of GAS.
9 GAS is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the license, or
12 (at your option) any later version.
14 GAS is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; see the file COPYING3. If not,
21 see <http://www.gnu.org/licenses/>. */
23 /* This file tests the GAS's ability in assembling sbfm, bfm and ubfm
24 instructions. Disassembler should use alias mnemonics to display
25 {[u|s]}bfm instructions. bitfield-bfm.s and bitfield-alias.s will be
26 assembled into idential binary, which is why the two tests share the
27 same dump match file 'bitfield-dump'. */
39 // <op> <Wd>, <Wn>, #<shift>
40 .macro bf_32s op, shift
44 // <op> <Xd>, <Xn>, #<shift>
45 .macro bf_64s op, shift
50 .macro op_bfm signed, reg, immr, imms
51 \signed\()bfm \reg\()zr, \reg\()7, #\immr, #\imms // e.g. sbfm xzr, x7, #0, #15
54 .macro ext2bfm signed, reg, imms
55 op_bfm signed=\signed, reg=\reg, immr=0, imms=\imms
59 .macro sr2bfm signed, reg, shift, imms
60 op_bfm signed=\signed, reg=\reg, immr=\shift, imms=\imms
64 .macro sl2bfm signed, reg, shift
66 op_bfm signed=\signed, reg=\reg, immr="((32-\shift)&31)", imms="(31-\shift)"
68 op_bfm signed=\signed, reg=\reg, immr="((64-\shift)&63)", imms="(63-\shift)"
72 // bitfield insert -> bfm
73 .macro ins2bfm signed, reg, lsb, width
75 op_bfm signed=\signed, reg=\reg, immr="((32-\lsb)&31)", imms="(\width-1)"
77 op_bfm signed=\signed, reg=\reg, immr="((64-\lsb)&63)", imms="(\width-1)"
81 // bitfield extract -> bfm
82 .macro x2bfm signed, reg, lsb, width
83 op_bfm signed=\signed, reg=\reg, immr=\lsb, imms="(\lsb+\width-1)"
91 ext2bfm s, w, 7 // sxtb wzr, w7
92 ext2bfm s, x, 7 // sxtb xzr, x7
93 ext2bfm s, w, 15 // sxth wzr, w7
94 ext2bfm s, x, 15 // sxth xzr, x7
95 ext2bfm s, x, 31 // sxtw xzr, x7
97 ext2bfm u, w, 7 // uxtb wzr, w7
98 ext2bfm u, w, 7 // uxtb xzr, w7
99 ext2bfm u, w, 15 // uxth wzr, w7
100 ext2bfm u, w, 15 // uxth xzr, w7
101 orr wzr, wzr, w7 // uxtw wzr, w7
102 orr wzr, wzr, w7 // uxtw wzr, w7
108 .irp shift 0, 16, 31 // asr wzr, w7, #\shift
109 sr2bfm s, w, \shift, 31
112 .irp shift 0, 31, 63 // asr xzr, x7, #\shift
113 sr2bfm s, x, \shift, 63
116 .irp shift 0, 16, 31 // lsr wzr, w7, #\shift
117 sr2bfm u, w, \shift, 31
120 .irp shift 0, 31, 63 // lsr xzr, x7, #\shift
121 sr2bfm u, x, \shift, 63
124 .irp shift 0, 16, 31 // lsl wzr, w7, #\shift
128 .irp shift 0, 31, 63 // lsl xzr, x7, #\shift
133 * aliasing insert and extract
137 .irp whichm, ins2bfm, x2bfm
138 \whichm \signed, w, 0, 1
139 \whichm \signed, w, 0, 16
140 \whichm \signed, w, 0, 32
141 \whichm \signed, w, 16, 1
142 \whichm \signed, w, 16, 8
143 \whichm \signed, w, 16, 16
144 \whichm \signed, w, 31, 1
146 \whichm \signed, x, 0, 1
147 \whichm \signed, x, 0, 32
148 \whichm \signed, x, 0, 64
149 \whichm \signed, x, 32, 1
150 \whichm \signed, x, 32, 16
151 \whichm \signed, x, 32, 32
152 \whichm \signed, x, 63, 1