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