3 # Copyright (c) 2019 Linaro, Ltd
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
10 # This library 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 GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 # This file is processed by scripts/decodetree.py
23 &s_rrr_shi !extern s rd rn rm shim shty
24 &s_rrr_shr !extern s rn rd rm rs shty
25 &s_rri_rot !extern s rn rd imm rot
26 &s_rrrr !extern s rd rn rm ra
27 &rrr_rot !extern rd rn rm rot
31 &ldst_rr !extern p w u rn rt rm shimm shtype
32 &ldst_ri !extern p w u rn rt imm
33 &ldst_block !extern rn i b u w list
35 &cps !extern mode imod M A I F
37 # Set S if the instruction is outside of an IT block.
38 %s !function=t16_setflags
40 # Data-processing (two low registers)
44 @lll_noshr ...... .... rm:3 rd:3 \
45 &s_rrr_shi %s rn=%reg_0 shim=0 shty=0
46 @xll_noshr ...... .... rm:3 rn:3 \
47 &s_rrr_shi s=1 rd=0 shim=0 shty=0
48 @lxl_shr ...... .... rs:3 rd:3 \
49 &s_rrr_shr %s rm=%reg_0 rn=0
51 AND_rrri 010000 0000 ... ... @lll_noshr
52 EOR_rrri 010000 0001 ... ... @lll_noshr
53 MOV_rxrr 010000 0010 ... ... @lxl_shr shty=0 # LSL
54 MOV_rxrr 010000 0011 ... ... @lxl_shr shty=1 # LSR
55 MOV_rxrr 010000 0100 ... ... @lxl_shr shty=2 # ASR
56 ADC_rrri 010000 0101 ... ... @lll_noshr
57 SBC_rrri 010000 0110 ... ... @lll_noshr
58 MOV_rxrr 010000 0111 ... ... @lxl_shr shty=3 # ROR
59 TST_xrri 010000 1000 ... ... @xll_noshr
60 RSB_rri 010000 1001 rn:3 rd:3 &s_rri_rot %s imm=0 rot=0
61 CMP_xrri 010000 1010 ... ... @xll_noshr
62 CMN_xrri 010000 1011 ... ... @xll_noshr
63 ORR_rrri 010000 1100 ... ... @lll_noshr
64 MUL 010000 1101 rn:3 rd:3 &s_rrrr %s rm=%reg_0 ra=0
65 BIC_rrri 010000 1110 ... ... @lll_noshr
66 MVN_rxri 010000 1111 ... ... @lll_noshr
68 # Load/store (register offset)
70 @ldst_rr ....... rm:3 rn:3 rt:3 \
71 &ldst_rr p=1 w=0 u=1 shimm=0 shtype=0
73 STR_rr 0101 000 ... ... ... @ldst_rr
74 STRH_rr 0101 001 ... ... ... @ldst_rr
75 STRB_rr 0101 010 ... ... ... @ldst_rr
76 LDRSB_rr 0101 011 ... ... ... @ldst_rr
77 LDR_rr 0101 100 ... ... ... @ldst_rr
78 LDRH_rr 0101 101 ... ... ... @ldst_rr
79 LDRB_rr 0101 110 ... ... ... @ldst_rr
80 LDRSH_rr 0101 111 ... ... ... @ldst_rr
82 # Load/store word/byte (immediate offset)
84 %imm5_6x4 6:5 !function=times_4
86 @ldst_ri_1 ..... imm:5 rn:3 rt:3 \
88 @ldst_ri_4 ..... ..... rn:3 rt:3 \
89 &ldst_ri p=1 w=0 u=1 imm=%imm5_6x4
91 STR_ri 01100 ..... ... ... @ldst_ri_4
92 LDR_ri 01101 ..... ... ... @ldst_ri_4
93 STRB_ri 01110 ..... ... ... @ldst_ri_1
94 LDRB_ri 01111 ..... ... ... @ldst_ri_1
96 # Load/store halfword (immediate offset)
98 %imm5_6x2 6:5 !function=times_2
99 @ldst_ri_2 ..... ..... rn:3 rt:3 \
100 &ldst_ri p=1 w=0 u=1 imm=%imm5_6x2
102 STRH_ri 10000 ..... ... ... @ldst_ri_2
103 LDRH_ri 10001 ..... ... ... @ldst_ri_2
105 # Load/store (SP-relative)
107 %imm8_0x4 0:8 !function=times_4
108 @ldst_spec_i ..... rt:3 ........ \
109 &ldst_ri p=1 w=0 u=1 imm=%imm8_0x4
111 STR_ri 10010 ... ........ @ldst_spec_i rn=13
112 LDR_ri 10011 ... ........ @ldst_spec_i rn=13
114 # Add PC/SP (immediate)
116 ADR 10100 rd:3 ........ imm=%imm8_0x4
117 ADD_rri 10101 rd:3 ........ \
118 &s_rri_rot rn=13 s=0 rot=0 imm=%imm8_0x4 # SP
120 # Load/store multiple
122 @ldstm ..... rn:3 list:8 &ldst_block i=1 b=0 u=0 w=1
124 STM 11000 ... ........ @ldstm
125 LDM_t16 11001 ... ........ @ldstm
127 # Add/subtract (three low registers)
129 @addsub_3 ....... rm:3 rn:3 rd:3 \
130 &s_rrr_shi %s shim=0 shty=0
132 ADD_rrri 0001100 ... ... ... @addsub_3
133 SUB_rrri 0001101 ... ... ... @addsub_3
135 # Add/subtract (two low registers and immediate)
137 @addsub_2i ....... imm:3 rn:3 rd:3 \
140 ADD_rri 0001 110 ... ... ... @addsub_2i
141 SUB_rri 0001 111 ... ... ... @addsub_2i
143 # Add, subtract, compare, move (one low register and immediate)
146 @arith_1i ..... rd:3 imm:8 \
147 &s_rri_rot rot=0 rn=%reg_8
149 MOV_rxi 00100 ... ........ @arith_1i %s
150 CMP_xri 00101 ... ........ @arith_1i s=1
151 ADD_rri 00110 ... ........ @arith_1i %s
152 SUB_rri 00111 ... ........ @arith_1i %s
154 # Add, compare, move (two high registers)
157 @addsub_2h .... .... . rm:4 ... \
158 &s_rrr_shi rd=%reg_0_7 rn=%reg_0_7 shim=0 shty=0
160 ADD_rrri 0100 0100 . .... ... @addsub_2h s=0
161 CMP_xrri 0100 0101 . .... ... @addsub_2h s=1
162 MOV_rxri 0100 0110 . .... ... @addsub_2h s=0
164 # Adjust SP (immediate)
166 %imm7_0x4 0:7 !function=times_4
167 @addsub_sp_i .... .... . ....... \
168 &s_rri_rot s=0 rd=13 rn=13 rot=0 imm=%imm7_0x4
170 ADD_rri 1011 0000 0 ....... @addsub_sp_i
171 SUB_rri 1011 0000 1 ....... @addsub_sp_i
173 # Branch and exchange
175 @branchr .... .... . rm:4 ... &r
177 BX 0100 0111 0 .... 000 @branchr
178 BLX_r 0100 0111 1 .... 000 @branchr
179 BXNS 0100 0111 0 .... 100 @branchr
180 BLXNS 0100 0111 1 .... 100 @branchr
184 @extend .... .... .. rm:3 rd:3 &rrr_rot rn=15 rot=0
186 SXTAH 1011 0010 00 ... ... @extend
187 SXTAB 1011 0010 01 ... ... @extend
188 UXTAH 1011 0010 10 ... ... @extend
189 UXTAB 1011 0010 11 ... ... @extend
191 # Change processor state
193 %imod 4:1 !function=plus_2
195 SETEND 1011 0110 010 1 E:1 000 &setend
197 CPS 1011 0110 011 . 0 A:1 I:1 F:1 &cps mode=0 M=0 %imod
198 CPS_v7m 1011 0110 011 im:1 00 I:1 F:1
203 @rdm .... .... .. rm:3 rd:3 &rr
205 REV 1011 1010 00 ... ... @rdm
206 REV16 1011 1010 01 ... ... @rdm
207 REVSH 1011 1010 11 ... ... @rdm
212 YIELD 1011 1111 0001 0000
213 WFE 1011 1111 0010 0000
214 WFI 1011 1111 0011 0000
216 # TODO: Implement SEV, SEVL; may help SMP performance.
217 # SEV 1011 1111 0100 0000
218 # SEVL 1011 1111 0101 0000
220 # The canonical nop has the second nibble as 0000, but the whole of the
221 # rest of the space is a reserved hint, behaves as nop.
222 NOP 1011 1111 ---- 0000