root / target-alpha / translate.c @ f9d43072
History | View | Annotate | Download (57.9 kB)
1 | 4c9649a9 | j_mayer | /*
|
---|---|---|---|
2 | 4c9649a9 | j_mayer | * Alpha emulation cpu translation for qemu.
|
3 | 5fafdf24 | ths | *
|
4 | 4c9649a9 | j_mayer | * Copyright (c) 2007 Jocelyn Mayer
|
5 | 4c9649a9 | j_mayer | *
|
6 | 4c9649a9 | j_mayer | * This library is free software; you can redistribute it and/or
|
7 | 4c9649a9 | j_mayer | * modify it under the terms of the GNU Lesser General Public
|
8 | 4c9649a9 | j_mayer | * License as published by the Free Software Foundation; either
|
9 | 4c9649a9 | j_mayer | * version 2 of the License, or (at your option) any later version.
|
10 | 4c9649a9 | j_mayer | *
|
11 | 4c9649a9 | j_mayer | * This library is distributed in the hope that it will be useful,
|
12 | 4c9649a9 | j_mayer | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 4c9649a9 | j_mayer | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 4c9649a9 | j_mayer | * Lesser General Public License for more details.
|
15 | 4c9649a9 | j_mayer | *
|
16 | 4c9649a9 | j_mayer | * You should have received a copy of the GNU Lesser General Public
|
17 | 4c9649a9 | j_mayer | * License along with this library; if not, write to the Free Software
|
18 | 4c9649a9 | j_mayer | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 4c9649a9 | j_mayer | */
|
20 | 4c9649a9 | j_mayer | |
21 | 4c9649a9 | j_mayer | #include <stdint.h> |
22 | 4c9649a9 | j_mayer | #include <stdlib.h> |
23 | 4c9649a9 | j_mayer | #include <stdio.h> |
24 | 4c9649a9 | j_mayer | |
25 | 4c9649a9 | j_mayer | #include "cpu.h" |
26 | 4c9649a9 | j_mayer | #include "exec-all.h" |
27 | 4c9649a9 | j_mayer | #include "disas.h" |
28 | 4c9649a9 | j_mayer | |
29 | 4c9649a9 | j_mayer | #define DO_SINGLE_STEP
|
30 | 4c9649a9 | j_mayer | #define GENERATE_NOP
|
31 | 4c9649a9 | j_mayer | #define ALPHA_DEBUG_DISAS
|
32 | 4c9649a9 | j_mayer | #define DO_TB_FLUSH
|
33 | 4c9649a9 | j_mayer | |
34 | 4c9649a9 | j_mayer | typedef struct DisasContext DisasContext; |
35 | 4c9649a9 | j_mayer | struct DisasContext {
|
36 | 4c9649a9 | j_mayer | uint64_t pc; |
37 | 4c9649a9 | j_mayer | int mem_idx;
|
38 | 4c9649a9 | j_mayer | #if !defined (CONFIG_USER_ONLY)
|
39 | 4c9649a9 | j_mayer | int pal_mode;
|
40 | 4c9649a9 | j_mayer | #endif
|
41 | 4c9649a9 | j_mayer | uint32_t amask; |
42 | 4c9649a9 | j_mayer | }; |
43 | 4c9649a9 | j_mayer | |
44 | 4c9649a9 | j_mayer | #ifdef USE_DIRECT_JUMP
|
45 | 4c9649a9 | j_mayer | #define TBPARAM(x)
|
46 | 4c9649a9 | j_mayer | #else
|
47 | 4c9649a9 | j_mayer | #define TBPARAM(x) (long)(x) |
48 | 4c9649a9 | j_mayer | #endif
|
49 | 4c9649a9 | j_mayer | |
50 | 4c9649a9 | j_mayer | enum {
|
51 | 4c9649a9 | j_mayer | #define DEF(s, n, copy_size) INDEX_op_ ## s, |
52 | 4c9649a9 | j_mayer | #include "opc.h" |
53 | 4c9649a9 | j_mayer | #undef DEF
|
54 | 4c9649a9 | j_mayer | NB_OPS, |
55 | 4c9649a9 | j_mayer | }; |
56 | 4c9649a9 | j_mayer | |
57 | 4c9649a9 | j_mayer | static uint16_t *gen_opc_ptr;
|
58 | 4c9649a9 | j_mayer | static uint32_t *gen_opparam_ptr;
|
59 | 4c9649a9 | j_mayer | |
60 | 4c9649a9 | j_mayer | #include "gen-op.h" |
61 | 4c9649a9 | j_mayer | |
62 | f071b4d3 | j_mayer | static always_inline void gen_op_nop (void) |
63 | 4c9649a9 | j_mayer | { |
64 | 4c9649a9 | j_mayer | #if defined(GENERATE_NOP)
|
65 | 4c9649a9 | j_mayer | gen_op_no_op(); |
66 | 4c9649a9 | j_mayer | #endif
|
67 | 4c9649a9 | j_mayer | } |
68 | 4c9649a9 | j_mayer | |
69 | 4c9649a9 | j_mayer | #define GEN32(func, NAME) \
|
70 | 4c9649a9 | j_mayer | static GenOpFunc *NAME ## _table [32] = { \ |
71 | 4c9649a9 | j_mayer | NAME ## 0, NAME ## 1, NAME ## 2, NAME ## 3, \ |
72 | 4c9649a9 | j_mayer | NAME ## 4, NAME ## 5, NAME ## 6, NAME ## 7, \ |
73 | 4c9649a9 | j_mayer | NAME ## 8, NAME ## 9, NAME ## 10, NAME ## 11, \ |
74 | 4c9649a9 | j_mayer | NAME ## 12, NAME ## 13, NAME ## 14, NAME ## 15, \ |
75 | 4c9649a9 | j_mayer | NAME ## 16, NAME ## 17, NAME ## 18, NAME ## 19, \ |
76 | 4c9649a9 | j_mayer | NAME ## 20, NAME ## 21, NAME ## 22, NAME ## 23, \ |
77 | 4c9649a9 | j_mayer | NAME ## 24, NAME ## 25, NAME ## 26, NAME ## 27, \ |
78 | 4c9649a9 | j_mayer | NAME ## 28, NAME ## 29, NAME ## 30, NAME ## 31, \ |
79 | 4c9649a9 | j_mayer | }; \ |
80 | f071b4d3 | j_mayer | static always_inline void func (int n) \ |
81 | 4c9649a9 | j_mayer | { \ |
82 | 4c9649a9 | j_mayer | NAME ## _table[n](); \ |
83 | 4c9649a9 | j_mayer | } |
84 | 4c9649a9 | j_mayer | |
85 | 4c9649a9 | j_mayer | /* IR moves */
|
86 | 4c9649a9 | j_mayer | /* Special hacks for ir31 */
|
87 | 4c9649a9 | j_mayer | #define gen_op_load_T0_ir31 gen_op_reset_T0
|
88 | 4c9649a9 | j_mayer | #define gen_op_load_T1_ir31 gen_op_reset_T1
|
89 | 4c9649a9 | j_mayer | #define gen_op_load_T2_ir31 gen_op_reset_T2
|
90 | 4c9649a9 | j_mayer | #define gen_op_store_T0_ir31 gen_op_nop
|
91 | 4c9649a9 | j_mayer | #define gen_op_store_T1_ir31 gen_op_nop
|
92 | 4c9649a9 | j_mayer | #define gen_op_store_T2_ir31 gen_op_nop
|
93 | 4c9649a9 | j_mayer | #define gen_op_cmov_ir31 gen_op_nop
|
94 | 4c9649a9 | j_mayer | GEN32(gen_op_load_T0_ir, gen_op_load_T0_ir); |
95 | 4c9649a9 | j_mayer | GEN32(gen_op_load_T1_ir, gen_op_load_T1_ir); |
96 | 4c9649a9 | j_mayer | GEN32(gen_op_load_T2_ir, gen_op_load_T2_ir); |
97 | 4c9649a9 | j_mayer | GEN32(gen_op_store_T0_ir, gen_op_store_T0_ir); |
98 | 4c9649a9 | j_mayer | GEN32(gen_op_store_T1_ir, gen_op_store_T1_ir); |
99 | 4c9649a9 | j_mayer | GEN32(gen_op_store_T2_ir, gen_op_store_T2_ir); |
100 | 4c9649a9 | j_mayer | GEN32(gen_op_cmov_ir, gen_op_cmov_ir); |
101 | 4c9649a9 | j_mayer | |
102 | f071b4d3 | j_mayer | static always_inline void gen_load_ir (DisasContext *ctx, int irn, int Tn) |
103 | 4c9649a9 | j_mayer | { |
104 | 4c9649a9 | j_mayer | switch (Tn) {
|
105 | 4c9649a9 | j_mayer | case 0: |
106 | 4c9649a9 | j_mayer | gen_op_load_T0_ir(irn); |
107 | 4c9649a9 | j_mayer | break;
|
108 | 4c9649a9 | j_mayer | case 1: |
109 | 4c9649a9 | j_mayer | gen_op_load_T1_ir(irn); |
110 | 4c9649a9 | j_mayer | break;
|
111 | 4c9649a9 | j_mayer | case 2: |
112 | 4c9649a9 | j_mayer | gen_op_load_T2_ir(irn); |
113 | 4c9649a9 | j_mayer | break;
|
114 | 4c9649a9 | j_mayer | } |
115 | 4c9649a9 | j_mayer | } |
116 | 4c9649a9 | j_mayer | |
117 | f071b4d3 | j_mayer | static always_inline void gen_store_ir (DisasContext *ctx, int irn, int Tn) |
118 | 4c9649a9 | j_mayer | { |
119 | 4c9649a9 | j_mayer | switch (Tn) {
|
120 | 4c9649a9 | j_mayer | case 0: |
121 | 4c9649a9 | j_mayer | gen_op_store_T0_ir(irn); |
122 | 4c9649a9 | j_mayer | break;
|
123 | 4c9649a9 | j_mayer | case 1: |
124 | 4c9649a9 | j_mayer | gen_op_store_T1_ir(irn); |
125 | 4c9649a9 | j_mayer | break;
|
126 | 4c9649a9 | j_mayer | case 2: |
127 | 4c9649a9 | j_mayer | gen_op_store_T2_ir(irn); |
128 | 4c9649a9 | j_mayer | break;
|
129 | 4c9649a9 | j_mayer | } |
130 | 4c9649a9 | j_mayer | } |
131 | 4c9649a9 | j_mayer | |
132 | 4c9649a9 | j_mayer | /* FIR moves */
|
133 | 4c9649a9 | j_mayer | /* Special hacks for fir31 */
|
134 | 4c9649a9 | j_mayer | #define gen_op_load_FT0_fir31 gen_op_reset_FT0
|
135 | 4c9649a9 | j_mayer | #define gen_op_load_FT1_fir31 gen_op_reset_FT1
|
136 | 4c9649a9 | j_mayer | #define gen_op_load_FT2_fir31 gen_op_reset_FT2
|
137 | 4c9649a9 | j_mayer | #define gen_op_store_FT0_fir31 gen_op_nop
|
138 | 4c9649a9 | j_mayer | #define gen_op_store_FT1_fir31 gen_op_nop
|
139 | 4c9649a9 | j_mayer | #define gen_op_store_FT2_fir31 gen_op_nop
|
140 | 4c9649a9 | j_mayer | #define gen_op_cmov_fir31 gen_op_nop
|
141 | 4c9649a9 | j_mayer | GEN32(gen_op_load_FT0_fir, gen_op_load_FT0_fir); |
142 | 4c9649a9 | j_mayer | GEN32(gen_op_load_FT1_fir, gen_op_load_FT1_fir); |
143 | 4c9649a9 | j_mayer | GEN32(gen_op_load_FT2_fir, gen_op_load_FT2_fir); |
144 | 4c9649a9 | j_mayer | GEN32(gen_op_store_FT0_fir, gen_op_store_FT0_fir); |
145 | 4c9649a9 | j_mayer | GEN32(gen_op_store_FT1_fir, gen_op_store_FT1_fir); |
146 | 4c9649a9 | j_mayer | GEN32(gen_op_store_FT2_fir, gen_op_store_FT2_fir); |
147 | 4c9649a9 | j_mayer | GEN32(gen_op_cmov_fir, gen_op_cmov_fir); |
148 | 4c9649a9 | j_mayer | |
149 | f071b4d3 | j_mayer | static always_inline void gen_load_fir (DisasContext *ctx, int firn, int Tn) |
150 | 4c9649a9 | j_mayer | { |
151 | 4c9649a9 | j_mayer | switch (Tn) {
|
152 | 4c9649a9 | j_mayer | case 0: |
153 | 4c9649a9 | j_mayer | gen_op_load_FT0_fir(firn); |
154 | 4c9649a9 | j_mayer | break;
|
155 | 4c9649a9 | j_mayer | case 1: |
156 | 4c9649a9 | j_mayer | gen_op_load_FT1_fir(firn); |
157 | 4c9649a9 | j_mayer | break;
|
158 | 4c9649a9 | j_mayer | case 2: |
159 | 4c9649a9 | j_mayer | gen_op_load_FT2_fir(firn); |
160 | 4c9649a9 | j_mayer | break;
|
161 | 4c9649a9 | j_mayer | } |
162 | 4c9649a9 | j_mayer | } |
163 | 4c9649a9 | j_mayer | |
164 | f071b4d3 | j_mayer | static always_inline void gen_store_fir (DisasContext *ctx, int firn, int Tn) |
165 | 4c9649a9 | j_mayer | { |
166 | 4c9649a9 | j_mayer | switch (Tn) {
|
167 | 4c9649a9 | j_mayer | case 0: |
168 | 4c9649a9 | j_mayer | gen_op_store_FT0_fir(firn); |
169 | 4c9649a9 | j_mayer | break;
|
170 | 4c9649a9 | j_mayer | case 1: |
171 | 4c9649a9 | j_mayer | gen_op_store_FT1_fir(firn); |
172 | 4c9649a9 | j_mayer | break;
|
173 | 4c9649a9 | j_mayer | case 2: |
174 | 4c9649a9 | j_mayer | gen_op_store_FT2_fir(firn); |
175 | 4c9649a9 | j_mayer | break;
|
176 | 4c9649a9 | j_mayer | } |
177 | 4c9649a9 | j_mayer | } |
178 | 4c9649a9 | j_mayer | |
179 | 4c9649a9 | j_mayer | /* Memory moves */
|
180 | 4c9649a9 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
181 | 4c9649a9 | j_mayer | #define OP_LD_TABLE(width) \
|
182 | 4c9649a9 | j_mayer | static GenOpFunc *gen_op_ld##width[] = { \ |
183 | 4c9649a9 | j_mayer | &gen_op_ld##width##_raw, \ |
184 | 4c9649a9 | j_mayer | } |
185 | 4c9649a9 | j_mayer | #define OP_ST_TABLE(width) \
|
186 | 4c9649a9 | j_mayer | static GenOpFunc *gen_op_st##width[] = { \ |
187 | 4c9649a9 | j_mayer | &gen_op_st##width##_raw, \ |
188 | 4c9649a9 | j_mayer | } |
189 | 4c9649a9 | j_mayer | #else
|
190 | 4c9649a9 | j_mayer | #define OP_LD_TABLE(width) \
|
191 | 4c9649a9 | j_mayer | static GenOpFunc *gen_op_ld##width[] = { \ |
192 | 4c9649a9 | j_mayer | &gen_op_ld##width##_kernel, \ |
193 | bb6f6792 | j_mayer | &gen_op_ld##width##_executive, \ |
194 | bb6f6792 | j_mayer | &gen_op_ld##width##_supervisor, \ |
195 | bb6f6792 | j_mayer | &gen_op_ld##width##_user, \ |
196 | 4c9649a9 | j_mayer | } |
197 | 4c9649a9 | j_mayer | #define OP_ST_TABLE(width) \
|
198 | 4c9649a9 | j_mayer | static GenOpFunc *gen_op_st##width[] = { \ |
199 | 4c9649a9 | j_mayer | &gen_op_st##width##_kernel, \ |
200 | bb6f6792 | j_mayer | &gen_op_st##width##_executive, \ |
201 | bb6f6792 | j_mayer | &gen_op_st##width##_supervisor, \ |
202 | bb6f6792 | j_mayer | &gen_op_st##width##_user, \ |
203 | 4c9649a9 | j_mayer | } |
204 | 4c9649a9 | j_mayer | #endif
|
205 | 4c9649a9 | j_mayer | |
206 | 4c9649a9 | j_mayer | #define GEN_LD(width) \
|
207 | 4c9649a9 | j_mayer | OP_LD_TABLE(width); \ |
208 | f071b4d3 | j_mayer | static always_inline void gen_ld##width (DisasContext *ctx) \ |
209 | 4c9649a9 | j_mayer | { \ |
210 | 4c9649a9 | j_mayer | (*gen_op_ld##width[ctx->mem_idx])(); \ |
211 | 4c9649a9 | j_mayer | } |
212 | 4c9649a9 | j_mayer | |
213 | 4c9649a9 | j_mayer | #define GEN_ST(width) \
|
214 | 4c9649a9 | j_mayer | OP_ST_TABLE(width); \ |
215 | f071b4d3 | j_mayer | static always_inline void gen_st##width (DisasContext *ctx) \ |
216 | 4c9649a9 | j_mayer | { \ |
217 | 4c9649a9 | j_mayer | (*gen_op_st##width[ctx->mem_idx])(); \ |
218 | 4c9649a9 | j_mayer | } |
219 | 4c9649a9 | j_mayer | |
220 | 4c9649a9 | j_mayer | GEN_LD(bu); |
221 | 4c9649a9 | j_mayer | GEN_ST(b); |
222 | 4c9649a9 | j_mayer | GEN_LD(wu); |
223 | 4c9649a9 | j_mayer | GEN_ST(w); |
224 | 4c9649a9 | j_mayer | GEN_LD(l); |
225 | 4c9649a9 | j_mayer | GEN_ST(l); |
226 | 4c9649a9 | j_mayer | GEN_LD(q); |
227 | 4c9649a9 | j_mayer | GEN_ST(q); |
228 | 4c9649a9 | j_mayer | GEN_LD(q_u); |
229 | 4c9649a9 | j_mayer | GEN_ST(q_u); |
230 | 4c9649a9 | j_mayer | GEN_LD(l_l); |
231 | 4c9649a9 | j_mayer | GEN_ST(l_c); |
232 | 4c9649a9 | j_mayer | GEN_LD(q_l); |
233 | 4c9649a9 | j_mayer | GEN_ST(q_c); |
234 | 4c9649a9 | j_mayer | |
235 | 08ab123c | ths | #if 0 /* currently unused */
|
236 | 4c9649a9 | j_mayer | GEN_LD(f);
|
237 | 4c9649a9 | j_mayer | GEN_ST(f);
|
238 | 4c9649a9 | j_mayer | GEN_LD(g);
|
239 | 4c9649a9 | j_mayer | GEN_ST(g);
|
240 | 08ab123c | ths | #endif /* 0 */
|
241 | 4c9649a9 | j_mayer | GEN_LD(s); |
242 | 4c9649a9 | j_mayer | GEN_ST(s); |
243 | 4c9649a9 | j_mayer | GEN_LD(t); |
244 | 4c9649a9 | j_mayer | GEN_ST(t); |
245 | 4c9649a9 | j_mayer | |
246 | 4c9649a9 | j_mayer | #if defined(__i386__) || defined(__x86_64__)
|
247 | f071b4d3 | j_mayer | static always_inline void gen_op_set_s16_T0 (int16_t imm) |
248 | 4c9649a9 | j_mayer | { |
249 | 4c9649a9 | j_mayer | gen_op_set_s32_T0((int32_t)imm); |
250 | 4c9649a9 | j_mayer | } |
251 | 4c9649a9 | j_mayer | |
252 | f071b4d3 | j_mayer | static always_inline void gen_op_set_s16_T1 (int16_t imm) |
253 | 4c9649a9 | j_mayer | { |
254 | 4c9649a9 | j_mayer | gen_op_set_s32_T1((int32_t)imm); |
255 | 4c9649a9 | j_mayer | } |
256 | 4c9649a9 | j_mayer | |
257 | f071b4d3 | j_mayer | static always_inline void gen_op_set_u16_T0 (uint16_t imm) |
258 | 4c9649a9 | j_mayer | { |
259 | 4c9649a9 | j_mayer | gen_op_set_s32_T0((uint32_t)imm); |
260 | 4c9649a9 | j_mayer | } |
261 | 4c9649a9 | j_mayer | |
262 | f071b4d3 | j_mayer | static always_inline void gen_op_set_u16_T1 (uint16_t imm) |
263 | 4c9649a9 | j_mayer | { |
264 | 4c9649a9 | j_mayer | gen_op_set_s32_T1((uint32_t)imm); |
265 | 4c9649a9 | j_mayer | } |
266 | 4c9649a9 | j_mayer | #endif
|
267 | 4c9649a9 | j_mayer | |
268 | f071b4d3 | j_mayer | static always_inline void gen_set_sT0 (DisasContext *ctx, int64_t imm) |
269 | 4c9649a9 | j_mayer | { |
270 | 4c9649a9 | j_mayer | int32_t imm32; |
271 | 4c9649a9 | j_mayer | int16_t imm16; |
272 | 4c9649a9 | j_mayer | |
273 | 4c9649a9 | j_mayer | imm32 = imm; |
274 | 4c9649a9 | j_mayer | if (imm32 == imm) {
|
275 | 4c9649a9 | j_mayer | imm16 = imm; |
276 | 4c9649a9 | j_mayer | if (imm16 == imm) {
|
277 | 4c9649a9 | j_mayer | if (imm == 0) { |
278 | 4c9649a9 | j_mayer | gen_op_reset_T0(); |
279 | 4c9649a9 | j_mayer | } else {
|
280 | 4c9649a9 | j_mayer | gen_op_set_s16_T0(imm16); |
281 | 4c9649a9 | j_mayer | } |
282 | 4c9649a9 | j_mayer | } else {
|
283 | 4c9649a9 | j_mayer | gen_op_set_s32_T0(imm32); |
284 | 4c9649a9 | j_mayer | } |
285 | 4c9649a9 | j_mayer | } else {
|
286 | 4c9649a9 | j_mayer | #if 0 // Qemu does not know how to do this...
|
287 | 4c9649a9 | j_mayer | gen_op_set_64_T0(imm);
|
288 | 4c9649a9 | j_mayer | #else
|
289 | 4c9649a9 | j_mayer | gen_op_set_64_T0(imm >> 32, imm);
|
290 | 4c9649a9 | j_mayer | #endif
|
291 | 4c9649a9 | j_mayer | } |
292 | 4c9649a9 | j_mayer | } |
293 | 4c9649a9 | j_mayer | |
294 | f071b4d3 | j_mayer | static always_inline void gen_set_sT1 (DisasContext *ctx, int64_t imm) |
295 | 4c9649a9 | j_mayer | { |
296 | 4c9649a9 | j_mayer | int32_t imm32; |
297 | 4c9649a9 | j_mayer | int16_t imm16; |
298 | 4c9649a9 | j_mayer | |
299 | 4c9649a9 | j_mayer | imm32 = imm; |
300 | 4c9649a9 | j_mayer | if (imm32 == imm) {
|
301 | 4c9649a9 | j_mayer | imm16 = imm; |
302 | 4c9649a9 | j_mayer | if (imm16 == imm) {
|
303 | 4c9649a9 | j_mayer | if (imm == 0) { |
304 | 4c9649a9 | j_mayer | gen_op_reset_T1(); |
305 | 4c9649a9 | j_mayer | } else {
|
306 | 4c9649a9 | j_mayer | gen_op_set_s16_T1(imm16); |
307 | 4c9649a9 | j_mayer | } |
308 | 4c9649a9 | j_mayer | } else {
|
309 | 4c9649a9 | j_mayer | gen_op_set_s32_T1(imm32); |
310 | 4c9649a9 | j_mayer | } |
311 | 4c9649a9 | j_mayer | } else {
|
312 | 4c9649a9 | j_mayer | #if 0 // Qemu does not know how to do this...
|
313 | 4c9649a9 | j_mayer | gen_op_set_64_T1(imm);
|
314 | 4c9649a9 | j_mayer | #else
|
315 | 4c9649a9 | j_mayer | gen_op_set_64_T1(imm >> 32, imm);
|
316 | 4c9649a9 | j_mayer | #endif
|
317 | 4c9649a9 | j_mayer | } |
318 | 4c9649a9 | j_mayer | } |
319 | 4c9649a9 | j_mayer | |
320 | f071b4d3 | j_mayer | static always_inline void gen_set_uT0 (DisasContext *ctx, uint64_t imm) |
321 | 4c9649a9 | j_mayer | { |
322 | 4c9649a9 | j_mayer | if (!(imm >> 32)) { |
323 | 4c9649a9 | j_mayer | if ((!imm >> 16)) { |
324 | 4c9649a9 | j_mayer | if (imm == 0) |
325 | 4c9649a9 | j_mayer | gen_op_reset_T0(); |
326 | 4c9649a9 | j_mayer | else
|
327 | 4c9649a9 | j_mayer | gen_op_set_u16_T0(imm); |
328 | 4c9649a9 | j_mayer | } else {
|
329 | 4c9649a9 | j_mayer | gen_op_set_u32_T0(imm); |
330 | 4c9649a9 | j_mayer | } |
331 | 4c9649a9 | j_mayer | } else {
|
332 | 4c9649a9 | j_mayer | #if 0 // Qemu does not know how to do this...
|
333 | 4c9649a9 | j_mayer | gen_op_set_64_T0(imm);
|
334 | 4c9649a9 | j_mayer | #else
|
335 | 4c9649a9 | j_mayer | gen_op_set_64_T0(imm >> 32, imm);
|
336 | 4c9649a9 | j_mayer | #endif
|
337 | 4c9649a9 | j_mayer | } |
338 | 4c9649a9 | j_mayer | } |
339 | 4c9649a9 | j_mayer | |
340 | f071b4d3 | j_mayer | static always_inline void gen_set_uT1 (DisasContext *ctx, uint64_t imm) |
341 | 4c9649a9 | j_mayer | { |
342 | 4c9649a9 | j_mayer | if (!(imm >> 32)) { |
343 | 4c9649a9 | j_mayer | if ((!imm >> 16)) { |
344 | 4c9649a9 | j_mayer | if (imm == 0) |
345 | 4c9649a9 | j_mayer | gen_op_reset_T1(); |
346 | 4c9649a9 | j_mayer | else
|
347 | 4c9649a9 | j_mayer | gen_op_set_u16_T1(imm); |
348 | 4c9649a9 | j_mayer | } else {
|
349 | 4c9649a9 | j_mayer | gen_op_set_u32_T1(imm); |
350 | 4c9649a9 | j_mayer | } |
351 | 4c9649a9 | j_mayer | } else {
|
352 | 4c9649a9 | j_mayer | #if 0 // Qemu does not know how to do this...
|
353 | 4c9649a9 | j_mayer | gen_op_set_64_T1(imm);
|
354 | 4c9649a9 | j_mayer | #else
|
355 | 4c9649a9 | j_mayer | gen_op_set_64_T1(imm >> 32, imm);
|
356 | 4c9649a9 | j_mayer | #endif
|
357 | 4c9649a9 | j_mayer | } |
358 | 4c9649a9 | j_mayer | } |
359 | 4c9649a9 | j_mayer | |
360 | f071b4d3 | j_mayer | static always_inline void gen_update_pc (DisasContext *ctx) |
361 | 4c9649a9 | j_mayer | { |
362 | 4c9649a9 | j_mayer | if (!(ctx->pc >> 32)) { |
363 | 4c9649a9 | j_mayer | gen_op_update_pc32(ctx->pc); |
364 | 4c9649a9 | j_mayer | } else {
|
365 | 4c9649a9 | j_mayer | #if 0 // Qemu does not know how to do this...
|
366 | 4c9649a9 | j_mayer | gen_op_update_pc(ctx->pc);
|
367 | 4c9649a9 | j_mayer | #else
|
368 | 4c9649a9 | j_mayer | gen_op_update_pc(ctx->pc >> 32, ctx->pc);
|
369 | 4c9649a9 | j_mayer | #endif
|
370 | 4c9649a9 | j_mayer | } |
371 | 4c9649a9 | j_mayer | } |
372 | 4c9649a9 | j_mayer | |
373 | f071b4d3 | j_mayer | static always_inline void _gen_op_bcond (DisasContext *ctx) |
374 | 4c9649a9 | j_mayer | { |
375 | 4c9649a9 | j_mayer | #if 0 // Qemu does not know how to do this...
|
376 | 4c9649a9 | j_mayer | gen_op_bcond(ctx->pc);
|
377 | 4c9649a9 | j_mayer | #else
|
378 | 4c9649a9 | j_mayer | gen_op_bcond(ctx->pc >> 32, ctx->pc);
|
379 | 4c9649a9 | j_mayer | #endif
|
380 | 4c9649a9 | j_mayer | } |
381 | 4c9649a9 | j_mayer | |
382 | f071b4d3 | j_mayer | static always_inline void gen_excp (DisasContext *ctx, |
383 | f071b4d3 | j_mayer | int exception, int error_code) |
384 | 4c9649a9 | j_mayer | { |
385 | 4c9649a9 | j_mayer | gen_update_pc(ctx); |
386 | 4c9649a9 | j_mayer | gen_op_excp(exception, error_code); |
387 | 4c9649a9 | j_mayer | } |
388 | 4c9649a9 | j_mayer | |
389 | f071b4d3 | j_mayer | static always_inline void gen_invalid (DisasContext *ctx) |
390 | 4c9649a9 | j_mayer | { |
391 | 4c9649a9 | j_mayer | gen_excp(ctx, EXCP_OPCDEC, 0);
|
392 | 4c9649a9 | j_mayer | } |
393 | 4c9649a9 | j_mayer | |
394 | f071b4d3 | j_mayer | static always_inline void gen_load_mem (DisasContext *ctx, |
395 | f071b4d3 | j_mayer | void (*gen_load_op)(DisasContext *ctx),
|
396 | f071b4d3 | j_mayer | int ra, int rb, int32_t disp16, |
397 | f071b4d3 | j_mayer | int clear)
|
398 | 4c9649a9 | j_mayer | { |
399 | 4c9649a9 | j_mayer | if (ra == 31 && disp16 == 0) { |
400 | 4c9649a9 | j_mayer | /* UNOP */
|
401 | 4c9649a9 | j_mayer | gen_op_nop(); |
402 | 4c9649a9 | j_mayer | } else {
|
403 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
404 | 4c9649a9 | j_mayer | if (disp16 != 0) { |
405 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp16); |
406 | 4c9649a9 | j_mayer | gen_op_addq(); |
407 | 4c9649a9 | j_mayer | } |
408 | 4c9649a9 | j_mayer | if (clear)
|
409 | 4c9649a9 | j_mayer | gen_op_n7(); |
410 | 4c9649a9 | j_mayer | (*gen_load_op)(ctx); |
411 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 1);
|
412 | 4c9649a9 | j_mayer | } |
413 | 4c9649a9 | j_mayer | } |
414 | 4c9649a9 | j_mayer | |
415 | f071b4d3 | j_mayer | static always_inline void gen_store_mem (DisasContext *ctx, |
416 | f071b4d3 | j_mayer | void (*gen_store_op)(DisasContext *ctx),
|
417 | f071b4d3 | j_mayer | int ra, int rb, int32_t disp16, |
418 | f071b4d3 | j_mayer | int clear)
|
419 | 4c9649a9 | j_mayer | { |
420 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
421 | 4c9649a9 | j_mayer | if (disp16 != 0) { |
422 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp16); |
423 | 4c9649a9 | j_mayer | gen_op_addq(); |
424 | 4c9649a9 | j_mayer | } |
425 | 4c9649a9 | j_mayer | if (clear)
|
426 | 4c9649a9 | j_mayer | gen_op_n7(); |
427 | 4c9649a9 | j_mayer | gen_load_ir(ctx, ra, 1);
|
428 | 4c9649a9 | j_mayer | (*gen_store_op)(ctx); |
429 | 4c9649a9 | j_mayer | } |
430 | 4c9649a9 | j_mayer | |
431 | f071b4d3 | j_mayer | static always_inline void gen_load_fmem (DisasContext *ctx, |
432 | f071b4d3 | j_mayer | void (*gen_load_fop)(DisasContext *ctx),
|
433 | f071b4d3 | j_mayer | int ra, int rb, int32_t disp16) |
434 | 4c9649a9 | j_mayer | { |
435 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
436 | 4c9649a9 | j_mayer | if (disp16 != 0) { |
437 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp16); |
438 | 4c9649a9 | j_mayer | gen_op_addq(); |
439 | 4c9649a9 | j_mayer | } |
440 | 4c9649a9 | j_mayer | (*gen_load_fop)(ctx); |
441 | 4c9649a9 | j_mayer | gen_store_fir(ctx, ra, 1);
|
442 | 4c9649a9 | j_mayer | } |
443 | 4c9649a9 | j_mayer | |
444 | f071b4d3 | j_mayer | static always_inline void gen_store_fmem (DisasContext *ctx, |
445 | f071b4d3 | j_mayer | void (*gen_store_fop)(DisasContext *ctx),
|
446 | f071b4d3 | j_mayer | int ra, int rb, int32_t disp16) |
447 | 4c9649a9 | j_mayer | { |
448 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
449 | 4c9649a9 | j_mayer | if (disp16 != 0) { |
450 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp16); |
451 | 4c9649a9 | j_mayer | gen_op_addq(); |
452 | 4c9649a9 | j_mayer | } |
453 | 4c9649a9 | j_mayer | gen_load_fir(ctx, ra, 1);
|
454 | 4c9649a9 | j_mayer | (*gen_store_fop)(ctx); |
455 | 4c9649a9 | j_mayer | } |
456 | 4c9649a9 | j_mayer | |
457 | f071b4d3 | j_mayer | static always_inline void gen_bcond (DisasContext *ctx, |
458 | f071b4d3 | j_mayer | void (*gen_test_op)(void), |
459 | f071b4d3 | j_mayer | int ra, int32_t disp16)
|
460 | 4c9649a9 | j_mayer | { |
461 | 4c9649a9 | j_mayer | if (disp16 != 0) { |
462 | 4c9649a9 | j_mayer | gen_set_uT0(ctx, ctx->pc); |
463 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp16 << 2);
|
464 | 4c9649a9 | j_mayer | gen_op_addq1(); |
465 | 4c9649a9 | j_mayer | } else {
|
466 | 4c9649a9 | j_mayer | gen_set_uT1(ctx, ctx->pc); |
467 | 4c9649a9 | j_mayer | } |
468 | 4c9649a9 | j_mayer | gen_load_ir(ctx, ra, 0);
|
469 | 4c9649a9 | j_mayer | (*gen_test_op)(); |
470 | 4c9649a9 | j_mayer | _gen_op_bcond(ctx); |
471 | 4c9649a9 | j_mayer | } |
472 | 4c9649a9 | j_mayer | |
473 | f071b4d3 | j_mayer | static always_inline void gen_fbcond (DisasContext *ctx, |
474 | f071b4d3 | j_mayer | void (*gen_test_op)(void), |
475 | f071b4d3 | j_mayer | int ra, int32_t disp16)
|
476 | 4c9649a9 | j_mayer | { |
477 | 4c9649a9 | j_mayer | if (disp16 != 0) { |
478 | 4c9649a9 | j_mayer | gen_set_uT0(ctx, ctx->pc); |
479 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp16 << 2);
|
480 | 4c9649a9 | j_mayer | gen_op_addq1(); |
481 | 4c9649a9 | j_mayer | } else {
|
482 | 4c9649a9 | j_mayer | gen_set_uT1(ctx, ctx->pc); |
483 | 4c9649a9 | j_mayer | } |
484 | 4c9649a9 | j_mayer | gen_load_fir(ctx, ra, 0);
|
485 | 4c9649a9 | j_mayer | (*gen_test_op)(); |
486 | 4c9649a9 | j_mayer | _gen_op_bcond(ctx); |
487 | 4c9649a9 | j_mayer | } |
488 | 4c9649a9 | j_mayer | |
489 | f071b4d3 | j_mayer | static always_inline void gen_arith2 (DisasContext *ctx, |
490 | f071b4d3 | j_mayer | void (*gen_arith_op)(void), |
491 | f071b4d3 | j_mayer | int rb, int rc, int islit, int8_t lit) |
492 | 4c9649a9 | j_mayer | { |
493 | 4c9649a9 | j_mayer | if (islit)
|
494 | 4c9649a9 | j_mayer | gen_set_sT0(ctx, lit); |
495 | 4c9649a9 | j_mayer | else
|
496 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
497 | 4c9649a9 | j_mayer | (*gen_arith_op)(); |
498 | 4c9649a9 | j_mayer | gen_store_ir(ctx, rc, 0);
|
499 | 4c9649a9 | j_mayer | } |
500 | 4c9649a9 | j_mayer | |
501 | f071b4d3 | j_mayer | static always_inline void gen_arith3 (DisasContext *ctx, |
502 | f071b4d3 | j_mayer | void (*gen_arith_op)(void), |
503 | f071b4d3 | j_mayer | int ra, int rb, int rc, |
504 | f071b4d3 | j_mayer | int islit, int8_t lit)
|
505 | 4c9649a9 | j_mayer | { |
506 | 4c9649a9 | j_mayer | gen_load_ir(ctx, ra, 0);
|
507 | 4c9649a9 | j_mayer | if (islit)
|
508 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, lit); |
509 | 4c9649a9 | j_mayer | else
|
510 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 1);
|
511 | 4c9649a9 | j_mayer | (*gen_arith_op)(); |
512 | 4c9649a9 | j_mayer | gen_store_ir(ctx, rc, 0);
|
513 | 4c9649a9 | j_mayer | } |
514 | 4c9649a9 | j_mayer | |
515 | f071b4d3 | j_mayer | static always_inline void gen_cmov (DisasContext *ctx, |
516 | f071b4d3 | j_mayer | void (*gen_test_op)(void), |
517 | f071b4d3 | j_mayer | int ra, int rb, int rc, |
518 | f071b4d3 | j_mayer | int islit, int8_t lit)
|
519 | 4c9649a9 | j_mayer | { |
520 | 4c9649a9 | j_mayer | gen_load_ir(ctx, ra, 1);
|
521 | 4c9649a9 | j_mayer | if (islit)
|
522 | 4c9649a9 | j_mayer | gen_set_sT0(ctx, lit); |
523 | 4c9649a9 | j_mayer | else
|
524 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
525 | 4c9649a9 | j_mayer | (*gen_test_op)(); |
526 | 4c9649a9 | j_mayer | gen_op_cmov_ir(rc); |
527 | 4c9649a9 | j_mayer | } |
528 | 4c9649a9 | j_mayer | |
529 | f071b4d3 | j_mayer | static always_inline void gen_farith2 (DisasContext *ctx, |
530 | f071b4d3 | j_mayer | void (*gen_arith_fop)(void), |
531 | f071b4d3 | j_mayer | int rb, int rc) |
532 | 4c9649a9 | j_mayer | { |
533 | 4c9649a9 | j_mayer | gen_load_fir(ctx, rb, 0);
|
534 | 4c9649a9 | j_mayer | (*gen_arith_fop)(); |
535 | 4c9649a9 | j_mayer | gen_store_fir(ctx, rc, 0);
|
536 | 4c9649a9 | j_mayer | } |
537 | 4c9649a9 | j_mayer | |
538 | f071b4d3 | j_mayer | static always_inline void gen_farith3 (DisasContext *ctx, |
539 | f071b4d3 | j_mayer | void (*gen_arith_fop)(void), |
540 | f071b4d3 | j_mayer | int ra, int rb, int rc) |
541 | 4c9649a9 | j_mayer | { |
542 | 4c9649a9 | j_mayer | gen_load_fir(ctx, ra, 0);
|
543 | 4c9649a9 | j_mayer | gen_load_fir(ctx, rb, 1);
|
544 | 4c9649a9 | j_mayer | (*gen_arith_fop)(); |
545 | 4c9649a9 | j_mayer | gen_store_fir(ctx, rc, 0);
|
546 | 4c9649a9 | j_mayer | } |
547 | 4c9649a9 | j_mayer | |
548 | f071b4d3 | j_mayer | static always_inline void gen_fcmov (DisasContext *ctx, |
549 | f071b4d3 | j_mayer | void (*gen_test_fop)(void), |
550 | f071b4d3 | j_mayer | int ra, int rb, int rc) |
551 | 4c9649a9 | j_mayer | { |
552 | 4c9649a9 | j_mayer | gen_load_fir(ctx, ra, 0);
|
553 | 4c9649a9 | j_mayer | gen_load_fir(ctx, rb, 1);
|
554 | 4c9649a9 | j_mayer | (*gen_test_fop)(); |
555 | 4c9649a9 | j_mayer | gen_op_cmov_fir(rc); |
556 | 4c9649a9 | j_mayer | } |
557 | 4c9649a9 | j_mayer | |
558 | f071b4d3 | j_mayer | static always_inline void gen_fti (DisasContext *ctx, |
559 | f071b4d3 | j_mayer | void (*gen_move_fop)(void), |
560 | f071b4d3 | j_mayer | int ra, int rc) |
561 | 4c9649a9 | j_mayer | { |
562 | 4c9649a9 | j_mayer | gen_load_fir(ctx, rc, 0);
|
563 | 4c9649a9 | j_mayer | (*gen_move_fop)(); |
564 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 0);
|
565 | 4c9649a9 | j_mayer | } |
566 | 4c9649a9 | j_mayer | |
567 | f071b4d3 | j_mayer | static always_inline void gen_itf (DisasContext *ctx, |
568 | f071b4d3 | j_mayer | void (*gen_move_fop)(void), |
569 | f071b4d3 | j_mayer | int ra, int rc) |
570 | 4c9649a9 | j_mayer | { |
571 | 4c9649a9 | j_mayer | gen_load_ir(ctx, ra, 0);
|
572 | 4c9649a9 | j_mayer | (*gen_move_fop)(); |
573 | 4c9649a9 | j_mayer | gen_store_fir(ctx, rc, 0);
|
574 | 4c9649a9 | j_mayer | } |
575 | 4c9649a9 | j_mayer | |
576 | f071b4d3 | j_mayer | static always_inline void gen_s4addl (void) |
577 | 4c9649a9 | j_mayer | { |
578 | 4c9649a9 | j_mayer | gen_op_s4(); |
579 | 4c9649a9 | j_mayer | gen_op_addl(); |
580 | 5fafdf24 | ths | } |
581 | 4c9649a9 | j_mayer | |
582 | f071b4d3 | j_mayer | static always_inline void gen_s4subl (void) |
583 | 4c9649a9 | j_mayer | { |
584 | 4c9649a9 | j_mayer | gen_op_s4(); |
585 | 4c9649a9 | j_mayer | gen_op_subl(); |
586 | 5fafdf24 | ths | } |
587 | 4c9649a9 | j_mayer | |
588 | f071b4d3 | j_mayer | static always_inline void gen_s8addl (void) |
589 | 4c9649a9 | j_mayer | { |
590 | 4c9649a9 | j_mayer | gen_op_s8(); |
591 | 4c9649a9 | j_mayer | gen_op_addl(); |
592 | 5fafdf24 | ths | } |
593 | 4c9649a9 | j_mayer | |
594 | f071b4d3 | j_mayer | static always_inline void gen_s8subl (void) |
595 | 4c9649a9 | j_mayer | { |
596 | 4c9649a9 | j_mayer | gen_op_s8(); |
597 | 4c9649a9 | j_mayer | gen_op_subl(); |
598 | 5fafdf24 | ths | } |
599 | 4c9649a9 | j_mayer | |
600 | f071b4d3 | j_mayer | static always_inline void gen_s4addq (void) |
601 | 4c9649a9 | j_mayer | { |
602 | 4c9649a9 | j_mayer | gen_op_s4(); |
603 | 4c9649a9 | j_mayer | gen_op_addq(); |
604 | 5fafdf24 | ths | } |
605 | 4c9649a9 | j_mayer | |
606 | f071b4d3 | j_mayer | static always_inline void gen_s4subq (void) |
607 | 4c9649a9 | j_mayer | { |
608 | 4c9649a9 | j_mayer | gen_op_s4(); |
609 | 4c9649a9 | j_mayer | gen_op_subq(); |
610 | 5fafdf24 | ths | } |
611 | 4c9649a9 | j_mayer | |
612 | f071b4d3 | j_mayer | static always_inline void gen_s8addq (void) |
613 | 4c9649a9 | j_mayer | { |
614 | 4c9649a9 | j_mayer | gen_op_s8(); |
615 | 4c9649a9 | j_mayer | gen_op_addq(); |
616 | 5fafdf24 | ths | } |
617 | 4c9649a9 | j_mayer | |
618 | f071b4d3 | j_mayer | static always_inline void gen_s8subq (void) |
619 | 4c9649a9 | j_mayer | { |
620 | 4c9649a9 | j_mayer | gen_op_s8(); |
621 | 4c9649a9 | j_mayer | gen_op_subq(); |
622 | 5fafdf24 | ths | } |
623 | 4c9649a9 | j_mayer | |
624 | f071b4d3 | j_mayer | static always_inline void gen_amask (void) |
625 | 4c9649a9 | j_mayer | { |
626 | 4c9649a9 | j_mayer | gen_op_load_amask(); |
627 | 4c9649a9 | j_mayer | gen_op_bic(); |
628 | 4c9649a9 | j_mayer | } |
629 | 4c9649a9 | j_mayer | |
630 | f071b4d3 | j_mayer | static always_inline int translate_one (DisasContext *ctx, uint32_t insn) |
631 | 4c9649a9 | j_mayer | { |
632 | 4c9649a9 | j_mayer | uint32_t palcode; |
633 | 4c9649a9 | j_mayer | int32_t disp21, disp16, disp12; |
634 | 4c9649a9 | j_mayer | uint16_t fn11, fn16; |
635 | 4c9649a9 | j_mayer | uint8_t opc, ra, rb, rc, sbz, fpfn, fn7, fn2, islit; |
636 | 4c9649a9 | j_mayer | int8_t lit; |
637 | 4c9649a9 | j_mayer | int ret;
|
638 | 4c9649a9 | j_mayer | |
639 | 4c9649a9 | j_mayer | /* Decode all instruction fields */
|
640 | 4c9649a9 | j_mayer | opc = insn >> 26;
|
641 | 4c9649a9 | j_mayer | ra = (insn >> 21) & 0x1F; |
642 | 4c9649a9 | j_mayer | rb = (insn >> 16) & 0x1F; |
643 | 4c9649a9 | j_mayer | rc = insn & 0x1F;
|
644 | 4c9649a9 | j_mayer | sbz = (insn >> 13) & 0x07; |
645 | 4c9649a9 | j_mayer | islit = (insn >> 12) & 1; |
646 | 4c9649a9 | j_mayer | lit = (insn >> 13) & 0xFF; |
647 | 4c9649a9 | j_mayer | palcode = insn & 0x03FFFFFF;
|
648 | 4c9649a9 | j_mayer | disp21 = ((int32_t)((insn & 0x001FFFFF) << 11)) >> 11; |
649 | 4c9649a9 | j_mayer | disp16 = (int16_t)(insn & 0x0000FFFF);
|
650 | 4c9649a9 | j_mayer | disp12 = (int32_t)((insn & 0x00000FFF) << 20) >> 20; |
651 | 4c9649a9 | j_mayer | fn16 = insn & 0x0000FFFF;
|
652 | 4c9649a9 | j_mayer | fn11 = (insn >> 5) & 0x000007FF; |
653 | 4c9649a9 | j_mayer | fpfn = fn11 & 0x3F;
|
654 | 4c9649a9 | j_mayer | fn7 = (insn >> 5) & 0x0000007F; |
655 | 4c9649a9 | j_mayer | fn2 = (insn >> 5) & 0x00000003; |
656 | 4c9649a9 | j_mayer | ret = 0;
|
657 | 4c9649a9 | j_mayer | #if defined ALPHA_DEBUG_DISAS
|
658 | 4c9649a9 | j_mayer | if (logfile != NULL) { |
659 | 4c9649a9 | j_mayer | fprintf(logfile, "opc %02x ra %d rb %d rc %d disp16 %04x\n",
|
660 | 4c9649a9 | j_mayer | opc, ra, rb, rc, disp16); |
661 | 4c9649a9 | j_mayer | } |
662 | 4c9649a9 | j_mayer | #endif
|
663 | 4c9649a9 | j_mayer | switch (opc) {
|
664 | 4c9649a9 | j_mayer | case 0x00: |
665 | 4c9649a9 | j_mayer | /* CALL_PAL */
|
666 | 4c9649a9 | j_mayer | if (palcode >= 0x80 && palcode < 0xC0) { |
667 | 4c9649a9 | j_mayer | /* Unprivileged PAL call */
|
668 | 4c9649a9 | j_mayer | gen_excp(ctx, EXCP_CALL_PAL + ((palcode & 0x1F) << 6), 0); |
669 | 4c9649a9 | j_mayer | #if !defined (CONFIG_USER_ONLY)
|
670 | 4c9649a9 | j_mayer | } else if (palcode < 0x40) { |
671 | 4c9649a9 | j_mayer | /* Privileged PAL code */
|
672 | 4c9649a9 | j_mayer | if (ctx->mem_idx & 1) |
673 | 4c9649a9 | j_mayer | goto invalid_opc;
|
674 | 4c9649a9 | j_mayer | else
|
675 | 4c9649a9 | j_mayer | gen_excp(ctx, EXCP_CALL_PALP + ((palcode & 0x1F) << 6), 0); |
676 | 4c9649a9 | j_mayer | #endif
|
677 | 4c9649a9 | j_mayer | } else {
|
678 | 4c9649a9 | j_mayer | /* Invalid PAL call */
|
679 | 4c9649a9 | j_mayer | goto invalid_opc;
|
680 | 4c9649a9 | j_mayer | } |
681 | 4c9649a9 | j_mayer | ret = 3;
|
682 | 4c9649a9 | j_mayer | break;
|
683 | 4c9649a9 | j_mayer | case 0x01: |
684 | 4c9649a9 | j_mayer | /* OPC01 */
|
685 | 4c9649a9 | j_mayer | goto invalid_opc;
|
686 | 4c9649a9 | j_mayer | case 0x02: |
687 | 4c9649a9 | j_mayer | /* OPC02 */
|
688 | 4c9649a9 | j_mayer | goto invalid_opc;
|
689 | 4c9649a9 | j_mayer | case 0x03: |
690 | 4c9649a9 | j_mayer | /* OPC03 */
|
691 | 4c9649a9 | j_mayer | goto invalid_opc;
|
692 | 4c9649a9 | j_mayer | case 0x04: |
693 | 4c9649a9 | j_mayer | /* OPC04 */
|
694 | 4c9649a9 | j_mayer | goto invalid_opc;
|
695 | 4c9649a9 | j_mayer | case 0x05: |
696 | 4c9649a9 | j_mayer | /* OPC05 */
|
697 | 4c9649a9 | j_mayer | goto invalid_opc;
|
698 | 4c9649a9 | j_mayer | case 0x06: |
699 | 4c9649a9 | j_mayer | /* OPC06 */
|
700 | 4c9649a9 | j_mayer | goto invalid_opc;
|
701 | 4c9649a9 | j_mayer | case 0x07: |
702 | 4c9649a9 | j_mayer | /* OPC07 */
|
703 | 4c9649a9 | j_mayer | goto invalid_opc;
|
704 | 4c9649a9 | j_mayer | case 0x08: |
705 | 4c9649a9 | j_mayer | /* LDA */
|
706 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
707 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp16); |
708 | 4c9649a9 | j_mayer | gen_op_addq(); |
709 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 0);
|
710 | 4c9649a9 | j_mayer | break;
|
711 | 4c9649a9 | j_mayer | case 0x09: |
712 | 4c9649a9 | j_mayer | /* LDAH */
|
713 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
714 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp16 << 16);
|
715 | 4c9649a9 | j_mayer | gen_op_addq(); |
716 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 0);
|
717 | 4c9649a9 | j_mayer | break;
|
718 | 4c9649a9 | j_mayer | case 0x0A: |
719 | 4c9649a9 | j_mayer | /* LDBU */
|
720 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
721 | 4c9649a9 | j_mayer | goto invalid_opc;
|
722 | 4c9649a9 | j_mayer | gen_load_mem(ctx, &gen_ldbu, ra, rb, disp16, 0);
|
723 | 4c9649a9 | j_mayer | break;
|
724 | 4c9649a9 | j_mayer | case 0x0B: |
725 | 4c9649a9 | j_mayer | /* LDQ_U */
|
726 | 4c9649a9 | j_mayer | gen_load_mem(ctx, &gen_ldq_u, ra, rb, disp16, 1);
|
727 | 4c9649a9 | j_mayer | break;
|
728 | 4c9649a9 | j_mayer | case 0x0C: |
729 | 4c9649a9 | j_mayer | /* LDWU */
|
730 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
731 | 4c9649a9 | j_mayer | goto invalid_opc;
|
732 | 4c9649a9 | j_mayer | gen_load_mem(ctx, &gen_ldwu, ra, rb, disp16, 0);
|
733 | 4c9649a9 | j_mayer | break;
|
734 | 4c9649a9 | j_mayer | case 0x0D: |
735 | 4c9649a9 | j_mayer | /* STW */
|
736 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
737 | 4c9649a9 | j_mayer | goto invalid_opc;
|
738 | 4c9649a9 | j_mayer | gen_store_mem(ctx, &gen_stw, ra, rb, disp16, 0);
|
739 | 4c9649a9 | j_mayer | break;
|
740 | 4c9649a9 | j_mayer | case 0x0E: |
741 | 4c9649a9 | j_mayer | /* STB */
|
742 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
743 | 4c9649a9 | j_mayer | goto invalid_opc;
|
744 | 4c9649a9 | j_mayer | gen_store_mem(ctx, &gen_stb, ra, rb, disp16, 0);
|
745 | 4c9649a9 | j_mayer | break;
|
746 | 4c9649a9 | j_mayer | case 0x0F: |
747 | 4c9649a9 | j_mayer | /* STQ_U */
|
748 | 4c9649a9 | j_mayer | gen_store_mem(ctx, &gen_stq_u, ra, rb, disp16, 1);
|
749 | 4c9649a9 | j_mayer | break;
|
750 | 4c9649a9 | j_mayer | case 0x10: |
751 | 4c9649a9 | j_mayer | switch (fn7) {
|
752 | 4c9649a9 | j_mayer | case 0x00: |
753 | 4c9649a9 | j_mayer | /* ADDL */
|
754 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_addl, ra, rb, rc, islit, lit); |
755 | 4c9649a9 | j_mayer | break;
|
756 | 4c9649a9 | j_mayer | case 0x02: |
757 | 4c9649a9 | j_mayer | /* S4ADDL */
|
758 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_s4addl, ra, rb, rc, islit, lit); |
759 | 4c9649a9 | j_mayer | break;
|
760 | 4c9649a9 | j_mayer | case 0x09: |
761 | 4c9649a9 | j_mayer | /* SUBL */
|
762 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_subl, ra, rb, rc, islit, lit); |
763 | 4c9649a9 | j_mayer | break;
|
764 | 4c9649a9 | j_mayer | case 0x0B: |
765 | 4c9649a9 | j_mayer | /* S4SUBL */
|
766 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_s4subl, ra, rb, rc, islit, lit); |
767 | 4c9649a9 | j_mayer | break;
|
768 | 4c9649a9 | j_mayer | case 0x0F: |
769 | 4c9649a9 | j_mayer | /* CMPBGE */
|
770 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_cmpbge, ra, rb, rc, islit, lit); |
771 | 4c9649a9 | j_mayer | break;
|
772 | 4c9649a9 | j_mayer | case 0x12: |
773 | 4c9649a9 | j_mayer | /* S8ADDL */
|
774 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_s8addl, ra, rb, rc, islit, lit); |
775 | 4c9649a9 | j_mayer | break;
|
776 | 4c9649a9 | j_mayer | case 0x1B: |
777 | 4c9649a9 | j_mayer | /* S8SUBL */
|
778 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_s8subl, ra, rb, rc, islit, lit); |
779 | 4c9649a9 | j_mayer | break;
|
780 | 4c9649a9 | j_mayer | case 0x1D: |
781 | 4c9649a9 | j_mayer | /* CMPULT */
|
782 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_cmpult, ra, rb, rc, islit, lit); |
783 | 4c9649a9 | j_mayer | break;
|
784 | 4c9649a9 | j_mayer | case 0x20: |
785 | 4c9649a9 | j_mayer | /* ADDQ */
|
786 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_addq, ra, rb, rc, islit, lit); |
787 | 4c9649a9 | j_mayer | break;
|
788 | 4c9649a9 | j_mayer | case 0x22: |
789 | 4c9649a9 | j_mayer | /* S4ADDQ */
|
790 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_s4addq, ra, rb, rc, islit, lit); |
791 | 4c9649a9 | j_mayer | break;
|
792 | 4c9649a9 | j_mayer | case 0x29: |
793 | 4c9649a9 | j_mayer | /* SUBQ */
|
794 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_subq, ra, rb, rc, islit, lit); |
795 | 4c9649a9 | j_mayer | break;
|
796 | 4c9649a9 | j_mayer | case 0x2B: |
797 | 4c9649a9 | j_mayer | /* S4SUBQ */
|
798 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_s4subq, ra, rb, rc, islit, lit); |
799 | 4c9649a9 | j_mayer | break;
|
800 | 4c9649a9 | j_mayer | case 0x2D: |
801 | 4c9649a9 | j_mayer | /* CMPEQ */
|
802 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_cmpeq, ra, rb, rc, islit, lit); |
803 | 4c9649a9 | j_mayer | break;
|
804 | 4c9649a9 | j_mayer | case 0x32: |
805 | 4c9649a9 | j_mayer | /* S8ADDQ */
|
806 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_s8addq, ra, rb, rc, islit, lit); |
807 | 4c9649a9 | j_mayer | break;
|
808 | 4c9649a9 | j_mayer | case 0x3B: |
809 | 4c9649a9 | j_mayer | /* S8SUBQ */
|
810 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_s8subq, ra, rb, rc, islit, lit); |
811 | 4c9649a9 | j_mayer | break;
|
812 | 4c9649a9 | j_mayer | case 0x3D: |
813 | 4c9649a9 | j_mayer | /* CMPULE */
|
814 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_cmpule, ra, rb, rc, islit, lit); |
815 | 4c9649a9 | j_mayer | break;
|
816 | 4c9649a9 | j_mayer | case 0x40: |
817 | 4c9649a9 | j_mayer | /* ADDL/V */
|
818 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_addlv, ra, rb, rc, islit, lit); |
819 | 4c9649a9 | j_mayer | break;
|
820 | 4c9649a9 | j_mayer | case 0x49: |
821 | 4c9649a9 | j_mayer | /* SUBL/V */
|
822 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_sublv, ra, rb, rc, islit, lit); |
823 | 4c9649a9 | j_mayer | break;
|
824 | 4c9649a9 | j_mayer | case 0x4D: |
825 | 4c9649a9 | j_mayer | /* CMPLT */
|
826 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_cmplt, ra, rb, rc, islit, lit); |
827 | 4c9649a9 | j_mayer | break;
|
828 | 4c9649a9 | j_mayer | case 0x60: |
829 | 4c9649a9 | j_mayer | /* ADDQ/V */
|
830 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_addqv, ra, rb, rc, islit, lit); |
831 | 4c9649a9 | j_mayer | break;
|
832 | 4c9649a9 | j_mayer | case 0x69: |
833 | 4c9649a9 | j_mayer | /* SUBQ/V */
|
834 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_subqv, ra, rb, rc, islit, lit); |
835 | 4c9649a9 | j_mayer | break;
|
836 | 4c9649a9 | j_mayer | case 0x6D: |
837 | 4c9649a9 | j_mayer | /* CMPLE */
|
838 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_cmple, ra, rb, rc, islit, lit); |
839 | 4c9649a9 | j_mayer | break;
|
840 | 4c9649a9 | j_mayer | default:
|
841 | 4c9649a9 | j_mayer | goto invalid_opc;
|
842 | 4c9649a9 | j_mayer | } |
843 | 4c9649a9 | j_mayer | break;
|
844 | 4c9649a9 | j_mayer | case 0x11: |
845 | 4c9649a9 | j_mayer | switch (fn7) {
|
846 | 4c9649a9 | j_mayer | case 0x00: |
847 | 4c9649a9 | j_mayer | /* AND */
|
848 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_and, ra, rb, rc, islit, lit); |
849 | 4c9649a9 | j_mayer | break;
|
850 | 4c9649a9 | j_mayer | case 0x08: |
851 | 4c9649a9 | j_mayer | /* BIC */
|
852 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_bic, ra, rb, rc, islit, lit); |
853 | 4c9649a9 | j_mayer | break;
|
854 | 4c9649a9 | j_mayer | case 0x14: |
855 | 4c9649a9 | j_mayer | /* CMOVLBS */
|
856 | 4c9649a9 | j_mayer | gen_cmov(ctx, &gen_op_cmplbs, ra, rb, rc, islit, lit); |
857 | 4c9649a9 | j_mayer | break;
|
858 | 4c9649a9 | j_mayer | case 0x16: |
859 | 4c9649a9 | j_mayer | /* CMOVLBC */
|
860 | 4c9649a9 | j_mayer | gen_cmov(ctx, &gen_op_cmplbc, ra, rb, rc, islit, lit); |
861 | 4c9649a9 | j_mayer | break;
|
862 | 4c9649a9 | j_mayer | case 0x20: |
863 | 4c9649a9 | j_mayer | /* BIS */
|
864 | 4c9649a9 | j_mayer | if (ra == rb || ra == 31 || rb == 31) { |
865 | 4c9649a9 | j_mayer | if (ra == 31 && rc == 31) { |
866 | 4c9649a9 | j_mayer | /* NOP */
|
867 | 4c9649a9 | j_mayer | gen_op_nop(); |
868 | 4c9649a9 | j_mayer | } else {
|
869 | 4c9649a9 | j_mayer | /* MOV */
|
870 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
871 | 4c9649a9 | j_mayer | gen_store_ir(ctx, rc, 0);
|
872 | 4c9649a9 | j_mayer | } |
873 | 4c9649a9 | j_mayer | } else {
|
874 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_bis, ra, rb, rc, islit, lit); |
875 | 4c9649a9 | j_mayer | } |
876 | 4c9649a9 | j_mayer | break;
|
877 | 4c9649a9 | j_mayer | case 0x24: |
878 | 4c9649a9 | j_mayer | /* CMOVEQ */
|
879 | 4c9649a9 | j_mayer | gen_cmov(ctx, &gen_op_cmpeqz, ra, rb, rc, islit, lit); |
880 | 4c9649a9 | j_mayer | break;
|
881 | 4c9649a9 | j_mayer | case 0x26: |
882 | 4c9649a9 | j_mayer | /* CMOVNE */
|
883 | 4c9649a9 | j_mayer | gen_cmov(ctx, &gen_op_cmpnez, ra, rb, rc, islit, lit); |
884 | 4c9649a9 | j_mayer | break;
|
885 | 4c9649a9 | j_mayer | case 0x28: |
886 | 4c9649a9 | j_mayer | /* ORNOT */
|
887 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_ornot, ra, rb, rc, islit, lit); |
888 | 4c9649a9 | j_mayer | break;
|
889 | 4c9649a9 | j_mayer | case 0x40: |
890 | 4c9649a9 | j_mayer | /* XOR */
|
891 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_xor, ra, rb, rc, islit, lit); |
892 | 4c9649a9 | j_mayer | break;
|
893 | 4c9649a9 | j_mayer | case 0x44: |
894 | 4c9649a9 | j_mayer | /* CMOVLT */
|
895 | 4c9649a9 | j_mayer | gen_cmov(ctx, &gen_op_cmpltz, ra, rb, rc, islit, lit); |
896 | 4c9649a9 | j_mayer | break;
|
897 | 4c9649a9 | j_mayer | case 0x46: |
898 | 4c9649a9 | j_mayer | /* CMOVGE */
|
899 | 4c9649a9 | j_mayer | gen_cmov(ctx, &gen_op_cmpgez, ra, rb, rc, islit, lit); |
900 | 4c9649a9 | j_mayer | break;
|
901 | 4c9649a9 | j_mayer | case 0x48: |
902 | 4c9649a9 | j_mayer | /* EQV */
|
903 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_eqv, ra, rb, rc, islit, lit); |
904 | 4c9649a9 | j_mayer | break;
|
905 | 4c9649a9 | j_mayer | case 0x61: |
906 | 4c9649a9 | j_mayer | /* AMASK */
|
907 | 4c9649a9 | j_mayer | gen_arith2(ctx, &gen_amask, rb, rc, islit, lit); |
908 | 4c9649a9 | j_mayer | break;
|
909 | 4c9649a9 | j_mayer | case 0x64: |
910 | 4c9649a9 | j_mayer | /* CMOVLE */
|
911 | 4c9649a9 | j_mayer | gen_cmov(ctx, &gen_op_cmplez, ra, rb, rc, islit, lit); |
912 | 4c9649a9 | j_mayer | break;
|
913 | 4c9649a9 | j_mayer | case 0x66: |
914 | 4c9649a9 | j_mayer | /* CMOVGT */
|
915 | 4c9649a9 | j_mayer | gen_cmov(ctx, &gen_op_cmpgtz, ra, rb, rc, islit, lit); |
916 | 4c9649a9 | j_mayer | break;
|
917 | 4c9649a9 | j_mayer | case 0x6C: |
918 | 4c9649a9 | j_mayer | /* IMPLVER */
|
919 | 4c9649a9 | j_mayer | gen_op_load_implver(); |
920 | 4c9649a9 | j_mayer | gen_store_ir(ctx, rc, 0);
|
921 | 4c9649a9 | j_mayer | break;
|
922 | 4c9649a9 | j_mayer | default:
|
923 | 4c9649a9 | j_mayer | goto invalid_opc;
|
924 | 4c9649a9 | j_mayer | } |
925 | 4c9649a9 | j_mayer | break;
|
926 | 4c9649a9 | j_mayer | case 0x12: |
927 | 4c9649a9 | j_mayer | switch (fn7) {
|
928 | 4c9649a9 | j_mayer | case 0x02: |
929 | 4c9649a9 | j_mayer | /* MSKBL */
|
930 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mskbl, ra, rb, rc, islit, lit); |
931 | 4c9649a9 | j_mayer | break;
|
932 | 4c9649a9 | j_mayer | case 0x06: |
933 | 4c9649a9 | j_mayer | /* EXTBL */
|
934 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_extbl, ra, rb, rc, islit, lit); |
935 | 4c9649a9 | j_mayer | break;
|
936 | 4c9649a9 | j_mayer | case 0x0B: |
937 | 4c9649a9 | j_mayer | /* INSBL */
|
938 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_insbl, ra, rb, rc, islit, lit); |
939 | 4c9649a9 | j_mayer | break;
|
940 | 4c9649a9 | j_mayer | case 0x12: |
941 | 4c9649a9 | j_mayer | /* MSKWL */
|
942 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mskwl, ra, rb, rc, islit, lit); |
943 | 4c9649a9 | j_mayer | break;
|
944 | 4c9649a9 | j_mayer | case 0x16: |
945 | 4c9649a9 | j_mayer | /* EXTWL */
|
946 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_extwl, ra, rb, rc, islit, lit); |
947 | 4c9649a9 | j_mayer | break;
|
948 | 4c9649a9 | j_mayer | case 0x1B: |
949 | 4c9649a9 | j_mayer | /* INSWL */
|
950 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_inswl, ra, rb, rc, islit, lit); |
951 | 4c9649a9 | j_mayer | break;
|
952 | 4c9649a9 | j_mayer | case 0x22: |
953 | 4c9649a9 | j_mayer | /* MSKLL */
|
954 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mskll, ra, rb, rc, islit, lit); |
955 | 4c9649a9 | j_mayer | break;
|
956 | 4c9649a9 | j_mayer | case 0x26: |
957 | 4c9649a9 | j_mayer | /* EXTLL */
|
958 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_extll, ra, rb, rc, islit, lit); |
959 | 4c9649a9 | j_mayer | break;
|
960 | 4c9649a9 | j_mayer | case 0x2B: |
961 | 4c9649a9 | j_mayer | /* INSLL */
|
962 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_insll, ra, rb, rc, islit, lit); |
963 | 4c9649a9 | j_mayer | break;
|
964 | 4c9649a9 | j_mayer | case 0x30: |
965 | 4c9649a9 | j_mayer | /* ZAP */
|
966 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_zap, ra, rb, rc, islit, lit); |
967 | 4c9649a9 | j_mayer | break;
|
968 | 4c9649a9 | j_mayer | case 0x31: |
969 | 4c9649a9 | j_mayer | /* ZAPNOT */
|
970 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_zapnot, ra, rb, rc, islit, lit); |
971 | 4c9649a9 | j_mayer | break;
|
972 | 4c9649a9 | j_mayer | case 0x32: |
973 | 4c9649a9 | j_mayer | /* MSKQL */
|
974 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mskql, ra, rb, rc, islit, lit); |
975 | 4c9649a9 | j_mayer | break;
|
976 | 4c9649a9 | j_mayer | case 0x34: |
977 | 4c9649a9 | j_mayer | /* SRL */
|
978 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_srl, ra, rb, rc, islit, lit); |
979 | 4c9649a9 | j_mayer | break;
|
980 | 4c9649a9 | j_mayer | case 0x36: |
981 | 4c9649a9 | j_mayer | /* EXTQL */
|
982 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_extql, ra, rb, rc, islit, lit); |
983 | 4c9649a9 | j_mayer | break;
|
984 | 4c9649a9 | j_mayer | case 0x39: |
985 | 4c9649a9 | j_mayer | /* SLL */
|
986 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_sll, ra, rb, rc, islit, lit); |
987 | 4c9649a9 | j_mayer | break;
|
988 | 4c9649a9 | j_mayer | case 0x3B: |
989 | 4c9649a9 | j_mayer | /* INSQL */
|
990 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_insql, ra, rb, rc, islit, lit); |
991 | 4c9649a9 | j_mayer | break;
|
992 | 4c9649a9 | j_mayer | case 0x3C: |
993 | 4c9649a9 | j_mayer | /* SRA */
|
994 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_sra, ra, rb, rc, islit, lit); |
995 | 4c9649a9 | j_mayer | break;
|
996 | 4c9649a9 | j_mayer | case 0x52: |
997 | 4c9649a9 | j_mayer | /* MSKWH */
|
998 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mskwh, ra, rb, rc, islit, lit); |
999 | 4c9649a9 | j_mayer | break;
|
1000 | 4c9649a9 | j_mayer | case 0x57: |
1001 | 4c9649a9 | j_mayer | /* INSWH */
|
1002 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_inswh, ra, rb, rc, islit, lit); |
1003 | 4c9649a9 | j_mayer | break;
|
1004 | 4c9649a9 | j_mayer | case 0x5A: |
1005 | 4c9649a9 | j_mayer | /* EXTWH */
|
1006 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_extwh, ra, rb, rc, islit, lit); |
1007 | 4c9649a9 | j_mayer | break;
|
1008 | 4c9649a9 | j_mayer | case 0x62: |
1009 | 4c9649a9 | j_mayer | /* MSKLH */
|
1010 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_msklh, ra, rb, rc, islit, lit); |
1011 | 4c9649a9 | j_mayer | break;
|
1012 | 4c9649a9 | j_mayer | case 0x67: |
1013 | 4c9649a9 | j_mayer | /* INSLH */
|
1014 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_inslh, ra, rb, rc, islit, lit); |
1015 | 4c9649a9 | j_mayer | break;
|
1016 | 4c9649a9 | j_mayer | case 0x6A: |
1017 | 4c9649a9 | j_mayer | /* EXTLH */
|
1018 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_extlh, ra, rb, rc, islit, lit); |
1019 | 4c9649a9 | j_mayer | break;
|
1020 | 4c9649a9 | j_mayer | case 0x72: |
1021 | 4c9649a9 | j_mayer | /* MSKQH */
|
1022 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mskqh, ra, rb, rc, islit, lit); |
1023 | 4c9649a9 | j_mayer | break;
|
1024 | 4c9649a9 | j_mayer | case 0x77: |
1025 | 4c9649a9 | j_mayer | /* INSQH */
|
1026 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_insqh, ra, rb, rc, islit, lit); |
1027 | 4c9649a9 | j_mayer | break;
|
1028 | 4c9649a9 | j_mayer | case 0x7A: |
1029 | 4c9649a9 | j_mayer | /* EXTQH */
|
1030 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_extqh, ra, rb, rc, islit, lit); |
1031 | 4c9649a9 | j_mayer | break;
|
1032 | 4c9649a9 | j_mayer | default:
|
1033 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1034 | 4c9649a9 | j_mayer | } |
1035 | 4c9649a9 | j_mayer | break;
|
1036 | 4c9649a9 | j_mayer | case 0x13: |
1037 | 4c9649a9 | j_mayer | switch (fn7) {
|
1038 | 4c9649a9 | j_mayer | case 0x00: |
1039 | 4c9649a9 | j_mayer | /* MULL */
|
1040 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mull, ra, rb, rc, islit, lit); |
1041 | 4c9649a9 | j_mayer | break;
|
1042 | 4c9649a9 | j_mayer | case 0x20: |
1043 | 4c9649a9 | j_mayer | /* MULQ */
|
1044 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mulq, ra, rb, rc, islit, lit); |
1045 | 4c9649a9 | j_mayer | break;
|
1046 | 4c9649a9 | j_mayer | case 0x30: |
1047 | 4c9649a9 | j_mayer | /* UMULH */
|
1048 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_umulh, ra, rb, rc, islit, lit); |
1049 | 4c9649a9 | j_mayer | break;
|
1050 | 4c9649a9 | j_mayer | case 0x40: |
1051 | 4c9649a9 | j_mayer | /* MULL/V */
|
1052 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mullv, ra, rb, rc, islit, lit); |
1053 | 4c9649a9 | j_mayer | break;
|
1054 | 4c9649a9 | j_mayer | case 0x60: |
1055 | 4c9649a9 | j_mayer | /* MULQ/V */
|
1056 | 4c9649a9 | j_mayer | gen_arith3(ctx, &gen_op_mulqv, ra, rb, rc, islit, lit); |
1057 | 4c9649a9 | j_mayer | break;
|
1058 | 4c9649a9 | j_mayer | default:
|
1059 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1060 | 4c9649a9 | j_mayer | } |
1061 | 4c9649a9 | j_mayer | break;
|
1062 | 4c9649a9 | j_mayer | case 0x14: |
1063 | 4c9649a9 | j_mayer | switch (fpfn) { /* f11 & 0x3F */ |
1064 | 4c9649a9 | j_mayer | case 0x04: |
1065 | 4c9649a9 | j_mayer | /* ITOFS */
|
1066 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1067 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1068 | 4c9649a9 | j_mayer | gen_itf(ctx, &gen_op_itofs, ra, rc); |
1069 | 4c9649a9 | j_mayer | break;
|
1070 | 4c9649a9 | j_mayer | case 0x0A: |
1071 | 4c9649a9 | j_mayer | /* SQRTF */
|
1072 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1073 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1074 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_sqrtf, rb, rc); |
1075 | 4c9649a9 | j_mayer | break;
|
1076 | 4c9649a9 | j_mayer | case 0x0B: |
1077 | 4c9649a9 | j_mayer | /* SQRTS */
|
1078 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1079 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1080 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_sqrts, rb, rc); |
1081 | 4c9649a9 | j_mayer | break;
|
1082 | 4c9649a9 | j_mayer | case 0x14: |
1083 | 4c9649a9 | j_mayer | /* ITOFF */
|
1084 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1085 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1086 | 4c9649a9 | j_mayer | #if 0 // TODO
|
1087 | 4c9649a9 | j_mayer | gen_itf(ctx, &gen_op_itoff, ra, rc);
|
1088 | 4c9649a9 | j_mayer | #else
|
1089 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1090 | 4c9649a9 | j_mayer | #endif
|
1091 | 4c9649a9 | j_mayer | break;
|
1092 | 4c9649a9 | j_mayer | case 0x24: |
1093 | 4c9649a9 | j_mayer | /* ITOFT */
|
1094 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1095 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1096 | 4c9649a9 | j_mayer | gen_itf(ctx, &gen_op_itoft, ra, rc); |
1097 | 4c9649a9 | j_mayer | break;
|
1098 | 4c9649a9 | j_mayer | case 0x2A: |
1099 | 4c9649a9 | j_mayer | /* SQRTG */
|
1100 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1101 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1102 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_sqrtg, rb, rc); |
1103 | 4c9649a9 | j_mayer | break;
|
1104 | 4c9649a9 | j_mayer | case 0x02B: |
1105 | 4c9649a9 | j_mayer | /* SQRTT */
|
1106 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1107 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1108 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_sqrtt, rb, rc); |
1109 | 4c9649a9 | j_mayer | break;
|
1110 | 4c9649a9 | j_mayer | default:
|
1111 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1112 | 4c9649a9 | j_mayer | } |
1113 | 4c9649a9 | j_mayer | break;
|
1114 | 4c9649a9 | j_mayer | case 0x15: |
1115 | 4c9649a9 | j_mayer | /* VAX floating point */
|
1116 | 4c9649a9 | j_mayer | /* XXX: rounding mode and trap are ignored (!) */
|
1117 | 4c9649a9 | j_mayer | switch (fpfn) { /* f11 & 0x3F */ |
1118 | 4c9649a9 | j_mayer | case 0x00: |
1119 | 4c9649a9 | j_mayer | /* ADDF */
|
1120 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_addf, ra, rb, rc); |
1121 | 4c9649a9 | j_mayer | break;
|
1122 | 4c9649a9 | j_mayer | case 0x01: |
1123 | 4c9649a9 | j_mayer | /* SUBF */
|
1124 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_subf, ra, rb, rc); |
1125 | 4c9649a9 | j_mayer | break;
|
1126 | 4c9649a9 | j_mayer | case 0x02: |
1127 | 4c9649a9 | j_mayer | /* MULF */
|
1128 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_mulf, ra, rb, rc); |
1129 | 4c9649a9 | j_mayer | break;
|
1130 | 4c9649a9 | j_mayer | case 0x03: |
1131 | 4c9649a9 | j_mayer | /* DIVF */
|
1132 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_divf, ra, rb, rc); |
1133 | 4c9649a9 | j_mayer | break;
|
1134 | 4c9649a9 | j_mayer | case 0x1E: |
1135 | 4c9649a9 | j_mayer | /* CVTDG */
|
1136 | 4c9649a9 | j_mayer | #if 0 // TODO
|
1137 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtdg, rb, rc);
|
1138 | 4c9649a9 | j_mayer | #else
|
1139 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1140 | 4c9649a9 | j_mayer | #endif
|
1141 | 4c9649a9 | j_mayer | break;
|
1142 | 4c9649a9 | j_mayer | case 0x20: |
1143 | 4c9649a9 | j_mayer | /* ADDG */
|
1144 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_addg, ra, rb, rc); |
1145 | 4c9649a9 | j_mayer | break;
|
1146 | 4c9649a9 | j_mayer | case 0x21: |
1147 | 4c9649a9 | j_mayer | /* SUBG */
|
1148 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_subg, ra, rb, rc); |
1149 | 4c9649a9 | j_mayer | break;
|
1150 | 4c9649a9 | j_mayer | case 0x22: |
1151 | 4c9649a9 | j_mayer | /* MULG */
|
1152 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_mulg, ra, rb, rc); |
1153 | 4c9649a9 | j_mayer | break;
|
1154 | 4c9649a9 | j_mayer | case 0x23: |
1155 | 4c9649a9 | j_mayer | /* DIVG */
|
1156 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_divg, ra, rb, rc); |
1157 | 4c9649a9 | j_mayer | break;
|
1158 | 4c9649a9 | j_mayer | case 0x25: |
1159 | 4c9649a9 | j_mayer | /* CMPGEQ */
|
1160 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_cmpgeq, ra, rb, rc); |
1161 | 4c9649a9 | j_mayer | break;
|
1162 | 4c9649a9 | j_mayer | case 0x26: |
1163 | 4c9649a9 | j_mayer | /* CMPGLT */
|
1164 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_cmpglt, ra, rb, rc); |
1165 | 4c9649a9 | j_mayer | break;
|
1166 | 4c9649a9 | j_mayer | case 0x27: |
1167 | 4c9649a9 | j_mayer | /* CMPGLE */
|
1168 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_cmpgle, ra, rb, rc); |
1169 | 4c9649a9 | j_mayer | break;
|
1170 | 4c9649a9 | j_mayer | case 0x2C: |
1171 | 4c9649a9 | j_mayer | /* CVTGF */
|
1172 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtgf, rb, rc); |
1173 | 4c9649a9 | j_mayer | break;
|
1174 | 4c9649a9 | j_mayer | case 0x2D: |
1175 | 4c9649a9 | j_mayer | /* CVTGD */
|
1176 | 4c9649a9 | j_mayer | #if 0 // TODO
|
1177 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtgd, rb, rc);
|
1178 | 4c9649a9 | j_mayer | #else
|
1179 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1180 | 4c9649a9 | j_mayer | #endif
|
1181 | 4c9649a9 | j_mayer | break;
|
1182 | 4c9649a9 | j_mayer | case 0x2F: |
1183 | 4c9649a9 | j_mayer | /* CVTGQ */
|
1184 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtgq, rb, rc); |
1185 | 4c9649a9 | j_mayer | break;
|
1186 | 4c9649a9 | j_mayer | case 0x3C: |
1187 | 4c9649a9 | j_mayer | /* CVTQF */
|
1188 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtqf, rb, rc); |
1189 | 4c9649a9 | j_mayer | break;
|
1190 | 4c9649a9 | j_mayer | case 0x3E: |
1191 | 4c9649a9 | j_mayer | /* CVTQG */
|
1192 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtqg, rb, rc); |
1193 | 4c9649a9 | j_mayer | break;
|
1194 | 4c9649a9 | j_mayer | default:
|
1195 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1196 | 4c9649a9 | j_mayer | } |
1197 | 4c9649a9 | j_mayer | break;
|
1198 | 4c9649a9 | j_mayer | case 0x16: |
1199 | 4c9649a9 | j_mayer | /* IEEE floating-point */
|
1200 | 4c9649a9 | j_mayer | /* XXX: rounding mode and traps are ignored (!) */
|
1201 | 4c9649a9 | j_mayer | switch (fpfn) { /* f11 & 0x3F */ |
1202 | 4c9649a9 | j_mayer | case 0x00: |
1203 | 4c9649a9 | j_mayer | /* ADDS */
|
1204 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_adds, ra, rb, rc); |
1205 | 4c9649a9 | j_mayer | break;
|
1206 | 4c9649a9 | j_mayer | case 0x01: |
1207 | 4c9649a9 | j_mayer | /* SUBS */
|
1208 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_subs, ra, rb, rc); |
1209 | 4c9649a9 | j_mayer | break;
|
1210 | 4c9649a9 | j_mayer | case 0x02: |
1211 | 4c9649a9 | j_mayer | /* MULS */
|
1212 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_muls, ra, rb, rc); |
1213 | 4c9649a9 | j_mayer | break;
|
1214 | 4c9649a9 | j_mayer | case 0x03: |
1215 | 4c9649a9 | j_mayer | /* DIVS */
|
1216 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_divs, ra, rb, rc); |
1217 | 4c9649a9 | j_mayer | break;
|
1218 | 4c9649a9 | j_mayer | case 0x20: |
1219 | 4c9649a9 | j_mayer | /* ADDT */
|
1220 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_addt, ra, rb, rc); |
1221 | 4c9649a9 | j_mayer | break;
|
1222 | 4c9649a9 | j_mayer | case 0x21: |
1223 | 4c9649a9 | j_mayer | /* SUBT */
|
1224 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_subt, ra, rb, rc); |
1225 | 4c9649a9 | j_mayer | break;
|
1226 | 4c9649a9 | j_mayer | case 0x22: |
1227 | 4c9649a9 | j_mayer | /* MULT */
|
1228 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_mult, ra, rb, rc); |
1229 | 4c9649a9 | j_mayer | break;
|
1230 | 4c9649a9 | j_mayer | case 0x23: |
1231 | 4c9649a9 | j_mayer | /* DIVT */
|
1232 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_divt, ra, rb, rc); |
1233 | 4c9649a9 | j_mayer | break;
|
1234 | 4c9649a9 | j_mayer | case 0x24: |
1235 | 4c9649a9 | j_mayer | /* CMPTUN */
|
1236 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_cmptun, ra, rb, rc); |
1237 | 4c9649a9 | j_mayer | break;
|
1238 | 4c9649a9 | j_mayer | case 0x25: |
1239 | 4c9649a9 | j_mayer | /* CMPTEQ */
|
1240 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_cmpteq, ra, rb, rc); |
1241 | 4c9649a9 | j_mayer | break;
|
1242 | 4c9649a9 | j_mayer | case 0x26: |
1243 | 4c9649a9 | j_mayer | /* CMPTLT */
|
1244 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_cmptlt, ra, rb, rc); |
1245 | 4c9649a9 | j_mayer | break;
|
1246 | 4c9649a9 | j_mayer | case 0x27: |
1247 | 4c9649a9 | j_mayer | /* CMPTLE */
|
1248 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_cmptle, ra, rb, rc); |
1249 | 4c9649a9 | j_mayer | break;
|
1250 | 4c9649a9 | j_mayer | case 0x2C: |
1251 | 4c9649a9 | j_mayer | /* XXX: incorrect */
|
1252 | 4c9649a9 | j_mayer | if (fn11 == 0x2AC) { |
1253 | 4c9649a9 | j_mayer | /* CVTST */
|
1254 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtst, rb, rc); |
1255 | 4c9649a9 | j_mayer | } else {
|
1256 | 4c9649a9 | j_mayer | /* CVTTS */
|
1257 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtts, rb, rc); |
1258 | 4c9649a9 | j_mayer | } |
1259 | 4c9649a9 | j_mayer | break;
|
1260 | 4c9649a9 | j_mayer | case 0x2F: |
1261 | 4c9649a9 | j_mayer | /* CVTTQ */
|
1262 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvttq, rb, rc); |
1263 | 4c9649a9 | j_mayer | break;
|
1264 | 4c9649a9 | j_mayer | case 0x3C: |
1265 | 4c9649a9 | j_mayer | /* CVTQS */
|
1266 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtqs, rb, rc); |
1267 | 4c9649a9 | j_mayer | break;
|
1268 | 4c9649a9 | j_mayer | case 0x3E: |
1269 | 4c9649a9 | j_mayer | /* CVTQT */
|
1270 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtqt, rb, rc); |
1271 | 4c9649a9 | j_mayer | break;
|
1272 | 4c9649a9 | j_mayer | default:
|
1273 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1274 | 4c9649a9 | j_mayer | } |
1275 | 4c9649a9 | j_mayer | break;
|
1276 | 4c9649a9 | j_mayer | case 0x17: |
1277 | 4c9649a9 | j_mayer | switch (fn11) {
|
1278 | 4c9649a9 | j_mayer | case 0x010: |
1279 | 4c9649a9 | j_mayer | /* CVTLQ */
|
1280 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtlq, rb, rc); |
1281 | 4c9649a9 | j_mayer | break;
|
1282 | 4c9649a9 | j_mayer | case 0x020: |
1283 | 4c9649a9 | j_mayer | /* CPYS */
|
1284 | 4c9649a9 | j_mayer | if (ra == rb) {
|
1285 | 4c9649a9 | j_mayer | if (ra == 31 && rc == 31) { |
1286 | 4c9649a9 | j_mayer | /* FNOP */
|
1287 | 4c9649a9 | j_mayer | gen_op_nop(); |
1288 | 4c9649a9 | j_mayer | } else {
|
1289 | 4c9649a9 | j_mayer | /* FMOV */
|
1290 | 4c9649a9 | j_mayer | gen_load_fir(ctx, rb, 0);
|
1291 | 4c9649a9 | j_mayer | gen_store_fir(ctx, rc, 0);
|
1292 | 4c9649a9 | j_mayer | } |
1293 | 4c9649a9 | j_mayer | } else {
|
1294 | 4c9649a9 | j_mayer | gen_farith3(ctx, &gen_op_cpys, ra, rb, rc); |
1295 | 4c9649a9 | j_mayer | } |
1296 | 4c9649a9 | j_mayer | break;
|
1297 | 4c9649a9 | j_mayer | case 0x021: |
1298 | 4c9649a9 | j_mayer | /* CPYSN */
|
1299 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cpysn, rb, rc); |
1300 | 4c9649a9 | j_mayer | break;
|
1301 | 4c9649a9 | j_mayer | case 0x022: |
1302 | 4c9649a9 | j_mayer | /* CPYSE */
|
1303 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cpyse, rb, rc); |
1304 | 4c9649a9 | j_mayer | break;
|
1305 | 4c9649a9 | j_mayer | case 0x024: |
1306 | 4c9649a9 | j_mayer | /* MT_FPCR */
|
1307 | 4c9649a9 | j_mayer | gen_load_fir(ctx, ra, 0);
|
1308 | 4c9649a9 | j_mayer | gen_op_store_fpcr(); |
1309 | 4c9649a9 | j_mayer | break;
|
1310 | 4c9649a9 | j_mayer | case 0x025: |
1311 | 4c9649a9 | j_mayer | /* MF_FPCR */
|
1312 | 4c9649a9 | j_mayer | gen_op_load_fpcr(); |
1313 | 4c9649a9 | j_mayer | gen_store_fir(ctx, ra, 0);
|
1314 | 4c9649a9 | j_mayer | break;
|
1315 | 4c9649a9 | j_mayer | case 0x02A: |
1316 | 4c9649a9 | j_mayer | /* FCMOVEQ */
|
1317 | 4c9649a9 | j_mayer | gen_fcmov(ctx, &gen_op_cmpfeq, ra, rb, rc); |
1318 | 4c9649a9 | j_mayer | break;
|
1319 | 4c9649a9 | j_mayer | case 0x02B: |
1320 | 4c9649a9 | j_mayer | /* FCMOVNE */
|
1321 | 4c9649a9 | j_mayer | gen_fcmov(ctx, &gen_op_cmpfne, ra, rb, rc); |
1322 | 4c9649a9 | j_mayer | break;
|
1323 | 4c9649a9 | j_mayer | case 0x02C: |
1324 | 4c9649a9 | j_mayer | /* FCMOVLT */
|
1325 | 4c9649a9 | j_mayer | gen_fcmov(ctx, &gen_op_cmpflt, ra, rb, rc); |
1326 | 4c9649a9 | j_mayer | break;
|
1327 | 4c9649a9 | j_mayer | case 0x02D: |
1328 | 4c9649a9 | j_mayer | /* FCMOVGE */
|
1329 | 4c9649a9 | j_mayer | gen_fcmov(ctx, &gen_op_cmpfge, ra, rb, rc); |
1330 | 4c9649a9 | j_mayer | break;
|
1331 | 4c9649a9 | j_mayer | case 0x02E: |
1332 | 4c9649a9 | j_mayer | /* FCMOVLE */
|
1333 | 4c9649a9 | j_mayer | gen_fcmov(ctx, &gen_op_cmpfle, ra, rb, rc); |
1334 | 4c9649a9 | j_mayer | break;
|
1335 | 4c9649a9 | j_mayer | case 0x02F: |
1336 | 4c9649a9 | j_mayer | /* FCMOVGT */
|
1337 | 4c9649a9 | j_mayer | gen_fcmov(ctx, &gen_op_cmpfgt, ra, rb, rc); |
1338 | 4c9649a9 | j_mayer | break;
|
1339 | 4c9649a9 | j_mayer | case 0x030: |
1340 | 4c9649a9 | j_mayer | /* CVTQL */
|
1341 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtql, rb, rc); |
1342 | 4c9649a9 | j_mayer | break;
|
1343 | 4c9649a9 | j_mayer | case 0x130: |
1344 | 4c9649a9 | j_mayer | /* CVTQL/V */
|
1345 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtqlv, rb, rc); |
1346 | 4c9649a9 | j_mayer | break;
|
1347 | 4c9649a9 | j_mayer | case 0x530: |
1348 | 4c9649a9 | j_mayer | /* CVTQL/SV */
|
1349 | 4c9649a9 | j_mayer | gen_farith2(ctx, &gen_op_cvtqlsv, rb, rc); |
1350 | 4c9649a9 | j_mayer | break;
|
1351 | 4c9649a9 | j_mayer | default:
|
1352 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1353 | 4c9649a9 | j_mayer | } |
1354 | 4c9649a9 | j_mayer | break;
|
1355 | 4c9649a9 | j_mayer | case 0x18: |
1356 | 4c9649a9 | j_mayer | switch ((uint16_t)disp16) {
|
1357 | 4c9649a9 | j_mayer | case 0x0000: |
1358 | 4c9649a9 | j_mayer | /* TRAPB */
|
1359 | 4c9649a9 | j_mayer | /* No-op. Just exit from the current tb */
|
1360 | 4c9649a9 | j_mayer | ret = 2;
|
1361 | 4c9649a9 | j_mayer | break;
|
1362 | 4c9649a9 | j_mayer | case 0x0400: |
1363 | 4c9649a9 | j_mayer | /* EXCB */
|
1364 | 4c9649a9 | j_mayer | /* No-op. Just exit from the current tb */
|
1365 | 4c9649a9 | j_mayer | ret = 2;
|
1366 | 4c9649a9 | j_mayer | break;
|
1367 | 4c9649a9 | j_mayer | case 0x4000: |
1368 | 4c9649a9 | j_mayer | /* MB */
|
1369 | 4c9649a9 | j_mayer | /* No-op */
|
1370 | 4c9649a9 | j_mayer | break;
|
1371 | 4c9649a9 | j_mayer | case 0x4400: |
1372 | 4c9649a9 | j_mayer | /* WMB */
|
1373 | 4c9649a9 | j_mayer | /* No-op */
|
1374 | 4c9649a9 | j_mayer | break;
|
1375 | 4c9649a9 | j_mayer | case 0x8000: |
1376 | 4c9649a9 | j_mayer | /* FETCH */
|
1377 | 4c9649a9 | j_mayer | /* No-op */
|
1378 | 4c9649a9 | j_mayer | break;
|
1379 | 4c9649a9 | j_mayer | case 0xA000: |
1380 | 4c9649a9 | j_mayer | /* FETCH_M */
|
1381 | 4c9649a9 | j_mayer | /* No-op */
|
1382 | 4c9649a9 | j_mayer | break;
|
1383 | 4c9649a9 | j_mayer | case 0xC000: |
1384 | 4c9649a9 | j_mayer | /* RPCC */
|
1385 | 4c9649a9 | j_mayer | gen_op_load_pcc(); |
1386 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 0);
|
1387 | 4c9649a9 | j_mayer | break;
|
1388 | 4c9649a9 | j_mayer | case 0xE000: |
1389 | 4c9649a9 | j_mayer | /* RC */
|
1390 | 4c9649a9 | j_mayer | gen_op_load_irf(); |
1391 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 0);
|
1392 | 4c9649a9 | j_mayer | gen_op_clear_irf(); |
1393 | 4c9649a9 | j_mayer | break;
|
1394 | 4c9649a9 | j_mayer | case 0xE800: |
1395 | 4c9649a9 | j_mayer | /* ECB */
|
1396 | 4c9649a9 | j_mayer | /* XXX: TODO: evict tb cache at address rb */
|
1397 | 4c9649a9 | j_mayer | #if 0
|
1398 | 4c9649a9 | j_mayer | ret = 2;
|
1399 | 4c9649a9 | j_mayer | #else
|
1400 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1401 | 4c9649a9 | j_mayer | #endif
|
1402 | 4c9649a9 | j_mayer | break;
|
1403 | 4c9649a9 | j_mayer | case 0xF000: |
1404 | 4c9649a9 | j_mayer | /* RS */
|
1405 | 4c9649a9 | j_mayer | gen_op_load_irf(); |
1406 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 0);
|
1407 | 4c9649a9 | j_mayer | gen_op_set_irf(); |
1408 | 4c9649a9 | j_mayer | break;
|
1409 | 4c9649a9 | j_mayer | case 0xF800: |
1410 | 4c9649a9 | j_mayer | /* WH64 */
|
1411 | 4c9649a9 | j_mayer | /* No-op */
|
1412 | 4c9649a9 | j_mayer | break;
|
1413 | 4c9649a9 | j_mayer | default:
|
1414 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1415 | 4c9649a9 | j_mayer | } |
1416 | 4c9649a9 | j_mayer | break;
|
1417 | 4c9649a9 | j_mayer | case 0x19: |
1418 | 4c9649a9 | j_mayer | /* HW_MFPR (PALcode) */
|
1419 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
1420 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1421 | 4c9649a9 | j_mayer | #else
|
1422 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
1423 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1424 | 4c9649a9 | j_mayer | gen_op_mfpr(insn & 0xFF);
|
1425 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 0);
|
1426 | 4c9649a9 | j_mayer | break;
|
1427 | 4c9649a9 | j_mayer | #endif
|
1428 | 4c9649a9 | j_mayer | case 0x1A: |
1429 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
1430 | 4c9649a9 | j_mayer | if (ra != 31) { |
1431 | 4c9649a9 | j_mayer | gen_set_uT1(ctx, ctx->pc); |
1432 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 1);
|
1433 | 4c9649a9 | j_mayer | } |
1434 | 4c9649a9 | j_mayer | gen_op_branch(); |
1435 | 4c9649a9 | j_mayer | /* Those four jumps only differ by the branch prediction hint */
|
1436 | 4c9649a9 | j_mayer | switch (fn2) {
|
1437 | 4c9649a9 | j_mayer | case 0x0: |
1438 | 4c9649a9 | j_mayer | /* JMP */
|
1439 | 4c9649a9 | j_mayer | break;
|
1440 | 4c9649a9 | j_mayer | case 0x1: |
1441 | 4c9649a9 | j_mayer | /* JSR */
|
1442 | 4c9649a9 | j_mayer | break;
|
1443 | 4c9649a9 | j_mayer | case 0x2: |
1444 | 4c9649a9 | j_mayer | /* RET */
|
1445 | 4c9649a9 | j_mayer | break;
|
1446 | 4c9649a9 | j_mayer | case 0x3: |
1447 | 4c9649a9 | j_mayer | /* JSR_COROUTINE */
|
1448 | 4c9649a9 | j_mayer | break;
|
1449 | 4c9649a9 | j_mayer | } |
1450 | 4c9649a9 | j_mayer | ret = 1;
|
1451 | 4c9649a9 | j_mayer | break;
|
1452 | 4c9649a9 | j_mayer | case 0x1B: |
1453 | 4c9649a9 | j_mayer | /* HW_LD (PALcode) */
|
1454 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
1455 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1456 | 4c9649a9 | j_mayer | #else
|
1457 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
1458 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1459 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
1460 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp12); |
1461 | 4c9649a9 | j_mayer | gen_op_addq(); |
1462 | 4c9649a9 | j_mayer | switch ((insn >> 12) & 0xF) { |
1463 | 4c9649a9 | j_mayer | case 0x0: |
1464 | 4c9649a9 | j_mayer | /* Longword physical access */
|
1465 | 4c9649a9 | j_mayer | gen_op_ldl_raw(); |
1466 | 4c9649a9 | j_mayer | break;
|
1467 | 4c9649a9 | j_mayer | case 0x1: |
1468 | 4c9649a9 | j_mayer | /* Quadword physical access */
|
1469 | 4c9649a9 | j_mayer | gen_op_ldq_raw(); |
1470 | 4c9649a9 | j_mayer | break;
|
1471 | 4c9649a9 | j_mayer | case 0x2: |
1472 | 4c9649a9 | j_mayer | /* Longword physical access with lock */
|
1473 | 4c9649a9 | j_mayer | gen_op_ldl_l_raw(); |
1474 | 4c9649a9 | j_mayer | break;
|
1475 | 4c9649a9 | j_mayer | case 0x3: |
1476 | 4c9649a9 | j_mayer | /* Quadword physical access with lock */
|
1477 | 4c9649a9 | j_mayer | gen_op_ldq_l_raw(); |
1478 | 4c9649a9 | j_mayer | break;
|
1479 | 4c9649a9 | j_mayer | case 0x4: |
1480 | 4c9649a9 | j_mayer | /* Longword virtual PTE fetch */
|
1481 | 4c9649a9 | j_mayer | gen_op_ldl_kernel(); |
1482 | 4c9649a9 | j_mayer | break;
|
1483 | 4c9649a9 | j_mayer | case 0x5: |
1484 | 4c9649a9 | j_mayer | /* Quadword virtual PTE fetch */
|
1485 | 4c9649a9 | j_mayer | gen_op_ldq_kernel(); |
1486 | 4c9649a9 | j_mayer | break;
|
1487 | 4c9649a9 | j_mayer | case 0x6: |
1488 | 4c9649a9 | j_mayer | /* Invalid */
|
1489 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1490 | 4c9649a9 | j_mayer | case 0x7: |
1491 | 4c9649a9 | j_mayer | /* Invalid */
|
1492 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1493 | 4c9649a9 | j_mayer | case 0x8: |
1494 | 4c9649a9 | j_mayer | /* Longword virtual access */
|
1495 | 4c9649a9 | j_mayer | gen_op_ld_phys_to_virt(); |
1496 | 4c9649a9 | j_mayer | gen_op_ldl_raw(); |
1497 | 4c9649a9 | j_mayer | break;
|
1498 | 4c9649a9 | j_mayer | case 0x9: |
1499 | 4c9649a9 | j_mayer | /* Quadword virtual access */
|
1500 | 4c9649a9 | j_mayer | gen_op_ld_phys_to_virt(); |
1501 | 4c9649a9 | j_mayer | gen_op_ldq_raw(); |
1502 | 4c9649a9 | j_mayer | break;
|
1503 | 4c9649a9 | j_mayer | case 0xA: |
1504 | 4c9649a9 | j_mayer | /* Longword virtual access with protection check */
|
1505 | 4c9649a9 | j_mayer | gen_ldl(ctx); |
1506 | 4c9649a9 | j_mayer | break;
|
1507 | 4c9649a9 | j_mayer | case 0xB: |
1508 | 4c9649a9 | j_mayer | /* Quadword virtual access with protection check */
|
1509 | 4c9649a9 | j_mayer | gen_ldq(ctx); |
1510 | 4c9649a9 | j_mayer | break;
|
1511 | 4c9649a9 | j_mayer | case 0xC: |
1512 | 4c9649a9 | j_mayer | /* Longword virtual access with altenate access mode */
|
1513 | 4c9649a9 | j_mayer | gen_op_set_alt_mode(); |
1514 | 4c9649a9 | j_mayer | gen_op_ld_phys_to_virt(); |
1515 | 4c9649a9 | j_mayer | gen_op_ldl_raw(); |
1516 | 4c9649a9 | j_mayer | gen_op_restore_mode(); |
1517 | 4c9649a9 | j_mayer | break;
|
1518 | 4c9649a9 | j_mayer | case 0xD: |
1519 | 4c9649a9 | j_mayer | /* Quadword virtual access with altenate access mode */
|
1520 | 4c9649a9 | j_mayer | gen_op_set_alt_mode(); |
1521 | 4c9649a9 | j_mayer | gen_op_ld_phys_to_virt(); |
1522 | 4c9649a9 | j_mayer | gen_op_ldq_raw(); |
1523 | 4c9649a9 | j_mayer | gen_op_restore_mode(); |
1524 | 4c9649a9 | j_mayer | break;
|
1525 | 4c9649a9 | j_mayer | case 0xE: |
1526 | 4c9649a9 | j_mayer | /* Longword virtual access with alternate access mode and
|
1527 | 4c9649a9 | j_mayer | * protection checks
|
1528 | 4c9649a9 | j_mayer | */
|
1529 | 4c9649a9 | j_mayer | gen_op_set_alt_mode(); |
1530 | 4c9649a9 | j_mayer | gen_op_ldl_data(); |
1531 | 4c9649a9 | j_mayer | gen_op_restore_mode(); |
1532 | 4c9649a9 | j_mayer | break;
|
1533 | 4c9649a9 | j_mayer | case 0xF: |
1534 | 4c9649a9 | j_mayer | /* Quadword virtual access with alternate access mode and
|
1535 | 4c9649a9 | j_mayer | * protection checks
|
1536 | 4c9649a9 | j_mayer | */
|
1537 | 4c9649a9 | j_mayer | gen_op_set_alt_mode(); |
1538 | 4c9649a9 | j_mayer | gen_op_ldq_data(); |
1539 | 4c9649a9 | j_mayer | gen_op_restore_mode(); |
1540 | 4c9649a9 | j_mayer | break;
|
1541 | 4c9649a9 | j_mayer | } |
1542 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 1);
|
1543 | 4c9649a9 | j_mayer | break;
|
1544 | 4c9649a9 | j_mayer | #endif
|
1545 | 4c9649a9 | j_mayer | case 0x1C: |
1546 | 4c9649a9 | j_mayer | switch (fn7) {
|
1547 | 4c9649a9 | j_mayer | case 0x00: |
1548 | 4c9649a9 | j_mayer | /* SEXTB */
|
1549 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
1550 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1551 | 4c9649a9 | j_mayer | gen_arith2(ctx, &gen_op_sextb, rb, rc, islit, lit); |
1552 | 4c9649a9 | j_mayer | break;
|
1553 | 4c9649a9 | j_mayer | case 0x01: |
1554 | 4c9649a9 | j_mayer | /* SEXTW */
|
1555 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
1556 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1557 | 4c9649a9 | j_mayer | gen_arith2(ctx, &gen_op_sextw, rb, rc, islit, lit); |
1558 | 4c9649a9 | j_mayer | break;
|
1559 | 4c9649a9 | j_mayer | case 0x30: |
1560 | 4c9649a9 | j_mayer | /* CTPOP */
|
1561 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_CIX))
|
1562 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1563 | 4c9649a9 | j_mayer | gen_arith2(ctx, &gen_op_ctpop, rb, rc, 0, 0); |
1564 | 4c9649a9 | j_mayer | break;
|
1565 | 4c9649a9 | j_mayer | case 0x31: |
1566 | 4c9649a9 | j_mayer | /* PERR */
|
1567 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1568 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1569 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1570 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1571 | 4c9649a9 | j_mayer | break;
|
1572 | 4c9649a9 | j_mayer | case 0x32: |
1573 | 4c9649a9 | j_mayer | /* CTLZ */
|
1574 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_CIX))
|
1575 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1576 | 4c9649a9 | j_mayer | gen_arith2(ctx, &gen_op_ctlz, rb, rc, 0, 0); |
1577 | 4c9649a9 | j_mayer | break;
|
1578 | 4c9649a9 | j_mayer | case 0x33: |
1579 | 4c9649a9 | j_mayer | /* CTTZ */
|
1580 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_CIX))
|
1581 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1582 | 4c9649a9 | j_mayer | gen_arith2(ctx, &gen_op_cttz, rb, rc, 0, 0); |
1583 | 4c9649a9 | j_mayer | break;
|
1584 | 4c9649a9 | j_mayer | case 0x34: |
1585 | 4c9649a9 | j_mayer | /* UNPKBW */
|
1586 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1587 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1588 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1589 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1590 | 4c9649a9 | j_mayer | break;
|
1591 | 4c9649a9 | j_mayer | case 0x35: |
1592 | 4c9649a9 | j_mayer | /* UNPKWL */
|
1593 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1594 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1595 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1596 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1597 | 4c9649a9 | j_mayer | break;
|
1598 | 4c9649a9 | j_mayer | case 0x36: |
1599 | 4c9649a9 | j_mayer | /* PKWB */
|
1600 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1601 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1602 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1603 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1604 | 4c9649a9 | j_mayer | break;
|
1605 | 4c9649a9 | j_mayer | case 0x37: |
1606 | 4c9649a9 | j_mayer | /* PKLB */
|
1607 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1608 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1609 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1610 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1611 | 4c9649a9 | j_mayer | break;
|
1612 | 4c9649a9 | j_mayer | case 0x38: |
1613 | 4c9649a9 | j_mayer | /* MINSB8 */
|
1614 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1615 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1616 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1617 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1618 | 4c9649a9 | j_mayer | break;
|
1619 | 4c9649a9 | j_mayer | case 0x39: |
1620 | 4c9649a9 | j_mayer | /* MINSW4 */
|
1621 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1622 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1623 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1624 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1625 | 4c9649a9 | j_mayer | break;
|
1626 | 4c9649a9 | j_mayer | case 0x3A: |
1627 | 4c9649a9 | j_mayer | /* MINUB8 */
|
1628 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1629 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1630 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1631 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1632 | 4c9649a9 | j_mayer | break;
|
1633 | 4c9649a9 | j_mayer | case 0x3B: |
1634 | 4c9649a9 | j_mayer | /* MINUW4 */
|
1635 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1636 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1637 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1638 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1639 | 4c9649a9 | j_mayer | break;
|
1640 | 4c9649a9 | j_mayer | case 0x3C: |
1641 | 4c9649a9 | j_mayer | /* MAXUB8 */
|
1642 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1643 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1644 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1645 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1646 | 4c9649a9 | j_mayer | break;
|
1647 | 4c9649a9 | j_mayer | case 0x3D: |
1648 | 4c9649a9 | j_mayer | /* MAXUW4 */
|
1649 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1650 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1651 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1652 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1653 | 4c9649a9 | j_mayer | break;
|
1654 | 4c9649a9 | j_mayer | case 0x3E: |
1655 | 4c9649a9 | j_mayer | /* MAXSB8 */
|
1656 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1657 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1658 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1659 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1660 | 4c9649a9 | j_mayer | break;
|
1661 | 4c9649a9 | j_mayer | case 0x3F: |
1662 | 4c9649a9 | j_mayer | /* MAXSW4 */
|
1663 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1664 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1665 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1666 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1667 | 4c9649a9 | j_mayer | break;
|
1668 | 4c9649a9 | j_mayer | case 0x70: |
1669 | 4c9649a9 | j_mayer | /* FTOIT */
|
1670 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1671 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1672 | 4c9649a9 | j_mayer | gen_fti(ctx, &gen_op_ftoit, ra, rb); |
1673 | 4c9649a9 | j_mayer | break;
|
1674 | 4c9649a9 | j_mayer | case 0x78: |
1675 | 4c9649a9 | j_mayer | /* FTOIS */
|
1676 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1677 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1678 | 4c9649a9 | j_mayer | gen_fti(ctx, &gen_op_ftois, ra, rb); |
1679 | 4c9649a9 | j_mayer | break;
|
1680 | 4c9649a9 | j_mayer | default:
|
1681 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1682 | 4c9649a9 | j_mayer | } |
1683 | 4c9649a9 | j_mayer | break;
|
1684 | 4c9649a9 | j_mayer | case 0x1D: |
1685 | 4c9649a9 | j_mayer | /* HW_MTPR (PALcode) */
|
1686 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
1687 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1688 | 4c9649a9 | j_mayer | #else
|
1689 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
1690 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1691 | 4c9649a9 | j_mayer | gen_load_ir(ctx, ra, 0);
|
1692 | 4c9649a9 | j_mayer | gen_op_mtpr(insn & 0xFF);
|
1693 | 4c9649a9 | j_mayer | ret = 2;
|
1694 | 4c9649a9 | j_mayer | break;
|
1695 | 4c9649a9 | j_mayer | #endif
|
1696 | 4c9649a9 | j_mayer | case 0x1E: |
1697 | 4c9649a9 | j_mayer | /* HW_REI (PALcode) */
|
1698 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
1699 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1700 | 4c9649a9 | j_mayer | #else
|
1701 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
1702 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1703 | 4c9649a9 | j_mayer | if (rb == 31) { |
1704 | 4c9649a9 | j_mayer | /* "Old" alpha */
|
1705 | 4c9649a9 | j_mayer | gen_op_hw_rei(); |
1706 | 4c9649a9 | j_mayer | } else {
|
1707 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
1708 | 4c9649a9 | j_mayer | gen_set_uT1(ctx, (((int64_t)insn << 51) >> 51)); |
1709 | 4c9649a9 | j_mayer | gen_op_addq(); |
1710 | 4c9649a9 | j_mayer | gen_op_hw_ret(); |
1711 | 4c9649a9 | j_mayer | } |
1712 | 4c9649a9 | j_mayer | ret = 2;
|
1713 | 4c9649a9 | j_mayer | break;
|
1714 | 4c9649a9 | j_mayer | #endif
|
1715 | 4c9649a9 | j_mayer | case 0x1F: |
1716 | 4c9649a9 | j_mayer | /* HW_ST (PALcode) */
|
1717 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
1718 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1719 | 4c9649a9 | j_mayer | #else
|
1720 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
1721 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1722 | 4c9649a9 | j_mayer | gen_load_ir(ctx, rb, 0);
|
1723 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp12); |
1724 | 4c9649a9 | j_mayer | gen_op_addq(); |
1725 | 4c9649a9 | j_mayer | gen_load_ir(ctx, ra, 1);
|
1726 | 4c9649a9 | j_mayer | switch ((insn >> 12) & 0xF) { |
1727 | 4c9649a9 | j_mayer | case 0x0: |
1728 | 4c9649a9 | j_mayer | /* Longword physical access */
|
1729 | 4c9649a9 | j_mayer | gen_op_stl_raw(); |
1730 | 4c9649a9 | j_mayer | break;
|
1731 | 4c9649a9 | j_mayer | case 0x1: |
1732 | 4c9649a9 | j_mayer | /* Quadword physical access */
|
1733 | 4c9649a9 | j_mayer | gen_op_stq_raw(); |
1734 | 4c9649a9 | j_mayer | break;
|
1735 | 4c9649a9 | j_mayer | case 0x2: |
1736 | 4c9649a9 | j_mayer | /* Longword physical access with lock */
|
1737 | 4c9649a9 | j_mayer | gen_op_stl_c_raw(); |
1738 | 4c9649a9 | j_mayer | break;
|
1739 | 4c9649a9 | j_mayer | case 0x3: |
1740 | 4c9649a9 | j_mayer | /* Quadword physical access with lock */
|
1741 | 4c9649a9 | j_mayer | gen_op_stq_c_raw(); |
1742 | 4c9649a9 | j_mayer | break;
|
1743 | 4c9649a9 | j_mayer | case 0x4: |
1744 | 4c9649a9 | j_mayer | /* Longword virtual access */
|
1745 | 4c9649a9 | j_mayer | gen_op_st_phys_to_virt(); |
1746 | 4c9649a9 | j_mayer | gen_op_stl_raw(); |
1747 | 4c9649a9 | j_mayer | break;
|
1748 | 4c9649a9 | j_mayer | case 0x5: |
1749 | 4c9649a9 | j_mayer | /* Quadword virtual access */
|
1750 | 4c9649a9 | j_mayer | gen_op_st_phys_to_virt(); |
1751 | 4c9649a9 | j_mayer | gen_op_stq_raw(); |
1752 | 4c9649a9 | j_mayer | break;
|
1753 | 4c9649a9 | j_mayer | case 0x6: |
1754 | 4c9649a9 | j_mayer | /* Invalid */
|
1755 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1756 | 4c9649a9 | j_mayer | case 0x7: |
1757 | 4c9649a9 | j_mayer | /* Invalid */
|
1758 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1759 | 4c9649a9 | j_mayer | case 0x8: |
1760 | 4c9649a9 | j_mayer | /* Invalid */
|
1761 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1762 | 4c9649a9 | j_mayer | case 0x9: |
1763 | 4c9649a9 | j_mayer | /* Invalid */
|
1764 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1765 | 4c9649a9 | j_mayer | case 0xA: |
1766 | 4c9649a9 | j_mayer | /* Invalid */
|
1767 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1768 | 4c9649a9 | j_mayer | case 0xB: |
1769 | 4c9649a9 | j_mayer | /* Invalid */
|
1770 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1771 | 4c9649a9 | j_mayer | case 0xC: |
1772 | 4c9649a9 | j_mayer | /* Longword virtual access with alternate access mode */
|
1773 | 4c9649a9 | j_mayer | gen_op_set_alt_mode(); |
1774 | 4c9649a9 | j_mayer | gen_op_st_phys_to_virt(); |
1775 | 4c9649a9 | j_mayer | gen_op_ldl_raw(); |
1776 | 4c9649a9 | j_mayer | gen_op_restore_mode(); |
1777 | 4c9649a9 | j_mayer | break;
|
1778 | 4c9649a9 | j_mayer | case 0xD: |
1779 | 4c9649a9 | j_mayer | /* Quadword virtual access with alternate access mode */
|
1780 | 4c9649a9 | j_mayer | gen_op_set_alt_mode(); |
1781 | 4c9649a9 | j_mayer | gen_op_st_phys_to_virt(); |
1782 | 4c9649a9 | j_mayer | gen_op_ldq_raw(); |
1783 | 4c9649a9 | j_mayer | gen_op_restore_mode(); |
1784 | 4c9649a9 | j_mayer | break;
|
1785 | 4c9649a9 | j_mayer | case 0xE: |
1786 | 4c9649a9 | j_mayer | /* Invalid */
|
1787 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1788 | 4c9649a9 | j_mayer | case 0xF: |
1789 | 4c9649a9 | j_mayer | /* Invalid */
|
1790 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1791 | 4c9649a9 | j_mayer | } |
1792 | 4c9649a9 | j_mayer | ret = 2;
|
1793 | 4c9649a9 | j_mayer | break;
|
1794 | 4c9649a9 | j_mayer | #endif
|
1795 | 4c9649a9 | j_mayer | case 0x20: |
1796 | 4c9649a9 | j_mayer | /* LDF */
|
1797 | 4c9649a9 | j_mayer | #if 0 // TODO
|
1798 | 4c9649a9 | j_mayer | gen_load_fmem(ctx, &gen_ldf, ra, rb, disp16);
|
1799 | 4c9649a9 | j_mayer | #else
|
1800 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1801 | 4c9649a9 | j_mayer | #endif
|
1802 | 4c9649a9 | j_mayer | break;
|
1803 | 4c9649a9 | j_mayer | case 0x21: |
1804 | 4c9649a9 | j_mayer | /* LDG */
|
1805 | 4c9649a9 | j_mayer | #if 0 // TODO
|
1806 | 4c9649a9 | j_mayer | gen_load_fmem(ctx, &gen_ldg, ra, rb, disp16);
|
1807 | 4c9649a9 | j_mayer | #else
|
1808 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1809 | 4c9649a9 | j_mayer | #endif
|
1810 | 4c9649a9 | j_mayer | break;
|
1811 | 4c9649a9 | j_mayer | case 0x22: |
1812 | 4c9649a9 | j_mayer | /* LDS */
|
1813 | 4c9649a9 | j_mayer | gen_load_fmem(ctx, &gen_lds, ra, rb, disp16); |
1814 | 4c9649a9 | j_mayer | break;
|
1815 | 4c9649a9 | j_mayer | case 0x23: |
1816 | 4c9649a9 | j_mayer | /* LDT */
|
1817 | 4c9649a9 | j_mayer | gen_load_fmem(ctx, &gen_ldt, ra, rb, disp16); |
1818 | 4c9649a9 | j_mayer | break;
|
1819 | 4c9649a9 | j_mayer | case 0x24: |
1820 | 4c9649a9 | j_mayer | /* STF */
|
1821 | 4c9649a9 | j_mayer | #if 0 // TODO
|
1822 | 4c9649a9 | j_mayer | gen_store_fmem(ctx, &gen_stf, ra, rb, disp16);
|
1823 | 4c9649a9 | j_mayer | #else
|
1824 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1825 | 4c9649a9 | j_mayer | #endif
|
1826 | 4c9649a9 | j_mayer | break;
|
1827 | 4c9649a9 | j_mayer | case 0x25: |
1828 | 4c9649a9 | j_mayer | /* STG */
|
1829 | 4c9649a9 | j_mayer | #if 0 // TODO
|
1830 | 4c9649a9 | j_mayer | gen_store_fmem(ctx, &gen_stg, ra, rb, disp16);
|
1831 | 4c9649a9 | j_mayer | #else
|
1832 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1833 | 4c9649a9 | j_mayer | #endif
|
1834 | 4c9649a9 | j_mayer | break;
|
1835 | 4c9649a9 | j_mayer | case 0x26: |
1836 | 4c9649a9 | j_mayer | /* STS */
|
1837 | 4c9649a9 | j_mayer | gen_store_fmem(ctx, &gen_sts, ra, rb, disp16); |
1838 | 4c9649a9 | j_mayer | break;
|
1839 | 4c9649a9 | j_mayer | case 0x27: |
1840 | 4c9649a9 | j_mayer | /* STT */
|
1841 | 4c9649a9 | j_mayer | gen_store_fmem(ctx, &gen_stt, ra, rb, disp16); |
1842 | 4c9649a9 | j_mayer | break;
|
1843 | 4c9649a9 | j_mayer | case 0x28: |
1844 | 4c9649a9 | j_mayer | /* LDL */
|
1845 | 4c9649a9 | j_mayer | gen_load_mem(ctx, &gen_ldl, ra, rb, disp16, 0);
|
1846 | 4c9649a9 | j_mayer | break;
|
1847 | 4c9649a9 | j_mayer | case 0x29: |
1848 | 4c9649a9 | j_mayer | /* LDQ */
|
1849 | 4c9649a9 | j_mayer | gen_load_mem(ctx, &gen_ldq, ra, rb, disp16, 0);
|
1850 | 4c9649a9 | j_mayer | break;
|
1851 | 4c9649a9 | j_mayer | case 0x2A: |
1852 | 4c9649a9 | j_mayer | /* LDL_L */
|
1853 | 4c9649a9 | j_mayer | gen_load_mem(ctx, &gen_ldl_l, ra, rb, disp16, 0);
|
1854 | 4c9649a9 | j_mayer | break;
|
1855 | 4c9649a9 | j_mayer | case 0x2B: |
1856 | 4c9649a9 | j_mayer | /* LDQ_L */
|
1857 | 4c9649a9 | j_mayer | gen_load_mem(ctx, &gen_ldq_l, ra, rb, disp16, 0);
|
1858 | 4c9649a9 | j_mayer | break;
|
1859 | 4c9649a9 | j_mayer | case 0x2C: |
1860 | 4c9649a9 | j_mayer | /* STL */
|
1861 | 4c9649a9 | j_mayer | gen_store_mem(ctx, &gen_stl, ra, rb, disp16, 0);
|
1862 | 4c9649a9 | j_mayer | break;
|
1863 | 4c9649a9 | j_mayer | case 0x2D: |
1864 | 4c9649a9 | j_mayer | /* STQ */
|
1865 | 4c9649a9 | j_mayer | gen_store_mem(ctx, &gen_stq, ra, rb, disp16, 0);
|
1866 | 4c9649a9 | j_mayer | break;
|
1867 | 4c9649a9 | j_mayer | case 0x2E: |
1868 | 4c9649a9 | j_mayer | /* STL_C */
|
1869 | 4c9649a9 | j_mayer | gen_store_mem(ctx, &gen_stl_c, ra, rb, disp16, 0);
|
1870 | 4c9649a9 | j_mayer | break;
|
1871 | 4c9649a9 | j_mayer | case 0x2F: |
1872 | 4c9649a9 | j_mayer | /* STQ_C */
|
1873 | 4c9649a9 | j_mayer | gen_store_mem(ctx, &gen_stq_c, ra, rb, disp16, 0);
|
1874 | 4c9649a9 | j_mayer | break;
|
1875 | 4c9649a9 | j_mayer | case 0x30: |
1876 | 4c9649a9 | j_mayer | /* BR */
|
1877 | 4c9649a9 | j_mayer | gen_set_uT0(ctx, ctx->pc); |
1878 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 0);
|
1879 | 4c9649a9 | j_mayer | if (disp21 != 0) { |
1880 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp21 << 2);
|
1881 | 4c9649a9 | j_mayer | gen_op_addq(); |
1882 | 4c9649a9 | j_mayer | } |
1883 | 4c9649a9 | j_mayer | gen_op_branch(); |
1884 | 4c9649a9 | j_mayer | ret = 1;
|
1885 | 4c9649a9 | j_mayer | break;
|
1886 | 4c9649a9 | j_mayer | case 0x31: |
1887 | 4c9649a9 | j_mayer | /* FBEQ */
|
1888 | 4c9649a9 | j_mayer | gen_fbcond(ctx, &gen_op_cmpfeq, ra, disp16); |
1889 | 4c9649a9 | j_mayer | ret = 1;
|
1890 | 4c9649a9 | j_mayer | break;
|
1891 | 4c9649a9 | j_mayer | case 0x32: |
1892 | 4c9649a9 | j_mayer | /* FBLT */
|
1893 | 4c9649a9 | j_mayer | gen_fbcond(ctx, &gen_op_cmpflt, ra, disp16); |
1894 | 4c9649a9 | j_mayer | ret = 1;
|
1895 | 4c9649a9 | j_mayer | break;
|
1896 | 4c9649a9 | j_mayer | case 0x33: |
1897 | 4c9649a9 | j_mayer | /* FBLE */
|
1898 | 4c9649a9 | j_mayer | gen_fbcond(ctx, &gen_op_cmpfle, ra, disp16); |
1899 | 4c9649a9 | j_mayer | ret = 1;
|
1900 | 4c9649a9 | j_mayer | break;
|
1901 | 4c9649a9 | j_mayer | case 0x34: |
1902 | 4c9649a9 | j_mayer | /* BSR */
|
1903 | 4c9649a9 | j_mayer | gen_set_uT0(ctx, ctx->pc); |
1904 | 4c9649a9 | j_mayer | gen_store_ir(ctx, ra, 0);
|
1905 | 4c9649a9 | j_mayer | if (disp21 != 0) { |
1906 | 4c9649a9 | j_mayer | gen_set_sT1(ctx, disp21 << 2);
|
1907 | 4c9649a9 | j_mayer | gen_op_addq(); |
1908 | 4c9649a9 | j_mayer | } |
1909 | 4c9649a9 | j_mayer | gen_op_branch(); |
1910 | 4c9649a9 | j_mayer | ret = 1;
|
1911 | 4c9649a9 | j_mayer | break;
|
1912 | 4c9649a9 | j_mayer | case 0x35: |
1913 | 4c9649a9 | j_mayer | /* FBNE */
|
1914 | 4c9649a9 | j_mayer | gen_fbcond(ctx, &gen_op_cmpfne, ra, disp16); |
1915 | 4c9649a9 | j_mayer | ret = 1;
|
1916 | 4c9649a9 | j_mayer | break;
|
1917 | 4c9649a9 | j_mayer | case 0x36: |
1918 | 4c9649a9 | j_mayer | /* FBGE */
|
1919 | 4c9649a9 | j_mayer | gen_fbcond(ctx, &gen_op_cmpfge, ra, disp16); |
1920 | 4c9649a9 | j_mayer | ret = 1;
|
1921 | 4c9649a9 | j_mayer | break;
|
1922 | 4c9649a9 | j_mayer | case 0x37: |
1923 | 4c9649a9 | j_mayer | /* FBGT */
|
1924 | 4c9649a9 | j_mayer | gen_fbcond(ctx, &gen_op_cmpfgt, ra, disp16); |
1925 | 4c9649a9 | j_mayer | ret = 1;
|
1926 | 4c9649a9 | j_mayer | break;
|
1927 | 4c9649a9 | j_mayer | case 0x38: |
1928 | 4c9649a9 | j_mayer | /* BLBC */
|
1929 | 4c9649a9 | j_mayer | gen_bcond(ctx, &gen_op_cmplbc, ra, disp16); |
1930 | 4c9649a9 | j_mayer | ret = 1;
|
1931 | 4c9649a9 | j_mayer | break;
|
1932 | 4c9649a9 | j_mayer | case 0x39: |
1933 | 4c9649a9 | j_mayer | /* BEQ */
|
1934 | 4c9649a9 | j_mayer | gen_bcond(ctx, &gen_op_cmpeqz, ra, disp16); |
1935 | 4c9649a9 | j_mayer | ret = 1;
|
1936 | 4c9649a9 | j_mayer | break;
|
1937 | 4c9649a9 | j_mayer | case 0x3A: |
1938 | 4c9649a9 | j_mayer | /* BLT */
|
1939 | 4c9649a9 | j_mayer | gen_bcond(ctx, &gen_op_cmpltz, ra, disp16); |
1940 | 4c9649a9 | j_mayer | ret = 1;
|
1941 | 4c9649a9 | j_mayer | break;
|
1942 | 4c9649a9 | j_mayer | case 0x3B: |
1943 | 4c9649a9 | j_mayer | /* BLE */
|
1944 | 4c9649a9 | j_mayer | gen_bcond(ctx, &gen_op_cmplez, ra, disp16); |
1945 | 4c9649a9 | j_mayer | ret = 1;
|
1946 | 4c9649a9 | j_mayer | break;
|
1947 | 4c9649a9 | j_mayer | case 0x3C: |
1948 | 4c9649a9 | j_mayer | /* BLBS */
|
1949 | 4c9649a9 | j_mayer | gen_bcond(ctx, &gen_op_cmplbs, ra, disp16); |
1950 | 4c9649a9 | j_mayer | ret = 1;
|
1951 | 4c9649a9 | j_mayer | break;
|
1952 | 4c9649a9 | j_mayer | case 0x3D: |
1953 | 4c9649a9 | j_mayer | /* BNE */
|
1954 | 4c9649a9 | j_mayer | gen_bcond(ctx, &gen_op_cmpnez, ra, disp16); |
1955 | 4c9649a9 | j_mayer | ret = 1;
|
1956 | 4c9649a9 | j_mayer | break;
|
1957 | 4c9649a9 | j_mayer | case 0x3E: |
1958 | 4c9649a9 | j_mayer | /* BGE */
|
1959 | 4c9649a9 | j_mayer | gen_bcond(ctx, &gen_op_cmpgez, ra, disp16); |
1960 | 4c9649a9 | j_mayer | ret = 1;
|
1961 | 4c9649a9 | j_mayer | break;
|
1962 | 4c9649a9 | j_mayer | case 0x3F: |
1963 | 4c9649a9 | j_mayer | /* BGT */
|
1964 | 4c9649a9 | j_mayer | gen_bcond(ctx, &gen_op_cmpgtz, ra, disp16); |
1965 | 4c9649a9 | j_mayer | ret = 1;
|
1966 | 4c9649a9 | j_mayer | break;
|
1967 | 4c9649a9 | j_mayer | invalid_opc:
|
1968 | 4c9649a9 | j_mayer | gen_invalid(ctx); |
1969 | 4c9649a9 | j_mayer | ret = 3;
|
1970 | 4c9649a9 | j_mayer | break;
|
1971 | 4c9649a9 | j_mayer | } |
1972 | 4c9649a9 | j_mayer | |
1973 | 4c9649a9 | j_mayer | return ret;
|
1974 | 4c9649a9 | j_mayer | } |
1975 | 4c9649a9 | j_mayer | |
1976 | f071b4d3 | j_mayer | static always_inline int gen_intermediate_code_internal (CPUState *env, |
1977 | f071b4d3 | j_mayer | TranslationBlock *tb, |
1978 | f071b4d3 | j_mayer | int search_pc)
|
1979 | 4c9649a9 | j_mayer | { |
1980 | 4c9649a9 | j_mayer | #if defined ALPHA_DEBUG_DISAS
|
1981 | 4c9649a9 | j_mayer | static int insn_count; |
1982 | 4c9649a9 | j_mayer | #endif
|
1983 | 4c9649a9 | j_mayer | DisasContext ctx, *ctxp = &ctx; |
1984 | 4c9649a9 | j_mayer | target_ulong pc_start; |
1985 | 4c9649a9 | j_mayer | uint32_t insn; |
1986 | 4c9649a9 | j_mayer | uint16_t *gen_opc_end; |
1987 | 4c9649a9 | j_mayer | int j, lj = -1; |
1988 | 4c9649a9 | j_mayer | int ret;
|
1989 | 4c9649a9 | j_mayer | |
1990 | 4c9649a9 | j_mayer | pc_start = tb->pc; |
1991 | 4c9649a9 | j_mayer | gen_opc_ptr = gen_opc_buf; |
1992 | 4c9649a9 | j_mayer | gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; |
1993 | 4c9649a9 | j_mayer | gen_opparam_ptr = gen_opparam_buf; |
1994 | 4c9649a9 | j_mayer | nb_gen_labels = 0;
|
1995 | 4c9649a9 | j_mayer | ctx.pc = pc_start; |
1996 | 4c9649a9 | j_mayer | ctx.amask = env->amask; |
1997 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
1998 | 4c9649a9 | j_mayer | ctx.mem_idx = 0;
|
1999 | 4c9649a9 | j_mayer | #else
|
2000 | 4c9649a9 | j_mayer | ctx.mem_idx = ((env->ps >> 3) & 3); |
2001 | 4c9649a9 | j_mayer | ctx.pal_mode = env->ipr[IPR_EXC_ADDR] & 1;
|
2002 | 4c9649a9 | j_mayer | #endif
|
2003 | 4c9649a9 | j_mayer | for (ret = 0; ret == 0;) { |
2004 | 4c9649a9 | j_mayer | if (env->nb_breakpoints > 0) { |
2005 | 4c9649a9 | j_mayer | for(j = 0; j < env->nb_breakpoints; j++) { |
2006 | 4c9649a9 | j_mayer | if (env->breakpoints[j] == ctx.pc) {
|
2007 | 4c9649a9 | j_mayer | gen_excp(&ctx, EXCP_DEBUG, 0);
|
2008 | 4c9649a9 | j_mayer | break;
|
2009 | 4c9649a9 | j_mayer | } |
2010 | 4c9649a9 | j_mayer | } |
2011 | 4c9649a9 | j_mayer | } |
2012 | 4c9649a9 | j_mayer | if (search_pc) {
|
2013 | 4c9649a9 | j_mayer | j = gen_opc_ptr - gen_opc_buf; |
2014 | 4c9649a9 | j_mayer | if (lj < j) {
|
2015 | 4c9649a9 | j_mayer | lj++; |
2016 | 4c9649a9 | j_mayer | while (lj < j)
|
2017 | 4c9649a9 | j_mayer | gen_opc_instr_start[lj++] = 0;
|
2018 | 4c9649a9 | j_mayer | gen_opc_pc[lj] = ctx.pc; |
2019 | 4c9649a9 | j_mayer | gen_opc_instr_start[lj] = 1;
|
2020 | 4c9649a9 | j_mayer | } |
2021 | 4c9649a9 | j_mayer | } |
2022 | 4c9649a9 | j_mayer | #if defined ALPHA_DEBUG_DISAS
|
2023 | 4c9649a9 | j_mayer | insn_count++; |
2024 | 4c9649a9 | j_mayer | if (logfile != NULL) { |
2025 | e96efcfc | j_mayer | fprintf(logfile, "pc " TARGET_FMT_lx " mem_idx %d\n", |
2026 | e96efcfc | j_mayer | ctx.pc, ctx.mem_idx); |
2027 | 4c9649a9 | j_mayer | } |
2028 | 4c9649a9 | j_mayer | #endif
|
2029 | 4c9649a9 | j_mayer | insn = ldl_code(ctx.pc); |
2030 | 4c9649a9 | j_mayer | #if defined ALPHA_DEBUG_DISAS
|
2031 | 4c9649a9 | j_mayer | insn_count++; |
2032 | 4c9649a9 | j_mayer | if (logfile != NULL) { |
2033 | 4c9649a9 | j_mayer | fprintf(logfile, "opcode %08x %d\n", insn, insn_count);
|
2034 | 4c9649a9 | j_mayer | } |
2035 | 4c9649a9 | j_mayer | #endif
|
2036 | 4c9649a9 | j_mayer | ctx.pc += 4;
|
2037 | 4c9649a9 | j_mayer | ret = translate_one(ctxp, insn); |
2038 | 4c9649a9 | j_mayer | if (ret != 0) |
2039 | 4c9649a9 | j_mayer | break;
|
2040 | 4c9649a9 | j_mayer | /* if we reach a page boundary or are single stepping, stop
|
2041 | 4c9649a9 | j_mayer | * generation
|
2042 | 4c9649a9 | j_mayer | */
|
2043 | 4c9649a9 | j_mayer | if (((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) || |
2044 | 4c9649a9 | j_mayer | (env->singlestep_enabled)) { |
2045 | 4c9649a9 | j_mayer | break;
|
2046 | 4c9649a9 | j_mayer | } |
2047 | 4c9649a9 | j_mayer | #if defined (DO_SINGLE_STEP)
|
2048 | 4c9649a9 | j_mayer | break;
|
2049 | 4c9649a9 | j_mayer | #endif
|
2050 | 4c9649a9 | j_mayer | } |
2051 | 4c9649a9 | j_mayer | if (ret != 1 && ret != 3) { |
2052 | 4c9649a9 | j_mayer | gen_update_pc(&ctx); |
2053 | 4c9649a9 | j_mayer | } |
2054 | 4c9649a9 | j_mayer | gen_op_reset_T0(); |
2055 | 4c9649a9 | j_mayer | #if defined (DO_TB_FLUSH)
|
2056 | 4c9649a9 | j_mayer | gen_op_tb_flush(); |
2057 | 4c9649a9 | j_mayer | #endif
|
2058 | 4c9649a9 | j_mayer | /* Generate the return instruction */
|
2059 | 4c9649a9 | j_mayer | gen_op_exit_tb(); |
2060 | 4c9649a9 | j_mayer | *gen_opc_ptr = INDEX_op_end; |
2061 | 4c9649a9 | j_mayer | if (search_pc) {
|
2062 | 4c9649a9 | j_mayer | j = gen_opc_ptr - gen_opc_buf; |
2063 | 4c9649a9 | j_mayer | lj++; |
2064 | 4c9649a9 | j_mayer | while (lj <= j)
|
2065 | 4c9649a9 | j_mayer | gen_opc_instr_start[lj++] = 0;
|
2066 | 4c9649a9 | j_mayer | } else {
|
2067 | 4c9649a9 | j_mayer | tb->size = ctx.pc - pc_start; |
2068 | 4c9649a9 | j_mayer | } |
2069 | 4c9649a9 | j_mayer | #if defined ALPHA_DEBUG_DISAS
|
2070 | 4c9649a9 | j_mayer | if (loglevel & CPU_LOG_TB_CPU) {
|
2071 | 4c9649a9 | j_mayer | cpu_dump_state(env, logfile, fprintf, 0);
|
2072 | 4c9649a9 | j_mayer | } |
2073 | 4c9649a9 | j_mayer | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
2074 | 4c9649a9 | j_mayer | fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
|
2075 | 4c9649a9 | j_mayer | target_disas(logfile, pc_start, ctx.pc - pc_start, 1);
|
2076 | 4c9649a9 | j_mayer | fprintf(logfile, "\n");
|
2077 | 4c9649a9 | j_mayer | } |
2078 | 4c9649a9 | j_mayer | if (loglevel & CPU_LOG_TB_OP) {
|
2079 | 4c9649a9 | j_mayer | fprintf(logfile, "OP:\n");
|
2080 | 4c9649a9 | j_mayer | dump_ops(gen_opc_buf, gen_opparam_buf); |
2081 | 4c9649a9 | j_mayer | fprintf(logfile, "\n");
|
2082 | 4c9649a9 | j_mayer | } |
2083 | 4c9649a9 | j_mayer | #endif
|
2084 | 4c9649a9 | j_mayer | |
2085 | 4c9649a9 | j_mayer | return 0; |
2086 | 4c9649a9 | j_mayer | } |
2087 | 4c9649a9 | j_mayer | |
2088 | 4c9649a9 | j_mayer | int gen_intermediate_code (CPUState *env, struct TranslationBlock *tb) |
2089 | 4c9649a9 | j_mayer | { |
2090 | 4c9649a9 | j_mayer | return gen_intermediate_code_internal(env, tb, 0); |
2091 | 4c9649a9 | j_mayer | } |
2092 | 4c9649a9 | j_mayer | |
2093 | 4c9649a9 | j_mayer | int gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb) |
2094 | 4c9649a9 | j_mayer | { |
2095 | 4c9649a9 | j_mayer | return gen_intermediate_code_internal(env, tb, 1); |
2096 | 4c9649a9 | j_mayer | } |
2097 | 4c9649a9 | j_mayer | |
2098 | aaed909a | bellard | CPUAlphaState * cpu_alpha_init (const char *cpu_model) |
2099 | 4c9649a9 | j_mayer | { |
2100 | 4c9649a9 | j_mayer | CPUAlphaState *env; |
2101 | 4c9649a9 | j_mayer | uint64_t hwpcb; |
2102 | 4c9649a9 | j_mayer | |
2103 | 4c9649a9 | j_mayer | env = qemu_mallocz(sizeof(CPUAlphaState));
|
2104 | 4c9649a9 | j_mayer | if (!env)
|
2105 | 4c9649a9 | j_mayer | return NULL; |
2106 | 4c9649a9 | j_mayer | cpu_exec_init(env); |
2107 | 4c9649a9 | j_mayer | tlb_flush(env, 1);
|
2108 | 4c9649a9 | j_mayer | /* XXX: should not be hardcoded */
|
2109 | 4c9649a9 | j_mayer | env->implver = IMPLVER_2106x; |
2110 | 4c9649a9 | j_mayer | env->ps = 0x1F00;
|
2111 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
2112 | 4c9649a9 | j_mayer | env->ps |= 1 << 3; |
2113 | 4c9649a9 | j_mayer | #endif
|
2114 | 4c9649a9 | j_mayer | pal_init(env); |
2115 | 4c9649a9 | j_mayer | /* Initialize IPR */
|
2116 | 4c9649a9 | j_mayer | hwpcb = env->ipr[IPR_PCBB]; |
2117 | 4c9649a9 | j_mayer | env->ipr[IPR_ASN] = 0;
|
2118 | 4c9649a9 | j_mayer | env->ipr[IPR_ASTEN] = 0;
|
2119 | 4c9649a9 | j_mayer | env->ipr[IPR_ASTSR] = 0;
|
2120 | 4c9649a9 | j_mayer | env->ipr[IPR_DATFX] = 0;
|
2121 | 4c9649a9 | j_mayer | /* XXX: fix this */
|
2122 | 4c9649a9 | j_mayer | // env->ipr[IPR_ESP] = ldq_raw(hwpcb + 8);
|
2123 | 4c9649a9 | j_mayer | // env->ipr[IPR_KSP] = ldq_raw(hwpcb + 0);
|
2124 | 4c9649a9 | j_mayer | // env->ipr[IPR_SSP] = ldq_raw(hwpcb + 16);
|
2125 | 4c9649a9 | j_mayer | // env->ipr[IPR_USP] = ldq_raw(hwpcb + 24);
|
2126 | 4c9649a9 | j_mayer | env->ipr[IPR_FEN] = 0;
|
2127 | 4c9649a9 | j_mayer | env->ipr[IPR_IPL] = 31;
|
2128 | 4c9649a9 | j_mayer | env->ipr[IPR_MCES] = 0;
|
2129 | 4c9649a9 | j_mayer | env->ipr[IPR_PERFMON] = 0; /* Implementation specific */ |
2130 | 4c9649a9 | j_mayer | // env->ipr[IPR_PTBR] = ldq_raw(hwpcb + 32);
|
2131 | 4c9649a9 | j_mayer | env->ipr[IPR_SISR] = 0;
|
2132 | 4c9649a9 | j_mayer | env->ipr[IPR_VIRBND] = -1ULL;
|
2133 | 4c9649a9 | j_mayer | |
2134 | 4c9649a9 | j_mayer | return env;
|
2135 | 4c9649a9 | j_mayer | } |