root / target-sh4 / translate.c @ 44e4c0ba
History | View | Annotate | Download (60.8 kB)
1 | fdf9b3e8 | bellard | /*
|
---|---|---|---|
2 | fdf9b3e8 | bellard | * SH4 translation
|
3 | 5fafdf24 | ths | *
|
4 | fdf9b3e8 | bellard | * Copyright (c) 2005 Samuel Tardieu
|
5 | fdf9b3e8 | bellard | *
|
6 | fdf9b3e8 | bellard | * This library is free software; you can redistribute it and/or
|
7 | fdf9b3e8 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | fdf9b3e8 | bellard | * License as published by the Free Software Foundation; either
|
9 | fdf9b3e8 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | fdf9b3e8 | bellard | *
|
11 | fdf9b3e8 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | fdf9b3e8 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | fdf9b3e8 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | fdf9b3e8 | bellard | * Lesser General Public License for more details.
|
15 | fdf9b3e8 | bellard | *
|
16 | fdf9b3e8 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 | fdf9b3e8 | bellard | */
|
19 | fdf9b3e8 | bellard | #include <stdarg.h> |
20 | fdf9b3e8 | bellard | #include <stdlib.h> |
21 | fdf9b3e8 | bellard | #include <stdio.h> |
22 | fdf9b3e8 | bellard | #include <string.h> |
23 | fdf9b3e8 | bellard | #include <inttypes.h> |
24 | fdf9b3e8 | bellard | |
25 | fdf9b3e8 | bellard | #define DEBUG_DISAS
|
26 | fdf9b3e8 | bellard | #define SH4_DEBUG_DISAS
|
27 | fdf9b3e8 | bellard | //#define SH4_SINGLE_STEP
|
28 | fdf9b3e8 | bellard | |
29 | fdf9b3e8 | bellard | #include "cpu.h" |
30 | fdf9b3e8 | bellard | #include "exec-all.h" |
31 | fdf9b3e8 | bellard | #include "disas.h" |
32 | 57fec1fe | bellard | #include "tcg-op.h" |
33 | ca10f867 | aurel32 | #include "qemu-common.h" |
34 | fdf9b3e8 | bellard | |
35 | a7812ae4 | pbrook | #include "helper.h" |
36 | a7812ae4 | pbrook | #define GEN_HELPER 1 |
37 | a7812ae4 | pbrook | #include "helper.h" |
38 | a7812ae4 | pbrook | |
39 | fdf9b3e8 | bellard | typedef struct DisasContext { |
40 | fdf9b3e8 | bellard | struct TranslationBlock *tb;
|
41 | fdf9b3e8 | bellard | target_ulong pc; |
42 | fdf9b3e8 | bellard | uint32_t sr; |
43 | eda9b09b | bellard | uint32_t fpscr; |
44 | fdf9b3e8 | bellard | uint16_t opcode; |
45 | fdf9b3e8 | bellard | uint32_t flags; |
46 | 823029f9 | ths | int bstate;
|
47 | fdf9b3e8 | bellard | int memidx;
|
48 | fdf9b3e8 | bellard | uint32_t delayed_pc; |
49 | fdf9b3e8 | bellard | int singlestep_enabled;
|
50 | 71968fa6 | aurel32 | uint32_t features; |
51 | 852d481f | edgar_igl | int has_movcal;
|
52 | fdf9b3e8 | bellard | } DisasContext; |
53 | fdf9b3e8 | bellard | |
54 | fe25591e | aurel32 | #if defined(CONFIG_USER_ONLY)
|
55 | fe25591e | aurel32 | #define IS_USER(ctx) 1 |
56 | fe25591e | aurel32 | #else
|
57 | fe25591e | aurel32 | #define IS_USER(ctx) (!(ctx->sr & SR_MD))
|
58 | fe25591e | aurel32 | #endif
|
59 | fe25591e | aurel32 | |
60 | 823029f9 | ths | enum {
|
61 | 823029f9 | ths | BS_NONE = 0, /* We go out of the TB without reaching a branch or an |
62 | 823029f9 | ths | * exception condition
|
63 | 823029f9 | ths | */
|
64 | 823029f9 | ths | BS_STOP = 1, /* We want to stop translation for any reason */ |
65 | 823029f9 | ths | BS_BRANCH = 2, /* We reached a branch condition */ |
66 | 823029f9 | ths | BS_EXCP = 3, /* We reached an exception condition */ |
67 | 823029f9 | ths | }; |
68 | 823029f9 | ths | |
69 | 1e8864f7 | aurel32 | /* global register indexes */
|
70 | a7812ae4 | pbrook | static TCGv_ptr cpu_env;
|
71 | 1e8864f7 | aurel32 | static TCGv cpu_gregs[24]; |
72 | 3a8a44c4 | aurel32 | static TCGv cpu_pc, cpu_sr, cpu_ssr, cpu_spc, cpu_gbr;
|
73 | 3a8a44c4 | aurel32 | static TCGv cpu_vbr, cpu_sgr, cpu_dbr, cpu_mach, cpu_macl;
|
74 | 66c7c806 | aurel32 | static TCGv cpu_pr, cpu_fpscr, cpu_fpul, cpu_ldst;
|
75 | 66ba317c | aurel32 | static TCGv cpu_fregs[32]; |
76 | 1000822b | aurel32 | |
77 | 1000822b | aurel32 | /* internal register indexes */
|
78 | 1000822b | aurel32 | static TCGv cpu_flags, cpu_delayed_pc;
|
79 | 1e8864f7 | aurel32 | |
80 | 2e70f6ef | pbrook | #include "gen-icount.h" |
81 | 2e70f6ef | pbrook | |
82 | a5f1b965 | blueswir1 | static void sh4_translate_init(void) |
83 | 2e70f6ef | pbrook | { |
84 | 1e8864f7 | aurel32 | int i;
|
85 | 2e70f6ef | pbrook | static int done_init = 0; |
86 | 559dd74d | aurel32 | static const char * const gregnames[24] = { |
87 | 1e8864f7 | aurel32 | "R0_BANK0", "R1_BANK0", "R2_BANK0", "R3_BANK0", |
88 | 1e8864f7 | aurel32 | "R4_BANK0", "R5_BANK0", "R6_BANK0", "R7_BANK0", |
89 | 1e8864f7 | aurel32 | "R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15", |
90 | 1e8864f7 | aurel32 | "R0_BANK1", "R1_BANK1", "R2_BANK1", "R3_BANK1", |
91 | 1e8864f7 | aurel32 | "R4_BANK1", "R5_BANK1", "R6_BANK1", "R7_BANK1" |
92 | 1e8864f7 | aurel32 | }; |
93 | 66ba317c | aurel32 | static const char * const fregnames[32] = { |
94 | 66ba317c | aurel32 | "FPR0_BANK0", "FPR1_BANK0", "FPR2_BANK0", "FPR3_BANK0", |
95 | 66ba317c | aurel32 | "FPR4_BANK0", "FPR5_BANK0", "FPR6_BANK0", "FPR7_BANK0", |
96 | 66ba317c | aurel32 | "FPR8_BANK0", "FPR9_BANK0", "FPR10_BANK0", "FPR11_BANK0", |
97 | 66ba317c | aurel32 | "FPR12_BANK0", "FPR13_BANK0", "FPR14_BANK0", "FPR15_BANK0", |
98 | 66ba317c | aurel32 | "FPR0_BANK1", "FPR1_BANK1", "FPR2_BANK1", "FPR3_BANK1", |
99 | 66ba317c | aurel32 | "FPR4_BANK1", "FPR5_BANK1", "FPR6_BANK1", "FPR7_BANK1", |
100 | 66ba317c | aurel32 | "FPR8_BANK1", "FPR9_BANK1", "FPR10_BANK1", "FPR11_BANK1", |
101 | 66ba317c | aurel32 | "FPR12_BANK1", "FPR13_BANK1", "FPR14_BANK1", "FPR15_BANK1", |
102 | 66ba317c | aurel32 | }; |
103 | 1e8864f7 | aurel32 | |
104 | 2e70f6ef | pbrook | if (done_init)
|
105 | 2e70f6ef | pbrook | return;
|
106 | 1e8864f7 | aurel32 | |
107 | a7812ae4 | pbrook | cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
|
108 | 1e8864f7 | aurel32 | |
109 | 1e8864f7 | aurel32 | for (i = 0; i < 24; i++) |
110 | a7812ae4 | pbrook | cpu_gregs[i] = tcg_global_mem_new_i32(TCG_AREG0, |
111 | 66ba317c | aurel32 | offsetof(CPUState, gregs[i]), |
112 | 66ba317c | aurel32 | gregnames[i]); |
113 | 988d7eaa | aurel32 | |
114 | a7812ae4 | pbrook | cpu_pc = tcg_global_mem_new_i32(TCG_AREG0, |
115 | a7812ae4 | pbrook | offsetof(CPUState, pc), "PC");
|
116 | a7812ae4 | pbrook | cpu_sr = tcg_global_mem_new_i32(TCG_AREG0, |
117 | a7812ae4 | pbrook | offsetof(CPUState, sr), "SR");
|
118 | a7812ae4 | pbrook | cpu_ssr = tcg_global_mem_new_i32(TCG_AREG0, |
119 | a7812ae4 | pbrook | offsetof(CPUState, ssr), "SSR");
|
120 | a7812ae4 | pbrook | cpu_spc = tcg_global_mem_new_i32(TCG_AREG0, |
121 | a7812ae4 | pbrook | offsetof(CPUState, spc), "SPC");
|
122 | a7812ae4 | pbrook | cpu_gbr = tcg_global_mem_new_i32(TCG_AREG0, |
123 | a7812ae4 | pbrook | offsetof(CPUState, gbr), "GBR");
|
124 | a7812ae4 | pbrook | cpu_vbr = tcg_global_mem_new_i32(TCG_AREG0, |
125 | a7812ae4 | pbrook | offsetof(CPUState, vbr), "VBR");
|
126 | a7812ae4 | pbrook | cpu_sgr = tcg_global_mem_new_i32(TCG_AREG0, |
127 | a7812ae4 | pbrook | offsetof(CPUState, sgr), "SGR");
|
128 | a7812ae4 | pbrook | cpu_dbr = tcg_global_mem_new_i32(TCG_AREG0, |
129 | a7812ae4 | pbrook | offsetof(CPUState, dbr), "DBR");
|
130 | a7812ae4 | pbrook | cpu_mach = tcg_global_mem_new_i32(TCG_AREG0, |
131 | a7812ae4 | pbrook | offsetof(CPUState, mach), "MACH");
|
132 | a7812ae4 | pbrook | cpu_macl = tcg_global_mem_new_i32(TCG_AREG0, |
133 | a7812ae4 | pbrook | offsetof(CPUState, macl), "MACL");
|
134 | a7812ae4 | pbrook | cpu_pr = tcg_global_mem_new_i32(TCG_AREG0, |
135 | a7812ae4 | pbrook | offsetof(CPUState, pr), "PR");
|
136 | a7812ae4 | pbrook | cpu_fpscr = tcg_global_mem_new_i32(TCG_AREG0, |
137 | a7812ae4 | pbrook | offsetof(CPUState, fpscr), "FPSCR");
|
138 | a7812ae4 | pbrook | cpu_fpul = tcg_global_mem_new_i32(TCG_AREG0, |
139 | a7812ae4 | pbrook | offsetof(CPUState, fpul), "FPUL");
|
140 | a7812ae4 | pbrook | |
141 | a7812ae4 | pbrook | cpu_flags = tcg_global_mem_new_i32(TCG_AREG0, |
142 | a7812ae4 | pbrook | offsetof(CPUState, flags), "_flags_");
|
143 | a7812ae4 | pbrook | cpu_delayed_pc = tcg_global_mem_new_i32(TCG_AREG0, |
144 | a7812ae4 | pbrook | offsetof(CPUState, delayed_pc), |
145 | a7812ae4 | pbrook | "_delayed_pc_");
|
146 | 66c7c806 | aurel32 | cpu_ldst = tcg_global_mem_new_i32(TCG_AREG0, |
147 | 66c7c806 | aurel32 | offsetof(CPUState, ldst), "_ldst_");
|
148 | 1000822b | aurel32 | |
149 | 66ba317c | aurel32 | for (i = 0; i < 32; i++) |
150 | 66ba317c | aurel32 | cpu_fregs[i] = tcg_global_mem_new_i32(TCG_AREG0, |
151 | 66ba317c | aurel32 | offsetof(CPUState, fregs[i]), |
152 | 66ba317c | aurel32 | fregnames[i]); |
153 | 66ba317c | aurel32 | |
154 | 988d7eaa | aurel32 | /* register helpers */
|
155 | a7812ae4 | pbrook | #define GEN_HELPER 2 |
156 | 988d7eaa | aurel32 | #include "helper.h" |
157 | 988d7eaa | aurel32 | |
158 | 2e70f6ef | pbrook | done_init = 1;
|
159 | 2e70f6ef | pbrook | } |
160 | 2e70f6ef | pbrook | |
161 | fdf9b3e8 | bellard | void cpu_dump_state(CPUState * env, FILE * f,
|
162 | fdf9b3e8 | bellard | int (*cpu_fprintf) (FILE * f, const char *fmt, ...), |
163 | fdf9b3e8 | bellard | int flags)
|
164 | fdf9b3e8 | bellard | { |
165 | fdf9b3e8 | bellard | int i;
|
166 | eda9b09b | bellard | cpu_fprintf(f, "pc=0x%08x sr=0x%08x pr=0x%08x fpscr=0x%08x\n",
|
167 | eda9b09b | bellard | env->pc, env->sr, env->pr, env->fpscr); |
168 | 274a9e70 | aurel32 | cpu_fprintf(f, "spc=0x%08x ssr=0x%08x gbr=0x%08x vbr=0x%08x\n",
|
169 | 274a9e70 | aurel32 | env->spc, env->ssr, env->gbr, env->vbr); |
170 | 274a9e70 | aurel32 | cpu_fprintf(f, "sgr=0x%08x dbr=0x%08x delayed_pc=0x%08x fpul=0x%08x\n",
|
171 | 274a9e70 | aurel32 | env->sgr, env->dbr, env->delayed_pc, env->fpul); |
172 | fdf9b3e8 | bellard | for (i = 0; i < 24; i += 4) { |
173 | fdf9b3e8 | bellard | cpu_fprintf(f, "r%d=0x%08x r%d=0x%08x r%d=0x%08x r%d=0x%08x\n",
|
174 | fdf9b3e8 | bellard | i, env->gregs[i], i + 1, env->gregs[i + 1], |
175 | fdf9b3e8 | bellard | i + 2, env->gregs[i + 2], i + 3, env->gregs[i + 3]); |
176 | fdf9b3e8 | bellard | } |
177 | fdf9b3e8 | bellard | if (env->flags & DELAY_SLOT) {
|
178 | fdf9b3e8 | bellard | cpu_fprintf(f, "in delay slot (delayed_pc=0x%08x)\n",
|
179 | fdf9b3e8 | bellard | env->delayed_pc); |
180 | fdf9b3e8 | bellard | } else if (env->flags & DELAY_SLOT_CONDITIONAL) { |
181 | fdf9b3e8 | bellard | cpu_fprintf(f, "in conditional delay slot (delayed_pc=0x%08x)\n",
|
182 | fdf9b3e8 | bellard | env->delayed_pc); |
183 | fdf9b3e8 | bellard | } |
184 | fdf9b3e8 | bellard | } |
185 | fdf9b3e8 | bellard | |
186 | b79e1752 | aurel32 | static void cpu_sh4_reset(CPUSH4State * env) |
187 | fdf9b3e8 | bellard | { |
188 | eca1bdf4 | aliguori | if (qemu_loglevel_mask(CPU_LOG_RESET)) {
|
189 | eca1bdf4 | aliguori | qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
|
190 | eca1bdf4 | aliguori | log_cpu_state(env, 0);
|
191 | eca1bdf4 | aliguori | } |
192 | eca1bdf4 | aliguori | |
193 | 9c2a9ea1 | pbrook | #if defined(CONFIG_USER_ONLY)
|
194 | f3ff7fac | aurel32 | env->sr = 0;
|
195 | 9c2a9ea1 | pbrook | #else
|
196 | 56cd2b96 | aurel32 | env->sr = SR_MD | SR_RB | SR_BL | SR_I3 | SR_I2 | SR_I1 | SR_I0; |
197 | 9c2a9ea1 | pbrook | #endif
|
198 | fdf9b3e8 | bellard | env->vbr = 0;
|
199 | fdf9b3e8 | bellard | env->pc = 0xA0000000;
|
200 | ea6cf6be | ths | #if defined(CONFIG_USER_ONLY)
|
201 | ea6cf6be | ths | env->fpscr = FPSCR_PR; /* value for userspace according to the kernel */
|
202 | b0b3de89 | bellard | set_float_rounding_mode(float_round_nearest_even, &env->fp_status); /* ?! */
|
203 | ea6cf6be | ths | #else
|
204 | ea6cf6be | ths | env->fpscr = 0x00040001; /* CPU reset value according to SH4 manual */ |
205 | b0b3de89 | bellard | set_float_rounding_mode(float_round_to_zero, &env->fp_status); |
206 | ea6cf6be | ths | #endif
|
207 | fdf9b3e8 | bellard | env->mmucr = 0;
|
208 | fdf9b3e8 | bellard | } |
209 | fdf9b3e8 | bellard | |
210 | 0fd3ca30 | aurel32 | typedef struct { |
211 | b55266b5 | blueswir1 | const char *name; |
212 | 0fd3ca30 | aurel32 | int id;
|
213 | 0fd3ca30 | aurel32 | uint32_t pvr; |
214 | 0fd3ca30 | aurel32 | uint32_t prr; |
215 | 0fd3ca30 | aurel32 | uint32_t cvr; |
216 | 71968fa6 | aurel32 | uint32_t features; |
217 | 0fd3ca30 | aurel32 | } sh4_def_t; |
218 | 0fd3ca30 | aurel32 | |
219 | 0fd3ca30 | aurel32 | static sh4_def_t sh4_defs[] = {
|
220 | 0fd3ca30 | aurel32 | { |
221 | 0fd3ca30 | aurel32 | .name = "SH7750R",
|
222 | 0fd3ca30 | aurel32 | .id = SH_CPU_SH7750R, |
223 | 0fd3ca30 | aurel32 | .pvr = 0x00050000,
|
224 | 0fd3ca30 | aurel32 | .prr = 0x00000100,
|
225 | 0fd3ca30 | aurel32 | .cvr = 0x00110000,
|
226 | c2432a42 | aurel32 | .features = SH_FEATURE_BCR3_AND_BCR4, |
227 | 0fd3ca30 | aurel32 | }, { |
228 | 0fd3ca30 | aurel32 | .name = "SH7751R",
|
229 | 0fd3ca30 | aurel32 | .id = SH_CPU_SH7751R, |
230 | 0fd3ca30 | aurel32 | .pvr = 0x04050005,
|
231 | 0fd3ca30 | aurel32 | .prr = 0x00000113,
|
232 | 0fd3ca30 | aurel32 | .cvr = 0x00110000, /* Neutered caches, should be 0x20480000 */ |
233 | c2432a42 | aurel32 | .features = SH_FEATURE_BCR3_AND_BCR4, |
234 | a9c43f8e | aurel32 | }, { |
235 | a9c43f8e | aurel32 | .name = "SH7785",
|
236 | a9c43f8e | aurel32 | .id = SH_CPU_SH7785, |
237 | a9c43f8e | aurel32 | .pvr = 0x10300700,
|
238 | a9c43f8e | aurel32 | .prr = 0x00000200,
|
239 | a9c43f8e | aurel32 | .cvr = 0x71440211,
|
240 | 71968fa6 | aurel32 | .features = SH_FEATURE_SH4A, |
241 | a9c43f8e | aurel32 | }, |
242 | 0fd3ca30 | aurel32 | }; |
243 | 0fd3ca30 | aurel32 | |
244 | b55266b5 | blueswir1 | static const sh4_def_t *cpu_sh4_find_by_name(const char *name) |
245 | 0fd3ca30 | aurel32 | { |
246 | 0fd3ca30 | aurel32 | int i;
|
247 | 0fd3ca30 | aurel32 | |
248 | 0fd3ca30 | aurel32 | if (strcasecmp(name, "any") == 0) |
249 | 0fd3ca30 | aurel32 | return &sh4_defs[0]; |
250 | 0fd3ca30 | aurel32 | |
251 | b1503cda | malc | for (i = 0; i < ARRAY_SIZE(sh4_defs); i++) |
252 | 0fd3ca30 | aurel32 | if (strcasecmp(name, sh4_defs[i].name) == 0) |
253 | 0fd3ca30 | aurel32 | return &sh4_defs[i];
|
254 | 0fd3ca30 | aurel32 | |
255 | 0fd3ca30 | aurel32 | return NULL; |
256 | 0fd3ca30 | aurel32 | } |
257 | 0fd3ca30 | aurel32 | |
258 | 0fd3ca30 | aurel32 | void sh4_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
259 | 0fd3ca30 | aurel32 | { |
260 | 0fd3ca30 | aurel32 | int i;
|
261 | 0fd3ca30 | aurel32 | |
262 | b1503cda | malc | for (i = 0; i < ARRAY_SIZE(sh4_defs); i++) |
263 | 0fd3ca30 | aurel32 | (*cpu_fprintf)(f, "%s\n", sh4_defs[i].name);
|
264 | 0fd3ca30 | aurel32 | } |
265 | 0fd3ca30 | aurel32 | |
266 | 1ed1a787 | blueswir1 | static void cpu_sh4_register(CPUSH4State *env, const sh4_def_t *def) |
267 | 0fd3ca30 | aurel32 | { |
268 | 0fd3ca30 | aurel32 | env->pvr = def->pvr; |
269 | 0fd3ca30 | aurel32 | env->prr = def->prr; |
270 | 0fd3ca30 | aurel32 | env->cvr = def->cvr; |
271 | 0fd3ca30 | aurel32 | env->id = def->id; |
272 | 0fd3ca30 | aurel32 | } |
273 | 0fd3ca30 | aurel32 | |
274 | aaed909a | bellard | CPUSH4State *cpu_sh4_init(const char *cpu_model) |
275 | fdf9b3e8 | bellard | { |
276 | fdf9b3e8 | bellard | CPUSH4State *env; |
277 | 0fd3ca30 | aurel32 | const sh4_def_t *def;
|
278 | fdf9b3e8 | bellard | |
279 | 0fd3ca30 | aurel32 | def = cpu_sh4_find_by_name(cpu_model); |
280 | 0fd3ca30 | aurel32 | if (!def)
|
281 | 0fd3ca30 | aurel32 | return NULL; |
282 | fdf9b3e8 | bellard | env = qemu_mallocz(sizeof(CPUSH4State));
|
283 | 71968fa6 | aurel32 | env->features = def->features; |
284 | fdf9b3e8 | bellard | cpu_exec_init(env); |
285 | 852d481f | edgar_igl | env->movcal_backup_tail = &(env->movcal_backup); |
286 | 2e70f6ef | pbrook | sh4_translate_init(); |
287 | 7478757e | aurel32 | env->cpu_model_str = cpu_model; |
288 | fdf9b3e8 | bellard | cpu_sh4_reset(env); |
289 | 0fd3ca30 | aurel32 | cpu_sh4_register(env, def); |
290 | fdf9b3e8 | bellard | tlb_flush(env, 1);
|
291 | 0bf46a40 | aliguori | qemu_init_vcpu(env); |
292 | fdf9b3e8 | bellard | return env;
|
293 | fdf9b3e8 | bellard | } |
294 | fdf9b3e8 | bellard | |
295 | fdf9b3e8 | bellard | static void gen_goto_tb(DisasContext * ctx, int n, target_ulong dest) |
296 | fdf9b3e8 | bellard | { |
297 | fdf9b3e8 | bellard | TranslationBlock *tb; |
298 | fdf9b3e8 | bellard | tb = ctx->tb; |
299 | fdf9b3e8 | bellard | |
300 | fdf9b3e8 | bellard | if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) &&
|
301 | fdf9b3e8 | bellard | !ctx->singlestep_enabled) { |
302 | fdf9b3e8 | bellard | /* Use a direct jump if in same page and singlestep not enabled */
|
303 | 57fec1fe | bellard | tcg_gen_goto_tb(n); |
304 | 3a8a44c4 | aurel32 | tcg_gen_movi_i32(cpu_pc, dest); |
305 | 57fec1fe | bellard | tcg_gen_exit_tb((long) tb + n);
|
306 | fdf9b3e8 | bellard | } else {
|
307 | 3a8a44c4 | aurel32 | tcg_gen_movi_i32(cpu_pc, dest); |
308 | 57fec1fe | bellard | if (ctx->singlestep_enabled)
|
309 | a7812ae4 | pbrook | gen_helper_debug(); |
310 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
311 | fdf9b3e8 | bellard | } |
312 | fdf9b3e8 | bellard | } |
313 | fdf9b3e8 | bellard | |
314 | fdf9b3e8 | bellard | static void gen_jump(DisasContext * ctx) |
315 | fdf9b3e8 | bellard | { |
316 | fdf9b3e8 | bellard | if (ctx->delayed_pc == (uint32_t) - 1) { |
317 | fdf9b3e8 | bellard | /* Target is not statically known, it comes necessarily from a
|
318 | fdf9b3e8 | bellard | delayed jump as immediate jump are conditinal jumps */
|
319 | 1000822b | aurel32 | tcg_gen_mov_i32(cpu_pc, cpu_delayed_pc); |
320 | fdf9b3e8 | bellard | if (ctx->singlestep_enabled)
|
321 | a7812ae4 | pbrook | gen_helper_debug(); |
322 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
323 | fdf9b3e8 | bellard | } else {
|
324 | fdf9b3e8 | bellard | gen_goto_tb(ctx, 0, ctx->delayed_pc);
|
325 | fdf9b3e8 | bellard | } |
326 | fdf9b3e8 | bellard | } |
327 | fdf9b3e8 | bellard | |
328 | 1000822b | aurel32 | static inline void gen_branch_slot(uint32_t delayed_pc, int t) |
329 | 1000822b | aurel32 | { |
330 | c55497ec | aurel32 | TCGv sr; |
331 | 1000822b | aurel32 | int label = gen_new_label();
|
332 | 1000822b | aurel32 | tcg_gen_movi_i32(cpu_delayed_pc, delayed_pc); |
333 | a7812ae4 | pbrook | sr = tcg_temp_new(); |
334 | c55497ec | aurel32 | tcg_gen_andi_i32(sr, cpu_sr, SR_T); |
335 | c55497ec | aurel32 | tcg_gen_brcondi_i32(TCG_COND_NE, sr, t ? SR_T : 0, label);
|
336 | 1000822b | aurel32 | tcg_gen_ori_i32(cpu_flags, cpu_flags, DELAY_SLOT_TRUE); |
337 | 1000822b | aurel32 | gen_set_label(label); |
338 | 1000822b | aurel32 | } |
339 | 1000822b | aurel32 | |
340 | fdf9b3e8 | bellard | /* Immediate conditional jump (bt or bf) */
|
341 | fdf9b3e8 | bellard | static void gen_conditional_jump(DisasContext * ctx, |
342 | fdf9b3e8 | bellard | target_ulong ift, target_ulong ifnott) |
343 | fdf9b3e8 | bellard | { |
344 | fdf9b3e8 | bellard | int l1;
|
345 | c55497ec | aurel32 | TCGv sr; |
346 | fdf9b3e8 | bellard | |
347 | fdf9b3e8 | bellard | l1 = gen_new_label(); |
348 | a7812ae4 | pbrook | sr = tcg_temp_new(); |
349 | c55497ec | aurel32 | tcg_gen_andi_i32(sr, cpu_sr, SR_T); |
350 | c55497ec | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, sr, SR_T, l1); |
351 | fdf9b3e8 | bellard | gen_goto_tb(ctx, 0, ifnott);
|
352 | fdf9b3e8 | bellard | gen_set_label(l1); |
353 | fdf9b3e8 | bellard | gen_goto_tb(ctx, 1, ift);
|
354 | fdf9b3e8 | bellard | } |
355 | fdf9b3e8 | bellard | |
356 | fdf9b3e8 | bellard | /* Delayed conditional jump (bt or bf) */
|
357 | fdf9b3e8 | bellard | static void gen_delayed_conditional_jump(DisasContext * ctx) |
358 | fdf9b3e8 | bellard | { |
359 | fdf9b3e8 | bellard | int l1;
|
360 | c55497ec | aurel32 | TCGv ds; |
361 | fdf9b3e8 | bellard | |
362 | fdf9b3e8 | bellard | l1 = gen_new_label(); |
363 | a7812ae4 | pbrook | ds = tcg_temp_new(); |
364 | c55497ec | aurel32 | tcg_gen_andi_i32(ds, cpu_flags, DELAY_SLOT_TRUE); |
365 | c55497ec | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, ds, DELAY_SLOT_TRUE, l1); |
366 | 823029f9 | ths | gen_goto_tb(ctx, 1, ctx->pc + 2); |
367 | fdf9b3e8 | bellard | gen_set_label(l1); |
368 | 1000822b | aurel32 | tcg_gen_andi_i32(cpu_flags, cpu_flags, ~DELAY_SLOT_TRUE); |
369 | 9c2a9ea1 | pbrook | gen_jump(ctx); |
370 | fdf9b3e8 | bellard | } |
371 | fdf9b3e8 | bellard | |
372 | a4625612 | aurel32 | static inline void gen_set_t(void) |
373 | a4625612 | aurel32 | { |
374 | a4625612 | aurel32 | tcg_gen_ori_i32(cpu_sr, cpu_sr, SR_T); |
375 | a4625612 | aurel32 | } |
376 | a4625612 | aurel32 | |
377 | a4625612 | aurel32 | static inline void gen_clr_t(void) |
378 | a4625612 | aurel32 | { |
379 | a4625612 | aurel32 | tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T); |
380 | a4625612 | aurel32 | } |
381 | a4625612 | aurel32 | |
382 | a4625612 | aurel32 | static inline void gen_cmp(int cond, TCGv t0, TCGv t1) |
383 | a4625612 | aurel32 | { |
384 | a4625612 | aurel32 | int label1 = gen_new_label();
|
385 | a4625612 | aurel32 | int label2 = gen_new_label();
|
386 | a4625612 | aurel32 | tcg_gen_brcond_i32(cond, t1, t0, label1); |
387 | a4625612 | aurel32 | gen_clr_t(); |
388 | a4625612 | aurel32 | tcg_gen_br(label2); |
389 | a4625612 | aurel32 | gen_set_label(label1); |
390 | a4625612 | aurel32 | gen_set_t(); |
391 | a4625612 | aurel32 | gen_set_label(label2); |
392 | a4625612 | aurel32 | } |
393 | a4625612 | aurel32 | |
394 | a4625612 | aurel32 | static inline void gen_cmp_imm(int cond, TCGv t0, int32_t imm) |
395 | a4625612 | aurel32 | { |
396 | a4625612 | aurel32 | int label1 = gen_new_label();
|
397 | a4625612 | aurel32 | int label2 = gen_new_label();
|
398 | a4625612 | aurel32 | tcg_gen_brcondi_i32(cond, t0, imm, label1); |
399 | a4625612 | aurel32 | gen_clr_t(); |
400 | a4625612 | aurel32 | tcg_gen_br(label2); |
401 | a4625612 | aurel32 | gen_set_label(label1); |
402 | a4625612 | aurel32 | gen_set_t(); |
403 | a4625612 | aurel32 | gen_set_label(label2); |
404 | a4625612 | aurel32 | } |
405 | a4625612 | aurel32 | |
406 | 1000822b | aurel32 | static inline void gen_store_flags(uint32_t flags) |
407 | 1000822b | aurel32 | { |
408 | 1000822b | aurel32 | tcg_gen_andi_i32(cpu_flags, cpu_flags, DELAY_SLOT_TRUE); |
409 | 1000822b | aurel32 | tcg_gen_ori_i32(cpu_flags, cpu_flags, flags); |
410 | 1000822b | aurel32 | } |
411 | 1000822b | aurel32 | |
412 | 69d6275b | aurel32 | static inline void gen_copy_bit_i32(TCGv t0, int p0, TCGv t1, int p1) |
413 | 69d6275b | aurel32 | { |
414 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
415 | 69d6275b | aurel32 | |
416 | 69d6275b | aurel32 | p0 &= 0x1f;
|
417 | 69d6275b | aurel32 | p1 &= 0x1f;
|
418 | 69d6275b | aurel32 | |
419 | 69d6275b | aurel32 | tcg_gen_andi_i32(tmp, t1, (1 << p1));
|
420 | 69d6275b | aurel32 | tcg_gen_andi_i32(t0, t0, ~(1 << p0));
|
421 | 69d6275b | aurel32 | if (p0 < p1)
|
422 | 69d6275b | aurel32 | tcg_gen_shri_i32(tmp, tmp, p1 - p0); |
423 | 69d6275b | aurel32 | else if (p0 > p1) |
424 | 69d6275b | aurel32 | tcg_gen_shli_i32(tmp, tmp, p0 - p1); |
425 | 69d6275b | aurel32 | tcg_gen_or_i32(t0, t0, tmp); |
426 | 69d6275b | aurel32 | |
427 | 69d6275b | aurel32 | tcg_temp_free(tmp); |
428 | 69d6275b | aurel32 | } |
429 | 69d6275b | aurel32 | |
430 | a7812ae4 | pbrook | static inline void gen_load_fpr64(TCGv_i64 t, int reg) |
431 | cc4ba6a9 | aurel32 | { |
432 | 66ba317c | aurel32 | tcg_gen_concat_i32_i64(t, cpu_fregs[reg + 1], cpu_fregs[reg]);
|
433 | cc4ba6a9 | aurel32 | } |
434 | cc4ba6a9 | aurel32 | |
435 | a7812ae4 | pbrook | static inline void gen_store_fpr64 (TCGv_i64 t, int reg) |
436 | cc4ba6a9 | aurel32 | { |
437 | a7812ae4 | pbrook | TCGv_i32 tmp = tcg_temp_new_i32(); |
438 | cc4ba6a9 | aurel32 | tcg_gen_trunc_i64_i32(tmp, t); |
439 | 66ba317c | aurel32 | tcg_gen_mov_i32(cpu_fregs[reg + 1], tmp);
|
440 | cc4ba6a9 | aurel32 | tcg_gen_shri_i64(t, t, 32);
|
441 | cc4ba6a9 | aurel32 | tcg_gen_trunc_i64_i32(tmp, t); |
442 | 66ba317c | aurel32 | tcg_gen_mov_i32(cpu_fregs[reg], tmp); |
443 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp); |
444 | cc4ba6a9 | aurel32 | } |
445 | cc4ba6a9 | aurel32 | |
446 | fdf9b3e8 | bellard | #define B3_0 (ctx->opcode & 0xf) |
447 | fdf9b3e8 | bellard | #define B6_4 ((ctx->opcode >> 4) & 0x7) |
448 | fdf9b3e8 | bellard | #define B7_4 ((ctx->opcode >> 4) & 0xf) |
449 | fdf9b3e8 | bellard | #define B7_0 (ctx->opcode & 0xff) |
450 | fdf9b3e8 | bellard | #define B7_0s ((int32_t) (int8_t) (ctx->opcode & 0xff)) |
451 | fdf9b3e8 | bellard | #define B11_0s (ctx->opcode & 0x800 ? 0xfffff000 | (ctx->opcode & 0xfff) : \ |
452 | fdf9b3e8 | bellard | (ctx->opcode & 0xfff))
|
453 | fdf9b3e8 | bellard | #define B11_8 ((ctx->opcode >> 8) & 0xf) |
454 | fdf9b3e8 | bellard | #define B15_12 ((ctx->opcode >> 12) & 0xf) |
455 | fdf9b3e8 | bellard | |
456 | fdf9b3e8 | bellard | #define REG(x) ((x) < 8 && (ctx->sr & (SR_MD | SR_RB)) == (SR_MD | SR_RB) ? \ |
457 | 7efbe241 | aurel32 | (cpu_gregs[x + 16]) : (cpu_gregs[x]))
|
458 | fdf9b3e8 | bellard | |
459 | fdf9b3e8 | bellard | #define ALTREG(x) ((x) < 8 && (ctx->sr & (SR_MD | SR_RB)) != (SR_MD | SR_RB) \ |
460 | 7efbe241 | aurel32 | ? (cpu_gregs[x + 16]) : (cpu_gregs[x]))
|
461 | fdf9b3e8 | bellard | |
462 | eda9b09b | bellard | #define FREG(x) (ctx->fpscr & FPSCR_FR ? (x) ^ 0x10 : (x)) |
463 | f09111e0 | ths | #define XHACK(x) ((((x) & 1 ) << 4) | ((x) & 0xe)) |
464 | eda9b09b | bellard | #define XREG(x) (ctx->fpscr & FPSCR_FR ? XHACK(x) ^ 0x10 : XHACK(x)) |
465 | ea6cf6be | ths | #define DREG(x) FREG(x) /* Assumes lsb of (x) is always 0 */ |
466 | eda9b09b | bellard | |
467 | fdf9b3e8 | bellard | #define CHECK_NOT_DELAY_SLOT \
|
468 | d8299bcc | aurel32 | if (ctx->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) \
|
469 | d8299bcc | aurel32 | { \ |
470 | d8299bcc | aurel32 | tcg_gen_movi_i32(cpu_pc, ctx->pc-2); \
|
471 | d8299bcc | aurel32 | gen_helper_raise_slot_illegal_instruction(); \ |
472 | d8299bcc | aurel32 | ctx->bstate = BS_EXCP; \ |
473 | d8299bcc | aurel32 | return; \
|
474 | d8299bcc | aurel32 | } |
475 | fdf9b3e8 | bellard | |
476 | fe25591e | aurel32 | #define CHECK_PRIVILEGED \
|
477 | fe25591e | aurel32 | if (IS_USER(ctx)) { \
|
478 | d8299bcc | aurel32 | tcg_gen_movi_i32(cpu_pc, ctx->pc); \ |
479 | a7812ae4 | pbrook | gen_helper_raise_illegal_instruction(); \ |
480 | fe25591e | aurel32 | ctx->bstate = BS_EXCP; \ |
481 | fe25591e | aurel32 | return; \
|
482 | fe25591e | aurel32 | } |
483 | fe25591e | aurel32 | |
484 | d8299bcc | aurel32 | #define CHECK_FPU_ENABLED \
|
485 | d8299bcc | aurel32 | if (ctx->flags & SR_FD) { \
|
486 | d8299bcc | aurel32 | if (ctx->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) { \
|
487 | d8299bcc | aurel32 | tcg_gen_movi_i32(cpu_pc, ctx->pc-2); \
|
488 | d8299bcc | aurel32 | gen_helper_raise_slot_fpu_disable(); \ |
489 | d8299bcc | aurel32 | } else { \
|
490 | d8299bcc | aurel32 | tcg_gen_movi_i32(cpu_pc, ctx->pc); \ |
491 | d8299bcc | aurel32 | gen_helper_raise_fpu_disable(); \ |
492 | d8299bcc | aurel32 | } \ |
493 | d8299bcc | aurel32 | ctx->bstate = BS_EXCP; \ |
494 | d8299bcc | aurel32 | return; \
|
495 | d8299bcc | aurel32 | } |
496 | d8299bcc | aurel32 | |
497 | b1d8e52e | blueswir1 | static void _decode_opc(DisasContext * ctx) |
498 | fdf9b3e8 | bellard | { |
499 | 852d481f | edgar_igl | /* This code tries to make movcal emulation sufficiently
|
500 | 852d481f | edgar_igl | accurate for Linux purposes. This instruction writes
|
501 | 852d481f | edgar_igl | memory, and prior to that, always allocates a cache line.
|
502 | 852d481f | edgar_igl | It is used in two contexts:
|
503 | 852d481f | edgar_igl | - in memcpy, where data is copied in blocks, the first write
|
504 | 852d481f | edgar_igl | of to a block uses movca.l for performance.
|
505 | 852d481f | edgar_igl | - in arch/sh/mm/cache-sh4.c, movcal.l + ocbi combination is used
|
506 | 852d481f | edgar_igl | to flush the cache. Here, the data written by movcal.l is never
|
507 | 852d481f | edgar_igl | written to memory, and the data written is just bogus.
|
508 | 852d481f | edgar_igl | |
509 | 852d481f | edgar_igl | To simulate this, we simulate movcal.l, we store the value to memory,
|
510 | 852d481f | edgar_igl | but we also remember the previous content. If we see ocbi, we check
|
511 | 852d481f | edgar_igl | if movcal.l for that address was done previously. If so, the write should
|
512 | 852d481f | edgar_igl | not have hit the memory, so we restore the previous content.
|
513 | 852d481f | edgar_igl | When we see an instruction that is neither movca.l
|
514 | 852d481f | edgar_igl | nor ocbi, the previous content is discarded.
|
515 | 852d481f | edgar_igl | |
516 | 852d481f | edgar_igl | To optimize, we only try to flush stores when we're at the start of
|
517 | 852d481f | edgar_igl | TB, or if we already saw movca.l in this TB and did not flush stores
|
518 | 852d481f | edgar_igl | yet. */
|
519 | 852d481f | edgar_igl | if (ctx->has_movcal)
|
520 | 852d481f | edgar_igl | { |
521 | 852d481f | edgar_igl | int opcode = ctx->opcode & 0xf0ff; |
522 | 852d481f | edgar_igl | if (opcode != 0x0093 /* ocbi */ |
523 | 852d481f | edgar_igl | && opcode != 0x00c3 /* movca.l */) |
524 | 852d481f | edgar_igl | { |
525 | 852d481f | edgar_igl | gen_helper_discard_movcal_backup (); |
526 | 852d481f | edgar_igl | ctx->has_movcal = 0;
|
527 | 852d481f | edgar_igl | } |
528 | 852d481f | edgar_igl | } |
529 | 852d481f | edgar_igl | |
530 | fdf9b3e8 | bellard | #if 0
|
531 | fdf9b3e8 | bellard | fprintf(stderr, "Translating opcode 0x%04x\n", ctx->opcode);
|
532 | fdf9b3e8 | bellard | #endif
|
533 | f6198371 | aurel32 | |
534 | fdf9b3e8 | bellard | switch (ctx->opcode) {
|
535 | fdf9b3e8 | bellard | case 0x0019: /* div0u */ |
536 | 3a8a44c4 | aurel32 | tcg_gen_andi_i32(cpu_sr, cpu_sr, ~(SR_M | SR_Q | SR_T)); |
537 | fdf9b3e8 | bellard | return;
|
538 | fdf9b3e8 | bellard | case 0x000b: /* rts */ |
539 | 1000822b | aurel32 | CHECK_NOT_DELAY_SLOT |
540 | 1000822b | aurel32 | tcg_gen_mov_i32(cpu_delayed_pc, cpu_pr); |
541 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT; |
542 | fdf9b3e8 | bellard | ctx->delayed_pc = (uint32_t) - 1;
|
543 | fdf9b3e8 | bellard | return;
|
544 | fdf9b3e8 | bellard | case 0x0028: /* clrmac */ |
545 | 3a8a44c4 | aurel32 | tcg_gen_movi_i32(cpu_mach, 0);
|
546 | 3a8a44c4 | aurel32 | tcg_gen_movi_i32(cpu_macl, 0);
|
547 | fdf9b3e8 | bellard | return;
|
548 | fdf9b3e8 | bellard | case 0x0048: /* clrs */ |
549 | 3a8a44c4 | aurel32 | tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_S); |
550 | fdf9b3e8 | bellard | return;
|
551 | fdf9b3e8 | bellard | case 0x0008: /* clrt */ |
552 | a4625612 | aurel32 | gen_clr_t(); |
553 | fdf9b3e8 | bellard | return;
|
554 | fdf9b3e8 | bellard | case 0x0038: /* ldtlb */ |
555 | fe25591e | aurel32 | CHECK_PRIVILEGED |
556 | a7812ae4 | pbrook | gen_helper_ldtlb(); |
557 | fdf9b3e8 | bellard | return;
|
558 | c5e814b2 | ths | case 0x002b: /* rte */ |
559 | fe25591e | aurel32 | CHECK_PRIVILEGED |
560 | 1000822b | aurel32 | CHECK_NOT_DELAY_SLOT |
561 | 1000822b | aurel32 | tcg_gen_mov_i32(cpu_sr, cpu_ssr); |
562 | 1000822b | aurel32 | tcg_gen_mov_i32(cpu_delayed_pc, cpu_spc); |
563 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT; |
564 | fdf9b3e8 | bellard | ctx->delayed_pc = (uint32_t) - 1;
|
565 | fdf9b3e8 | bellard | return;
|
566 | fdf9b3e8 | bellard | case 0x0058: /* sets */ |
567 | 3a8a44c4 | aurel32 | tcg_gen_ori_i32(cpu_sr, cpu_sr, SR_S); |
568 | fdf9b3e8 | bellard | return;
|
569 | fdf9b3e8 | bellard | case 0x0018: /* sett */ |
570 | a4625612 | aurel32 | gen_set_t(); |
571 | fdf9b3e8 | bellard | return;
|
572 | 24988dc2 | aurel32 | case 0xfbfd: /* frchg */ |
573 | 6f06939b | aurel32 | tcg_gen_xori_i32(cpu_fpscr, cpu_fpscr, FPSCR_FR); |
574 | 823029f9 | ths | ctx->bstate = BS_STOP; |
575 | fdf9b3e8 | bellard | return;
|
576 | 24988dc2 | aurel32 | case 0xf3fd: /* fschg */ |
577 | 6f06939b | aurel32 | tcg_gen_xori_i32(cpu_fpscr, cpu_fpscr, FPSCR_SZ); |
578 | 823029f9 | ths | ctx->bstate = BS_STOP; |
579 | fdf9b3e8 | bellard | return;
|
580 | fdf9b3e8 | bellard | case 0x0009: /* nop */ |
581 | fdf9b3e8 | bellard | return;
|
582 | fdf9b3e8 | bellard | case 0x001b: /* sleep */ |
583 | fe25591e | aurel32 | CHECK_PRIVILEGED |
584 | a7812ae4 | pbrook | gen_helper_sleep(tcg_const_i32(ctx->pc + 2));
|
585 | fdf9b3e8 | bellard | return;
|
586 | fdf9b3e8 | bellard | } |
587 | fdf9b3e8 | bellard | |
588 | fdf9b3e8 | bellard | switch (ctx->opcode & 0xf000) { |
589 | fdf9b3e8 | bellard | case 0x1000: /* mov.l Rm,@(disp,Rn) */ |
590 | c55497ec | aurel32 | { |
591 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
592 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, REG(B11_8), B3_0 * 4);
|
593 | c55497ec | aurel32 | tcg_gen_qemu_st32(REG(B7_4), addr, ctx->memidx); |
594 | c55497ec | aurel32 | tcg_temp_free(addr); |
595 | c55497ec | aurel32 | } |
596 | fdf9b3e8 | bellard | return;
|
597 | fdf9b3e8 | bellard | case 0x5000: /* mov.l @(disp,Rm),Rn */ |
598 | c55497ec | aurel32 | { |
599 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
600 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, REG(B7_4), B3_0 * 4);
|
601 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(REG(B11_8), addr, ctx->memidx); |
602 | c55497ec | aurel32 | tcg_temp_free(addr); |
603 | c55497ec | aurel32 | } |
604 | fdf9b3e8 | bellard | return;
|
605 | 24988dc2 | aurel32 | case 0xe000: /* mov #imm,Rn */ |
606 | 7efbe241 | aurel32 | tcg_gen_movi_i32(REG(B11_8), B7_0s); |
607 | fdf9b3e8 | bellard | return;
|
608 | fdf9b3e8 | bellard | case 0x9000: /* mov.w @(disp,PC),Rn */ |
609 | c55497ec | aurel32 | { |
610 | c55497ec | aurel32 | TCGv addr = tcg_const_i32(ctx->pc + 4 + B7_0 * 2); |
611 | c55497ec | aurel32 | tcg_gen_qemu_ld16s(REG(B11_8), addr, ctx->memidx); |
612 | c55497ec | aurel32 | tcg_temp_free(addr); |
613 | c55497ec | aurel32 | } |
614 | fdf9b3e8 | bellard | return;
|
615 | fdf9b3e8 | bellard | case 0xd000: /* mov.l @(disp,PC),Rn */ |
616 | c55497ec | aurel32 | { |
617 | c55497ec | aurel32 | TCGv addr = tcg_const_i32((ctx->pc + 4 + B7_0 * 4) & ~3); |
618 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(REG(B11_8), addr, ctx->memidx); |
619 | c55497ec | aurel32 | tcg_temp_free(addr); |
620 | c55497ec | aurel32 | } |
621 | fdf9b3e8 | bellard | return;
|
622 | 24988dc2 | aurel32 | case 0x7000: /* add #imm,Rn */ |
623 | 7efbe241 | aurel32 | tcg_gen_addi_i32(REG(B11_8), REG(B11_8), B7_0s); |
624 | fdf9b3e8 | bellard | return;
|
625 | fdf9b3e8 | bellard | case 0xa000: /* bra disp */ |
626 | fdf9b3e8 | bellard | CHECK_NOT_DELAY_SLOT |
627 | 1000822b | aurel32 | ctx->delayed_pc = ctx->pc + 4 + B11_0s * 2; |
628 | 1000822b | aurel32 | tcg_gen_movi_i32(cpu_delayed_pc, ctx->delayed_pc); |
629 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT; |
630 | fdf9b3e8 | bellard | return;
|
631 | fdf9b3e8 | bellard | case 0xb000: /* bsr disp */ |
632 | fdf9b3e8 | bellard | CHECK_NOT_DELAY_SLOT |
633 | 1000822b | aurel32 | tcg_gen_movi_i32(cpu_pr, ctx->pc + 4);
|
634 | 1000822b | aurel32 | ctx->delayed_pc = ctx->pc + 4 + B11_0s * 2; |
635 | 1000822b | aurel32 | tcg_gen_movi_i32(cpu_delayed_pc, ctx->delayed_pc); |
636 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT; |
637 | fdf9b3e8 | bellard | return;
|
638 | fdf9b3e8 | bellard | } |
639 | fdf9b3e8 | bellard | |
640 | fdf9b3e8 | bellard | switch (ctx->opcode & 0xf00f) { |
641 | fdf9b3e8 | bellard | case 0x6003: /* mov Rm,Rn */ |
642 | 7efbe241 | aurel32 | tcg_gen_mov_i32(REG(B11_8), REG(B7_4)); |
643 | fdf9b3e8 | bellard | return;
|
644 | fdf9b3e8 | bellard | case 0x2000: /* mov.b Rm,@Rn */ |
645 | 7efbe241 | aurel32 | tcg_gen_qemu_st8(REG(B7_4), REG(B11_8), ctx->memidx); |
646 | fdf9b3e8 | bellard | return;
|
647 | fdf9b3e8 | bellard | case 0x2001: /* mov.w Rm,@Rn */ |
648 | 7efbe241 | aurel32 | tcg_gen_qemu_st16(REG(B7_4), REG(B11_8), ctx->memidx); |
649 | fdf9b3e8 | bellard | return;
|
650 | fdf9b3e8 | bellard | case 0x2002: /* mov.l Rm,@Rn */ |
651 | 7efbe241 | aurel32 | tcg_gen_qemu_st32(REG(B7_4), REG(B11_8), ctx->memidx); |
652 | fdf9b3e8 | bellard | return;
|
653 | fdf9b3e8 | bellard | case 0x6000: /* mov.b @Rm,Rn */ |
654 | 7efbe241 | aurel32 | tcg_gen_qemu_ld8s(REG(B11_8), REG(B7_4), ctx->memidx); |
655 | fdf9b3e8 | bellard | return;
|
656 | fdf9b3e8 | bellard | case 0x6001: /* mov.w @Rm,Rn */ |
657 | 7efbe241 | aurel32 | tcg_gen_qemu_ld16s(REG(B11_8), REG(B7_4), ctx->memidx); |
658 | fdf9b3e8 | bellard | return;
|
659 | fdf9b3e8 | bellard | case 0x6002: /* mov.l @Rm,Rn */ |
660 | 7efbe241 | aurel32 | tcg_gen_qemu_ld32s(REG(B11_8), REG(B7_4), ctx->memidx); |
661 | fdf9b3e8 | bellard | return;
|
662 | fdf9b3e8 | bellard | case 0x2004: /* mov.b Rm,@-Rn */ |
663 | c55497ec | aurel32 | { |
664 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
665 | c55497ec | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 1);
|
666 | c55497ec | aurel32 | tcg_gen_qemu_st8(REG(B7_4), addr, ctx->memidx); /* might cause re-execution */
|
667 | c55497ec | aurel32 | tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 1); /* modify register status */ |
668 | c55497ec | aurel32 | tcg_temp_free(addr); |
669 | c55497ec | aurel32 | } |
670 | fdf9b3e8 | bellard | return;
|
671 | fdf9b3e8 | bellard | case 0x2005: /* mov.w Rm,@-Rn */ |
672 | c55497ec | aurel32 | { |
673 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
674 | c55497ec | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 2);
|
675 | c55497ec | aurel32 | tcg_gen_qemu_st16(REG(B7_4), addr, ctx->memidx); |
676 | c55497ec | aurel32 | tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 2);
|
677 | c55497ec | aurel32 | tcg_temp_free(addr); |
678 | c55497ec | aurel32 | } |
679 | fdf9b3e8 | bellard | return;
|
680 | fdf9b3e8 | bellard | case 0x2006: /* mov.l Rm,@-Rn */ |
681 | c55497ec | aurel32 | { |
682 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
683 | c55497ec | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
684 | c55497ec | aurel32 | tcg_gen_qemu_st32(REG(B7_4), addr, ctx->memidx); |
685 | c55497ec | aurel32 | tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 4);
|
686 | c55497ec | aurel32 | } |
687 | fdf9b3e8 | bellard | return;
|
688 | eda9b09b | bellard | case 0x6004: /* mov.b @Rm+,Rn */ |
689 | 7efbe241 | aurel32 | tcg_gen_qemu_ld8s(REG(B11_8), REG(B7_4), ctx->memidx); |
690 | 24988dc2 | aurel32 | if ( B11_8 != B7_4 )
|
691 | 7efbe241 | aurel32 | tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 1);
|
692 | fdf9b3e8 | bellard | return;
|
693 | fdf9b3e8 | bellard | case 0x6005: /* mov.w @Rm+,Rn */ |
694 | 7efbe241 | aurel32 | tcg_gen_qemu_ld16s(REG(B11_8), REG(B7_4), ctx->memidx); |
695 | 24988dc2 | aurel32 | if ( B11_8 != B7_4 )
|
696 | 7efbe241 | aurel32 | tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 2);
|
697 | fdf9b3e8 | bellard | return;
|
698 | fdf9b3e8 | bellard | case 0x6006: /* mov.l @Rm+,Rn */ |
699 | 7efbe241 | aurel32 | tcg_gen_qemu_ld32s(REG(B11_8), REG(B7_4), ctx->memidx); |
700 | 24988dc2 | aurel32 | if ( B11_8 != B7_4 )
|
701 | 7efbe241 | aurel32 | tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 4);
|
702 | fdf9b3e8 | bellard | return;
|
703 | fdf9b3e8 | bellard | case 0x0004: /* mov.b Rm,@(R0,Rn) */ |
704 | c55497ec | aurel32 | { |
705 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
706 | c55497ec | aurel32 | tcg_gen_add_i32(addr, REG(B11_8), REG(0));
|
707 | c55497ec | aurel32 | tcg_gen_qemu_st8(REG(B7_4), addr, ctx->memidx); |
708 | c55497ec | aurel32 | tcg_temp_free(addr); |
709 | c55497ec | aurel32 | } |
710 | fdf9b3e8 | bellard | return;
|
711 | fdf9b3e8 | bellard | case 0x0005: /* mov.w Rm,@(R0,Rn) */ |
712 | c55497ec | aurel32 | { |
713 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
714 | c55497ec | aurel32 | tcg_gen_add_i32(addr, REG(B11_8), REG(0));
|
715 | c55497ec | aurel32 | tcg_gen_qemu_st16(REG(B7_4), addr, ctx->memidx); |
716 | c55497ec | aurel32 | tcg_temp_free(addr); |
717 | c55497ec | aurel32 | } |
718 | fdf9b3e8 | bellard | return;
|
719 | fdf9b3e8 | bellard | case 0x0006: /* mov.l Rm,@(R0,Rn) */ |
720 | c55497ec | aurel32 | { |
721 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
722 | c55497ec | aurel32 | tcg_gen_add_i32(addr, REG(B11_8), REG(0));
|
723 | c55497ec | aurel32 | tcg_gen_qemu_st32(REG(B7_4), addr, ctx->memidx); |
724 | c55497ec | aurel32 | tcg_temp_free(addr); |
725 | c55497ec | aurel32 | } |
726 | fdf9b3e8 | bellard | return;
|
727 | fdf9b3e8 | bellard | case 0x000c: /* mov.b @(R0,Rm),Rn */ |
728 | c55497ec | aurel32 | { |
729 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
730 | c55497ec | aurel32 | tcg_gen_add_i32(addr, REG(B7_4), REG(0));
|
731 | c55497ec | aurel32 | tcg_gen_qemu_ld8s(REG(B11_8), addr, ctx->memidx); |
732 | c55497ec | aurel32 | tcg_temp_free(addr); |
733 | c55497ec | aurel32 | } |
734 | fdf9b3e8 | bellard | return;
|
735 | fdf9b3e8 | bellard | case 0x000d: /* mov.w @(R0,Rm),Rn */ |
736 | c55497ec | aurel32 | { |
737 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
738 | c55497ec | aurel32 | tcg_gen_add_i32(addr, REG(B7_4), REG(0));
|
739 | c55497ec | aurel32 | tcg_gen_qemu_ld16s(REG(B11_8), addr, ctx->memidx); |
740 | c55497ec | aurel32 | tcg_temp_free(addr); |
741 | c55497ec | aurel32 | } |
742 | fdf9b3e8 | bellard | return;
|
743 | fdf9b3e8 | bellard | case 0x000e: /* mov.l @(R0,Rm),Rn */ |
744 | c55497ec | aurel32 | { |
745 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
746 | c55497ec | aurel32 | tcg_gen_add_i32(addr, REG(B7_4), REG(0));
|
747 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(REG(B11_8), addr, ctx->memidx); |
748 | c55497ec | aurel32 | tcg_temp_free(addr); |
749 | c55497ec | aurel32 | } |
750 | fdf9b3e8 | bellard | return;
|
751 | fdf9b3e8 | bellard | case 0x6008: /* swap.b Rm,Rn */ |
752 | c55497ec | aurel32 | { |
753 | c69e3264 | aurel32 | TCGv highw, high, low; |
754 | a7812ae4 | pbrook | highw = tcg_temp_new(); |
755 | c69e3264 | aurel32 | tcg_gen_andi_i32(highw, REG(B7_4), 0xffff0000);
|
756 | a7812ae4 | pbrook | high = tcg_temp_new(); |
757 | c55497ec | aurel32 | tcg_gen_ext8u_i32(high, REG(B7_4)); |
758 | c55497ec | aurel32 | tcg_gen_shli_i32(high, high, 8);
|
759 | a7812ae4 | pbrook | low = tcg_temp_new(); |
760 | c55497ec | aurel32 | tcg_gen_shri_i32(low, REG(B7_4), 8);
|
761 | c55497ec | aurel32 | tcg_gen_ext8u_i32(low, low); |
762 | c55497ec | aurel32 | tcg_gen_or_i32(REG(B11_8), high, low); |
763 | c69e3264 | aurel32 | tcg_gen_or_i32(REG(B11_8), REG(B11_8), highw); |
764 | c55497ec | aurel32 | tcg_temp_free(low); |
765 | c55497ec | aurel32 | tcg_temp_free(high); |
766 | c55497ec | aurel32 | } |
767 | fdf9b3e8 | bellard | return;
|
768 | fdf9b3e8 | bellard | case 0x6009: /* swap.w Rm,Rn */ |
769 | c55497ec | aurel32 | { |
770 | c55497ec | aurel32 | TCGv high, low; |
771 | a7812ae4 | pbrook | high = tcg_temp_new(); |
772 | c55497ec | aurel32 | tcg_gen_ext16u_i32(high, REG(B7_4)); |
773 | c55497ec | aurel32 | tcg_gen_shli_i32(high, high, 16);
|
774 | a7812ae4 | pbrook | low = tcg_temp_new(); |
775 | c55497ec | aurel32 | tcg_gen_shri_i32(low, REG(B7_4), 16);
|
776 | c55497ec | aurel32 | tcg_gen_ext16u_i32(low, low); |
777 | c55497ec | aurel32 | tcg_gen_or_i32(REG(B11_8), high, low); |
778 | c55497ec | aurel32 | tcg_temp_free(low); |
779 | c55497ec | aurel32 | tcg_temp_free(high); |
780 | c55497ec | aurel32 | } |
781 | fdf9b3e8 | bellard | return;
|
782 | fdf9b3e8 | bellard | case 0x200d: /* xtrct Rm,Rn */ |
783 | c55497ec | aurel32 | { |
784 | c55497ec | aurel32 | TCGv high, low; |
785 | a7812ae4 | pbrook | high = tcg_temp_new(); |
786 | c55497ec | aurel32 | tcg_gen_ext16u_i32(high, REG(B7_4)); |
787 | c55497ec | aurel32 | tcg_gen_shli_i32(high, high, 16);
|
788 | a7812ae4 | pbrook | low = tcg_temp_new(); |
789 | c55497ec | aurel32 | tcg_gen_shri_i32(low, REG(B11_8), 16);
|
790 | c55497ec | aurel32 | tcg_gen_ext16u_i32(low, low); |
791 | c55497ec | aurel32 | tcg_gen_or_i32(REG(B11_8), high, low); |
792 | c55497ec | aurel32 | tcg_temp_free(low); |
793 | c55497ec | aurel32 | tcg_temp_free(high); |
794 | c55497ec | aurel32 | } |
795 | fdf9b3e8 | bellard | return;
|
796 | fdf9b3e8 | bellard | case 0x300c: /* add Rm,Rn */ |
797 | 7efbe241 | aurel32 | tcg_gen_add_i32(REG(B11_8), REG(B11_8), REG(B7_4)); |
798 | fdf9b3e8 | bellard | return;
|
799 | fdf9b3e8 | bellard | case 0x300e: /* addc Rm,Rn */ |
800 | a7812ae4 | pbrook | gen_helper_addc(REG(B11_8), REG(B7_4), REG(B11_8)); |
801 | fdf9b3e8 | bellard | return;
|
802 | fdf9b3e8 | bellard | case 0x300f: /* addv Rm,Rn */ |
803 | a7812ae4 | pbrook | gen_helper_addv(REG(B11_8), REG(B7_4), REG(B11_8)); |
804 | fdf9b3e8 | bellard | return;
|
805 | fdf9b3e8 | bellard | case 0x2009: /* and Rm,Rn */ |
806 | 7efbe241 | aurel32 | tcg_gen_and_i32(REG(B11_8), REG(B11_8), REG(B7_4)); |
807 | fdf9b3e8 | bellard | return;
|
808 | fdf9b3e8 | bellard | case 0x3000: /* cmp/eq Rm,Rn */ |
809 | 7efbe241 | aurel32 | gen_cmp(TCG_COND_EQ, REG(B7_4), REG(B11_8)); |
810 | fdf9b3e8 | bellard | return;
|
811 | fdf9b3e8 | bellard | case 0x3003: /* cmp/ge Rm,Rn */ |
812 | 7efbe241 | aurel32 | gen_cmp(TCG_COND_GE, REG(B7_4), REG(B11_8)); |
813 | fdf9b3e8 | bellard | return;
|
814 | fdf9b3e8 | bellard | case 0x3007: /* cmp/gt Rm,Rn */ |
815 | 7efbe241 | aurel32 | gen_cmp(TCG_COND_GT, REG(B7_4), REG(B11_8)); |
816 | fdf9b3e8 | bellard | return;
|
817 | fdf9b3e8 | bellard | case 0x3006: /* cmp/hi Rm,Rn */ |
818 | 7efbe241 | aurel32 | gen_cmp(TCG_COND_GTU, REG(B7_4), REG(B11_8)); |
819 | fdf9b3e8 | bellard | return;
|
820 | fdf9b3e8 | bellard | case 0x3002: /* cmp/hs Rm,Rn */ |
821 | 7efbe241 | aurel32 | gen_cmp(TCG_COND_GEU, REG(B7_4), REG(B11_8)); |
822 | fdf9b3e8 | bellard | return;
|
823 | fdf9b3e8 | bellard | case 0x200c: /* cmp/str Rm,Rn */ |
824 | 69d6275b | aurel32 | { |
825 | 69d6275b | aurel32 | int label1 = gen_new_label();
|
826 | 69d6275b | aurel32 | int label2 = gen_new_label();
|
827 | df9247b2 | aurel32 | TCGv cmp1 = tcg_temp_local_new(); |
828 | df9247b2 | aurel32 | TCGv cmp2 = tcg_temp_local_new(); |
829 | c55497ec | aurel32 | tcg_gen_xor_i32(cmp1, REG(B7_4), REG(B11_8)); |
830 | c55497ec | aurel32 | tcg_gen_andi_i32(cmp2, cmp1, 0xff000000);
|
831 | c55497ec | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, cmp2, 0, label1);
|
832 | c55497ec | aurel32 | tcg_gen_andi_i32(cmp2, cmp1, 0x00ff0000);
|
833 | c55497ec | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, cmp2, 0, label1);
|
834 | c55497ec | aurel32 | tcg_gen_andi_i32(cmp2, cmp1, 0x0000ff00);
|
835 | c55497ec | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, cmp2, 0, label1);
|
836 | c55497ec | aurel32 | tcg_gen_andi_i32(cmp2, cmp1, 0x000000ff);
|
837 | c55497ec | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, cmp2, 0, label1);
|
838 | 69d6275b | aurel32 | tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T); |
839 | 69d6275b | aurel32 | tcg_gen_br(label2); |
840 | 69d6275b | aurel32 | gen_set_label(label1); |
841 | 69d6275b | aurel32 | tcg_gen_ori_i32(cpu_sr, cpu_sr, SR_T); |
842 | 69d6275b | aurel32 | gen_set_label(label2); |
843 | c55497ec | aurel32 | tcg_temp_free(cmp2); |
844 | c55497ec | aurel32 | tcg_temp_free(cmp1); |
845 | 69d6275b | aurel32 | } |
846 | fdf9b3e8 | bellard | return;
|
847 | fdf9b3e8 | bellard | case 0x2007: /* div0s Rm,Rn */ |
848 | c55497ec | aurel32 | { |
849 | c55497ec | aurel32 | gen_copy_bit_i32(cpu_sr, 8, REG(B11_8), 31); /* SR_Q */ |
850 | c55497ec | aurel32 | gen_copy_bit_i32(cpu_sr, 9, REG(B7_4), 31); /* SR_M */ |
851 | a7812ae4 | pbrook | TCGv val = tcg_temp_new(); |
852 | c55497ec | aurel32 | tcg_gen_xor_i32(val, REG(B7_4), REG(B11_8)); |
853 | c55497ec | aurel32 | gen_copy_bit_i32(cpu_sr, 0, val, 31); /* SR_T */ |
854 | c55497ec | aurel32 | tcg_temp_free(val); |
855 | c55497ec | aurel32 | } |
856 | fdf9b3e8 | bellard | return;
|
857 | fdf9b3e8 | bellard | case 0x3004: /* div1 Rm,Rn */ |
858 | a7812ae4 | pbrook | gen_helper_div1(REG(B11_8), REG(B7_4), REG(B11_8)); |
859 | fdf9b3e8 | bellard | return;
|
860 | fdf9b3e8 | bellard | case 0x300d: /* dmuls.l Rm,Rn */ |
861 | 6f06939b | aurel32 | { |
862 | a7812ae4 | pbrook | TCGv_i64 tmp1 = tcg_temp_new_i64(); |
863 | a7812ae4 | pbrook | TCGv_i64 tmp2 = tcg_temp_new_i64(); |
864 | 6f06939b | aurel32 | |
865 | 7efbe241 | aurel32 | tcg_gen_ext_i32_i64(tmp1, REG(B7_4)); |
866 | 7efbe241 | aurel32 | tcg_gen_ext_i32_i64(tmp2, REG(B11_8)); |
867 | 6f06939b | aurel32 | tcg_gen_mul_i64(tmp1, tmp1, tmp2); |
868 | 6f06939b | aurel32 | tcg_gen_trunc_i64_i32(cpu_macl, tmp1); |
869 | 6f06939b | aurel32 | tcg_gen_shri_i64(tmp1, tmp1, 32);
|
870 | 6f06939b | aurel32 | tcg_gen_trunc_i64_i32(cpu_mach, tmp1); |
871 | 6f06939b | aurel32 | |
872 | a7812ae4 | pbrook | tcg_temp_free_i64(tmp2); |
873 | a7812ae4 | pbrook | tcg_temp_free_i64(tmp1); |
874 | 6f06939b | aurel32 | } |
875 | fdf9b3e8 | bellard | return;
|
876 | fdf9b3e8 | bellard | case 0x3005: /* dmulu.l Rm,Rn */ |
877 | 6f06939b | aurel32 | { |
878 | a7812ae4 | pbrook | TCGv_i64 tmp1 = tcg_temp_new_i64(); |
879 | a7812ae4 | pbrook | TCGv_i64 tmp2 = tcg_temp_new_i64(); |
880 | 6f06939b | aurel32 | |
881 | 7efbe241 | aurel32 | tcg_gen_extu_i32_i64(tmp1, REG(B7_4)); |
882 | 7efbe241 | aurel32 | tcg_gen_extu_i32_i64(tmp2, REG(B11_8)); |
883 | 6f06939b | aurel32 | tcg_gen_mul_i64(tmp1, tmp1, tmp2); |
884 | 6f06939b | aurel32 | tcg_gen_trunc_i64_i32(cpu_macl, tmp1); |
885 | 6f06939b | aurel32 | tcg_gen_shri_i64(tmp1, tmp1, 32);
|
886 | 6f06939b | aurel32 | tcg_gen_trunc_i64_i32(cpu_mach, tmp1); |
887 | 6f06939b | aurel32 | |
888 | a7812ae4 | pbrook | tcg_temp_free_i64(tmp2); |
889 | a7812ae4 | pbrook | tcg_temp_free_i64(tmp1); |
890 | 6f06939b | aurel32 | } |
891 | fdf9b3e8 | bellard | return;
|
892 | fdf9b3e8 | bellard | case 0x600e: /* exts.b Rm,Rn */ |
893 | 7efbe241 | aurel32 | tcg_gen_ext8s_i32(REG(B11_8), REG(B7_4)); |
894 | fdf9b3e8 | bellard | return;
|
895 | fdf9b3e8 | bellard | case 0x600f: /* exts.w Rm,Rn */ |
896 | 7efbe241 | aurel32 | tcg_gen_ext16s_i32(REG(B11_8), REG(B7_4)); |
897 | fdf9b3e8 | bellard | return;
|
898 | fdf9b3e8 | bellard | case 0x600c: /* extu.b Rm,Rn */ |
899 | 7efbe241 | aurel32 | tcg_gen_ext8u_i32(REG(B11_8), REG(B7_4)); |
900 | fdf9b3e8 | bellard | return;
|
901 | fdf9b3e8 | bellard | case 0x600d: /* extu.w Rm,Rn */ |
902 | 7efbe241 | aurel32 | tcg_gen_ext16u_i32(REG(B11_8), REG(B7_4)); |
903 | fdf9b3e8 | bellard | return;
|
904 | 24988dc2 | aurel32 | case 0x000f: /* mac.l @Rm+,@Rn+ */ |
905 | c55497ec | aurel32 | { |
906 | c55497ec | aurel32 | TCGv arg0, arg1; |
907 | a7812ae4 | pbrook | arg0 = tcg_temp_new(); |
908 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(arg0, REG(B7_4), ctx->memidx); |
909 | a7812ae4 | pbrook | arg1 = tcg_temp_new(); |
910 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(arg1, REG(B11_8), ctx->memidx); |
911 | a7812ae4 | pbrook | gen_helper_macl(arg0, arg1); |
912 | c55497ec | aurel32 | tcg_temp_free(arg1); |
913 | c55497ec | aurel32 | tcg_temp_free(arg0); |
914 | c55497ec | aurel32 | tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 4);
|
915 | c55497ec | aurel32 | tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
916 | c55497ec | aurel32 | } |
917 | fdf9b3e8 | bellard | return;
|
918 | fdf9b3e8 | bellard | case 0x400f: /* mac.w @Rm+,@Rn+ */ |
919 | c55497ec | aurel32 | { |
920 | c55497ec | aurel32 | TCGv arg0, arg1; |
921 | a7812ae4 | pbrook | arg0 = tcg_temp_new(); |
922 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(arg0, REG(B7_4), ctx->memidx); |
923 | a7812ae4 | pbrook | arg1 = tcg_temp_new(); |
924 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(arg1, REG(B11_8), ctx->memidx); |
925 | a7812ae4 | pbrook | gen_helper_macw(arg0, arg1); |
926 | c55497ec | aurel32 | tcg_temp_free(arg1); |
927 | c55497ec | aurel32 | tcg_temp_free(arg0); |
928 | c55497ec | aurel32 | tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 2);
|
929 | c55497ec | aurel32 | tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 2);
|
930 | c55497ec | aurel32 | } |
931 | fdf9b3e8 | bellard | return;
|
932 | fdf9b3e8 | bellard | case 0x0007: /* mul.l Rm,Rn */ |
933 | 7efbe241 | aurel32 | tcg_gen_mul_i32(cpu_macl, REG(B7_4), REG(B11_8)); |
934 | fdf9b3e8 | bellard | return;
|
935 | fdf9b3e8 | bellard | case 0x200f: /* muls.w Rm,Rn */ |
936 | c55497ec | aurel32 | { |
937 | c55497ec | aurel32 | TCGv arg0, arg1; |
938 | a7812ae4 | pbrook | arg0 = tcg_temp_new(); |
939 | c55497ec | aurel32 | tcg_gen_ext16s_i32(arg0, REG(B7_4)); |
940 | a7812ae4 | pbrook | arg1 = tcg_temp_new(); |
941 | c55497ec | aurel32 | tcg_gen_ext16s_i32(arg1, REG(B11_8)); |
942 | c55497ec | aurel32 | tcg_gen_mul_i32(cpu_macl, arg0, arg1); |
943 | c55497ec | aurel32 | tcg_temp_free(arg1); |
944 | c55497ec | aurel32 | tcg_temp_free(arg0); |
945 | c55497ec | aurel32 | } |
946 | fdf9b3e8 | bellard | return;
|
947 | fdf9b3e8 | bellard | case 0x200e: /* mulu.w Rm,Rn */ |
948 | c55497ec | aurel32 | { |
949 | c55497ec | aurel32 | TCGv arg0, arg1; |
950 | a7812ae4 | pbrook | arg0 = tcg_temp_new(); |
951 | c55497ec | aurel32 | tcg_gen_ext16u_i32(arg0, REG(B7_4)); |
952 | a7812ae4 | pbrook | arg1 = tcg_temp_new(); |
953 | c55497ec | aurel32 | tcg_gen_ext16u_i32(arg1, REG(B11_8)); |
954 | c55497ec | aurel32 | tcg_gen_mul_i32(cpu_macl, arg0, arg1); |
955 | c55497ec | aurel32 | tcg_temp_free(arg1); |
956 | c55497ec | aurel32 | tcg_temp_free(arg0); |
957 | c55497ec | aurel32 | } |
958 | fdf9b3e8 | bellard | return;
|
959 | fdf9b3e8 | bellard | case 0x600b: /* neg Rm,Rn */ |
960 | 7efbe241 | aurel32 | tcg_gen_neg_i32(REG(B11_8), REG(B7_4)); |
961 | fdf9b3e8 | bellard | return;
|
962 | fdf9b3e8 | bellard | case 0x600a: /* negc Rm,Rn */ |
963 | a7812ae4 | pbrook | gen_helper_negc(REG(B11_8), REG(B7_4)); |
964 | fdf9b3e8 | bellard | return;
|
965 | fdf9b3e8 | bellard | case 0x6007: /* not Rm,Rn */ |
966 | 7efbe241 | aurel32 | tcg_gen_not_i32(REG(B11_8), REG(B7_4)); |
967 | fdf9b3e8 | bellard | return;
|
968 | fdf9b3e8 | bellard | case 0x200b: /* or Rm,Rn */ |
969 | 7efbe241 | aurel32 | tcg_gen_or_i32(REG(B11_8), REG(B11_8), REG(B7_4)); |
970 | fdf9b3e8 | bellard | return;
|
971 | fdf9b3e8 | bellard | case 0x400c: /* shad Rm,Rn */ |
972 | 69d6275b | aurel32 | { |
973 | 69d6275b | aurel32 | int label1 = gen_new_label();
|
974 | 69d6275b | aurel32 | int label2 = gen_new_label();
|
975 | 69d6275b | aurel32 | int label3 = gen_new_label();
|
976 | 69d6275b | aurel32 | int label4 = gen_new_label();
|
977 | df9247b2 | aurel32 | TCGv shift = tcg_temp_local_new(); |
978 | 7efbe241 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_LT, REG(B7_4), 0, label1);
|
979 | 69d6275b | aurel32 | /* Rm positive, shift to the left */
|
980 | c55497ec | aurel32 | tcg_gen_andi_i32(shift, REG(B7_4), 0x1f);
|
981 | c55497ec | aurel32 | tcg_gen_shl_i32(REG(B11_8), REG(B11_8), shift); |
982 | 69d6275b | aurel32 | tcg_gen_br(label4); |
983 | 69d6275b | aurel32 | /* Rm negative, shift to the right */
|
984 | 69d6275b | aurel32 | gen_set_label(label1); |
985 | c55497ec | aurel32 | tcg_gen_andi_i32(shift, REG(B7_4), 0x1f);
|
986 | c55497ec | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, shift, 0, label2);
|
987 | c55497ec | aurel32 | tcg_gen_not_i32(shift, REG(B7_4)); |
988 | c55497ec | aurel32 | tcg_gen_andi_i32(shift, shift, 0x1f);
|
989 | c55497ec | aurel32 | tcg_gen_addi_i32(shift, shift, 1);
|
990 | c55497ec | aurel32 | tcg_gen_sar_i32(REG(B11_8), REG(B11_8), shift); |
991 | 69d6275b | aurel32 | tcg_gen_br(label4); |
992 | 69d6275b | aurel32 | /* Rm = -32 */
|
993 | 69d6275b | aurel32 | gen_set_label(label2); |
994 | 7efbe241 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_LT, REG(B11_8), 0, label3);
|
995 | 7efbe241 | aurel32 | tcg_gen_movi_i32(REG(B11_8), 0);
|
996 | 69d6275b | aurel32 | tcg_gen_br(label4); |
997 | 69d6275b | aurel32 | gen_set_label(label3); |
998 | 7efbe241 | aurel32 | tcg_gen_movi_i32(REG(B11_8), 0xffffffff);
|
999 | 69d6275b | aurel32 | gen_set_label(label4); |
1000 | c55497ec | aurel32 | tcg_temp_free(shift); |
1001 | 69d6275b | aurel32 | } |
1002 | fdf9b3e8 | bellard | return;
|
1003 | fdf9b3e8 | bellard | case 0x400d: /* shld Rm,Rn */ |
1004 | 69d6275b | aurel32 | { |
1005 | 69d6275b | aurel32 | int label1 = gen_new_label();
|
1006 | 69d6275b | aurel32 | int label2 = gen_new_label();
|
1007 | 69d6275b | aurel32 | int label3 = gen_new_label();
|
1008 | df9247b2 | aurel32 | TCGv shift = tcg_temp_local_new(); |
1009 | 7efbe241 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_LT, REG(B7_4), 0, label1);
|
1010 | 69d6275b | aurel32 | /* Rm positive, shift to the left */
|
1011 | c55497ec | aurel32 | tcg_gen_andi_i32(shift, REG(B7_4), 0x1f);
|
1012 | c55497ec | aurel32 | tcg_gen_shl_i32(REG(B11_8), REG(B11_8), shift); |
1013 | 69d6275b | aurel32 | tcg_gen_br(label3); |
1014 | 69d6275b | aurel32 | /* Rm negative, shift to the right */
|
1015 | 69d6275b | aurel32 | gen_set_label(label1); |
1016 | c55497ec | aurel32 | tcg_gen_andi_i32(shift, REG(B7_4), 0x1f);
|
1017 | c55497ec | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, shift, 0, label2);
|
1018 | c55497ec | aurel32 | tcg_gen_not_i32(shift, REG(B7_4)); |
1019 | c55497ec | aurel32 | tcg_gen_andi_i32(shift, shift, 0x1f);
|
1020 | c55497ec | aurel32 | tcg_gen_addi_i32(shift, shift, 1);
|
1021 | c55497ec | aurel32 | tcg_gen_shr_i32(REG(B11_8), REG(B11_8), shift); |
1022 | 69d6275b | aurel32 | tcg_gen_br(label3); |
1023 | 69d6275b | aurel32 | /* Rm = -32 */
|
1024 | 69d6275b | aurel32 | gen_set_label(label2); |
1025 | 7efbe241 | aurel32 | tcg_gen_movi_i32(REG(B11_8), 0);
|
1026 | 69d6275b | aurel32 | gen_set_label(label3); |
1027 | c55497ec | aurel32 | tcg_temp_free(shift); |
1028 | 69d6275b | aurel32 | } |
1029 | fdf9b3e8 | bellard | return;
|
1030 | fdf9b3e8 | bellard | case 0x3008: /* sub Rm,Rn */ |
1031 | 7efbe241 | aurel32 | tcg_gen_sub_i32(REG(B11_8), REG(B11_8), REG(B7_4)); |
1032 | fdf9b3e8 | bellard | return;
|
1033 | fdf9b3e8 | bellard | case 0x300a: /* subc Rm,Rn */ |
1034 | a7812ae4 | pbrook | gen_helper_subc(REG(B11_8), REG(B7_4), REG(B11_8)); |
1035 | fdf9b3e8 | bellard | return;
|
1036 | fdf9b3e8 | bellard | case 0x300b: /* subv Rm,Rn */ |
1037 | a7812ae4 | pbrook | gen_helper_subv(REG(B11_8), REG(B7_4), REG(B11_8)); |
1038 | fdf9b3e8 | bellard | return;
|
1039 | fdf9b3e8 | bellard | case 0x2008: /* tst Rm,Rn */ |
1040 | c55497ec | aurel32 | { |
1041 | a7812ae4 | pbrook | TCGv val = tcg_temp_new(); |
1042 | c55497ec | aurel32 | tcg_gen_and_i32(val, REG(B7_4), REG(B11_8)); |
1043 | c55497ec | aurel32 | gen_cmp_imm(TCG_COND_EQ, val, 0);
|
1044 | c55497ec | aurel32 | tcg_temp_free(val); |
1045 | c55497ec | aurel32 | } |
1046 | fdf9b3e8 | bellard | return;
|
1047 | fdf9b3e8 | bellard | case 0x200a: /* xor Rm,Rn */ |
1048 | 7efbe241 | aurel32 | tcg_gen_xor_i32(REG(B11_8), REG(B11_8), REG(B7_4)); |
1049 | fdf9b3e8 | bellard | return;
|
1050 | e67888a7 | ths | case 0xf00c: /* fmov {F,D,X}Rm,{F,D,X}Rn - FPSCR: Nothing */ |
1051 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1052 | 022a22c7 | ths | if (ctx->fpscr & FPSCR_SZ) {
|
1053 | a7812ae4 | pbrook | TCGv_i64 fp = tcg_temp_new_i64(); |
1054 | cc4ba6a9 | aurel32 | gen_load_fpr64(fp, XREG(B7_4)); |
1055 | cc4ba6a9 | aurel32 | gen_store_fpr64(fp, XREG(B11_8)); |
1056 | a7812ae4 | pbrook | tcg_temp_free_i64(fp); |
1057 | eda9b09b | bellard | } else {
|
1058 | 66ba317c | aurel32 | tcg_gen_mov_i32(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B7_4)]); |
1059 | eda9b09b | bellard | } |
1060 | eda9b09b | bellard | return;
|
1061 | e67888a7 | ths | case 0xf00a: /* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */ |
1062 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1063 | 022a22c7 | ths | if (ctx->fpscr & FPSCR_SZ) {
|
1064 | 11bb09f1 | aurel32 | TCGv addr_hi = tcg_temp_new(); |
1065 | 11bb09f1 | aurel32 | int fr = XREG(B7_4);
|
1066 | 11bb09f1 | aurel32 | tcg_gen_addi_i32(addr_hi, REG(B11_8), 4);
|
1067 | 11bb09f1 | aurel32 | tcg_gen_qemu_st32(cpu_fregs[fr ], REG(B11_8), ctx->memidx); |
1068 | 11bb09f1 | aurel32 | tcg_gen_qemu_st32(cpu_fregs[fr+1], addr_hi, ctx->memidx);
|
1069 | 11bb09f1 | aurel32 | tcg_temp_free(addr_hi); |
1070 | eda9b09b | bellard | } else {
|
1071 | 66ba317c | aurel32 | tcg_gen_qemu_st32(cpu_fregs[FREG(B7_4)], REG(B11_8), ctx->memidx); |
1072 | eda9b09b | bellard | } |
1073 | eda9b09b | bellard | return;
|
1074 | e67888a7 | ths | case 0xf008: /* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */ |
1075 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1076 | 022a22c7 | ths | if (ctx->fpscr & FPSCR_SZ) {
|
1077 | 11bb09f1 | aurel32 | TCGv addr_hi = tcg_temp_new(); |
1078 | 11bb09f1 | aurel32 | int fr = XREG(B11_8);
|
1079 | 11bb09f1 | aurel32 | tcg_gen_addi_i32(addr_hi, REG(B7_4), 4);
|
1080 | 11bb09f1 | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[fr ], REG(B7_4), ctx->memidx); |
1081 | 11bb09f1 | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[fr+1], addr_hi, ctx->memidx);
|
1082 | 11bb09f1 | aurel32 | tcg_temp_free(addr_hi); |
1083 | eda9b09b | bellard | } else {
|
1084 | 66ba317c | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[FREG(B11_8)], REG(B7_4), ctx->memidx); |
1085 | eda9b09b | bellard | } |
1086 | eda9b09b | bellard | return;
|
1087 | e67888a7 | ths | case 0xf009: /* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */ |
1088 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1089 | 022a22c7 | ths | if (ctx->fpscr & FPSCR_SZ) {
|
1090 | 11bb09f1 | aurel32 | TCGv addr_hi = tcg_temp_new(); |
1091 | 11bb09f1 | aurel32 | int fr = XREG(B11_8);
|
1092 | 11bb09f1 | aurel32 | tcg_gen_addi_i32(addr_hi, REG(B7_4), 4);
|
1093 | 11bb09f1 | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[fr ], REG(B7_4), ctx->memidx); |
1094 | 11bb09f1 | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[fr+1], addr_hi, ctx->memidx);
|
1095 | 11bb09f1 | aurel32 | tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 8);
|
1096 | 11bb09f1 | aurel32 | tcg_temp_free(addr_hi); |
1097 | eda9b09b | bellard | } else {
|
1098 | 66ba317c | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[FREG(B11_8)], REG(B7_4), ctx->memidx); |
1099 | cc4ba6a9 | aurel32 | tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 4);
|
1100 | eda9b09b | bellard | } |
1101 | eda9b09b | bellard | return;
|
1102 | e67888a7 | ths | case 0xf00b: /* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */ |
1103 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1104 | 022a22c7 | ths | if (ctx->fpscr & FPSCR_SZ) {
|
1105 | 11bb09f1 | aurel32 | TCGv addr = tcg_temp_new_i32(); |
1106 | 11bb09f1 | aurel32 | int fr = XREG(B7_4);
|
1107 | 11bb09f1 | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
1108 | 11bb09f1 | aurel32 | tcg_gen_qemu_st32(cpu_fregs[fr+1], addr, ctx->memidx);
|
1109 | cc4ba6a9 | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 8);
|
1110 | 11bb09f1 | aurel32 | tcg_gen_qemu_st32(cpu_fregs[fr ], addr, ctx->memidx); |
1111 | 11bb09f1 | aurel32 | tcg_gen_mov_i32(REG(B11_8), addr); |
1112 | cc4ba6a9 | aurel32 | tcg_temp_free(addr); |
1113 | eda9b09b | bellard | } else {
|
1114 | a7812ae4 | pbrook | TCGv addr; |
1115 | a7812ae4 | pbrook | addr = tcg_temp_new_i32(); |
1116 | cc4ba6a9 | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
1117 | 66ba317c | aurel32 | tcg_gen_qemu_st32(cpu_fregs[FREG(B7_4)], addr, ctx->memidx); |
1118 | cc4ba6a9 | aurel32 | tcg_temp_free(addr); |
1119 | 7efbe241 | aurel32 | tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 4);
|
1120 | eda9b09b | bellard | } |
1121 | eda9b09b | bellard | return;
|
1122 | e67888a7 | ths | case 0xf006: /* fmov @(R0,Rm),{F,D,X}Rm - FPSCR: Nothing */ |
1123 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1124 | cc4ba6a9 | aurel32 | { |
1125 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new_i32(); |
1126 | cc4ba6a9 | aurel32 | tcg_gen_add_i32(addr, REG(B7_4), REG(0));
|
1127 | cc4ba6a9 | aurel32 | if (ctx->fpscr & FPSCR_SZ) {
|
1128 | 11bb09f1 | aurel32 | int fr = XREG(B11_8);
|
1129 | 11bb09f1 | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[fr ], addr, ctx->memidx); |
1130 | 11bb09f1 | aurel32 | tcg_gen_addi_i32(addr, addr, 4);
|
1131 | 11bb09f1 | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[fr+1], addr, ctx->memidx);
|
1132 | cc4ba6a9 | aurel32 | } else {
|
1133 | 66ba317c | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[FREG(B11_8)], addr, ctx->memidx); |
1134 | cc4ba6a9 | aurel32 | } |
1135 | cc4ba6a9 | aurel32 | tcg_temp_free(addr); |
1136 | eda9b09b | bellard | } |
1137 | eda9b09b | bellard | return;
|
1138 | e67888a7 | ths | case 0xf007: /* fmov {F,D,X}Rn,@(R0,Rn) - FPSCR: Nothing */ |
1139 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1140 | cc4ba6a9 | aurel32 | { |
1141 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1142 | cc4ba6a9 | aurel32 | tcg_gen_add_i32(addr, REG(B11_8), REG(0));
|
1143 | cc4ba6a9 | aurel32 | if (ctx->fpscr & FPSCR_SZ) {
|
1144 | 11bb09f1 | aurel32 | int fr = XREG(B7_4);
|
1145 | 11bb09f1 | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[fr ], addr, ctx->memidx); |
1146 | 11bb09f1 | aurel32 | tcg_gen_addi_i32(addr, addr, 4);
|
1147 | 11bb09f1 | aurel32 | tcg_gen_qemu_ld32u(cpu_fregs[fr+1], addr, ctx->memidx);
|
1148 | cc4ba6a9 | aurel32 | } else {
|
1149 | 66ba317c | aurel32 | tcg_gen_qemu_st32(cpu_fregs[FREG(B7_4)], addr, ctx->memidx); |
1150 | cc4ba6a9 | aurel32 | } |
1151 | cc4ba6a9 | aurel32 | tcg_temp_free(addr); |
1152 | eda9b09b | bellard | } |
1153 | eda9b09b | bellard | return;
|
1154 | e67888a7 | ths | case 0xf000: /* fadd Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */ |
1155 | e67888a7 | ths | case 0xf001: /* fsub Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */ |
1156 | e67888a7 | ths | case 0xf002: /* fmul Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */ |
1157 | e67888a7 | ths | case 0xf003: /* fdiv Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */ |
1158 | e67888a7 | ths | case 0xf004: /* fcmp/eq Rm,Rn - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */ |
1159 | e67888a7 | ths | case 0xf005: /* fcmp/gt Rm,Rn - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */ |
1160 | cc4ba6a9 | aurel32 | { |
1161 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1162 | cc4ba6a9 | aurel32 | if (ctx->fpscr & FPSCR_PR) {
|
1163 | a7812ae4 | pbrook | TCGv_i64 fp0, fp1; |
1164 | a7812ae4 | pbrook | |
1165 | cc4ba6a9 | aurel32 | if (ctx->opcode & 0x0110) |
1166 | cc4ba6a9 | aurel32 | break; /* illegal instruction */ |
1167 | a7812ae4 | pbrook | fp0 = tcg_temp_new_i64(); |
1168 | a7812ae4 | pbrook | fp1 = tcg_temp_new_i64(); |
1169 | cc4ba6a9 | aurel32 | gen_load_fpr64(fp0, DREG(B11_8)); |
1170 | cc4ba6a9 | aurel32 | gen_load_fpr64(fp1, DREG(B7_4)); |
1171 | a7812ae4 | pbrook | switch (ctx->opcode & 0xf00f) { |
1172 | a7812ae4 | pbrook | case 0xf000: /* fadd Rm,Rn */ |
1173 | a7812ae4 | pbrook | gen_helper_fadd_DT(fp0, fp0, fp1); |
1174 | a7812ae4 | pbrook | break;
|
1175 | a7812ae4 | pbrook | case 0xf001: /* fsub Rm,Rn */ |
1176 | a7812ae4 | pbrook | gen_helper_fsub_DT(fp0, fp0, fp1); |
1177 | a7812ae4 | pbrook | break;
|
1178 | a7812ae4 | pbrook | case 0xf002: /* fmul Rm,Rn */ |
1179 | a7812ae4 | pbrook | gen_helper_fmul_DT(fp0, fp0, fp1); |
1180 | a7812ae4 | pbrook | break;
|
1181 | a7812ae4 | pbrook | case 0xf003: /* fdiv Rm,Rn */ |
1182 | a7812ae4 | pbrook | gen_helper_fdiv_DT(fp0, fp0, fp1); |
1183 | a7812ae4 | pbrook | break;
|
1184 | a7812ae4 | pbrook | case 0xf004: /* fcmp/eq Rm,Rn */ |
1185 | a7812ae4 | pbrook | gen_helper_fcmp_eq_DT(fp0, fp1); |
1186 | a7812ae4 | pbrook | return;
|
1187 | a7812ae4 | pbrook | case 0xf005: /* fcmp/gt Rm,Rn */ |
1188 | a7812ae4 | pbrook | gen_helper_fcmp_gt_DT(fp0, fp1); |
1189 | a7812ae4 | pbrook | return;
|
1190 | a7812ae4 | pbrook | } |
1191 | a7812ae4 | pbrook | gen_store_fpr64(fp0, DREG(B11_8)); |
1192 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
1193 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
1194 | a7812ae4 | pbrook | } else {
|
1195 | a7812ae4 | pbrook | switch (ctx->opcode & 0xf00f) { |
1196 | a7812ae4 | pbrook | case 0xf000: /* fadd Rm,Rn */ |
1197 | 66ba317c | aurel32 | gen_helper_fadd_FT(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B7_4)]); |
1198 | a7812ae4 | pbrook | break;
|
1199 | a7812ae4 | pbrook | case 0xf001: /* fsub Rm,Rn */ |
1200 | 66ba317c | aurel32 | gen_helper_fsub_FT(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B7_4)]); |
1201 | a7812ae4 | pbrook | break;
|
1202 | a7812ae4 | pbrook | case 0xf002: /* fmul Rm,Rn */ |
1203 | 66ba317c | aurel32 | gen_helper_fmul_FT(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B7_4)]); |
1204 | a7812ae4 | pbrook | break;
|
1205 | a7812ae4 | pbrook | case 0xf003: /* fdiv Rm,Rn */ |
1206 | 66ba317c | aurel32 | gen_helper_fdiv_FT(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B7_4)]); |
1207 | a7812ae4 | pbrook | break;
|
1208 | a7812ae4 | pbrook | case 0xf004: /* fcmp/eq Rm,Rn */ |
1209 | 66ba317c | aurel32 | gen_helper_fcmp_eq_FT(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B7_4)]); |
1210 | a7812ae4 | pbrook | return;
|
1211 | a7812ae4 | pbrook | case 0xf005: /* fcmp/gt Rm,Rn */ |
1212 | 66ba317c | aurel32 | gen_helper_fcmp_gt_FT(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B7_4)]); |
1213 | a7812ae4 | pbrook | return;
|
1214 | a7812ae4 | pbrook | } |
1215 | cc4ba6a9 | aurel32 | } |
1216 | ea6cf6be | ths | } |
1217 | ea6cf6be | ths | return;
|
1218 | 5b7141a1 | aurel32 | case 0xf00e: /* fmac FR0,RM,Rn */ |
1219 | 5b7141a1 | aurel32 | { |
1220 | 5b7141a1 | aurel32 | CHECK_FPU_ENABLED |
1221 | 5b7141a1 | aurel32 | if (ctx->fpscr & FPSCR_PR) {
|
1222 | 5b7141a1 | aurel32 | break; /* illegal instruction */ |
1223 | 5b7141a1 | aurel32 | } else {
|
1224 | 5b7141a1 | aurel32 | gen_helper_fmac_FT(cpu_fregs[FREG(B11_8)], |
1225 | 5b7141a1 | aurel32 | cpu_fregs[FREG(0)], cpu_fregs[FREG(B7_4)], cpu_fregs[FREG(B11_8)]);
|
1226 | 5b7141a1 | aurel32 | return;
|
1227 | 5b7141a1 | aurel32 | } |
1228 | 5b7141a1 | aurel32 | } |
1229 | fdf9b3e8 | bellard | } |
1230 | fdf9b3e8 | bellard | |
1231 | fdf9b3e8 | bellard | switch (ctx->opcode & 0xff00) { |
1232 | fdf9b3e8 | bellard | case 0xc900: /* and #imm,R0 */ |
1233 | 7efbe241 | aurel32 | tcg_gen_andi_i32(REG(0), REG(0), B7_0); |
1234 | fdf9b3e8 | bellard | return;
|
1235 | 24988dc2 | aurel32 | case 0xcd00: /* and.b #imm,@(R0,GBR) */ |
1236 | c55497ec | aurel32 | { |
1237 | c55497ec | aurel32 | TCGv addr, val; |
1238 | a7812ae4 | pbrook | addr = tcg_temp_new(); |
1239 | c55497ec | aurel32 | tcg_gen_add_i32(addr, REG(0), cpu_gbr);
|
1240 | a7812ae4 | pbrook | val = tcg_temp_new(); |
1241 | c55497ec | aurel32 | tcg_gen_qemu_ld8u(val, addr, ctx->memidx); |
1242 | c55497ec | aurel32 | tcg_gen_andi_i32(val, val, B7_0); |
1243 | c55497ec | aurel32 | tcg_gen_qemu_st8(val, addr, ctx->memidx); |
1244 | c55497ec | aurel32 | tcg_temp_free(val); |
1245 | c55497ec | aurel32 | tcg_temp_free(addr); |
1246 | c55497ec | aurel32 | } |
1247 | fdf9b3e8 | bellard | return;
|
1248 | fdf9b3e8 | bellard | case 0x8b00: /* bf label */ |
1249 | fdf9b3e8 | bellard | CHECK_NOT_DELAY_SLOT |
1250 | fdf9b3e8 | bellard | gen_conditional_jump(ctx, ctx->pc + 2,
|
1251 | fdf9b3e8 | bellard | ctx->pc + 4 + B7_0s * 2); |
1252 | 823029f9 | ths | ctx->bstate = BS_BRANCH; |
1253 | fdf9b3e8 | bellard | return;
|
1254 | fdf9b3e8 | bellard | case 0x8f00: /* bf/s label */ |
1255 | fdf9b3e8 | bellard | CHECK_NOT_DELAY_SLOT |
1256 | 1000822b | aurel32 | gen_branch_slot(ctx->delayed_pc = ctx->pc + 4 + B7_0s * 2, 0); |
1257 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT_CONDITIONAL; |
1258 | fdf9b3e8 | bellard | return;
|
1259 | fdf9b3e8 | bellard | case 0x8900: /* bt label */ |
1260 | fdf9b3e8 | bellard | CHECK_NOT_DELAY_SLOT |
1261 | fdf9b3e8 | bellard | gen_conditional_jump(ctx, ctx->pc + 4 + B7_0s * 2, |
1262 | fdf9b3e8 | bellard | ctx->pc + 2);
|
1263 | 823029f9 | ths | ctx->bstate = BS_BRANCH; |
1264 | fdf9b3e8 | bellard | return;
|
1265 | fdf9b3e8 | bellard | case 0x8d00: /* bt/s label */ |
1266 | fdf9b3e8 | bellard | CHECK_NOT_DELAY_SLOT |
1267 | 1000822b | aurel32 | gen_branch_slot(ctx->delayed_pc = ctx->pc + 4 + B7_0s * 2, 1); |
1268 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT_CONDITIONAL; |
1269 | fdf9b3e8 | bellard | return;
|
1270 | fdf9b3e8 | bellard | case 0x8800: /* cmp/eq #imm,R0 */ |
1271 | 7efbe241 | aurel32 | gen_cmp_imm(TCG_COND_EQ, REG(0), B7_0s);
|
1272 | fdf9b3e8 | bellard | return;
|
1273 | fdf9b3e8 | bellard | case 0xc400: /* mov.b @(disp,GBR),R0 */ |
1274 | c55497ec | aurel32 | { |
1275 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1276 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, cpu_gbr, B7_0); |
1277 | c55497ec | aurel32 | tcg_gen_qemu_ld8s(REG(0), addr, ctx->memidx);
|
1278 | c55497ec | aurel32 | tcg_temp_free(addr); |
1279 | c55497ec | aurel32 | } |
1280 | fdf9b3e8 | bellard | return;
|
1281 | fdf9b3e8 | bellard | case 0xc500: /* mov.w @(disp,GBR),R0 */ |
1282 | c55497ec | aurel32 | { |
1283 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1284 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, cpu_gbr, B7_0 * 2);
|
1285 | c55497ec | aurel32 | tcg_gen_qemu_ld16s(REG(0), addr, ctx->memidx);
|
1286 | c55497ec | aurel32 | tcg_temp_free(addr); |
1287 | c55497ec | aurel32 | } |
1288 | fdf9b3e8 | bellard | return;
|
1289 | fdf9b3e8 | bellard | case 0xc600: /* mov.l @(disp,GBR),R0 */ |
1290 | c55497ec | aurel32 | { |
1291 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1292 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, cpu_gbr, B7_0 * 4);
|
1293 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(REG(0), addr, ctx->memidx);
|
1294 | c55497ec | aurel32 | tcg_temp_free(addr); |
1295 | c55497ec | aurel32 | } |
1296 | fdf9b3e8 | bellard | return;
|
1297 | fdf9b3e8 | bellard | case 0xc000: /* mov.b R0,@(disp,GBR) */ |
1298 | c55497ec | aurel32 | { |
1299 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1300 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, cpu_gbr, B7_0); |
1301 | c55497ec | aurel32 | tcg_gen_qemu_st8(REG(0), addr, ctx->memidx);
|
1302 | c55497ec | aurel32 | tcg_temp_free(addr); |
1303 | c55497ec | aurel32 | } |
1304 | fdf9b3e8 | bellard | return;
|
1305 | fdf9b3e8 | bellard | case 0xc100: /* mov.w R0,@(disp,GBR) */ |
1306 | c55497ec | aurel32 | { |
1307 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1308 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, cpu_gbr, B7_0 * 2);
|
1309 | c55497ec | aurel32 | tcg_gen_qemu_st16(REG(0), addr, ctx->memidx);
|
1310 | c55497ec | aurel32 | tcg_temp_free(addr); |
1311 | c55497ec | aurel32 | } |
1312 | fdf9b3e8 | bellard | return;
|
1313 | fdf9b3e8 | bellard | case 0xc200: /* mov.l R0,@(disp,GBR) */ |
1314 | c55497ec | aurel32 | { |
1315 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1316 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, cpu_gbr, B7_0 * 4);
|
1317 | c55497ec | aurel32 | tcg_gen_qemu_st32(REG(0), addr, ctx->memidx);
|
1318 | c55497ec | aurel32 | tcg_temp_free(addr); |
1319 | c55497ec | aurel32 | } |
1320 | fdf9b3e8 | bellard | return;
|
1321 | fdf9b3e8 | bellard | case 0x8000: /* mov.b R0,@(disp,Rn) */ |
1322 | c55497ec | aurel32 | { |
1323 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1324 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, REG(B7_4), B3_0); |
1325 | c55497ec | aurel32 | tcg_gen_qemu_st8(REG(0), addr, ctx->memidx);
|
1326 | c55497ec | aurel32 | tcg_temp_free(addr); |
1327 | c55497ec | aurel32 | } |
1328 | fdf9b3e8 | bellard | return;
|
1329 | fdf9b3e8 | bellard | case 0x8100: /* mov.w R0,@(disp,Rn) */ |
1330 | c55497ec | aurel32 | { |
1331 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1332 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, REG(B7_4), B3_0 * 2);
|
1333 | c55497ec | aurel32 | tcg_gen_qemu_st16(REG(0), addr, ctx->memidx);
|
1334 | c55497ec | aurel32 | tcg_temp_free(addr); |
1335 | c55497ec | aurel32 | } |
1336 | fdf9b3e8 | bellard | return;
|
1337 | fdf9b3e8 | bellard | case 0x8400: /* mov.b @(disp,Rn),R0 */ |
1338 | c55497ec | aurel32 | { |
1339 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1340 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, REG(B7_4), B3_0); |
1341 | c55497ec | aurel32 | tcg_gen_qemu_ld8s(REG(0), addr, ctx->memidx);
|
1342 | c55497ec | aurel32 | tcg_temp_free(addr); |
1343 | c55497ec | aurel32 | } |
1344 | fdf9b3e8 | bellard | return;
|
1345 | fdf9b3e8 | bellard | case 0x8500: /* mov.w @(disp,Rn),R0 */ |
1346 | c55497ec | aurel32 | { |
1347 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1348 | c55497ec | aurel32 | tcg_gen_addi_i32(addr, REG(B7_4), B3_0 * 2);
|
1349 | c55497ec | aurel32 | tcg_gen_qemu_ld16s(REG(0), addr, ctx->memidx);
|
1350 | c55497ec | aurel32 | tcg_temp_free(addr); |
1351 | c55497ec | aurel32 | } |
1352 | fdf9b3e8 | bellard | return;
|
1353 | fdf9b3e8 | bellard | case 0xc700: /* mova @(disp,PC),R0 */ |
1354 | 7efbe241 | aurel32 | tcg_gen_movi_i32(REG(0), ((ctx->pc & 0xfffffffc) + 4 + B7_0 * 4) & ~3); |
1355 | fdf9b3e8 | bellard | return;
|
1356 | fdf9b3e8 | bellard | case 0xcb00: /* or #imm,R0 */ |
1357 | 7efbe241 | aurel32 | tcg_gen_ori_i32(REG(0), REG(0), B7_0); |
1358 | fdf9b3e8 | bellard | return;
|
1359 | 24988dc2 | aurel32 | case 0xcf00: /* or.b #imm,@(R0,GBR) */ |
1360 | c55497ec | aurel32 | { |
1361 | c55497ec | aurel32 | TCGv addr, val; |
1362 | a7812ae4 | pbrook | addr = tcg_temp_new(); |
1363 | c55497ec | aurel32 | tcg_gen_add_i32(addr, REG(0), cpu_gbr);
|
1364 | a7812ae4 | pbrook | val = tcg_temp_new(); |
1365 | c55497ec | aurel32 | tcg_gen_qemu_ld8u(val, addr, ctx->memidx); |
1366 | c55497ec | aurel32 | tcg_gen_ori_i32(val, val, B7_0); |
1367 | c55497ec | aurel32 | tcg_gen_qemu_st8(val, addr, ctx->memidx); |
1368 | c55497ec | aurel32 | tcg_temp_free(val); |
1369 | c55497ec | aurel32 | tcg_temp_free(addr); |
1370 | c55497ec | aurel32 | } |
1371 | fdf9b3e8 | bellard | return;
|
1372 | fdf9b3e8 | bellard | case 0xc300: /* trapa #imm */ |
1373 | c55497ec | aurel32 | { |
1374 | c55497ec | aurel32 | TCGv imm; |
1375 | c55497ec | aurel32 | CHECK_NOT_DELAY_SLOT |
1376 | c55497ec | aurel32 | tcg_gen_movi_i32(cpu_pc, ctx->pc); |
1377 | c55497ec | aurel32 | imm = tcg_const_i32(B7_0); |
1378 | a7812ae4 | pbrook | gen_helper_trapa(imm); |
1379 | c55497ec | aurel32 | tcg_temp_free(imm); |
1380 | c55497ec | aurel32 | ctx->bstate = BS_BRANCH; |
1381 | c55497ec | aurel32 | } |
1382 | fdf9b3e8 | bellard | return;
|
1383 | fdf9b3e8 | bellard | case 0xc800: /* tst #imm,R0 */ |
1384 | c55497ec | aurel32 | { |
1385 | a7812ae4 | pbrook | TCGv val = tcg_temp_new(); |
1386 | c55497ec | aurel32 | tcg_gen_andi_i32(val, REG(0), B7_0);
|
1387 | c55497ec | aurel32 | gen_cmp_imm(TCG_COND_EQ, val, 0);
|
1388 | c55497ec | aurel32 | tcg_temp_free(val); |
1389 | c55497ec | aurel32 | } |
1390 | fdf9b3e8 | bellard | return;
|
1391 | 24988dc2 | aurel32 | case 0xcc00: /* tst.b #imm,@(R0,GBR) */ |
1392 | c55497ec | aurel32 | { |
1393 | a7812ae4 | pbrook | TCGv val = tcg_temp_new(); |
1394 | c55497ec | aurel32 | tcg_gen_add_i32(val, REG(0), cpu_gbr);
|
1395 | c55497ec | aurel32 | tcg_gen_qemu_ld8u(val, val, ctx->memidx); |
1396 | c55497ec | aurel32 | tcg_gen_andi_i32(val, val, B7_0); |
1397 | c55497ec | aurel32 | gen_cmp_imm(TCG_COND_EQ, val, 0);
|
1398 | c55497ec | aurel32 | tcg_temp_free(val); |
1399 | c55497ec | aurel32 | } |
1400 | fdf9b3e8 | bellard | return;
|
1401 | fdf9b3e8 | bellard | case 0xca00: /* xor #imm,R0 */ |
1402 | 7efbe241 | aurel32 | tcg_gen_xori_i32(REG(0), REG(0), B7_0); |
1403 | fdf9b3e8 | bellard | return;
|
1404 | 24988dc2 | aurel32 | case 0xce00: /* xor.b #imm,@(R0,GBR) */ |
1405 | c55497ec | aurel32 | { |
1406 | c55497ec | aurel32 | TCGv addr, val; |
1407 | a7812ae4 | pbrook | addr = tcg_temp_new(); |
1408 | c55497ec | aurel32 | tcg_gen_add_i32(addr, REG(0), cpu_gbr);
|
1409 | a7812ae4 | pbrook | val = tcg_temp_new(); |
1410 | c55497ec | aurel32 | tcg_gen_qemu_ld8u(val, addr, ctx->memidx); |
1411 | c55497ec | aurel32 | tcg_gen_xori_i32(val, val, B7_0); |
1412 | c55497ec | aurel32 | tcg_gen_qemu_st8(val, addr, ctx->memidx); |
1413 | c55497ec | aurel32 | tcg_temp_free(val); |
1414 | c55497ec | aurel32 | tcg_temp_free(addr); |
1415 | c55497ec | aurel32 | } |
1416 | fdf9b3e8 | bellard | return;
|
1417 | fdf9b3e8 | bellard | } |
1418 | fdf9b3e8 | bellard | |
1419 | fdf9b3e8 | bellard | switch (ctx->opcode & 0xf08f) { |
1420 | fdf9b3e8 | bellard | case 0x408e: /* ldc Rm,Rn_BANK */ |
1421 | fe25591e | aurel32 | CHECK_PRIVILEGED |
1422 | 7efbe241 | aurel32 | tcg_gen_mov_i32(ALTREG(B6_4), REG(B11_8)); |
1423 | fdf9b3e8 | bellard | return;
|
1424 | fdf9b3e8 | bellard | case 0x4087: /* ldc.l @Rm+,Rn_BANK */ |
1425 | fe25591e | aurel32 | CHECK_PRIVILEGED |
1426 | 7efbe241 | aurel32 | tcg_gen_qemu_ld32s(ALTREG(B6_4), REG(B11_8), ctx->memidx); |
1427 | 7efbe241 | aurel32 | tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
1428 | fdf9b3e8 | bellard | return;
|
1429 | fdf9b3e8 | bellard | case 0x0082: /* stc Rm_BANK,Rn */ |
1430 | fe25591e | aurel32 | CHECK_PRIVILEGED |
1431 | 7efbe241 | aurel32 | tcg_gen_mov_i32(REG(B11_8), ALTREG(B6_4)); |
1432 | fdf9b3e8 | bellard | return;
|
1433 | fdf9b3e8 | bellard | case 0x4083: /* stc.l Rm_BANK,@-Rn */ |
1434 | fe25591e | aurel32 | CHECK_PRIVILEGED |
1435 | c55497ec | aurel32 | { |
1436 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1437 | c55497ec | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
1438 | c55497ec | aurel32 | tcg_gen_qemu_st32(ALTREG(B6_4), addr, ctx->memidx); |
1439 | c55497ec | aurel32 | tcg_temp_free(addr); |
1440 | c55497ec | aurel32 | tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 4);
|
1441 | c55497ec | aurel32 | } |
1442 | fdf9b3e8 | bellard | return;
|
1443 | fdf9b3e8 | bellard | } |
1444 | fdf9b3e8 | bellard | |
1445 | fdf9b3e8 | bellard | switch (ctx->opcode & 0xf0ff) { |
1446 | fdf9b3e8 | bellard | case 0x0023: /* braf Rn */ |
1447 | 7efbe241 | aurel32 | CHECK_NOT_DELAY_SLOT |
1448 | 7efbe241 | aurel32 | tcg_gen_addi_i32(cpu_delayed_pc, REG(B11_8), ctx->pc + 4);
|
1449 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT; |
1450 | fdf9b3e8 | bellard | ctx->delayed_pc = (uint32_t) - 1;
|
1451 | fdf9b3e8 | bellard | return;
|
1452 | fdf9b3e8 | bellard | case 0x0003: /* bsrf Rn */ |
1453 | 7efbe241 | aurel32 | CHECK_NOT_DELAY_SLOT |
1454 | 1000822b | aurel32 | tcg_gen_movi_i32(cpu_pr, ctx->pc + 4);
|
1455 | 7efbe241 | aurel32 | tcg_gen_add_i32(cpu_delayed_pc, REG(B11_8), cpu_pr); |
1456 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT; |
1457 | fdf9b3e8 | bellard | ctx->delayed_pc = (uint32_t) - 1;
|
1458 | fdf9b3e8 | bellard | return;
|
1459 | fdf9b3e8 | bellard | case 0x4015: /* cmp/pl Rn */ |
1460 | 7efbe241 | aurel32 | gen_cmp_imm(TCG_COND_GT, REG(B11_8), 0);
|
1461 | fdf9b3e8 | bellard | return;
|
1462 | fdf9b3e8 | bellard | case 0x4011: /* cmp/pz Rn */ |
1463 | 7efbe241 | aurel32 | gen_cmp_imm(TCG_COND_GE, REG(B11_8), 0);
|
1464 | fdf9b3e8 | bellard | return;
|
1465 | fdf9b3e8 | bellard | case 0x4010: /* dt Rn */ |
1466 | 7efbe241 | aurel32 | tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 1);
|
1467 | 7efbe241 | aurel32 | gen_cmp_imm(TCG_COND_EQ, REG(B11_8), 0);
|
1468 | fdf9b3e8 | bellard | return;
|
1469 | fdf9b3e8 | bellard | case 0x402b: /* jmp @Rn */ |
1470 | 7efbe241 | aurel32 | CHECK_NOT_DELAY_SLOT |
1471 | 7efbe241 | aurel32 | tcg_gen_mov_i32(cpu_delayed_pc, REG(B11_8)); |
1472 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT; |
1473 | fdf9b3e8 | bellard | ctx->delayed_pc = (uint32_t) - 1;
|
1474 | fdf9b3e8 | bellard | return;
|
1475 | fdf9b3e8 | bellard | case 0x400b: /* jsr @Rn */ |
1476 | 7efbe241 | aurel32 | CHECK_NOT_DELAY_SLOT |
1477 | 1000822b | aurel32 | tcg_gen_movi_i32(cpu_pr, ctx->pc + 4);
|
1478 | 7efbe241 | aurel32 | tcg_gen_mov_i32(cpu_delayed_pc, REG(B11_8)); |
1479 | fdf9b3e8 | bellard | ctx->flags |= DELAY_SLOT; |
1480 | fdf9b3e8 | bellard | ctx->delayed_pc = (uint32_t) - 1;
|
1481 | fdf9b3e8 | bellard | return;
|
1482 | fe25591e | aurel32 | case 0x400e: /* ldc Rm,SR */ |
1483 | fe25591e | aurel32 | CHECK_PRIVILEGED |
1484 | 7efbe241 | aurel32 | tcg_gen_andi_i32(cpu_sr, REG(B11_8), 0x700083f3);
|
1485 | 390af821 | aurel32 | ctx->bstate = BS_STOP; |
1486 | 390af821 | aurel32 | return;
|
1487 | fe25591e | aurel32 | case 0x4007: /* ldc.l @Rm+,SR */ |
1488 | fe25591e | aurel32 | CHECK_PRIVILEGED |
1489 | c55497ec | aurel32 | { |
1490 | a7812ae4 | pbrook | TCGv val = tcg_temp_new(); |
1491 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(val, REG(B11_8), ctx->memidx); |
1492 | c55497ec | aurel32 | tcg_gen_andi_i32(cpu_sr, val, 0x700083f3);
|
1493 | c55497ec | aurel32 | tcg_temp_free(val); |
1494 | c55497ec | aurel32 | tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
1495 | c55497ec | aurel32 | ctx->bstate = BS_STOP; |
1496 | c55497ec | aurel32 | } |
1497 | 390af821 | aurel32 | return;
|
1498 | fe25591e | aurel32 | case 0x0002: /* stc SR,Rn */ |
1499 | fe25591e | aurel32 | CHECK_PRIVILEGED |
1500 | 7efbe241 | aurel32 | tcg_gen_mov_i32(REG(B11_8), cpu_sr); |
1501 | 390af821 | aurel32 | return;
|
1502 | fe25591e | aurel32 | case 0x4003: /* stc SR,@-Rn */ |
1503 | fe25591e | aurel32 | CHECK_PRIVILEGED |
1504 | c55497ec | aurel32 | { |
1505 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1506 | c55497ec | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
1507 | c55497ec | aurel32 | tcg_gen_qemu_st32(cpu_sr, addr, ctx->memidx); |
1508 | c55497ec | aurel32 | tcg_temp_free(addr); |
1509 | c55497ec | aurel32 | tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 4);
|
1510 | c55497ec | aurel32 | } |
1511 | 390af821 | aurel32 | return;
|
1512 | fe25591e | aurel32 | #define LDST(reg,ldnum,ldpnum,stnum,stpnum,prechk) \
|
1513 | fdf9b3e8 | bellard | case ldnum: \
|
1514 | fe25591e | aurel32 | prechk \ |
1515 | 7efbe241 | aurel32 | tcg_gen_mov_i32 (cpu_##reg, REG(B11_8)); \ |
1516 | fdf9b3e8 | bellard | return; \
|
1517 | fdf9b3e8 | bellard | case ldpnum: \
|
1518 | fe25591e | aurel32 | prechk \ |
1519 | 7efbe241 | aurel32 | tcg_gen_qemu_ld32s (cpu_##reg, REG(B11_8), ctx->memidx); \ |
1520 | 7efbe241 | aurel32 | tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4); \
|
1521 | fdf9b3e8 | bellard | return; \
|
1522 | fdf9b3e8 | bellard | case stnum: \
|
1523 | fe25591e | aurel32 | prechk \ |
1524 | 7efbe241 | aurel32 | tcg_gen_mov_i32 (REG(B11_8), cpu_##reg); \ |
1525 | fdf9b3e8 | bellard | return; \
|
1526 | fdf9b3e8 | bellard | case stpnum: \
|
1527 | fe25591e | aurel32 | prechk \ |
1528 | c55497ec | aurel32 | { \ |
1529 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); \ |
1530 | c55497ec | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 4); \
|
1531 | c55497ec | aurel32 | tcg_gen_qemu_st32 (cpu_##reg, addr, ctx->memidx); \ |
1532 | c55497ec | aurel32 | tcg_temp_free(addr); \ |
1533 | c55497ec | aurel32 | tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 4); \
|
1534 | 86e0abc7 | aurel32 | } \ |
1535 | fdf9b3e8 | bellard | return;
|
1536 | fe25591e | aurel32 | LDST(gbr, 0x401e, 0x4017, 0x0012, 0x4013, {}) |
1537 | fe25591e | aurel32 | LDST(vbr, 0x402e, 0x4027, 0x0022, 0x4023, CHECK_PRIVILEGED) |
1538 | fe25591e | aurel32 | LDST(ssr, 0x403e, 0x4037, 0x0032, 0x4033, CHECK_PRIVILEGED) |
1539 | fe25591e | aurel32 | LDST(spc, 0x404e, 0x4047, 0x0042, 0x4043, CHECK_PRIVILEGED) |
1540 | fe25591e | aurel32 | LDST(dbr, 0x40fa, 0x40f6, 0x00fa, 0x40f2, CHECK_PRIVILEGED) |
1541 | fe25591e | aurel32 | LDST(mach, 0x400a, 0x4006, 0x000a, 0x4002, {}) |
1542 | fe25591e | aurel32 | LDST(macl, 0x401a, 0x4016, 0x001a, 0x4012, {}) |
1543 | fe25591e | aurel32 | LDST(pr, 0x402a, 0x4026, 0x002a, 0x4022, {}) |
1544 | d8299bcc | aurel32 | LDST(fpul, 0x405a, 0x4056, 0x005a, 0x4052, {CHECK_FPU_ENABLED}) |
1545 | 390af821 | aurel32 | case 0x406a: /* lds Rm,FPSCR */ |
1546 | d8299bcc | aurel32 | CHECK_FPU_ENABLED |
1547 | a7812ae4 | pbrook | gen_helper_ld_fpscr(REG(B11_8)); |
1548 | 390af821 | aurel32 | ctx->bstate = BS_STOP; |
1549 | 390af821 | aurel32 | return;
|
1550 | 390af821 | aurel32 | case 0x4066: /* lds.l @Rm+,FPSCR */ |
1551 | d8299bcc | aurel32 | CHECK_FPU_ENABLED |
1552 | c55497ec | aurel32 | { |
1553 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1554 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(addr, REG(B11_8), ctx->memidx); |
1555 | c55497ec | aurel32 | tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
1556 | a7812ae4 | pbrook | gen_helper_ld_fpscr(addr); |
1557 | c55497ec | aurel32 | tcg_temp_free(addr); |
1558 | c55497ec | aurel32 | ctx->bstate = BS_STOP; |
1559 | c55497ec | aurel32 | } |
1560 | 390af821 | aurel32 | return;
|
1561 | 390af821 | aurel32 | case 0x006a: /* sts FPSCR,Rn */ |
1562 | d8299bcc | aurel32 | CHECK_FPU_ENABLED |
1563 | c55497ec | aurel32 | tcg_gen_andi_i32(REG(B11_8), cpu_fpscr, 0x003fffff);
|
1564 | 390af821 | aurel32 | return;
|
1565 | 390af821 | aurel32 | case 0x4062: /* sts FPSCR,@-Rn */ |
1566 | d8299bcc | aurel32 | CHECK_FPU_ENABLED |
1567 | c55497ec | aurel32 | { |
1568 | c55497ec | aurel32 | TCGv addr, val; |
1569 | a7812ae4 | pbrook | val = tcg_temp_new(); |
1570 | c55497ec | aurel32 | tcg_gen_andi_i32(val, cpu_fpscr, 0x003fffff);
|
1571 | a7812ae4 | pbrook | addr = tcg_temp_new(); |
1572 | c55497ec | aurel32 | tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
1573 | c55497ec | aurel32 | tcg_gen_qemu_st32(val, addr, ctx->memidx); |
1574 | c55497ec | aurel32 | tcg_temp_free(addr); |
1575 | c55497ec | aurel32 | tcg_temp_free(val); |
1576 | c55497ec | aurel32 | tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 4);
|
1577 | c55497ec | aurel32 | } |
1578 | 390af821 | aurel32 | return;
|
1579 | fdf9b3e8 | bellard | case 0x00c3: /* movca.l R0,@Rm */ |
1580 | 852d481f | edgar_igl | { |
1581 | 852d481f | edgar_igl | TCGv val = tcg_temp_new(); |
1582 | 852d481f | edgar_igl | tcg_gen_qemu_ld32u(val, REG(B11_8), ctx->memidx); |
1583 | 852d481f | edgar_igl | gen_helper_movcal (REG(B11_8), val); |
1584 | 852d481f | edgar_igl | tcg_gen_qemu_st32(REG(0), REG(B11_8), ctx->memidx);
|
1585 | 852d481f | edgar_igl | } |
1586 | 852d481f | edgar_igl | ctx->has_movcal = 1;
|
1587 | fdf9b3e8 | bellard | return;
|
1588 | 7526aa2d | aurel32 | case 0x40a9: |
1589 | 7526aa2d | aurel32 | /* MOVUA.L @Rm,R0 (Rm) -> R0
|
1590 | 7526aa2d | aurel32 | Load non-boundary-aligned data */
|
1591 | 7526aa2d | aurel32 | tcg_gen_qemu_ld32u(REG(0), REG(B11_8), ctx->memidx);
|
1592 | 7526aa2d | aurel32 | return;
|
1593 | 7526aa2d | aurel32 | case 0x40e9: |
1594 | 7526aa2d | aurel32 | /* MOVUA.L @Rm+,R0 (Rm) -> R0, Rm + 4 -> Rm
|
1595 | 7526aa2d | aurel32 | Load non-boundary-aligned data */
|
1596 | 7526aa2d | aurel32 | tcg_gen_qemu_ld32u(REG(0), REG(B11_8), ctx->memidx);
|
1597 | 7526aa2d | aurel32 | tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
1598 | 7526aa2d | aurel32 | return;
|
1599 | fdf9b3e8 | bellard | case 0x0029: /* movt Rn */ |
1600 | 7efbe241 | aurel32 | tcg_gen_andi_i32(REG(B11_8), cpu_sr, SR_T); |
1601 | fdf9b3e8 | bellard | return;
|
1602 | 66c7c806 | aurel32 | case 0x0073: |
1603 | 66c7c806 | aurel32 | /* MOVCO.L
|
1604 | 66c7c806 | aurel32 | LDST -> T
|
1605 | 66c7c806 | aurel32 | If (T == 1) R0 -> (Rn)
|
1606 | 66c7c806 | aurel32 | 0 -> LDST
|
1607 | 66c7c806 | aurel32 | */
|
1608 | 66c7c806 | aurel32 | if (ctx->features & SH_FEATURE_SH4A) {
|
1609 | 66c7c806 | aurel32 | int label = gen_new_label();
|
1610 | 66c7c806 | aurel32 | gen_clr_t(); |
1611 | 66c7c806 | aurel32 | tcg_gen_or_i32(cpu_sr, cpu_sr, cpu_ldst); |
1612 | 66c7c806 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_ldst, 0, label);
|
1613 | 66c7c806 | aurel32 | tcg_gen_qemu_st32(REG(0), REG(B11_8), ctx->memidx);
|
1614 | 66c7c806 | aurel32 | gen_set_label(label); |
1615 | 66c7c806 | aurel32 | tcg_gen_movi_i32(cpu_ldst, 0);
|
1616 | 66c7c806 | aurel32 | return;
|
1617 | 66c7c806 | aurel32 | } else
|
1618 | 66c7c806 | aurel32 | break;
|
1619 | 66c7c806 | aurel32 | case 0x0063: |
1620 | 66c7c806 | aurel32 | /* MOVLI.L @Rm,R0
|
1621 | 66c7c806 | aurel32 | 1 -> LDST
|
1622 | 66c7c806 | aurel32 | (Rm) -> R0
|
1623 | 66c7c806 | aurel32 | When interrupt/exception
|
1624 | 66c7c806 | aurel32 | occurred 0 -> LDST
|
1625 | 66c7c806 | aurel32 | */
|
1626 | 66c7c806 | aurel32 | if (ctx->features & SH_FEATURE_SH4A) {
|
1627 | 66c7c806 | aurel32 | tcg_gen_movi_i32(cpu_ldst, 0);
|
1628 | 66c7c806 | aurel32 | tcg_gen_qemu_ld32s(REG(0), REG(B11_8), ctx->memidx);
|
1629 | 66c7c806 | aurel32 | tcg_gen_movi_i32(cpu_ldst, 1);
|
1630 | 66c7c806 | aurel32 | return;
|
1631 | 66c7c806 | aurel32 | } else
|
1632 | 66c7c806 | aurel32 | break;
|
1633 | fdf9b3e8 | bellard | case 0x0093: /* ocbi @Rn */ |
1634 | c55497ec | aurel32 | { |
1635 | 852d481f | edgar_igl | gen_helper_ocbi (REG(B11_8)); |
1636 | c55497ec | aurel32 | } |
1637 | fdf9b3e8 | bellard | return;
|
1638 | 24988dc2 | aurel32 | case 0x00a3: /* ocbp @Rn */ |
1639 | c55497ec | aurel32 | { |
1640 | a7812ae4 | pbrook | TCGv dummy = tcg_temp_new(); |
1641 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(dummy, REG(B11_8), ctx->memidx); |
1642 | c55497ec | aurel32 | tcg_temp_free(dummy); |
1643 | c55497ec | aurel32 | } |
1644 | fdf9b3e8 | bellard | return;
|
1645 | fdf9b3e8 | bellard | case 0x00b3: /* ocbwb @Rn */ |
1646 | c55497ec | aurel32 | { |
1647 | a7812ae4 | pbrook | TCGv dummy = tcg_temp_new(); |
1648 | c55497ec | aurel32 | tcg_gen_qemu_ld32s(dummy, REG(B11_8), ctx->memidx); |
1649 | c55497ec | aurel32 | tcg_temp_free(dummy); |
1650 | c55497ec | aurel32 | } |
1651 | fdf9b3e8 | bellard | return;
|
1652 | fdf9b3e8 | bellard | case 0x0083: /* pref @Rn */ |
1653 | fdf9b3e8 | bellard | return;
|
1654 | 71968fa6 | aurel32 | case 0x00d3: /* prefi @Rn */ |
1655 | 71968fa6 | aurel32 | if (ctx->features & SH_FEATURE_SH4A)
|
1656 | 71968fa6 | aurel32 | return;
|
1657 | 71968fa6 | aurel32 | else
|
1658 | 71968fa6 | aurel32 | break;
|
1659 | 71968fa6 | aurel32 | case 0x00e3: /* icbi @Rn */ |
1660 | 71968fa6 | aurel32 | if (ctx->features & SH_FEATURE_SH4A)
|
1661 | 71968fa6 | aurel32 | return;
|
1662 | 71968fa6 | aurel32 | else
|
1663 | 71968fa6 | aurel32 | break;
|
1664 | 71968fa6 | aurel32 | case 0x00ab: /* synco */ |
1665 | 71968fa6 | aurel32 | if (ctx->features & SH_FEATURE_SH4A)
|
1666 | 71968fa6 | aurel32 | return;
|
1667 | 71968fa6 | aurel32 | else
|
1668 | 71968fa6 | aurel32 | break;
|
1669 | fdf9b3e8 | bellard | case 0x4024: /* rotcl Rn */ |
1670 | c55497ec | aurel32 | { |
1671 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
1672 | c55497ec | aurel32 | tcg_gen_mov_i32(tmp, cpu_sr); |
1673 | c55497ec | aurel32 | gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 31); |
1674 | c55497ec | aurel32 | tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 1);
|
1675 | c55497ec | aurel32 | gen_copy_bit_i32(REG(B11_8), 0, tmp, 0); |
1676 | c55497ec | aurel32 | tcg_temp_free(tmp); |
1677 | c55497ec | aurel32 | } |
1678 | fdf9b3e8 | bellard | return;
|
1679 | fdf9b3e8 | bellard | case 0x4025: /* rotcr Rn */ |
1680 | c55497ec | aurel32 | { |
1681 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
1682 | c55497ec | aurel32 | tcg_gen_mov_i32(tmp, cpu_sr); |
1683 | c55497ec | aurel32 | gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 0); |
1684 | c55497ec | aurel32 | tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 1);
|
1685 | c55497ec | aurel32 | gen_copy_bit_i32(REG(B11_8), 31, tmp, 0); |
1686 | c55497ec | aurel32 | tcg_temp_free(tmp); |
1687 | c55497ec | aurel32 | } |
1688 | fdf9b3e8 | bellard | return;
|
1689 | fdf9b3e8 | bellard | case 0x4004: /* rotl Rn */ |
1690 | 7efbe241 | aurel32 | gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 31); |
1691 | 7efbe241 | aurel32 | tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 1);
|
1692 | 7efbe241 | aurel32 | gen_copy_bit_i32(REG(B11_8), 0, cpu_sr, 0); |
1693 | fdf9b3e8 | bellard | return;
|
1694 | fdf9b3e8 | bellard | case 0x4005: /* rotr Rn */ |
1695 | 7efbe241 | aurel32 | gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 0); |
1696 | 7efbe241 | aurel32 | tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 1);
|
1697 | 7efbe241 | aurel32 | gen_copy_bit_i32(REG(B11_8), 31, cpu_sr, 0); |
1698 | fdf9b3e8 | bellard | return;
|
1699 | fdf9b3e8 | bellard | case 0x4000: /* shll Rn */ |
1700 | fdf9b3e8 | bellard | case 0x4020: /* shal Rn */ |
1701 | 7efbe241 | aurel32 | gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 31); |
1702 | 7efbe241 | aurel32 | tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 1);
|
1703 | fdf9b3e8 | bellard | return;
|
1704 | fdf9b3e8 | bellard | case 0x4021: /* shar Rn */ |
1705 | 7efbe241 | aurel32 | gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 0); |
1706 | 7efbe241 | aurel32 | tcg_gen_sari_i32(REG(B11_8), REG(B11_8), 1);
|
1707 | fdf9b3e8 | bellard | return;
|
1708 | fdf9b3e8 | bellard | case 0x4001: /* shlr Rn */ |
1709 | 7efbe241 | aurel32 | gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 0); |
1710 | 7efbe241 | aurel32 | tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 1);
|
1711 | fdf9b3e8 | bellard | return;
|
1712 | fdf9b3e8 | bellard | case 0x4008: /* shll2 Rn */ |
1713 | 7efbe241 | aurel32 | tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 2);
|
1714 | fdf9b3e8 | bellard | return;
|
1715 | fdf9b3e8 | bellard | case 0x4018: /* shll8 Rn */ |
1716 | 7efbe241 | aurel32 | tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 8);
|
1717 | fdf9b3e8 | bellard | return;
|
1718 | fdf9b3e8 | bellard | case 0x4028: /* shll16 Rn */ |
1719 | 7efbe241 | aurel32 | tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 16);
|
1720 | fdf9b3e8 | bellard | return;
|
1721 | fdf9b3e8 | bellard | case 0x4009: /* shlr2 Rn */ |
1722 | 7efbe241 | aurel32 | tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 2);
|
1723 | fdf9b3e8 | bellard | return;
|
1724 | fdf9b3e8 | bellard | case 0x4019: /* shlr8 Rn */ |
1725 | 7efbe241 | aurel32 | tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 8);
|
1726 | fdf9b3e8 | bellard | return;
|
1727 | fdf9b3e8 | bellard | case 0x4029: /* shlr16 Rn */ |
1728 | 7efbe241 | aurel32 | tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 16);
|
1729 | fdf9b3e8 | bellard | return;
|
1730 | fdf9b3e8 | bellard | case 0x401b: /* tas.b @Rn */ |
1731 | c55497ec | aurel32 | { |
1732 | c55497ec | aurel32 | TCGv addr, val; |
1733 | df9247b2 | aurel32 | addr = tcg_temp_local_new(); |
1734 | c55497ec | aurel32 | tcg_gen_mov_i32(addr, REG(B11_8)); |
1735 | df9247b2 | aurel32 | val = tcg_temp_local_new(); |
1736 | c55497ec | aurel32 | tcg_gen_qemu_ld8u(val, addr, ctx->memidx); |
1737 | c55497ec | aurel32 | gen_cmp_imm(TCG_COND_EQ, val, 0);
|
1738 | c55497ec | aurel32 | tcg_gen_ori_i32(val, val, 0x80);
|
1739 | c55497ec | aurel32 | tcg_gen_qemu_st8(val, addr, ctx->memidx); |
1740 | c55497ec | aurel32 | tcg_temp_free(val); |
1741 | c55497ec | aurel32 | tcg_temp_free(addr); |
1742 | c55497ec | aurel32 | } |
1743 | fdf9b3e8 | bellard | return;
|
1744 | e67888a7 | ths | case 0xf00d: /* fsts FPUL,FRn - FPSCR: Nothing */ |
1745 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1746 | f6198371 | aurel32 | tcg_gen_mov_i32(cpu_fregs[FREG(B11_8)], cpu_fpul); |
1747 | eda9b09b | bellard | return;
|
1748 | e67888a7 | ths | case 0xf01d: /* flds FRm,FPUL - FPSCR: Nothing */ |
1749 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1750 | f6198371 | aurel32 | tcg_gen_mov_i32(cpu_fpul, cpu_fregs[FREG(B11_8)]); |
1751 | eda9b09b | bellard | return;
|
1752 | e67888a7 | ths | case 0xf02d: /* float FPUL,FRn/DRn - FPSCR: R[PR,Enable.I]/W[Cause,Flag] */ |
1753 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1754 | ea6cf6be | ths | if (ctx->fpscr & FPSCR_PR) {
|
1755 | a7812ae4 | pbrook | TCGv_i64 fp; |
1756 | ea6cf6be | ths | if (ctx->opcode & 0x0100) |
1757 | ea6cf6be | ths | break; /* illegal instruction */ |
1758 | a7812ae4 | pbrook | fp = tcg_temp_new_i64(); |
1759 | a7812ae4 | pbrook | gen_helper_float_DT(fp, cpu_fpul); |
1760 | cc4ba6a9 | aurel32 | gen_store_fpr64(fp, DREG(B11_8)); |
1761 | a7812ae4 | pbrook | tcg_temp_free_i64(fp); |
1762 | ea6cf6be | ths | } |
1763 | ea6cf6be | ths | else {
|
1764 | 66ba317c | aurel32 | gen_helper_float_FT(cpu_fregs[FREG(B11_8)], cpu_fpul); |
1765 | ea6cf6be | ths | } |
1766 | ea6cf6be | ths | return;
|
1767 | e67888a7 | ths | case 0xf03d: /* ftrc FRm/DRm,FPUL - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */ |
1768 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1769 | ea6cf6be | ths | if (ctx->fpscr & FPSCR_PR) {
|
1770 | a7812ae4 | pbrook | TCGv_i64 fp; |
1771 | ea6cf6be | ths | if (ctx->opcode & 0x0100) |
1772 | ea6cf6be | ths | break; /* illegal instruction */ |
1773 | a7812ae4 | pbrook | fp = tcg_temp_new_i64(); |
1774 | cc4ba6a9 | aurel32 | gen_load_fpr64(fp, DREG(B11_8)); |
1775 | a7812ae4 | pbrook | gen_helper_ftrc_DT(cpu_fpul, fp); |
1776 | a7812ae4 | pbrook | tcg_temp_free_i64(fp); |
1777 | ea6cf6be | ths | } |
1778 | ea6cf6be | ths | else {
|
1779 | 66ba317c | aurel32 | gen_helper_ftrc_FT(cpu_fpul, cpu_fregs[FREG(B11_8)]); |
1780 | ea6cf6be | ths | } |
1781 | ea6cf6be | ths | return;
|
1782 | 24988dc2 | aurel32 | case 0xf04d: /* fneg FRn/DRn - FPSCR: Nothing */ |
1783 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1784 | 7fdf924f | aurel32 | { |
1785 | 66ba317c | aurel32 | gen_helper_fneg_T(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B11_8)]); |
1786 | 7fdf924f | aurel32 | } |
1787 | 24988dc2 | aurel32 | return;
|
1788 | 24988dc2 | aurel32 | case 0xf05d: /* fabs FRn/DRn */ |
1789 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1790 | 24988dc2 | aurel32 | if (ctx->fpscr & FPSCR_PR) {
|
1791 | 24988dc2 | aurel32 | if (ctx->opcode & 0x0100) |
1792 | 24988dc2 | aurel32 | break; /* illegal instruction */ |
1793 | a7812ae4 | pbrook | TCGv_i64 fp = tcg_temp_new_i64(); |
1794 | cc4ba6a9 | aurel32 | gen_load_fpr64(fp, DREG(B11_8)); |
1795 | a7812ae4 | pbrook | gen_helper_fabs_DT(fp, fp); |
1796 | cc4ba6a9 | aurel32 | gen_store_fpr64(fp, DREG(B11_8)); |
1797 | a7812ae4 | pbrook | tcg_temp_free_i64(fp); |
1798 | 24988dc2 | aurel32 | } else {
|
1799 | 66ba317c | aurel32 | gen_helper_fabs_FT(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B11_8)]); |
1800 | 24988dc2 | aurel32 | } |
1801 | 24988dc2 | aurel32 | return;
|
1802 | 24988dc2 | aurel32 | case 0xf06d: /* fsqrt FRn */ |
1803 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1804 | 24988dc2 | aurel32 | if (ctx->fpscr & FPSCR_PR) {
|
1805 | 24988dc2 | aurel32 | if (ctx->opcode & 0x0100) |
1806 | 24988dc2 | aurel32 | break; /* illegal instruction */ |
1807 | a7812ae4 | pbrook | TCGv_i64 fp = tcg_temp_new_i64(); |
1808 | cc4ba6a9 | aurel32 | gen_load_fpr64(fp, DREG(B11_8)); |
1809 | a7812ae4 | pbrook | gen_helper_fsqrt_DT(fp, fp); |
1810 | cc4ba6a9 | aurel32 | gen_store_fpr64(fp, DREG(B11_8)); |
1811 | a7812ae4 | pbrook | tcg_temp_free_i64(fp); |
1812 | 24988dc2 | aurel32 | } else {
|
1813 | 66ba317c | aurel32 | gen_helper_fsqrt_FT(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B11_8)]); |
1814 | 24988dc2 | aurel32 | } |
1815 | 24988dc2 | aurel32 | return;
|
1816 | 24988dc2 | aurel32 | case 0xf07d: /* fsrra FRn */ |
1817 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1818 | 24988dc2 | aurel32 | break;
|
1819 | e67888a7 | ths | case 0xf08d: /* fldi0 FRn - FPSCR: R[PR] */ |
1820 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1821 | ea6cf6be | ths | if (!(ctx->fpscr & FPSCR_PR)) {
|
1822 | 66ba317c | aurel32 | tcg_gen_movi_i32(cpu_fregs[FREG(B11_8)], 0);
|
1823 | ea6cf6be | ths | } |
1824 | 12d96138 | aurel32 | return;
|
1825 | e67888a7 | ths | case 0xf09d: /* fldi1 FRn - FPSCR: R[PR] */ |
1826 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1827 | ea6cf6be | ths | if (!(ctx->fpscr & FPSCR_PR)) {
|
1828 | 66ba317c | aurel32 | tcg_gen_movi_i32(cpu_fregs[FREG(B11_8)], 0x3f800000);
|
1829 | ea6cf6be | ths | } |
1830 | 12d96138 | aurel32 | return;
|
1831 | 24988dc2 | aurel32 | case 0xf0ad: /* fcnvsd FPUL,DRn */ |
1832 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1833 | cc4ba6a9 | aurel32 | { |
1834 | a7812ae4 | pbrook | TCGv_i64 fp = tcg_temp_new_i64(); |
1835 | a7812ae4 | pbrook | gen_helper_fcnvsd_FT_DT(fp, cpu_fpul); |
1836 | cc4ba6a9 | aurel32 | gen_store_fpr64(fp, DREG(B11_8)); |
1837 | a7812ae4 | pbrook | tcg_temp_free_i64(fp); |
1838 | cc4ba6a9 | aurel32 | } |
1839 | 24988dc2 | aurel32 | return;
|
1840 | 24988dc2 | aurel32 | case 0xf0bd: /* fcnvds DRn,FPUL */ |
1841 | f6198371 | aurel32 | CHECK_FPU_ENABLED |
1842 | cc4ba6a9 | aurel32 | { |
1843 | a7812ae4 | pbrook | TCGv_i64 fp = tcg_temp_new_i64(); |
1844 | cc4ba6a9 | aurel32 | gen_load_fpr64(fp, DREG(B11_8)); |
1845 | a7812ae4 | pbrook | gen_helper_fcnvds_DT_FT(cpu_fpul, fp); |
1846 | a7812ae4 | pbrook | tcg_temp_free_i64(fp); |
1847 | cc4ba6a9 | aurel32 | } |
1848 | 24988dc2 | aurel32 | return;
|
1849 | fdf9b3e8 | bellard | } |
1850 | bacc637a | aurel32 | #if 0
|
1851 | fdf9b3e8 | bellard | fprintf(stderr, "unknown instruction 0x%04x at pc 0x%08x\n",
|
1852 | fdf9b3e8 | bellard | ctx->opcode, ctx->pc);
|
1853 | bacc637a | aurel32 | fflush(stderr);
|
1854 | bacc637a | aurel32 | #endif
|
1855 | a7812ae4 | pbrook | gen_helper_raise_illegal_instruction(); |
1856 | 823029f9 | ths | ctx->bstate = BS_EXCP; |
1857 | 823029f9 | ths | } |
1858 | 823029f9 | ths | |
1859 | b1d8e52e | blueswir1 | static void decode_opc(DisasContext * ctx) |
1860 | 823029f9 | ths | { |
1861 | 823029f9 | ths | uint32_t old_flags = ctx->flags; |
1862 | 823029f9 | ths | |
1863 | 823029f9 | ths | _decode_opc(ctx); |
1864 | 823029f9 | ths | |
1865 | 823029f9 | ths | if (old_flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) {
|
1866 | 823029f9 | ths | if (ctx->flags & DELAY_SLOT_CLEARME) {
|
1867 | 1000822b | aurel32 | gen_store_flags(0);
|
1868 | 274a9e70 | aurel32 | } else {
|
1869 | 274a9e70 | aurel32 | /* go out of the delay slot */
|
1870 | 274a9e70 | aurel32 | uint32_t new_flags = ctx->flags; |
1871 | 274a9e70 | aurel32 | new_flags &= ~(DELAY_SLOT | DELAY_SLOT_CONDITIONAL); |
1872 | 1000822b | aurel32 | gen_store_flags(new_flags); |
1873 | 823029f9 | ths | } |
1874 | 823029f9 | ths | ctx->flags = 0;
|
1875 | 823029f9 | ths | ctx->bstate = BS_BRANCH; |
1876 | 823029f9 | ths | if (old_flags & DELAY_SLOT_CONDITIONAL) {
|
1877 | 823029f9 | ths | gen_delayed_conditional_jump(ctx); |
1878 | 823029f9 | ths | } else if (old_flags & DELAY_SLOT) { |
1879 | 823029f9 | ths | gen_jump(ctx); |
1880 | 823029f9 | ths | } |
1881 | 823029f9 | ths | |
1882 | 823029f9 | ths | } |
1883 | 274a9e70 | aurel32 | |
1884 | 274a9e70 | aurel32 | /* go into a delay slot */
|
1885 | 274a9e70 | aurel32 | if (ctx->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL))
|
1886 | 1000822b | aurel32 | gen_store_flags(ctx->flags); |
1887 | fdf9b3e8 | bellard | } |
1888 | fdf9b3e8 | bellard | |
1889 | 2cfc5f17 | ths | static inline void |
1890 | 820e00f2 | ths | gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb, |
1891 | 820e00f2 | ths | int search_pc)
|
1892 | fdf9b3e8 | bellard | { |
1893 | fdf9b3e8 | bellard | DisasContext ctx; |
1894 | fdf9b3e8 | bellard | target_ulong pc_start; |
1895 | fdf9b3e8 | bellard | static uint16_t *gen_opc_end;
|
1896 | a1d1bb31 | aliguori | CPUBreakpoint *bp; |
1897 | 355fb23d | pbrook | int i, ii;
|
1898 | 2e70f6ef | pbrook | int num_insns;
|
1899 | 2e70f6ef | pbrook | int max_insns;
|
1900 | fdf9b3e8 | bellard | |
1901 | fdf9b3e8 | bellard | pc_start = tb->pc; |
1902 | fdf9b3e8 | bellard | gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; |
1903 | fdf9b3e8 | bellard | ctx.pc = pc_start; |
1904 | 823029f9 | ths | ctx.flags = (uint32_t)tb->flags; |
1905 | 823029f9 | ths | ctx.bstate = BS_NONE; |
1906 | fdf9b3e8 | bellard | ctx.sr = env->sr; |
1907 | eda9b09b | bellard | ctx.fpscr = env->fpscr; |
1908 | fdf9b3e8 | bellard | ctx.memidx = (env->sr & SR_MD) ? 1 : 0; |
1909 | 9854bc46 | pbrook | /* We don't know if the delayed pc came from a dynamic or static branch,
|
1910 | 9854bc46 | pbrook | so assume it is a dynamic branch. */
|
1911 | 823029f9 | ths | ctx.delayed_pc = -1; /* use delayed pc from env pointer */ |
1912 | fdf9b3e8 | bellard | ctx.tb = tb; |
1913 | fdf9b3e8 | bellard | ctx.singlestep_enabled = env->singlestep_enabled; |
1914 | 71968fa6 | aurel32 | ctx.features = env->features; |
1915 | 852d481f | edgar_igl | ctx.has_movcal = (tb->flags & TB_FLAG_PENDING_MOVCA); |
1916 | fdf9b3e8 | bellard | |
1917 | fdf9b3e8 | bellard | #ifdef DEBUG_DISAS
|
1918 | 93fcfe39 | aliguori | qemu_log_mask(CPU_LOG_TB_CPU, |
1919 | 93fcfe39 | aliguori | "------------------------------------------------\n");
|
1920 | 93fcfe39 | aliguori | log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
|
1921 | fdf9b3e8 | bellard | #endif
|
1922 | fdf9b3e8 | bellard | |
1923 | 355fb23d | pbrook | ii = -1;
|
1924 | 2e70f6ef | pbrook | num_insns = 0;
|
1925 | 2e70f6ef | pbrook | max_insns = tb->cflags & CF_COUNT_MASK; |
1926 | 2e70f6ef | pbrook | if (max_insns == 0) |
1927 | 2e70f6ef | pbrook | max_insns = CF_COUNT_MASK; |
1928 | 2e70f6ef | pbrook | gen_icount_start(); |
1929 | 823029f9 | ths | while (ctx.bstate == BS_NONE && gen_opc_ptr < gen_opc_end) {
|
1930 | 72cf2d4f | Blue Swirl | if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) {
|
1931 | 72cf2d4f | Blue Swirl | QTAILQ_FOREACH(bp, &env->breakpoints, entry) { |
1932 | a1d1bb31 | aliguori | if (ctx.pc == bp->pc) {
|
1933 | fdf9b3e8 | bellard | /* We have hit a breakpoint - make sure PC is up-to-date */
|
1934 | 3a8a44c4 | aurel32 | tcg_gen_movi_i32(cpu_pc, ctx.pc); |
1935 | a7812ae4 | pbrook | gen_helper_debug(); |
1936 | 823029f9 | ths | ctx.bstate = BS_EXCP; |
1937 | fdf9b3e8 | bellard | break;
|
1938 | fdf9b3e8 | bellard | } |
1939 | fdf9b3e8 | bellard | } |
1940 | fdf9b3e8 | bellard | } |
1941 | 355fb23d | pbrook | if (search_pc) {
|
1942 | 355fb23d | pbrook | i = gen_opc_ptr - gen_opc_buf; |
1943 | 355fb23d | pbrook | if (ii < i) {
|
1944 | 355fb23d | pbrook | ii++; |
1945 | 355fb23d | pbrook | while (ii < i)
|
1946 | 355fb23d | pbrook | gen_opc_instr_start[ii++] = 0;
|
1947 | 355fb23d | pbrook | } |
1948 | 355fb23d | pbrook | gen_opc_pc[ii] = ctx.pc; |
1949 | 823029f9 | ths | gen_opc_hflags[ii] = ctx.flags; |
1950 | 355fb23d | pbrook | gen_opc_instr_start[ii] = 1;
|
1951 | 2e70f6ef | pbrook | gen_opc_icount[ii] = num_insns; |
1952 | 355fb23d | pbrook | } |
1953 | 2e70f6ef | pbrook | if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) |
1954 | 2e70f6ef | pbrook | gen_io_start(); |
1955 | fdf9b3e8 | bellard | #if 0
|
1956 | fdf9b3e8 | bellard | fprintf(stderr, "Loading opcode at address 0x%08x\n", ctx.pc);
|
1957 | fdf9b3e8 | bellard | fflush(stderr);
|
1958 | fdf9b3e8 | bellard | #endif
|
1959 | fdf9b3e8 | bellard | ctx.opcode = lduw_code(ctx.pc); |
1960 | fdf9b3e8 | bellard | decode_opc(&ctx); |
1961 | 2e70f6ef | pbrook | num_insns++; |
1962 | fdf9b3e8 | bellard | ctx.pc += 2;
|
1963 | fdf9b3e8 | bellard | if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) |
1964 | fdf9b3e8 | bellard | break;
|
1965 | fdf9b3e8 | bellard | if (env->singlestep_enabled)
|
1966 | fdf9b3e8 | bellard | break;
|
1967 | 2e70f6ef | pbrook | if (num_insns >= max_insns)
|
1968 | 2e70f6ef | pbrook | break;
|
1969 | 1b530a6d | aurel32 | if (singlestep)
|
1970 | 1b530a6d | aurel32 | break;
|
1971 | fdf9b3e8 | bellard | } |
1972 | 2e70f6ef | pbrook | if (tb->cflags & CF_LAST_IO)
|
1973 | 2e70f6ef | pbrook | gen_io_end(); |
1974 | fdf9b3e8 | bellard | if (env->singlestep_enabled) {
|
1975 | bdbf22e6 | aurel32 | tcg_gen_movi_i32(cpu_pc, ctx.pc); |
1976 | a7812ae4 | pbrook | gen_helper_debug(); |
1977 | 823029f9 | ths | } else {
|
1978 | 823029f9 | ths | switch (ctx.bstate) {
|
1979 | 823029f9 | ths | case BS_STOP:
|
1980 | 823029f9 | ths | /* gen_op_interrupt_restart(); */
|
1981 | 823029f9 | ths | /* fall through */
|
1982 | 823029f9 | ths | case BS_NONE:
|
1983 | 823029f9 | ths | if (ctx.flags) {
|
1984 | 1000822b | aurel32 | gen_store_flags(ctx.flags | DELAY_SLOT_CLEARME); |
1985 | 823029f9 | ths | } |
1986 | 823029f9 | ths | gen_goto_tb(&ctx, 0, ctx.pc);
|
1987 | 823029f9 | ths | break;
|
1988 | 823029f9 | ths | case BS_EXCP:
|
1989 | 823029f9 | ths | /* gen_op_interrupt_restart(); */
|
1990 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
1991 | 823029f9 | ths | break;
|
1992 | 823029f9 | ths | case BS_BRANCH:
|
1993 | 823029f9 | ths | default:
|
1994 | 823029f9 | ths | break;
|
1995 | 823029f9 | ths | } |
1996 | fdf9b3e8 | bellard | } |
1997 | 823029f9 | ths | |
1998 | 2e70f6ef | pbrook | gen_icount_end(tb, num_insns); |
1999 | fdf9b3e8 | bellard | *gen_opc_ptr = INDEX_op_end; |
2000 | 355fb23d | pbrook | if (search_pc) {
|
2001 | 355fb23d | pbrook | i = gen_opc_ptr - gen_opc_buf; |
2002 | 355fb23d | pbrook | ii++; |
2003 | 355fb23d | pbrook | while (ii <= i)
|
2004 | 355fb23d | pbrook | gen_opc_instr_start[ii++] = 0;
|
2005 | 355fb23d | pbrook | } else {
|
2006 | 355fb23d | pbrook | tb->size = ctx.pc - pc_start; |
2007 | 2e70f6ef | pbrook | tb->icount = num_insns; |
2008 | 355fb23d | pbrook | } |
2009 | fdf9b3e8 | bellard | |
2010 | fdf9b3e8 | bellard | #ifdef DEBUG_DISAS
|
2011 | fdf9b3e8 | bellard | #ifdef SH4_DEBUG_DISAS
|
2012 | 93fcfe39 | aliguori | qemu_log_mask(CPU_LOG_TB_IN_ASM, "\n");
|
2013 | fdf9b3e8 | bellard | #endif
|
2014 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
2015 | 93fcfe39 | aliguori | qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */ |
2016 | 93fcfe39 | aliguori | log_target_disas(pc_start, ctx.pc - pc_start, 0);
|
2017 | 93fcfe39 | aliguori | qemu_log("\n");
|
2018 | fdf9b3e8 | bellard | } |
2019 | fdf9b3e8 | bellard | #endif
|
2020 | fdf9b3e8 | bellard | } |
2021 | fdf9b3e8 | bellard | |
2022 | 2cfc5f17 | ths | void gen_intermediate_code(CPUState * env, struct TranslationBlock *tb) |
2023 | fdf9b3e8 | bellard | { |
2024 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 0);
|
2025 | fdf9b3e8 | bellard | } |
2026 | fdf9b3e8 | bellard | |
2027 | 2cfc5f17 | ths | void gen_intermediate_code_pc(CPUState * env, struct TranslationBlock *tb) |
2028 | fdf9b3e8 | bellard | { |
2029 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 1);
|
2030 | fdf9b3e8 | bellard | } |
2031 | d2856f1a | aurel32 | |
2032 | d2856f1a | aurel32 | void gen_pc_load(CPUState *env, TranslationBlock *tb,
|
2033 | d2856f1a | aurel32 | unsigned long searched_pc, int pc_pos, void *puc) |
2034 | d2856f1a | aurel32 | { |
2035 | d2856f1a | aurel32 | env->pc = gen_opc_pc[pc_pos]; |
2036 | d2856f1a | aurel32 | env->flags = gen_opc_hflags[pc_pos]; |
2037 | d2856f1a | aurel32 | } |