root / target-ppc / translate.c @ 39dd32ee
History | View | Annotate | Download (227.8 kB)
1 | 79aceca5 | bellard | /*
|
---|---|---|---|
2 | 3fc6c082 | bellard | * PowerPC emulation for qemu: main translation routines.
|
3 | 5fafdf24 | ths | *
|
4 | 76a66253 | j_mayer | * Copyright (c) 2003-2007 Jocelyn Mayer
|
5 | 79aceca5 | bellard | *
|
6 | 79aceca5 | bellard | * This library is free software; you can redistribute it and/or
|
7 | 79aceca5 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 79aceca5 | bellard | * License as published by the Free Software Foundation; either
|
9 | 79aceca5 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 79aceca5 | bellard | *
|
11 | 79aceca5 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 79aceca5 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 79aceca5 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 79aceca5 | bellard | * Lesser General Public License for more details.
|
15 | 79aceca5 | bellard | *
|
16 | 79aceca5 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 79aceca5 | bellard | * License along with this library; if not, write to the Free Software
|
18 | 79aceca5 | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 79aceca5 | bellard | */
|
20 | c6a1c22b | bellard | #include <stdarg.h> |
21 | c6a1c22b | bellard | #include <stdlib.h> |
22 | c6a1c22b | bellard | #include <stdio.h> |
23 | c6a1c22b | bellard | #include <string.h> |
24 | c6a1c22b | bellard | #include <inttypes.h> |
25 | c6a1c22b | bellard | |
26 | 79aceca5 | bellard | #include "cpu.h" |
27 | c6a1c22b | bellard | #include "exec-all.h" |
28 | 79aceca5 | bellard | #include "disas.h" |
29 | f10dc08e | aurel32 | #include "helper.h" |
30 | 57fec1fe | bellard | #include "tcg-op.h" |
31 | ca10f867 | aurel32 | #include "qemu-common.h" |
32 | 79aceca5 | bellard | |
33 | 8cbcb4fa | aurel32 | #define CPU_SINGLE_STEP 0x1 |
34 | 8cbcb4fa | aurel32 | #define CPU_BRANCH_STEP 0x2 |
35 | 8cbcb4fa | aurel32 | #define GDBSTUB_SINGLE_STEP 0x4 |
36 | 8cbcb4fa | aurel32 | |
37 | a750fc0b | j_mayer | /* Include definitions for instructions classes and implementations flags */
|
38 | 79aceca5 | bellard | //#define DO_SINGLE_STEP
|
39 | 9fddaa0c | bellard | //#define PPC_DEBUG_DISAS
|
40 | a496775f | j_mayer | //#define DEBUG_MEMORY_ACCESSES
|
41 | 76a66253 | j_mayer | //#define DO_PPC_STATISTICS
|
42 | 7c58044c | j_mayer | //#define OPTIMIZE_FPRF_UPDATE
|
43 | 79aceca5 | bellard | |
44 | a750fc0b | j_mayer | /*****************************************************************************/
|
45 | a750fc0b | j_mayer | /* Code translation helpers */
|
46 | c53be334 | bellard | |
47 | f78fb44e | aurel32 | /* global register indexes */
|
48 | f78fb44e | aurel32 | static TCGv cpu_env;
|
49 | 1d542695 | aurel32 | static char cpu_reg_names[10*3 + 22*4 /* GPR */ |
50 | f78fb44e | aurel32 | #if !defined(TARGET_PPC64)
|
51 | 1d542695 | aurel32 | + 10*4 + 22*5 /* SPE GPRh */ |
52 | f78fb44e | aurel32 | #endif
|
53 | a5e26afa | aurel32 | + 10*4 + 22*5 /* FPR */ |
54 | 47e4661c | aurel32 | + 2*(10*6 + 22*7) /* AVRh, AVRl */ |
55 | 47e4661c | aurel32 | + 8*5 /* CRF */]; |
56 | f78fb44e | aurel32 | static TCGv cpu_gpr[32]; |
57 | f78fb44e | aurel32 | #if !defined(TARGET_PPC64)
|
58 | f78fb44e | aurel32 | static TCGv cpu_gprh[32]; |
59 | f78fb44e | aurel32 | #endif
|
60 | a5e26afa | aurel32 | static TCGv cpu_fpr[32]; |
61 | 1d542695 | aurel32 | static TCGv cpu_avrh[32], cpu_avrl[32]; |
62 | 47e4661c | aurel32 | static TCGv cpu_crf[8]; |
63 | bd568f18 | aurel32 | static TCGv cpu_nip;
|
64 | f78fb44e | aurel32 | |
65 | f78fb44e | aurel32 | /* dyngen register indexes */
|
66 | f78fb44e | aurel32 | static TCGv cpu_T[3]; |
67 | f78fb44e | aurel32 | #if defined(TARGET_PPC64)
|
68 | f78fb44e | aurel32 | #define cpu_T64 cpu_T
|
69 | f78fb44e | aurel32 | #else
|
70 | f78fb44e | aurel32 | static TCGv cpu_T64[3]; |
71 | f78fb44e | aurel32 | #endif
|
72 | a5e26afa | aurel32 | static TCGv cpu_FT[3]; |
73 | 1d542695 | aurel32 | static TCGv cpu_AVRh[3], cpu_AVRl[3]; |
74 | 2e70f6ef | pbrook | |
75 | 2e70f6ef | pbrook | #include "gen-icount.h" |
76 | 2e70f6ef | pbrook | |
77 | 2e70f6ef | pbrook | void ppc_translate_init(void) |
78 | 2e70f6ef | pbrook | { |
79 | f78fb44e | aurel32 | int i;
|
80 | f78fb44e | aurel32 | char* p;
|
81 | b2437bf2 | pbrook | static int done_init = 0; |
82 | f78fb44e | aurel32 | |
83 | 2e70f6ef | pbrook | if (done_init)
|
84 | 2e70f6ef | pbrook | return;
|
85 | f78fb44e | aurel32 | |
86 | 2e70f6ef | pbrook | cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
|
87 | 1c73fe5b | aurel32 | #if TARGET_LONG_BITS > HOST_LONG_BITS
|
88 | 1c73fe5b | aurel32 | cpu_T[0] = tcg_global_mem_new(TCG_TYPE_TL,
|
89 | 1c73fe5b | aurel32 | TCG_AREG0, offsetof(CPUState, t0), "T0");
|
90 | 1c73fe5b | aurel32 | cpu_T[1] = tcg_global_mem_new(TCG_TYPE_TL,
|
91 | 1c73fe5b | aurel32 | TCG_AREG0, offsetof(CPUState, t1), "T1");
|
92 | 1c73fe5b | aurel32 | cpu_T[2] = tcg_global_mem_new(TCG_TYPE_TL,
|
93 | 1c73fe5b | aurel32 | TCG_AREG0, offsetof(CPUState, t2), "T2");
|
94 | 1c73fe5b | aurel32 | #else
|
95 | 1c73fe5b | aurel32 | cpu_T[0] = tcg_global_reg_new(TCG_TYPE_TL, TCG_AREG1, "T0"); |
96 | 1c73fe5b | aurel32 | cpu_T[1] = tcg_global_reg_new(TCG_TYPE_TL, TCG_AREG2, "T1"); |
97 | 1c73fe5b | aurel32 | cpu_T[2] = tcg_global_reg_new(TCG_TYPE_TL, TCG_AREG3, "T2"); |
98 | 1c73fe5b | aurel32 | #endif
|
99 | f78fb44e | aurel32 | #if !defined(TARGET_PPC64)
|
100 | f78fb44e | aurel32 | cpu_T64[0] = tcg_global_mem_new(TCG_TYPE_I64,
|
101 | bd7d9a6d | aurel32 | TCG_AREG0, offsetof(CPUState, t0_64), |
102 | f78fb44e | aurel32 | "T0_64");
|
103 | f78fb44e | aurel32 | cpu_T64[1] = tcg_global_mem_new(TCG_TYPE_I64,
|
104 | bd7d9a6d | aurel32 | TCG_AREG0, offsetof(CPUState, t1_64), |
105 | f78fb44e | aurel32 | "T1_64");
|
106 | f78fb44e | aurel32 | cpu_T64[2] = tcg_global_mem_new(TCG_TYPE_I64,
|
107 | bd7d9a6d | aurel32 | TCG_AREG0, offsetof(CPUState, t2_64), |
108 | f78fb44e | aurel32 | "T2_64");
|
109 | f78fb44e | aurel32 | #endif
|
110 | a5e26afa | aurel32 | |
111 | a5e26afa | aurel32 | cpu_FT[0] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
|
112 | a5e26afa | aurel32 | offsetof(CPUState, ft0), "FT0");
|
113 | a5e26afa | aurel32 | cpu_FT[1] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
|
114 | a5e26afa | aurel32 | offsetof(CPUState, ft1), "FT1");
|
115 | a5e26afa | aurel32 | cpu_FT[2] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
|
116 | a5e26afa | aurel32 | offsetof(CPUState, ft2), "FT2");
|
117 | a5e26afa | aurel32 | |
118 | 1d542695 | aurel32 | cpu_AVRh[0] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
|
119 | 1d542695 | aurel32 | offsetof(CPUState, avr0.u64[0]), "AVR0H"); |
120 | 1d542695 | aurel32 | cpu_AVRl[0] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
|
121 | 1d542695 | aurel32 | offsetof(CPUState, avr0.u64[1]), "AVR0L"); |
122 | 1d542695 | aurel32 | cpu_AVRh[1] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
|
123 | 1d542695 | aurel32 | offsetof(CPUState, avr1.u64[0]), "AVR1H"); |
124 | 1d542695 | aurel32 | cpu_AVRl[1] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
|
125 | 1d542695 | aurel32 | offsetof(CPUState, avr1.u64[1]), "AVR1L"); |
126 | 1d542695 | aurel32 | cpu_AVRh[2] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
|
127 | 1d542695 | aurel32 | offsetof(CPUState, avr2.u64[0]), "AVR2H"); |
128 | 1d542695 | aurel32 | cpu_AVRl[2] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
|
129 | 1d542695 | aurel32 | offsetof(CPUState, avr2.u64[1]), "AVR2L"); |
130 | 1d542695 | aurel32 | |
131 | f78fb44e | aurel32 | p = cpu_reg_names; |
132 | 47e4661c | aurel32 | |
133 | 47e4661c | aurel32 | for (i = 0; i < 8; i++) { |
134 | 47e4661c | aurel32 | sprintf(p, "crf%d", i);
|
135 | 47e4661c | aurel32 | cpu_crf[i] = tcg_global_mem_new(TCG_TYPE_I32, TCG_AREG0, |
136 | 47e4661c | aurel32 | offsetof(CPUState, crf[i]), p); |
137 | 47e4661c | aurel32 | p += 5;
|
138 | 47e4661c | aurel32 | } |
139 | 47e4661c | aurel32 | |
140 | f78fb44e | aurel32 | for (i = 0; i < 32; i++) { |
141 | f78fb44e | aurel32 | sprintf(p, "r%d", i);
|
142 | f78fb44e | aurel32 | cpu_gpr[i] = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0, |
143 | f78fb44e | aurel32 | offsetof(CPUState, gpr[i]), p); |
144 | f78fb44e | aurel32 | p += (i < 10) ? 3 : 4; |
145 | f78fb44e | aurel32 | #if !defined(TARGET_PPC64)
|
146 | f78fb44e | aurel32 | sprintf(p, "r%dH", i);
|
147 | f78fb44e | aurel32 | cpu_gprh[i] = tcg_global_mem_new(TCG_TYPE_I32, TCG_AREG0, |
148 | f78fb44e | aurel32 | offsetof(CPUState, gprh[i]), p); |
149 | f78fb44e | aurel32 | p += (i < 10) ? 4 : 5; |
150 | f78fb44e | aurel32 | #endif
|
151 | 1d542695 | aurel32 | |
152 | a5e26afa | aurel32 | sprintf(p, "fp%d", i);
|
153 | a5e26afa | aurel32 | cpu_fpr[i] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0, |
154 | a5e26afa | aurel32 | offsetof(CPUState, fpr[i]), p); |
155 | ec1ac72d | aurel32 | p += (i < 10) ? 4 : 5; |
156 | a5e26afa | aurel32 | |
157 | 1d542695 | aurel32 | sprintf(p, "avr%dH", i);
|
158 | 1d542695 | aurel32 | cpu_avrh[i] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0, |
159 | 1d542695 | aurel32 | offsetof(CPUState, avr[i].u64[0]), p);
|
160 | 1d542695 | aurel32 | p += (i < 10) ? 6 : 7; |
161 | ec1ac72d | aurel32 | |
162 | 1d542695 | aurel32 | sprintf(p, "avr%dL", i);
|
163 | 1d542695 | aurel32 | cpu_avrl[i] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0, |
164 | 1d542695 | aurel32 | offsetof(CPUState, avr[i].u64[1]), p);
|
165 | 1d542695 | aurel32 | p += (i < 10) ? 6 : 7; |
166 | f78fb44e | aurel32 | } |
167 | f10dc08e | aurel32 | |
168 | bd568f18 | aurel32 | cpu_nip = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0, |
169 | bd568f18 | aurel32 | offsetof(CPUState, nip), "nip");
|
170 | bd568f18 | aurel32 | |
171 | f10dc08e | aurel32 | /* register helpers */
|
172 | f10dc08e | aurel32 | #undef DEF_HELPER
|
173 | f10dc08e | aurel32 | #define DEF_HELPER(ret, name, params) tcg_register_helper(name, #name); |
174 | f10dc08e | aurel32 | #include "helper.h" |
175 | f10dc08e | aurel32 | |
176 | 2e70f6ef | pbrook | done_init = 1;
|
177 | 2e70f6ef | pbrook | } |
178 | 2e70f6ef | pbrook | |
179 | 7c58044c | j_mayer | #if defined(OPTIMIZE_FPRF_UPDATE)
|
180 | 7c58044c | j_mayer | static uint16_t *gen_fprf_buf[OPC_BUF_SIZE];
|
181 | 7c58044c | j_mayer | static uint16_t **gen_fprf_ptr;
|
182 | 7c58044c | j_mayer | #endif
|
183 | 79aceca5 | bellard | |
184 | 79aceca5 | bellard | /* internal defines */
|
185 | 79aceca5 | bellard | typedef struct DisasContext { |
186 | 79aceca5 | bellard | struct TranslationBlock *tb;
|
187 | 0fa85d43 | bellard | target_ulong nip; |
188 | 79aceca5 | bellard | uint32_t opcode; |
189 | 9a64fbe4 | bellard | uint32_t exception; |
190 | 3cc62370 | bellard | /* Routine used to access memory */
|
191 | 3cc62370 | bellard | int mem_idx;
|
192 | 3cc62370 | bellard | /* Translation flags */
|
193 | 9a64fbe4 | bellard | #if !defined(CONFIG_USER_ONLY)
|
194 | 79aceca5 | bellard | int supervisor;
|
195 | 9a64fbe4 | bellard | #endif
|
196 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
197 | d9bce9d9 | j_mayer | int sf_mode;
|
198 | d9bce9d9 | j_mayer | #endif
|
199 | 3cc62370 | bellard | int fpu_enabled;
|
200 | a9d9eb8f | j_mayer | int altivec_enabled;
|
201 | 0487d6a8 | j_mayer | int spe_enabled;
|
202 | 3fc6c082 | bellard | ppc_spr_t *spr_cb; /* Needed to check rights for mfspr/mtspr */
|
203 | ea4e754f | bellard | int singlestep_enabled;
|
204 | d63001d1 | j_mayer | int dcache_line_size;
|
205 | 79aceca5 | bellard | } DisasContext; |
206 | 79aceca5 | bellard | |
207 | 3fc6c082 | bellard | struct opc_handler_t {
|
208 | 79aceca5 | bellard | /* invalid bits */
|
209 | 79aceca5 | bellard | uint32_t inval; |
210 | 9a64fbe4 | bellard | /* instruction type */
|
211 | 0487d6a8 | j_mayer | uint64_t type; |
212 | 79aceca5 | bellard | /* handler */
|
213 | 79aceca5 | bellard | void (*handler)(DisasContext *ctx);
|
214 | a750fc0b | j_mayer | #if defined(DO_PPC_STATISTICS) || defined(PPC_DUMP_CPU)
|
215 | 76a66253 | j_mayer | const unsigned char *oname; |
216 | a750fc0b | j_mayer | #endif
|
217 | a750fc0b | j_mayer | #if defined(DO_PPC_STATISTICS)
|
218 | 76a66253 | j_mayer | uint64_t count; |
219 | 76a66253 | j_mayer | #endif
|
220 | 3fc6c082 | bellard | }; |
221 | 79aceca5 | bellard | |
222 | b068d6a7 | j_mayer | static always_inline void gen_set_Rc0 (DisasContext *ctx) |
223 | 76a66253 | j_mayer | { |
224 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
225 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
226 | d9bce9d9 | j_mayer | gen_op_cmpi_64(0);
|
227 | d9bce9d9 | j_mayer | else
|
228 | d9bce9d9 | j_mayer | #endif
|
229 | d9bce9d9 | j_mayer | gen_op_cmpi(0);
|
230 | 76a66253 | j_mayer | gen_op_set_Rc0(); |
231 | 76a66253 | j_mayer | } |
232 | 76a66253 | j_mayer | |
233 | 7c58044c | j_mayer | static always_inline void gen_reset_fpstatus (void) |
234 | 7c58044c | j_mayer | { |
235 | 7c58044c | j_mayer | #ifdef CONFIG_SOFTFLOAT
|
236 | 7c58044c | j_mayer | gen_op_reset_fpstatus(); |
237 | 7c58044c | j_mayer | #endif
|
238 | 7c58044c | j_mayer | } |
239 | 7c58044c | j_mayer | |
240 | 7c58044c | j_mayer | static always_inline void gen_compute_fprf (int set_fprf, int set_rc) |
241 | 7c58044c | j_mayer | { |
242 | 7c58044c | j_mayer | if (set_fprf != 0) { |
243 | 7c58044c | j_mayer | /* This case might be optimized later */
|
244 | 7c58044c | j_mayer | #if defined(OPTIMIZE_FPRF_UPDATE)
|
245 | 7c58044c | j_mayer | *gen_fprf_ptr++ = gen_opc_ptr; |
246 | 7c58044c | j_mayer | #endif
|
247 | 7c58044c | j_mayer | gen_op_compute_fprf(1);
|
248 | 7c58044c | j_mayer | if (unlikely(set_rc))
|
249 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[1], cpu_T[0], 0xf); |
250 | 7c58044c | j_mayer | gen_op_float_check_status(); |
251 | 7c58044c | j_mayer | } else if (unlikely(set_rc)) { |
252 | 7c58044c | j_mayer | /* We always need to compute fpcc */
|
253 | 7c58044c | j_mayer | gen_op_compute_fprf(0);
|
254 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[1], cpu_T[0], 0xf); |
255 | 7c58044c | j_mayer | if (set_fprf)
|
256 | 7c58044c | j_mayer | gen_op_float_check_status(); |
257 | 7c58044c | j_mayer | } |
258 | 7c58044c | j_mayer | } |
259 | 7c58044c | j_mayer | |
260 | 7c58044c | j_mayer | static always_inline void gen_optimize_fprf (void) |
261 | 7c58044c | j_mayer | { |
262 | 7c58044c | j_mayer | #if defined(OPTIMIZE_FPRF_UPDATE)
|
263 | 7c58044c | j_mayer | uint16_t **ptr; |
264 | 7c58044c | j_mayer | |
265 | 7c58044c | j_mayer | for (ptr = gen_fprf_buf; ptr != (gen_fprf_ptr - 1); ptr++) |
266 | 7c58044c | j_mayer | *ptr = INDEX_op_nop1; |
267 | 7c58044c | j_mayer | gen_fprf_ptr = gen_fprf_buf; |
268 | 7c58044c | j_mayer | #endif
|
269 | 7c58044c | j_mayer | } |
270 | 7c58044c | j_mayer | |
271 | b068d6a7 | j_mayer | static always_inline void gen_update_nip (DisasContext *ctx, target_ulong nip) |
272 | d9bce9d9 | j_mayer | { |
273 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
274 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
275 | bd568f18 | aurel32 | tcg_gen_movi_tl(cpu_nip, nip); |
276 | d9bce9d9 | j_mayer | else
|
277 | d9bce9d9 | j_mayer | #endif
|
278 | bd568f18 | aurel32 | tcg_gen_movi_tl(cpu_nip, (uint32_t)nip); |
279 | d9bce9d9 | j_mayer | } |
280 | d9bce9d9 | j_mayer | |
281 | e1833e1f | j_mayer | #define GEN_EXCP(ctx, excp, error) \
|
282 | 79aceca5 | bellard | do { \
|
283 | e1833e1f | j_mayer | if ((ctx)->exception == POWERPC_EXCP_NONE) { \
|
284 | d9bce9d9 | j_mayer | gen_update_nip(ctx, (ctx)->nip); \ |
285 | 9fddaa0c | bellard | } \ |
286 | 9fddaa0c | bellard | gen_op_raise_exception_err((excp), (error)); \ |
287 | 9fddaa0c | bellard | ctx->exception = (excp); \ |
288 | 79aceca5 | bellard | } while (0) |
289 | 79aceca5 | bellard | |
290 | e1833e1f | j_mayer | #define GEN_EXCP_INVAL(ctx) \
|
291 | e1833e1f | j_mayer | GEN_EXCP((ctx), POWERPC_EXCP_PROGRAM, \ |
292 | e1833e1f | j_mayer | POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL) |
293 | 9fddaa0c | bellard | |
294 | e1833e1f | j_mayer | #define GEN_EXCP_PRIVOPC(ctx) \
|
295 | e1833e1f | j_mayer | GEN_EXCP((ctx), POWERPC_EXCP_PROGRAM, \ |
296 | e1833e1f | j_mayer | POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_OPC) |
297 | 9a64fbe4 | bellard | |
298 | e1833e1f | j_mayer | #define GEN_EXCP_PRIVREG(ctx) \
|
299 | e1833e1f | j_mayer | GEN_EXCP((ctx), POWERPC_EXCP_PROGRAM, \ |
300 | e1833e1f | j_mayer | POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG) |
301 | e1833e1f | j_mayer | |
302 | e1833e1f | j_mayer | #define GEN_EXCP_NO_FP(ctx) \
|
303 | e1833e1f | j_mayer | GEN_EXCP(ctx, POWERPC_EXCP_FPU, 0)
|
304 | e1833e1f | j_mayer | |
305 | e1833e1f | j_mayer | #define GEN_EXCP_NO_AP(ctx) \
|
306 | e1833e1f | j_mayer | GEN_EXCP(ctx, POWERPC_EXCP_APU, 0)
|
307 | 9a64fbe4 | bellard | |
308 | a9d9eb8f | j_mayer | #define GEN_EXCP_NO_VR(ctx) \
|
309 | a9d9eb8f | j_mayer | GEN_EXCP(ctx, POWERPC_EXCP_VPU, 0)
|
310 | a9d9eb8f | j_mayer | |
311 | f24e5695 | bellard | /* Stop translation */
|
312 | b068d6a7 | j_mayer | static always_inline void GEN_STOP (DisasContext *ctx) |
313 | 3fc6c082 | bellard | { |
314 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip); |
315 | e1833e1f | j_mayer | ctx->exception = POWERPC_EXCP_STOP; |
316 | 3fc6c082 | bellard | } |
317 | 3fc6c082 | bellard | |
318 | f24e5695 | bellard | /* No need to update nip here, as execution flow will change */
|
319 | b068d6a7 | j_mayer | static always_inline void GEN_SYNC (DisasContext *ctx) |
320 | 2be0071f | bellard | { |
321 | e1833e1f | j_mayer | ctx->exception = POWERPC_EXCP_SYNC; |
322 | 2be0071f | bellard | } |
323 | 2be0071f | bellard | |
324 | 79aceca5 | bellard | #define GEN_HANDLER(name, opc1, opc2, opc3, inval, type) \
|
325 | 79aceca5 | bellard | static void gen_##name (DisasContext *ctx); \ |
326 | 79aceca5 | bellard | GEN_OPCODE(name, opc1, opc2, opc3, inval, type); \ |
327 | 79aceca5 | bellard | static void gen_##name (DisasContext *ctx) |
328 | 79aceca5 | bellard | |
329 | c7697e1f | j_mayer | #define GEN_HANDLER2(name, onam, opc1, opc2, opc3, inval, type) \
|
330 | c7697e1f | j_mayer | static void gen_##name (DisasContext *ctx); \ |
331 | c7697e1f | j_mayer | GEN_OPCODE2(name, onam, opc1, opc2, opc3, inval, type); \ |
332 | c7697e1f | j_mayer | static void gen_##name (DisasContext *ctx) |
333 | c7697e1f | j_mayer | |
334 | 79aceca5 | bellard | typedef struct opcode_t { |
335 | 79aceca5 | bellard | unsigned char opc1, opc2, opc3; |
336 | 1235fc06 | ths | #if HOST_LONG_BITS == 64 /* Explicitly align to 64 bits */ |
337 | 18fba28c | bellard | unsigned char pad[5]; |
338 | 18fba28c | bellard | #else
|
339 | 18fba28c | bellard | unsigned char pad[1]; |
340 | 18fba28c | bellard | #endif
|
341 | 79aceca5 | bellard | opc_handler_t handler; |
342 | 3fc6c082 | bellard | const unsigned char *oname; |
343 | 79aceca5 | bellard | } opcode_t; |
344 | 79aceca5 | bellard | |
345 | a750fc0b | j_mayer | /*****************************************************************************/
|
346 | 79aceca5 | bellard | /*** Instruction decoding ***/
|
347 | 79aceca5 | bellard | #define EXTRACT_HELPER(name, shift, nb) \
|
348 | b068d6a7 | j_mayer | static always_inline uint32_t name (uint32_t opcode) \
|
349 | 79aceca5 | bellard | { \ |
350 | 79aceca5 | bellard | return (opcode >> (shift)) & ((1 << (nb)) - 1); \ |
351 | 79aceca5 | bellard | } |
352 | 79aceca5 | bellard | |
353 | 79aceca5 | bellard | #define EXTRACT_SHELPER(name, shift, nb) \
|
354 | b068d6a7 | j_mayer | static always_inline int32_t name (uint32_t opcode) \
|
355 | 79aceca5 | bellard | { \ |
356 | 18fba28c | bellard | return (int16_t)((opcode >> (shift)) & ((1 << (nb)) - 1)); \ |
357 | 79aceca5 | bellard | } |
358 | 79aceca5 | bellard | |
359 | 79aceca5 | bellard | /* Opcode part 1 */
|
360 | 79aceca5 | bellard | EXTRACT_HELPER(opc1, 26, 6); |
361 | 79aceca5 | bellard | /* Opcode part 2 */
|
362 | 79aceca5 | bellard | EXTRACT_HELPER(opc2, 1, 5); |
363 | 79aceca5 | bellard | /* Opcode part 3 */
|
364 | 79aceca5 | bellard | EXTRACT_HELPER(opc3, 6, 5); |
365 | 79aceca5 | bellard | /* Update Cr0 flags */
|
366 | 79aceca5 | bellard | EXTRACT_HELPER(Rc, 0, 1); |
367 | 79aceca5 | bellard | /* Destination */
|
368 | 79aceca5 | bellard | EXTRACT_HELPER(rD, 21, 5); |
369 | 79aceca5 | bellard | /* Source */
|
370 | 79aceca5 | bellard | EXTRACT_HELPER(rS, 21, 5); |
371 | 79aceca5 | bellard | /* First operand */
|
372 | 79aceca5 | bellard | EXTRACT_HELPER(rA, 16, 5); |
373 | 79aceca5 | bellard | /* Second operand */
|
374 | 79aceca5 | bellard | EXTRACT_HELPER(rB, 11, 5); |
375 | 79aceca5 | bellard | /* Third operand */
|
376 | 79aceca5 | bellard | EXTRACT_HELPER(rC, 6, 5); |
377 | 79aceca5 | bellard | /*** Get CRn ***/
|
378 | 79aceca5 | bellard | EXTRACT_HELPER(crfD, 23, 3); |
379 | 79aceca5 | bellard | EXTRACT_HELPER(crfS, 18, 3); |
380 | 79aceca5 | bellard | EXTRACT_HELPER(crbD, 21, 5); |
381 | 79aceca5 | bellard | EXTRACT_HELPER(crbA, 16, 5); |
382 | 79aceca5 | bellard | EXTRACT_HELPER(crbB, 11, 5); |
383 | 79aceca5 | bellard | /* SPR / TBL */
|
384 | 3fc6c082 | bellard | EXTRACT_HELPER(_SPR, 11, 10); |
385 | b068d6a7 | j_mayer | static always_inline uint32_t SPR (uint32_t opcode)
|
386 | 3fc6c082 | bellard | { |
387 | 3fc6c082 | bellard | uint32_t sprn = _SPR(opcode); |
388 | 3fc6c082 | bellard | |
389 | 3fc6c082 | bellard | return ((sprn >> 5) & 0x1F) | ((sprn & 0x1F) << 5); |
390 | 3fc6c082 | bellard | } |
391 | 79aceca5 | bellard | /*** Get constants ***/
|
392 | 79aceca5 | bellard | EXTRACT_HELPER(IMM, 12, 8); |
393 | 79aceca5 | bellard | /* 16 bits signed immediate value */
|
394 | 79aceca5 | bellard | EXTRACT_SHELPER(SIMM, 0, 16); |
395 | 79aceca5 | bellard | /* 16 bits unsigned immediate value */
|
396 | 79aceca5 | bellard | EXTRACT_HELPER(UIMM, 0, 16); |
397 | 79aceca5 | bellard | /* Bit count */
|
398 | 79aceca5 | bellard | EXTRACT_HELPER(NB, 11, 5); |
399 | 79aceca5 | bellard | /* Shift count */
|
400 | 79aceca5 | bellard | EXTRACT_HELPER(SH, 11, 5); |
401 | 79aceca5 | bellard | /* Mask start */
|
402 | 79aceca5 | bellard | EXTRACT_HELPER(MB, 6, 5); |
403 | 79aceca5 | bellard | /* Mask end */
|
404 | 79aceca5 | bellard | EXTRACT_HELPER(ME, 1, 5); |
405 | fb0eaffc | bellard | /* Trap operand */
|
406 | fb0eaffc | bellard | EXTRACT_HELPER(TO, 21, 5); |
407 | 79aceca5 | bellard | |
408 | 79aceca5 | bellard | EXTRACT_HELPER(CRM, 12, 8); |
409 | 79aceca5 | bellard | EXTRACT_HELPER(FM, 17, 8); |
410 | 79aceca5 | bellard | EXTRACT_HELPER(SR, 16, 4); |
411 | e4bb997e | aurel32 | EXTRACT_HELPER(FPIMM, 12, 4); |
412 | fb0eaffc | bellard | |
413 | 79aceca5 | bellard | /*** Jump target decoding ***/
|
414 | 79aceca5 | bellard | /* Displacement */
|
415 | 79aceca5 | bellard | EXTRACT_SHELPER(d, 0, 16); |
416 | 79aceca5 | bellard | /* Immediate address */
|
417 | b068d6a7 | j_mayer | static always_inline target_ulong LI (uint32_t opcode)
|
418 | 79aceca5 | bellard | { |
419 | 79aceca5 | bellard | return (opcode >> 0) & 0x03FFFFFC; |
420 | 79aceca5 | bellard | } |
421 | 79aceca5 | bellard | |
422 | b068d6a7 | j_mayer | static always_inline uint32_t BD (uint32_t opcode)
|
423 | 79aceca5 | bellard | { |
424 | 79aceca5 | bellard | return (opcode >> 0) & 0xFFFC; |
425 | 79aceca5 | bellard | } |
426 | 79aceca5 | bellard | |
427 | 79aceca5 | bellard | EXTRACT_HELPER(BO, 21, 5); |
428 | 79aceca5 | bellard | EXTRACT_HELPER(BI, 16, 5); |
429 | 79aceca5 | bellard | /* Absolute/relative address */
|
430 | 79aceca5 | bellard | EXTRACT_HELPER(AA, 1, 1); |
431 | 79aceca5 | bellard | /* Link */
|
432 | 79aceca5 | bellard | EXTRACT_HELPER(LK, 0, 1); |
433 | 79aceca5 | bellard | |
434 | 79aceca5 | bellard | /* Create a mask between <start> and <end> bits */
|
435 | b068d6a7 | j_mayer | static always_inline target_ulong MASK (uint32_t start, uint32_t end)
|
436 | 79aceca5 | bellard | { |
437 | 76a66253 | j_mayer | target_ulong ret; |
438 | 79aceca5 | bellard | |
439 | 76a66253 | j_mayer | #if defined(TARGET_PPC64)
|
440 | 76a66253 | j_mayer | if (likely(start == 0)) { |
441 | 6f2d8978 | j_mayer | ret = UINT64_MAX << (63 - end);
|
442 | 76a66253 | j_mayer | } else if (likely(end == 63)) { |
443 | 6f2d8978 | j_mayer | ret = UINT64_MAX >> start; |
444 | 76a66253 | j_mayer | } |
445 | 76a66253 | j_mayer | #else
|
446 | 76a66253 | j_mayer | if (likely(start == 0)) { |
447 | 6f2d8978 | j_mayer | ret = UINT32_MAX << (31 - end);
|
448 | 76a66253 | j_mayer | } else if (likely(end == 31)) { |
449 | 6f2d8978 | j_mayer | ret = UINT32_MAX >> start; |
450 | 76a66253 | j_mayer | } |
451 | 76a66253 | j_mayer | #endif
|
452 | 76a66253 | j_mayer | else {
|
453 | 76a66253 | j_mayer | ret = (((target_ulong)(-1ULL)) >> (start)) ^
|
454 | 76a66253 | j_mayer | (((target_ulong)(-1ULL) >> (end)) >> 1); |
455 | 76a66253 | j_mayer | if (unlikely(start > end))
|
456 | 76a66253 | j_mayer | return ~ret;
|
457 | 76a66253 | j_mayer | } |
458 | 79aceca5 | bellard | |
459 | 79aceca5 | bellard | return ret;
|
460 | 79aceca5 | bellard | } |
461 | 79aceca5 | bellard | |
462 | a750fc0b | j_mayer | /*****************************************************************************/
|
463 | a750fc0b | j_mayer | /* PowerPC Instructions types definitions */
|
464 | a750fc0b | j_mayer | enum {
|
465 | 1b413d55 | j_mayer | PPC_NONE = 0x0000000000000000ULL,
|
466 | 12de9a39 | j_mayer | /* PowerPC base instructions set */
|
467 | 1b413d55 | j_mayer | PPC_INSNS_BASE = 0x0000000000000001ULL,
|
468 | 1b413d55 | j_mayer | /* integer operations instructions */
|
469 | a750fc0b | j_mayer | #define PPC_INTEGER PPC_INSNS_BASE
|
470 | 1b413d55 | j_mayer | /* flow control instructions */
|
471 | a750fc0b | j_mayer | #define PPC_FLOW PPC_INSNS_BASE
|
472 | 1b413d55 | j_mayer | /* virtual memory instructions */
|
473 | a750fc0b | j_mayer | #define PPC_MEM PPC_INSNS_BASE
|
474 | 1b413d55 | j_mayer | /* ld/st with reservation instructions */
|
475 | a750fc0b | j_mayer | #define PPC_RES PPC_INSNS_BASE
|
476 | 1b413d55 | j_mayer | /* spr/msr access instructions */
|
477 | a750fc0b | j_mayer | #define PPC_MISC PPC_INSNS_BASE
|
478 | 1b413d55 | j_mayer | /* Deprecated instruction sets */
|
479 | 1b413d55 | j_mayer | /* Original POWER instruction set */
|
480 | f610349f | j_mayer | PPC_POWER = 0x0000000000000002ULL,
|
481 | 1b413d55 | j_mayer | /* POWER2 instruction set extension */
|
482 | f610349f | j_mayer | PPC_POWER2 = 0x0000000000000004ULL,
|
483 | 1b413d55 | j_mayer | /* Power RTC support */
|
484 | f610349f | j_mayer | PPC_POWER_RTC = 0x0000000000000008ULL,
|
485 | 1b413d55 | j_mayer | /* Power-to-PowerPC bridge (601) */
|
486 | f610349f | j_mayer | PPC_POWER_BR = 0x0000000000000010ULL,
|
487 | 1b413d55 | j_mayer | /* 64 bits PowerPC instruction set */
|
488 | f610349f | j_mayer | PPC_64B = 0x0000000000000020ULL,
|
489 | 1b413d55 | j_mayer | /* New 64 bits extensions (PowerPC 2.0x) */
|
490 | f610349f | j_mayer | PPC_64BX = 0x0000000000000040ULL,
|
491 | 1b413d55 | j_mayer | /* 64 bits hypervisor extensions */
|
492 | f610349f | j_mayer | PPC_64H = 0x0000000000000080ULL,
|
493 | 1b413d55 | j_mayer | /* New wait instruction (PowerPC 2.0x) */
|
494 | f610349f | j_mayer | PPC_WAIT = 0x0000000000000100ULL,
|
495 | 1b413d55 | j_mayer | /* Time base mftb instruction */
|
496 | f610349f | j_mayer | PPC_MFTB = 0x0000000000000200ULL,
|
497 | 1b413d55 | j_mayer | |
498 | 1b413d55 | j_mayer | /* Fixed-point unit extensions */
|
499 | 1b413d55 | j_mayer | /* PowerPC 602 specific */
|
500 | f610349f | j_mayer | PPC_602_SPEC = 0x0000000000000400ULL,
|
501 | 05332d70 | j_mayer | /* isel instruction */
|
502 | 05332d70 | j_mayer | PPC_ISEL = 0x0000000000000800ULL,
|
503 | 05332d70 | j_mayer | /* popcntb instruction */
|
504 | 05332d70 | j_mayer | PPC_POPCNTB = 0x0000000000001000ULL,
|
505 | 05332d70 | j_mayer | /* string load / store */
|
506 | 05332d70 | j_mayer | PPC_STRING = 0x0000000000002000ULL,
|
507 | 1b413d55 | j_mayer | |
508 | 1b413d55 | j_mayer | /* Floating-point unit extensions */
|
509 | 1b413d55 | j_mayer | /* Optional floating point instructions */
|
510 | 1b413d55 | j_mayer | PPC_FLOAT = 0x0000000000010000ULL,
|
511 | 1b413d55 | j_mayer | /* New floating-point extensions (PowerPC 2.0x) */
|
512 | 1b413d55 | j_mayer | PPC_FLOAT_EXT = 0x0000000000020000ULL,
|
513 | 1b413d55 | j_mayer | PPC_FLOAT_FSQRT = 0x0000000000040000ULL,
|
514 | 1b413d55 | j_mayer | PPC_FLOAT_FRES = 0x0000000000080000ULL,
|
515 | 1b413d55 | j_mayer | PPC_FLOAT_FRSQRTE = 0x0000000000100000ULL,
|
516 | 1b413d55 | j_mayer | PPC_FLOAT_FRSQRTES = 0x0000000000200000ULL,
|
517 | 1b413d55 | j_mayer | PPC_FLOAT_FSEL = 0x0000000000400000ULL,
|
518 | 1b413d55 | j_mayer | PPC_FLOAT_STFIWX = 0x0000000000800000ULL,
|
519 | 1b413d55 | j_mayer | |
520 | 1b413d55 | j_mayer | /* Vector/SIMD extensions */
|
521 | 1b413d55 | j_mayer | /* Altivec support */
|
522 | 1b413d55 | j_mayer | PPC_ALTIVEC = 0x0000000001000000ULL,
|
523 | 1b413d55 | j_mayer | /* PowerPC 2.03 SPE extension */
|
524 | 05332d70 | j_mayer | PPC_SPE = 0x0000000002000000ULL,
|
525 | 1b413d55 | j_mayer | /* PowerPC 2.03 SPE floating-point extension */
|
526 | 05332d70 | j_mayer | PPC_SPEFPU = 0x0000000004000000ULL,
|
527 | 1b413d55 | j_mayer | |
528 | 12de9a39 | j_mayer | /* Optional memory control instructions */
|
529 | 1b413d55 | j_mayer | PPC_MEM_TLBIA = 0x0000000010000000ULL,
|
530 | 1b413d55 | j_mayer | PPC_MEM_TLBIE = 0x0000000020000000ULL,
|
531 | 1b413d55 | j_mayer | PPC_MEM_TLBSYNC = 0x0000000040000000ULL,
|
532 | 1b413d55 | j_mayer | /* sync instruction */
|
533 | 1b413d55 | j_mayer | PPC_MEM_SYNC = 0x0000000080000000ULL,
|
534 | 1b413d55 | j_mayer | /* eieio instruction */
|
535 | 1b413d55 | j_mayer | PPC_MEM_EIEIO = 0x0000000100000000ULL,
|
536 | 1b413d55 | j_mayer | |
537 | 1b413d55 | j_mayer | /* Cache control instructions */
|
538 | c8623f2e | j_mayer | PPC_CACHE = 0x0000000200000000ULL,
|
539 | 1b413d55 | j_mayer | /* icbi instruction */
|
540 | 05332d70 | j_mayer | PPC_CACHE_ICBI = 0x0000000400000000ULL,
|
541 | 1b413d55 | j_mayer | /* dcbz instruction with fixed cache line size */
|
542 | 05332d70 | j_mayer | PPC_CACHE_DCBZ = 0x0000000800000000ULL,
|
543 | 1b413d55 | j_mayer | /* dcbz instruction with tunable cache line size */
|
544 | 05332d70 | j_mayer | PPC_CACHE_DCBZT = 0x0000001000000000ULL,
|
545 | 1b413d55 | j_mayer | /* dcba instruction */
|
546 | 05332d70 | j_mayer | PPC_CACHE_DCBA = 0x0000002000000000ULL,
|
547 | 05332d70 | j_mayer | /* Freescale cache locking instructions */
|
548 | 05332d70 | j_mayer | PPC_CACHE_LOCK = 0x0000004000000000ULL,
|
549 | 1b413d55 | j_mayer | |
550 | 1b413d55 | j_mayer | /* MMU related extensions */
|
551 | 1b413d55 | j_mayer | /* external control instructions */
|
552 | 05332d70 | j_mayer | PPC_EXTERN = 0x0000010000000000ULL,
|
553 | 1b413d55 | j_mayer | /* segment register access instructions */
|
554 | 05332d70 | j_mayer | PPC_SEGMENT = 0x0000020000000000ULL,
|
555 | 1b413d55 | j_mayer | /* PowerPC 6xx TLB management instructions */
|
556 | 05332d70 | j_mayer | PPC_6xx_TLB = 0x0000040000000000ULL,
|
557 | 1b413d55 | j_mayer | /* PowerPC 74xx TLB management instructions */
|
558 | 05332d70 | j_mayer | PPC_74xx_TLB = 0x0000080000000000ULL,
|
559 | 1b413d55 | j_mayer | /* PowerPC 40x TLB management instructions */
|
560 | 05332d70 | j_mayer | PPC_40x_TLB = 0x0000100000000000ULL,
|
561 | 1b413d55 | j_mayer | /* segment register access instructions for PowerPC 64 "bridge" */
|
562 | 05332d70 | j_mayer | PPC_SEGMENT_64B = 0x0000200000000000ULL,
|
563 | 1b413d55 | j_mayer | /* SLB management */
|
564 | 05332d70 | j_mayer | PPC_SLBI = 0x0000400000000000ULL,
|
565 | 1b413d55 | j_mayer | |
566 | 12de9a39 | j_mayer | /* Embedded PowerPC dedicated instructions */
|
567 | 05332d70 | j_mayer | PPC_WRTEE = 0x0001000000000000ULL,
|
568 | 12de9a39 | j_mayer | /* PowerPC 40x exception model */
|
569 | 05332d70 | j_mayer | PPC_40x_EXCP = 0x0002000000000000ULL,
|
570 | 12de9a39 | j_mayer | /* PowerPC 405 Mac instructions */
|
571 | 05332d70 | j_mayer | PPC_405_MAC = 0x0004000000000000ULL,
|
572 | 12de9a39 | j_mayer | /* PowerPC 440 specific instructions */
|
573 | 05332d70 | j_mayer | PPC_440_SPEC = 0x0008000000000000ULL,
|
574 | 12de9a39 | j_mayer | /* BookE (embedded) PowerPC specification */
|
575 | 05332d70 | j_mayer | PPC_BOOKE = 0x0010000000000000ULL,
|
576 | 05332d70 | j_mayer | /* mfapidi instruction */
|
577 | 05332d70 | j_mayer | PPC_MFAPIDI = 0x0020000000000000ULL,
|
578 | 05332d70 | j_mayer | /* tlbiva instruction */
|
579 | 05332d70 | j_mayer | PPC_TLBIVA = 0x0040000000000000ULL,
|
580 | 05332d70 | j_mayer | /* tlbivax instruction */
|
581 | 05332d70 | j_mayer | PPC_TLBIVAX = 0x0080000000000000ULL,
|
582 | 12de9a39 | j_mayer | /* PowerPC 4xx dedicated instructions */
|
583 | 05332d70 | j_mayer | PPC_4xx_COMMON = 0x0100000000000000ULL,
|
584 | 12de9a39 | j_mayer | /* PowerPC 40x ibct instructions */
|
585 | 05332d70 | j_mayer | PPC_40x_ICBT = 0x0200000000000000ULL,
|
586 | 12de9a39 | j_mayer | /* rfmci is not implemented in all BookE PowerPC */
|
587 | 05332d70 | j_mayer | PPC_RFMCI = 0x0400000000000000ULL,
|
588 | 05332d70 | j_mayer | /* rfdi instruction */
|
589 | 05332d70 | j_mayer | PPC_RFDI = 0x0800000000000000ULL,
|
590 | 05332d70 | j_mayer | /* DCR accesses */
|
591 | 05332d70 | j_mayer | PPC_DCR = 0x1000000000000000ULL,
|
592 | 05332d70 | j_mayer | /* DCR extended accesse */
|
593 | 05332d70 | j_mayer | PPC_DCRX = 0x2000000000000000ULL,
|
594 | 12de9a39 | j_mayer | /* user-mode DCR access, implemented in PowerPC 460 */
|
595 | 05332d70 | j_mayer | PPC_DCRUX = 0x4000000000000000ULL,
|
596 | a750fc0b | j_mayer | }; |
597 | a750fc0b | j_mayer | |
598 | a750fc0b | j_mayer | /*****************************************************************************/
|
599 | a750fc0b | j_mayer | /* PowerPC instructions table */
|
600 | 3fc6c082 | bellard | #if HOST_LONG_BITS == 64 |
601 | 3fc6c082 | bellard | #define OPC_ALIGN 8 |
602 | 3fc6c082 | bellard | #else
|
603 | 3fc6c082 | bellard | #define OPC_ALIGN 4 |
604 | 3fc6c082 | bellard | #endif
|
605 | 1b039c09 | bellard | #if defined(__APPLE__)
|
606 | d9bce9d9 | j_mayer | #define OPCODES_SECTION \
|
607 | 3fc6c082 | bellard | __attribute__ ((section("__TEXT,__opcodes"), unused, aligned (OPC_ALIGN) ))
|
608 | 933dc6eb | bellard | #else
|
609 | d9bce9d9 | j_mayer | #define OPCODES_SECTION \
|
610 | 3fc6c082 | bellard | __attribute__ ((section(".opcodes"), unused, aligned (OPC_ALIGN) ))
|
611 | 933dc6eb | bellard | #endif
|
612 | 933dc6eb | bellard | |
613 | 76a66253 | j_mayer | #if defined(DO_PPC_STATISTICS)
|
614 | 79aceca5 | bellard | #define GEN_OPCODE(name, op1, op2, op3, invl, _typ) \
|
615 | 18fba28c | bellard | OPCODES_SECTION opcode_t opc_##name = { \ |
616 | 79aceca5 | bellard | .opc1 = op1, \ |
617 | 79aceca5 | bellard | .opc2 = op2, \ |
618 | 79aceca5 | bellard | .opc3 = op3, \ |
619 | 18fba28c | bellard | .pad = { 0, }, \
|
620 | 79aceca5 | bellard | .handler = { \ |
621 | 79aceca5 | bellard | .inval = invl, \ |
622 | 9a64fbe4 | bellard | .type = _typ, \ |
623 | 79aceca5 | bellard | .handler = &gen_##name, \ |
624 | 76a66253 | j_mayer | .oname = stringify(name), \ |
625 | 79aceca5 | bellard | }, \ |
626 | 3fc6c082 | bellard | .oname = stringify(name), \ |
627 | 79aceca5 | bellard | } |
628 | c7697e1f | j_mayer | #define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ) \
|
629 | c7697e1f | j_mayer | OPCODES_SECTION opcode_t opc_##name = { \ |
630 | c7697e1f | j_mayer | .opc1 = op1, \ |
631 | c7697e1f | j_mayer | .opc2 = op2, \ |
632 | c7697e1f | j_mayer | .opc3 = op3, \ |
633 | c7697e1f | j_mayer | .pad = { 0, }, \
|
634 | c7697e1f | j_mayer | .handler = { \ |
635 | c7697e1f | j_mayer | .inval = invl, \ |
636 | c7697e1f | j_mayer | .type = _typ, \ |
637 | c7697e1f | j_mayer | .handler = &gen_##name, \ |
638 | c7697e1f | j_mayer | .oname = onam, \ |
639 | c7697e1f | j_mayer | }, \ |
640 | c7697e1f | j_mayer | .oname = onam, \ |
641 | c7697e1f | j_mayer | } |
642 | 76a66253 | j_mayer | #else
|
643 | 76a66253 | j_mayer | #define GEN_OPCODE(name, op1, op2, op3, invl, _typ) \
|
644 | 76a66253 | j_mayer | OPCODES_SECTION opcode_t opc_##name = { \ |
645 | 76a66253 | j_mayer | .opc1 = op1, \ |
646 | 76a66253 | j_mayer | .opc2 = op2, \ |
647 | 76a66253 | j_mayer | .opc3 = op3, \ |
648 | 76a66253 | j_mayer | .pad = { 0, }, \
|
649 | 76a66253 | j_mayer | .handler = { \ |
650 | 76a66253 | j_mayer | .inval = invl, \ |
651 | 76a66253 | j_mayer | .type = _typ, \ |
652 | 76a66253 | j_mayer | .handler = &gen_##name, \ |
653 | 76a66253 | j_mayer | }, \ |
654 | 76a66253 | j_mayer | .oname = stringify(name), \ |
655 | 76a66253 | j_mayer | } |
656 | c7697e1f | j_mayer | #define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ) \
|
657 | c7697e1f | j_mayer | OPCODES_SECTION opcode_t opc_##name = { \ |
658 | c7697e1f | j_mayer | .opc1 = op1, \ |
659 | c7697e1f | j_mayer | .opc2 = op2, \ |
660 | c7697e1f | j_mayer | .opc3 = op3, \ |
661 | c7697e1f | j_mayer | .pad = { 0, }, \
|
662 | c7697e1f | j_mayer | .handler = { \ |
663 | c7697e1f | j_mayer | .inval = invl, \ |
664 | c7697e1f | j_mayer | .type = _typ, \ |
665 | c7697e1f | j_mayer | .handler = &gen_##name, \ |
666 | c7697e1f | j_mayer | }, \ |
667 | c7697e1f | j_mayer | .oname = onam, \ |
668 | c7697e1f | j_mayer | } |
669 | 76a66253 | j_mayer | #endif
|
670 | 79aceca5 | bellard | |
671 | 79aceca5 | bellard | #define GEN_OPCODE_MARK(name) \
|
672 | 18fba28c | bellard | OPCODES_SECTION opcode_t opc_##name = { \ |
673 | 79aceca5 | bellard | .opc1 = 0xFF, \
|
674 | 79aceca5 | bellard | .opc2 = 0xFF, \
|
675 | 79aceca5 | bellard | .opc3 = 0xFF, \
|
676 | 18fba28c | bellard | .pad = { 0, }, \
|
677 | 79aceca5 | bellard | .handler = { \ |
678 | 79aceca5 | bellard | .inval = 0x00000000, \
|
679 | 9a64fbe4 | bellard | .type = 0x00, \
|
680 | 79aceca5 | bellard | .handler = NULL, \
|
681 | 79aceca5 | bellard | }, \ |
682 | 3fc6c082 | bellard | .oname = stringify(name), \ |
683 | 79aceca5 | bellard | } |
684 | 79aceca5 | bellard | |
685 | 79aceca5 | bellard | /* Start opcode list */
|
686 | 79aceca5 | bellard | GEN_OPCODE_MARK(start); |
687 | 79aceca5 | bellard | |
688 | 79aceca5 | bellard | /* Invalid instruction */
|
689 | 9a64fbe4 | bellard | GEN_HANDLER(invalid, 0x00, 0x00, 0x00, 0xFFFFFFFF, PPC_NONE) |
690 | 9a64fbe4 | bellard | { |
691 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
692 | 9a64fbe4 | bellard | } |
693 | 9a64fbe4 | bellard | |
694 | 79aceca5 | bellard | static opc_handler_t invalid_handler = {
|
695 | 79aceca5 | bellard | .inval = 0xFFFFFFFF,
|
696 | 9a64fbe4 | bellard | .type = PPC_NONE, |
697 | 79aceca5 | bellard | .handler = gen_invalid, |
698 | 79aceca5 | bellard | }; |
699 | 79aceca5 | bellard | |
700 | 79aceca5 | bellard | /*** Integer arithmetic ***/
|
701 | d9bce9d9 | j_mayer | #define __GEN_INT_ARITH2(name, opc1, opc2, opc3, inval, type) \
|
702 | d9bce9d9 | j_mayer | GEN_HANDLER(name, opc1, opc2, opc3, inval, type) \ |
703 | 79aceca5 | bellard | { \ |
704 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
705 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]); \
|
706 | 79aceca5 | bellard | gen_op_##name(); \ |
707 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); \
|
708 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
709 | 76a66253 | j_mayer | gen_set_Rc0(ctx); \ |
710 | 79aceca5 | bellard | } |
711 | 79aceca5 | bellard | |
712 | d9bce9d9 | j_mayer | #define __GEN_INT_ARITH2_O(name, opc1, opc2, opc3, inval, type) \
|
713 | d9bce9d9 | j_mayer | GEN_HANDLER(name, opc1, opc2, opc3, inval, type) \ |
714 | 79aceca5 | bellard | { \ |
715 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
716 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]); \
|
717 | 79aceca5 | bellard | gen_op_##name(); \ |
718 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); \
|
719 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
720 | 76a66253 | j_mayer | gen_set_Rc0(ctx); \ |
721 | 79aceca5 | bellard | } |
722 | 79aceca5 | bellard | |
723 | d9bce9d9 | j_mayer | #define __GEN_INT_ARITH1(name, opc1, opc2, opc3, type) \
|
724 | d9bce9d9 | j_mayer | GEN_HANDLER(name, opc1, opc2, opc3, 0x0000F800, type) \
|
725 | 79aceca5 | bellard | { \ |
726 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
727 | 79aceca5 | bellard | gen_op_##name(); \ |
728 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); \
|
729 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
730 | 76a66253 | j_mayer | gen_set_Rc0(ctx); \ |
731 | 79aceca5 | bellard | } |
732 | d9bce9d9 | j_mayer | #define __GEN_INT_ARITH1_O(name, opc1, opc2, opc3, type) \
|
733 | d9bce9d9 | j_mayer | GEN_HANDLER(name, opc1, opc2, opc3, 0x0000F800, type) \
|
734 | 79aceca5 | bellard | { \ |
735 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
736 | 79aceca5 | bellard | gen_op_##name(); \ |
737 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); \
|
738 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
739 | 76a66253 | j_mayer | gen_set_Rc0(ctx); \ |
740 | 79aceca5 | bellard | } |
741 | 79aceca5 | bellard | |
742 | 79aceca5 | bellard | /* Two operands arithmetic functions */
|
743 | d9bce9d9 | j_mayer | #define GEN_INT_ARITH2(name, opc1, opc2, opc3, type) \
|
744 | d9bce9d9 | j_mayer | __GEN_INT_ARITH2(name, opc1, opc2, opc3, 0x00000000, type) \
|
745 | d9bce9d9 | j_mayer | __GEN_INT_ARITH2_O(name##o, opc1, opc2, opc3 | 0x10, 0x00000000, type) |
746 | d9bce9d9 | j_mayer | |
747 | d9bce9d9 | j_mayer | /* Two operands arithmetic functions with no overflow allowed */
|
748 | d9bce9d9 | j_mayer | #define GEN_INT_ARITHN(name, opc1, opc2, opc3, type) \
|
749 | d9bce9d9 | j_mayer | __GEN_INT_ARITH2(name, opc1, opc2, opc3, 0x00000400, type)
|
750 | d9bce9d9 | j_mayer | |
751 | d9bce9d9 | j_mayer | /* One operand arithmetic functions */
|
752 | d9bce9d9 | j_mayer | #define GEN_INT_ARITH1(name, opc1, opc2, opc3, type) \
|
753 | d9bce9d9 | j_mayer | __GEN_INT_ARITH1(name, opc1, opc2, opc3, type) \ |
754 | d9bce9d9 | j_mayer | __GEN_INT_ARITH1_O(name##o, opc1, opc2, opc3 | 0x10, type) |
755 | d9bce9d9 | j_mayer | |
756 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
757 | d9bce9d9 | j_mayer | #define __GEN_INT_ARITH2_64(name, opc1, opc2, opc3, inval, type) \
|
758 | d9bce9d9 | j_mayer | GEN_HANDLER(name, opc1, opc2, opc3, inval, type) \ |
759 | d9bce9d9 | j_mayer | { \ |
760 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
761 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]); \
|
762 | d9bce9d9 | j_mayer | if (ctx->sf_mode) \
|
763 | d9bce9d9 | j_mayer | gen_op_##name##_64(); \ |
764 | d9bce9d9 | j_mayer | else \
|
765 | d9bce9d9 | j_mayer | gen_op_##name(); \ |
766 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); \
|
767 | d9bce9d9 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
768 | d9bce9d9 | j_mayer | gen_set_Rc0(ctx); \ |
769 | d9bce9d9 | j_mayer | } |
770 | d9bce9d9 | j_mayer | |
771 | d9bce9d9 | j_mayer | #define __GEN_INT_ARITH2_O_64(name, opc1, opc2, opc3, inval, type) \
|
772 | d9bce9d9 | j_mayer | GEN_HANDLER(name, opc1, opc2, opc3, inval, type) \ |
773 | d9bce9d9 | j_mayer | { \ |
774 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
775 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]); \
|
776 | d9bce9d9 | j_mayer | if (ctx->sf_mode) \
|
777 | d9bce9d9 | j_mayer | gen_op_##name##_64(); \ |
778 | d9bce9d9 | j_mayer | else \
|
779 | d9bce9d9 | j_mayer | gen_op_##name(); \ |
780 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); \
|
781 | d9bce9d9 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
782 | d9bce9d9 | j_mayer | gen_set_Rc0(ctx); \ |
783 | d9bce9d9 | j_mayer | } |
784 | d9bce9d9 | j_mayer | |
785 | d9bce9d9 | j_mayer | #define __GEN_INT_ARITH1_64(name, opc1, opc2, opc3, type) \
|
786 | d9bce9d9 | j_mayer | GEN_HANDLER(name, opc1, opc2, opc3, 0x0000F800, type) \
|
787 | d9bce9d9 | j_mayer | { \ |
788 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
789 | d9bce9d9 | j_mayer | if (ctx->sf_mode) \
|
790 | d9bce9d9 | j_mayer | gen_op_##name##_64(); \ |
791 | d9bce9d9 | j_mayer | else \
|
792 | d9bce9d9 | j_mayer | gen_op_##name(); \ |
793 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); \
|
794 | d9bce9d9 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
795 | d9bce9d9 | j_mayer | gen_set_Rc0(ctx); \ |
796 | d9bce9d9 | j_mayer | } |
797 | d9bce9d9 | j_mayer | #define __GEN_INT_ARITH1_O_64(name, opc1, opc2, opc3, type) \
|
798 | d9bce9d9 | j_mayer | GEN_HANDLER(name, opc1, opc2, opc3, 0x0000F800, type) \
|
799 | d9bce9d9 | j_mayer | { \ |
800 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
801 | d9bce9d9 | j_mayer | if (ctx->sf_mode) \
|
802 | d9bce9d9 | j_mayer | gen_op_##name##_64(); \ |
803 | d9bce9d9 | j_mayer | else \
|
804 | d9bce9d9 | j_mayer | gen_op_##name(); \ |
805 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); \
|
806 | d9bce9d9 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
807 | d9bce9d9 | j_mayer | gen_set_Rc0(ctx); \ |
808 | d9bce9d9 | j_mayer | } |
809 | d9bce9d9 | j_mayer | |
810 | d9bce9d9 | j_mayer | /* Two operands arithmetic functions */
|
811 | d9bce9d9 | j_mayer | #define GEN_INT_ARITH2_64(name, opc1, opc2, opc3, type) \
|
812 | d9bce9d9 | j_mayer | __GEN_INT_ARITH2_64(name, opc1, opc2, opc3, 0x00000000, type) \
|
813 | d9bce9d9 | j_mayer | __GEN_INT_ARITH2_O_64(name##o, opc1, opc2, opc3 | 0x10, 0x00000000, type) |
814 | 79aceca5 | bellard | |
815 | 79aceca5 | bellard | /* Two operands arithmetic functions with no overflow allowed */
|
816 | d9bce9d9 | j_mayer | #define GEN_INT_ARITHN_64(name, opc1, opc2, opc3, type) \
|
817 | d9bce9d9 | j_mayer | __GEN_INT_ARITH2_64(name, opc1, opc2, opc3, 0x00000400, type)
|
818 | 79aceca5 | bellard | |
819 | 79aceca5 | bellard | /* One operand arithmetic functions */
|
820 | d9bce9d9 | j_mayer | #define GEN_INT_ARITH1_64(name, opc1, opc2, opc3, type) \
|
821 | d9bce9d9 | j_mayer | __GEN_INT_ARITH1_64(name, opc1, opc2, opc3, type) \ |
822 | d9bce9d9 | j_mayer | __GEN_INT_ARITH1_O_64(name##o, opc1, opc2, opc3 | 0x10, type) |
823 | d9bce9d9 | j_mayer | #else
|
824 | d9bce9d9 | j_mayer | #define GEN_INT_ARITH2_64 GEN_INT_ARITH2
|
825 | d9bce9d9 | j_mayer | #define GEN_INT_ARITHN_64 GEN_INT_ARITHN
|
826 | d9bce9d9 | j_mayer | #define GEN_INT_ARITH1_64 GEN_INT_ARITH1
|
827 | d9bce9d9 | j_mayer | #endif
|
828 | 79aceca5 | bellard | |
829 | 79aceca5 | bellard | /* add add. addo addo. */
|
830 | 39dd32ee | aurel32 | static always_inline void gen_op_add (void) |
831 | 39dd32ee | aurel32 | { |
832 | 39dd32ee | aurel32 | tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]); |
833 | 39dd32ee | aurel32 | } |
834 | b068d6a7 | j_mayer | static always_inline void gen_op_addo (void) |
835 | d9bce9d9 | j_mayer | { |
836 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
837 | 39dd32ee | aurel32 | tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]); |
838 | d9bce9d9 | j_mayer | gen_op_check_addo(); |
839 | d9bce9d9 | j_mayer | } |
840 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
841 | d9bce9d9 | j_mayer | #define gen_op_add_64 gen_op_add
|
842 | b068d6a7 | j_mayer | static always_inline void gen_op_addo_64 (void) |
843 | d9bce9d9 | j_mayer | { |
844 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
845 | 39dd32ee | aurel32 | tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]); |
846 | d9bce9d9 | j_mayer | gen_op_check_addo_64(); |
847 | d9bce9d9 | j_mayer | } |
848 | d9bce9d9 | j_mayer | #endif
|
849 | d9bce9d9 | j_mayer | GEN_INT_ARITH2_64 (add, 0x1F, 0x0A, 0x08, PPC_INTEGER); |
850 | 79aceca5 | bellard | /* addc addc. addco addco. */
|
851 | b068d6a7 | j_mayer | static always_inline void gen_op_addc (void) |
852 | d9bce9d9 | j_mayer | { |
853 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
854 | 39dd32ee | aurel32 | tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]); |
855 | d9bce9d9 | j_mayer | gen_op_check_addc(); |
856 | d9bce9d9 | j_mayer | } |
857 | b068d6a7 | j_mayer | static always_inline void gen_op_addco (void) |
858 | d9bce9d9 | j_mayer | { |
859 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
860 | 39dd32ee | aurel32 | tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]); |
861 | d9bce9d9 | j_mayer | gen_op_check_addc(); |
862 | d9bce9d9 | j_mayer | gen_op_check_addo(); |
863 | d9bce9d9 | j_mayer | } |
864 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
865 | b068d6a7 | j_mayer | static always_inline void gen_op_addc_64 (void) |
866 | d9bce9d9 | j_mayer | { |
867 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
868 | 39dd32ee | aurel32 | tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]); |
869 | d9bce9d9 | j_mayer | gen_op_check_addc_64(); |
870 | d9bce9d9 | j_mayer | } |
871 | b068d6a7 | j_mayer | static always_inline void gen_op_addco_64 (void) |
872 | d9bce9d9 | j_mayer | { |
873 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
874 | 39dd32ee | aurel32 | tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]); |
875 | d9bce9d9 | j_mayer | gen_op_check_addc_64(); |
876 | d9bce9d9 | j_mayer | gen_op_check_addo_64(); |
877 | d9bce9d9 | j_mayer | } |
878 | d9bce9d9 | j_mayer | #endif
|
879 | d9bce9d9 | j_mayer | GEN_INT_ARITH2_64 (addc, 0x1F, 0x0A, 0x00, PPC_INTEGER); |
880 | 79aceca5 | bellard | /* adde adde. addeo addeo. */
|
881 | b068d6a7 | j_mayer | static always_inline void gen_op_addeo (void) |
882 | d9bce9d9 | j_mayer | { |
883 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
884 | d9bce9d9 | j_mayer | gen_op_adde(); |
885 | d9bce9d9 | j_mayer | gen_op_check_addo(); |
886 | d9bce9d9 | j_mayer | } |
887 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
888 | b068d6a7 | j_mayer | static always_inline void gen_op_addeo_64 (void) |
889 | d9bce9d9 | j_mayer | { |
890 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
891 | d9bce9d9 | j_mayer | gen_op_adde_64(); |
892 | d9bce9d9 | j_mayer | gen_op_check_addo_64(); |
893 | d9bce9d9 | j_mayer | } |
894 | d9bce9d9 | j_mayer | #endif
|
895 | d9bce9d9 | j_mayer | GEN_INT_ARITH2_64 (adde, 0x1F, 0x0A, 0x04, PPC_INTEGER); |
896 | 79aceca5 | bellard | /* addme addme. addmeo addmeo. */
|
897 | b068d6a7 | j_mayer | static always_inline void gen_op_addme (void) |
898 | d9bce9d9 | j_mayer | { |
899 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_T[0]); |
900 | d9bce9d9 | j_mayer | gen_op_add_me(); |
901 | d9bce9d9 | j_mayer | } |
902 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
903 | b068d6a7 | j_mayer | static always_inline void gen_op_addme_64 (void) |
904 | d9bce9d9 | j_mayer | { |
905 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_T[0]); |
906 | d9bce9d9 | j_mayer | gen_op_add_me_64(); |
907 | d9bce9d9 | j_mayer | } |
908 | d9bce9d9 | j_mayer | #endif
|
909 | d9bce9d9 | j_mayer | GEN_INT_ARITH1_64 (addme, 0x1F, 0x0A, 0x07, PPC_INTEGER); |
910 | 79aceca5 | bellard | /* addze addze. addzeo addzeo. */
|
911 | b068d6a7 | j_mayer | static always_inline void gen_op_addze (void) |
912 | d9bce9d9 | j_mayer | { |
913 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
914 | d9bce9d9 | j_mayer | gen_op_add_ze(); |
915 | d9bce9d9 | j_mayer | gen_op_check_addc(); |
916 | d9bce9d9 | j_mayer | } |
917 | b068d6a7 | j_mayer | static always_inline void gen_op_addzeo (void) |
918 | d9bce9d9 | j_mayer | { |
919 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
920 | d9bce9d9 | j_mayer | gen_op_add_ze(); |
921 | d9bce9d9 | j_mayer | gen_op_check_addc(); |
922 | d9bce9d9 | j_mayer | gen_op_check_addo(); |
923 | d9bce9d9 | j_mayer | } |
924 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
925 | b068d6a7 | j_mayer | static always_inline void gen_op_addze_64 (void) |
926 | d9bce9d9 | j_mayer | { |
927 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
928 | d9bce9d9 | j_mayer | gen_op_add_ze(); |
929 | d9bce9d9 | j_mayer | gen_op_check_addc_64(); |
930 | d9bce9d9 | j_mayer | } |
931 | b068d6a7 | j_mayer | static always_inline void gen_op_addzeo_64 (void) |
932 | d9bce9d9 | j_mayer | { |
933 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
934 | d9bce9d9 | j_mayer | gen_op_add_ze(); |
935 | d9bce9d9 | j_mayer | gen_op_check_addc_64(); |
936 | d9bce9d9 | j_mayer | gen_op_check_addo_64(); |
937 | d9bce9d9 | j_mayer | } |
938 | d9bce9d9 | j_mayer | #endif
|
939 | d9bce9d9 | j_mayer | GEN_INT_ARITH1_64 (addze, 0x1F, 0x0A, 0x06, PPC_INTEGER); |
940 | 79aceca5 | bellard | /* divw divw. divwo divwo. */
|
941 | d9bce9d9 | j_mayer | GEN_INT_ARITH2 (divw, 0x1F, 0x0B, 0x0F, PPC_INTEGER); |
942 | 79aceca5 | bellard | /* divwu divwu. divwuo divwuo. */
|
943 | d9bce9d9 | j_mayer | GEN_INT_ARITH2 (divwu, 0x1F, 0x0B, 0x0E, PPC_INTEGER); |
944 | 79aceca5 | bellard | /* mulhw mulhw. */
|
945 | d9bce9d9 | j_mayer | GEN_INT_ARITHN (mulhw, 0x1F, 0x0B, 0x02, PPC_INTEGER); |
946 | 79aceca5 | bellard | /* mulhwu mulhwu. */
|
947 | d9bce9d9 | j_mayer | GEN_INT_ARITHN (mulhwu, 0x1F, 0x0B, 0x00, PPC_INTEGER); |
948 | 79aceca5 | bellard | /* mullw mullw. mullwo mullwo. */
|
949 | d9bce9d9 | j_mayer | GEN_INT_ARITH2 (mullw, 0x1F, 0x0B, 0x07, PPC_INTEGER); |
950 | 79aceca5 | bellard | /* neg neg. nego nego. */
|
951 | d9bce9d9 | j_mayer | GEN_INT_ARITH1_64 (neg, 0x1F, 0x08, 0x03, PPC_INTEGER); |
952 | 79aceca5 | bellard | /* subf subf. subfo subfo. */
|
953 | b068d6a7 | j_mayer | static always_inline void gen_op_subfo (void) |
954 | d9bce9d9 | j_mayer | { |
955 | f0413473 | aurel32 | tcg_gen_not_tl(cpu_T[2], cpu_T[0]); |
956 | d9bce9d9 | j_mayer | gen_op_subf(); |
957 | c3e10c7b | j_mayer | gen_op_check_addo(); |
958 | d9bce9d9 | j_mayer | } |
959 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
960 | d9bce9d9 | j_mayer | #define gen_op_subf_64 gen_op_subf
|
961 | b068d6a7 | j_mayer | static always_inline void gen_op_subfo_64 (void) |
962 | d9bce9d9 | j_mayer | { |
963 | f0413473 | aurel32 | tcg_gen_not_i64(cpu_T[2], cpu_T[0]); |
964 | d9bce9d9 | j_mayer | gen_op_subf(); |
965 | c3e10c7b | j_mayer | gen_op_check_addo_64(); |
966 | d9bce9d9 | j_mayer | } |
967 | d9bce9d9 | j_mayer | #endif
|
968 | d9bce9d9 | j_mayer | GEN_INT_ARITH2_64 (subf, 0x1F, 0x08, 0x01, PPC_INTEGER); |
969 | 79aceca5 | bellard | /* subfc subfc. subfco subfco. */
|
970 | b068d6a7 | j_mayer | static always_inline void gen_op_subfc (void) |
971 | d9bce9d9 | j_mayer | { |
972 | d9bce9d9 | j_mayer | gen_op_subf(); |
973 | d9bce9d9 | j_mayer | gen_op_check_subfc(); |
974 | d9bce9d9 | j_mayer | } |
975 | b068d6a7 | j_mayer | static always_inline void gen_op_subfco (void) |
976 | d9bce9d9 | j_mayer | { |
977 | f0413473 | aurel32 | tcg_gen_not_tl(cpu_T[2], cpu_T[0]); |
978 | d9bce9d9 | j_mayer | gen_op_subf(); |
979 | d9bce9d9 | j_mayer | gen_op_check_subfc(); |
980 | c3e10c7b | j_mayer | gen_op_check_addo(); |
981 | d9bce9d9 | j_mayer | } |
982 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
983 | b068d6a7 | j_mayer | static always_inline void gen_op_subfc_64 (void) |
984 | d9bce9d9 | j_mayer | { |
985 | d9bce9d9 | j_mayer | gen_op_subf(); |
986 | d9bce9d9 | j_mayer | gen_op_check_subfc_64(); |
987 | d9bce9d9 | j_mayer | } |
988 | b068d6a7 | j_mayer | static always_inline void gen_op_subfco_64 (void) |
989 | d9bce9d9 | j_mayer | { |
990 | f0413473 | aurel32 | tcg_gen_not_i64(cpu_T[2], cpu_T[0]); |
991 | d9bce9d9 | j_mayer | gen_op_subf(); |
992 | d9bce9d9 | j_mayer | gen_op_check_subfc_64(); |
993 | c3e10c7b | j_mayer | gen_op_check_addo_64(); |
994 | d9bce9d9 | j_mayer | } |
995 | d9bce9d9 | j_mayer | #endif
|
996 | d9bce9d9 | j_mayer | GEN_INT_ARITH2_64 (subfc, 0x1F, 0x08, 0x00, PPC_INTEGER); |
997 | 79aceca5 | bellard | /* subfe subfe. subfeo subfeo. */
|
998 | b068d6a7 | j_mayer | static always_inline void gen_op_subfeo (void) |
999 | d9bce9d9 | j_mayer | { |
1000 | f0413473 | aurel32 | tcg_gen_not_tl(cpu_T[2], cpu_T[0]); |
1001 | d9bce9d9 | j_mayer | gen_op_subfe(); |
1002 | c3e10c7b | j_mayer | gen_op_check_addo(); |
1003 | d9bce9d9 | j_mayer | } |
1004 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1005 | d9bce9d9 | j_mayer | #define gen_op_subfe_64 gen_op_subfe
|
1006 | b068d6a7 | j_mayer | static always_inline void gen_op_subfeo_64 (void) |
1007 | d9bce9d9 | j_mayer | { |
1008 | f0413473 | aurel32 | tcg_gen_not_i64(cpu_T[2], cpu_T[0]); |
1009 | d9bce9d9 | j_mayer | gen_op_subfe_64(); |
1010 | c3e10c7b | j_mayer | gen_op_check_addo_64(); |
1011 | d9bce9d9 | j_mayer | } |
1012 | d9bce9d9 | j_mayer | #endif
|
1013 | d9bce9d9 | j_mayer | GEN_INT_ARITH2_64 (subfe, 0x1F, 0x08, 0x04, PPC_INTEGER); |
1014 | 79aceca5 | bellard | /* subfme subfme. subfmeo subfmeo. */
|
1015 | d9bce9d9 | j_mayer | GEN_INT_ARITH1_64 (subfme, 0x1F, 0x08, 0x07, PPC_INTEGER); |
1016 | 79aceca5 | bellard | /* subfze subfze. subfzeo subfzeo. */
|
1017 | d9bce9d9 | j_mayer | GEN_INT_ARITH1_64 (subfze, 0x1F, 0x08, 0x06, PPC_INTEGER); |
1018 | 79aceca5 | bellard | /* addi */
|
1019 | 79aceca5 | bellard | GEN_HANDLER(addi, 0x0E, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1020 | 79aceca5 | bellard | { |
1021 | 76a66253 | j_mayer | target_long simm = SIMM(ctx->opcode); |
1022 | 79aceca5 | bellard | |
1023 | 79aceca5 | bellard | if (rA(ctx->opcode) == 0) { |
1024 | 76a66253 | j_mayer | /* li case */
|
1025 | 02f4f6c2 | aurel32 | tcg_gen_movi_tl(cpu_T[0], simm);
|
1026 | 79aceca5 | bellard | } else {
|
1027 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
1028 | 76a66253 | j_mayer | if (likely(simm != 0)) |
1029 | 39dd32ee | aurel32 | tcg_gen_addi_tl(cpu_T[0], cpu_T[0], simm); |
1030 | 79aceca5 | bellard | } |
1031 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
1032 | 79aceca5 | bellard | } |
1033 | 79aceca5 | bellard | /* addic */
|
1034 | 79aceca5 | bellard | GEN_HANDLER(addic, 0x0C, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1035 | 79aceca5 | bellard | { |
1036 | 76a66253 | j_mayer | target_long simm = SIMM(ctx->opcode); |
1037 | 76a66253 | j_mayer | |
1038 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
1039 | d9bce9d9 | j_mayer | if (likely(simm != 0)) { |
1040 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
1041 | 39dd32ee | aurel32 | tcg_gen_addi_tl(cpu_T[0], cpu_T[0], simm); |
1042 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1043 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
1044 | d9bce9d9 | j_mayer | gen_op_check_addc_64(); |
1045 | d9bce9d9 | j_mayer | else
|
1046 | d9bce9d9 | j_mayer | #endif
|
1047 | d9bce9d9 | j_mayer | gen_op_check_addc(); |
1048 | e864cabd | j_mayer | } else {
|
1049 | e864cabd | j_mayer | gen_op_clear_xer_ca(); |
1050 | d9bce9d9 | j_mayer | } |
1051 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
1052 | 79aceca5 | bellard | } |
1053 | 79aceca5 | bellard | /* addic. */
|
1054 | c7697e1f | j_mayer | GEN_HANDLER2(addic_, "addic.", 0x0D, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1055 | 79aceca5 | bellard | { |
1056 | 76a66253 | j_mayer | target_long simm = SIMM(ctx->opcode); |
1057 | 76a66253 | j_mayer | |
1058 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
1059 | d9bce9d9 | j_mayer | if (likely(simm != 0)) { |
1060 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_T[0]); |
1061 | 39dd32ee | aurel32 | tcg_gen_addi_tl(cpu_T[0], cpu_T[0], simm); |
1062 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1063 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
1064 | d9bce9d9 | j_mayer | gen_op_check_addc_64(); |
1065 | d9bce9d9 | j_mayer | else
|
1066 | d9bce9d9 | j_mayer | #endif
|
1067 | d9bce9d9 | j_mayer | gen_op_check_addc(); |
1068 | 966439a6 | j_mayer | } else {
|
1069 | 966439a6 | j_mayer | gen_op_clear_xer_ca(); |
1070 | d9bce9d9 | j_mayer | } |
1071 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
1072 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1073 | 79aceca5 | bellard | } |
1074 | 79aceca5 | bellard | /* addis */
|
1075 | 79aceca5 | bellard | GEN_HANDLER(addis, 0x0F, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1076 | 79aceca5 | bellard | { |
1077 | 76a66253 | j_mayer | target_long simm = SIMM(ctx->opcode); |
1078 | 79aceca5 | bellard | |
1079 | 79aceca5 | bellard | if (rA(ctx->opcode) == 0) { |
1080 | 76a66253 | j_mayer | /* lis case */
|
1081 | 02f4f6c2 | aurel32 | tcg_gen_movi_tl(cpu_T[0], simm << 16); |
1082 | 79aceca5 | bellard | } else {
|
1083 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
1084 | 76a66253 | j_mayer | if (likely(simm != 0)) |
1085 | 39dd32ee | aurel32 | tcg_gen_addi_tl(cpu_T[0], cpu_T[0], simm << 16); |
1086 | 79aceca5 | bellard | } |
1087 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
1088 | 79aceca5 | bellard | } |
1089 | 79aceca5 | bellard | /* mulli */
|
1090 | 79aceca5 | bellard | GEN_HANDLER(mulli, 0x07, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1091 | 79aceca5 | bellard | { |
1092 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
1093 | 79aceca5 | bellard | gen_op_mulli(SIMM(ctx->opcode)); |
1094 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
1095 | 79aceca5 | bellard | } |
1096 | 79aceca5 | bellard | /* subfic */
|
1097 | 79aceca5 | bellard | GEN_HANDLER(subfic, 0x08, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1098 | 79aceca5 | bellard | { |
1099 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
1100 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1101 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
1102 | d9bce9d9 | j_mayer | gen_op_subfic_64(SIMM(ctx->opcode)); |
1103 | d9bce9d9 | j_mayer | else
|
1104 | d9bce9d9 | j_mayer | #endif
|
1105 | d9bce9d9 | j_mayer | gen_op_subfic(SIMM(ctx->opcode)); |
1106 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
1107 | 79aceca5 | bellard | } |
1108 | 79aceca5 | bellard | |
1109 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1110 | d9bce9d9 | j_mayer | /* mulhd mulhd. */
|
1111 | a750fc0b | j_mayer | GEN_INT_ARITHN (mulhd, 0x1F, 0x09, 0x02, PPC_64B); |
1112 | d9bce9d9 | j_mayer | /* mulhdu mulhdu. */
|
1113 | a750fc0b | j_mayer | GEN_INT_ARITHN (mulhdu, 0x1F, 0x09, 0x00, PPC_64B); |
1114 | d9bce9d9 | j_mayer | /* mulld mulld. mulldo mulldo. */
|
1115 | a750fc0b | j_mayer | GEN_INT_ARITH2 (mulld, 0x1F, 0x09, 0x07, PPC_64B); |
1116 | d9bce9d9 | j_mayer | /* divd divd. divdo divdo. */
|
1117 | a750fc0b | j_mayer | GEN_INT_ARITH2 (divd, 0x1F, 0x09, 0x0F, PPC_64B); |
1118 | d9bce9d9 | j_mayer | /* divdu divdu. divduo divduo. */
|
1119 | a750fc0b | j_mayer | GEN_INT_ARITH2 (divdu, 0x1F, 0x09, 0x0E, PPC_64B); |
1120 | d9bce9d9 | j_mayer | #endif
|
1121 | d9bce9d9 | j_mayer | |
1122 | 79aceca5 | bellard | /*** Integer comparison ***/
|
1123 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1124 | d9bce9d9 | j_mayer | #define GEN_CMP(name, opc, type) \
|
1125 | d9bce9d9 | j_mayer | GEN_HANDLER(name, 0x1F, 0x00, opc, 0x00400000, type) \ |
1126 | d9bce9d9 | j_mayer | { \ |
1127 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
1128 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]); \
|
1129 | e3878283 | j_mayer | if (ctx->sf_mode && (ctx->opcode & 0x00200000)) \ |
1130 | d9bce9d9 | j_mayer | gen_op_##name##_64(); \ |
1131 | d9bce9d9 | j_mayer | else \
|
1132 | d9bce9d9 | j_mayer | gen_op_##name(); \ |
1133 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_T[0], 0xf); \ |
1134 | d9bce9d9 | j_mayer | } |
1135 | d9bce9d9 | j_mayer | #else
|
1136 | d9bce9d9 | j_mayer | #define GEN_CMP(name, opc, type) \
|
1137 | d9bce9d9 | j_mayer | GEN_HANDLER(name, 0x1F, 0x00, opc, 0x00400000, type) \ |
1138 | 79aceca5 | bellard | { \ |
1139 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); \
|
1140 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]); \
|
1141 | 79aceca5 | bellard | gen_op_##name(); \ |
1142 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_T[0], 0xf); \ |
1143 | 79aceca5 | bellard | } |
1144 | d9bce9d9 | j_mayer | #endif
|
1145 | 79aceca5 | bellard | |
1146 | 79aceca5 | bellard | /* cmp */
|
1147 | d9bce9d9 | j_mayer | GEN_CMP(cmp, 0x00, PPC_INTEGER);
|
1148 | 79aceca5 | bellard | /* cmpi */
|
1149 | 79aceca5 | bellard | GEN_HANDLER(cmpi, 0x0B, 0xFF, 0xFF, 0x00400000, PPC_INTEGER) |
1150 | 79aceca5 | bellard | { |
1151 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
1152 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1153 | e3878283 | j_mayer | if (ctx->sf_mode && (ctx->opcode & 0x00200000)) |
1154 | d9bce9d9 | j_mayer | gen_op_cmpi_64(SIMM(ctx->opcode)); |
1155 | d9bce9d9 | j_mayer | else
|
1156 | d9bce9d9 | j_mayer | #endif
|
1157 | d9bce9d9 | j_mayer | gen_op_cmpi(SIMM(ctx->opcode)); |
1158 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_T[0], 0xf); |
1159 | 79aceca5 | bellard | } |
1160 | 79aceca5 | bellard | /* cmpl */
|
1161 | d9bce9d9 | j_mayer | GEN_CMP(cmpl, 0x01, PPC_INTEGER);
|
1162 | 79aceca5 | bellard | /* cmpli */
|
1163 | 79aceca5 | bellard | GEN_HANDLER(cmpli, 0x0A, 0xFF, 0xFF, 0x00400000, PPC_INTEGER) |
1164 | 79aceca5 | bellard | { |
1165 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
1166 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1167 | e3878283 | j_mayer | if (ctx->sf_mode && (ctx->opcode & 0x00200000)) |
1168 | d9bce9d9 | j_mayer | gen_op_cmpli_64(UIMM(ctx->opcode)); |
1169 | d9bce9d9 | j_mayer | else
|
1170 | d9bce9d9 | j_mayer | #endif
|
1171 | d9bce9d9 | j_mayer | gen_op_cmpli(UIMM(ctx->opcode)); |
1172 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_T[0], 0xf); |
1173 | 79aceca5 | bellard | } |
1174 | 79aceca5 | bellard | |
1175 | d9bce9d9 | j_mayer | /* isel (PowerPC 2.03 specification) */
|
1176 | fd501a05 | aurel32 | GEN_HANDLER(isel, 0x1F, 0x0F, 0xFF, 0x00000001, PPC_ISEL) |
1177 | d9bce9d9 | j_mayer | { |
1178 | d9bce9d9 | j_mayer | uint32_t bi = rC(ctx->opcode); |
1179 | d9bce9d9 | j_mayer | uint32_t mask; |
1180 | d9bce9d9 | j_mayer | |
1181 | d9bce9d9 | j_mayer | if (rA(ctx->opcode) == 0) { |
1182 | 02f4f6c2 | aurel32 | tcg_gen_movi_tl(cpu_T[0], 0); |
1183 | d9bce9d9 | j_mayer | } else {
|
1184 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rA(ctx->opcode)]);
|
1185 | d9bce9d9 | j_mayer | } |
1186 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_gpr[rB(ctx->opcode)]);
|
1187 | d9bce9d9 | j_mayer | mask = 1 << (3 - (bi & 0x03)); |
1188 | 47e4661c | aurel32 | tcg_gen_mov_i32(cpu_T[0], cpu_crf[bi >> 2]); |
1189 | d9bce9d9 | j_mayer | gen_op_test_true(mask); |
1190 | d9bce9d9 | j_mayer | gen_op_isel(); |
1191 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
1192 | d9bce9d9 | j_mayer | } |
1193 | d9bce9d9 | j_mayer | |
1194 | 79aceca5 | bellard | /*** Integer logical ***/
|
1195 | d9bce9d9 | j_mayer | #define __GEN_LOGICAL2(name, opc2, opc3, type) \
|
1196 | d9bce9d9 | j_mayer | GEN_HANDLER(name, 0x1F, opc2, opc3, 0x00000000, type) \ |
1197 | 79aceca5 | bellard | { \ |
1198 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]); \
|
1199 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]); \
|
1200 | 79aceca5 | bellard | gen_op_##name(); \ |
1201 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
1202 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
1203 | 76a66253 | j_mayer | gen_set_Rc0(ctx); \ |
1204 | 79aceca5 | bellard | } |
1205 | d9bce9d9 | j_mayer | #define GEN_LOGICAL2(name, opc, type) \
|
1206 | d9bce9d9 | j_mayer | __GEN_LOGICAL2(name, 0x1C, opc, type)
|
1207 | 79aceca5 | bellard | |
1208 | d9bce9d9 | j_mayer | #define GEN_LOGICAL1(name, opc, type) \
|
1209 | d9bce9d9 | j_mayer | GEN_HANDLER(name, 0x1F, 0x1A, opc, 0x00000000, type) \ |
1210 | 79aceca5 | bellard | { \ |
1211 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]); \
|
1212 | 79aceca5 | bellard | gen_op_##name(); \ |
1213 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
1214 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) \ |
1215 | 76a66253 | j_mayer | gen_set_Rc0(ctx); \ |
1216 | 79aceca5 | bellard | } |
1217 | 79aceca5 | bellard | |
1218 | 79aceca5 | bellard | /* and & and. */
|
1219 | d9bce9d9 | j_mayer | GEN_LOGICAL2(and, 0x00, PPC_INTEGER);
|
1220 | 79aceca5 | bellard | /* andc & andc. */
|
1221 | d9bce9d9 | j_mayer | GEN_LOGICAL2(andc, 0x01, PPC_INTEGER);
|
1222 | 79aceca5 | bellard | /* andi. */
|
1223 | c7697e1f | j_mayer | GEN_HANDLER2(andi_, "andi.", 0x1C, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1224 | 79aceca5 | bellard | { |
1225 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1226 | 76a66253 | j_mayer | gen_op_andi_T0(UIMM(ctx->opcode)); |
1227 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1228 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1229 | 79aceca5 | bellard | } |
1230 | 79aceca5 | bellard | /* andis. */
|
1231 | c7697e1f | j_mayer | GEN_HANDLER2(andis_, "andis.", 0x1D, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1232 | 79aceca5 | bellard | { |
1233 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1234 | 76a66253 | j_mayer | gen_op_andi_T0(UIMM(ctx->opcode) << 16);
|
1235 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1236 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1237 | 79aceca5 | bellard | } |
1238 | 79aceca5 | bellard | |
1239 | 79aceca5 | bellard | /* cntlzw */
|
1240 | d9bce9d9 | j_mayer | GEN_LOGICAL1(cntlzw, 0x00, PPC_INTEGER);
|
1241 | 79aceca5 | bellard | /* eqv & eqv. */
|
1242 | d9bce9d9 | j_mayer | GEN_LOGICAL2(eqv, 0x08, PPC_INTEGER);
|
1243 | 79aceca5 | bellard | /* extsb & extsb. */
|
1244 | d9bce9d9 | j_mayer | GEN_LOGICAL1(extsb, 0x1D, PPC_INTEGER);
|
1245 | 79aceca5 | bellard | /* extsh & extsh. */
|
1246 | d9bce9d9 | j_mayer | GEN_LOGICAL1(extsh, 0x1C, PPC_INTEGER);
|
1247 | 79aceca5 | bellard | /* nand & nand. */
|
1248 | d9bce9d9 | j_mayer | GEN_LOGICAL2(nand, 0x0E, PPC_INTEGER);
|
1249 | 79aceca5 | bellard | /* nor & nor. */
|
1250 | d9bce9d9 | j_mayer | GEN_LOGICAL2(nor, 0x03, PPC_INTEGER);
|
1251 | 9a64fbe4 | bellard | |
1252 | 79aceca5 | bellard | /* or & or. */
|
1253 | 9a64fbe4 | bellard | GEN_HANDLER(or, 0x1F, 0x1C, 0x0D, 0x00000000, PPC_INTEGER) |
1254 | 9a64fbe4 | bellard | { |
1255 | 76a66253 | j_mayer | int rs, ra, rb;
|
1256 | 76a66253 | j_mayer | |
1257 | 76a66253 | j_mayer | rs = rS(ctx->opcode); |
1258 | 76a66253 | j_mayer | ra = rA(ctx->opcode); |
1259 | 76a66253 | j_mayer | rb = rB(ctx->opcode); |
1260 | 76a66253 | j_mayer | /* Optimisation for mr. ri case */
|
1261 | 76a66253 | j_mayer | if (rs != ra || rs != rb) {
|
1262 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rs]);
|
1263 | 76a66253 | j_mayer | if (rs != rb) {
|
1264 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rb]);
|
1265 | 76a66253 | j_mayer | gen_op_or(); |
1266 | 76a66253 | j_mayer | } |
1267 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[ra], cpu_T[0]);
|
1268 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1269 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1270 | 76a66253 | j_mayer | } else if (unlikely(Rc(ctx->opcode) != 0)) { |
1271 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rs]);
|
1272 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1273 | c80f84e3 | j_mayer | #if defined(TARGET_PPC64)
|
1274 | c80f84e3 | j_mayer | } else {
|
1275 | c80f84e3 | j_mayer | switch (rs) {
|
1276 | c80f84e3 | j_mayer | case 1: |
1277 | c80f84e3 | j_mayer | /* Set process priority to low */
|
1278 | c80f84e3 | j_mayer | gen_op_store_pri(2);
|
1279 | c80f84e3 | j_mayer | break;
|
1280 | c80f84e3 | j_mayer | case 6: |
1281 | c80f84e3 | j_mayer | /* Set process priority to medium-low */
|
1282 | c80f84e3 | j_mayer | gen_op_store_pri(3);
|
1283 | c80f84e3 | j_mayer | break;
|
1284 | c80f84e3 | j_mayer | case 2: |
1285 | c80f84e3 | j_mayer | /* Set process priority to normal */
|
1286 | c80f84e3 | j_mayer | gen_op_store_pri(4);
|
1287 | c80f84e3 | j_mayer | break;
|
1288 | be147d08 | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
1289 | be147d08 | j_mayer | case 31: |
1290 | be147d08 | j_mayer | if (ctx->supervisor > 0) { |
1291 | be147d08 | j_mayer | /* Set process priority to very low */
|
1292 | be147d08 | j_mayer | gen_op_store_pri(1);
|
1293 | be147d08 | j_mayer | } |
1294 | be147d08 | j_mayer | break;
|
1295 | be147d08 | j_mayer | case 5: |
1296 | be147d08 | j_mayer | if (ctx->supervisor > 0) { |
1297 | be147d08 | j_mayer | /* Set process priority to medium-hight */
|
1298 | be147d08 | j_mayer | gen_op_store_pri(5);
|
1299 | be147d08 | j_mayer | } |
1300 | be147d08 | j_mayer | break;
|
1301 | be147d08 | j_mayer | case 3: |
1302 | be147d08 | j_mayer | if (ctx->supervisor > 0) { |
1303 | be147d08 | j_mayer | /* Set process priority to high */
|
1304 | be147d08 | j_mayer | gen_op_store_pri(6);
|
1305 | be147d08 | j_mayer | } |
1306 | be147d08 | j_mayer | break;
|
1307 | be147d08 | j_mayer | case 7: |
1308 | be147d08 | j_mayer | if (ctx->supervisor > 1) { |
1309 | be147d08 | j_mayer | /* Set process priority to very high */
|
1310 | be147d08 | j_mayer | gen_op_store_pri(7);
|
1311 | be147d08 | j_mayer | } |
1312 | be147d08 | j_mayer | break;
|
1313 | be147d08 | j_mayer | #endif
|
1314 | c80f84e3 | j_mayer | default:
|
1315 | c80f84e3 | j_mayer | /* nop */
|
1316 | c80f84e3 | j_mayer | break;
|
1317 | c80f84e3 | j_mayer | } |
1318 | c80f84e3 | j_mayer | #endif
|
1319 | 9a64fbe4 | bellard | } |
1320 | 9a64fbe4 | bellard | } |
1321 | 9a64fbe4 | bellard | |
1322 | 79aceca5 | bellard | /* orc & orc. */
|
1323 | d9bce9d9 | j_mayer | GEN_LOGICAL2(orc, 0x0C, PPC_INTEGER);
|
1324 | 79aceca5 | bellard | /* xor & xor. */
|
1325 | 9a64fbe4 | bellard | GEN_HANDLER(xor, 0x1F, 0x1C, 0x09, 0x00000000, PPC_INTEGER) |
1326 | 9a64fbe4 | bellard | { |
1327 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1328 | 9a64fbe4 | bellard | /* Optimisation for "set to zero" case */
|
1329 | 9a64fbe4 | bellard | if (rS(ctx->opcode) != rB(ctx->opcode)) {
|
1330 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
1331 | 9a64fbe4 | bellard | gen_op_xor(); |
1332 | 9a64fbe4 | bellard | } else {
|
1333 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[0], 0); |
1334 | 9a64fbe4 | bellard | } |
1335 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1336 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1337 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1338 | 9a64fbe4 | bellard | } |
1339 | 79aceca5 | bellard | /* ori */
|
1340 | 79aceca5 | bellard | GEN_HANDLER(ori, 0x18, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1341 | 79aceca5 | bellard | { |
1342 | 76a66253 | j_mayer | target_ulong uimm = UIMM(ctx->opcode); |
1343 | 79aceca5 | bellard | |
1344 | 9a64fbe4 | bellard | if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) { |
1345 | 9a64fbe4 | bellard | /* NOP */
|
1346 | 76a66253 | j_mayer | /* XXX: should handle special NOPs for POWER series */
|
1347 | 9a64fbe4 | bellard | return;
|
1348 | 76a66253 | j_mayer | } |
1349 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1350 | 76a66253 | j_mayer | if (likely(uimm != 0)) |
1351 | 79aceca5 | bellard | gen_op_ori(uimm); |
1352 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1353 | 79aceca5 | bellard | } |
1354 | 79aceca5 | bellard | /* oris */
|
1355 | 79aceca5 | bellard | GEN_HANDLER(oris, 0x19, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1356 | 79aceca5 | bellard | { |
1357 | 76a66253 | j_mayer | target_ulong uimm = UIMM(ctx->opcode); |
1358 | 79aceca5 | bellard | |
1359 | 9a64fbe4 | bellard | if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) { |
1360 | 9a64fbe4 | bellard | /* NOP */
|
1361 | 9a64fbe4 | bellard | return;
|
1362 | 76a66253 | j_mayer | } |
1363 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1364 | 76a66253 | j_mayer | if (likely(uimm != 0)) |
1365 | 79aceca5 | bellard | gen_op_ori(uimm << 16);
|
1366 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1367 | 79aceca5 | bellard | } |
1368 | 79aceca5 | bellard | /* xori */
|
1369 | 79aceca5 | bellard | GEN_HANDLER(xori, 0x1A, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1370 | 79aceca5 | bellard | { |
1371 | 76a66253 | j_mayer | target_ulong uimm = UIMM(ctx->opcode); |
1372 | 9a64fbe4 | bellard | |
1373 | 9a64fbe4 | bellard | if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) { |
1374 | 9a64fbe4 | bellard | /* NOP */
|
1375 | 9a64fbe4 | bellard | return;
|
1376 | 9a64fbe4 | bellard | } |
1377 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1378 | 76a66253 | j_mayer | if (likely(uimm != 0)) |
1379 | 76a66253 | j_mayer | gen_op_xori(uimm); |
1380 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1381 | 79aceca5 | bellard | } |
1382 | 79aceca5 | bellard | |
1383 | 79aceca5 | bellard | /* xoris */
|
1384 | 79aceca5 | bellard | GEN_HANDLER(xoris, 0x1B, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1385 | 79aceca5 | bellard | { |
1386 | 76a66253 | j_mayer | target_ulong uimm = UIMM(ctx->opcode); |
1387 | 9a64fbe4 | bellard | |
1388 | 9a64fbe4 | bellard | if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) { |
1389 | 9a64fbe4 | bellard | /* NOP */
|
1390 | 9a64fbe4 | bellard | return;
|
1391 | 9a64fbe4 | bellard | } |
1392 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1393 | 76a66253 | j_mayer | if (likely(uimm != 0)) |
1394 | 76a66253 | j_mayer | gen_op_xori(uimm << 16);
|
1395 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1396 | 79aceca5 | bellard | } |
1397 | 79aceca5 | bellard | |
1398 | d9bce9d9 | j_mayer | /* popcntb : PowerPC 2.03 specification */
|
1399 | 05332d70 | j_mayer | GEN_HANDLER(popcntb, 0x1F, 0x03, 0x03, 0x0000F801, PPC_POPCNTB) |
1400 | d9bce9d9 | j_mayer | { |
1401 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1402 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1403 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
1404 | 6676f424 | aurel32 | gen_op_popcntb_64(); |
1405 | d9bce9d9 | j_mayer | else
|
1406 | d9bce9d9 | j_mayer | #endif
|
1407 | 6676f424 | aurel32 | gen_op_popcntb(); |
1408 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1409 | d9bce9d9 | j_mayer | } |
1410 | d9bce9d9 | j_mayer | |
1411 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1412 | d9bce9d9 | j_mayer | /* extsw & extsw. */
|
1413 | d9bce9d9 | j_mayer | GEN_LOGICAL1(extsw, 0x1E, PPC_64B);
|
1414 | d9bce9d9 | j_mayer | /* cntlzd */
|
1415 | d9bce9d9 | j_mayer | GEN_LOGICAL1(cntlzd, 0x01, PPC_64B);
|
1416 | d9bce9d9 | j_mayer | #endif
|
1417 | d9bce9d9 | j_mayer | |
1418 | 79aceca5 | bellard | /*** Integer rotate ***/
|
1419 | 79aceca5 | bellard | /* rlwimi & rlwimi. */
|
1420 | 79aceca5 | bellard | GEN_HANDLER(rlwimi, 0x14, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1421 | 79aceca5 | bellard | { |
1422 | 76a66253 | j_mayer | target_ulong mask; |
1423 | 76a66253 | j_mayer | uint32_t mb, me, sh; |
1424 | 79aceca5 | bellard | |
1425 | 79aceca5 | bellard | mb = MB(ctx->opcode); |
1426 | 79aceca5 | bellard | me = ME(ctx->opcode); |
1427 | 76a66253 | j_mayer | sh = SH(ctx->opcode); |
1428 | 76a66253 | j_mayer | if (likely(sh == 0)) { |
1429 | 76a66253 | j_mayer | if (likely(mb == 0 && me == 31)) { |
1430 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1431 | 76a66253 | j_mayer | goto do_store;
|
1432 | 76a66253 | j_mayer | } else if (likely(mb == 31 && me == 0)) { |
1433 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
1434 | 76a66253 | j_mayer | goto do_store;
|
1435 | 76a66253 | j_mayer | } |
1436 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1437 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rA(ctx->opcode)]);
|
1438 | 76a66253 | j_mayer | goto do_mask;
|
1439 | 76a66253 | j_mayer | } |
1440 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1441 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rA(ctx->opcode)]);
|
1442 | 76a66253 | j_mayer | gen_op_rotli32_T0(SH(ctx->opcode)); |
1443 | 76a66253 | j_mayer | do_mask:
|
1444 | 76a66253 | j_mayer | #if defined(TARGET_PPC64)
|
1445 | 76a66253 | j_mayer | mb += 32;
|
1446 | 76a66253 | j_mayer | me += 32;
|
1447 | 76a66253 | j_mayer | #endif
|
1448 | 76a66253 | j_mayer | mask = MASK(mb, me); |
1449 | 76a66253 | j_mayer | gen_op_andi_T0(mask); |
1450 | 76a66253 | j_mayer | gen_op_andi_T1(~mask); |
1451 | 76a66253 | j_mayer | gen_op_or(); |
1452 | 76a66253 | j_mayer | do_store:
|
1453 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1454 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1455 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1456 | 79aceca5 | bellard | } |
1457 | 79aceca5 | bellard | /* rlwinm & rlwinm. */
|
1458 | 79aceca5 | bellard | GEN_HANDLER(rlwinm, 0x15, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1459 | 79aceca5 | bellard | { |
1460 | 79aceca5 | bellard | uint32_t mb, me, sh; |
1461 | 3b46e624 | ths | |
1462 | 79aceca5 | bellard | sh = SH(ctx->opcode); |
1463 | 79aceca5 | bellard | mb = MB(ctx->opcode); |
1464 | 79aceca5 | bellard | me = ME(ctx->opcode); |
1465 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1466 | 76a66253 | j_mayer | if (likely(sh == 0)) { |
1467 | 76a66253 | j_mayer | goto do_mask;
|
1468 | 76a66253 | j_mayer | } |
1469 | 76a66253 | j_mayer | if (likely(mb == 0)) { |
1470 | 76a66253 | j_mayer | if (likely(me == 31)) { |
1471 | 76a66253 | j_mayer | gen_op_rotli32_T0(sh); |
1472 | 76a66253 | j_mayer | goto do_store;
|
1473 | 76a66253 | j_mayer | } else if (likely(me == (31 - sh))) { |
1474 | 76a66253 | j_mayer | gen_op_sli_T0(sh); |
1475 | 76a66253 | j_mayer | goto do_store;
|
1476 | 79aceca5 | bellard | } |
1477 | 76a66253 | j_mayer | } else if (likely(me == 31)) { |
1478 | 76a66253 | j_mayer | if (likely(sh == (32 - mb))) { |
1479 | 76a66253 | j_mayer | gen_op_srli_T0(mb); |
1480 | 76a66253 | j_mayer | goto do_store;
|
1481 | 79aceca5 | bellard | } |
1482 | 79aceca5 | bellard | } |
1483 | 76a66253 | j_mayer | gen_op_rotli32_T0(sh); |
1484 | 76a66253 | j_mayer | do_mask:
|
1485 | 76a66253 | j_mayer | #if defined(TARGET_PPC64)
|
1486 | 76a66253 | j_mayer | mb += 32;
|
1487 | 76a66253 | j_mayer | me += 32;
|
1488 | 76a66253 | j_mayer | #endif
|
1489 | 76a66253 | j_mayer | gen_op_andi_T0(MASK(mb, me)); |
1490 | 76a66253 | j_mayer | do_store:
|
1491 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1492 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1493 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1494 | 79aceca5 | bellard | } |
1495 | 79aceca5 | bellard | /* rlwnm & rlwnm. */
|
1496 | 79aceca5 | bellard | GEN_HANDLER(rlwnm, 0x17, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
1497 | 79aceca5 | bellard | { |
1498 | 79aceca5 | bellard | uint32_t mb, me; |
1499 | 79aceca5 | bellard | |
1500 | 79aceca5 | bellard | mb = MB(ctx->opcode); |
1501 | 79aceca5 | bellard | me = ME(ctx->opcode); |
1502 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1503 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
1504 | 76a66253 | j_mayer | gen_op_rotl32_T0_T1(); |
1505 | 76a66253 | j_mayer | if (unlikely(mb != 0 || me != 31)) { |
1506 | 76a66253 | j_mayer | #if defined(TARGET_PPC64)
|
1507 | 76a66253 | j_mayer | mb += 32;
|
1508 | 76a66253 | j_mayer | me += 32;
|
1509 | 76a66253 | j_mayer | #endif
|
1510 | 76a66253 | j_mayer | gen_op_andi_T0(MASK(mb, me)); |
1511 | 79aceca5 | bellard | } |
1512 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1513 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1514 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1515 | 79aceca5 | bellard | } |
1516 | 79aceca5 | bellard | |
1517 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1518 | d9bce9d9 | j_mayer | #define GEN_PPC64_R2(name, opc1, opc2) \
|
1519 | c7697e1f | j_mayer | GEN_HANDLER2(name##0, stringify(name), opc1, opc2, 0xFF, 0x00000000, PPC_64B) \ |
1520 | d9bce9d9 | j_mayer | { \ |
1521 | d9bce9d9 | j_mayer | gen_##name(ctx, 0); \ |
1522 | d9bce9d9 | j_mayer | } \ |
1523 | c7697e1f | j_mayer | GEN_HANDLER2(name##1, stringify(name), opc1, opc2 | 0x10, 0xFF, 0x00000000, \ |
1524 | c7697e1f | j_mayer | PPC_64B) \ |
1525 | d9bce9d9 | j_mayer | { \ |
1526 | d9bce9d9 | j_mayer | gen_##name(ctx, 1); \ |
1527 | d9bce9d9 | j_mayer | } |
1528 | d9bce9d9 | j_mayer | #define GEN_PPC64_R4(name, opc1, opc2) \
|
1529 | c7697e1f | j_mayer | GEN_HANDLER2(name##0, stringify(name), opc1, opc2, 0xFF, 0x00000000, PPC_64B) \ |
1530 | d9bce9d9 | j_mayer | { \ |
1531 | d9bce9d9 | j_mayer | gen_##name(ctx, 0, 0); \ |
1532 | d9bce9d9 | j_mayer | } \ |
1533 | c7697e1f | j_mayer | GEN_HANDLER2(name##1, stringify(name), opc1, opc2 | 0x01, 0xFF, 0x00000000, \ |
1534 | c7697e1f | j_mayer | PPC_64B) \ |
1535 | d9bce9d9 | j_mayer | { \ |
1536 | d9bce9d9 | j_mayer | gen_##name(ctx, 0, 1); \ |
1537 | d9bce9d9 | j_mayer | } \ |
1538 | c7697e1f | j_mayer | GEN_HANDLER2(name##2, stringify(name), opc1, opc2 | 0x10, 0xFF, 0x00000000, \ |
1539 | c7697e1f | j_mayer | PPC_64B) \ |
1540 | d9bce9d9 | j_mayer | { \ |
1541 | d9bce9d9 | j_mayer | gen_##name(ctx, 1, 0); \ |
1542 | d9bce9d9 | j_mayer | } \ |
1543 | c7697e1f | j_mayer | GEN_HANDLER2(name##3, stringify(name), opc1, opc2 | 0x11, 0xFF, 0x00000000, \ |
1544 | c7697e1f | j_mayer | PPC_64B) \ |
1545 | d9bce9d9 | j_mayer | { \ |
1546 | d9bce9d9 | j_mayer | gen_##name(ctx, 1, 1); \ |
1547 | d9bce9d9 | j_mayer | } |
1548 | 51789c41 | j_mayer | |
1549 | b068d6a7 | j_mayer | static always_inline void gen_andi_T0_64 (DisasContext *ctx, uint64_t mask) |
1550 | 40d0591e | j_mayer | { |
1551 | 40d0591e | j_mayer | if (mask >> 32) |
1552 | 40d0591e | j_mayer | gen_op_andi_T0_64(mask >> 32, mask & 0xFFFFFFFF); |
1553 | 40d0591e | j_mayer | else
|
1554 | 40d0591e | j_mayer | gen_op_andi_T0(mask); |
1555 | 40d0591e | j_mayer | } |
1556 | 40d0591e | j_mayer | |
1557 | b068d6a7 | j_mayer | static always_inline void gen_andi_T1_64 (DisasContext *ctx, uint64_t mask) |
1558 | 40d0591e | j_mayer | { |
1559 | 40d0591e | j_mayer | if (mask >> 32) |
1560 | 40d0591e | j_mayer | gen_op_andi_T1_64(mask >> 32, mask & 0xFFFFFFFF); |
1561 | 40d0591e | j_mayer | else
|
1562 | 40d0591e | j_mayer | gen_op_andi_T1(mask); |
1563 | 40d0591e | j_mayer | } |
1564 | 40d0591e | j_mayer | |
1565 | b068d6a7 | j_mayer | static always_inline void gen_rldinm (DisasContext *ctx, uint32_t mb, |
1566 | b068d6a7 | j_mayer | uint32_t me, uint32_t sh) |
1567 | 51789c41 | j_mayer | { |
1568 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1569 | 51789c41 | j_mayer | if (likely(sh == 0)) { |
1570 | 51789c41 | j_mayer | goto do_mask;
|
1571 | 51789c41 | j_mayer | } |
1572 | 51789c41 | j_mayer | if (likely(mb == 0)) { |
1573 | 51789c41 | j_mayer | if (likely(me == 63)) { |
1574 | 40d0591e | j_mayer | gen_op_rotli64_T0(sh); |
1575 | 51789c41 | j_mayer | goto do_store;
|
1576 | 51789c41 | j_mayer | } else if (likely(me == (63 - sh))) { |
1577 | 51789c41 | j_mayer | gen_op_sli_T0(sh); |
1578 | 51789c41 | j_mayer | goto do_store;
|
1579 | 51789c41 | j_mayer | } |
1580 | 51789c41 | j_mayer | } else if (likely(me == 63)) { |
1581 | 51789c41 | j_mayer | if (likely(sh == (64 - mb))) { |
1582 | 40d0591e | j_mayer | gen_op_srli_T0_64(mb); |
1583 | 51789c41 | j_mayer | goto do_store;
|
1584 | 51789c41 | j_mayer | } |
1585 | 51789c41 | j_mayer | } |
1586 | 51789c41 | j_mayer | gen_op_rotli64_T0(sh); |
1587 | 51789c41 | j_mayer | do_mask:
|
1588 | 40d0591e | j_mayer | gen_andi_T0_64(ctx, MASK(mb, me)); |
1589 | 51789c41 | j_mayer | do_store:
|
1590 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1591 | 51789c41 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1592 | 51789c41 | j_mayer | gen_set_Rc0(ctx); |
1593 | 51789c41 | j_mayer | } |
1594 | d9bce9d9 | j_mayer | /* rldicl - rldicl. */
|
1595 | b068d6a7 | j_mayer | static always_inline void gen_rldicl (DisasContext *ctx, int mbn, int shn) |
1596 | d9bce9d9 | j_mayer | { |
1597 | 51789c41 | j_mayer | uint32_t sh, mb; |
1598 | d9bce9d9 | j_mayer | |
1599 | 9d53c753 | j_mayer | sh = SH(ctx->opcode) | (shn << 5);
|
1600 | 9d53c753 | j_mayer | mb = MB(ctx->opcode) | (mbn << 5);
|
1601 | 51789c41 | j_mayer | gen_rldinm(ctx, mb, 63, sh);
|
1602 | d9bce9d9 | j_mayer | } |
1603 | 51789c41 | j_mayer | GEN_PPC64_R4(rldicl, 0x1E, 0x00); |
1604 | d9bce9d9 | j_mayer | /* rldicr - rldicr. */
|
1605 | b068d6a7 | j_mayer | static always_inline void gen_rldicr (DisasContext *ctx, int men, int shn) |
1606 | d9bce9d9 | j_mayer | { |
1607 | 51789c41 | j_mayer | uint32_t sh, me; |
1608 | d9bce9d9 | j_mayer | |
1609 | 9d53c753 | j_mayer | sh = SH(ctx->opcode) | (shn << 5);
|
1610 | 9d53c753 | j_mayer | me = MB(ctx->opcode) | (men << 5);
|
1611 | 51789c41 | j_mayer | gen_rldinm(ctx, 0, me, sh);
|
1612 | d9bce9d9 | j_mayer | } |
1613 | 51789c41 | j_mayer | GEN_PPC64_R4(rldicr, 0x1E, 0x02); |
1614 | d9bce9d9 | j_mayer | /* rldic - rldic. */
|
1615 | b068d6a7 | j_mayer | static always_inline void gen_rldic (DisasContext *ctx, int mbn, int shn) |
1616 | d9bce9d9 | j_mayer | { |
1617 | 51789c41 | j_mayer | uint32_t sh, mb; |
1618 | d9bce9d9 | j_mayer | |
1619 | 9d53c753 | j_mayer | sh = SH(ctx->opcode) | (shn << 5);
|
1620 | 9d53c753 | j_mayer | mb = MB(ctx->opcode) | (mbn << 5);
|
1621 | 51789c41 | j_mayer | gen_rldinm(ctx, mb, 63 - sh, sh);
|
1622 | 51789c41 | j_mayer | } |
1623 | 51789c41 | j_mayer | GEN_PPC64_R4(rldic, 0x1E, 0x04); |
1624 | 51789c41 | j_mayer | |
1625 | b068d6a7 | j_mayer | static always_inline void gen_rldnm (DisasContext *ctx, uint32_t mb, |
1626 | b068d6a7 | j_mayer | uint32_t me) |
1627 | 51789c41 | j_mayer | { |
1628 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1629 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
1630 | 51789c41 | j_mayer | gen_op_rotl64_T0_T1(); |
1631 | 51789c41 | j_mayer | if (unlikely(mb != 0 || me != 63)) { |
1632 | 40d0591e | j_mayer | gen_andi_T0_64(ctx, MASK(mb, me)); |
1633 | 51789c41 | j_mayer | } |
1634 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1635 | 51789c41 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1636 | 51789c41 | j_mayer | gen_set_Rc0(ctx); |
1637 | d9bce9d9 | j_mayer | } |
1638 | 51789c41 | j_mayer | |
1639 | d9bce9d9 | j_mayer | /* rldcl - rldcl. */
|
1640 | b068d6a7 | j_mayer | static always_inline void gen_rldcl (DisasContext *ctx, int mbn) |
1641 | d9bce9d9 | j_mayer | { |
1642 | 51789c41 | j_mayer | uint32_t mb; |
1643 | d9bce9d9 | j_mayer | |
1644 | 9d53c753 | j_mayer | mb = MB(ctx->opcode) | (mbn << 5);
|
1645 | 51789c41 | j_mayer | gen_rldnm(ctx, mb, 63);
|
1646 | d9bce9d9 | j_mayer | } |
1647 | 36081602 | j_mayer | GEN_PPC64_R2(rldcl, 0x1E, 0x08); |
1648 | d9bce9d9 | j_mayer | /* rldcr - rldcr. */
|
1649 | b068d6a7 | j_mayer | static always_inline void gen_rldcr (DisasContext *ctx, int men) |
1650 | d9bce9d9 | j_mayer | { |
1651 | 51789c41 | j_mayer | uint32_t me; |
1652 | d9bce9d9 | j_mayer | |
1653 | 9d53c753 | j_mayer | me = MB(ctx->opcode) | (men << 5);
|
1654 | 51789c41 | j_mayer | gen_rldnm(ctx, 0, me);
|
1655 | d9bce9d9 | j_mayer | } |
1656 | 36081602 | j_mayer | GEN_PPC64_R2(rldcr, 0x1E, 0x09); |
1657 | d9bce9d9 | j_mayer | /* rldimi - rldimi. */
|
1658 | b068d6a7 | j_mayer | static always_inline void gen_rldimi (DisasContext *ctx, int mbn, int shn) |
1659 | d9bce9d9 | j_mayer | { |
1660 | 51789c41 | j_mayer | uint64_t mask; |
1661 | 271a916e | j_mayer | uint32_t sh, mb, me; |
1662 | d9bce9d9 | j_mayer | |
1663 | 9d53c753 | j_mayer | sh = SH(ctx->opcode) | (shn << 5);
|
1664 | 9d53c753 | j_mayer | mb = MB(ctx->opcode) | (mbn << 5);
|
1665 | 271a916e | j_mayer | me = 63 - sh;
|
1666 | 51789c41 | j_mayer | if (likely(sh == 0)) { |
1667 | 51789c41 | j_mayer | if (likely(mb == 0)) { |
1668 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1669 | 51789c41 | j_mayer | goto do_store;
|
1670 | 51789c41 | j_mayer | } |
1671 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1672 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rA(ctx->opcode)]);
|
1673 | 51789c41 | j_mayer | goto do_mask;
|
1674 | 51789c41 | j_mayer | } |
1675 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1676 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rA(ctx->opcode)]);
|
1677 | 40d0591e | j_mayer | gen_op_rotli64_T0(sh); |
1678 | 51789c41 | j_mayer | do_mask:
|
1679 | 271a916e | j_mayer | mask = MASK(mb, me); |
1680 | 40d0591e | j_mayer | gen_andi_T0_64(ctx, mask); |
1681 | 40d0591e | j_mayer | gen_andi_T1_64(ctx, ~mask); |
1682 | 51789c41 | j_mayer | gen_op_or(); |
1683 | 51789c41 | j_mayer | do_store:
|
1684 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1685 | 51789c41 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1686 | 51789c41 | j_mayer | gen_set_Rc0(ctx); |
1687 | d9bce9d9 | j_mayer | } |
1688 | 36081602 | j_mayer | GEN_PPC64_R4(rldimi, 0x1E, 0x06); |
1689 | d9bce9d9 | j_mayer | #endif
|
1690 | d9bce9d9 | j_mayer | |
1691 | 79aceca5 | bellard | /*** Integer shift ***/
|
1692 | 79aceca5 | bellard | /* slw & slw. */
|
1693 | d9bce9d9 | j_mayer | __GEN_LOGICAL2(slw, 0x18, 0x00, PPC_INTEGER); |
1694 | 79aceca5 | bellard | /* sraw & sraw. */
|
1695 | d9bce9d9 | j_mayer | __GEN_LOGICAL2(sraw, 0x18, 0x18, PPC_INTEGER); |
1696 | 79aceca5 | bellard | /* srawi & srawi. */
|
1697 | 79aceca5 | bellard | GEN_HANDLER(srawi, 0x1F, 0x18, 0x19, 0x00000000, PPC_INTEGER) |
1698 | 79aceca5 | bellard | { |
1699 | d9bce9d9 | j_mayer | int mb, me;
|
1700 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1701 | d9bce9d9 | j_mayer | if (SH(ctx->opcode) != 0) { |
1702 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_T[0]); |
1703 | d9bce9d9 | j_mayer | mb = 32 - SH(ctx->opcode);
|
1704 | d9bce9d9 | j_mayer | me = 31;
|
1705 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1706 | d9bce9d9 | j_mayer | mb += 32;
|
1707 | d9bce9d9 | j_mayer | me += 32;
|
1708 | d9bce9d9 | j_mayer | #endif
|
1709 | d9bce9d9 | j_mayer | gen_op_srawi(SH(ctx->opcode), MASK(mb, me)); |
1710 | d9bce9d9 | j_mayer | } |
1711 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1712 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1713 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
1714 | 79aceca5 | bellard | } |
1715 | 79aceca5 | bellard | /* srw & srw. */
|
1716 | d9bce9d9 | j_mayer | __GEN_LOGICAL2(srw, 0x18, 0x10, PPC_INTEGER); |
1717 | d9bce9d9 | j_mayer | |
1718 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
1719 | d9bce9d9 | j_mayer | /* sld & sld. */
|
1720 | d9bce9d9 | j_mayer | __GEN_LOGICAL2(sld, 0x1B, 0x00, PPC_64B); |
1721 | d9bce9d9 | j_mayer | /* srad & srad. */
|
1722 | d9bce9d9 | j_mayer | __GEN_LOGICAL2(srad, 0x1A, 0x18, PPC_64B); |
1723 | d9bce9d9 | j_mayer | /* sradi & sradi. */
|
1724 | b068d6a7 | j_mayer | static always_inline void gen_sradi (DisasContext *ctx, int n) |
1725 | d9bce9d9 | j_mayer | { |
1726 | d9bce9d9 | j_mayer | uint64_t mask; |
1727 | d9bce9d9 | j_mayer | int sh, mb, me;
|
1728 | d9bce9d9 | j_mayer | |
1729 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
1730 | d9bce9d9 | j_mayer | sh = SH(ctx->opcode) + (n << 5);
|
1731 | d9bce9d9 | j_mayer | if (sh != 0) { |
1732 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_T[0]); |
1733 | d9bce9d9 | j_mayer | mb = 64 - SH(ctx->opcode);
|
1734 | d9bce9d9 | j_mayer | me = 63;
|
1735 | d9bce9d9 | j_mayer | mask = MASK(mb, me); |
1736 | d9bce9d9 | j_mayer | gen_op_sradi(sh, mask >> 32, mask);
|
1737 | d9bce9d9 | j_mayer | } |
1738 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
1739 | d9bce9d9 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
1740 | d9bce9d9 | j_mayer | gen_set_Rc0(ctx); |
1741 | d9bce9d9 | j_mayer | } |
1742 | c7697e1f | j_mayer | GEN_HANDLER2(sradi0, "sradi", 0x1F, 0x1A, 0x19, 0x00000000, PPC_64B) |
1743 | d9bce9d9 | j_mayer | { |
1744 | d9bce9d9 | j_mayer | gen_sradi(ctx, 0);
|
1745 | d9bce9d9 | j_mayer | } |
1746 | c7697e1f | j_mayer | GEN_HANDLER2(sradi1, "sradi", 0x1F, 0x1B, 0x19, 0x00000000, PPC_64B) |
1747 | d9bce9d9 | j_mayer | { |
1748 | d9bce9d9 | j_mayer | gen_sradi(ctx, 1);
|
1749 | d9bce9d9 | j_mayer | } |
1750 | d9bce9d9 | j_mayer | /* srd & srd. */
|
1751 | d9bce9d9 | j_mayer | __GEN_LOGICAL2(srd, 0x1B, 0x10, PPC_64B); |
1752 | d9bce9d9 | j_mayer | #endif
|
1753 | 79aceca5 | bellard | |
1754 | 79aceca5 | bellard | /*** Floating-Point arithmetic ***/
|
1755 | 7c58044c | j_mayer | #define _GEN_FLOAT_ACB(name, op, op1, op2, isfloat, set_fprf, type) \
|
1756 | a750fc0b | j_mayer | GEN_HANDLER(f##name, op1, op2, 0xFF, 0x00000000, type) \ |
1757 | 9a64fbe4 | bellard | { \ |
1758 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
1759 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
1760 | 3cc62370 | bellard | return; \
|
1761 | 3cc62370 | bellard | } \ |
1762 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rA(ctx->opcode)]); \
|
1763 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rC(ctx->opcode)]); \
|
1764 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[2], cpu_fpr[rB(ctx->opcode)]); \
|
1765 | 7c58044c | j_mayer | gen_reset_fpstatus(); \ |
1766 | 4ecc3190 | bellard | gen_op_f##op(); \ |
1767 | 4ecc3190 | bellard | if (isfloat) { \
|
1768 | 4ecc3190 | bellard | gen_op_frsp(); \ |
1769 | 4ecc3190 | bellard | } \ |
1770 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
|
1771 | 7c58044c | j_mayer | gen_compute_fprf(set_fprf, Rc(ctx->opcode) != 0); \
|
1772 | 9a64fbe4 | bellard | } |
1773 | 9a64fbe4 | bellard | |
1774 | 7c58044c | j_mayer | #define GEN_FLOAT_ACB(name, op2, set_fprf, type) \
|
1775 | 7c58044c | j_mayer | _GEN_FLOAT_ACB(name, name, 0x3F, op2, 0, set_fprf, type); \ |
1776 | 7c58044c | j_mayer | _GEN_FLOAT_ACB(name##s, name, 0x3B, op2, 1, set_fprf, type); |
1777 | 9a64fbe4 | bellard | |
1778 | 7c58044c | j_mayer | #define _GEN_FLOAT_AB(name, op, op1, op2, inval, isfloat, set_fprf, type) \
|
1779 | 7c58044c | j_mayer | GEN_HANDLER(f##name, op1, op2, 0xFF, inval, type) \ |
1780 | 9a64fbe4 | bellard | { \ |
1781 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
1782 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
1783 | 3cc62370 | bellard | return; \
|
1784 | 3cc62370 | bellard | } \ |
1785 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rA(ctx->opcode)]); \
|
1786 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rB(ctx->opcode)]); \
|
1787 | 7c58044c | j_mayer | gen_reset_fpstatus(); \ |
1788 | 4ecc3190 | bellard | gen_op_f##op(); \ |
1789 | 4ecc3190 | bellard | if (isfloat) { \
|
1790 | 4ecc3190 | bellard | gen_op_frsp(); \ |
1791 | 4ecc3190 | bellard | } \ |
1792 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
|
1793 | 7c58044c | j_mayer | gen_compute_fprf(set_fprf, Rc(ctx->opcode) != 0); \
|
1794 | 9a64fbe4 | bellard | } |
1795 | 7c58044c | j_mayer | #define GEN_FLOAT_AB(name, op2, inval, set_fprf, type) \
|
1796 | 7c58044c | j_mayer | _GEN_FLOAT_AB(name, name, 0x3F, op2, inval, 0, set_fprf, type); \ |
1797 | 7c58044c | j_mayer | _GEN_FLOAT_AB(name##s, name, 0x3B, op2, inval, 1, set_fprf, type); |
1798 | 9a64fbe4 | bellard | |
1799 | 7c58044c | j_mayer | #define _GEN_FLOAT_AC(name, op, op1, op2, inval, isfloat, set_fprf, type) \
|
1800 | 7c58044c | j_mayer | GEN_HANDLER(f##name, op1, op2, 0xFF, inval, type) \ |
1801 | 9a64fbe4 | bellard | { \ |
1802 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
1803 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
1804 | 3cc62370 | bellard | return; \
|
1805 | 3cc62370 | bellard | } \ |
1806 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rA(ctx->opcode)]); \
|
1807 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rC(ctx->opcode)]); \
|
1808 | 7c58044c | j_mayer | gen_reset_fpstatus(); \ |
1809 | 4ecc3190 | bellard | gen_op_f##op(); \ |
1810 | 4ecc3190 | bellard | if (isfloat) { \
|
1811 | 4ecc3190 | bellard | gen_op_frsp(); \ |
1812 | 4ecc3190 | bellard | } \ |
1813 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
|
1814 | 7c58044c | j_mayer | gen_compute_fprf(set_fprf, Rc(ctx->opcode) != 0); \
|
1815 | 9a64fbe4 | bellard | } |
1816 | 7c58044c | j_mayer | #define GEN_FLOAT_AC(name, op2, inval, set_fprf, type) \
|
1817 | 7c58044c | j_mayer | _GEN_FLOAT_AC(name, name, 0x3F, op2, inval, 0, set_fprf, type); \ |
1818 | 7c58044c | j_mayer | _GEN_FLOAT_AC(name##s, name, 0x3B, op2, inval, 1, set_fprf, type); |
1819 | 9a64fbe4 | bellard | |
1820 | 7c58044c | j_mayer | #define GEN_FLOAT_B(name, op2, op3, set_fprf, type) \
|
1821 | a750fc0b | j_mayer | GEN_HANDLER(f##name, 0x3F, op2, op3, 0x001F0000, type) \ |
1822 | 9a64fbe4 | bellard | { \ |
1823 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
1824 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
1825 | 3cc62370 | bellard | return; \
|
1826 | 3cc62370 | bellard | } \ |
1827 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rB(ctx->opcode)]); \
|
1828 | 7c58044c | j_mayer | gen_reset_fpstatus(); \ |
1829 | 9a64fbe4 | bellard | gen_op_f##name(); \ |
1830 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
|
1831 | 7c58044c | j_mayer | gen_compute_fprf(set_fprf, Rc(ctx->opcode) != 0); \
|
1832 | 79aceca5 | bellard | } |
1833 | 79aceca5 | bellard | |
1834 | 7c58044c | j_mayer | #define GEN_FLOAT_BS(name, op1, op2, set_fprf, type) \
|
1835 | a750fc0b | j_mayer | GEN_HANDLER(f##name, op1, op2, 0xFF, 0x001F07C0, type) \ |
1836 | 9a64fbe4 | bellard | { \ |
1837 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
1838 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
1839 | 3cc62370 | bellard | return; \
|
1840 | 3cc62370 | bellard | } \ |
1841 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rB(ctx->opcode)]); \
|
1842 | 7c58044c | j_mayer | gen_reset_fpstatus(); \ |
1843 | 9a64fbe4 | bellard | gen_op_f##name(); \ |
1844 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
|
1845 | 7c58044c | j_mayer | gen_compute_fprf(set_fprf, Rc(ctx->opcode) != 0); \
|
1846 | 79aceca5 | bellard | } |
1847 | 79aceca5 | bellard | |
1848 | 9a64fbe4 | bellard | /* fadd - fadds */
|
1849 | 7c58044c | j_mayer | GEN_FLOAT_AB(add, 0x15, 0x000007C0, 1, PPC_FLOAT); |
1850 | 4ecc3190 | bellard | /* fdiv - fdivs */
|
1851 | 7c58044c | j_mayer | GEN_FLOAT_AB(div, 0x12, 0x000007C0, 1, PPC_FLOAT); |
1852 | 4ecc3190 | bellard | /* fmul - fmuls */
|
1853 | 7c58044c | j_mayer | GEN_FLOAT_AC(mul, 0x19, 0x0000F800, 1, PPC_FLOAT); |
1854 | 79aceca5 | bellard | |
1855 | d7e4b87e | j_mayer | /* fre */
|
1856 | 7c58044c | j_mayer | GEN_FLOAT_BS(re, 0x3F, 0x18, 1, PPC_FLOAT_EXT); |
1857 | d7e4b87e | j_mayer | |
1858 | a750fc0b | j_mayer | /* fres */
|
1859 | 7c58044c | j_mayer | GEN_FLOAT_BS(res, 0x3B, 0x18, 1, PPC_FLOAT_FRES); |
1860 | 79aceca5 | bellard | |
1861 | a750fc0b | j_mayer | /* frsqrte */
|
1862 | 7c58044c | j_mayer | GEN_FLOAT_BS(rsqrte, 0x3F, 0x1A, 1, PPC_FLOAT_FRSQRTE); |
1863 | 7c58044c | j_mayer | |
1864 | 7c58044c | j_mayer | /* frsqrtes */
|
1865 | 7c58044c | j_mayer | static always_inline void gen_op_frsqrtes (void) |
1866 | 7c58044c | j_mayer | { |
1867 | 7c58044c | j_mayer | gen_op_frsqrte(); |
1868 | 7c58044c | j_mayer | gen_op_frsp(); |
1869 | 7c58044c | j_mayer | } |
1870 | 1b413d55 | j_mayer | GEN_FLOAT_BS(rsqrtes, 0x3B, 0x1A, 1, PPC_FLOAT_FRSQRTES); |
1871 | 79aceca5 | bellard | |
1872 | a750fc0b | j_mayer | /* fsel */
|
1873 | 7c58044c | j_mayer | _GEN_FLOAT_ACB(sel, sel, 0x3F, 0x17, 0, 0, PPC_FLOAT_FSEL); |
1874 | 4ecc3190 | bellard | /* fsub - fsubs */
|
1875 | 7c58044c | j_mayer | GEN_FLOAT_AB(sub, 0x14, 0x000007C0, 1, PPC_FLOAT); |
1876 | 79aceca5 | bellard | /* Optional: */
|
1877 | 79aceca5 | bellard | /* fsqrt */
|
1878 | a750fc0b | j_mayer | GEN_HANDLER(fsqrt, 0x3F, 0x16, 0xFF, 0x001F07C0, PPC_FLOAT_FSQRT) |
1879 | c7d344af | bellard | { |
1880 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
1881 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
1882 | c7d344af | bellard | return;
|
1883 | c7d344af | bellard | } |
1884 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rB(ctx->opcode)]);
|
1885 | 7c58044c | j_mayer | gen_reset_fpstatus(); |
1886 | c7d344af | bellard | gen_op_fsqrt(); |
1887 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
|
1888 | 7c58044c | j_mayer | gen_compute_fprf(1, Rc(ctx->opcode) != 0); |
1889 | c7d344af | bellard | } |
1890 | 79aceca5 | bellard | |
1891 | a750fc0b | j_mayer | GEN_HANDLER(fsqrts, 0x3B, 0x16, 0xFF, 0x001F07C0, PPC_FLOAT_FSQRT) |
1892 | 79aceca5 | bellard | { |
1893 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
1894 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
1895 | 3cc62370 | bellard | return;
|
1896 | 3cc62370 | bellard | } |
1897 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rB(ctx->opcode)]);
|
1898 | 7c58044c | j_mayer | gen_reset_fpstatus(); |
1899 | 4ecc3190 | bellard | gen_op_fsqrt(); |
1900 | 4ecc3190 | bellard | gen_op_frsp(); |
1901 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
|
1902 | 7c58044c | j_mayer | gen_compute_fprf(1, Rc(ctx->opcode) != 0); |
1903 | 79aceca5 | bellard | } |
1904 | 79aceca5 | bellard | |
1905 | 79aceca5 | bellard | /*** Floating-Point multiply-and-add ***/
|
1906 | 4ecc3190 | bellard | /* fmadd - fmadds */
|
1907 | 7c58044c | j_mayer | GEN_FLOAT_ACB(madd, 0x1D, 1, PPC_FLOAT); |
1908 | 4ecc3190 | bellard | /* fmsub - fmsubs */
|
1909 | 7c58044c | j_mayer | GEN_FLOAT_ACB(msub, 0x1C, 1, PPC_FLOAT); |
1910 | 4ecc3190 | bellard | /* fnmadd - fnmadds */
|
1911 | 7c58044c | j_mayer | GEN_FLOAT_ACB(nmadd, 0x1F, 1, PPC_FLOAT); |
1912 | 4ecc3190 | bellard | /* fnmsub - fnmsubs */
|
1913 | 7c58044c | j_mayer | GEN_FLOAT_ACB(nmsub, 0x1E, 1, PPC_FLOAT); |
1914 | 79aceca5 | bellard | |
1915 | 79aceca5 | bellard | /*** Floating-Point round & convert ***/
|
1916 | 79aceca5 | bellard | /* fctiw */
|
1917 | 7c58044c | j_mayer | GEN_FLOAT_B(ctiw, 0x0E, 0x00, 0, PPC_FLOAT); |
1918 | 79aceca5 | bellard | /* fctiwz */
|
1919 | 7c58044c | j_mayer | GEN_FLOAT_B(ctiwz, 0x0F, 0x00, 0, PPC_FLOAT); |
1920 | 79aceca5 | bellard | /* frsp */
|
1921 | 7c58044c | j_mayer | GEN_FLOAT_B(rsp, 0x0C, 0x00, 1, PPC_FLOAT); |
1922 | 426613db | j_mayer | #if defined(TARGET_PPC64)
|
1923 | 426613db | j_mayer | /* fcfid */
|
1924 | 7c58044c | j_mayer | GEN_FLOAT_B(cfid, 0x0E, 0x1A, 1, PPC_64B); |
1925 | 426613db | j_mayer | /* fctid */
|
1926 | 7c58044c | j_mayer | GEN_FLOAT_B(ctid, 0x0E, 0x19, 0, PPC_64B); |
1927 | 426613db | j_mayer | /* fctidz */
|
1928 | 7c58044c | j_mayer | GEN_FLOAT_B(ctidz, 0x0F, 0x19, 0, PPC_64B); |
1929 | 426613db | j_mayer | #endif
|
1930 | 79aceca5 | bellard | |
1931 | d7e4b87e | j_mayer | /* frin */
|
1932 | 7c58044c | j_mayer | GEN_FLOAT_B(rin, 0x08, 0x0C, 1, PPC_FLOAT_EXT); |
1933 | d7e4b87e | j_mayer | /* friz */
|
1934 | 7c58044c | j_mayer | GEN_FLOAT_B(riz, 0x08, 0x0D, 1, PPC_FLOAT_EXT); |
1935 | d7e4b87e | j_mayer | /* frip */
|
1936 | 7c58044c | j_mayer | GEN_FLOAT_B(rip, 0x08, 0x0E, 1, PPC_FLOAT_EXT); |
1937 | d7e4b87e | j_mayer | /* frim */
|
1938 | 7c58044c | j_mayer | GEN_FLOAT_B(rim, 0x08, 0x0F, 1, PPC_FLOAT_EXT); |
1939 | d7e4b87e | j_mayer | |
1940 | 79aceca5 | bellard | /*** Floating-Point compare ***/
|
1941 | 79aceca5 | bellard | /* fcmpo */
|
1942 | 76a66253 | j_mayer | GEN_HANDLER(fcmpo, 0x3F, 0x00, 0x01, 0x00600001, PPC_FLOAT) |
1943 | 79aceca5 | bellard | { |
1944 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
1945 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
1946 | 3cc62370 | bellard | return;
|
1947 | 3cc62370 | bellard | } |
1948 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rA(ctx->opcode)]);
|
1949 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rB(ctx->opcode)]);
|
1950 | 7c58044c | j_mayer | gen_reset_fpstatus(); |
1951 | 9a64fbe4 | bellard | gen_op_fcmpo(); |
1952 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_T[0], 0xf); |
1953 | 7c58044c | j_mayer | gen_op_float_check_status(); |
1954 | 79aceca5 | bellard | } |
1955 | 79aceca5 | bellard | |
1956 | 79aceca5 | bellard | /* fcmpu */
|
1957 | 76a66253 | j_mayer | GEN_HANDLER(fcmpu, 0x3F, 0x00, 0x00, 0x00600001, PPC_FLOAT) |
1958 | 79aceca5 | bellard | { |
1959 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
1960 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
1961 | 3cc62370 | bellard | return;
|
1962 | 3cc62370 | bellard | } |
1963 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rA(ctx->opcode)]);
|
1964 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rB(ctx->opcode)]);
|
1965 | 7c58044c | j_mayer | gen_reset_fpstatus(); |
1966 | 9a64fbe4 | bellard | gen_op_fcmpu(); |
1967 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_T[0], 0xf); |
1968 | 7c58044c | j_mayer | gen_op_float_check_status(); |
1969 | 79aceca5 | bellard | } |
1970 | 79aceca5 | bellard | |
1971 | 9a64fbe4 | bellard | /*** Floating-point move ***/
|
1972 | 9a64fbe4 | bellard | /* fabs */
|
1973 | 7c58044c | j_mayer | /* XXX: beware that fabs never checks for NaNs nor update FPSCR */
|
1974 | 7c58044c | j_mayer | GEN_FLOAT_B(abs, 0x08, 0x08, 0, PPC_FLOAT); |
1975 | 9a64fbe4 | bellard | |
1976 | 9a64fbe4 | bellard | /* fmr - fmr. */
|
1977 | 7c58044c | j_mayer | /* XXX: beware that fmr never checks for NaNs nor update FPSCR */
|
1978 | 9a64fbe4 | bellard | GEN_HANDLER(fmr, 0x3F, 0x08, 0x02, 0x001F0000, PPC_FLOAT) |
1979 | 9a64fbe4 | bellard | { |
1980 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
1981 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
1982 | 3cc62370 | bellard | return;
|
1983 | 3cc62370 | bellard | } |
1984 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rB(ctx->opcode)]);
|
1985 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
|
1986 | 7c58044c | j_mayer | gen_compute_fprf(0, Rc(ctx->opcode) != 0); |
1987 | 9a64fbe4 | bellard | } |
1988 | 9a64fbe4 | bellard | |
1989 | 9a64fbe4 | bellard | /* fnabs */
|
1990 | 7c58044c | j_mayer | /* XXX: beware that fnabs never checks for NaNs nor update FPSCR */
|
1991 | 7c58044c | j_mayer | GEN_FLOAT_B(nabs, 0x08, 0x04, 0, PPC_FLOAT); |
1992 | 9a64fbe4 | bellard | /* fneg */
|
1993 | 7c58044c | j_mayer | /* XXX: beware that fneg never checks for NaNs nor update FPSCR */
|
1994 | 7c58044c | j_mayer | GEN_FLOAT_B(neg, 0x08, 0x01, 0, PPC_FLOAT); |
1995 | 9a64fbe4 | bellard | |
1996 | 79aceca5 | bellard | /*** Floating-Point status & ctrl register ***/
|
1997 | 79aceca5 | bellard | /* mcrfs */
|
1998 | 79aceca5 | bellard | GEN_HANDLER(mcrfs, 0x3F, 0x00, 0x02, 0x0063F801, PPC_FLOAT) |
1999 | 79aceca5 | bellard | { |
2000 | 7c58044c | j_mayer | int bfa;
|
2001 | 7c58044c | j_mayer | |
2002 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
2003 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
2004 | 3cc62370 | bellard | return;
|
2005 | 3cc62370 | bellard | } |
2006 | 7c58044c | j_mayer | gen_optimize_fprf(); |
2007 | 7c58044c | j_mayer | bfa = 4 * (7 - crfS(ctx->opcode)); |
2008 | 7c58044c | j_mayer | gen_op_load_fpscr_T0(bfa); |
2009 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_T[0], 0xf); |
2010 | 7c58044c | j_mayer | gen_op_fpscr_resetbit(~(0xF << bfa));
|
2011 | 79aceca5 | bellard | } |
2012 | 79aceca5 | bellard | |
2013 | 79aceca5 | bellard | /* mffs */
|
2014 | 79aceca5 | bellard | GEN_HANDLER(mffs, 0x3F, 0x07, 0x12, 0x001FF800, PPC_FLOAT) |
2015 | 79aceca5 | bellard | { |
2016 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
2017 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
2018 | 3cc62370 | bellard | return;
|
2019 | 3cc62370 | bellard | } |
2020 | 7c58044c | j_mayer | gen_optimize_fprf(); |
2021 | 7c58044c | j_mayer | gen_reset_fpstatus(); |
2022 | 7c58044c | j_mayer | gen_op_load_fpscr_FT0(); |
2023 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
|
2024 | 7c58044c | j_mayer | gen_compute_fprf(0, Rc(ctx->opcode) != 0); |
2025 | 79aceca5 | bellard | } |
2026 | 79aceca5 | bellard | |
2027 | 79aceca5 | bellard | /* mtfsb0 */
|
2028 | 79aceca5 | bellard | GEN_HANDLER(mtfsb0, 0x3F, 0x06, 0x02, 0x001FF800, PPC_FLOAT) |
2029 | 79aceca5 | bellard | { |
2030 | fb0eaffc | bellard | uint8_t crb; |
2031 | 3b46e624 | ths | |
2032 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
2033 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
2034 | 3cc62370 | bellard | return;
|
2035 | 3cc62370 | bellard | } |
2036 | 7c58044c | j_mayer | crb = 32 - (crbD(ctx->opcode) >> 2); |
2037 | 7c58044c | j_mayer | gen_optimize_fprf(); |
2038 | 7c58044c | j_mayer | gen_reset_fpstatus(); |
2039 | 7c58044c | j_mayer | if (likely(crb != 30 && crb != 29)) |
2040 | 7c58044c | j_mayer | gen_op_fpscr_resetbit(~(1 << crb));
|
2041 | 7c58044c | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) { |
2042 | 7c58044c | j_mayer | gen_op_load_fpcc(); |
2043 | 7c58044c | j_mayer | gen_op_set_Rc0(); |
2044 | 7c58044c | j_mayer | } |
2045 | 79aceca5 | bellard | } |
2046 | 79aceca5 | bellard | |
2047 | 79aceca5 | bellard | /* mtfsb1 */
|
2048 | 79aceca5 | bellard | GEN_HANDLER(mtfsb1, 0x3F, 0x06, 0x01, 0x001FF800, PPC_FLOAT) |
2049 | 79aceca5 | bellard | { |
2050 | fb0eaffc | bellard | uint8_t crb; |
2051 | 3b46e624 | ths | |
2052 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
2053 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
2054 | 3cc62370 | bellard | return;
|
2055 | 3cc62370 | bellard | } |
2056 | 7c58044c | j_mayer | crb = 32 - (crbD(ctx->opcode) >> 2); |
2057 | 7c58044c | j_mayer | gen_optimize_fprf(); |
2058 | 7c58044c | j_mayer | gen_reset_fpstatus(); |
2059 | 7c58044c | j_mayer | /* XXX: we pretend we can only do IEEE floating-point computations */
|
2060 | 7c58044c | j_mayer | if (likely(crb != FPSCR_FEX && crb != FPSCR_VX && crb != FPSCR_NI))
|
2061 | 7c58044c | j_mayer | gen_op_fpscr_setbit(crb); |
2062 | 7c58044c | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) { |
2063 | 7c58044c | j_mayer | gen_op_load_fpcc(); |
2064 | 7c58044c | j_mayer | gen_op_set_Rc0(); |
2065 | 7c58044c | j_mayer | } |
2066 | 7c58044c | j_mayer | /* We can raise a differed exception */
|
2067 | 7c58044c | j_mayer | gen_op_float_check_status(); |
2068 | 79aceca5 | bellard | } |
2069 | 79aceca5 | bellard | |
2070 | 79aceca5 | bellard | /* mtfsf */
|
2071 | 79aceca5 | bellard | GEN_HANDLER(mtfsf, 0x3F, 0x07, 0x16, 0x02010000, PPC_FLOAT) |
2072 | 79aceca5 | bellard | { |
2073 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
2074 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
2075 | 3cc62370 | bellard | return;
|
2076 | 3cc62370 | bellard | } |
2077 | 7c58044c | j_mayer | gen_optimize_fprf(); |
2078 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rB(ctx->opcode)]);
|
2079 | 7c58044c | j_mayer | gen_reset_fpstatus(); |
2080 | 28b6751f | bellard | gen_op_store_fpscr(FM(ctx->opcode)); |
2081 | 7c58044c | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) { |
2082 | 7c58044c | j_mayer | gen_op_load_fpcc(); |
2083 | 7c58044c | j_mayer | gen_op_set_Rc0(); |
2084 | 7c58044c | j_mayer | } |
2085 | 7c58044c | j_mayer | /* We can raise a differed exception */
|
2086 | 7c58044c | j_mayer | gen_op_float_check_status(); |
2087 | 79aceca5 | bellard | } |
2088 | 79aceca5 | bellard | |
2089 | 79aceca5 | bellard | /* mtfsfi */
|
2090 | 79aceca5 | bellard | GEN_HANDLER(mtfsfi, 0x3F, 0x06, 0x04, 0x006f0800, PPC_FLOAT) |
2091 | 79aceca5 | bellard | { |
2092 | 7c58044c | j_mayer | int bf, sh;
|
2093 | 7c58044c | j_mayer | |
2094 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) {
|
2095 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); |
2096 | 3cc62370 | bellard | return;
|
2097 | 3cc62370 | bellard | } |
2098 | 7c58044c | j_mayer | bf = crbD(ctx->opcode) >> 2;
|
2099 | 7c58044c | j_mayer | sh = 7 - bf;
|
2100 | 7c58044c | j_mayer | gen_optimize_fprf(); |
2101 | 489251fa | aurel32 | tcg_gen_movi_i64(cpu_FT[0], FPIMM(ctx->opcode) << (4 * sh)); |
2102 | 7c58044c | j_mayer | gen_reset_fpstatus(); |
2103 | 7c58044c | j_mayer | gen_op_store_fpscr(1 << sh);
|
2104 | 7c58044c | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) { |
2105 | 7c58044c | j_mayer | gen_op_load_fpcc(); |
2106 | 7c58044c | j_mayer | gen_op_set_Rc0(); |
2107 | 7c58044c | j_mayer | } |
2108 | 7c58044c | j_mayer | /* We can raise a differed exception */
|
2109 | 7c58044c | j_mayer | gen_op_float_check_status(); |
2110 | 79aceca5 | bellard | } |
2111 | 79aceca5 | bellard | |
2112 | 76a66253 | j_mayer | /*** Addressing modes ***/
|
2113 | 76a66253 | j_mayer | /* Register indirect with immediate index : EA = (rA|0) + SIMM */
|
2114 | b068d6a7 | j_mayer | static always_inline void gen_addr_imm_index (DisasContext *ctx, |
2115 | b068d6a7 | j_mayer | target_long maskl) |
2116 | 76a66253 | j_mayer | { |
2117 | 76a66253 | j_mayer | target_long simm = SIMM(ctx->opcode); |
2118 | 76a66253 | j_mayer | |
2119 | be147d08 | j_mayer | simm &= ~maskl; |
2120 | 76a66253 | j_mayer | if (rA(ctx->opcode) == 0) { |
2121 | 02f4f6c2 | aurel32 | tcg_gen_movi_tl(cpu_T[0], simm);
|
2122 | 76a66253 | j_mayer | } else {
|
2123 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
2124 | 76a66253 | j_mayer | if (likely(simm != 0)) |
2125 | 39dd32ee | aurel32 | tcg_gen_addi_tl(cpu_T[0], cpu_T[0], simm); |
2126 | 76a66253 | j_mayer | } |
2127 | a496775f | j_mayer | #ifdef DEBUG_MEMORY_ACCESSES
|
2128 | 6676f424 | aurel32 | gen_op_print_mem_EA(); |
2129 | a496775f | j_mayer | #endif
|
2130 | 76a66253 | j_mayer | } |
2131 | 76a66253 | j_mayer | |
2132 | b068d6a7 | j_mayer | static always_inline void gen_addr_reg_index (DisasContext *ctx) |
2133 | 76a66253 | j_mayer | { |
2134 | 76a66253 | j_mayer | if (rA(ctx->opcode) == 0) { |
2135 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rB(ctx->opcode)]);
|
2136 | 76a66253 | j_mayer | } else {
|
2137 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
2138 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
2139 | 39dd32ee | aurel32 | tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]); |
2140 | 76a66253 | j_mayer | } |
2141 | a496775f | j_mayer | #ifdef DEBUG_MEMORY_ACCESSES
|
2142 | 6676f424 | aurel32 | gen_op_print_mem_EA(); |
2143 | a496775f | j_mayer | #endif
|
2144 | 76a66253 | j_mayer | } |
2145 | 76a66253 | j_mayer | |
2146 | b068d6a7 | j_mayer | static always_inline void gen_addr_register (DisasContext *ctx) |
2147 | 76a66253 | j_mayer | { |
2148 | 76a66253 | j_mayer | if (rA(ctx->opcode) == 0) { |
2149 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[0], 0); |
2150 | 76a66253 | j_mayer | } else {
|
2151 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
2152 | 76a66253 | j_mayer | } |
2153 | a496775f | j_mayer | #ifdef DEBUG_MEMORY_ACCESSES
|
2154 | 6676f424 | aurel32 | gen_op_print_mem_EA(); |
2155 | a496775f | j_mayer | #endif
|
2156 | 76a66253 | j_mayer | } |
2157 | 76a66253 | j_mayer | |
2158 | 7863667f | j_mayer | #if defined(TARGET_PPC64)
|
2159 | 7863667f | j_mayer | #define _GEN_MEM_FUNCS(name, mode) \
|
2160 | 7863667f | j_mayer | &gen_op_##name##_##mode, \ |
2161 | 7863667f | j_mayer | &gen_op_##name##_le_##mode, \ |
2162 | 7863667f | j_mayer | &gen_op_##name##_64_##mode, \ |
2163 | 7863667f | j_mayer | &gen_op_##name##_le_64_##mode |
2164 | 7863667f | j_mayer | #else
|
2165 | 7863667f | j_mayer | #define _GEN_MEM_FUNCS(name, mode) \
|
2166 | 7863667f | j_mayer | &gen_op_##name##_##mode, \ |
2167 | 7863667f | j_mayer | &gen_op_##name##_le_##mode |
2168 | 7863667f | j_mayer | #endif
|
2169 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
2170 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2171 | 7863667f | j_mayer | #define NB_MEM_FUNCS 4 |
2172 | d9bce9d9 | j_mayer | #else
|
2173 | 7863667f | j_mayer | #define NB_MEM_FUNCS 2 |
2174 | d9bce9d9 | j_mayer | #endif
|
2175 | 7863667f | j_mayer | #define GEN_MEM_FUNCS(name) \
|
2176 | 7863667f | j_mayer | _GEN_MEM_FUNCS(name, raw) |
2177 | 9a64fbe4 | bellard | #else
|
2178 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2179 | 7863667f | j_mayer | #define NB_MEM_FUNCS 12 |
2180 | 2857068e | j_mayer | #else
|
2181 | 7863667f | j_mayer | #define NB_MEM_FUNCS 6 |
2182 | 2857068e | j_mayer | #endif
|
2183 | 7863667f | j_mayer | #define GEN_MEM_FUNCS(name) \
|
2184 | 7863667f | j_mayer | _GEN_MEM_FUNCS(name, user), \ |
2185 | 7863667f | j_mayer | _GEN_MEM_FUNCS(name, kernel), \ |
2186 | 7863667f | j_mayer | _GEN_MEM_FUNCS(name, hypv) |
2187 | 7863667f | j_mayer | #endif
|
2188 | 7863667f | j_mayer | |
2189 | 7863667f | j_mayer | /*** Integer load ***/
|
2190 | 7863667f | j_mayer | #define op_ldst(name) (*gen_op_##name[ctx->mem_idx])() |
2191 | 111bfab3 | bellard | /* Byte access routine are endian safe */
|
2192 | 7863667f | j_mayer | #define gen_op_lbz_le_raw gen_op_lbz_raw
|
2193 | 7863667f | j_mayer | #define gen_op_lbz_le_user gen_op_lbz_user
|
2194 | 7863667f | j_mayer | #define gen_op_lbz_le_kernel gen_op_lbz_kernel
|
2195 | 7863667f | j_mayer | #define gen_op_lbz_le_hypv gen_op_lbz_hypv
|
2196 | 7863667f | j_mayer | #define gen_op_lbz_le_64_raw gen_op_lbz_64_raw
|
2197 | 2857068e | j_mayer | #define gen_op_lbz_le_64_user gen_op_lbz_64_user
|
2198 | d9bce9d9 | j_mayer | #define gen_op_lbz_le_64_kernel gen_op_lbz_64_kernel
|
2199 | 7863667f | j_mayer | #define gen_op_lbz_le_64_hypv gen_op_lbz_64_hypv
|
2200 | 7863667f | j_mayer | #define gen_op_stb_le_raw gen_op_stb_raw
|
2201 | 7863667f | j_mayer | #define gen_op_stb_le_user gen_op_stb_user
|
2202 | 7863667f | j_mayer | #define gen_op_stb_le_kernel gen_op_stb_kernel
|
2203 | 7863667f | j_mayer | #define gen_op_stb_le_hypv gen_op_stb_hypv
|
2204 | 7863667f | j_mayer | #define gen_op_stb_le_64_raw gen_op_stb_64_raw
|
2205 | 7863667f | j_mayer | #define gen_op_stb_le_64_user gen_op_stb_64_user
|
2206 | 7863667f | j_mayer | #define gen_op_stb_le_64_kernel gen_op_stb_64_kernel
|
2207 | 7863667f | j_mayer | #define gen_op_stb_le_64_hypv gen_op_stb_64_hypv
|
2208 | d9bce9d9 | j_mayer | #define OP_LD_TABLE(width) \
|
2209 | 7863667f | j_mayer | static GenOpFunc *gen_op_l##width[NB_MEM_FUNCS] = { \ |
2210 | 7863667f | j_mayer | GEN_MEM_FUNCS(l##width), \ |
2211 | d9bce9d9 | j_mayer | }; |
2212 | d9bce9d9 | j_mayer | #define OP_ST_TABLE(width) \
|
2213 | 7863667f | j_mayer | static GenOpFunc *gen_op_st##width[NB_MEM_FUNCS] = { \ |
2214 | 7863667f | j_mayer | GEN_MEM_FUNCS(st##width), \ |
2215 | d9bce9d9 | j_mayer | }; |
2216 | 9a64fbe4 | bellard | |
2217 | d9bce9d9 | j_mayer | #define GEN_LD(width, opc, type) \
|
2218 | d9bce9d9 | j_mayer | GEN_HANDLER(l##width, opc, 0xFF, 0xFF, 0x00000000, type) \ |
2219 | 79aceca5 | bellard | { \ |
2220 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0); \
|
2221 | 9a64fbe4 | bellard | op_ldst(l##width); \ |
2222 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]); \
|
2223 | 79aceca5 | bellard | } |
2224 | 79aceca5 | bellard | |
2225 | d9bce9d9 | j_mayer | #define GEN_LDU(width, opc, type) \
|
2226 | d9bce9d9 | j_mayer | GEN_HANDLER(l##width##u, opc, 0xFF, 0xFF, 0x00000000, type) \ |
2227 | 79aceca5 | bellard | { \ |
2228 | 76a66253 | j_mayer | if (unlikely(rA(ctx->opcode) == 0 || \ |
2229 | 76a66253 | j_mayer | rA(ctx->opcode) == rD(ctx->opcode))) { \ |
2230 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); \ |
2231 | 9fddaa0c | bellard | return; \
|
2232 | 9a64fbe4 | bellard | } \ |
2233 | 9d53c753 | j_mayer | if (type == PPC_64B) \
|
2234 | be147d08 | j_mayer | gen_addr_imm_index(ctx, 0x03); \
|
2235 | 9d53c753 | j_mayer | else \
|
2236 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0); \
|
2237 | 9a64fbe4 | bellard | op_ldst(l##width); \ |
2238 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]); \
|
2239 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
2240 | 79aceca5 | bellard | } |
2241 | 79aceca5 | bellard | |
2242 | d9bce9d9 | j_mayer | #define GEN_LDUX(width, opc2, opc3, type) \
|
2243 | d9bce9d9 | j_mayer | GEN_HANDLER(l##width##ux, 0x1F, opc2, opc3, 0x00000001, type) \ |
2244 | 79aceca5 | bellard | { \ |
2245 | 76a66253 | j_mayer | if (unlikely(rA(ctx->opcode) == 0 || \ |
2246 | 76a66253 | j_mayer | rA(ctx->opcode) == rD(ctx->opcode))) { \ |
2247 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); \ |
2248 | 9fddaa0c | bellard | return; \
|
2249 | 9a64fbe4 | bellard | } \ |
2250 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); \ |
2251 | 9a64fbe4 | bellard | op_ldst(l##width); \ |
2252 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]); \
|
2253 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
2254 | 79aceca5 | bellard | } |
2255 | 79aceca5 | bellard | |
2256 | d9bce9d9 | j_mayer | #define GEN_LDX(width, opc2, opc3, type) \
|
2257 | d9bce9d9 | j_mayer | GEN_HANDLER(l##width##x, 0x1F, opc2, opc3, 0x00000001, type) \ |
2258 | 79aceca5 | bellard | { \ |
2259 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); \ |
2260 | 9a64fbe4 | bellard | op_ldst(l##width); \ |
2261 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]); \
|
2262 | 79aceca5 | bellard | } |
2263 | 79aceca5 | bellard | |
2264 | d9bce9d9 | j_mayer | #define GEN_LDS(width, op, type) \
|
2265 | 9a64fbe4 | bellard | OP_LD_TABLE(width); \ |
2266 | d9bce9d9 | j_mayer | GEN_LD(width, op | 0x20, type); \
|
2267 | d9bce9d9 | j_mayer | GEN_LDU(width, op | 0x21, type); \
|
2268 | d9bce9d9 | j_mayer | GEN_LDUX(width, 0x17, op | 0x01, type); \ |
2269 | d9bce9d9 | j_mayer | GEN_LDX(width, 0x17, op | 0x00, type) |
2270 | 79aceca5 | bellard | |
2271 | 79aceca5 | bellard | /* lbz lbzu lbzux lbzx */
|
2272 | d9bce9d9 | j_mayer | GEN_LDS(bz, 0x02, PPC_INTEGER);
|
2273 | 79aceca5 | bellard | /* lha lhau lhaux lhax */
|
2274 | d9bce9d9 | j_mayer | GEN_LDS(ha, 0x0A, PPC_INTEGER);
|
2275 | 79aceca5 | bellard | /* lhz lhzu lhzux lhzx */
|
2276 | d9bce9d9 | j_mayer | GEN_LDS(hz, 0x08, PPC_INTEGER);
|
2277 | 79aceca5 | bellard | /* lwz lwzu lwzux lwzx */
|
2278 | d9bce9d9 | j_mayer | GEN_LDS(wz, 0x00, PPC_INTEGER);
|
2279 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2280 | d9bce9d9 | j_mayer | OP_LD_TABLE(wa); |
2281 | d9bce9d9 | j_mayer | OP_LD_TABLE(d); |
2282 | d9bce9d9 | j_mayer | /* lwaux */
|
2283 | d9bce9d9 | j_mayer | GEN_LDUX(wa, 0x15, 0x0B, PPC_64B); |
2284 | d9bce9d9 | j_mayer | /* lwax */
|
2285 | d9bce9d9 | j_mayer | GEN_LDX(wa, 0x15, 0x0A, PPC_64B); |
2286 | d9bce9d9 | j_mayer | /* ldux */
|
2287 | d9bce9d9 | j_mayer | GEN_LDUX(d, 0x15, 0x01, PPC_64B); |
2288 | d9bce9d9 | j_mayer | /* ldx */
|
2289 | d9bce9d9 | j_mayer | GEN_LDX(d, 0x15, 0x00, PPC_64B); |
2290 | d9bce9d9 | j_mayer | GEN_HANDLER(ld, 0x3A, 0xFF, 0xFF, 0x00000000, PPC_64B) |
2291 | d9bce9d9 | j_mayer | { |
2292 | d9bce9d9 | j_mayer | if (Rc(ctx->opcode)) {
|
2293 | d9bce9d9 | j_mayer | if (unlikely(rA(ctx->opcode) == 0 || |
2294 | d9bce9d9 | j_mayer | rA(ctx->opcode) == rD(ctx->opcode))) { |
2295 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
2296 | d9bce9d9 | j_mayer | return;
|
2297 | d9bce9d9 | j_mayer | } |
2298 | d9bce9d9 | j_mayer | } |
2299 | be147d08 | j_mayer | gen_addr_imm_index(ctx, 0x03);
|
2300 | d9bce9d9 | j_mayer | if (ctx->opcode & 0x02) { |
2301 | d9bce9d9 | j_mayer | /* lwa (lwau is undefined) */
|
2302 | d9bce9d9 | j_mayer | op_ldst(lwa); |
2303 | d9bce9d9 | j_mayer | } else {
|
2304 | d9bce9d9 | j_mayer | /* ld - ldu */
|
2305 | d9bce9d9 | j_mayer | op_ldst(ld); |
2306 | d9bce9d9 | j_mayer | } |
2307 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]);
|
2308 | d9bce9d9 | j_mayer | if (Rc(ctx->opcode))
|
2309 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
2310 | d9bce9d9 | j_mayer | } |
2311 | be147d08 | j_mayer | /* lq */
|
2312 | be147d08 | j_mayer | GEN_HANDLER(lq, 0x38, 0xFF, 0xFF, 0x00000000, PPC_64BX) |
2313 | be147d08 | j_mayer | { |
2314 | be147d08 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
2315 | be147d08 | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
2316 | be147d08 | j_mayer | #else
|
2317 | be147d08 | j_mayer | int ra, rd;
|
2318 | be147d08 | j_mayer | |
2319 | be147d08 | j_mayer | /* Restore CPU state */
|
2320 | be147d08 | j_mayer | if (unlikely(ctx->supervisor == 0)) { |
2321 | be147d08 | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
2322 | be147d08 | j_mayer | return;
|
2323 | be147d08 | j_mayer | } |
2324 | be147d08 | j_mayer | ra = rA(ctx->opcode); |
2325 | be147d08 | j_mayer | rd = rD(ctx->opcode); |
2326 | be147d08 | j_mayer | if (unlikely((rd & 1) || rd == ra)) { |
2327 | be147d08 | j_mayer | GEN_EXCP_INVAL(ctx); |
2328 | be147d08 | j_mayer | return;
|
2329 | be147d08 | j_mayer | } |
2330 | be147d08 | j_mayer | if (unlikely(ctx->mem_idx & 1)) { |
2331 | be147d08 | j_mayer | /* Little-endian mode is not handled */
|
2332 | be147d08 | j_mayer | GEN_EXCP(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE); |
2333 | be147d08 | j_mayer | return;
|
2334 | be147d08 | j_mayer | } |
2335 | be147d08 | j_mayer | gen_addr_imm_index(ctx, 0x0F);
|
2336 | be147d08 | j_mayer | op_ldst(ld); |
2337 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rd], cpu_T[1]);
|
2338 | 39dd32ee | aurel32 | tcg_gen_addi_tl(cpu_T[0], cpu_T[0], 8); |
2339 | be147d08 | j_mayer | op_ldst(ld); |
2340 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rd + 1], cpu_T[1]); |
2341 | be147d08 | j_mayer | #endif
|
2342 | be147d08 | j_mayer | } |
2343 | d9bce9d9 | j_mayer | #endif
|
2344 | 79aceca5 | bellard | |
2345 | 79aceca5 | bellard | /*** Integer store ***/
|
2346 | d9bce9d9 | j_mayer | #define GEN_ST(width, opc, type) \
|
2347 | d9bce9d9 | j_mayer | GEN_HANDLER(st##width, opc, 0xFF, 0xFF, 0x00000000, type) \ |
2348 | 79aceca5 | bellard | { \ |
2349 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0); \
|
2350 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); \
|
2351 | 9a64fbe4 | bellard | op_ldst(st##width); \ |
2352 | 79aceca5 | bellard | } |
2353 | 79aceca5 | bellard | |
2354 | d9bce9d9 | j_mayer | #define GEN_STU(width, opc, type) \
|
2355 | d9bce9d9 | j_mayer | GEN_HANDLER(st##width##u, opc, 0xFF, 0xFF, 0x00000000, type) \ |
2356 | 79aceca5 | bellard | { \ |
2357 | 76a66253 | j_mayer | if (unlikely(rA(ctx->opcode) == 0)) { \ |
2358 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); \ |
2359 | 9fddaa0c | bellard | return; \
|
2360 | 9a64fbe4 | bellard | } \ |
2361 | 9d53c753 | j_mayer | if (type == PPC_64B) \
|
2362 | be147d08 | j_mayer | gen_addr_imm_index(ctx, 0x03); \
|
2363 | 9d53c753 | j_mayer | else \
|
2364 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0); \
|
2365 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); \
|
2366 | 9a64fbe4 | bellard | op_ldst(st##width); \ |
2367 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
2368 | 79aceca5 | bellard | } |
2369 | 79aceca5 | bellard | |
2370 | d9bce9d9 | j_mayer | #define GEN_STUX(width, opc2, opc3, type) \
|
2371 | d9bce9d9 | j_mayer | GEN_HANDLER(st##width##ux, 0x1F, opc2, opc3, 0x00000001, type) \ |
2372 | 79aceca5 | bellard | { \ |
2373 | 76a66253 | j_mayer | if (unlikely(rA(ctx->opcode) == 0)) { \ |
2374 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); \ |
2375 | 9fddaa0c | bellard | return; \
|
2376 | 9a64fbe4 | bellard | } \ |
2377 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); \ |
2378 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); \
|
2379 | 9a64fbe4 | bellard | op_ldst(st##width); \ |
2380 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
2381 | 79aceca5 | bellard | } |
2382 | 79aceca5 | bellard | |
2383 | d9bce9d9 | j_mayer | #define GEN_STX(width, opc2, opc3, type) \
|
2384 | d9bce9d9 | j_mayer | GEN_HANDLER(st##width##x, 0x1F, opc2, opc3, 0x00000001, type) \ |
2385 | 79aceca5 | bellard | { \ |
2386 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); \ |
2387 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); \
|
2388 | 9a64fbe4 | bellard | op_ldst(st##width); \ |
2389 | 79aceca5 | bellard | } |
2390 | 79aceca5 | bellard | |
2391 | d9bce9d9 | j_mayer | #define GEN_STS(width, op, type) \
|
2392 | 9a64fbe4 | bellard | OP_ST_TABLE(width); \ |
2393 | d9bce9d9 | j_mayer | GEN_ST(width, op | 0x20, type); \
|
2394 | d9bce9d9 | j_mayer | GEN_STU(width, op | 0x21, type); \
|
2395 | d9bce9d9 | j_mayer | GEN_STUX(width, 0x17, op | 0x01, type); \ |
2396 | d9bce9d9 | j_mayer | GEN_STX(width, 0x17, op | 0x00, type) |
2397 | 79aceca5 | bellard | |
2398 | 79aceca5 | bellard | /* stb stbu stbux stbx */
|
2399 | d9bce9d9 | j_mayer | GEN_STS(b, 0x06, PPC_INTEGER);
|
2400 | 79aceca5 | bellard | /* sth sthu sthux sthx */
|
2401 | d9bce9d9 | j_mayer | GEN_STS(h, 0x0C, PPC_INTEGER);
|
2402 | 79aceca5 | bellard | /* stw stwu stwux stwx */
|
2403 | d9bce9d9 | j_mayer | GEN_STS(w, 0x04, PPC_INTEGER);
|
2404 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2405 | d9bce9d9 | j_mayer | OP_ST_TABLE(d); |
2406 | 426613db | j_mayer | GEN_STUX(d, 0x15, 0x05, PPC_64B); |
2407 | 426613db | j_mayer | GEN_STX(d, 0x15, 0x04, PPC_64B); |
2408 | be147d08 | j_mayer | GEN_HANDLER(std, 0x3E, 0xFF, 0xFF, 0x00000000, PPC_64B) |
2409 | d9bce9d9 | j_mayer | { |
2410 | be147d08 | j_mayer | int rs;
|
2411 | be147d08 | j_mayer | |
2412 | be147d08 | j_mayer | rs = rS(ctx->opcode); |
2413 | be147d08 | j_mayer | if ((ctx->opcode & 0x3) == 0x2) { |
2414 | be147d08 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
2415 | be147d08 | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
2416 | be147d08 | j_mayer | #else
|
2417 | be147d08 | j_mayer | /* stq */
|
2418 | be147d08 | j_mayer | if (unlikely(ctx->supervisor == 0)) { |
2419 | be147d08 | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
2420 | be147d08 | j_mayer | return;
|
2421 | be147d08 | j_mayer | } |
2422 | be147d08 | j_mayer | if (unlikely(rs & 1)) { |
2423 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
2424 | d9bce9d9 | j_mayer | return;
|
2425 | d9bce9d9 | j_mayer | } |
2426 | be147d08 | j_mayer | if (unlikely(ctx->mem_idx & 1)) { |
2427 | be147d08 | j_mayer | /* Little-endian mode is not handled */
|
2428 | be147d08 | j_mayer | GEN_EXCP(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE); |
2429 | be147d08 | j_mayer | return;
|
2430 | be147d08 | j_mayer | } |
2431 | be147d08 | j_mayer | gen_addr_imm_index(ctx, 0x03);
|
2432 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rs]);
|
2433 | be147d08 | j_mayer | op_ldst(std); |
2434 | 39dd32ee | aurel32 | tcg_gen_addi_tl(cpu_T[0], cpu_T[0], 8); |
2435 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rs + 1]); |
2436 | be147d08 | j_mayer | op_ldst(std); |
2437 | be147d08 | j_mayer | #endif
|
2438 | be147d08 | j_mayer | } else {
|
2439 | be147d08 | j_mayer | /* std / stdu */
|
2440 | be147d08 | j_mayer | if (Rc(ctx->opcode)) {
|
2441 | be147d08 | j_mayer | if (unlikely(rA(ctx->opcode) == 0)) { |
2442 | be147d08 | j_mayer | GEN_EXCP_INVAL(ctx); |
2443 | be147d08 | j_mayer | return;
|
2444 | be147d08 | j_mayer | } |
2445 | be147d08 | j_mayer | } |
2446 | be147d08 | j_mayer | gen_addr_imm_index(ctx, 0x03);
|
2447 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rs]);
|
2448 | be147d08 | j_mayer | op_ldst(std); |
2449 | be147d08 | j_mayer | if (Rc(ctx->opcode))
|
2450 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
2451 | d9bce9d9 | j_mayer | } |
2452 | d9bce9d9 | j_mayer | } |
2453 | d9bce9d9 | j_mayer | #endif
|
2454 | 79aceca5 | bellard | /*** Integer load and store with byte reverse ***/
|
2455 | 79aceca5 | bellard | /* lhbrx */
|
2456 | 9a64fbe4 | bellard | OP_LD_TABLE(hbr); |
2457 | d9bce9d9 | j_mayer | GEN_LDX(hbr, 0x16, 0x18, PPC_INTEGER); |
2458 | 79aceca5 | bellard | /* lwbrx */
|
2459 | 9a64fbe4 | bellard | OP_LD_TABLE(wbr); |
2460 | d9bce9d9 | j_mayer | GEN_LDX(wbr, 0x16, 0x10, PPC_INTEGER); |
2461 | 79aceca5 | bellard | /* sthbrx */
|
2462 | 9a64fbe4 | bellard | OP_ST_TABLE(hbr); |
2463 | d9bce9d9 | j_mayer | GEN_STX(hbr, 0x16, 0x1C, PPC_INTEGER); |
2464 | 79aceca5 | bellard | /* stwbrx */
|
2465 | 9a64fbe4 | bellard | OP_ST_TABLE(wbr); |
2466 | d9bce9d9 | j_mayer | GEN_STX(wbr, 0x16, 0x14, PPC_INTEGER); |
2467 | 79aceca5 | bellard | |
2468 | 79aceca5 | bellard | /*** Integer load and store multiple ***/
|
2469 | 111bfab3 | bellard | #define op_ldstm(name, reg) (*gen_op_##name[ctx->mem_idx])(reg) |
2470 | 7863667f | j_mayer | static GenOpFunc1 *gen_op_lmw[NB_MEM_FUNCS] = {
|
2471 | 7863667f | j_mayer | GEN_MEM_FUNCS(lmw), |
2472 | d9bce9d9 | j_mayer | }; |
2473 | 7863667f | j_mayer | static GenOpFunc1 *gen_op_stmw[NB_MEM_FUNCS] = {
|
2474 | 7863667f | j_mayer | GEN_MEM_FUNCS(stmw), |
2475 | d9bce9d9 | j_mayer | }; |
2476 | 9a64fbe4 | bellard | |
2477 | 79aceca5 | bellard | /* lmw */
|
2478 | 79aceca5 | bellard | GEN_HANDLER(lmw, 0x2E, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
2479 | 79aceca5 | bellard | { |
2480 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
2481 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
2482 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0);
|
2483 | 9a64fbe4 | bellard | op_ldstm(lmw, rD(ctx->opcode)); |
2484 | 79aceca5 | bellard | } |
2485 | 79aceca5 | bellard | |
2486 | 79aceca5 | bellard | /* stmw */
|
2487 | 79aceca5 | bellard | GEN_HANDLER(stmw, 0x2F, 0xFF, 0xFF, 0x00000000, PPC_INTEGER) |
2488 | 79aceca5 | bellard | { |
2489 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
2490 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
2491 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0);
|
2492 | 9a64fbe4 | bellard | op_ldstm(stmw, rS(ctx->opcode)); |
2493 | 79aceca5 | bellard | } |
2494 | 79aceca5 | bellard | |
2495 | 79aceca5 | bellard | /*** Integer load and store strings ***/
|
2496 | 9a64fbe4 | bellard | #define op_ldsts(name, start) (*gen_op_##name[ctx->mem_idx])(start) |
2497 | 9a64fbe4 | bellard | #define op_ldstsx(name, rd, ra, rb) (*gen_op_##name[ctx->mem_idx])(rd, ra, rb) |
2498 | e7c24003 | j_mayer | /* string load & stores are by definition endian-safe */
|
2499 | e7c24003 | j_mayer | #define gen_op_lswi_le_raw gen_op_lswi_raw
|
2500 | e7c24003 | j_mayer | #define gen_op_lswi_le_user gen_op_lswi_user
|
2501 | e7c24003 | j_mayer | #define gen_op_lswi_le_kernel gen_op_lswi_kernel
|
2502 | e7c24003 | j_mayer | #define gen_op_lswi_le_hypv gen_op_lswi_hypv
|
2503 | e7c24003 | j_mayer | #define gen_op_lswi_le_64_raw gen_op_lswi_raw
|
2504 | e7c24003 | j_mayer | #define gen_op_lswi_le_64_user gen_op_lswi_user
|
2505 | e7c24003 | j_mayer | #define gen_op_lswi_le_64_kernel gen_op_lswi_kernel
|
2506 | e7c24003 | j_mayer | #define gen_op_lswi_le_64_hypv gen_op_lswi_hypv
|
2507 | 7863667f | j_mayer | static GenOpFunc1 *gen_op_lswi[NB_MEM_FUNCS] = {
|
2508 | 7863667f | j_mayer | GEN_MEM_FUNCS(lswi), |
2509 | d9bce9d9 | j_mayer | }; |
2510 | e7c24003 | j_mayer | #define gen_op_lswx_le_raw gen_op_lswx_raw
|
2511 | e7c24003 | j_mayer | #define gen_op_lswx_le_user gen_op_lswx_user
|
2512 | e7c24003 | j_mayer | #define gen_op_lswx_le_kernel gen_op_lswx_kernel
|
2513 | e7c24003 | j_mayer | #define gen_op_lswx_le_hypv gen_op_lswx_hypv
|
2514 | e7c24003 | j_mayer | #define gen_op_lswx_le_64_raw gen_op_lswx_raw
|
2515 | e7c24003 | j_mayer | #define gen_op_lswx_le_64_user gen_op_lswx_user
|
2516 | e7c24003 | j_mayer | #define gen_op_lswx_le_64_kernel gen_op_lswx_kernel
|
2517 | e7c24003 | j_mayer | #define gen_op_lswx_le_64_hypv gen_op_lswx_hypv
|
2518 | 7863667f | j_mayer | static GenOpFunc3 *gen_op_lswx[NB_MEM_FUNCS] = {
|
2519 | 7863667f | j_mayer | GEN_MEM_FUNCS(lswx), |
2520 | d9bce9d9 | j_mayer | }; |
2521 | e7c24003 | j_mayer | #define gen_op_stsw_le_raw gen_op_stsw_raw
|
2522 | e7c24003 | j_mayer | #define gen_op_stsw_le_user gen_op_stsw_user
|
2523 | e7c24003 | j_mayer | #define gen_op_stsw_le_kernel gen_op_stsw_kernel
|
2524 | e7c24003 | j_mayer | #define gen_op_stsw_le_hypv gen_op_stsw_hypv
|
2525 | e7c24003 | j_mayer | #define gen_op_stsw_le_64_raw gen_op_stsw_raw
|
2526 | e7c24003 | j_mayer | #define gen_op_stsw_le_64_user gen_op_stsw_user
|
2527 | e7c24003 | j_mayer | #define gen_op_stsw_le_64_kernel gen_op_stsw_kernel
|
2528 | e7c24003 | j_mayer | #define gen_op_stsw_le_64_hypv gen_op_stsw_hypv
|
2529 | 7863667f | j_mayer | static GenOpFunc1 *gen_op_stsw[NB_MEM_FUNCS] = {
|
2530 | 7863667f | j_mayer | GEN_MEM_FUNCS(stsw), |
2531 | 9a64fbe4 | bellard | }; |
2532 | 9a64fbe4 | bellard | |
2533 | 79aceca5 | bellard | /* lswi */
|
2534 | 3fc6c082 | bellard | /* PowerPC32 specification says we must generate an exception if
|
2535 | 9a64fbe4 | bellard | * rA is in the range of registers to be loaded.
|
2536 | 9a64fbe4 | bellard | * In an other hand, IBM says this is valid, but rA won't be loaded.
|
2537 | 9a64fbe4 | bellard | * For now, I'll follow the spec...
|
2538 | 9a64fbe4 | bellard | */
|
2539 | 05332d70 | j_mayer | GEN_HANDLER(lswi, 0x1F, 0x15, 0x12, 0x00000001, PPC_STRING) |
2540 | 79aceca5 | bellard | { |
2541 | 79aceca5 | bellard | int nb = NB(ctx->opcode);
|
2542 | 79aceca5 | bellard | int start = rD(ctx->opcode);
|
2543 | 9a64fbe4 | bellard | int ra = rA(ctx->opcode);
|
2544 | 79aceca5 | bellard | int nr;
|
2545 | 79aceca5 | bellard | |
2546 | 79aceca5 | bellard | if (nb == 0) |
2547 | 79aceca5 | bellard | nb = 32;
|
2548 | 79aceca5 | bellard | nr = nb / 4;
|
2549 | 76a66253 | j_mayer | if (unlikely(((start + nr) > 32 && |
2550 | 76a66253 | j_mayer | start <= ra && (start + nr - 32) > ra) ||
|
2551 | 76a66253 | j_mayer | ((start + nr) <= 32 && start <= ra && (start + nr) > ra))) {
|
2552 | e1833e1f | j_mayer | GEN_EXCP(ctx, POWERPC_EXCP_PROGRAM, |
2553 | e1833e1f | j_mayer | POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_LSWX); |
2554 | 9fddaa0c | bellard | return;
|
2555 | 297d8e62 | bellard | } |
2556 | 8dd4983c | bellard | /* NIP cannot be restored if the memory exception comes from an helper */
|
2557 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
2558 | 76a66253 | j_mayer | gen_addr_register(ctx); |
2559 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], nb);
|
2560 | 9a64fbe4 | bellard | op_ldsts(lswi, start); |
2561 | 79aceca5 | bellard | } |
2562 | 79aceca5 | bellard | |
2563 | 79aceca5 | bellard | /* lswx */
|
2564 | 05332d70 | j_mayer | GEN_HANDLER(lswx, 0x1F, 0x15, 0x10, 0x00000001, PPC_STRING) |
2565 | 79aceca5 | bellard | { |
2566 | 9a64fbe4 | bellard | int ra = rA(ctx->opcode);
|
2567 | 9a64fbe4 | bellard | int rb = rB(ctx->opcode);
|
2568 | 9a64fbe4 | bellard | |
2569 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
2570 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
2571 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
2572 | 9a64fbe4 | bellard | if (ra == 0) { |
2573 | 9a64fbe4 | bellard | ra = rb; |
2574 | 79aceca5 | bellard | } |
2575 | 9a64fbe4 | bellard | gen_op_load_xer_bc(); |
2576 | 9a64fbe4 | bellard | op_ldstsx(lswx, rD(ctx->opcode), ra, rb); |
2577 | 79aceca5 | bellard | } |
2578 | 79aceca5 | bellard | |
2579 | 79aceca5 | bellard | /* stswi */
|
2580 | 05332d70 | j_mayer | GEN_HANDLER(stswi, 0x1F, 0x15, 0x16, 0x00000001, PPC_STRING) |
2581 | 79aceca5 | bellard | { |
2582 | 4b3686fa | bellard | int nb = NB(ctx->opcode);
|
2583 | 4b3686fa | bellard | |
2584 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
2585 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
2586 | 76a66253 | j_mayer | gen_addr_register(ctx); |
2587 | 4b3686fa | bellard | if (nb == 0) |
2588 | 4b3686fa | bellard | nb = 32;
|
2589 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], nb);
|
2590 | 9a64fbe4 | bellard | op_ldsts(stsw, rS(ctx->opcode)); |
2591 | 79aceca5 | bellard | } |
2592 | 79aceca5 | bellard | |
2593 | 79aceca5 | bellard | /* stswx */
|
2594 | 05332d70 | j_mayer | GEN_HANDLER(stswx, 0x1F, 0x15, 0x14, 0x00000001, PPC_STRING) |
2595 | 79aceca5 | bellard | { |
2596 | 8dd4983c | bellard | /* NIP cannot be restored if the memory exception comes from an helper */
|
2597 | 5fafdf24 | ths | gen_update_nip(ctx, ctx->nip - 4);
|
2598 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
2599 | 76a66253 | j_mayer | gen_op_load_xer_bc(); |
2600 | 9a64fbe4 | bellard | op_ldsts(stsw, rS(ctx->opcode)); |
2601 | 79aceca5 | bellard | } |
2602 | 79aceca5 | bellard | |
2603 | 79aceca5 | bellard | /*** Memory synchronisation ***/
|
2604 | 79aceca5 | bellard | /* eieio */
|
2605 | 0db1b20e | j_mayer | GEN_HANDLER(eieio, 0x1F, 0x16, 0x1A, 0x03FFF801, PPC_MEM_EIEIO) |
2606 | 79aceca5 | bellard | { |
2607 | 79aceca5 | bellard | } |
2608 | 79aceca5 | bellard | |
2609 | 79aceca5 | bellard | /* isync */
|
2610 | 0db1b20e | j_mayer | GEN_HANDLER(isync, 0x13, 0x16, 0x04, 0x03FFF801, PPC_MEM) |
2611 | 79aceca5 | bellard | { |
2612 | e1833e1f | j_mayer | GEN_STOP(ctx); |
2613 | 79aceca5 | bellard | } |
2614 | 79aceca5 | bellard | |
2615 | 111bfab3 | bellard | #define op_lwarx() (*gen_op_lwarx[ctx->mem_idx])()
|
2616 | 111bfab3 | bellard | #define op_stwcx() (*gen_op_stwcx[ctx->mem_idx])()
|
2617 | 7863667f | j_mayer | static GenOpFunc *gen_op_lwarx[NB_MEM_FUNCS] = {
|
2618 | 7863667f | j_mayer | GEN_MEM_FUNCS(lwarx), |
2619 | 111bfab3 | bellard | }; |
2620 | 7863667f | j_mayer | static GenOpFunc *gen_op_stwcx[NB_MEM_FUNCS] = {
|
2621 | 7863667f | j_mayer | GEN_MEM_FUNCS(stwcx), |
2622 | 985a19d6 | bellard | }; |
2623 | 9a64fbe4 | bellard | |
2624 | 111bfab3 | bellard | /* lwarx */
|
2625 | 76a66253 | j_mayer | GEN_HANDLER(lwarx, 0x1F, 0x14, 0x00, 0x00000001, PPC_RES) |
2626 | 79aceca5 | bellard | { |
2627 | 30032c94 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
2628 | 30032c94 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
2629 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
2630 | 985a19d6 | bellard | op_lwarx(); |
2631 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]);
|
2632 | 79aceca5 | bellard | } |
2633 | 79aceca5 | bellard | |
2634 | 79aceca5 | bellard | /* stwcx. */
|
2635 | c7697e1f | j_mayer | GEN_HANDLER2(stwcx_, "stwcx.", 0x1F, 0x16, 0x04, 0x00000000, PPC_RES) |
2636 | 79aceca5 | bellard | { |
2637 | 30032c94 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
2638 | 30032c94 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
2639 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
2640 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
2641 | 9a64fbe4 | bellard | op_stwcx(); |
2642 | 79aceca5 | bellard | } |
2643 | 79aceca5 | bellard | |
2644 | 426613db | j_mayer | #if defined(TARGET_PPC64)
|
2645 | 426613db | j_mayer | #define op_ldarx() (*gen_op_ldarx[ctx->mem_idx])()
|
2646 | 426613db | j_mayer | #define op_stdcx() (*gen_op_stdcx[ctx->mem_idx])()
|
2647 | 7863667f | j_mayer | static GenOpFunc *gen_op_ldarx[NB_MEM_FUNCS] = {
|
2648 | 7863667f | j_mayer | GEN_MEM_FUNCS(ldarx), |
2649 | 426613db | j_mayer | }; |
2650 | 7863667f | j_mayer | static GenOpFunc *gen_op_stdcx[NB_MEM_FUNCS] = {
|
2651 | 7863667f | j_mayer | GEN_MEM_FUNCS(stdcx), |
2652 | 426613db | j_mayer | }; |
2653 | 426613db | j_mayer | |
2654 | 426613db | j_mayer | /* ldarx */
|
2655 | a750fc0b | j_mayer | GEN_HANDLER(ldarx, 0x1F, 0x14, 0x02, 0x00000001, PPC_64B) |
2656 | 426613db | j_mayer | { |
2657 | 30032c94 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
2658 | 30032c94 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
2659 | 426613db | j_mayer | gen_addr_reg_index(ctx); |
2660 | 426613db | j_mayer | op_ldarx(); |
2661 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[1]);
|
2662 | 426613db | j_mayer | } |
2663 | 426613db | j_mayer | |
2664 | 426613db | j_mayer | /* stdcx. */
|
2665 | c7697e1f | j_mayer | GEN_HANDLER2(stdcx_, "stdcx.", 0x1F, 0x16, 0x06, 0x00000000, PPC_64B) |
2666 | 426613db | j_mayer | { |
2667 | 30032c94 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
2668 | 30032c94 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
2669 | 426613db | j_mayer | gen_addr_reg_index(ctx); |
2670 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
2671 | 426613db | j_mayer | op_stdcx(); |
2672 | 426613db | j_mayer | } |
2673 | 426613db | j_mayer | #endif /* defined(TARGET_PPC64) */ |
2674 | 426613db | j_mayer | |
2675 | 79aceca5 | bellard | /* sync */
|
2676 | a902d886 | j_mayer | GEN_HANDLER(sync, 0x1F, 0x16, 0x12, 0x039FF801, PPC_MEM_SYNC) |
2677 | 79aceca5 | bellard | { |
2678 | 79aceca5 | bellard | } |
2679 | 79aceca5 | bellard | |
2680 | 0db1b20e | j_mayer | /* wait */
|
2681 | 0db1b20e | j_mayer | GEN_HANDLER(wait, 0x1F, 0x1E, 0x01, 0x03FFF801, PPC_WAIT) |
2682 | 0db1b20e | j_mayer | { |
2683 | 0db1b20e | j_mayer | /* Stop translation, as the CPU is supposed to sleep from now */
|
2684 | be147d08 | j_mayer | gen_op_wait(); |
2685 | be147d08 | j_mayer | GEN_EXCP(ctx, EXCP_HLT, 1);
|
2686 | 0db1b20e | j_mayer | } |
2687 | 0db1b20e | j_mayer | |
2688 | 79aceca5 | bellard | /*** Floating-point load ***/
|
2689 | 477023a6 | j_mayer | #define GEN_LDF(width, opc, type) \
|
2690 | 477023a6 | j_mayer | GEN_HANDLER(l##width, opc, 0xFF, 0xFF, 0x00000000, type) \ |
2691 | 79aceca5 | bellard | { \ |
2692 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
2693 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
2694 | 4ecc3190 | bellard | return; \
|
2695 | 4ecc3190 | bellard | } \ |
2696 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0); \
|
2697 | 9a64fbe4 | bellard | op_ldst(l##width); \ |
2698 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
|
2699 | 79aceca5 | bellard | } |
2700 | 79aceca5 | bellard | |
2701 | 477023a6 | j_mayer | #define GEN_LDUF(width, opc, type) \
|
2702 | 477023a6 | j_mayer | GEN_HANDLER(l##width##u, opc, 0xFF, 0xFF, 0x00000000, type) \ |
2703 | 79aceca5 | bellard | { \ |
2704 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
2705 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
2706 | 4ecc3190 | bellard | return; \
|
2707 | 4ecc3190 | bellard | } \ |
2708 | 76a66253 | j_mayer | if (unlikely(rA(ctx->opcode) == 0)) { \ |
2709 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); \ |
2710 | 9fddaa0c | bellard | return; \
|
2711 | 9a64fbe4 | bellard | } \ |
2712 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0); \
|
2713 | 9a64fbe4 | bellard | op_ldst(l##width); \ |
2714 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
|
2715 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
2716 | 79aceca5 | bellard | } |
2717 | 79aceca5 | bellard | |
2718 | 477023a6 | j_mayer | #define GEN_LDUXF(width, opc, type) \
|
2719 | 477023a6 | j_mayer | GEN_HANDLER(l##width##ux, 0x1F, 0x17, opc, 0x00000001, type) \ |
2720 | 79aceca5 | bellard | { \ |
2721 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
2722 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
2723 | 4ecc3190 | bellard | return; \
|
2724 | 4ecc3190 | bellard | } \ |
2725 | 76a66253 | j_mayer | if (unlikely(rA(ctx->opcode) == 0)) { \ |
2726 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); \ |
2727 | 9fddaa0c | bellard | return; \
|
2728 | 9a64fbe4 | bellard | } \ |
2729 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); \ |
2730 | 9a64fbe4 | bellard | op_ldst(l##width); \ |
2731 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
|
2732 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
2733 | 79aceca5 | bellard | } |
2734 | 79aceca5 | bellard | |
2735 | 477023a6 | j_mayer | #define GEN_LDXF(width, opc2, opc3, type) \
|
2736 | 477023a6 | j_mayer | GEN_HANDLER(l##width##x, 0x1F, opc2, opc3, 0x00000001, type) \ |
2737 | 79aceca5 | bellard | { \ |
2738 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
2739 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
2740 | 4ecc3190 | bellard | return; \
|
2741 | 4ecc3190 | bellard | } \ |
2742 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); \ |
2743 | 9a64fbe4 | bellard | op_ldst(l##width); \ |
2744 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]); \
|
2745 | 79aceca5 | bellard | } |
2746 | 79aceca5 | bellard | |
2747 | 477023a6 | j_mayer | #define GEN_LDFS(width, op, type) \
|
2748 | 9a64fbe4 | bellard | OP_LD_TABLE(width); \ |
2749 | 477023a6 | j_mayer | GEN_LDF(width, op | 0x20, type); \
|
2750 | 477023a6 | j_mayer | GEN_LDUF(width, op | 0x21, type); \
|
2751 | 477023a6 | j_mayer | GEN_LDUXF(width, op | 0x01, type); \
|
2752 | 477023a6 | j_mayer | GEN_LDXF(width, 0x17, op | 0x00, type) |
2753 | 79aceca5 | bellard | |
2754 | 79aceca5 | bellard | /* lfd lfdu lfdux lfdx */
|
2755 | 477023a6 | j_mayer | GEN_LDFS(fd, 0x12, PPC_FLOAT);
|
2756 | 79aceca5 | bellard | /* lfs lfsu lfsux lfsx */
|
2757 | 477023a6 | j_mayer | GEN_LDFS(fs, 0x10, PPC_FLOAT);
|
2758 | 79aceca5 | bellard | |
2759 | 79aceca5 | bellard | /*** Floating-point store ***/
|
2760 | 477023a6 | j_mayer | #define GEN_STF(width, opc, type) \
|
2761 | 477023a6 | j_mayer | GEN_HANDLER(st##width, opc, 0xFF, 0xFF, 0x00000000, type) \ |
2762 | 79aceca5 | bellard | { \ |
2763 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
2764 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
2765 | 4ecc3190 | bellard | return; \
|
2766 | 4ecc3190 | bellard | } \ |
2767 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0); \
|
2768 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]); \
|
2769 | 9a64fbe4 | bellard | op_ldst(st##width); \ |
2770 | 79aceca5 | bellard | } |
2771 | 79aceca5 | bellard | |
2772 | 477023a6 | j_mayer | #define GEN_STUF(width, opc, type) \
|
2773 | 477023a6 | j_mayer | GEN_HANDLER(st##width##u, opc, 0xFF, 0xFF, 0x00000000, type) \ |
2774 | 79aceca5 | bellard | { \ |
2775 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
2776 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
2777 | 4ecc3190 | bellard | return; \
|
2778 | 4ecc3190 | bellard | } \ |
2779 | 76a66253 | j_mayer | if (unlikely(rA(ctx->opcode) == 0)) { \ |
2780 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); \ |
2781 | 9fddaa0c | bellard | return; \
|
2782 | 9a64fbe4 | bellard | } \ |
2783 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0); \
|
2784 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]); \
|
2785 | 9a64fbe4 | bellard | op_ldst(st##width); \ |
2786 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
2787 | 79aceca5 | bellard | } |
2788 | 79aceca5 | bellard | |
2789 | 477023a6 | j_mayer | #define GEN_STUXF(width, opc, type) \
|
2790 | 477023a6 | j_mayer | GEN_HANDLER(st##width##ux, 0x1F, 0x17, opc, 0x00000001, type) \ |
2791 | 79aceca5 | bellard | { \ |
2792 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
2793 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
2794 | 4ecc3190 | bellard | return; \
|
2795 | 4ecc3190 | bellard | } \ |
2796 | 76a66253 | j_mayer | if (unlikely(rA(ctx->opcode) == 0)) { \ |
2797 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); \ |
2798 | 9fddaa0c | bellard | return; \
|
2799 | 9a64fbe4 | bellard | } \ |
2800 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); \ |
2801 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]); \
|
2802 | 9a64fbe4 | bellard | op_ldst(st##width); \ |
2803 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); \
|
2804 | 79aceca5 | bellard | } |
2805 | 79aceca5 | bellard | |
2806 | 477023a6 | j_mayer | #define GEN_STXF(width, opc2, opc3, type) \
|
2807 | 477023a6 | j_mayer | GEN_HANDLER(st##width##x, 0x1F, opc2, opc3, 0x00000001, type) \ |
2808 | 79aceca5 | bellard | { \ |
2809 | 76a66253 | j_mayer | if (unlikely(!ctx->fpu_enabled)) { \
|
2810 | e1833e1f | j_mayer | GEN_EXCP_NO_FP(ctx); \ |
2811 | 4ecc3190 | bellard | return; \
|
2812 | 4ecc3190 | bellard | } \ |
2813 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); \ |
2814 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]); \
|
2815 | 9a64fbe4 | bellard | op_ldst(st##width); \ |
2816 | 79aceca5 | bellard | } |
2817 | 79aceca5 | bellard | |
2818 | 477023a6 | j_mayer | #define GEN_STFS(width, op, type) \
|
2819 | 9a64fbe4 | bellard | OP_ST_TABLE(width); \ |
2820 | 477023a6 | j_mayer | GEN_STF(width, op | 0x20, type); \
|
2821 | 477023a6 | j_mayer | GEN_STUF(width, op | 0x21, type); \
|
2822 | 477023a6 | j_mayer | GEN_STUXF(width, op | 0x01, type); \
|
2823 | 477023a6 | j_mayer | GEN_STXF(width, 0x17, op | 0x00, type) |
2824 | 79aceca5 | bellard | |
2825 | 79aceca5 | bellard | /* stfd stfdu stfdux stfdx */
|
2826 | 477023a6 | j_mayer | GEN_STFS(fd, 0x16, PPC_FLOAT);
|
2827 | 79aceca5 | bellard | /* stfs stfsu stfsux stfsx */
|
2828 | 477023a6 | j_mayer | GEN_STFS(fs, 0x14, PPC_FLOAT);
|
2829 | 79aceca5 | bellard | |
2830 | 79aceca5 | bellard | /* Optional: */
|
2831 | 79aceca5 | bellard | /* stfiwx */
|
2832 | 5b8105fa | j_mayer | OP_ST_TABLE(fiw); |
2833 | 5b8105fa | j_mayer | GEN_STXF(fiw, 0x17, 0x1E, PPC_FLOAT_STFIWX); |
2834 | 79aceca5 | bellard | |
2835 | 79aceca5 | bellard | /*** Branch ***/
|
2836 | b068d6a7 | j_mayer | static always_inline void gen_goto_tb (DisasContext *ctx, int n, |
2837 | b068d6a7 | j_mayer | target_ulong dest) |
2838 | c1942362 | bellard | { |
2839 | c1942362 | bellard | TranslationBlock *tb; |
2840 | c1942362 | bellard | tb = ctx->tb; |
2841 | 57fec1fe | bellard | if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) &&
|
2842 | 8cbcb4fa | aurel32 | likely(!ctx->singlestep_enabled)) { |
2843 | 57fec1fe | bellard | tcg_gen_goto_tb(n); |
2844 | 02f4f6c2 | aurel32 | tcg_gen_movi_tl(cpu_T[1], dest);
|
2845 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2846 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
2847 | bd568f18 | aurel32 | tcg_gen_andi_tl(cpu_nip, cpu_T[1], ~3); |
2848 | d9bce9d9 | j_mayer | else
|
2849 | d9bce9d9 | j_mayer | #endif
|
2850 | bd568f18 | aurel32 | tcg_gen_andi_tl(cpu_nip, cpu_T[1], (uint32_t)~3); |
2851 | 57fec1fe | bellard | tcg_gen_exit_tb((long)tb + n);
|
2852 | c1942362 | bellard | } else {
|
2853 | 02f4f6c2 | aurel32 | tcg_gen_movi_tl(cpu_T[1], dest);
|
2854 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2855 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
2856 | bd568f18 | aurel32 | tcg_gen_andi_tl(cpu_nip, cpu_T[1], ~3); |
2857 | d9bce9d9 | j_mayer | else
|
2858 | d9bce9d9 | j_mayer | #endif
|
2859 | bd568f18 | aurel32 | tcg_gen_andi_tl(cpu_nip, cpu_T[1], (uint32_t)~3); |
2860 | 8cbcb4fa | aurel32 | if (unlikely(ctx->singlestep_enabled)) {
|
2861 | 8cbcb4fa | aurel32 | if ((ctx->singlestep_enabled &
|
2862 | 8cbcb4fa | aurel32 | (CPU_BRANCH_STEP | CPU_SINGLE_STEP)) && |
2863 | 8cbcb4fa | aurel32 | ctx->exception == POWERPC_EXCP_BRANCH) { |
2864 | 8cbcb4fa | aurel32 | target_ulong tmp = ctx->nip; |
2865 | 8cbcb4fa | aurel32 | ctx->nip = dest; |
2866 | 8cbcb4fa | aurel32 | GEN_EXCP(ctx, POWERPC_EXCP_TRACE, 0);
|
2867 | 8cbcb4fa | aurel32 | ctx->nip = tmp; |
2868 | 8cbcb4fa | aurel32 | } |
2869 | 8cbcb4fa | aurel32 | if (ctx->singlestep_enabled & GDBSTUB_SINGLE_STEP) {
|
2870 | 8cbcb4fa | aurel32 | gen_update_nip(ctx, dest); |
2871 | 8cbcb4fa | aurel32 | gen_op_debug(); |
2872 | 8cbcb4fa | aurel32 | } |
2873 | 8cbcb4fa | aurel32 | } |
2874 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
2875 | c1942362 | bellard | } |
2876 | c53be334 | bellard | } |
2877 | c53be334 | bellard | |
2878 | b068d6a7 | j_mayer | static always_inline void gen_setlr (DisasContext *ctx, target_ulong nip) |
2879 | e1833e1f | j_mayer | { |
2880 | e1833e1f | j_mayer | #if defined(TARGET_PPC64)
|
2881 | e1833e1f | j_mayer | if (ctx->sf_mode != 0 && (nip >> 32)) |
2882 | e1833e1f | j_mayer | gen_op_setlr_64(ctx->nip >> 32, ctx->nip);
|
2883 | e1833e1f | j_mayer | else
|
2884 | e1833e1f | j_mayer | #endif
|
2885 | e1833e1f | j_mayer | gen_op_setlr(ctx->nip); |
2886 | e1833e1f | j_mayer | } |
2887 | e1833e1f | j_mayer | |
2888 | 79aceca5 | bellard | /* b ba bl bla */
|
2889 | 79aceca5 | bellard | GEN_HANDLER(b, 0x12, 0xFF, 0xFF, 0x00000000, PPC_FLOW) |
2890 | 79aceca5 | bellard | { |
2891 | 76a66253 | j_mayer | target_ulong li, target; |
2892 | 38a64f9d | bellard | |
2893 | 8cbcb4fa | aurel32 | ctx->exception = POWERPC_EXCP_BRANCH; |
2894 | 38a64f9d | bellard | /* sign extend LI */
|
2895 | 76a66253 | j_mayer | #if defined(TARGET_PPC64)
|
2896 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
2897 | d9bce9d9 | j_mayer | li = ((int64_t)LI(ctx->opcode) << 38) >> 38; |
2898 | d9bce9d9 | j_mayer | else
|
2899 | 76a66253 | j_mayer | #endif
|
2900 | d9bce9d9 | j_mayer | li = ((int32_t)LI(ctx->opcode) << 6) >> 6; |
2901 | 76a66253 | j_mayer | if (likely(AA(ctx->opcode) == 0)) |
2902 | 046d6672 | bellard | target = ctx->nip + li - 4;
|
2903 | 79aceca5 | bellard | else
|
2904 | 9a64fbe4 | bellard | target = li; |
2905 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2906 | e1833e1f | j_mayer | if (!ctx->sf_mode)
|
2907 | e1833e1f | j_mayer | target = (uint32_t)target; |
2908 | d9bce9d9 | j_mayer | #endif
|
2909 | e1833e1f | j_mayer | if (LK(ctx->opcode))
|
2910 | e1833e1f | j_mayer | gen_setlr(ctx, ctx->nip); |
2911 | c1942362 | bellard | gen_goto_tb(ctx, 0, target);
|
2912 | 79aceca5 | bellard | } |
2913 | 79aceca5 | bellard | |
2914 | e98a6e40 | bellard | #define BCOND_IM 0 |
2915 | e98a6e40 | bellard | #define BCOND_LR 1 |
2916 | e98a6e40 | bellard | #define BCOND_CTR 2 |
2917 | e98a6e40 | bellard | |
2918 | b068d6a7 | j_mayer | static always_inline void gen_bcond (DisasContext *ctx, int type) |
2919 | d9bce9d9 | j_mayer | { |
2920 | 76a66253 | j_mayer | target_ulong target = 0;
|
2921 | 76a66253 | j_mayer | target_ulong li; |
2922 | d9bce9d9 | j_mayer | uint32_t bo = BO(ctx->opcode); |
2923 | d9bce9d9 | j_mayer | uint32_t bi = BI(ctx->opcode); |
2924 | d9bce9d9 | j_mayer | uint32_t mask; |
2925 | e98a6e40 | bellard | |
2926 | 8cbcb4fa | aurel32 | ctx->exception = POWERPC_EXCP_BRANCH; |
2927 | e98a6e40 | bellard | if ((bo & 0x4) == 0) |
2928 | d9bce9d9 | j_mayer | gen_op_dec_ctr(); |
2929 | e98a6e40 | bellard | switch(type) {
|
2930 | e98a6e40 | bellard | case BCOND_IM:
|
2931 | 76a66253 | j_mayer | li = (target_long)((int16_t)(BD(ctx->opcode))); |
2932 | 76a66253 | j_mayer | if (likely(AA(ctx->opcode) == 0)) { |
2933 | 046d6672 | bellard | target = ctx->nip + li - 4;
|
2934 | e98a6e40 | bellard | } else {
|
2935 | e98a6e40 | bellard | target = li; |
2936 | e98a6e40 | bellard | } |
2937 | e1833e1f | j_mayer | #if defined(TARGET_PPC64)
|
2938 | e1833e1f | j_mayer | if (!ctx->sf_mode)
|
2939 | e1833e1f | j_mayer | target = (uint32_t)target; |
2940 | e1833e1f | j_mayer | #endif
|
2941 | e98a6e40 | bellard | break;
|
2942 | e98a6e40 | bellard | case BCOND_CTR:
|
2943 | e98a6e40 | bellard | gen_op_movl_T1_ctr(); |
2944 | e98a6e40 | bellard | break;
|
2945 | e98a6e40 | bellard | default:
|
2946 | e98a6e40 | bellard | case BCOND_LR:
|
2947 | e98a6e40 | bellard | gen_op_movl_T1_lr(); |
2948 | e98a6e40 | bellard | break;
|
2949 | e98a6e40 | bellard | } |
2950 | e1833e1f | j_mayer | if (LK(ctx->opcode))
|
2951 | e1833e1f | j_mayer | gen_setlr(ctx, ctx->nip); |
2952 | e98a6e40 | bellard | if (bo & 0x10) { |
2953 | d9bce9d9 | j_mayer | /* No CR condition */
|
2954 | d9bce9d9 | j_mayer | switch (bo & 0x6) { |
2955 | d9bce9d9 | j_mayer | case 0: |
2956 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2957 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
2958 | d9bce9d9 | j_mayer | gen_op_test_ctr_64(); |
2959 | d9bce9d9 | j_mayer | else
|
2960 | d9bce9d9 | j_mayer | #endif
|
2961 | d9bce9d9 | j_mayer | gen_op_test_ctr(); |
2962 | d9bce9d9 | j_mayer | break;
|
2963 | d9bce9d9 | j_mayer | case 2: |
2964 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2965 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
2966 | d9bce9d9 | j_mayer | gen_op_test_ctrz_64(); |
2967 | d9bce9d9 | j_mayer | else
|
2968 | d9bce9d9 | j_mayer | #endif
|
2969 | d9bce9d9 | j_mayer | gen_op_test_ctrz(); |
2970 | e98a6e40 | bellard | break;
|
2971 | e98a6e40 | bellard | default:
|
2972 | d9bce9d9 | j_mayer | case 4: |
2973 | d9bce9d9 | j_mayer | case 6: |
2974 | e98a6e40 | bellard | if (type == BCOND_IM) {
|
2975 | c1942362 | bellard | gen_goto_tb(ctx, 0, target);
|
2976 | 8cbcb4fa | aurel32 | return;
|
2977 | e98a6e40 | bellard | } else {
|
2978 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2979 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
2980 | bd568f18 | aurel32 | tcg_gen_andi_tl(cpu_nip, cpu_T[1], ~3); |
2981 | d9bce9d9 | j_mayer | else
|
2982 | d9bce9d9 | j_mayer | #endif
|
2983 | bd568f18 | aurel32 | tcg_gen_andi_tl(cpu_nip, cpu_T[1], (uint32_t)~3); |
2984 | 056b05f8 | j_mayer | goto no_test;
|
2985 | e98a6e40 | bellard | } |
2986 | 056b05f8 | j_mayer | break;
|
2987 | e98a6e40 | bellard | } |
2988 | d9bce9d9 | j_mayer | } else {
|
2989 | d9bce9d9 | j_mayer | mask = 1 << (3 - (bi & 0x03)); |
2990 | 47e4661c | aurel32 | tcg_gen_mov_i32(cpu_T[0], cpu_crf[bi >> 2]); |
2991 | d9bce9d9 | j_mayer | if (bo & 0x8) { |
2992 | d9bce9d9 | j_mayer | switch (bo & 0x6) { |
2993 | d9bce9d9 | j_mayer | case 0: |
2994 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
2995 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
2996 | d9bce9d9 | j_mayer | gen_op_test_ctr_true_64(mask); |
2997 | d9bce9d9 | j_mayer | else
|
2998 | d9bce9d9 | j_mayer | #endif
|
2999 | d9bce9d9 | j_mayer | gen_op_test_ctr_true(mask); |
3000 | d9bce9d9 | j_mayer | break;
|
3001 | d9bce9d9 | j_mayer | case 2: |
3002 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
3003 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
3004 | d9bce9d9 | j_mayer | gen_op_test_ctrz_true_64(mask); |
3005 | d9bce9d9 | j_mayer | else
|
3006 | d9bce9d9 | j_mayer | #endif
|
3007 | d9bce9d9 | j_mayer | gen_op_test_ctrz_true(mask); |
3008 | d9bce9d9 | j_mayer | break;
|
3009 | d9bce9d9 | j_mayer | default:
|
3010 | d9bce9d9 | j_mayer | case 4: |
3011 | d9bce9d9 | j_mayer | case 6: |
3012 | e98a6e40 | bellard | gen_op_test_true(mask); |
3013 | d9bce9d9 | j_mayer | break;
|
3014 | d9bce9d9 | j_mayer | } |
3015 | d9bce9d9 | j_mayer | } else {
|
3016 | d9bce9d9 | j_mayer | switch (bo & 0x6) { |
3017 | d9bce9d9 | j_mayer | case 0: |
3018 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
3019 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
3020 | d9bce9d9 | j_mayer | gen_op_test_ctr_false_64(mask); |
3021 | d9bce9d9 | j_mayer | else
|
3022 | d9bce9d9 | j_mayer | #endif
|
3023 | d9bce9d9 | j_mayer | gen_op_test_ctr_false(mask); |
3024 | 3b46e624 | ths | break;
|
3025 | d9bce9d9 | j_mayer | case 2: |
3026 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
3027 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
3028 | d9bce9d9 | j_mayer | gen_op_test_ctrz_false_64(mask); |
3029 | d9bce9d9 | j_mayer | else
|
3030 | d9bce9d9 | j_mayer | #endif
|
3031 | d9bce9d9 | j_mayer | gen_op_test_ctrz_false(mask); |
3032 | d9bce9d9 | j_mayer | break;
|
3033 | e98a6e40 | bellard | default:
|
3034 | d9bce9d9 | j_mayer | case 4: |
3035 | d9bce9d9 | j_mayer | case 6: |
3036 | e98a6e40 | bellard | gen_op_test_false(mask); |
3037 | d9bce9d9 | j_mayer | break;
|
3038 | d9bce9d9 | j_mayer | } |
3039 | d9bce9d9 | j_mayer | } |
3040 | d9bce9d9 | j_mayer | } |
3041 | e98a6e40 | bellard | if (type == BCOND_IM) {
|
3042 | c53be334 | bellard | int l1 = gen_new_label();
|
3043 | c53be334 | bellard | gen_op_jz_T0(l1); |
3044 | c1942362 | bellard | gen_goto_tb(ctx, 0, target);
|
3045 | c53be334 | bellard | gen_set_label(l1); |
3046 | c1942362 | bellard | gen_goto_tb(ctx, 1, ctx->nip);
|
3047 | e98a6e40 | bellard | } else {
|
3048 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
3049 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
3050 | d9bce9d9 | j_mayer | gen_op_btest_T1_64(ctx->nip >> 32, ctx->nip);
|
3051 | d9bce9d9 | j_mayer | else
|
3052 | d9bce9d9 | j_mayer | #endif
|
3053 | d9bce9d9 | j_mayer | gen_op_btest_T1(ctx->nip); |
3054 | 36081602 | j_mayer | no_test:
|
3055 | 8cbcb4fa | aurel32 | if (ctx->singlestep_enabled & GDBSTUB_SINGLE_STEP) {
|
3056 | 8cbcb4fa | aurel32 | gen_update_nip(ctx, ctx->nip); |
3057 | 08e46e54 | j_mayer | gen_op_debug(); |
3058 | 8cbcb4fa | aurel32 | } |
3059 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
3060 | 08e46e54 | j_mayer | } |
3061 | e98a6e40 | bellard | } |
3062 | e98a6e40 | bellard | |
3063 | e98a6e40 | bellard | GEN_HANDLER(bc, 0x10, 0xFF, 0xFF, 0x00000000, PPC_FLOW) |
3064 | 3b46e624 | ths | { |
3065 | e98a6e40 | bellard | gen_bcond(ctx, BCOND_IM); |
3066 | e98a6e40 | bellard | } |
3067 | e98a6e40 | bellard | |
3068 | e98a6e40 | bellard | GEN_HANDLER(bcctr, 0x13, 0x10, 0x10, 0x00000000, PPC_FLOW) |
3069 | 3b46e624 | ths | { |
3070 | e98a6e40 | bellard | gen_bcond(ctx, BCOND_CTR); |
3071 | e98a6e40 | bellard | } |
3072 | e98a6e40 | bellard | |
3073 | e98a6e40 | bellard | GEN_HANDLER(bclr, 0x13, 0x10, 0x00, 0x00000000, PPC_FLOW) |
3074 | 3b46e624 | ths | { |
3075 | e98a6e40 | bellard | gen_bcond(ctx, BCOND_LR); |
3076 | e98a6e40 | bellard | } |
3077 | 79aceca5 | bellard | |
3078 | 79aceca5 | bellard | /*** Condition register logical ***/
|
3079 | 79aceca5 | bellard | #define GEN_CRLOGIC(op, opc) \
|
3080 | 79aceca5 | bellard | GEN_HANDLER(cr##op, 0x13, 0x01, opc, 0x00000001, PPC_INTEGER) \ |
3081 | 79aceca5 | bellard | { \ |
3082 | fc0d441e | j_mayer | uint8_t bitmask; \ |
3083 | fc0d441e | j_mayer | int sh; \
|
3084 | 47e4661c | aurel32 | tcg_gen_mov_i32(cpu_T[0], cpu_crf[crbA(ctx->opcode) >> 2]); \ |
3085 | fc0d441e | j_mayer | sh = (crbD(ctx->opcode) & 0x03) - (crbA(ctx->opcode) & 0x03); \ |
3086 | fc0d441e | j_mayer | if (sh > 0) \ |
3087 | fc0d441e | j_mayer | gen_op_srli_T0(sh); \ |
3088 | fc0d441e | j_mayer | else if (sh < 0) \ |
3089 | fc0d441e | j_mayer | gen_op_sli_T0(-sh); \ |
3090 | 47e4661c | aurel32 | tcg_gen_mov_i32(cpu_T[1], cpu_crf[crbB(ctx->opcode) >> 2]); \ |
3091 | fc0d441e | j_mayer | sh = (crbD(ctx->opcode) & 0x03) - (crbB(ctx->opcode) & 0x03); \ |
3092 | fc0d441e | j_mayer | if (sh > 0) \ |
3093 | fc0d441e | j_mayer | gen_op_srli_T1(sh); \ |
3094 | fc0d441e | j_mayer | else if (sh < 0) \ |
3095 | fc0d441e | j_mayer | gen_op_sli_T1(-sh); \ |
3096 | 79aceca5 | bellard | gen_op_##op(); \ |
3097 | fc0d441e | j_mayer | bitmask = 1 << (3 - (crbD(ctx->opcode) & 0x03)); \ |
3098 | fc0d441e | j_mayer | gen_op_andi_T0(bitmask); \ |
3099 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_T[1], cpu_crf[crbD(ctx->opcode) >> 2], ~bitmask); \ |
3100 | fc0d441e | j_mayer | gen_op_or(); \ |
3101 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crbD(ctx->opcode) >> 2], cpu_T[0], 0xf); \ |
3102 | 79aceca5 | bellard | } |
3103 | 79aceca5 | bellard | |
3104 | 79aceca5 | bellard | /* crand */
|
3105 | 76a66253 | j_mayer | GEN_CRLOGIC(and, 0x08);
|
3106 | 79aceca5 | bellard | /* crandc */
|
3107 | 76a66253 | j_mayer | GEN_CRLOGIC(andc, 0x04);
|
3108 | 79aceca5 | bellard | /* creqv */
|
3109 | 76a66253 | j_mayer | GEN_CRLOGIC(eqv, 0x09);
|
3110 | 79aceca5 | bellard | /* crnand */
|
3111 | 76a66253 | j_mayer | GEN_CRLOGIC(nand, 0x07);
|
3112 | 79aceca5 | bellard | /* crnor */
|
3113 | 76a66253 | j_mayer | GEN_CRLOGIC(nor, 0x01);
|
3114 | 79aceca5 | bellard | /* cror */
|
3115 | 76a66253 | j_mayer | GEN_CRLOGIC(or, 0x0E);
|
3116 | 79aceca5 | bellard | /* crorc */
|
3117 | 76a66253 | j_mayer | GEN_CRLOGIC(orc, 0x0D);
|
3118 | 79aceca5 | bellard | /* crxor */
|
3119 | 76a66253 | j_mayer | GEN_CRLOGIC(xor, 0x06);
|
3120 | 79aceca5 | bellard | /* mcrf */
|
3121 | 79aceca5 | bellard | GEN_HANDLER(mcrf, 0x13, 0x00, 0xFF, 0x00000001, PPC_INTEGER) |
3122 | 79aceca5 | bellard | { |
3123 | 47e4661c | aurel32 | tcg_gen_mov_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfS(ctx->opcode)]); |
3124 | 79aceca5 | bellard | } |
3125 | 79aceca5 | bellard | |
3126 | 79aceca5 | bellard | /*** System linkage ***/
|
3127 | 79aceca5 | bellard | /* rfi (supervisor only) */
|
3128 | 76a66253 | j_mayer | GEN_HANDLER(rfi, 0x13, 0x12, 0x01, 0x03FF8001, PPC_FLOW) |
3129 | 79aceca5 | bellard | { |
3130 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3131 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3132 | 9a64fbe4 | bellard | #else
|
3133 | 9a64fbe4 | bellard | /* Restore CPU state */
|
3134 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3135 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3136 | 9fddaa0c | bellard | return;
|
3137 | 9a64fbe4 | bellard | } |
3138 | a42bd6cc | j_mayer | gen_op_rfi(); |
3139 | e1833e1f | j_mayer | GEN_SYNC(ctx); |
3140 | 9a64fbe4 | bellard | #endif
|
3141 | 79aceca5 | bellard | } |
3142 | 79aceca5 | bellard | |
3143 | 426613db | j_mayer | #if defined(TARGET_PPC64)
|
3144 | a750fc0b | j_mayer | GEN_HANDLER(rfid, 0x13, 0x12, 0x00, 0x03FF8001, PPC_64B) |
3145 | 426613db | j_mayer | { |
3146 | 426613db | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3147 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3148 | 426613db | j_mayer | #else
|
3149 | 426613db | j_mayer | /* Restore CPU state */
|
3150 | 426613db | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3151 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3152 | 426613db | j_mayer | return;
|
3153 | 426613db | j_mayer | } |
3154 | a42bd6cc | j_mayer | gen_op_rfid(); |
3155 | e1833e1f | j_mayer | GEN_SYNC(ctx); |
3156 | 426613db | j_mayer | #endif
|
3157 | 426613db | j_mayer | } |
3158 | 426613db | j_mayer | |
3159 | 5b8105fa | j_mayer | GEN_HANDLER(hrfid, 0x13, 0x12, 0x08, 0x03FF8001, PPC_64H) |
3160 | be147d08 | j_mayer | { |
3161 | be147d08 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3162 | be147d08 | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3163 | be147d08 | j_mayer | #else
|
3164 | be147d08 | j_mayer | /* Restore CPU state */
|
3165 | be147d08 | j_mayer | if (unlikely(ctx->supervisor <= 1)) { |
3166 | be147d08 | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3167 | be147d08 | j_mayer | return;
|
3168 | be147d08 | j_mayer | } |
3169 | be147d08 | j_mayer | gen_op_hrfid(); |
3170 | be147d08 | j_mayer | GEN_SYNC(ctx); |
3171 | be147d08 | j_mayer | #endif
|
3172 | be147d08 | j_mayer | } |
3173 | be147d08 | j_mayer | #endif
|
3174 | be147d08 | j_mayer | |
3175 | 79aceca5 | bellard | /* sc */
|
3176 | 417bf010 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3177 | 417bf010 | j_mayer | #define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL_USER
|
3178 | 417bf010 | j_mayer | #else
|
3179 | 417bf010 | j_mayer | #define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL
|
3180 | 417bf010 | j_mayer | #endif
|
3181 | e1833e1f | j_mayer | GEN_HANDLER(sc, 0x11, 0xFF, 0xFF, 0x03FFF01D, PPC_FLOW) |
3182 | 79aceca5 | bellard | { |
3183 | e1833e1f | j_mayer | uint32_t lev; |
3184 | e1833e1f | j_mayer | |
3185 | e1833e1f | j_mayer | lev = (ctx->opcode >> 5) & 0x7F; |
3186 | 417bf010 | j_mayer | GEN_EXCP(ctx, POWERPC_SYSCALL, lev); |
3187 | 79aceca5 | bellard | } |
3188 | 79aceca5 | bellard | |
3189 | 79aceca5 | bellard | /*** Trap ***/
|
3190 | 79aceca5 | bellard | /* tw */
|
3191 | 76a66253 | j_mayer | GEN_HANDLER(tw, 0x1F, 0x04, 0x00, 0x00000001, PPC_FLOW) |
3192 | 79aceca5 | bellard | { |
3193 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3194 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3195 | a0ae05aa | ths | /* Update the nip since this might generate a trap exception */
|
3196 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip); |
3197 | 9a64fbe4 | bellard | gen_op_tw(TO(ctx->opcode)); |
3198 | 79aceca5 | bellard | } |
3199 | 79aceca5 | bellard | |
3200 | 79aceca5 | bellard | /* twi */
|
3201 | 79aceca5 | bellard | GEN_HANDLER(twi, 0x03, 0xFF, 0xFF, 0x00000000, PPC_FLOW) |
3202 | 79aceca5 | bellard | { |
3203 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3204 | 02f4f6c2 | aurel32 | tcg_gen_movi_tl(cpu_T[1], SIMM(ctx->opcode));
|
3205 | d9bce9d9 | j_mayer | /* Update the nip since this might generate a trap exception */
|
3206 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip); |
3207 | 76a66253 | j_mayer | gen_op_tw(TO(ctx->opcode)); |
3208 | 79aceca5 | bellard | } |
3209 | 79aceca5 | bellard | |
3210 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
3211 | d9bce9d9 | j_mayer | /* td */
|
3212 | d9bce9d9 | j_mayer | GEN_HANDLER(td, 0x1F, 0x04, 0x02, 0x00000001, PPC_64B) |
3213 | d9bce9d9 | j_mayer | { |
3214 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3215 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3216 | d9bce9d9 | j_mayer | /* Update the nip since this might generate a trap exception */
|
3217 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip); |
3218 | d9bce9d9 | j_mayer | gen_op_td(TO(ctx->opcode)); |
3219 | d9bce9d9 | j_mayer | } |
3220 | d9bce9d9 | j_mayer | |
3221 | d9bce9d9 | j_mayer | /* tdi */
|
3222 | d9bce9d9 | j_mayer | GEN_HANDLER(tdi, 0x02, 0xFF, 0xFF, 0x00000000, PPC_64B) |
3223 | d9bce9d9 | j_mayer | { |
3224 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3225 | 02f4f6c2 | aurel32 | tcg_gen_movi_tl(cpu_T[1], SIMM(ctx->opcode));
|
3226 | d9bce9d9 | j_mayer | /* Update the nip since this might generate a trap exception */
|
3227 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip); |
3228 | d9bce9d9 | j_mayer | gen_op_td(TO(ctx->opcode)); |
3229 | d9bce9d9 | j_mayer | } |
3230 | d9bce9d9 | j_mayer | #endif
|
3231 | d9bce9d9 | j_mayer | |
3232 | 79aceca5 | bellard | /*** Processor control ***/
|
3233 | 79aceca5 | bellard | /* mcrxr */
|
3234 | 79aceca5 | bellard | GEN_HANDLER(mcrxr, 0x1F, 0x00, 0x10, 0x007FF801, PPC_MISC) |
3235 | 79aceca5 | bellard | { |
3236 | 79aceca5 | bellard | gen_op_load_xer_cr(); |
3237 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_T[0], 0xf); |
3238 | e864cabd | j_mayer | gen_op_clear_xer_ov(); |
3239 | e864cabd | j_mayer | gen_op_clear_xer_ca(); |
3240 | 79aceca5 | bellard | } |
3241 | 79aceca5 | bellard | |
3242 | 79aceca5 | bellard | /* mfcr */
|
3243 | 76a66253 | j_mayer | GEN_HANDLER(mfcr, 0x1F, 0x13, 0x00, 0x00000801, PPC_MISC) |
3244 | 79aceca5 | bellard | { |
3245 | 76a66253 | j_mayer | uint32_t crm, crn; |
3246 | 3b46e624 | ths | |
3247 | 76a66253 | j_mayer | if (likely(ctx->opcode & 0x00100000)) { |
3248 | 76a66253 | j_mayer | crm = CRM(ctx->opcode); |
3249 | 76a66253 | j_mayer | if (likely((crm ^ (crm - 1)) == 0)) { |
3250 | 76a66253 | j_mayer | crn = ffs(crm); |
3251 | 47e4661c | aurel32 | tcg_gen_mov_i32(cpu_T[0], cpu_crf[7 - crn]); |
3252 | 76a66253 | j_mayer | } |
3253 | d9bce9d9 | j_mayer | } else {
|
3254 | 6676f424 | aurel32 | gen_op_load_cr(); |
3255 | d9bce9d9 | j_mayer | } |
3256 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3257 | 79aceca5 | bellard | } |
3258 | 79aceca5 | bellard | |
3259 | 79aceca5 | bellard | /* mfmsr */
|
3260 | 79aceca5 | bellard | GEN_HANDLER(mfmsr, 0x1F, 0x13, 0x02, 0x001FF801, PPC_MISC) |
3261 | 79aceca5 | bellard | { |
3262 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3263 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3264 | 9a64fbe4 | bellard | #else
|
3265 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3266 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3267 | 9fddaa0c | bellard | return;
|
3268 | 9a64fbe4 | bellard | } |
3269 | 6676f424 | aurel32 | gen_op_load_msr(); |
3270 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3271 | 9a64fbe4 | bellard | #endif
|
3272 | 79aceca5 | bellard | } |
3273 | 79aceca5 | bellard | |
3274 | a11b8151 | j_mayer | #if 1 |
3275 | 6f2d8978 | j_mayer | #define SPR_NOACCESS ((void *)(-1UL)) |
3276 | 3fc6c082 | bellard | #else
|
3277 | 3fc6c082 | bellard | static void spr_noaccess (void *opaque, int sprn) |
3278 | 3fc6c082 | bellard | { |
3279 | 3fc6c082 | bellard | sprn = ((sprn >> 5) & 0x1F) | ((sprn & 0x1F) << 5); |
3280 | 3fc6c082 | bellard | printf("ERROR: try to access SPR %d !\n", sprn);
|
3281 | 3fc6c082 | bellard | } |
3282 | 3fc6c082 | bellard | #define SPR_NOACCESS (&spr_noaccess)
|
3283 | 3fc6c082 | bellard | #endif
|
3284 | 3fc6c082 | bellard | |
3285 | 79aceca5 | bellard | /* mfspr */
|
3286 | b068d6a7 | j_mayer | static always_inline void gen_op_mfspr (DisasContext *ctx) |
3287 | 79aceca5 | bellard | { |
3288 | 3fc6c082 | bellard | void (*read_cb)(void *opaque, int sprn); |
3289 | 79aceca5 | bellard | uint32_t sprn = SPR(ctx->opcode); |
3290 | 79aceca5 | bellard | |
3291 | 3fc6c082 | bellard | #if !defined(CONFIG_USER_ONLY)
|
3292 | be147d08 | j_mayer | if (ctx->supervisor == 2) |
3293 | be147d08 | j_mayer | read_cb = ctx->spr_cb[sprn].hea_read; |
3294 | 7863667f | j_mayer | else if (ctx->supervisor) |
3295 | 3fc6c082 | bellard | read_cb = ctx->spr_cb[sprn].oea_read; |
3296 | 3fc6c082 | bellard | else
|
3297 | 9a64fbe4 | bellard | #endif
|
3298 | 3fc6c082 | bellard | read_cb = ctx->spr_cb[sprn].uea_read; |
3299 | 76a66253 | j_mayer | if (likely(read_cb != NULL)) { |
3300 | 76a66253 | j_mayer | if (likely(read_cb != SPR_NOACCESS)) {
|
3301 | 3fc6c082 | bellard | (*read_cb)(ctx, sprn); |
3302 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3303 | 3fc6c082 | bellard | } else {
|
3304 | 3fc6c082 | bellard | /* Privilege exception */
|
3305 | 9fceefa7 | j_mayer | /* This is a hack to avoid warnings when running Linux:
|
3306 | 9fceefa7 | j_mayer | * this OS breaks the PowerPC virtualisation model,
|
3307 | 9fceefa7 | j_mayer | * allowing userland application to read the PVR
|
3308 | 9fceefa7 | j_mayer | */
|
3309 | 9fceefa7 | j_mayer | if (sprn != SPR_PVR) {
|
3310 | 9fceefa7 | j_mayer | if (loglevel != 0) { |
3311 | 6b542af7 | j_mayer | fprintf(logfile, "Trying to read privileged spr %d %03x at "
|
3312 | 077fc206 | j_mayer | ADDRX "\n", sprn, sprn, ctx->nip);
|
3313 | 9fceefa7 | j_mayer | } |
3314 | 077fc206 | j_mayer | printf("Trying to read privileged spr %d %03x at " ADDRX "\n", |
3315 | 077fc206 | j_mayer | sprn, sprn, ctx->nip); |
3316 | f24e5695 | bellard | } |
3317 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3318 | 79aceca5 | bellard | } |
3319 | 3fc6c082 | bellard | } else {
|
3320 | 3fc6c082 | bellard | /* Not defined */
|
3321 | 4a057712 | j_mayer | if (loglevel != 0) { |
3322 | 077fc206 | j_mayer | fprintf(logfile, "Trying to read invalid spr %d %03x at "
|
3323 | 077fc206 | j_mayer | ADDRX "\n", sprn, sprn, ctx->nip);
|
3324 | f24e5695 | bellard | } |
3325 | 077fc206 | j_mayer | printf("Trying to read invalid spr %d %03x at " ADDRX "\n", |
3326 | 077fc206 | j_mayer | sprn, sprn, ctx->nip); |
3327 | e1833e1f | j_mayer | GEN_EXCP(ctx, POWERPC_EXCP_PROGRAM, |
3328 | e1833e1f | j_mayer | POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_SPR); |
3329 | 79aceca5 | bellard | } |
3330 | 79aceca5 | bellard | } |
3331 | 79aceca5 | bellard | |
3332 | 3fc6c082 | bellard | GEN_HANDLER(mfspr, 0x1F, 0x13, 0x0A, 0x00000001, PPC_MISC) |
3333 | 79aceca5 | bellard | { |
3334 | 3fc6c082 | bellard | gen_op_mfspr(ctx); |
3335 | 76a66253 | j_mayer | } |
3336 | 3fc6c082 | bellard | |
3337 | 3fc6c082 | bellard | /* mftb */
|
3338 | a750fc0b | j_mayer | GEN_HANDLER(mftb, 0x1F, 0x13, 0x0B, 0x00000001, PPC_MFTB) |
3339 | 3fc6c082 | bellard | { |
3340 | 3fc6c082 | bellard | gen_op_mfspr(ctx); |
3341 | 79aceca5 | bellard | } |
3342 | 79aceca5 | bellard | |
3343 | 79aceca5 | bellard | /* mtcrf */
|
3344 | 8dd4983c | bellard | GEN_HANDLER(mtcrf, 0x1F, 0x10, 0x04, 0x00000801, PPC_MISC) |
3345 | 79aceca5 | bellard | { |
3346 | 76a66253 | j_mayer | uint32_t crm, crn; |
3347 | 3b46e624 | ths | |
3348 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
3349 | 76a66253 | j_mayer | crm = CRM(ctx->opcode); |
3350 | 76a66253 | j_mayer | if (likely((ctx->opcode & 0x00100000) || (crm ^ (crm - 1)) == 0)) { |
3351 | 76a66253 | j_mayer | crn = ffs(crm); |
3352 | 76a66253 | j_mayer | gen_op_srli_T0(crn * 4);
|
3353 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[7 - crn], cpu_T[0], 0xf); |
3354 | 76a66253 | j_mayer | } else {
|
3355 | 6676f424 | aurel32 | gen_op_store_cr(crm); |
3356 | 76a66253 | j_mayer | } |
3357 | 79aceca5 | bellard | } |
3358 | 79aceca5 | bellard | |
3359 | 79aceca5 | bellard | /* mtmsr */
|
3360 | 426613db | j_mayer | #if defined(TARGET_PPC64)
|
3361 | be147d08 | j_mayer | GEN_HANDLER(mtmsrd, 0x1F, 0x12, 0x05, 0x001EF801, PPC_64B) |
3362 | 426613db | j_mayer | { |
3363 | 426613db | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3364 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3365 | 426613db | j_mayer | #else
|
3366 | 426613db | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3367 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3368 | 426613db | j_mayer | return;
|
3369 | 426613db | j_mayer | } |
3370 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
3371 | be147d08 | j_mayer | if (ctx->opcode & 0x00010000) { |
3372 | be147d08 | j_mayer | /* Special form that does not need any synchronisation */
|
3373 | be147d08 | j_mayer | gen_op_update_riee(); |
3374 | be147d08 | j_mayer | } else {
|
3375 | 056b05f8 | j_mayer | /* XXX: we need to update nip before the store
|
3376 | 056b05f8 | j_mayer | * if we enter power saving mode, we will exit the loop
|
3377 | 056b05f8 | j_mayer | * directly from ppc_store_msr
|
3378 | 056b05f8 | j_mayer | */
|
3379 | be147d08 | j_mayer | gen_update_nip(ctx, ctx->nip); |
3380 | 6676f424 | aurel32 | gen_op_store_msr(); |
3381 | be147d08 | j_mayer | /* Must stop the translation as machine state (may have) changed */
|
3382 | be147d08 | j_mayer | /* Note that mtmsr is not always defined as context-synchronizing */
|
3383 | 056b05f8 | j_mayer | ctx->exception = POWERPC_EXCP_STOP; |
3384 | be147d08 | j_mayer | } |
3385 | 426613db | j_mayer | #endif
|
3386 | 426613db | j_mayer | } |
3387 | 426613db | j_mayer | #endif
|
3388 | 426613db | j_mayer | |
3389 | 79aceca5 | bellard | GEN_HANDLER(mtmsr, 0x1F, 0x12, 0x04, 0x001FF801, PPC_MISC) |
3390 | 79aceca5 | bellard | { |
3391 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3392 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3393 | 9a64fbe4 | bellard | #else
|
3394 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3395 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3396 | 9fddaa0c | bellard | return;
|
3397 | 9a64fbe4 | bellard | } |
3398 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
3399 | be147d08 | j_mayer | if (ctx->opcode & 0x00010000) { |
3400 | be147d08 | j_mayer | /* Special form that does not need any synchronisation */
|
3401 | be147d08 | j_mayer | gen_op_update_riee(); |
3402 | be147d08 | j_mayer | } else {
|
3403 | 056b05f8 | j_mayer | /* XXX: we need to update nip before the store
|
3404 | 056b05f8 | j_mayer | * if we enter power saving mode, we will exit the loop
|
3405 | 056b05f8 | j_mayer | * directly from ppc_store_msr
|
3406 | 056b05f8 | j_mayer | */
|
3407 | be147d08 | j_mayer | gen_update_nip(ctx, ctx->nip); |
3408 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
3409 | be147d08 | j_mayer | if (!ctx->sf_mode)
|
3410 | 6676f424 | aurel32 | gen_op_store_msr_32(); |
3411 | be147d08 | j_mayer | else
|
3412 | d9bce9d9 | j_mayer | #endif
|
3413 | 6676f424 | aurel32 | gen_op_store_msr(); |
3414 | be147d08 | j_mayer | /* Must stop the translation as machine state (may have) changed */
|
3415 | be147d08 | j_mayer | /* Note that mtmsrd is not always defined as context-synchronizing */
|
3416 | 056b05f8 | j_mayer | ctx->exception = POWERPC_EXCP_STOP; |
3417 | be147d08 | j_mayer | } |
3418 | 9a64fbe4 | bellard | #endif
|
3419 | 79aceca5 | bellard | } |
3420 | 79aceca5 | bellard | |
3421 | 79aceca5 | bellard | /* mtspr */
|
3422 | 79aceca5 | bellard | GEN_HANDLER(mtspr, 0x1F, 0x13, 0x0E, 0x00000001, PPC_MISC) |
3423 | 79aceca5 | bellard | { |
3424 | 3fc6c082 | bellard | void (*write_cb)(void *opaque, int sprn); |
3425 | 79aceca5 | bellard | uint32_t sprn = SPR(ctx->opcode); |
3426 | 79aceca5 | bellard | |
3427 | 3fc6c082 | bellard | #if !defined(CONFIG_USER_ONLY)
|
3428 | be147d08 | j_mayer | if (ctx->supervisor == 2) |
3429 | be147d08 | j_mayer | write_cb = ctx->spr_cb[sprn].hea_write; |
3430 | 7863667f | j_mayer | else if (ctx->supervisor) |
3431 | 3fc6c082 | bellard | write_cb = ctx->spr_cb[sprn].oea_write; |
3432 | 3fc6c082 | bellard | else
|
3433 | 9a64fbe4 | bellard | #endif
|
3434 | 3fc6c082 | bellard | write_cb = ctx->spr_cb[sprn].uea_write; |
3435 | 76a66253 | j_mayer | if (likely(write_cb != NULL)) { |
3436 | 76a66253 | j_mayer | if (likely(write_cb != SPR_NOACCESS)) {
|
3437 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
3438 | 3fc6c082 | bellard | (*write_cb)(ctx, sprn); |
3439 | 3fc6c082 | bellard | } else {
|
3440 | 3fc6c082 | bellard | /* Privilege exception */
|
3441 | 4a057712 | j_mayer | if (loglevel != 0) { |
3442 | 077fc206 | j_mayer | fprintf(logfile, "Trying to write privileged spr %d %03x at "
|
3443 | 077fc206 | j_mayer | ADDRX "\n", sprn, sprn, ctx->nip);
|
3444 | f24e5695 | bellard | } |
3445 | 077fc206 | j_mayer | printf("Trying to write privileged spr %d %03x at " ADDRX "\n", |
3446 | 077fc206 | j_mayer | sprn, sprn, ctx->nip); |
3447 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3448 | 76a66253 | j_mayer | } |
3449 | 3fc6c082 | bellard | } else {
|
3450 | 3fc6c082 | bellard | /* Not defined */
|
3451 | 4a057712 | j_mayer | if (loglevel != 0) { |
3452 | 077fc206 | j_mayer | fprintf(logfile, "Trying to write invalid spr %d %03x at "
|
3453 | 077fc206 | j_mayer | ADDRX "\n", sprn, sprn, ctx->nip);
|
3454 | f24e5695 | bellard | } |
3455 | 077fc206 | j_mayer | printf("Trying to write invalid spr %d %03x at " ADDRX "\n", |
3456 | 077fc206 | j_mayer | sprn, sprn, ctx->nip); |
3457 | e1833e1f | j_mayer | GEN_EXCP(ctx, POWERPC_EXCP_PROGRAM, |
3458 | e1833e1f | j_mayer | POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_SPR); |
3459 | 79aceca5 | bellard | } |
3460 | 79aceca5 | bellard | } |
3461 | 79aceca5 | bellard | |
3462 | 79aceca5 | bellard | /*** Cache management ***/
|
3463 | 79aceca5 | bellard | /* dcbf */
|
3464 | 0db1b20e | j_mayer | GEN_HANDLER(dcbf, 0x1F, 0x16, 0x02, 0x03C00001, PPC_CACHE) |
3465 | 79aceca5 | bellard | { |
3466 | dac454af | j_mayer | /* XXX: specification says this is treated as a load by the MMU */
|
3467 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
3468 | a541f297 | bellard | op_ldst(lbz); |
3469 | 79aceca5 | bellard | } |
3470 | 79aceca5 | bellard | |
3471 | 79aceca5 | bellard | /* dcbi (Supervisor only) */
|
3472 | 9a64fbe4 | bellard | GEN_HANDLER(dcbi, 0x1F, 0x16, 0x0E, 0x03E00001, PPC_CACHE) |
3473 | 79aceca5 | bellard | { |
3474 | a541f297 | bellard | #if defined(CONFIG_USER_ONLY)
|
3475 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3476 | a541f297 | bellard | #else
|
3477 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3478 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3479 | 9fddaa0c | bellard | return;
|
3480 | 9a64fbe4 | bellard | } |
3481 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
3482 | 76a66253 | j_mayer | /* XXX: specification says this should be treated as a store by the MMU */
|
3483 | dac454af | j_mayer | op_ldst(lbz); |
3484 | a541f297 | bellard | op_ldst(stb); |
3485 | a541f297 | bellard | #endif
|
3486 | 79aceca5 | bellard | } |
3487 | 79aceca5 | bellard | |
3488 | 79aceca5 | bellard | /* dcdst */
|
3489 | 9a64fbe4 | bellard | GEN_HANDLER(dcbst, 0x1F, 0x16, 0x01, 0x03E00001, PPC_CACHE) |
3490 | 79aceca5 | bellard | { |
3491 | 76a66253 | j_mayer | /* XXX: specification say this is treated as a load by the MMU */
|
3492 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
3493 | a541f297 | bellard | op_ldst(lbz); |
3494 | 79aceca5 | bellard | } |
3495 | 79aceca5 | bellard | |
3496 | 79aceca5 | bellard | /* dcbt */
|
3497 | 0db1b20e | j_mayer | GEN_HANDLER(dcbt, 0x1F, 0x16, 0x08, 0x02000001, PPC_CACHE) |
3498 | 79aceca5 | bellard | { |
3499 | 0db1b20e | j_mayer | /* interpreted as no-op */
|
3500 | 76a66253 | j_mayer | /* XXX: specification say this is treated as a load by the MMU
|
3501 | 76a66253 | j_mayer | * but does not generate any exception
|
3502 | 76a66253 | j_mayer | */
|
3503 | 79aceca5 | bellard | } |
3504 | 79aceca5 | bellard | |
3505 | 79aceca5 | bellard | /* dcbtst */
|
3506 | 0db1b20e | j_mayer | GEN_HANDLER(dcbtst, 0x1F, 0x16, 0x07, 0x02000001, PPC_CACHE) |
3507 | 79aceca5 | bellard | { |
3508 | 0db1b20e | j_mayer | /* interpreted as no-op */
|
3509 | 76a66253 | j_mayer | /* XXX: specification say this is treated as a load by the MMU
|
3510 | 76a66253 | j_mayer | * but does not generate any exception
|
3511 | 76a66253 | j_mayer | */
|
3512 | 79aceca5 | bellard | } |
3513 | 79aceca5 | bellard | |
3514 | 79aceca5 | bellard | /* dcbz */
|
3515 | d63001d1 | j_mayer | #define op_dcbz(n) (*gen_op_dcbz[n][ctx->mem_idx])()
|
3516 | 7863667f | j_mayer | static GenOpFunc *gen_op_dcbz[4][NB_MEM_FUNCS] = { |
3517 | 7863667f | j_mayer | /* 32 bytes cache line size */
|
3518 | d63001d1 | j_mayer | { |
3519 | 7863667f | j_mayer | #define gen_op_dcbz_l32_le_raw gen_op_dcbz_l32_raw
|
3520 | 7863667f | j_mayer | #define gen_op_dcbz_l32_le_user gen_op_dcbz_l32_user
|
3521 | 7863667f | j_mayer | #define gen_op_dcbz_l32_le_kernel gen_op_dcbz_l32_kernel
|
3522 | 7863667f | j_mayer | #define gen_op_dcbz_l32_le_hypv gen_op_dcbz_l32_hypv
|
3523 | 7863667f | j_mayer | #define gen_op_dcbz_l32_le_64_raw gen_op_dcbz_l32_64_raw
|
3524 | 7863667f | j_mayer | #define gen_op_dcbz_l32_le_64_user gen_op_dcbz_l32_64_user
|
3525 | 7863667f | j_mayer | #define gen_op_dcbz_l32_le_64_kernel gen_op_dcbz_l32_64_kernel
|
3526 | 7863667f | j_mayer | #define gen_op_dcbz_l32_le_64_hypv gen_op_dcbz_l32_64_hypv
|
3527 | 7863667f | j_mayer | GEN_MEM_FUNCS(dcbz_l32), |
3528 | d63001d1 | j_mayer | }, |
3529 | 7863667f | j_mayer | /* 64 bytes cache line size */
|
3530 | d63001d1 | j_mayer | { |
3531 | 7863667f | j_mayer | #define gen_op_dcbz_l64_le_raw gen_op_dcbz_l64_raw
|
3532 | 7863667f | j_mayer | #define gen_op_dcbz_l64_le_user gen_op_dcbz_l64_user
|
3533 | 7863667f | j_mayer | #define gen_op_dcbz_l64_le_kernel gen_op_dcbz_l64_kernel
|
3534 | 7863667f | j_mayer | #define gen_op_dcbz_l64_le_hypv gen_op_dcbz_l64_hypv
|
3535 | 7863667f | j_mayer | #define gen_op_dcbz_l64_le_64_raw gen_op_dcbz_l64_64_raw
|
3536 | 7863667f | j_mayer | #define gen_op_dcbz_l64_le_64_user gen_op_dcbz_l64_64_user
|
3537 | 7863667f | j_mayer | #define gen_op_dcbz_l64_le_64_kernel gen_op_dcbz_l64_64_kernel
|
3538 | 7863667f | j_mayer | #define gen_op_dcbz_l64_le_64_hypv gen_op_dcbz_l64_64_hypv
|
3539 | 7863667f | j_mayer | GEN_MEM_FUNCS(dcbz_l64), |
3540 | d63001d1 | j_mayer | }, |
3541 | 7863667f | j_mayer | /* 128 bytes cache line size */
|
3542 | d63001d1 | j_mayer | { |
3543 | 7863667f | j_mayer | #define gen_op_dcbz_l128_le_raw gen_op_dcbz_l128_raw
|
3544 | 7863667f | j_mayer | #define gen_op_dcbz_l128_le_user gen_op_dcbz_l128_user
|
3545 | 7863667f | j_mayer | #define gen_op_dcbz_l128_le_kernel gen_op_dcbz_l128_kernel
|
3546 | 7863667f | j_mayer | #define gen_op_dcbz_l128_le_hypv gen_op_dcbz_l128_hypv
|
3547 | 7863667f | j_mayer | #define gen_op_dcbz_l128_le_64_raw gen_op_dcbz_l128_64_raw
|
3548 | 7863667f | j_mayer | #define gen_op_dcbz_l128_le_64_user gen_op_dcbz_l128_64_user
|
3549 | 7863667f | j_mayer | #define gen_op_dcbz_l128_le_64_kernel gen_op_dcbz_l128_64_kernel
|
3550 | 7863667f | j_mayer | #define gen_op_dcbz_l128_le_64_hypv gen_op_dcbz_l128_64_hypv
|
3551 | 7863667f | j_mayer | GEN_MEM_FUNCS(dcbz_l128), |
3552 | d63001d1 | j_mayer | }, |
3553 | 7863667f | j_mayer | /* tunable cache line size */
|
3554 | d63001d1 | j_mayer | { |
3555 | 7863667f | j_mayer | #define gen_op_dcbz_le_raw gen_op_dcbz_raw
|
3556 | 7863667f | j_mayer | #define gen_op_dcbz_le_user gen_op_dcbz_user
|
3557 | 7863667f | j_mayer | #define gen_op_dcbz_le_kernel gen_op_dcbz_kernel
|
3558 | 7863667f | j_mayer | #define gen_op_dcbz_le_hypv gen_op_dcbz_hypv
|
3559 | 7863667f | j_mayer | #define gen_op_dcbz_le_64_raw gen_op_dcbz_64_raw
|
3560 | 7863667f | j_mayer | #define gen_op_dcbz_le_64_user gen_op_dcbz_64_user
|
3561 | 7863667f | j_mayer | #define gen_op_dcbz_le_64_kernel gen_op_dcbz_64_kernel
|
3562 | 7863667f | j_mayer | #define gen_op_dcbz_le_64_hypv gen_op_dcbz_64_hypv
|
3563 | 7863667f | j_mayer | GEN_MEM_FUNCS(dcbz), |
3564 | d63001d1 | j_mayer | }, |
3565 | 76a66253 | j_mayer | }; |
3566 | 9a64fbe4 | bellard | |
3567 | b068d6a7 | j_mayer | static always_inline void handler_dcbz (DisasContext *ctx, |
3568 | b068d6a7 | j_mayer | int dcache_line_size)
|
3569 | d63001d1 | j_mayer | { |
3570 | d63001d1 | j_mayer | int n;
|
3571 | d63001d1 | j_mayer | |
3572 | d63001d1 | j_mayer | switch (dcache_line_size) {
|
3573 | d63001d1 | j_mayer | case 32: |
3574 | d63001d1 | j_mayer | n = 0;
|
3575 | d63001d1 | j_mayer | break;
|
3576 | d63001d1 | j_mayer | case 64: |
3577 | d63001d1 | j_mayer | n = 1;
|
3578 | d63001d1 | j_mayer | break;
|
3579 | d63001d1 | j_mayer | case 128: |
3580 | d63001d1 | j_mayer | n = 2;
|
3581 | d63001d1 | j_mayer | break;
|
3582 | d63001d1 | j_mayer | default:
|
3583 | d63001d1 | j_mayer | n = 3;
|
3584 | d63001d1 | j_mayer | break;
|
3585 | d63001d1 | j_mayer | } |
3586 | d63001d1 | j_mayer | op_dcbz(n); |
3587 | d63001d1 | j_mayer | } |
3588 | d63001d1 | j_mayer | |
3589 | d63001d1 | j_mayer | GEN_HANDLER(dcbz, 0x1F, 0x16, 0x1F, 0x03E00001, PPC_CACHE_DCBZ) |
3590 | 79aceca5 | bellard | { |
3591 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
3592 | d63001d1 | j_mayer | handler_dcbz(ctx, ctx->dcache_line_size); |
3593 | d63001d1 | j_mayer | gen_op_check_reservation(); |
3594 | d63001d1 | j_mayer | } |
3595 | d63001d1 | j_mayer | |
3596 | c7697e1f | j_mayer | GEN_HANDLER2(dcbz_970, "dcbz", 0x1F, 0x16, 0x1F, 0x03C00001, PPC_CACHE_DCBZT) |
3597 | d63001d1 | j_mayer | { |
3598 | d63001d1 | j_mayer | gen_addr_reg_index(ctx); |
3599 | d63001d1 | j_mayer | if (ctx->opcode & 0x00200000) |
3600 | d63001d1 | j_mayer | handler_dcbz(ctx, ctx->dcache_line_size); |
3601 | d63001d1 | j_mayer | else
|
3602 | d63001d1 | j_mayer | handler_dcbz(ctx, -1);
|
3603 | 4b3686fa | bellard | gen_op_check_reservation(); |
3604 | 79aceca5 | bellard | } |
3605 | 79aceca5 | bellard | |
3606 | 79aceca5 | bellard | /* icbi */
|
3607 | 36f69651 | j_mayer | #define op_icbi() (*gen_op_icbi[ctx->mem_idx])()
|
3608 | 7863667f | j_mayer | #define gen_op_icbi_le_raw gen_op_icbi_raw
|
3609 | 7863667f | j_mayer | #define gen_op_icbi_le_user gen_op_icbi_user
|
3610 | 7863667f | j_mayer | #define gen_op_icbi_le_kernel gen_op_icbi_kernel
|
3611 | 7863667f | j_mayer | #define gen_op_icbi_le_hypv gen_op_icbi_hypv
|
3612 | 7863667f | j_mayer | #define gen_op_icbi_le_64_raw gen_op_icbi_64_raw
|
3613 | 7863667f | j_mayer | #define gen_op_icbi_le_64_user gen_op_icbi_64_user
|
3614 | 7863667f | j_mayer | #define gen_op_icbi_le_64_kernel gen_op_icbi_64_kernel
|
3615 | 7863667f | j_mayer | #define gen_op_icbi_le_64_hypv gen_op_icbi_64_hypv
|
3616 | 7863667f | j_mayer | static GenOpFunc *gen_op_icbi[NB_MEM_FUNCS] = {
|
3617 | 7863667f | j_mayer | GEN_MEM_FUNCS(icbi), |
3618 | 36f69651 | j_mayer | }; |
3619 | e1833e1f | j_mayer | |
3620 | 1b413d55 | j_mayer | GEN_HANDLER(icbi, 0x1F, 0x16, 0x1E, 0x03E00001, PPC_CACHE_ICBI) |
3621 | 79aceca5 | bellard | { |
3622 | 30032c94 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
3623 | 30032c94 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
3624 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
3625 | 36f69651 | j_mayer | op_icbi(); |
3626 | 79aceca5 | bellard | } |
3627 | 79aceca5 | bellard | |
3628 | 79aceca5 | bellard | /* Optional: */
|
3629 | 79aceca5 | bellard | /* dcba */
|
3630 | a750fc0b | j_mayer | GEN_HANDLER(dcba, 0x1F, 0x16, 0x17, 0x03E00001, PPC_CACHE_DCBA) |
3631 | 79aceca5 | bellard | { |
3632 | 0db1b20e | j_mayer | /* interpreted as no-op */
|
3633 | 0db1b20e | j_mayer | /* XXX: specification say this is treated as a store by the MMU
|
3634 | 0db1b20e | j_mayer | * but does not generate any exception
|
3635 | 0db1b20e | j_mayer | */
|
3636 | 79aceca5 | bellard | } |
3637 | 79aceca5 | bellard | |
3638 | 79aceca5 | bellard | /*** Segment register manipulation ***/
|
3639 | 79aceca5 | bellard | /* Supervisor only: */
|
3640 | 79aceca5 | bellard | /* mfsr */
|
3641 | 79aceca5 | bellard | GEN_HANDLER(mfsr, 0x1F, 0x13, 0x12, 0x0010F801, PPC_SEGMENT) |
3642 | 79aceca5 | bellard | { |
3643 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3644 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3645 | 9a64fbe4 | bellard | #else
|
3646 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3647 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3648 | 9fddaa0c | bellard | return;
|
3649 | 9a64fbe4 | bellard | } |
3650 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SR(ctx->opcode));
|
3651 | 76a66253 | j_mayer | gen_op_load_sr(); |
3652 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3653 | 9a64fbe4 | bellard | #endif
|
3654 | 79aceca5 | bellard | } |
3655 | 79aceca5 | bellard | |
3656 | 79aceca5 | bellard | /* mfsrin */
|
3657 | 9a64fbe4 | bellard | GEN_HANDLER(mfsrin, 0x1F, 0x13, 0x14, 0x001F0001, PPC_SEGMENT) |
3658 | 79aceca5 | bellard | { |
3659 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3660 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3661 | 9a64fbe4 | bellard | #else
|
3662 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3663 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3664 | 9fddaa0c | bellard | return;
|
3665 | 9a64fbe4 | bellard | } |
3666 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3667 | 76a66253 | j_mayer | gen_op_srli_T1(28);
|
3668 | 76a66253 | j_mayer | gen_op_load_sr(); |
3669 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3670 | 9a64fbe4 | bellard | #endif
|
3671 | 79aceca5 | bellard | } |
3672 | 79aceca5 | bellard | |
3673 | 79aceca5 | bellard | /* mtsr */
|
3674 | e63c59cb | bellard | GEN_HANDLER(mtsr, 0x1F, 0x12, 0x06, 0x0010F801, PPC_SEGMENT) |
3675 | 79aceca5 | bellard | { |
3676 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3677 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3678 | 9a64fbe4 | bellard | #else
|
3679 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3680 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3681 | 9fddaa0c | bellard | return;
|
3682 | 9a64fbe4 | bellard | } |
3683 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
3684 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SR(ctx->opcode));
|
3685 | 76a66253 | j_mayer | gen_op_store_sr(); |
3686 | 9a64fbe4 | bellard | #endif
|
3687 | 79aceca5 | bellard | } |
3688 | 79aceca5 | bellard | |
3689 | 79aceca5 | bellard | /* mtsrin */
|
3690 | 9a64fbe4 | bellard | GEN_HANDLER(mtsrin, 0x1F, 0x12, 0x07, 0x001F0001, PPC_SEGMENT) |
3691 | 79aceca5 | bellard | { |
3692 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3693 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3694 | 9a64fbe4 | bellard | #else
|
3695 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3696 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3697 | 9fddaa0c | bellard | return;
|
3698 | 9a64fbe4 | bellard | } |
3699 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
3700 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3701 | 76a66253 | j_mayer | gen_op_srli_T1(28);
|
3702 | 76a66253 | j_mayer | gen_op_store_sr(); |
3703 | 9a64fbe4 | bellard | #endif
|
3704 | 79aceca5 | bellard | } |
3705 | 79aceca5 | bellard | |
3706 | 12de9a39 | j_mayer | #if defined(TARGET_PPC64)
|
3707 | 12de9a39 | j_mayer | /* Specific implementation for PowerPC 64 "bridge" emulation using SLB */
|
3708 | 12de9a39 | j_mayer | /* mfsr */
|
3709 | c7697e1f | j_mayer | GEN_HANDLER2(mfsr_64b, "mfsr", 0x1F, 0x13, 0x12, 0x0010F801, PPC_SEGMENT_64B) |
3710 | 12de9a39 | j_mayer | { |
3711 | 12de9a39 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3712 | 12de9a39 | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3713 | 12de9a39 | j_mayer | #else
|
3714 | 12de9a39 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3715 | 12de9a39 | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3716 | 12de9a39 | j_mayer | return;
|
3717 | 12de9a39 | j_mayer | } |
3718 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SR(ctx->opcode));
|
3719 | 12de9a39 | j_mayer | gen_op_load_slb(); |
3720 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3721 | 12de9a39 | j_mayer | #endif
|
3722 | 12de9a39 | j_mayer | } |
3723 | 12de9a39 | j_mayer | |
3724 | 12de9a39 | j_mayer | /* mfsrin */
|
3725 | c7697e1f | j_mayer | GEN_HANDLER2(mfsrin_64b, "mfsrin", 0x1F, 0x13, 0x14, 0x001F0001, |
3726 | c7697e1f | j_mayer | PPC_SEGMENT_64B) |
3727 | 12de9a39 | j_mayer | { |
3728 | 12de9a39 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3729 | 12de9a39 | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3730 | 12de9a39 | j_mayer | #else
|
3731 | 12de9a39 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3732 | 12de9a39 | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3733 | 12de9a39 | j_mayer | return;
|
3734 | 12de9a39 | j_mayer | } |
3735 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3736 | 12de9a39 | j_mayer | gen_op_srli_T1(28);
|
3737 | 12de9a39 | j_mayer | gen_op_load_slb(); |
3738 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3739 | 12de9a39 | j_mayer | #endif
|
3740 | 12de9a39 | j_mayer | } |
3741 | 12de9a39 | j_mayer | |
3742 | 12de9a39 | j_mayer | /* mtsr */
|
3743 | c7697e1f | j_mayer | GEN_HANDLER2(mtsr_64b, "mtsr", 0x1F, 0x12, 0x06, 0x0010F801, PPC_SEGMENT_64B) |
3744 | 12de9a39 | j_mayer | { |
3745 | 12de9a39 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3746 | 12de9a39 | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3747 | 12de9a39 | j_mayer | #else
|
3748 | 12de9a39 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3749 | 12de9a39 | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3750 | 12de9a39 | j_mayer | return;
|
3751 | 12de9a39 | j_mayer | } |
3752 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
3753 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SR(ctx->opcode));
|
3754 | 12de9a39 | j_mayer | gen_op_store_slb(); |
3755 | 12de9a39 | j_mayer | #endif
|
3756 | 12de9a39 | j_mayer | } |
3757 | 12de9a39 | j_mayer | |
3758 | 12de9a39 | j_mayer | /* mtsrin */
|
3759 | c7697e1f | j_mayer | GEN_HANDLER2(mtsrin_64b, "mtsrin", 0x1F, 0x12, 0x07, 0x001F0001, |
3760 | c7697e1f | j_mayer | PPC_SEGMENT_64B) |
3761 | 12de9a39 | j_mayer | { |
3762 | 12de9a39 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3763 | 12de9a39 | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3764 | 12de9a39 | j_mayer | #else
|
3765 | 12de9a39 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3766 | 12de9a39 | j_mayer | GEN_EXCP_PRIVREG(ctx); |
3767 | 12de9a39 | j_mayer | return;
|
3768 | 12de9a39 | j_mayer | } |
3769 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
3770 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3771 | 12de9a39 | j_mayer | gen_op_srli_T1(28);
|
3772 | 12de9a39 | j_mayer | gen_op_store_slb(); |
3773 | 12de9a39 | j_mayer | #endif
|
3774 | 12de9a39 | j_mayer | } |
3775 | 12de9a39 | j_mayer | #endif /* defined(TARGET_PPC64) */ |
3776 | 12de9a39 | j_mayer | |
3777 | 79aceca5 | bellard | /*** Lookaside buffer management ***/
|
3778 | 79aceca5 | bellard | /* Optional & supervisor only: */
|
3779 | 79aceca5 | bellard | /* tlbia */
|
3780 | 3fc6c082 | bellard | GEN_HANDLER(tlbia, 0x1F, 0x12, 0x0B, 0x03FFFC01, PPC_MEM_TLBIA) |
3781 | 79aceca5 | bellard | { |
3782 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3783 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3784 | 9a64fbe4 | bellard | #else
|
3785 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3786 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3787 | 9fddaa0c | bellard | return;
|
3788 | 9a64fbe4 | bellard | } |
3789 | 9a64fbe4 | bellard | gen_op_tlbia(); |
3790 | 9a64fbe4 | bellard | #endif
|
3791 | 79aceca5 | bellard | } |
3792 | 79aceca5 | bellard | |
3793 | 79aceca5 | bellard | /* tlbie */
|
3794 | 76a66253 | j_mayer | GEN_HANDLER(tlbie, 0x1F, 0x12, 0x09, 0x03FF0001, PPC_MEM_TLBIE) |
3795 | 79aceca5 | bellard | { |
3796 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3797 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3798 | 9a64fbe4 | bellard | #else
|
3799 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3800 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3801 | 9fddaa0c | bellard | return;
|
3802 | 9a64fbe4 | bellard | } |
3803 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rB(ctx->opcode)]);
|
3804 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
3805 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
3806 | d9bce9d9 | j_mayer | gen_op_tlbie_64(); |
3807 | d9bce9d9 | j_mayer | else
|
3808 | d9bce9d9 | j_mayer | #endif
|
3809 | d9bce9d9 | j_mayer | gen_op_tlbie(); |
3810 | 9a64fbe4 | bellard | #endif
|
3811 | 79aceca5 | bellard | } |
3812 | 79aceca5 | bellard | |
3813 | 79aceca5 | bellard | /* tlbsync */
|
3814 | 76a66253 | j_mayer | GEN_HANDLER(tlbsync, 0x1F, 0x16, 0x11, 0x03FFF801, PPC_MEM_TLBSYNC) |
3815 | 79aceca5 | bellard | { |
3816 | 9a64fbe4 | bellard | #if defined(CONFIG_USER_ONLY)
|
3817 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3818 | 9a64fbe4 | bellard | #else
|
3819 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3820 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3821 | 9fddaa0c | bellard | return;
|
3822 | 9a64fbe4 | bellard | } |
3823 | 9a64fbe4 | bellard | /* This has no effect: it should ensure that all previous
|
3824 | 9a64fbe4 | bellard | * tlbie have completed
|
3825 | 9a64fbe4 | bellard | */
|
3826 | e1833e1f | j_mayer | GEN_STOP(ctx); |
3827 | 9a64fbe4 | bellard | #endif
|
3828 | 79aceca5 | bellard | } |
3829 | 79aceca5 | bellard | |
3830 | 426613db | j_mayer | #if defined(TARGET_PPC64)
|
3831 | 426613db | j_mayer | /* slbia */
|
3832 | 426613db | j_mayer | GEN_HANDLER(slbia, 0x1F, 0x12, 0x0F, 0x03FFFC01, PPC_SLBI) |
3833 | 426613db | j_mayer | { |
3834 | 426613db | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3835 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3836 | 426613db | j_mayer | #else
|
3837 | 426613db | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3838 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3839 | 426613db | j_mayer | return;
|
3840 | 426613db | j_mayer | } |
3841 | 426613db | j_mayer | gen_op_slbia(); |
3842 | 426613db | j_mayer | #endif
|
3843 | 426613db | j_mayer | } |
3844 | 426613db | j_mayer | |
3845 | 426613db | j_mayer | /* slbie */
|
3846 | 426613db | j_mayer | GEN_HANDLER(slbie, 0x1F, 0x12, 0x0D, 0x03FF0001, PPC_SLBI) |
3847 | 426613db | j_mayer | { |
3848 | 426613db | j_mayer | #if defined(CONFIG_USER_ONLY)
|
3849 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3850 | 426613db | j_mayer | #else
|
3851 | 426613db | j_mayer | if (unlikely(!ctx->supervisor)) {
|
3852 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
3853 | 426613db | j_mayer | return;
|
3854 | 426613db | j_mayer | } |
3855 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rB(ctx->opcode)]);
|
3856 | 426613db | j_mayer | gen_op_slbie(); |
3857 | 426613db | j_mayer | #endif
|
3858 | 426613db | j_mayer | } |
3859 | 426613db | j_mayer | #endif
|
3860 | 426613db | j_mayer | |
3861 | 79aceca5 | bellard | /*** External control ***/
|
3862 | 79aceca5 | bellard | /* Optional: */
|
3863 | 9a64fbe4 | bellard | #define op_eciwx() (*gen_op_eciwx[ctx->mem_idx])()
|
3864 | 9a64fbe4 | bellard | #define op_ecowx() (*gen_op_ecowx[ctx->mem_idx])()
|
3865 | 7863667f | j_mayer | static GenOpFunc *gen_op_eciwx[NB_MEM_FUNCS] = {
|
3866 | 7863667f | j_mayer | GEN_MEM_FUNCS(eciwx), |
3867 | 111bfab3 | bellard | }; |
3868 | 7863667f | j_mayer | static GenOpFunc *gen_op_ecowx[NB_MEM_FUNCS] = {
|
3869 | 7863667f | j_mayer | GEN_MEM_FUNCS(ecowx), |
3870 | 111bfab3 | bellard | }; |
3871 | 9a64fbe4 | bellard | |
3872 | 111bfab3 | bellard | /* eciwx */
|
3873 | 79aceca5 | bellard | GEN_HANDLER(eciwx, 0x1F, 0x16, 0x0D, 0x00000001, PPC_EXTERN) |
3874 | 79aceca5 | bellard | { |
3875 | 9a64fbe4 | bellard | /* Should check EAR[E] & alignment ! */
|
3876 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
3877 | 76a66253 | j_mayer | op_eciwx(); |
3878 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3879 | 76a66253 | j_mayer | } |
3880 | 76a66253 | j_mayer | |
3881 | 76a66253 | j_mayer | /* ecowx */
|
3882 | 76a66253 | j_mayer | GEN_HANDLER(ecowx, 0x1F, 0x16, 0x09, 0x00000001, PPC_EXTERN) |
3883 | 76a66253 | j_mayer | { |
3884 | 76a66253 | j_mayer | /* Should check EAR[E] & alignment ! */
|
3885 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
3886 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
3887 | 76a66253 | j_mayer | op_ecowx(); |
3888 | 76a66253 | j_mayer | } |
3889 | 76a66253 | j_mayer | |
3890 | 76a66253 | j_mayer | /* PowerPC 601 specific instructions */
|
3891 | 76a66253 | j_mayer | /* abs - abs. */
|
3892 | 76a66253 | j_mayer | GEN_HANDLER(abs, 0x1F, 0x08, 0x0B, 0x0000F800, PPC_POWER_BR) |
3893 | 76a66253 | j_mayer | { |
3894 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3895 | 76a66253 | j_mayer | gen_op_POWER_abs(); |
3896 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3897 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
3898 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
3899 | 76a66253 | j_mayer | } |
3900 | 76a66253 | j_mayer | |
3901 | 76a66253 | j_mayer | /* abso - abso. */
|
3902 | 76a66253 | j_mayer | GEN_HANDLER(abso, 0x1F, 0x08, 0x1B, 0x0000F800, PPC_POWER_BR) |
3903 | 76a66253 | j_mayer | { |
3904 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3905 | 76a66253 | j_mayer | gen_op_POWER_abso(); |
3906 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3907 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
3908 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
3909 | 76a66253 | j_mayer | } |
3910 | 76a66253 | j_mayer | |
3911 | 76a66253 | j_mayer | /* clcs */
|
3912 | a750fc0b | j_mayer | GEN_HANDLER(clcs, 0x1F, 0x10, 0x13, 0x0000F800, PPC_POWER_BR) |
3913 | 76a66253 | j_mayer | { |
3914 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3915 | 76a66253 | j_mayer | gen_op_POWER_clcs(); |
3916 | c7697e1f | j_mayer | /* Rc=1 sets CR0 to an undefined state */
|
3917 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3918 | 76a66253 | j_mayer | } |
3919 | 76a66253 | j_mayer | |
3920 | 76a66253 | j_mayer | /* div - div. */
|
3921 | 76a66253 | j_mayer | GEN_HANDLER(div, 0x1F, 0x0B, 0x0A, 0x00000000, PPC_POWER_BR) |
3922 | 76a66253 | j_mayer | { |
3923 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3924 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3925 | 76a66253 | j_mayer | gen_op_POWER_div(); |
3926 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3927 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
3928 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
3929 | 76a66253 | j_mayer | } |
3930 | 76a66253 | j_mayer | |
3931 | 76a66253 | j_mayer | /* divo - divo. */
|
3932 | 76a66253 | j_mayer | GEN_HANDLER(divo, 0x1F, 0x0B, 0x1A, 0x00000000, PPC_POWER_BR) |
3933 | 76a66253 | j_mayer | { |
3934 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3935 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3936 | 76a66253 | j_mayer | gen_op_POWER_divo(); |
3937 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3938 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
3939 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
3940 | 76a66253 | j_mayer | } |
3941 | 76a66253 | j_mayer | |
3942 | 76a66253 | j_mayer | /* divs - divs. */
|
3943 | 76a66253 | j_mayer | GEN_HANDLER(divs, 0x1F, 0x0B, 0x0B, 0x00000000, PPC_POWER_BR) |
3944 | 76a66253 | j_mayer | { |
3945 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3946 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3947 | 76a66253 | j_mayer | gen_op_POWER_divs(); |
3948 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3949 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
3950 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
3951 | 76a66253 | j_mayer | } |
3952 | 76a66253 | j_mayer | |
3953 | 76a66253 | j_mayer | /* divso - divso. */
|
3954 | 76a66253 | j_mayer | GEN_HANDLER(divso, 0x1F, 0x0B, 0x1B, 0x00000000, PPC_POWER_BR) |
3955 | 76a66253 | j_mayer | { |
3956 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3957 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3958 | 76a66253 | j_mayer | gen_op_POWER_divso(); |
3959 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3960 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
3961 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
3962 | 76a66253 | j_mayer | } |
3963 | 76a66253 | j_mayer | |
3964 | 76a66253 | j_mayer | /* doz - doz. */
|
3965 | 76a66253 | j_mayer | GEN_HANDLER(doz, 0x1F, 0x08, 0x08, 0x00000000, PPC_POWER_BR) |
3966 | 76a66253 | j_mayer | { |
3967 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3968 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3969 | 76a66253 | j_mayer | gen_op_POWER_doz(); |
3970 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3971 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
3972 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
3973 | 76a66253 | j_mayer | } |
3974 | 76a66253 | j_mayer | |
3975 | 76a66253 | j_mayer | /* dozo - dozo. */
|
3976 | 76a66253 | j_mayer | GEN_HANDLER(dozo, 0x1F, 0x08, 0x18, 0x00000000, PPC_POWER_BR) |
3977 | 76a66253 | j_mayer | { |
3978 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3979 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
3980 | 76a66253 | j_mayer | gen_op_POWER_dozo(); |
3981 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3982 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
3983 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
3984 | 76a66253 | j_mayer | } |
3985 | 76a66253 | j_mayer | |
3986 | 76a66253 | j_mayer | /* dozi */
|
3987 | 76a66253 | j_mayer | GEN_HANDLER(dozi, 0x09, 0xFF, 0xFF, 0x00000000, PPC_POWER_BR) |
3988 | 76a66253 | j_mayer | { |
3989 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
3990 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SIMM(ctx->opcode));
|
3991 | 76a66253 | j_mayer | gen_op_POWER_doz(); |
3992 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
3993 | 76a66253 | j_mayer | } |
3994 | 76a66253 | j_mayer | |
3995 | 7863667f | j_mayer | /* As lscbx load from memory byte after byte, it's always endian safe.
|
3996 | 7863667f | j_mayer | * Original POWER is 32 bits only, define 64 bits ops as 32 bits ones
|
3997 | 7863667f | j_mayer | */
|
3998 | 2857068e | j_mayer | #define op_POWER_lscbx(start, ra, rb) \
|
3999 | 76a66253 | j_mayer | (*gen_op_POWER_lscbx[ctx->mem_idx])(start, ra, rb) |
4000 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_64_raw gen_op_POWER_lscbx_raw
|
4001 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_64_user gen_op_POWER_lscbx_user
|
4002 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_64_kernel gen_op_POWER_lscbx_kernel
|
4003 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_64_hypv gen_op_POWER_lscbx_hypv
|
4004 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_le_raw gen_op_POWER_lscbx_raw
|
4005 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_le_user gen_op_POWER_lscbx_user
|
4006 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_le_kernel gen_op_POWER_lscbx_kernel
|
4007 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_le_hypv gen_op_POWER_lscbx_hypv
|
4008 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_le_64_raw gen_op_POWER_lscbx_raw
|
4009 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_le_64_user gen_op_POWER_lscbx_user
|
4010 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_le_64_kernel gen_op_POWER_lscbx_kernel
|
4011 | 7863667f | j_mayer | #define gen_op_POWER_lscbx_le_64_hypv gen_op_POWER_lscbx_hypv
|
4012 | 7863667f | j_mayer | static GenOpFunc3 *gen_op_POWER_lscbx[NB_MEM_FUNCS] = {
|
4013 | 7863667f | j_mayer | GEN_MEM_FUNCS(POWER_lscbx), |
4014 | 76a66253 | j_mayer | }; |
4015 | 76a66253 | j_mayer | |
4016 | 76a66253 | j_mayer | /* lscbx - lscbx. */
|
4017 | 76a66253 | j_mayer | GEN_HANDLER(lscbx, 0x1F, 0x15, 0x08, 0x00000000, PPC_POWER_BR) |
4018 | 76a66253 | j_mayer | { |
4019 | 76a66253 | j_mayer | int ra = rA(ctx->opcode);
|
4020 | 76a66253 | j_mayer | int rb = rB(ctx->opcode);
|
4021 | 76a66253 | j_mayer | |
4022 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
4023 | 76a66253 | j_mayer | if (ra == 0) { |
4024 | 76a66253 | j_mayer | ra = rb; |
4025 | 76a66253 | j_mayer | } |
4026 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
4027 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
4028 | 76a66253 | j_mayer | gen_op_load_xer_bc(); |
4029 | 76a66253 | j_mayer | gen_op_load_xer_cmp(); |
4030 | 76a66253 | j_mayer | op_POWER_lscbx(rD(ctx->opcode), ra, rb); |
4031 | 76a66253 | j_mayer | gen_op_store_xer_bc(); |
4032 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4033 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4034 | 76a66253 | j_mayer | } |
4035 | 76a66253 | j_mayer | |
4036 | 76a66253 | j_mayer | /* maskg - maskg. */
|
4037 | 76a66253 | j_mayer | GEN_HANDLER(maskg, 0x1F, 0x1D, 0x00, 0x00000000, PPC_POWER_BR) |
4038 | 76a66253 | j_mayer | { |
4039 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4040 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4041 | 76a66253 | j_mayer | gen_op_POWER_maskg(); |
4042 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4043 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4044 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4045 | 76a66253 | j_mayer | } |
4046 | 76a66253 | j_mayer | |
4047 | 76a66253 | j_mayer | /* maskir - maskir. */
|
4048 | 76a66253 | j_mayer | GEN_HANDLER(maskir, 0x1F, 0x1D, 0x10, 0x00000000, PPC_POWER_BR) |
4049 | 76a66253 | j_mayer | { |
4050 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4051 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
4052 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_gpr[rB(ctx->opcode)]);
|
4053 | 76a66253 | j_mayer | gen_op_POWER_maskir(); |
4054 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4055 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4056 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4057 | 76a66253 | j_mayer | } |
4058 | 76a66253 | j_mayer | |
4059 | 76a66253 | j_mayer | /* mul - mul. */
|
4060 | 76a66253 | j_mayer | GEN_HANDLER(mul, 0x1F, 0x0B, 0x03, 0x00000000, PPC_POWER_BR) |
4061 | 76a66253 | j_mayer | { |
4062 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4063 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4064 | 76a66253 | j_mayer | gen_op_POWER_mul(); |
4065 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4066 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4067 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4068 | 76a66253 | j_mayer | } |
4069 | 76a66253 | j_mayer | |
4070 | 76a66253 | j_mayer | /* mulo - mulo. */
|
4071 | 76a66253 | j_mayer | GEN_HANDLER(mulo, 0x1F, 0x0B, 0x13, 0x00000000, PPC_POWER_BR) |
4072 | 76a66253 | j_mayer | { |
4073 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4074 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4075 | 76a66253 | j_mayer | gen_op_POWER_mulo(); |
4076 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4077 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4078 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4079 | 76a66253 | j_mayer | } |
4080 | 76a66253 | j_mayer | |
4081 | 76a66253 | j_mayer | /* nabs - nabs. */
|
4082 | 76a66253 | j_mayer | GEN_HANDLER(nabs, 0x1F, 0x08, 0x0F, 0x00000000, PPC_POWER_BR) |
4083 | 76a66253 | j_mayer | { |
4084 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4085 | 76a66253 | j_mayer | gen_op_POWER_nabs(); |
4086 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4087 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4088 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4089 | 76a66253 | j_mayer | } |
4090 | 76a66253 | j_mayer | |
4091 | 76a66253 | j_mayer | /* nabso - nabso. */
|
4092 | 76a66253 | j_mayer | GEN_HANDLER(nabso, 0x1F, 0x08, 0x1F, 0x00000000, PPC_POWER_BR) |
4093 | 76a66253 | j_mayer | { |
4094 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4095 | 76a66253 | j_mayer | gen_op_POWER_nabso(); |
4096 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4097 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4098 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4099 | 76a66253 | j_mayer | } |
4100 | 76a66253 | j_mayer | |
4101 | 76a66253 | j_mayer | /* rlmi - rlmi. */
|
4102 | 76a66253 | j_mayer | GEN_HANDLER(rlmi, 0x16, 0xFF, 0xFF, 0x00000000, PPC_POWER_BR) |
4103 | 76a66253 | j_mayer | { |
4104 | 76a66253 | j_mayer | uint32_t mb, me; |
4105 | 76a66253 | j_mayer | |
4106 | 76a66253 | j_mayer | mb = MB(ctx->opcode); |
4107 | 76a66253 | j_mayer | me = ME(ctx->opcode); |
4108 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4109 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rA(ctx->opcode)]);
|
4110 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_gpr[rB(ctx->opcode)]);
|
4111 | 76a66253 | j_mayer | gen_op_POWER_rlmi(MASK(mb, me), ~MASK(mb, me)); |
4112 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4113 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4114 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4115 | 76a66253 | j_mayer | } |
4116 | 76a66253 | j_mayer | |
4117 | 76a66253 | j_mayer | /* rrib - rrib. */
|
4118 | 76a66253 | j_mayer | GEN_HANDLER(rrib, 0x1F, 0x19, 0x10, 0x00000000, PPC_POWER_BR) |
4119 | 76a66253 | j_mayer | { |
4120 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4121 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rA(ctx->opcode)]);
|
4122 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_gpr[rB(ctx->opcode)]);
|
4123 | 76a66253 | j_mayer | gen_op_POWER_rrib(); |
4124 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4125 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4126 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4127 | 76a66253 | j_mayer | } |
4128 | 76a66253 | j_mayer | |
4129 | 76a66253 | j_mayer | /* sle - sle. */
|
4130 | 76a66253 | j_mayer | GEN_HANDLER(sle, 0x1F, 0x19, 0x04, 0x00000000, PPC_POWER_BR) |
4131 | 76a66253 | j_mayer | { |
4132 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4133 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4134 | 76a66253 | j_mayer | gen_op_POWER_sle(); |
4135 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4136 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4137 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4138 | 76a66253 | j_mayer | } |
4139 | 76a66253 | j_mayer | |
4140 | 76a66253 | j_mayer | /* sleq - sleq. */
|
4141 | 76a66253 | j_mayer | GEN_HANDLER(sleq, 0x1F, 0x19, 0x06, 0x00000000, PPC_POWER_BR) |
4142 | 76a66253 | j_mayer | { |
4143 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4144 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4145 | 76a66253 | j_mayer | gen_op_POWER_sleq(); |
4146 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4147 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4148 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4149 | 76a66253 | j_mayer | } |
4150 | 76a66253 | j_mayer | |
4151 | 76a66253 | j_mayer | /* sliq - sliq. */
|
4152 | 76a66253 | j_mayer | GEN_HANDLER(sliq, 0x1F, 0x18, 0x05, 0x00000000, PPC_POWER_BR) |
4153 | 76a66253 | j_mayer | { |
4154 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4155 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SH(ctx->opcode));
|
4156 | 76a66253 | j_mayer | gen_op_POWER_sle(); |
4157 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4158 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4159 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4160 | 76a66253 | j_mayer | } |
4161 | 76a66253 | j_mayer | |
4162 | 76a66253 | j_mayer | /* slliq - slliq. */
|
4163 | 76a66253 | j_mayer | GEN_HANDLER(slliq, 0x1F, 0x18, 0x07, 0x00000000, PPC_POWER_BR) |
4164 | 76a66253 | j_mayer | { |
4165 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4166 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SH(ctx->opcode));
|
4167 | 76a66253 | j_mayer | gen_op_POWER_sleq(); |
4168 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4169 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4170 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4171 | 76a66253 | j_mayer | } |
4172 | 76a66253 | j_mayer | |
4173 | 76a66253 | j_mayer | /* sllq - sllq. */
|
4174 | 76a66253 | j_mayer | GEN_HANDLER(sllq, 0x1F, 0x18, 0x06, 0x00000000, PPC_POWER_BR) |
4175 | 76a66253 | j_mayer | { |
4176 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4177 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4178 | 76a66253 | j_mayer | gen_op_POWER_sllq(); |
4179 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4180 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4181 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4182 | 76a66253 | j_mayer | } |
4183 | 76a66253 | j_mayer | |
4184 | 76a66253 | j_mayer | /* slq - slq. */
|
4185 | 76a66253 | j_mayer | GEN_HANDLER(slq, 0x1F, 0x18, 0x04, 0x00000000, PPC_POWER_BR) |
4186 | 76a66253 | j_mayer | { |
4187 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4188 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4189 | 76a66253 | j_mayer | gen_op_POWER_slq(); |
4190 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4191 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4192 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4193 | 76a66253 | j_mayer | } |
4194 | 76a66253 | j_mayer | |
4195 | d9bce9d9 | j_mayer | /* sraiq - sraiq. */
|
4196 | 76a66253 | j_mayer | GEN_HANDLER(sraiq, 0x1F, 0x18, 0x1D, 0x00000000, PPC_POWER_BR) |
4197 | 76a66253 | j_mayer | { |
4198 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4199 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SH(ctx->opcode));
|
4200 | 76a66253 | j_mayer | gen_op_POWER_sraq(); |
4201 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4202 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4203 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4204 | 76a66253 | j_mayer | } |
4205 | 76a66253 | j_mayer | |
4206 | 76a66253 | j_mayer | /* sraq - sraq. */
|
4207 | 76a66253 | j_mayer | GEN_HANDLER(sraq, 0x1F, 0x18, 0x1C, 0x00000000, PPC_POWER_BR) |
4208 | 76a66253 | j_mayer | { |
4209 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4210 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4211 | 76a66253 | j_mayer | gen_op_POWER_sraq(); |
4212 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4213 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4214 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4215 | 76a66253 | j_mayer | } |
4216 | 76a66253 | j_mayer | |
4217 | 76a66253 | j_mayer | /* sre - sre. */
|
4218 | 76a66253 | j_mayer | GEN_HANDLER(sre, 0x1F, 0x19, 0x14, 0x00000000, PPC_POWER_BR) |
4219 | 76a66253 | j_mayer | { |
4220 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4221 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4222 | 76a66253 | j_mayer | gen_op_POWER_sre(); |
4223 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4224 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4225 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4226 | 76a66253 | j_mayer | } |
4227 | 76a66253 | j_mayer | |
4228 | 76a66253 | j_mayer | /* srea - srea. */
|
4229 | 76a66253 | j_mayer | GEN_HANDLER(srea, 0x1F, 0x19, 0x1C, 0x00000000, PPC_POWER_BR) |
4230 | 76a66253 | j_mayer | { |
4231 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4232 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4233 | 76a66253 | j_mayer | gen_op_POWER_srea(); |
4234 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4235 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4236 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4237 | 76a66253 | j_mayer | } |
4238 | 76a66253 | j_mayer | |
4239 | 76a66253 | j_mayer | /* sreq */
|
4240 | 76a66253 | j_mayer | GEN_HANDLER(sreq, 0x1F, 0x19, 0x16, 0x00000000, PPC_POWER_BR) |
4241 | 76a66253 | j_mayer | { |
4242 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4243 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4244 | 76a66253 | j_mayer | gen_op_POWER_sreq(); |
4245 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4246 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4247 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4248 | 76a66253 | j_mayer | } |
4249 | 76a66253 | j_mayer | |
4250 | 76a66253 | j_mayer | /* sriq */
|
4251 | 76a66253 | j_mayer | GEN_HANDLER(sriq, 0x1F, 0x18, 0x15, 0x00000000, PPC_POWER_BR) |
4252 | 76a66253 | j_mayer | { |
4253 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4254 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SH(ctx->opcode));
|
4255 | 76a66253 | j_mayer | gen_op_POWER_srq(); |
4256 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4257 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4258 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4259 | 76a66253 | j_mayer | } |
4260 | 76a66253 | j_mayer | |
4261 | 76a66253 | j_mayer | /* srliq */
|
4262 | 76a66253 | j_mayer | GEN_HANDLER(srliq, 0x1F, 0x18, 0x17, 0x00000000, PPC_POWER_BR) |
4263 | 76a66253 | j_mayer | { |
4264 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4265 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4266 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[1], SH(ctx->opcode));
|
4267 | 76a66253 | j_mayer | gen_op_POWER_srlq(); |
4268 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4269 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4270 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4271 | 76a66253 | j_mayer | } |
4272 | 76a66253 | j_mayer | |
4273 | 76a66253 | j_mayer | /* srlq */
|
4274 | 76a66253 | j_mayer | GEN_HANDLER(srlq, 0x1F, 0x18, 0x16, 0x00000000, PPC_POWER_BR) |
4275 | 76a66253 | j_mayer | { |
4276 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4277 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4278 | 76a66253 | j_mayer | gen_op_POWER_srlq(); |
4279 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4280 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4281 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4282 | 76a66253 | j_mayer | } |
4283 | 76a66253 | j_mayer | |
4284 | 76a66253 | j_mayer | /* srq */
|
4285 | 76a66253 | j_mayer | GEN_HANDLER(srq, 0x1F, 0x18, 0x14, 0x00000000, PPC_POWER_BR) |
4286 | 76a66253 | j_mayer | { |
4287 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
4288 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
4289 | 76a66253 | j_mayer | gen_op_POWER_srq(); |
4290 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
4291 | 76a66253 | j_mayer | if (unlikely(Rc(ctx->opcode) != 0)) |
4292 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4293 | 76a66253 | j_mayer | } |
4294 | 76a66253 | j_mayer | |
4295 | 76a66253 | j_mayer | /* PowerPC 602 specific instructions */
|
4296 | 76a66253 | j_mayer | /* dsa */
|
4297 | 76a66253 | j_mayer | GEN_HANDLER(dsa, 0x1F, 0x14, 0x13, 0x03FFF801, PPC_602_SPEC) |
4298 | 76a66253 | j_mayer | { |
4299 | 76a66253 | j_mayer | /* XXX: TODO */
|
4300 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
4301 | 76a66253 | j_mayer | } |
4302 | 76a66253 | j_mayer | |
4303 | 76a66253 | j_mayer | /* esa */
|
4304 | 76a66253 | j_mayer | GEN_HANDLER(esa, 0x1F, 0x14, 0x12, 0x03FFF801, PPC_602_SPEC) |
4305 | 76a66253 | j_mayer | { |
4306 | 76a66253 | j_mayer | /* XXX: TODO */
|
4307 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
4308 | 76a66253 | j_mayer | } |
4309 | 76a66253 | j_mayer | |
4310 | 76a66253 | j_mayer | /* mfrom */
|
4311 | 76a66253 | j_mayer | GEN_HANDLER(mfrom, 0x1F, 0x09, 0x08, 0x03E0F801, PPC_602_SPEC) |
4312 | 76a66253 | j_mayer | { |
4313 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4314 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4315 | 76a66253 | j_mayer | #else
|
4316 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4317 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4318 | 76a66253 | j_mayer | return;
|
4319 | 76a66253 | j_mayer | } |
4320 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4321 | 76a66253 | j_mayer | gen_op_602_mfrom(); |
4322 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4323 | 76a66253 | j_mayer | #endif
|
4324 | 76a66253 | j_mayer | } |
4325 | 76a66253 | j_mayer | |
4326 | 76a66253 | j_mayer | /* 602 - 603 - G2 TLB management */
|
4327 | 76a66253 | j_mayer | /* tlbld */
|
4328 | c7697e1f | j_mayer | GEN_HANDLER2(tlbld_6xx, "tlbld", 0x1F, 0x12, 0x1E, 0x03FF0001, PPC_6xx_TLB) |
4329 | 76a66253 | j_mayer | { |
4330 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4331 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4332 | 76a66253 | j_mayer | #else
|
4333 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4334 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4335 | 76a66253 | j_mayer | return;
|
4336 | 76a66253 | j_mayer | } |
4337 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rB(ctx->opcode)]);
|
4338 | 76a66253 | j_mayer | gen_op_6xx_tlbld(); |
4339 | 76a66253 | j_mayer | #endif
|
4340 | 76a66253 | j_mayer | } |
4341 | 76a66253 | j_mayer | |
4342 | 76a66253 | j_mayer | /* tlbli */
|
4343 | c7697e1f | j_mayer | GEN_HANDLER2(tlbli_6xx, "tlbli", 0x1F, 0x12, 0x1F, 0x03FF0001, PPC_6xx_TLB) |
4344 | 76a66253 | j_mayer | { |
4345 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4346 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4347 | 76a66253 | j_mayer | #else
|
4348 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4349 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4350 | 76a66253 | j_mayer | return;
|
4351 | 76a66253 | j_mayer | } |
4352 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rB(ctx->opcode)]);
|
4353 | 76a66253 | j_mayer | gen_op_6xx_tlbli(); |
4354 | 76a66253 | j_mayer | #endif
|
4355 | 76a66253 | j_mayer | } |
4356 | 76a66253 | j_mayer | |
4357 | 7dbe11ac | j_mayer | /* 74xx TLB management */
|
4358 | 7dbe11ac | j_mayer | /* tlbld */
|
4359 | c7697e1f | j_mayer | GEN_HANDLER2(tlbld_74xx, "tlbld", 0x1F, 0x12, 0x1E, 0x03FF0001, PPC_74xx_TLB) |
4360 | 7dbe11ac | j_mayer | { |
4361 | 7dbe11ac | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4362 | 7dbe11ac | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4363 | 7dbe11ac | j_mayer | #else
|
4364 | 7dbe11ac | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4365 | 7dbe11ac | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4366 | 7dbe11ac | j_mayer | return;
|
4367 | 7dbe11ac | j_mayer | } |
4368 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rB(ctx->opcode)]);
|
4369 | 7dbe11ac | j_mayer | gen_op_74xx_tlbld(); |
4370 | 7dbe11ac | j_mayer | #endif
|
4371 | 7dbe11ac | j_mayer | } |
4372 | 7dbe11ac | j_mayer | |
4373 | 7dbe11ac | j_mayer | /* tlbli */
|
4374 | c7697e1f | j_mayer | GEN_HANDLER2(tlbli_74xx, "tlbli", 0x1F, 0x12, 0x1F, 0x03FF0001, PPC_74xx_TLB) |
4375 | 7dbe11ac | j_mayer | { |
4376 | 7dbe11ac | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4377 | 7dbe11ac | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4378 | 7dbe11ac | j_mayer | #else
|
4379 | 7dbe11ac | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4380 | 7dbe11ac | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4381 | 7dbe11ac | j_mayer | return;
|
4382 | 7dbe11ac | j_mayer | } |
4383 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rB(ctx->opcode)]);
|
4384 | 7dbe11ac | j_mayer | gen_op_74xx_tlbli(); |
4385 | 7dbe11ac | j_mayer | #endif
|
4386 | 7dbe11ac | j_mayer | } |
4387 | 7dbe11ac | j_mayer | |
4388 | 76a66253 | j_mayer | /* POWER instructions not in PowerPC 601 */
|
4389 | 76a66253 | j_mayer | /* clf */
|
4390 | 76a66253 | j_mayer | GEN_HANDLER(clf, 0x1F, 0x16, 0x03, 0x03E00000, PPC_POWER) |
4391 | 76a66253 | j_mayer | { |
4392 | 76a66253 | j_mayer | /* Cache line flush: implemented as no-op */
|
4393 | 76a66253 | j_mayer | } |
4394 | 76a66253 | j_mayer | |
4395 | 76a66253 | j_mayer | /* cli */
|
4396 | 76a66253 | j_mayer | GEN_HANDLER(cli, 0x1F, 0x16, 0x0F, 0x03E00000, PPC_POWER) |
4397 | 76a66253 | j_mayer | { |
4398 | 7f75ffd3 | blueswir1 | /* Cache line invalidate: privileged and treated as no-op */
|
4399 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4400 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4401 | 76a66253 | j_mayer | #else
|
4402 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4403 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4404 | 76a66253 | j_mayer | return;
|
4405 | 76a66253 | j_mayer | } |
4406 | 76a66253 | j_mayer | #endif
|
4407 | 76a66253 | j_mayer | } |
4408 | 76a66253 | j_mayer | |
4409 | 76a66253 | j_mayer | /* dclst */
|
4410 | 76a66253 | j_mayer | GEN_HANDLER(dclst, 0x1F, 0x16, 0x13, 0x03E00000, PPC_POWER) |
4411 | 76a66253 | j_mayer | { |
4412 | 76a66253 | j_mayer | /* Data cache line store: treated as no-op */
|
4413 | 76a66253 | j_mayer | } |
4414 | 76a66253 | j_mayer | |
4415 | 76a66253 | j_mayer | GEN_HANDLER(mfsri, 0x1F, 0x13, 0x13, 0x00000001, PPC_POWER) |
4416 | 76a66253 | j_mayer | { |
4417 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4418 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4419 | 76a66253 | j_mayer | #else
|
4420 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4421 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4422 | 76a66253 | j_mayer | return;
|
4423 | 76a66253 | j_mayer | } |
4424 | 76a66253 | j_mayer | int ra = rA(ctx->opcode);
|
4425 | 76a66253 | j_mayer | int rd = rD(ctx->opcode);
|
4426 | 76a66253 | j_mayer | |
4427 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
4428 | 76a66253 | j_mayer | gen_op_POWER_mfsri(); |
4429 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rd], cpu_T[0]);
|
4430 | 76a66253 | j_mayer | if (ra != 0 && ra != rd) |
4431 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[ra], cpu_T[1]);
|
4432 | 76a66253 | j_mayer | #endif
|
4433 | 76a66253 | j_mayer | } |
4434 | 76a66253 | j_mayer | |
4435 | 76a66253 | j_mayer | GEN_HANDLER(rac, 0x1F, 0x12, 0x19, 0x00000001, PPC_POWER) |
4436 | 76a66253 | j_mayer | { |
4437 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4438 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4439 | 76a66253 | j_mayer | #else
|
4440 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4441 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4442 | 76a66253 | j_mayer | return;
|
4443 | 76a66253 | j_mayer | } |
4444 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
4445 | 76a66253 | j_mayer | gen_op_POWER_rac(); |
4446 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4447 | 76a66253 | j_mayer | #endif
|
4448 | 76a66253 | j_mayer | } |
4449 | 76a66253 | j_mayer | |
4450 | 76a66253 | j_mayer | GEN_HANDLER(rfsvc, 0x13, 0x12, 0x02, 0x03FFF0001, PPC_POWER) |
4451 | 76a66253 | j_mayer | { |
4452 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4453 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4454 | 76a66253 | j_mayer | #else
|
4455 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4456 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4457 | 76a66253 | j_mayer | return;
|
4458 | 76a66253 | j_mayer | } |
4459 | 76a66253 | j_mayer | gen_op_POWER_rfsvc(); |
4460 | e1833e1f | j_mayer | GEN_SYNC(ctx); |
4461 | 76a66253 | j_mayer | #endif
|
4462 | 76a66253 | j_mayer | } |
4463 | 76a66253 | j_mayer | |
4464 | 76a66253 | j_mayer | /* svc is not implemented for now */
|
4465 | 76a66253 | j_mayer | |
4466 | 76a66253 | j_mayer | /* POWER2 specific instructions */
|
4467 | 76a66253 | j_mayer | /* Quad manipulation (load/store two floats at a time) */
|
4468 | 7863667f | j_mayer | /* Original POWER2 is 32 bits only, define 64 bits ops as 32 bits ones */
|
4469 | 76a66253 | j_mayer | #define op_POWER2_lfq() (*gen_op_POWER2_lfq[ctx->mem_idx])()
|
4470 | 76a66253 | j_mayer | #define op_POWER2_stfq() (*gen_op_POWER2_stfq[ctx->mem_idx])()
|
4471 | 7863667f | j_mayer | #define gen_op_POWER2_lfq_64_raw gen_op_POWER2_lfq_raw
|
4472 | 7863667f | j_mayer | #define gen_op_POWER2_lfq_64_user gen_op_POWER2_lfq_user
|
4473 | 7863667f | j_mayer | #define gen_op_POWER2_lfq_64_kernel gen_op_POWER2_lfq_kernel
|
4474 | 7863667f | j_mayer | #define gen_op_POWER2_lfq_64_hypv gen_op_POWER2_lfq_hypv
|
4475 | 7863667f | j_mayer | #define gen_op_POWER2_lfq_le_64_raw gen_op_POWER2_lfq_le_raw
|
4476 | 7863667f | j_mayer | #define gen_op_POWER2_lfq_le_64_user gen_op_POWER2_lfq_le_user
|
4477 | 7863667f | j_mayer | #define gen_op_POWER2_lfq_le_64_kernel gen_op_POWER2_lfq_le_kernel
|
4478 | 7863667f | j_mayer | #define gen_op_POWER2_lfq_le_64_hypv gen_op_POWER2_lfq_le_hypv
|
4479 | 7863667f | j_mayer | #define gen_op_POWER2_stfq_64_raw gen_op_POWER2_stfq_raw
|
4480 | 7863667f | j_mayer | #define gen_op_POWER2_stfq_64_user gen_op_POWER2_stfq_user
|
4481 | 7863667f | j_mayer | #define gen_op_POWER2_stfq_64_kernel gen_op_POWER2_stfq_kernel
|
4482 | 7863667f | j_mayer | #define gen_op_POWER2_stfq_64_hypv gen_op_POWER2_stfq_hypv
|
4483 | 7863667f | j_mayer | #define gen_op_POWER2_stfq_le_64_raw gen_op_POWER2_stfq_le_raw
|
4484 | 7863667f | j_mayer | #define gen_op_POWER2_stfq_le_64_user gen_op_POWER2_stfq_le_user
|
4485 | 7863667f | j_mayer | #define gen_op_POWER2_stfq_le_64_kernel gen_op_POWER2_stfq_le_kernel
|
4486 | 7863667f | j_mayer | #define gen_op_POWER2_stfq_le_64_hypv gen_op_POWER2_stfq_le_hypv
|
4487 | 7863667f | j_mayer | static GenOpFunc *gen_op_POWER2_lfq[NB_MEM_FUNCS] = {
|
4488 | 7863667f | j_mayer | GEN_MEM_FUNCS(POWER2_lfq), |
4489 | 76a66253 | j_mayer | }; |
4490 | 7863667f | j_mayer | static GenOpFunc *gen_op_POWER2_stfq[NB_MEM_FUNCS] = {
|
4491 | 7863667f | j_mayer | GEN_MEM_FUNCS(POWER2_stfq), |
4492 | 76a66253 | j_mayer | }; |
4493 | 76a66253 | j_mayer | |
4494 | 76a66253 | j_mayer | /* lfq */
|
4495 | 76a66253 | j_mayer | GEN_HANDLER(lfq, 0x38, 0xFF, 0xFF, 0x00000003, PPC_POWER2) |
4496 | 76a66253 | j_mayer | { |
4497 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
4498 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
4499 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0);
|
4500 | 76a66253 | j_mayer | op_POWER2_lfq(); |
4501 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
|
4502 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode) + 1], cpu_FT[1]); |
4503 | 76a66253 | j_mayer | } |
4504 | 76a66253 | j_mayer | |
4505 | 76a66253 | j_mayer | /* lfqu */
|
4506 | 76a66253 | j_mayer | GEN_HANDLER(lfqu, 0x39, 0xFF, 0xFF, 0x00000003, PPC_POWER2) |
4507 | 76a66253 | j_mayer | { |
4508 | 76a66253 | j_mayer | int ra = rA(ctx->opcode);
|
4509 | 76a66253 | j_mayer | |
4510 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
4511 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
4512 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0);
|
4513 | 76a66253 | j_mayer | op_POWER2_lfq(); |
4514 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
|
4515 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode) + 1], cpu_FT[1]); |
4516 | 76a66253 | j_mayer | if (ra != 0) |
4517 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[ra], cpu_T[0]);
|
4518 | 76a66253 | j_mayer | } |
4519 | 76a66253 | j_mayer | |
4520 | 76a66253 | j_mayer | /* lfqux */
|
4521 | 76a66253 | j_mayer | GEN_HANDLER(lfqux, 0x1F, 0x17, 0x19, 0x00000001, PPC_POWER2) |
4522 | 76a66253 | j_mayer | { |
4523 | 76a66253 | j_mayer | int ra = rA(ctx->opcode);
|
4524 | 76a66253 | j_mayer | |
4525 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
4526 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
4527 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
4528 | 76a66253 | j_mayer | op_POWER2_lfq(); |
4529 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
|
4530 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode) + 1], cpu_FT[1]); |
4531 | 76a66253 | j_mayer | if (ra != 0) |
4532 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[ra], cpu_T[0]);
|
4533 | 76a66253 | j_mayer | } |
4534 | 76a66253 | j_mayer | |
4535 | 76a66253 | j_mayer | /* lfqx */
|
4536 | 76a66253 | j_mayer | GEN_HANDLER(lfqx, 0x1F, 0x17, 0x18, 0x00000001, PPC_POWER2) |
4537 | 76a66253 | j_mayer | { |
4538 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
4539 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
4540 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
4541 | 76a66253 | j_mayer | op_POWER2_lfq(); |
4542 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_FT[0]);
|
4543 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode) + 1], cpu_FT[1]); |
4544 | 76a66253 | j_mayer | } |
4545 | 76a66253 | j_mayer | |
4546 | 76a66253 | j_mayer | /* stfq */
|
4547 | 76a66253 | j_mayer | GEN_HANDLER(stfq, 0x3C, 0xFF, 0xFF, 0x00000003, PPC_POWER2) |
4548 | 76a66253 | j_mayer | { |
4549 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
4550 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
4551 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0);
|
4552 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]);
|
4553 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rS(ctx->opcode) + 1]); |
4554 | 76a66253 | j_mayer | op_POWER2_stfq(); |
4555 | 76a66253 | j_mayer | } |
4556 | 76a66253 | j_mayer | |
4557 | 76a66253 | j_mayer | /* stfqu */
|
4558 | 76a66253 | j_mayer | GEN_HANDLER(stfqu, 0x3D, 0xFF, 0xFF, 0x00000003, PPC_POWER2) |
4559 | 76a66253 | j_mayer | { |
4560 | 76a66253 | j_mayer | int ra = rA(ctx->opcode);
|
4561 | 76a66253 | j_mayer | |
4562 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
4563 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
4564 | 9d53c753 | j_mayer | gen_addr_imm_index(ctx, 0);
|
4565 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]);
|
4566 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rS(ctx->opcode) + 1]); |
4567 | 76a66253 | j_mayer | op_POWER2_stfq(); |
4568 | 76a66253 | j_mayer | if (ra != 0) |
4569 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[ra], cpu_T[0]);
|
4570 | 76a66253 | j_mayer | } |
4571 | 76a66253 | j_mayer | |
4572 | 76a66253 | j_mayer | /* stfqux */
|
4573 | 76a66253 | j_mayer | GEN_HANDLER(stfqux, 0x1F, 0x17, 0x1D, 0x00000001, PPC_POWER2) |
4574 | 76a66253 | j_mayer | { |
4575 | 76a66253 | j_mayer | int ra = rA(ctx->opcode);
|
4576 | 76a66253 | j_mayer | |
4577 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
4578 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
4579 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
4580 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]);
|
4581 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rS(ctx->opcode) + 1]); |
4582 | 76a66253 | j_mayer | op_POWER2_stfq(); |
4583 | 76a66253 | j_mayer | if (ra != 0) |
4584 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[ra], cpu_T[0]);
|
4585 | 76a66253 | j_mayer | } |
4586 | 76a66253 | j_mayer | |
4587 | 76a66253 | j_mayer | /* stfqx */
|
4588 | 76a66253 | j_mayer | GEN_HANDLER(stfqx, 0x1F, 0x17, 0x1C, 0x00000001, PPC_POWER2) |
4589 | 76a66253 | j_mayer | { |
4590 | 76a66253 | j_mayer | /* NIP cannot be restored if the memory exception comes from an helper */
|
4591 | d9bce9d9 | j_mayer | gen_update_nip(ctx, ctx->nip - 4);
|
4592 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
4593 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[0], cpu_fpr[rS(ctx->opcode)]);
|
4594 | a5e26afa | aurel32 | tcg_gen_mov_i64(cpu_FT[1], cpu_fpr[rS(ctx->opcode) + 1]); |
4595 | 76a66253 | j_mayer | op_POWER2_stfq(); |
4596 | 76a66253 | j_mayer | } |
4597 | 76a66253 | j_mayer | |
4598 | 76a66253 | j_mayer | /* BookE specific instructions */
|
4599 | 2662a059 | j_mayer | /* XXX: not implemented on 440 ? */
|
4600 | 05332d70 | j_mayer | GEN_HANDLER(mfapidi, 0x1F, 0x13, 0x08, 0x0000F801, PPC_MFAPIDI) |
4601 | 76a66253 | j_mayer | { |
4602 | 76a66253 | j_mayer | /* XXX: TODO */
|
4603 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
4604 | 76a66253 | j_mayer | } |
4605 | 76a66253 | j_mayer | |
4606 | 2662a059 | j_mayer | /* XXX: not implemented on 440 ? */
|
4607 | 05332d70 | j_mayer | GEN_HANDLER(tlbiva, 0x1F, 0x12, 0x18, 0x03FFF801, PPC_TLBIVA) |
4608 | 76a66253 | j_mayer | { |
4609 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4610 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4611 | 76a66253 | j_mayer | #else
|
4612 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4613 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4614 | 76a66253 | j_mayer | return;
|
4615 | 76a66253 | j_mayer | } |
4616 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
4617 | 76a66253 | j_mayer | /* Use the same micro-ops as for tlbie */
|
4618 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
4619 | d9bce9d9 | j_mayer | if (ctx->sf_mode)
|
4620 | d9bce9d9 | j_mayer | gen_op_tlbie_64(); |
4621 | d9bce9d9 | j_mayer | else
|
4622 | d9bce9d9 | j_mayer | #endif
|
4623 | d9bce9d9 | j_mayer | gen_op_tlbie(); |
4624 | 76a66253 | j_mayer | #endif
|
4625 | 76a66253 | j_mayer | } |
4626 | 76a66253 | j_mayer | |
4627 | 76a66253 | j_mayer | /* All 405 MAC instructions are translated here */
|
4628 | b068d6a7 | j_mayer | static always_inline void gen_405_mulladd_insn (DisasContext *ctx, |
4629 | b068d6a7 | j_mayer | int opc2, int opc3, |
4630 | b068d6a7 | j_mayer | int ra, int rb, int rt, int Rc) |
4631 | 76a66253 | j_mayer | { |
4632 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[ra]);
|
4633 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rb]);
|
4634 | 76a66253 | j_mayer | switch (opc3 & 0x0D) { |
4635 | 76a66253 | j_mayer | case 0x05: |
4636 | 76a66253 | j_mayer | /* macchw - macchw. - macchwo - macchwo. */
|
4637 | 76a66253 | j_mayer | /* macchws - macchws. - macchwso - macchwso. */
|
4638 | 76a66253 | j_mayer | /* nmacchw - nmacchw. - nmacchwo - nmacchwo. */
|
4639 | 76a66253 | j_mayer | /* nmacchws - nmacchws. - nmacchwso - nmacchwso. */
|
4640 | 76a66253 | j_mayer | /* mulchw - mulchw. */
|
4641 | 76a66253 | j_mayer | gen_op_405_mulchw(); |
4642 | 76a66253 | j_mayer | break;
|
4643 | 76a66253 | j_mayer | case 0x04: |
4644 | 76a66253 | j_mayer | /* macchwu - macchwu. - macchwuo - macchwuo. */
|
4645 | 76a66253 | j_mayer | /* macchwsu - macchwsu. - macchwsuo - macchwsuo. */
|
4646 | 76a66253 | j_mayer | /* mulchwu - mulchwu. */
|
4647 | 76a66253 | j_mayer | gen_op_405_mulchwu(); |
4648 | 76a66253 | j_mayer | break;
|
4649 | 76a66253 | j_mayer | case 0x01: |
4650 | 76a66253 | j_mayer | /* machhw - machhw. - machhwo - machhwo. */
|
4651 | 76a66253 | j_mayer | /* machhws - machhws. - machhwso - machhwso. */
|
4652 | 76a66253 | j_mayer | /* nmachhw - nmachhw. - nmachhwo - nmachhwo. */
|
4653 | 76a66253 | j_mayer | /* nmachhws - nmachhws. - nmachhwso - nmachhwso. */
|
4654 | 76a66253 | j_mayer | /* mulhhw - mulhhw. */
|
4655 | 76a66253 | j_mayer | gen_op_405_mulhhw(); |
4656 | 76a66253 | j_mayer | break;
|
4657 | 76a66253 | j_mayer | case 0x00: |
4658 | 76a66253 | j_mayer | /* machhwu - machhwu. - machhwuo - machhwuo. */
|
4659 | 76a66253 | j_mayer | /* machhwsu - machhwsu. - machhwsuo - machhwsuo. */
|
4660 | 76a66253 | j_mayer | /* mulhhwu - mulhhwu. */
|
4661 | 76a66253 | j_mayer | gen_op_405_mulhhwu(); |
4662 | 76a66253 | j_mayer | break;
|
4663 | 76a66253 | j_mayer | case 0x0D: |
4664 | 76a66253 | j_mayer | /* maclhw - maclhw. - maclhwo - maclhwo. */
|
4665 | 76a66253 | j_mayer | /* maclhws - maclhws. - maclhwso - maclhwso. */
|
4666 | 76a66253 | j_mayer | /* nmaclhw - nmaclhw. - nmaclhwo - nmaclhwo. */
|
4667 | 76a66253 | j_mayer | /* nmaclhws - nmaclhws. - nmaclhwso - nmaclhwso. */
|
4668 | 76a66253 | j_mayer | /* mullhw - mullhw. */
|
4669 | 76a66253 | j_mayer | gen_op_405_mullhw(); |
4670 | 76a66253 | j_mayer | break;
|
4671 | 76a66253 | j_mayer | case 0x0C: |
4672 | 76a66253 | j_mayer | /* maclhwu - maclhwu. - maclhwuo - maclhwuo. */
|
4673 | 76a66253 | j_mayer | /* maclhwsu - maclhwsu. - maclhwsuo - maclhwsuo. */
|
4674 | 76a66253 | j_mayer | /* mullhwu - mullhwu. */
|
4675 | 76a66253 | j_mayer | gen_op_405_mullhwu(); |
4676 | 76a66253 | j_mayer | break;
|
4677 | 76a66253 | j_mayer | } |
4678 | 76a66253 | j_mayer | if (opc2 & 0x02) { |
4679 | 76a66253 | j_mayer | /* nmultiply-and-accumulate (0x0E) */
|
4680 | 76a66253 | j_mayer | gen_op_neg(); |
4681 | 76a66253 | j_mayer | } |
4682 | 76a66253 | j_mayer | if (opc2 & 0x04) { |
4683 | 76a66253 | j_mayer | /* (n)multiply-and-accumulate (0x0C - 0x0E) */
|
4684 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[2], cpu_gpr[rt]);
|
4685 | e55fd934 | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_T[0]); |
4686 | 76a66253 | j_mayer | gen_op_405_add_T0_T2(); |
4687 | 76a66253 | j_mayer | } |
4688 | 76a66253 | j_mayer | if (opc3 & 0x10) { |
4689 | 76a66253 | j_mayer | /* Check overflow */
|
4690 | 76a66253 | j_mayer | if (opc3 & 0x01) |
4691 | c3e10c7b | j_mayer | gen_op_check_addo(); |
4692 | 76a66253 | j_mayer | else
|
4693 | 76a66253 | j_mayer | gen_op_405_check_ovu(); |
4694 | 76a66253 | j_mayer | } |
4695 | 76a66253 | j_mayer | if (opc3 & 0x02) { |
4696 | 76a66253 | j_mayer | /* Saturate */
|
4697 | 76a66253 | j_mayer | if (opc3 & 0x01) |
4698 | 76a66253 | j_mayer | gen_op_405_check_sat(); |
4699 | 76a66253 | j_mayer | else
|
4700 | 76a66253 | j_mayer | gen_op_405_check_satu(); |
4701 | 76a66253 | j_mayer | } |
4702 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rt], cpu_T[0]);
|
4703 | 76a66253 | j_mayer | if (unlikely(Rc) != 0) { |
4704 | 76a66253 | j_mayer | /* Update Rc0 */
|
4705 | 76a66253 | j_mayer | gen_set_Rc0(ctx); |
4706 | 76a66253 | j_mayer | } |
4707 | 76a66253 | j_mayer | } |
4708 | 76a66253 | j_mayer | |
4709 | a750fc0b | j_mayer | #define GEN_MAC_HANDLER(name, opc2, opc3) \
|
4710 | a750fc0b | j_mayer | GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_405_MAC) \ |
4711 | 76a66253 | j_mayer | { \ |
4712 | 76a66253 | j_mayer | gen_405_mulladd_insn(ctx, opc2, opc3, rA(ctx->opcode), rB(ctx->opcode), \ |
4713 | 76a66253 | j_mayer | rD(ctx->opcode), Rc(ctx->opcode)); \ |
4714 | 76a66253 | j_mayer | } |
4715 | 76a66253 | j_mayer | |
4716 | 76a66253 | j_mayer | /* macchw - macchw. */
|
4717 | a750fc0b | j_mayer | GEN_MAC_HANDLER(macchw, 0x0C, 0x05); |
4718 | 76a66253 | j_mayer | /* macchwo - macchwo. */
|
4719 | a750fc0b | j_mayer | GEN_MAC_HANDLER(macchwo, 0x0C, 0x15); |
4720 | 76a66253 | j_mayer | /* macchws - macchws. */
|
4721 | a750fc0b | j_mayer | GEN_MAC_HANDLER(macchws, 0x0C, 0x07); |
4722 | 76a66253 | j_mayer | /* macchwso - macchwso. */
|
4723 | a750fc0b | j_mayer | GEN_MAC_HANDLER(macchwso, 0x0C, 0x17); |
4724 | 76a66253 | j_mayer | /* macchwsu - macchwsu. */
|
4725 | a750fc0b | j_mayer | GEN_MAC_HANDLER(macchwsu, 0x0C, 0x06); |
4726 | 76a66253 | j_mayer | /* macchwsuo - macchwsuo. */
|
4727 | a750fc0b | j_mayer | GEN_MAC_HANDLER(macchwsuo, 0x0C, 0x16); |
4728 | 76a66253 | j_mayer | /* macchwu - macchwu. */
|
4729 | a750fc0b | j_mayer | GEN_MAC_HANDLER(macchwu, 0x0C, 0x04); |
4730 | 76a66253 | j_mayer | /* macchwuo - macchwuo. */
|
4731 | a750fc0b | j_mayer | GEN_MAC_HANDLER(macchwuo, 0x0C, 0x14); |
4732 | 76a66253 | j_mayer | /* machhw - machhw. */
|
4733 | a750fc0b | j_mayer | GEN_MAC_HANDLER(machhw, 0x0C, 0x01); |
4734 | 76a66253 | j_mayer | /* machhwo - machhwo. */
|
4735 | a750fc0b | j_mayer | GEN_MAC_HANDLER(machhwo, 0x0C, 0x11); |
4736 | 76a66253 | j_mayer | /* machhws - machhws. */
|
4737 | a750fc0b | j_mayer | GEN_MAC_HANDLER(machhws, 0x0C, 0x03); |
4738 | 76a66253 | j_mayer | /* machhwso - machhwso. */
|
4739 | a750fc0b | j_mayer | GEN_MAC_HANDLER(machhwso, 0x0C, 0x13); |
4740 | 76a66253 | j_mayer | /* machhwsu - machhwsu. */
|
4741 | a750fc0b | j_mayer | GEN_MAC_HANDLER(machhwsu, 0x0C, 0x02); |
4742 | 76a66253 | j_mayer | /* machhwsuo - machhwsuo. */
|
4743 | a750fc0b | j_mayer | GEN_MAC_HANDLER(machhwsuo, 0x0C, 0x12); |
4744 | 76a66253 | j_mayer | /* machhwu - machhwu. */
|
4745 | a750fc0b | j_mayer | GEN_MAC_HANDLER(machhwu, 0x0C, 0x00); |
4746 | 76a66253 | j_mayer | /* machhwuo - machhwuo. */
|
4747 | a750fc0b | j_mayer | GEN_MAC_HANDLER(machhwuo, 0x0C, 0x10); |
4748 | 76a66253 | j_mayer | /* maclhw - maclhw. */
|
4749 | a750fc0b | j_mayer | GEN_MAC_HANDLER(maclhw, 0x0C, 0x0D); |
4750 | 76a66253 | j_mayer | /* maclhwo - maclhwo. */
|
4751 | a750fc0b | j_mayer | GEN_MAC_HANDLER(maclhwo, 0x0C, 0x1D); |
4752 | 76a66253 | j_mayer | /* maclhws - maclhws. */
|
4753 | a750fc0b | j_mayer | GEN_MAC_HANDLER(maclhws, 0x0C, 0x0F); |
4754 | 76a66253 | j_mayer | /* maclhwso - maclhwso. */
|
4755 | a750fc0b | j_mayer | GEN_MAC_HANDLER(maclhwso, 0x0C, 0x1F); |
4756 | 76a66253 | j_mayer | /* maclhwu - maclhwu. */
|
4757 | a750fc0b | j_mayer | GEN_MAC_HANDLER(maclhwu, 0x0C, 0x0C); |
4758 | 76a66253 | j_mayer | /* maclhwuo - maclhwuo. */
|
4759 | a750fc0b | j_mayer | GEN_MAC_HANDLER(maclhwuo, 0x0C, 0x1C); |
4760 | 76a66253 | j_mayer | /* maclhwsu - maclhwsu. */
|
4761 | a750fc0b | j_mayer | GEN_MAC_HANDLER(maclhwsu, 0x0C, 0x0E); |
4762 | 76a66253 | j_mayer | /* maclhwsuo - maclhwsuo. */
|
4763 | a750fc0b | j_mayer | GEN_MAC_HANDLER(maclhwsuo, 0x0C, 0x1E); |
4764 | 76a66253 | j_mayer | /* nmacchw - nmacchw. */
|
4765 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmacchw, 0x0E, 0x05); |
4766 | 76a66253 | j_mayer | /* nmacchwo - nmacchwo. */
|
4767 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmacchwo, 0x0E, 0x15); |
4768 | 76a66253 | j_mayer | /* nmacchws - nmacchws. */
|
4769 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmacchws, 0x0E, 0x07); |
4770 | 76a66253 | j_mayer | /* nmacchwso - nmacchwso. */
|
4771 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmacchwso, 0x0E, 0x17); |
4772 | 76a66253 | j_mayer | /* nmachhw - nmachhw. */
|
4773 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmachhw, 0x0E, 0x01); |
4774 | 76a66253 | j_mayer | /* nmachhwo - nmachhwo. */
|
4775 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmachhwo, 0x0E, 0x11); |
4776 | 76a66253 | j_mayer | /* nmachhws - nmachhws. */
|
4777 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmachhws, 0x0E, 0x03); |
4778 | 76a66253 | j_mayer | /* nmachhwso - nmachhwso. */
|
4779 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmachhwso, 0x0E, 0x13); |
4780 | 76a66253 | j_mayer | /* nmaclhw - nmaclhw. */
|
4781 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmaclhw, 0x0E, 0x0D); |
4782 | 76a66253 | j_mayer | /* nmaclhwo - nmaclhwo. */
|
4783 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmaclhwo, 0x0E, 0x1D); |
4784 | 76a66253 | j_mayer | /* nmaclhws - nmaclhws. */
|
4785 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmaclhws, 0x0E, 0x0F); |
4786 | 76a66253 | j_mayer | /* nmaclhwso - nmaclhwso. */
|
4787 | a750fc0b | j_mayer | GEN_MAC_HANDLER(nmaclhwso, 0x0E, 0x1F); |
4788 | 76a66253 | j_mayer | |
4789 | 76a66253 | j_mayer | /* mulchw - mulchw. */
|
4790 | a750fc0b | j_mayer | GEN_MAC_HANDLER(mulchw, 0x08, 0x05); |
4791 | 76a66253 | j_mayer | /* mulchwu - mulchwu. */
|
4792 | a750fc0b | j_mayer | GEN_MAC_HANDLER(mulchwu, 0x08, 0x04); |
4793 | 76a66253 | j_mayer | /* mulhhw - mulhhw. */
|
4794 | a750fc0b | j_mayer | GEN_MAC_HANDLER(mulhhw, 0x08, 0x01); |
4795 | 76a66253 | j_mayer | /* mulhhwu - mulhhwu. */
|
4796 | a750fc0b | j_mayer | GEN_MAC_HANDLER(mulhhwu, 0x08, 0x00); |
4797 | 76a66253 | j_mayer | /* mullhw - mullhw. */
|
4798 | a750fc0b | j_mayer | GEN_MAC_HANDLER(mullhw, 0x08, 0x0D); |
4799 | 76a66253 | j_mayer | /* mullhwu - mullhwu. */
|
4800 | a750fc0b | j_mayer | GEN_MAC_HANDLER(mullhwu, 0x08, 0x0C); |
4801 | 76a66253 | j_mayer | |
4802 | 76a66253 | j_mayer | /* mfdcr */
|
4803 | 05332d70 | j_mayer | GEN_HANDLER(mfdcr, 0x1F, 0x03, 0x0A, 0x00000001, PPC_DCR) |
4804 | 76a66253 | j_mayer | { |
4805 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4806 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
4807 | 76a66253 | j_mayer | #else
|
4808 | 76a66253 | j_mayer | uint32_t dcrn = SPR(ctx->opcode); |
4809 | 76a66253 | j_mayer | |
4810 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4811 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
4812 | 76a66253 | j_mayer | return;
|
4813 | 76a66253 | j_mayer | } |
4814 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[0], dcrn);
|
4815 | a42bd6cc | j_mayer | gen_op_load_dcr(); |
4816 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4817 | 76a66253 | j_mayer | #endif
|
4818 | 76a66253 | j_mayer | } |
4819 | 76a66253 | j_mayer | |
4820 | 76a66253 | j_mayer | /* mtdcr */
|
4821 | 05332d70 | j_mayer | GEN_HANDLER(mtdcr, 0x1F, 0x03, 0x0E, 0x00000001, PPC_DCR) |
4822 | 76a66253 | j_mayer | { |
4823 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4824 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
4825 | 76a66253 | j_mayer | #else
|
4826 | 76a66253 | j_mayer | uint32_t dcrn = SPR(ctx->opcode); |
4827 | 76a66253 | j_mayer | |
4828 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4829 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
4830 | 76a66253 | j_mayer | return;
|
4831 | 76a66253 | j_mayer | } |
4832 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[0], dcrn);
|
4833 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
4834 | a42bd6cc | j_mayer | gen_op_store_dcr(); |
4835 | a42bd6cc | j_mayer | #endif
|
4836 | a42bd6cc | j_mayer | } |
4837 | a42bd6cc | j_mayer | |
4838 | a42bd6cc | j_mayer | /* mfdcrx */
|
4839 | 2662a059 | j_mayer | /* XXX: not implemented on 440 ? */
|
4840 | 05332d70 | j_mayer | GEN_HANDLER(mfdcrx, 0x1F, 0x03, 0x08, 0x00000000, PPC_DCRX) |
4841 | a42bd6cc | j_mayer | { |
4842 | a42bd6cc | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4843 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
4844 | a42bd6cc | j_mayer | #else
|
4845 | a42bd6cc | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4846 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
4847 | a42bd6cc | j_mayer | return;
|
4848 | a42bd6cc | j_mayer | } |
4849 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4850 | a42bd6cc | j_mayer | gen_op_load_dcr(); |
4851 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4852 | a750fc0b | j_mayer | /* Note: Rc update flag set leads to undefined state of Rc0 */
|
4853 | a42bd6cc | j_mayer | #endif
|
4854 | a42bd6cc | j_mayer | } |
4855 | a42bd6cc | j_mayer | |
4856 | a42bd6cc | j_mayer | /* mtdcrx */
|
4857 | 2662a059 | j_mayer | /* XXX: not implemented on 440 ? */
|
4858 | 05332d70 | j_mayer | GEN_HANDLER(mtdcrx, 0x1F, 0x03, 0x0C, 0x00000000, PPC_DCRX) |
4859 | a42bd6cc | j_mayer | { |
4860 | a42bd6cc | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4861 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
4862 | a42bd6cc | j_mayer | #else
|
4863 | a42bd6cc | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4864 | e1833e1f | j_mayer | GEN_EXCP_PRIVREG(ctx); |
4865 | a42bd6cc | j_mayer | return;
|
4866 | a42bd6cc | j_mayer | } |
4867 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4868 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
4869 | a42bd6cc | j_mayer | gen_op_store_dcr(); |
4870 | a750fc0b | j_mayer | /* Note: Rc update flag set leads to undefined state of Rc0 */
|
4871 | 76a66253 | j_mayer | #endif
|
4872 | 76a66253 | j_mayer | } |
4873 | 76a66253 | j_mayer | |
4874 | a750fc0b | j_mayer | /* mfdcrux (PPC 460) : user-mode access to DCR */
|
4875 | a750fc0b | j_mayer | GEN_HANDLER(mfdcrux, 0x1F, 0x03, 0x09, 0x00000000, PPC_DCRUX) |
4876 | a750fc0b | j_mayer | { |
4877 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4878 | a750fc0b | j_mayer | gen_op_load_dcr(); |
4879 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4880 | a750fc0b | j_mayer | /* Note: Rc update flag set leads to undefined state of Rc0 */
|
4881 | a750fc0b | j_mayer | } |
4882 | a750fc0b | j_mayer | |
4883 | a750fc0b | j_mayer | /* mtdcrux (PPC 460) : user-mode access to DCR */
|
4884 | a750fc0b | j_mayer | GEN_HANDLER(mtdcrux, 0x1F, 0x03, 0x0D, 0x00000000, PPC_DCRUX) |
4885 | a750fc0b | j_mayer | { |
4886 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
4887 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
4888 | a750fc0b | j_mayer | gen_op_store_dcr(); |
4889 | a750fc0b | j_mayer | /* Note: Rc update flag set leads to undefined state of Rc0 */
|
4890 | a750fc0b | j_mayer | } |
4891 | a750fc0b | j_mayer | |
4892 | 76a66253 | j_mayer | /* dccci */
|
4893 | 76a66253 | j_mayer | GEN_HANDLER(dccci, 0x1F, 0x06, 0x0E, 0x03E00001, PPC_4xx_COMMON) |
4894 | 76a66253 | j_mayer | { |
4895 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4896 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4897 | 76a66253 | j_mayer | #else
|
4898 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4899 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4900 | 76a66253 | j_mayer | return;
|
4901 | 76a66253 | j_mayer | } |
4902 | 76a66253 | j_mayer | /* interpreted as no-op */
|
4903 | 76a66253 | j_mayer | #endif
|
4904 | 76a66253 | j_mayer | } |
4905 | 76a66253 | j_mayer | |
4906 | 76a66253 | j_mayer | /* dcread */
|
4907 | 76a66253 | j_mayer | GEN_HANDLER(dcread, 0x1F, 0x06, 0x0F, 0x00000001, PPC_4xx_COMMON) |
4908 | 76a66253 | j_mayer | { |
4909 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4910 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4911 | 76a66253 | j_mayer | #else
|
4912 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4913 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4914 | 76a66253 | j_mayer | return;
|
4915 | 76a66253 | j_mayer | } |
4916 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
4917 | 76a66253 | j_mayer | op_ldst(lwz); |
4918 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
4919 | 76a66253 | j_mayer | #endif
|
4920 | 76a66253 | j_mayer | } |
4921 | 76a66253 | j_mayer | |
4922 | 76a66253 | j_mayer | /* icbt */
|
4923 | c7697e1f | j_mayer | GEN_HANDLER2(icbt_40x, "icbt", 0x1F, 0x06, 0x08, 0x03E00001, PPC_40x_ICBT) |
4924 | 76a66253 | j_mayer | { |
4925 | 76a66253 | j_mayer | /* interpreted as no-op */
|
4926 | 76a66253 | j_mayer | /* XXX: specification say this is treated as a load by the MMU
|
4927 | 76a66253 | j_mayer | * but does not generate any exception
|
4928 | 76a66253 | j_mayer | */
|
4929 | 76a66253 | j_mayer | } |
4930 | 76a66253 | j_mayer | |
4931 | 76a66253 | j_mayer | /* iccci */
|
4932 | 76a66253 | j_mayer | GEN_HANDLER(iccci, 0x1F, 0x06, 0x1E, 0x00000001, PPC_4xx_COMMON) |
4933 | 76a66253 | j_mayer | { |
4934 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4935 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4936 | 76a66253 | j_mayer | #else
|
4937 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4938 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4939 | 76a66253 | j_mayer | return;
|
4940 | 76a66253 | j_mayer | } |
4941 | 76a66253 | j_mayer | /* interpreted as no-op */
|
4942 | 76a66253 | j_mayer | #endif
|
4943 | 76a66253 | j_mayer | } |
4944 | 76a66253 | j_mayer | |
4945 | 76a66253 | j_mayer | /* icread */
|
4946 | 76a66253 | j_mayer | GEN_HANDLER(icread, 0x1F, 0x06, 0x1F, 0x03E00001, PPC_4xx_COMMON) |
4947 | 76a66253 | j_mayer | { |
4948 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4949 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4950 | 76a66253 | j_mayer | #else
|
4951 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4952 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4953 | 76a66253 | j_mayer | return;
|
4954 | 76a66253 | j_mayer | } |
4955 | 76a66253 | j_mayer | /* interpreted as no-op */
|
4956 | 76a66253 | j_mayer | #endif
|
4957 | 76a66253 | j_mayer | } |
4958 | 76a66253 | j_mayer | |
4959 | 76a66253 | j_mayer | /* rfci (supervisor only) */
|
4960 | c7697e1f | j_mayer | GEN_HANDLER2(rfci_40x, "rfci", 0x13, 0x13, 0x01, 0x03FF8001, PPC_40x_EXCP) |
4961 | a42bd6cc | j_mayer | { |
4962 | a42bd6cc | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4963 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4964 | a42bd6cc | j_mayer | #else
|
4965 | a42bd6cc | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4966 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4967 | a42bd6cc | j_mayer | return;
|
4968 | a42bd6cc | j_mayer | } |
4969 | a42bd6cc | j_mayer | /* Restore CPU state */
|
4970 | a42bd6cc | j_mayer | gen_op_40x_rfci(); |
4971 | e1833e1f | j_mayer | GEN_SYNC(ctx); |
4972 | a42bd6cc | j_mayer | #endif
|
4973 | a42bd6cc | j_mayer | } |
4974 | a42bd6cc | j_mayer | |
4975 | a42bd6cc | j_mayer | GEN_HANDLER(rfci, 0x13, 0x13, 0x01, 0x03FF8001, PPC_BOOKE) |
4976 | a42bd6cc | j_mayer | { |
4977 | a42bd6cc | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4978 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4979 | a42bd6cc | j_mayer | #else
|
4980 | a42bd6cc | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4981 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4982 | a42bd6cc | j_mayer | return;
|
4983 | a42bd6cc | j_mayer | } |
4984 | a42bd6cc | j_mayer | /* Restore CPU state */
|
4985 | a42bd6cc | j_mayer | gen_op_rfci(); |
4986 | e1833e1f | j_mayer | GEN_SYNC(ctx); |
4987 | a42bd6cc | j_mayer | #endif
|
4988 | a42bd6cc | j_mayer | } |
4989 | a42bd6cc | j_mayer | |
4990 | a42bd6cc | j_mayer | /* BookE specific */
|
4991 | 2662a059 | j_mayer | /* XXX: not implemented on 440 ? */
|
4992 | 05332d70 | j_mayer | GEN_HANDLER(rfdi, 0x13, 0x07, 0x01, 0x03FF8001, PPC_RFDI) |
4993 | 76a66253 | j_mayer | { |
4994 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
4995 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4996 | 76a66253 | j_mayer | #else
|
4997 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
4998 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
4999 | 76a66253 | j_mayer | return;
|
5000 | 76a66253 | j_mayer | } |
5001 | 76a66253 | j_mayer | /* Restore CPU state */
|
5002 | a42bd6cc | j_mayer | gen_op_rfdi(); |
5003 | e1833e1f | j_mayer | GEN_SYNC(ctx); |
5004 | 76a66253 | j_mayer | #endif
|
5005 | 76a66253 | j_mayer | } |
5006 | 76a66253 | j_mayer | |
5007 | 2662a059 | j_mayer | /* XXX: not implemented on 440 ? */
|
5008 | a750fc0b | j_mayer | GEN_HANDLER(rfmci, 0x13, 0x06, 0x01, 0x03FF8001, PPC_RFMCI) |
5009 | a42bd6cc | j_mayer | { |
5010 | a42bd6cc | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5011 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5012 | a42bd6cc | j_mayer | #else
|
5013 | a42bd6cc | j_mayer | if (unlikely(!ctx->supervisor)) {
|
5014 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5015 | a42bd6cc | j_mayer | return;
|
5016 | a42bd6cc | j_mayer | } |
5017 | a42bd6cc | j_mayer | /* Restore CPU state */
|
5018 | a42bd6cc | j_mayer | gen_op_rfmci(); |
5019 | e1833e1f | j_mayer | GEN_SYNC(ctx); |
5020 | a42bd6cc | j_mayer | #endif
|
5021 | a42bd6cc | j_mayer | } |
5022 | 5eb7995e | j_mayer | |
5023 | d9bce9d9 | j_mayer | /* TLB management - PowerPC 405 implementation */
|
5024 | 76a66253 | j_mayer | /* tlbre */
|
5025 | c7697e1f | j_mayer | GEN_HANDLER2(tlbre_40x, "tlbre", 0x1F, 0x12, 0x1D, 0x00000001, PPC_40x_TLB) |
5026 | 76a66253 | j_mayer | { |
5027 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5028 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5029 | 76a66253 | j_mayer | #else
|
5030 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
5031 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5032 | 76a66253 | j_mayer | return;
|
5033 | 76a66253 | j_mayer | } |
5034 | 76a66253 | j_mayer | switch (rB(ctx->opcode)) {
|
5035 | 76a66253 | j_mayer | case 0: |
5036 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
5037 | 76a66253 | j_mayer | gen_op_4xx_tlbre_hi(); |
5038 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
5039 | 76a66253 | j_mayer | break;
|
5040 | 76a66253 | j_mayer | case 1: |
5041 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
5042 | 76a66253 | j_mayer | gen_op_4xx_tlbre_lo(); |
5043 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
5044 | 76a66253 | j_mayer | break;
|
5045 | 76a66253 | j_mayer | default:
|
5046 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
5047 | 76a66253 | j_mayer | break;
|
5048 | 9a64fbe4 | bellard | } |
5049 | 76a66253 | j_mayer | #endif
|
5050 | 76a66253 | j_mayer | } |
5051 | 76a66253 | j_mayer | |
5052 | d9bce9d9 | j_mayer | /* tlbsx - tlbsx. */
|
5053 | c7697e1f | j_mayer | GEN_HANDLER2(tlbsx_40x, "tlbsx", 0x1F, 0x12, 0x1C, 0x00000000, PPC_40x_TLB) |
5054 | 76a66253 | j_mayer | { |
5055 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5056 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5057 | 76a66253 | j_mayer | #else
|
5058 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
5059 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5060 | 76a66253 | j_mayer | return;
|
5061 | 76a66253 | j_mayer | } |
5062 | 76a66253 | j_mayer | gen_addr_reg_index(ctx); |
5063 | daf4f96e | j_mayer | gen_op_4xx_tlbsx(); |
5064 | 76a66253 | j_mayer | if (Rc(ctx->opcode))
|
5065 | daf4f96e | j_mayer | gen_op_4xx_tlbsx_check(); |
5066 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
5067 | 76a66253 | j_mayer | #endif
|
5068 | 79aceca5 | bellard | } |
5069 | 79aceca5 | bellard | |
5070 | 76a66253 | j_mayer | /* tlbwe */
|
5071 | c7697e1f | j_mayer | GEN_HANDLER2(tlbwe_40x, "tlbwe", 0x1F, 0x12, 0x1E, 0x00000001, PPC_40x_TLB) |
5072 | 79aceca5 | bellard | { |
5073 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5074 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5075 | 76a66253 | j_mayer | #else
|
5076 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
5077 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5078 | 76a66253 | j_mayer | return;
|
5079 | 76a66253 | j_mayer | } |
5080 | 76a66253 | j_mayer | switch (rB(ctx->opcode)) {
|
5081 | 76a66253 | j_mayer | case 0: |
5082 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
5083 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
5084 | 76a66253 | j_mayer | gen_op_4xx_tlbwe_hi(); |
5085 | 76a66253 | j_mayer | break;
|
5086 | 76a66253 | j_mayer | case 1: |
5087 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
5088 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
5089 | 76a66253 | j_mayer | gen_op_4xx_tlbwe_lo(); |
5090 | 76a66253 | j_mayer | break;
|
5091 | 76a66253 | j_mayer | default:
|
5092 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
5093 | 76a66253 | j_mayer | break;
|
5094 | 9a64fbe4 | bellard | } |
5095 | 76a66253 | j_mayer | #endif
|
5096 | 76a66253 | j_mayer | } |
5097 | 76a66253 | j_mayer | |
5098 | a4bb6c3e | j_mayer | /* TLB management - PowerPC 440 implementation */
|
5099 | 5eb7995e | j_mayer | /* tlbre */
|
5100 | c7697e1f | j_mayer | GEN_HANDLER2(tlbre_440, "tlbre", 0x1F, 0x12, 0x1D, 0x00000001, PPC_BOOKE) |
5101 | 5eb7995e | j_mayer | { |
5102 | 5eb7995e | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5103 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5104 | 5eb7995e | j_mayer | #else
|
5105 | 5eb7995e | j_mayer | if (unlikely(!ctx->supervisor)) {
|
5106 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5107 | 5eb7995e | j_mayer | return;
|
5108 | 5eb7995e | j_mayer | } |
5109 | 5eb7995e | j_mayer | switch (rB(ctx->opcode)) {
|
5110 | 5eb7995e | j_mayer | case 0: |
5111 | 5eb7995e | j_mayer | case 1: |
5112 | 5eb7995e | j_mayer | case 2: |
5113 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
5114 | a4bb6c3e | j_mayer | gen_op_440_tlbre(rB(ctx->opcode)); |
5115 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
5116 | 5eb7995e | j_mayer | break;
|
5117 | 5eb7995e | j_mayer | default:
|
5118 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
5119 | 5eb7995e | j_mayer | break;
|
5120 | 5eb7995e | j_mayer | } |
5121 | 5eb7995e | j_mayer | #endif
|
5122 | 5eb7995e | j_mayer | } |
5123 | 5eb7995e | j_mayer | |
5124 | 5eb7995e | j_mayer | /* tlbsx - tlbsx. */
|
5125 | c7697e1f | j_mayer | GEN_HANDLER2(tlbsx_440, "tlbsx", 0x1F, 0x12, 0x1C, 0x00000000, PPC_BOOKE) |
5126 | 5eb7995e | j_mayer | { |
5127 | 5eb7995e | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5128 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5129 | 5eb7995e | j_mayer | #else
|
5130 | 5eb7995e | j_mayer | if (unlikely(!ctx->supervisor)) {
|
5131 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5132 | 5eb7995e | j_mayer | return;
|
5133 | 5eb7995e | j_mayer | } |
5134 | 5eb7995e | j_mayer | gen_addr_reg_index(ctx); |
5135 | daf4f96e | j_mayer | gen_op_440_tlbsx(); |
5136 | 5eb7995e | j_mayer | if (Rc(ctx->opcode))
|
5137 | daf4f96e | j_mayer | gen_op_4xx_tlbsx_check(); |
5138 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
5139 | 5eb7995e | j_mayer | #endif
|
5140 | 5eb7995e | j_mayer | } |
5141 | 5eb7995e | j_mayer | |
5142 | 5eb7995e | j_mayer | /* tlbwe */
|
5143 | c7697e1f | j_mayer | GEN_HANDLER2(tlbwe_440, "tlbwe", 0x1F, 0x12, 0x1E, 0x00000001, PPC_BOOKE) |
5144 | 5eb7995e | j_mayer | { |
5145 | 5eb7995e | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5146 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5147 | 5eb7995e | j_mayer | #else
|
5148 | 5eb7995e | j_mayer | if (unlikely(!ctx->supervisor)) {
|
5149 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5150 | 5eb7995e | j_mayer | return;
|
5151 | 5eb7995e | j_mayer | } |
5152 | 5eb7995e | j_mayer | switch (rB(ctx->opcode)) {
|
5153 | 5eb7995e | j_mayer | case 0: |
5154 | 5eb7995e | j_mayer | case 1: |
5155 | 5eb7995e | j_mayer | case 2: |
5156 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
5157 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);
|
5158 | a4bb6c3e | j_mayer | gen_op_440_tlbwe(rB(ctx->opcode)); |
5159 | 5eb7995e | j_mayer | break;
|
5160 | 5eb7995e | j_mayer | default:
|
5161 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
5162 | 5eb7995e | j_mayer | break;
|
5163 | 5eb7995e | j_mayer | } |
5164 | 5eb7995e | j_mayer | #endif
|
5165 | 5eb7995e | j_mayer | } |
5166 | 5eb7995e | j_mayer | |
5167 | 76a66253 | j_mayer | /* wrtee */
|
5168 | 05332d70 | j_mayer | GEN_HANDLER(wrtee, 0x1F, 0x03, 0x04, 0x000FFC01, PPC_WRTEE) |
5169 | 76a66253 | j_mayer | { |
5170 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5171 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5172 | 76a66253 | j_mayer | #else
|
5173 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
5174 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5175 | 76a66253 | j_mayer | return;
|
5176 | 76a66253 | j_mayer | } |
5177 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rD(ctx->opcode)]);
|
5178 | a42bd6cc | j_mayer | gen_op_wrte(); |
5179 | dee96f6c | j_mayer | /* Stop translation to have a chance to raise an exception
|
5180 | dee96f6c | j_mayer | * if we just set msr_ee to 1
|
5181 | dee96f6c | j_mayer | */
|
5182 | e1833e1f | j_mayer | GEN_STOP(ctx); |
5183 | 76a66253 | j_mayer | #endif
|
5184 | 76a66253 | j_mayer | } |
5185 | 76a66253 | j_mayer | |
5186 | 76a66253 | j_mayer | /* wrteei */
|
5187 | 05332d70 | j_mayer | GEN_HANDLER(wrteei, 0x1F, 0x03, 0x05, 0x000EFC01, PPC_WRTEE) |
5188 | 76a66253 | j_mayer | { |
5189 | 76a66253 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5190 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5191 | 76a66253 | j_mayer | #else
|
5192 | 76a66253 | j_mayer | if (unlikely(!ctx->supervisor)) {
|
5193 | e1833e1f | j_mayer | GEN_EXCP_PRIVOPC(ctx); |
5194 | 76a66253 | j_mayer | return;
|
5195 | 76a66253 | j_mayer | } |
5196 | 86c581dc | aurel32 | tcg_gen_movi_tl(cpu_T[0], ctx->opcode & 0x00010000); |
5197 | a42bd6cc | j_mayer | gen_op_wrte(); |
5198 | dee96f6c | j_mayer | /* Stop translation to have a chance to raise an exception
|
5199 | dee96f6c | j_mayer | * if we just set msr_ee to 1
|
5200 | dee96f6c | j_mayer | */
|
5201 | e1833e1f | j_mayer | GEN_STOP(ctx); |
5202 | 76a66253 | j_mayer | #endif
|
5203 | 76a66253 | j_mayer | } |
5204 | 76a66253 | j_mayer | |
5205 | 08e46e54 | j_mayer | /* PowerPC 440 specific instructions */
|
5206 | 76a66253 | j_mayer | /* dlmzb */
|
5207 | 76a66253 | j_mayer | GEN_HANDLER(dlmzb, 0x1F, 0x0E, 0x02, 0x00000000, PPC_440_SPEC) |
5208 | 76a66253 | j_mayer | { |
5209 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]);
|
5210 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
5211 | 76a66253 | j_mayer | gen_op_440_dlmzb(); |
5212 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]);
|
5213 | 76a66253 | j_mayer | gen_op_store_xer_bc(); |
5214 | 76a66253 | j_mayer | if (Rc(ctx->opcode)) {
|
5215 | 76a66253 | j_mayer | gen_op_440_dlmzb_update_Rc(); |
5216 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[0], cpu_T[0], 0xf); |
5217 | 76a66253 | j_mayer | } |
5218 | 76a66253 | j_mayer | } |
5219 | 76a66253 | j_mayer | |
5220 | 76a66253 | j_mayer | /* mbar replaces eieio on 440 */
|
5221 | 76a66253 | j_mayer | GEN_HANDLER(mbar, 0x1F, 0x16, 0x13, 0x001FF801, PPC_BOOKE) |
5222 | 76a66253 | j_mayer | { |
5223 | 76a66253 | j_mayer | /* interpreted as no-op */
|
5224 | 76a66253 | j_mayer | } |
5225 | 76a66253 | j_mayer | |
5226 | 76a66253 | j_mayer | /* msync replaces sync on 440 */
|
5227 | 0db1b20e | j_mayer | GEN_HANDLER(msync, 0x1F, 0x16, 0x12, 0x03FFF801, PPC_BOOKE) |
5228 | 76a66253 | j_mayer | { |
5229 | 76a66253 | j_mayer | /* interpreted as no-op */
|
5230 | 76a66253 | j_mayer | } |
5231 | 76a66253 | j_mayer | |
5232 | 76a66253 | j_mayer | /* icbt */
|
5233 | c7697e1f | j_mayer | GEN_HANDLER2(icbt_440, "icbt", 0x1F, 0x16, 0x00, 0x03E00001, PPC_BOOKE) |
5234 | 76a66253 | j_mayer | { |
5235 | 76a66253 | j_mayer | /* interpreted as no-op */
|
5236 | 76a66253 | j_mayer | /* XXX: specification say this is treated as a load by the MMU
|
5237 | 76a66253 | j_mayer | * but does not generate any exception
|
5238 | 76a66253 | j_mayer | */
|
5239 | 79aceca5 | bellard | } |
5240 | 79aceca5 | bellard | |
5241 | a9d9eb8f | j_mayer | /*** Altivec vector extension ***/
|
5242 | a9d9eb8f | j_mayer | /* Altivec registers moves */
|
5243 | a9d9eb8f | j_mayer | |
5244 | 1d542695 | aurel32 | static always_inline void gen_load_avr(int t, int reg) { |
5245 | 1d542695 | aurel32 | tcg_gen_mov_i64(cpu_AVRh[t], cpu_avrh[reg]); |
5246 | 1d542695 | aurel32 | tcg_gen_mov_i64(cpu_AVRl[t], cpu_avrl[reg]); |
5247 | 1d542695 | aurel32 | } |
5248 | 1d542695 | aurel32 | |
5249 | 1d542695 | aurel32 | static always_inline void gen_store_avr(int reg, int t) { |
5250 | 1d542695 | aurel32 | tcg_gen_mov_i64(cpu_avrh[reg], cpu_AVRh[t]); |
5251 | 1d542695 | aurel32 | tcg_gen_mov_i64(cpu_avrl[reg], cpu_AVRl[t]); |
5252 | 1d542695 | aurel32 | } |
5253 | a9d9eb8f | j_mayer | |
5254 | a9d9eb8f | j_mayer | #define op_vr_ldst(name) (*gen_op_##name[ctx->mem_idx])() |
5255 | a9d9eb8f | j_mayer | #define OP_VR_LD_TABLE(name) \
|
5256 | 7863667f | j_mayer | static GenOpFunc *gen_op_vr_l##name[NB_MEM_FUNCS] = { \ |
5257 | 7863667f | j_mayer | GEN_MEM_FUNCS(vr_l##name), \ |
5258 | a9d9eb8f | j_mayer | }; |
5259 | a9d9eb8f | j_mayer | #define OP_VR_ST_TABLE(name) \
|
5260 | 7863667f | j_mayer | static GenOpFunc *gen_op_vr_st##name[NB_MEM_FUNCS] = { \ |
5261 | 7863667f | j_mayer | GEN_MEM_FUNCS(vr_st##name), \ |
5262 | a9d9eb8f | j_mayer | }; |
5263 | a9d9eb8f | j_mayer | |
5264 | a9d9eb8f | j_mayer | #define GEN_VR_LDX(name, opc2, opc3) \
|
5265 | a9d9eb8f | j_mayer | GEN_HANDLER(l##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC) \ |
5266 | a9d9eb8f | j_mayer | { \ |
5267 | a9d9eb8f | j_mayer | if (unlikely(!ctx->altivec_enabled)) { \
|
5268 | a9d9eb8f | j_mayer | GEN_EXCP_NO_VR(ctx); \ |
5269 | a9d9eb8f | j_mayer | return; \
|
5270 | a9d9eb8f | j_mayer | } \ |
5271 | a9d9eb8f | j_mayer | gen_addr_reg_index(ctx); \ |
5272 | a9d9eb8f | j_mayer | op_vr_ldst(vr_l##name); \ |
5273 | 1d542695 | aurel32 | gen_store_avr(rD(ctx->opcode), 0); \
|
5274 | a9d9eb8f | j_mayer | } |
5275 | a9d9eb8f | j_mayer | |
5276 | a9d9eb8f | j_mayer | #define GEN_VR_STX(name, opc2, opc3) \
|
5277 | a9d9eb8f | j_mayer | GEN_HANDLER(st##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC) \ |
5278 | a9d9eb8f | j_mayer | { \ |
5279 | a9d9eb8f | j_mayer | if (unlikely(!ctx->altivec_enabled)) { \
|
5280 | a9d9eb8f | j_mayer | GEN_EXCP_NO_VR(ctx); \ |
5281 | a9d9eb8f | j_mayer | return; \
|
5282 | a9d9eb8f | j_mayer | } \ |
5283 | a9d9eb8f | j_mayer | gen_addr_reg_index(ctx); \ |
5284 | 1d542695 | aurel32 | gen_load_avr(0, rS(ctx->opcode)); \
|
5285 | a9d9eb8f | j_mayer | op_vr_ldst(vr_st##name); \ |
5286 | a9d9eb8f | j_mayer | } |
5287 | a9d9eb8f | j_mayer | |
5288 | a9d9eb8f | j_mayer | OP_VR_LD_TABLE(vx); |
5289 | a9d9eb8f | j_mayer | GEN_VR_LDX(vx, 0x07, 0x03); |
5290 | a9d9eb8f | j_mayer | /* As we don't emulate the cache, lvxl is stricly equivalent to lvx */
|
5291 | a9d9eb8f | j_mayer | #define gen_op_vr_lvxl gen_op_vr_lvx
|
5292 | a9d9eb8f | j_mayer | GEN_VR_LDX(vxl, 0x07, 0x0B); |
5293 | a9d9eb8f | j_mayer | |
5294 | a9d9eb8f | j_mayer | OP_VR_ST_TABLE(vx); |
5295 | a9d9eb8f | j_mayer | GEN_VR_STX(vx, 0x07, 0x07); |
5296 | a9d9eb8f | j_mayer | /* As we don't emulate the cache, stvxl is stricly equivalent to stvx */
|
5297 | a9d9eb8f | j_mayer | #define gen_op_vr_stvxl gen_op_vr_stvx
|
5298 | a9d9eb8f | j_mayer | GEN_VR_STX(vxl, 0x07, 0x0F); |
5299 | a9d9eb8f | j_mayer | |
5300 | 0487d6a8 | j_mayer | /*** SPE extension ***/
|
5301 | 0487d6a8 | j_mayer | /* Register moves */
|
5302 | 3cd7d1dd | j_mayer | |
5303 | f78fb44e | aurel32 | static always_inline void gen_load_gpr64(TCGv t, int reg) { |
5304 | f78fb44e | aurel32 | #if defined(TARGET_PPC64)
|
5305 | f78fb44e | aurel32 | tcg_gen_mov_i64(t, cpu_gpr[reg]); |
5306 | f78fb44e | aurel32 | #else
|
5307 | f78fb44e | aurel32 | tcg_gen_extu_i32_i64(t, cpu_gprh[reg]); |
5308 | f78fb44e | aurel32 | tcg_gen_shli_i64(t, t, 32);
|
5309 | f78fb44e | aurel32 | TCGv tmp = tcg_temp_local_new(TCG_TYPE_I64); |
5310 | f78fb44e | aurel32 | tcg_gen_extu_i32_i64(tmp, cpu_gpr[reg]); |
5311 | f78fb44e | aurel32 | tcg_gen_or_i64(t, t, tmp); |
5312 | f78fb44e | aurel32 | tcg_temp_free(tmp); |
5313 | 3cd7d1dd | j_mayer | #endif
|
5314 | f78fb44e | aurel32 | } |
5315 | 3cd7d1dd | j_mayer | |
5316 | f78fb44e | aurel32 | static always_inline void gen_store_gpr64(int reg, TCGv t) { |
5317 | f78fb44e | aurel32 | #if defined(TARGET_PPC64)
|
5318 | f78fb44e | aurel32 | tcg_gen_mov_i64(cpu_gpr[reg], t); |
5319 | f78fb44e | aurel32 | #else
|
5320 | f78fb44e | aurel32 | tcg_gen_trunc_i64_i32(cpu_gpr[reg], t); |
5321 | f78fb44e | aurel32 | TCGv tmp = tcg_temp_local_new(TCG_TYPE_I64); |
5322 | f78fb44e | aurel32 | tcg_gen_shri_i64(tmp, t, 32);
|
5323 | f78fb44e | aurel32 | tcg_gen_trunc_i64_i32(cpu_gprh[reg], tmp); |
5324 | f78fb44e | aurel32 | tcg_temp_free(tmp); |
5325 | 3cd7d1dd | j_mayer | #endif
|
5326 | f78fb44e | aurel32 | } |
5327 | 3cd7d1dd | j_mayer | |
5328 | 0487d6a8 | j_mayer | #define GEN_SPE(name0, name1, opc2, opc3, inval, type) \
|
5329 | 0487d6a8 | j_mayer | GEN_HANDLER(name0##_##name1, 0x04, opc2, opc3, inval, type) \ |
5330 | 0487d6a8 | j_mayer | { \ |
5331 | 0487d6a8 | j_mayer | if (Rc(ctx->opcode)) \
|
5332 | 0487d6a8 | j_mayer | gen_##name1(ctx); \ |
5333 | 0487d6a8 | j_mayer | else \
|
5334 | 0487d6a8 | j_mayer | gen_##name0(ctx); \ |
5335 | 0487d6a8 | j_mayer | } |
5336 | 0487d6a8 | j_mayer | |
5337 | 0487d6a8 | j_mayer | /* Handler for undefined SPE opcodes */
|
5338 | b068d6a7 | j_mayer | static always_inline void gen_speundef (DisasContext *ctx) |
5339 | 0487d6a8 | j_mayer | { |
5340 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctx); |
5341 | 0487d6a8 | j_mayer | } |
5342 | 0487d6a8 | j_mayer | |
5343 | 0487d6a8 | j_mayer | /* SPE load and stores */
|
5344 | b068d6a7 | j_mayer | static always_inline void gen_addr_spe_imm_index (DisasContext *ctx, int sh) |
5345 | 0487d6a8 | j_mayer | { |
5346 | 0487d6a8 | j_mayer | target_long simm = rB(ctx->opcode); |
5347 | 0487d6a8 | j_mayer | |
5348 | 0487d6a8 | j_mayer | if (rA(ctx->opcode) == 0) { |
5349 | 02f4f6c2 | aurel32 | tcg_gen_movi_tl(cpu_T[0], simm << sh);
|
5350 | 0487d6a8 | j_mayer | } else {
|
5351 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
5352 | 0487d6a8 | j_mayer | if (likely(simm != 0)) |
5353 | 39dd32ee | aurel32 | tcg_gen_addi_tl(cpu_T[0], cpu_T[0], simm << sh); |
5354 | 0487d6a8 | j_mayer | } |
5355 | 0487d6a8 | j_mayer | } |
5356 | 0487d6a8 | j_mayer | |
5357 | 0487d6a8 | j_mayer | #define op_spe_ldst(name) (*gen_op_##name[ctx->mem_idx])() |
5358 | 0487d6a8 | j_mayer | #define OP_SPE_LD_TABLE(name) \
|
5359 | 7863667f | j_mayer | static GenOpFunc *gen_op_spe_l##name[NB_MEM_FUNCS] = { \ |
5360 | 7863667f | j_mayer | GEN_MEM_FUNCS(spe_l##name), \ |
5361 | 0487d6a8 | j_mayer | }; |
5362 | 0487d6a8 | j_mayer | #define OP_SPE_ST_TABLE(name) \
|
5363 | 7863667f | j_mayer | static GenOpFunc *gen_op_spe_st##name[NB_MEM_FUNCS] = { \ |
5364 | 7863667f | j_mayer | GEN_MEM_FUNCS(spe_st##name), \ |
5365 | 2857068e | j_mayer | }; |
5366 | 0487d6a8 | j_mayer | |
5367 | 0487d6a8 | j_mayer | #define GEN_SPE_LD(name, sh) \
|
5368 | b068d6a7 | j_mayer | static always_inline void gen_evl##name (DisasContext *ctx) \ |
5369 | 0487d6a8 | j_mayer | { \ |
5370 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) { \
|
5371 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); \ |
5372 | 0487d6a8 | j_mayer | return; \
|
5373 | 0487d6a8 | j_mayer | } \ |
5374 | 0487d6a8 | j_mayer | gen_addr_spe_imm_index(ctx, sh); \ |
5375 | 0487d6a8 | j_mayer | op_spe_ldst(spe_l##name); \ |
5376 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[1]); \
|
5377 | 0487d6a8 | j_mayer | } |
5378 | 0487d6a8 | j_mayer | |
5379 | 0487d6a8 | j_mayer | #define GEN_SPE_LDX(name) \
|
5380 | b068d6a7 | j_mayer | static always_inline void gen_evl##name##x (DisasContext *ctx) \ |
5381 | 0487d6a8 | j_mayer | { \ |
5382 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) { \
|
5383 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); \ |
5384 | 0487d6a8 | j_mayer | return; \
|
5385 | 0487d6a8 | j_mayer | } \ |
5386 | 0487d6a8 | j_mayer | gen_addr_reg_index(ctx); \ |
5387 | 0487d6a8 | j_mayer | op_spe_ldst(spe_l##name); \ |
5388 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[1]); \
|
5389 | 0487d6a8 | j_mayer | } |
5390 | 0487d6a8 | j_mayer | |
5391 | 0487d6a8 | j_mayer | #define GEN_SPEOP_LD(name, sh) \
|
5392 | 0487d6a8 | j_mayer | OP_SPE_LD_TABLE(name); \ |
5393 | 0487d6a8 | j_mayer | GEN_SPE_LD(name, sh); \ |
5394 | 0487d6a8 | j_mayer | GEN_SPE_LDX(name) |
5395 | 0487d6a8 | j_mayer | |
5396 | 0487d6a8 | j_mayer | #define GEN_SPE_ST(name, sh) \
|
5397 | b068d6a7 | j_mayer | static always_inline void gen_evst##name (DisasContext *ctx) \ |
5398 | 0487d6a8 | j_mayer | { \ |
5399 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) { \
|
5400 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); \ |
5401 | 0487d6a8 | j_mayer | return; \
|
5402 | 0487d6a8 | j_mayer | } \ |
5403 | 0487d6a8 | j_mayer | gen_addr_spe_imm_index(ctx, sh); \ |
5404 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[1], rS(ctx->opcode)); \
|
5405 | 0487d6a8 | j_mayer | op_spe_ldst(spe_st##name); \ |
5406 | 0487d6a8 | j_mayer | } |
5407 | 0487d6a8 | j_mayer | |
5408 | 0487d6a8 | j_mayer | #define GEN_SPE_STX(name) \
|
5409 | b068d6a7 | j_mayer | static always_inline void gen_evst##name##x (DisasContext *ctx) \ |
5410 | 0487d6a8 | j_mayer | { \ |
5411 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) { \
|
5412 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); \ |
5413 | 0487d6a8 | j_mayer | return; \
|
5414 | 0487d6a8 | j_mayer | } \ |
5415 | 0487d6a8 | j_mayer | gen_addr_reg_index(ctx); \ |
5416 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[1], rS(ctx->opcode)); \
|
5417 | 0487d6a8 | j_mayer | op_spe_ldst(spe_st##name); \ |
5418 | 0487d6a8 | j_mayer | } |
5419 | 0487d6a8 | j_mayer | |
5420 | 0487d6a8 | j_mayer | #define GEN_SPEOP_ST(name, sh) \
|
5421 | 0487d6a8 | j_mayer | OP_SPE_ST_TABLE(name); \ |
5422 | 0487d6a8 | j_mayer | GEN_SPE_ST(name, sh); \ |
5423 | 0487d6a8 | j_mayer | GEN_SPE_STX(name) |
5424 | 0487d6a8 | j_mayer | |
5425 | 0487d6a8 | j_mayer | #define GEN_SPEOP_LDST(name, sh) \
|
5426 | 0487d6a8 | j_mayer | GEN_SPEOP_LD(name, sh); \ |
5427 | 0487d6a8 | j_mayer | GEN_SPEOP_ST(name, sh) |
5428 | 0487d6a8 | j_mayer | |
5429 | 0487d6a8 | j_mayer | /* SPE arithmetic and logic */
|
5430 | 0487d6a8 | j_mayer | #define GEN_SPEOP_ARITH2(name) \
|
5431 | b068d6a7 | j_mayer | static always_inline void gen_##name (DisasContext *ctx) \ |
5432 | 0487d6a8 | j_mayer | { \ |
5433 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) { \
|
5434 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); \ |
5435 | 0487d6a8 | j_mayer | return; \
|
5436 | 0487d6a8 | j_mayer | } \ |
5437 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[0], rA(ctx->opcode)); \
|
5438 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[1], rB(ctx->opcode)); \
|
5439 | 0487d6a8 | j_mayer | gen_op_##name(); \ |
5440 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[0]); \
|
5441 | 0487d6a8 | j_mayer | } |
5442 | 0487d6a8 | j_mayer | |
5443 | 0487d6a8 | j_mayer | #define GEN_SPEOP_ARITH1(name) \
|
5444 | b068d6a7 | j_mayer | static always_inline void gen_##name (DisasContext *ctx) \ |
5445 | 0487d6a8 | j_mayer | { \ |
5446 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) { \
|
5447 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); \ |
5448 | 0487d6a8 | j_mayer | return; \
|
5449 | 0487d6a8 | j_mayer | } \ |
5450 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[0], rA(ctx->opcode)); \
|
5451 | 0487d6a8 | j_mayer | gen_op_##name(); \ |
5452 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[0]); \
|
5453 | 0487d6a8 | j_mayer | } |
5454 | 0487d6a8 | j_mayer | |
5455 | 0487d6a8 | j_mayer | #define GEN_SPEOP_COMP(name) \
|
5456 | b068d6a7 | j_mayer | static always_inline void gen_##name (DisasContext *ctx) \ |
5457 | 0487d6a8 | j_mayer | { \ |
5458 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) { \
|
5459 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); \ |
5460 | 0487d6a8 | j_mayer | return; \
|
5461 | 0487d6a8 | j_mayer | } \ |
5462 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[0], rA(ctx->opcode)); \
|
5463 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[1], rB(ctx->opcode)); \
|
5464 | 0487d6a8 | j_mayer | gen_op_##name(); \ |
5465 | 47e4661c | aurel32 | tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_T[0], 0xf); \ |
5466 | 0487d6a8 | j_mayer | } |
5467 | 0487d6a8 | j_mayer | |
5468 | 0487d6a8 | j_mayer | /* Logical */
|
5469 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evand); |
5470 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evandc); |
5471 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evxor); |
5472 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evor); |
5473 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evnor); |
5474 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(eveqv); |
5475 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evorc); |
5476 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evnand); |
5477 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evsrwu); |
5478 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evsrws); |
5479 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evslw); |
5480 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evrlw); |
5481 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evmergehi); |
5482 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evmergelo); |
5483 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evmergehilo); |
5484 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evmergelohi); |
5485 | 0487d6a8 | j_mayer | |
5486 | 0487d6a8 | j_mayer | /* Arithmetic */
|
5487 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evaddw); |
5488 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evsubfw); |
5489 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evabs); |
5490 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evneg); |
5491 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evextsb); |
5492 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evextsh); |
5493 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evrndw); |
5494 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evcntlzw); |
5495 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evcntlsw); |
5496 | b068d6a7 | j_mayer | static always_inline void gen_brinc (DisasContext *ctx) |
5497 | 0487d6a8 | j_mayer | { |
5498 | 0487d6a8 | j_mayer | /* Note: brinc is usable even if SPE is disabled */
|
5499 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);
|
5500 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]);
|
5501 | 0487d6a8 | j_mayer | gen_op_brinc(); |
5502 | f78fb44e | aurel32 | tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]);
|
5503 | 0487d6a8 | j_mayer | } |
5504 | 0487d6a8 | j_mayer | |
5505 | 0487d6a8 | j_mayer | #define GEN_SPEOP_ARITH_IMM2(name) \
|
5506 | b068d6a7 | j_mayer | static always_inline void gen_##name##i (DisasContext *ctx) \ |
5507 | 0487d6a8 | j_mayer | { \ |
5508 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) { \
|
5509 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); \ |
5510 | 0487d6a8 | j_mayer | return; \
|
5511 | 0487d6a8 | j_mayer | } \ |
5512 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[0], rB(ctx->opcode)); \
|
5513 | 0487d6a8 | j_mayer | gen_op_splatwi_T1_64(rA(ctx->opcode)); \ |
5514 | 0487d6a8 | j_mayer | gen_op_##name(); \ |
5515 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[0]); \
|
5516 | 0487d6a8 | j_mayer | } |
5517 | 0487d6a8 | j_mayer | |
5518 | 0487d6a8 | j_mayer | #define GEN_SPEOP_LOGIC_IMM2(name) \
|
5519 | b068d6a7 | j_mayer | static always_inline void gen_##name##i (DisasContext *ctx) \ |
5520 | 0487d6a8 | j_mayer | { \ |
5521 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) { \
|
5522 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); \ |
5523 | 0487d6a8 | j_mayer | return; \
|
5524 | 0487d6a8 | j_mayer | } \ |
5525 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[0], rA(ctx->opcode)); \
|
5526 | 0487d6a8 | j_mayer | gen_op_splatwi_T1_64(rB(ctx->opcode)); \ |
5527 | 0487d6a8 | j_mayer | gen_op_##name(); \ |
5528 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[0]); \
|
5529 | 0487d6a8 | j_mayer | } |
5530 | 0487d6a8 | j_mayer | |
5531 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH_IMM2(evaddw); |
5532 | 0487d6a8 | j_mayer | #define gen_evaddiw gen_evaddwi
|
5533 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH_IMM2(evsubfw); |
5534 | 0487d6a8 | j_mayer | #define gen_evsubifw gen_evsubfwi
|
5535 | 0487d6a8 | j_mayer | GEN_SPEOP_LOGIC_IMM2(evslw); |
5536 | 0487d6a8 | j_mayer | GEN_SPEOP_LOGIC_IMM2(evsrwu); |
5537 | 0487d6a8 | j_mayer | #define gen_evsrwis gen_evsrwsi
|
5538 | 0487d6a8 | j_mayer | GEN_SPEOP_LOGIC_IMM2(evsrws); |
5539 | 0487d6a8 | j_mayer | #define gen_evsrwiu gen_evsrwui
|
5540 | 0487d6a8 | j_mayer | GEN_SPEOP_LOGIC_IMM2(evrlw); |
5541 | 0487d6a8 | j_mayer | |
5542 | b068d6a7 | j_mayer | static always_inline void gen_evsplati (DisasContext *ctx) |
5543 | 0487d6a8 | j_mayer | { |
5544 | 0487d6a8 | j_mayer | int32_t imm = (int32_t)(rA(ctx->opcode) << 27) >> 27; |
5545 | 0487d6a8 | j_mayer | |
5546 | 0487d6a8 | j_mayer | gen_op_splatwi_T0_64(imm); |
5547 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[0]);
|
5548 | 0487d6a8 | j_mayer | } |
5549 | 0487d6a8 | j_mayer | |
5550 | b068d6a7 | j_mayer | static always_inline void gen_evsplatfi (DisasContext *ctx) |
5551 | 0487d6a8 | j_mayer | { |
5552 | 0487d6a8 | j_mayer | uint32_t imm = rA(ctx->opcode) << 27;
|
5553 | 0487d6a8 | j_mayer | |
5554 | 0487d6a8 | j_mayer | gen_op_splatwi_T0_64(imm); |
5555 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[0]);
|
5556 | 0487d6a8 | j_mayer | } |
5557 | 0487d6a8 | j_mayer | |
5558 | 0487d6a8 | j_mayer | /* Comparison */
|
5559 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evcmpgtu); |
5560 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evcmpgts); |
5561 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evcmpltu); |
5562 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evcmplts); |
5563 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evcmpeq); |
5564 | 0487d6a8 | j_mayer | |
5565 | 0487d6a8 | j_mayer | GEN_SPE(evaddw, speundef, 0x00, 0x08, 0x00000000, PPC_SPE); //// |
5566 | 0487d6a8 | j_mayer | GEN_SPE(evaddiw, speundef, 0x01, 0x08, 0x00000000, PPC_SPE); |
5567 | 0487d6a8 | j_mayer | GEN_SPE(evsubfw, speundef, 0x02, 0x08, 0x00000000, PPC_SPE); //// |
5568 | 0487d6a8 | j_mayer | GEN_SPE(evsubifw, speundef, 0x03, 0x08, 0x00000000, PPC_SPE); |
5569 | 0487d6a8 | j_mayer | GEN_SPE(evabs, evneg, 0x04, 0x08, 0x0000F800, PPC_SPE); //// |
5570 | 0487d6a8 | j_mayer | GEN_SPE(evextsb, evextsh, 0x05, 0x08, 0x0000F800, PPC_SPE); //// |
5571 | 0487d6a8 | j_mayer | GEN_SPE(evrndw, evcntlzw, 0x06, 0x08, 0x0000F800, PPC_SPE); //// |
5572 | 0487d6a8 | j_mayer | GEN_SPE(evcntlsw, brinc, 0x07, 0x08, 0x00000000, PPC_SPE); // |
5573 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evand, 0x08, 0x08, 0x00000000, PPC_SPE); //// |
5574 | 0487d6a8 | j_mayer | GEN_SPE(evandc, speundef, 0x09, 0x08, 0x00000000, PPC_SPE); //// |
5575 | 0487d6a8 | j_mayer | GEN_SPE(evxor, evor, 0x0B, 0x08, 0x00000000, PPC_SPE); //// |
5576 | 0487d6a8 | j_mayer | GEN_SPE(evnor, eveqv, 0x0C, 0x08, 0x00000000, PPC_SPE); //// |
5577 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evorc, 0x0D, 0x08, 0x00000000, PPC_SPE); //// |
5578 | 0487d6a8 | j_mayer | GEN_SPE(evnand, speundef, 0x0F, 0x08, 0x00000000, PPC_SPE); //// |
5579 | 0487d6a8 | j_mayer | GEN_SPE(evsrwu, evsrws, 0x10, 0x08, 0x00000000, PPC_SPE); //// |
5580 | 0487d6a8 | j_mayer | GEN_SPE(evsrwiu, evsrwis, 0x11, 0x08, 0x00000000, PPC_SPE); |
5581 | 0487d6a8 | j_mayer | GEN_SPE(evslw, speundef, 0x12, 0x08, 0x00000000, PPC_SPE); //// |
5582 | 0487d6a8 | j_mayer | GEN_SPE(evslwi, speundef, 0x13, 0x08, 0x00000000, PPC_SPE); |
5583 | 0487d6a8 | j_mayer | GEN_SPE(evrlw, evsplati, 0x14, 0x08, 0x00000000, PPC_SPE); // |
5584 | 0487d6a8 | j_mayer | GEN_SPE(evrlwi, evsplatfi, 0x15, 0x08, 0x00000000, PPC_SPE); |
5585 | 0487d6a8 | j_mayer | GEN_SPE(evmergehi, evmergelo, 0x16, 0x08, 0x00000000, PPC_SPE); //// |
5586 | 0487d6a8 | j_mayer | GEN_SPE(evmergehilo, evmergelohi, 0x17, 0x08, 0x00000000, PPC_SPE); //// |
5587 | 0487d6a8 | j_mayer | GEN_SPE(evcmpgtu, evcmpgts, 0x18, 0x08, 0x00600000, PPC_SPE); //// |
5588 | 0487d6a8 | j_mayer | GEN_SPE(evcmpltu, evcmplts, 0x19, 0x08, 0x00600000, PPC_SPE); //// |
5589 | 0487d6a8 | j_mayer | GEN_SPE(evcmpeq, speundef, 0x1A, 0x08, 0x00600000, PPC_SPE); //// |
5590 | 0487d6a8 | j_mayer | |
5591 | b068d6a7 | j_mayer | static always_inline void gen_evsel (DisasContext *ctx) |
5592 | 0487d6a8 | j_mayer | { |
5593 | 0487d6a8 | j_mayer | if (unlikely(!ctx->spe_enabled)) {
|
5594 | e1833e1f | j_mayer | GEN_EXCP_NO_AP(ctx); |
5595 | 0487d6a8 | j_mayer | return;
|
5596 | 0487d6a8 | j_mayer | } |
5597 | 47e4661c | aurel32 | tcg_gen_mov_i32(cpu_T[0], cpu_crf[ctx->opcode & 0x7]); |
5598 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[0], rA(ctx->opcode));
|
5599 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[1], rB(ctx->opcode));
|
5600 | 0487d6a8 | j_mayer | gen_op_evsel(); |
5601 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[0]);
|
5602 | 0487d6a8 | j_mayer | } |
5603 | 0487d6a8 | j_mayer | |
5604 | c7697e1f | j_mayer | GEN_HANDLER2(evsel0, "evsel", 0x04, 0x1c, 0x09, 0x00000000, PPC_SPE) |
5605 | 0487d6a8 | j_mayer | { |
5606 | 0487d6a8 | j_mayer | gen_evsel(ctx); |
5607 | 0487d6a8 | j_mayer | } |
5608 | c7697e1f | j_mayer | GEN_HANDLER2(evsel1, "evsel", 0x04, 0x1d, 0x09, 0x00000000, PPC_SPE) |
5609 | 0487d6a8 | j_mayer | { |
5610 | 0487d6a8 | j_mayer | gen_evsel(ctx); |
5611 | 0487d6a8 | j_mayer | } |
5612 | c7697e1f | j_mayer | GEN_HANDLER2(evsel2, "evsel", 0x04, 0x1e, 0x09, 0x00000000, PPC_SPE) |
5613 | 0487d6a8 | j_mayer | { |
5614 | 0487d6a8 | j_mayer | gen_evsel(ctx); |
5615 | 0487d6a8 | j_mayer | } |
5616 | c7697e1f | j_mayer | GEN_HANDLER2(evsel3, "evsel", 0x04, 0x1f, 0x09, 0x00000000, PPC_SPE) |
5617 | 0487d6a8 | j_mayer | { |
5618 | 0487d6a8 | j_mayer | gen_evsel(ctx); |
5619 | 0487d6a8 | j_mayer | } |
5620 | 0487d6a8 | j_mayer | |
5621 | 0487d6a8 | j_mayer | /* Load and stores */
|
5622 | 0487d6a8 | j_mayer | #if defined(TARGET_PPC64)
|
5623 | 0487d6a8 | j_mayer | /* In that case, we already have 64 bits load & stores
|
5624 | 0487d6a8 | j_mayer | * so, spe_ldd is equivalent to ld and spe_std is equivalent to std
|
5625 | 0487d6a8 | j_mayer | */
|
5626 | 7863667f | j_mayer | #define gen_op_spe_ldd_raw gen_op_ld_raw
|
5627 | 7863667f | j_mayer | #define gen_op_spe_ldd_user gen_op_ld_user
|
5628 | 7863667f | j_mayer | #define gen_op_spe_ldd_kernel gen_op_ld_kernel
|
5629 | 7863667f | j_mayer | #define gen_op_spe_ldd_hypv gen_op_ld_hypv
|
5630 | 7863667f | j_mayer | #define gen_op_spe_ldd_64_raw gen_op_ld_64_raw
|
5631 | 7863667f | j_mayer | #define gen_op_spe_ldd_64_user gen_op_ld_64_user
|
5632 | 7863667f | j_mayer | #define gen_op_spe_ldd_64_kernel gen_op_ld_64_kernel
|
5633 | 7863667f | j_mayer | #define gen_op_spe_ldd_64_hypv gen_op_ld_64_hypv
|
5634 | 7863667f | j_mayer | #define gen_op_spe_ldd_le_raw gen_op_ld_le_raw
|
5635 | 7863667f | j_mayer | #define gen_op_spe_ldd_le_user gen_op_ld_le_user
|
5636 | 7863667f | j_mayer | #define gen_op_spe_ldd_le_kernel gen_op_ld_le_kernel
|
5637 | 7863667f | j_mayer | #define gen_op_spe_ldd_le_hypv gen_op_ld_le_hypv
|
5638 | 7863667f | j_mayer | #define gen_op_spe_ldd_le_64_raw gen_op_ld_le_64_raw
|
5639 | 7863667f | j_mayer | #define gen_op_spe_ldd_le_64_user gen_op_ld_le_64_user
|
5640 | 7863667f | j_mayer | #define gen_op_spe_ldd_le_64_kernel gen_op_ld_le_64_kernel
|
5641 | 7863667f | j_mayer | #define gen_op_spe_ldd_le_64_hypv gen_op_ld_le_64_hypv
|
5642 | 7863667f | j_mayer | #define gen_op_spe_stdd_raw gen_op_std_raw
|
5643 | 7863667f | j_mayer | #define gen_op_spe_stdd_user gen_op_std_user
|
5644 | 7863667f | j_mayer | #define gen_op_spe_stdd_kernel gen_op_std_kernel
|
5645 | 7863667f | j_mayer | #define gen_op_spe_stdd_hypv gen_op_std_hypv
|
5646 | 7863667f | j_mayer | #define gen_op_spe_stdd_64_raw gen_op_std_64_raw
|
5647 | 7863667f | j_mayer | #define gen_op_spe_stdd_64_user gen_op_std_64_user
|
5648 | 7863667f | j_mayer | #define gen_op_spe_stdd_64_kernel gen_op_std_64_kernel
|
5649 | 7863667f | j_mayer | #define gen_op_spe_stdd_64_hypv gen_op_std_64_hypv
|
5650 | 7863667f | j_mayer | #define gen_op_spe_stdd_le_raw gen_op_std_le_raw
|
5651 | 7863667f | j_mayer | #define gen_op_spe_stdd_le_user gen_op_std_le_user
|
5652 | 7863667f | j_mayer | #define gen_op_spe_stdd_le_kernel gen_op_std_le_kernel
|
5653 | 7863667f | j_mayer | #define gen_op_spe_stdd_le_hypv gen_op_std_le_hypv
|
5654 | 7863667f | j_mayer | #define gen_op_spe_stdd_le_64_raw gen_op_std_le_64_raw
|
5655 | 7863667f | j_mayer | #define gen_op_spe_stdd_le_64_user gen_op_std_le_64_user
|
5656 | 7863667f | j_mayer | #define gen_op_spe_stdd_le_64_kernel gen_op_std_le_64_kernel
|
5657 | 7863667f | j_mayer | #define gen_op_spe_stdd_le_64_hypv gen_op_std_le_64_hypv
|
5658 | 0487d6a8 | j_mayer | #endif /* defined(TARGET_PPC64) */ |
5659 | 0487d6a8 | j_mayer | GEN_SPEOP_LDST(dd, 3);
|
5660 | 0487d6a8 | j_mayer | GEN_SPEOP_LDST(dw, 3);
|
5661 | 0487d6a8 | j_mayer | GEN_SPEOP_LDST(dh, 3);
|
5662 | 0487d6a8 | j_mayer | GEN_SPEOP_LDST(whe, 2);
|
5663 | 0487d6a8 | j_mayer | GEN_SPEOP_LD(whou, 2);
|
5664 | 0487d6a8 | j_mayer | GEN_SPEOP_LD(whos, 2);
|
5665 | 0487d6a8 | j_mayer | GEN_SPEOP_ST(who, 2);
|
5666 | 0487d6a8 | j_mayer | |
5667 | 0487d6a8 | j_mayer | #if defined(TARGET_PPC64)
|
5668 | 0487d6a8 | j_mayer | /* In that case, spe_stwwo is equivalent to stw */
|
5669 | 7863667f | j_mayer | #define gen_op_spe_stwwo_raw gen_op_stw_raw
|
5670 | 7863667f | j_mayer | #define gen_op_spe_stwwo_user gen_op_stw_user
|
5671 | 7863667f | j_mayer | #define gen_op_spe_stwwo_kernel gen_op_stw_kernel
|
5672 | 7863667f | j_mayer | #define gen_op_spe_stwwo_hypv gen_op_stw_hypv
|
5673 | 7863667f | j_mayer | #define gen_op_spe_stwwo_le_raw gen_op_stw_le_raw
|
5674 | 7863667f | j_mayer | #define gen_op_spe_stwwo_le_user gen_op_stw_le_user
|
5675 | 7863667f | j_mayer | #define gen_op_spe_stwwo_le_kernel gen_op_stw_le_kernel
|
5676 | 7863667f | j_mayer | #define gen_op_spe_stwwo_le_hypv gen_op_stw_le_hypv
|
5677 | 7863667f | j_mayer | #define gen_op_spe_stwwo_64_raw gen_op_stw_64_raw
|
5678 | 7863667f | j_mayer | #define gen_op_spe_stwwo_64_user gen_op_stw_64_user
|
5679 | 7863667f | j_mayer | #define gen_op_spe_stwwo_64_kernel gen_op_stw_64_kernel
|
5680 | 7863667f | j_mayer | #define gen_op_spe_stwwo_64_hypv gen_op_stw_64_hypv
|
5681 | 7863667f | j_mayer | #define gen_op_spe_stwwo_le_64_raw gen_op_stw_le_64_raw
|
5682 | 7863667f | j_mayer | #define gen_op_spe_stwwo_le_64_user gen_op_stw_le_64_user
|
5683 | 0487d6a8 | j_mayer | #define gen_op_spe_stwwo_le_64_kernel gen_op_stw_le_64_kernel
|
5684 | 7863667f | j_mayer | #define gen_op_spe_stwwo_le_64_hypv gen_op_stw_le_64_hypv
|
5685 | 0487d6a8 | j_mayer | #endif
|
5686 | 0487d6a8 | j_mayer | #define _GEN_OP_SPE_STWWE(suffix) \
|
5687 | b068d6a7 | j_mayer | static always_inline void gen_op_spe_stwwe_##suffix (void) \ |
5688 | 0487d6a8 | j_mayer | { \ |
5689 | 0487d6a8 | j_mayer | gen_op_srli32_T1_64(); \ |
5690 | 0487d6a8 | j_mayer | gen_op_spe_stwwo_##suffix(); \ |
5691 | 0487d6a8 | j_mayer | } |
5692 | 0487d6a8 | j_mayer | #define _GEN_OP_SPE_STWWE_LE(suffix) \
|
5693 | b068d6a7 | j_mayer | static always_inline void gen_op_spe_stwwe_le_##suffix (void) \ |
5694 | 0487d6a8 | j_mayer | { \ |
5695 | 0487d6a8 | j_mayer | gen_op_srli32_T1_64(); \ |
5696 | 0487d6a8 | j_mayer | gen_op_spe_stwwo_le_##suffix(); \ |
5697 | 0487d6a8 | j_mayer | } |
5698 | 0487d6a8 | j_mayer | #if defined(TARGET_PPC64)
|
5699 | 0487d6a8 | j_mayer | #define GEN_OP_SPE_STWWE(suffix) \
|
5700 | 0487d6a8 | j_mayer | _GEN_OP_SPE_STWWE(suffix); \ |
5701 | 0487d6a8 | j_mayer | _GEN_OP_SPE_STWWE_LE(suffix); \ |
5702 | b068d6a7 | j_mayer | static always_inline void gen_op_spe_stwwe_64_##suffix (void) \ |
5703 | 0487d6a8 | j_mayer | { \ |
5704 | 0487d6a8 | j_mayer | gen_op_srli32_T1_64(); \ |
5705 | 0487d6a8 | j_mayer | gen_op_spe_stwwo_64_##suffix(); \ |
5706 | 0487d6a8 | j_mayer | } \ |
5707 | b068d6a7 | j_mayer | static always_inline void gen_op_spe_stwwe_le_64_##suffix (void) \ |
5708 | 0487d6a8 | j_mayer | { \ |
5709 | 0487d6a8 | j_mayer | gen_op_srli32_T1_64(); \ |
5710 | 0487d6a8 | j_mayer | gen_op_spe_stwwo_le_64_##suffix(); \ |
5711 | 0487d6a8 | j_mayer | } |
5712 | 0487d6a8 | j_mayer | #else
|
5713 | 0487d6a8 | j_mayer | #define GEN_OP_SPE_STWWE(suffix) \
|
5714 | 0487d6a8 | j_mayer | _GEN_OP_SPE_STWWE(suffix); \ |
5715 | 0487d6a8 | j_mayer | _GEN_OP_SPE_STWWE_LE(suffix) |
5716 | 0487d6a8 | j_mayer | #endif
|
5717 | 0487d6a8 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5718 | 0487d6a8 | j_mayer | GEN_OP_SPE_STWWE(raw); |
5719 | 0487d6a8 | j_mayer | #else /* defined(CONFIG_USER_ONLY) */ |
5720 | 0487d6a8 | j_mayer | GEN_OP_SPE_STWWE(user); |
5721 | 7863667f | j_mayer | GEN_OP_SPE_STWWE(kernel); |
5722 | 7863667f | j_mayer | GEN_OP_SPE_STWWE(hypv); |
5723 | 0487d6a8 | j_mayer | #endif /* defined(CONFIG_USER_ONLY) */ |
5724 | 0487d6a8 | j_mayer | GEN_SPEOP_ST(wwe, 2);
|
5725 | 0487d6a8 | j_mayer | GEN_SPEOP_ST(wwo, 2);
|
5726 | 0487d6a8 | j_mayer | |
5727 | 0487d6a8 | j_mayer | #define GEN_SPE_LDSPLAT(name, op, suffix) \
|
5728 | b068d6a7 | j_mayer | static always_inline void gen_op_spe_l##name##_##suffix (void) \ |
5729 | 0487d6a8 | j_mayer | { \ |
5730 | 0487d6a8 | j_mayer | gen_op_##op##_##suffix(); \ |
5731 | 0487d6a8 | j_mayer | gen_op_splatw_T1_64(); \ |
5732 | 0487d6a8 | j_mayer | } |
5733 | 0487d6a8 | j_mayer | |
5734 | 0487d6a8 | j_mayer | #define GEN_OP_SPE_LHE(suffix) \
|
5735 | b068d6a7 | j_mayer | static always_inline void gen_op_spe_lhe_##suffix (void) \ |
5736 | 0487d6a8 | j_mayer | { \ |
5737 | 0487d6a8 | j_mayer | gen_op_spe_lh_##suffix(); \ |
5738 | 0487d6a8 | j_mayer | gen_op_sli16_T1_64(); \ |
5739 | 0487d6a8 | j_mayer | } |
5740 | 0487d6a8 | j_mayer | |
5741 | 0487d6a8 | j_mayer | #define GEN_OP_SPE_LHX(suffix) \
|
5742 | b068d6a7 | j_mayer | static always_inline void gen_op_spe_lhx_##suffix (void) \ |
5743 | 0487d6a8 | j_mayer | { \ |
5744 | 0487d6a8 | j_mayer | gen_op_spe_lh_##suffix(); \ |
5745 | 0487d6a8 | j_mayer | gen_op_extsh_T1_64(); \ |
5746 | 0487d6a8 | j_mayer | } |
5747 | 0487d6a8 | j_mayer | |
5748 | 0487d6a8 | j_mayer | #if defined(CONFIG_USER_ONLY)
|
5749 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHE(raw); |
5750 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, raw); |
5751 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHE(le_raw); |
5752 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, le_raw); |
5753 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, raw); |
5754 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, le_raw); |
5755 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHX(raw); |
5756 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, raw); |
5757 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHX(le_raw); |
5758 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, le_raw); |
5759 | 0487d6a8 | j_mayer | #if defined(TARGET_PPC64)
|
5760 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHE(64_raw);
|
5761 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, 64_raw);
|
5762 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHE(le_64_raw); |
5763 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, le_64_raw); |
5764 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, 64_raw);
|
5765 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, le_64_raw); |
5766 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHX(64_raw);
|
5767 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, 64_raw);
|
5768 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHX(le_64_raw); |
5769 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, le_64_raw); |
5770 | 0487d6a8 | j_mayer | #endif
|
5771 | 0487d6a8 | j_mayer | #else
|
5772 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHE(user); |
5773 | 7863667f | j_mayer | GEN_OP_SPE_LHE(kernel); |
5774 | 7863667f | j_mayer | GEN_OP_SPE_LHE(hypv); |
5775 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, user); |
5776 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, kernel); |
5777 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, hypv); |
5778 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHE(le_user); |
5779 | 7863667f | j_mayer | GEN_OP_SPE_LHE(le_kernel); |
5780 | 7863667f | j_mayer | GEN_OP_SPE_LHE(le_hypv); |
5781 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, le_user); |
5782 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, le_kernel); |
5783 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, le_hypv); |
5784 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, user); |
5785 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, kernel); |
5786 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, hypv); |
5787 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, le_user); |
5788 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, le_kernel); |
5789 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, le_hypv); |
5790 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHX(user); |
5791 | 7863667f | j_mayer | GEN_OP_SPE_LHX(kernel); |
5792 | 7863667f | j_mayer | GEN_OP_SPE_LHX(hypv); |
5793 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, user); |
5794 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, kernel); |
5795 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, hypv); |
5796 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHX(le_user); |
5797 | 7863667f | j_mayer | GEN_OP_SPE_LHX(le_kernel); |
5798 | 7863667f | j_mayer | GEN_OP_SPE_LHX(le_hypv); |
5799 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, le_user); |
5800 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, le_kernel); |
5801 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, le_hypv); |
5802 | 0487d6a8 | j_mayer | #if defined(TARGET_PPC64)
|
5803 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHE(64_user);
|
5804 | 7863667f | j_mayer | GEN_OP_SPE_LHE(64_kernel);
|
5805 | 7863667f | j_mayer | GEN_OP_SPE_LHE(64_hypv);
|
5806 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, 64_user);
|
5807 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, 64_kernel);
|
5808 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, 64_hypv);
|
5809 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHE(le_64_user); |
5810 | 7863667f | j_mayer | GEN_OP_SPE_LHE(le_64_kernel); |
5811 | 7863667f | j_mayer | GEN_OP_SPE_LHE(le_64_hypv); |
5812 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, le_64_user); |
5813 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, le_64_kernel); |
5814 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhesplat, spe_lhe, le_64_hypv); |
5815 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, 64_user);
|
5816 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, 64_kernel);
|
5817 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, 64_hypv);
|
5818 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, le_64_user); |
5819 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, le_64_kernel); |
5820 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhousplat, spe_lh, le_64_hypv); |
5821 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHX(64_user);
|
5822 | 7863667f | j_mayer | GEN_OP_SPE_LHX(64_kernel);
|
5823 | 7863667f | j_mayer | GEN_OP_SPE_LHX(64_hypv);
|
5824 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, 64_user);
|
5825 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, 64_kernel);
|
5826 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, 64_hypv);
|
5827 | 0487d6a8 | j_mayer | GEN_OP_SPE_LHX(le_64_user); |
5828 | 7863667f | j_mayer | GEN_OP_SPE_LHX(le_64_kernel); |
5829 | 7863667f | j_mayer | GEN_OP_SPE_LHX(le_64_hypv); |
5830 | 0487d6a8 | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, le_64_user); |
5831 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, le_64_kernel); |
5832 | 7863667f | j_mayer | GEN_SPE_LDSPLAT(hhossplat, spe_lhx, le_64_hypv); |
5833 | 0487d6a8 | j_mayer | #endif
|
5834 | 0487d6a8 | j_mayer | #endif
|
5835 | 0487d6a8 | j_mayer | GEN_SPEOP_LD(hhesplat, 1);
|
5836 | 0487d6a8 | j_mayer | GEN_SPEOP_LD(hhousplat, 1);
|
5837 | 0487d6a8 | j_mayer | GEN_SPEOP_LD(hhossplat, 1);
|
5838 | 0487d6a8 | j_mayer | GEN_SPEOP_LD(wwsplat, 2);
|
5839 | 0487d6a8 | j_mayer | GEN_SPEOP_LD(whsplat, 2);
|
5840 | 0487d6a8 | j_mayer | |
5841 | 0487d6a8 | j_mayer | GEN_SPE(evlddx, evldd, 0x00, 0x0C, 0x00000000, PPC_SPE); // |
5842 | 0487d6a8 | j_mayer | GEN_SPE(evldwx, evldw, 0x01, 0x0C, 0x00000000, PPC_SPE); // |
5843 | 0487d6a8 | j_mayer | GEN_SPE(evldhx, evldh, 0x02, 0x0C, 0x00000000, PPC_SPE); // |
5844 | 0487d6a8 | j_mayer | GEN_SPE(evlhhesplatx, evlhhesplat, 0x04, 0x0C, 0x00000000, PPC_SPE); // |
5845 | 0487d6a8 | j_mayer | GEN_SPE(evlhhousplatx, evlhhousplat, 0x06, 0x0C, 0x00000000, PPC_SPE); // |
5846 | 0487d6a8 | j_mayer | GEN_SPE(evlhhossplatx, evlhhossplat, 0x07, 0x0C, 0x00000000, PPC_SPE); // |
5847 | 0487d6a8 | j_mayer | GEN_SPE(evlwhex, evlwhe, 0x08, 0x0C, 0x00000000, PPC_SPE); // |
5848 | 0487d6a8 | j_mayer | GEN_SPE(evlwhoux, evlwhou, 0x0A, 0x0C, 0x00000000, PPC_SPE); // |
5849 | 0487d6a8 | j_mayer | GEN_SPE(evlwhosx, evlwhos, 0x0B, 0x0C, 0x00000000, PPC_SPE); // |
5850 | 0487d6a8 | j_mayer | GEN_SPE(evlwwsplatx, evlwwsplat, 0x0C, 0x0C, 0x00000000, PPC_SPE); // |
5851 | 0487d6a8 | j_mayer | GEN_SPE(evlwhsplatx, evlwhsplat, 0x0E, 0x0C, 0x00000000, PPC_SPE); // |
5852 | 0487d6a8 | j_mayer | GEN_SPE(evstddx, evstdd, 0x10, 0x0C, 0x00000000, PPC_SPE); // |
5853 | 0487d6a8 | j_mayer | GEN_SPE(evstdwx, evstdw, 0x11, 0x0C, 0x00000000, PPC_SPE); // |
5854 | 0487d6a8 | j_mayer | GEN_SPE(evstdhx, evstdh, 0x12, 0x0C, 0x00000000, PPC_SPE); // |
5855 | 0487d6a8 | j_mayer | GEN_SPE(evstwhex, evstwhe, 0x18, 0x0C, 0x00000000, PPC_SPE); // |
5856 | 0487d6a8 | j_mayer | GEN_SPE(evstwhox, evstwho, 0x1A, 0x0C, 0x00000000, PPC_SPE); // |
5857 | 0487d6a8 | j_mayer | GEN_SPE(evstwwex, evstwwe, 0x1C, 0x0C, 0x00000000, PPC_SPE); // |
5858 | 0487d6a8 | j_mayer | GEN_SPE(evstwwox, evstwwo, 0x1E, 0x0C, 0x00000000, PPC_SPE); // |
5859 | 0487d6a8 | j_mayer | |
5860 | 0487d6a8 | j_mayer | /* Multiply and add - TODO */
|
5861 | 0487d6a8 | j_mayer | #if 0
|
5862 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhessf, 0x01, 0x10, 0x00000000, PPC_SPE);
|
5863 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhossf, 0x03, 0x10, 0x00000000, PPC_SPE);
|
5864 | 0487d6a8 | j_mayer | GEN_SPE(evmheumi, evmhesmi, 0x04, 0x10, 0x00000000, PPC_SPE);
|
5865 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhesmf, 0x05, 0x10, 0x00000000, PPC_SPE);
|
5866 | 0487d6a8 | j_mayer | GEN_SPE(evmhoumi, evmhosmi, 0x06, 0x10, 0x00000000, PPC_SPE);
|
5867 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhosmf, 0x07, 0x10, 0x00000000, PPC_SPE);
|
5868 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhessfa, 0x11, 0x10, 0x00000000, PPC_SPE);
|
5869 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhossfa, 0x13, 0x10, 0x00000000, PPC_SPE);
|
5870 | 0487d6a8 | j_mayer | GEN_SPE(evmheumia, evmhesmia, 0x14, 0x10, 0x00000000, PPC_SPE);
|
5871 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhesmfa, 0x15, 0x10, 0x00000000, PPC_SPE);
|
5872 | 0487d6a8 | j_mayer | GEN_SPE(evmhoumia, evmhosmia, 0x16, 0x10, 0x00000000, PPC_SPE);
|
5873 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhosmfa, 0x17, 0x10, 0x00000000, PPC_SPE);
|
5874 | 0487d6a8 | j_mayer | |
5875 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwhssf, 0x03, 0x11, 0x00000000, PPC_SPE);
|
5876 | 0487d6a8 | j_mayer | GEN_SPE(evmwlumi, speundef, 0x04, 0x11, 0x00000000, PPC_SPE);
|
5877 | 0487d6a8 | j_mayer | GEN_SPE(evmwhumi, evmwhsmi, 0x06, 0x11, 0x00000000, PPC_SPE);
|
5878 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwhsmf, 0x07, 0x11, 0x00000000, PPC_SPE);
|
5879 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwssf, 0x09, 0x11, 0x00000000, PPC_SPE);
|
5880 | 0487d6a8 | j_mayer | GEN_SPE(evmwumi, evmwsmi, 0x0C, 0x11, 0x00000000, PPC_SPE);
|
5881 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwsmf, 0x0D, 0x11, 0x00000000, PPC_SPE);
|
5882 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwhssfa, 0x13, 0x11, 0x00000000, PPC_SPE);
|
5883 | 0487d6a8 | j_mayer | GEN_SPE(evmwlumia, speundef, 0x14, 0x11, 0x00000000, PPC_SPE);
|
5884 | 0487d6a8 | j_mayer | GEN_SPE(evmwhumia, evmwhsmia, 0x16, 0x11, 0x00000000, PPC_SPE);
|
5885 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwhsmfa, 0x17, 0x11, 0x00000000, PPC_SPE);
|
5886 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwssfa, 0x19, 0x11, 0x00000000, PPC_SPE);
|
5887 | 0487d6a8 | j_mayer | GEN_SPE(evmwumia, evmwsmia, 0x1C, 0x11, 0x00000000, PPC_SPE);
|
5888 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwsmfa, 0x1D, 0x11, 0x00000000, PPC_SPE);
|
5889 | 0487d6a8 | j_mayer | |
5890 | 0487d6a8 | j_mayer | GEN_SPE(evadduiaaw, evaddsiaaw, 0x00, 0x13, 0x0000F800, PPC_SPE);
|
5891 | 0487d6a8 | j_mayer | GEN_SPE(evsubfusiaaw, evsubfssiaaw, 0x01, 0x13, 0x0000F800, PPC_SPE);
|
5892 | 0487d6a8 | j_mayer | GEN_SPE(evaddumiaaw, evaddsmiaaw, 0x04, 0x13, 0x0000F800, PPC_SPE);
|
5893 | 0487d6a8 | j_mayer | GEN_SPE(evsubfumiaaw, evsubfsmiaaw, 0x05, 0x13, 0x0000F800, PPC_SPE);
|
5894 | 0487d6a8 | j_mayer | GEN_SPE(evdivws, evdivwu, 0x06, 0x13, 0x00000000, PPC_SPE);
|
5895 | 0487d6a8 | j_mayer | GEN_SPE(evmra, speundef, 0x07, 0x13, 0x0000F800, PPC_SPE);
|
5896 | 0487d6a8 | j_mayer | |
5897 | 0487d6a8 | j_mayer | GEN_SPE(evmheusiaaw, evmhessiaaw, 0x00, 0x14, 0x00000000, PPC_SPE);
|
5898 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhessfaaw, 0x01, 0x14, 0x00000000, PPC_SPE);
|
5899 | 0487d6a8 | j_mayer | GEN_SPE(evmhousiaaw, evmhossiaaw, 0x02, 0x14, 0x00000000, PPC_SPE);
|
5900 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhossfaaw, 0x03, 0x14, 0x00000000, PPC_SPE);
|
5901 | 0487d6a8 | j_mayer | GEN_SPE(evmheumiaaw, evmhesmiaaw, 0x04, 0x14, 0x00000000, PPC_SPE);
|
5902 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhesmfaaw, 0x05, 0x14, 0x00000000, PPC_SPE);
|
5903 | 0487d6a8 | j_mayer | GEN_SPE(evmhoumiaaw, evmhosmiaaw, 0x06, 0x14, 0x00000000, PPC_SPE);
|
5904 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhosmfaaw, 0x07, 0x14, 0x00000000, PPC_SPE);
|
5905 | 0487d6a8 | j_mayer | GEN_SPE(evmhegumiaa, evmhegsmiaa, 0x14, 0x14, 0x00000000, PPC_SPE);
|
5906 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhegsmfaa, 0x15, 0x14, 0x00000000, PPC_SPE);
|
5907 | 0487d6a8 | j_mayer | GEN_SPE(evmhogumiaa, evmhogsmiaa, 0x16, 0x14, 0x00000000, PPC_SPE);
|
5908 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhogsmfaa, 0x17, 0x14, 0x00000000, PPC_SPE);
|
5909 | 0487d6a8 | j_mayer | |
5910 | 0487d6a8 | j_mayer | GEN_SPE(evmwlusiaaw, evmwlssiaaw, 0x00, 0x15, 0x00000000, PPC_SPE);
|
5911 | 0487d6a8 | j_mayer | GEN_SPE(evmwlumiaaw, evmwlsmiaaw, 0x04, 0x15, 0x00000000, PPC_SPE);
|
5912 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwssfaa, 0x09, 0x15, 0x00000000, PPC_SPE);
|
5913 | 0487d6a8 | j_mayer | GEN_SPE(evmwumiaa, evmwsmiaa, 0x0C, 0x15, 0x00000000, PPC_SPE);
|
5914 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwsmfaa, 0x0D, 0x15, 0x00000000, PPC_SPE);
|
5915 | 0487d6a8 | j_mayer | |
5916 | 0487d6a8 | j_mayer | GEN_SPE(evmheusianw, evmhessianw, 0x00, 0x16, 0x00000000, PPC_SPE);
|
5917 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhessfanw, 0x01, 0x16, 0x00000000, PPC_SPE);
|
5918 | 0487d6a8 | j_mayer | GEN_SPE(evmhousianw, evmhossianw, 0x02, 0x16, 0x00000000, PPC_SPE);
|
5919 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhossfanw, 0x03, 0x16, 0x00000000, PPC_SPE);
|
5920 | 0487d6a8 | j_mayer | GEN_SPE(evmheumianw, evmhesmianw, 0x04, 0x16, 0x00000000, PPC_SPE);
|
5921 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhesmfanw, 0x05, 0x16, 0x00000000, PPC_SPE);
|
5922 | 0487d6a8 | j_mayer | GEN_SPE(evmhoumianw, evmhosmianw, 0x06, 0x16, 0x00000000, PPC_SPE);
|
5923 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhosmfanw, 0x07, 0x16, 0x00000000, PPC_SPE);
|
5924 | 0487d6a8 | j_mayer | GEN_SPE(evmhegumian, evmhegsmian, 0x14, 0x16, 0x00000000, PPC_SPE);
|
5925 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhegsmfan, 0x15, 0x16, 0x00000000, PPC_SPE);
|
5926 | 0487d6a8 | j_mayer | GEN_SPE(evmhigumian, evmhigsmian, 0x16, 0x16, 0x00000000, PPC_SPE);
|
5927 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmhogsmfan, 0x17, 0x16, 0x00000000, PPC_SPE);
|
5928 | 0487d6a8 | j_mayer | |
5929 | 0487d6a8 | j_mayer | GEN_SPE(evmwlusianw, evmwlssianw, 0x00, 0x17, 0x00000000, PPC_SPE);
|
5930 | 0487d6a8 | j_mayer | GEN_SPE(evmwlumianw, evmwlsmianw, 0x04, 0x17, 0x00000000, PPC_SPE);
|
5931 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwssfan, 0x09, 0x17, 0x00000000, PPC_SPE);
|
5932 | 0487d6a8 | j_mayer | GEN_SPE(evmwumian, evmwsmian, 0x0C, 0x17, 0x00000000, PPC_SPE);
|
5933 | 0487d6a8 | j_mayer | GEN_SPE(speundef, evmwsmfan, 0x0D, 0x17, 0x00000000, PPC_SPE);
|
5934 | 0487d6a8 | j_mayer | #endif
|
5935 | 0487d6a8 | j_mayer | |
5936 | 0487d6a8 | j_mayer | /*** SPE floating-point extension ***/
|
5937 | 0487d6a8 | j_mayer | #define GEN_SPEFPUOP_CONV(name) \
|
5938 | b068d6a7 | j_mayer | static always_inline void gen_##name (DisasContext *ctx) \ |
5939 | 0487d6a8 | j_mayer | { \ |
5940 | f78fb44e | aurel32 | gen_load_gpr64(cpu_T64[0], rB(ctx->opcode)); \
|
5941 | 0487d6a8 | j_mayer | gen_op_##name(); \ |
5942 | f78fb44e | aurel32 | gen_store_gpr64(rD(ctx->opcode), cpu_T64[0]); \
|
5943 | 0487d6a8 | j_mayer | } |
5944 | 0487d6a8 | j_mayer | |
5945 | 0487d6a8 | j_mayer | /* Single precision floating-point vectors operations */
|
5946 | 0487d6a8 | j_mayer | /* Arithmetic */
|
5947 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evfsadd); |
5948 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evfssub); |
5949 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evfsmul); |
5950 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(evfsdiv); |
5951 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evfsabs); |
5952 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evfsnabs); |
5953 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(evfsneg); |
5954 | 0487d6a8 | j_mayer | /* Conversion */
|
5955 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfscfui); |
5956 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfscfsi); |
5957 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfscfuf); |
5958 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfscfsf); |
5959 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfsctui); |
5960 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfsctsi); |
5961 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfsctuf); |
5962 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfsctsf); |
5963 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfsctuiz); |
5964 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(evfsctsiz); |
5965 | 0487d6a8 | j_mayer | /* Comparison */
|
5966 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evfscmpgt); |
5967 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evfscmplt); |
5968 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evfscmpeq); |
5969 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evfststgt); |
5970 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evfststlt); |
5971 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(evfststeq); |
5972 | 0487d6a8 | j_mayer | |
5973 | 0487d6a8 | j_mayer | /* Opcodes definitions */
|
5974 | 0487d6a8 | j_mayer | GEN_SPE(evfsadd, evfssub, 0x00, 0x0A, 0x00000000, PPC_SPEFPU); // |
5975 | 0487d6a8 | j_mayer | GEN_SPE(evfsabs, evfsnabs, 0x02, 0x0A, 0x0000F800, PPC_SPEFPU); // |
5976 | 0487d6a8 | j_mayer | GEN_SPE(evfsneg, speundef, 0x03, 0x0A, 0x0000F800, PPC_SPEFPU); // |
5977 | 0487d6a8 | j_mayer | GEN_SPE(evfsmul, evfsdiv, 0x04, 0x0A, 0x00000000, PPC_SPEFPU); // |
5978 | 0487d6a8 | j_mayer | GEN_SPE(evfscmpgt, evfscmplt, 0x06, 0x0A, 0x00600000, PPC_SPEFPU); // |
5979 | 0487d6a8 | j_mayer | GEN_SPE(evfscmpeq, speundef, 0x07, 0x0A, 0x00600000, PPC_SPEFPU); // |
5980 | 0487d6a8 | j_mayer | GEN_SPE(evfscfui, evfscfsi, 0x08, 0x0A, 0x00180000, PPC_SPEFPU); // |
5981 | 0487d6a8 | j_mayer | GEN_SPE(evfscfuf, evfscfsf, 0x09, 0x0A, 0x00180000, PPC_SPEFPU); // |
5982 | 0487d6a8 | j_mayer | GEN_SPE(evfsctui, evfsctsi, 0x0A, 0x0A, 0x00180000, PPC_SPEFPU); // |
5983 | 0487d6a8 | j_mayer | GEN_SPE(evfsctuf, evfsctsf, 0x0B, 0x0A, 0x00180000, PPC_SPEFPU); // |
5984 | 0487d6a8 | j_mayer | GEN_SPE(evfsctuiz, speundef, 0x0C, 0x0A, 0x00180000, PPC_SPEFPU); // |
5985 | 0487d6a8 | j_mayer | GEN_SPE(evfsctsiz, speundef, 0x0D, 0x0A, 0x00180000, PPC_SPEFPU); // |
5986 | 0487d6a8 | j_mayer | GEN_SPE(evfststgt, evfststlt, 0x0E, 0x0A, 0x00600000, PPC_SPEFPU); // |
5987 | 0487d6a8 | j_mayer | GEN_SPE(evfststeq, speundef, 0x0F, 0x0A, 0x00600000, PPC_SPEFPU); // |
5988 | 0487d6a8 | j_mayer | |
5989 | 0487d6a8 | j_mayer | /* Single precision floating-point operations */
|
5990 | 0487d6a8 | j_mayer | /* Arithmetic */
|
5991 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(efsadd); |
5992 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(efssub); |
5993 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(efsmul); |
5994 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(efsdiv); |
5995 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(efsabs); |
5996 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(efsnabs); |
5997 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(efsneg); |
5998 | 0487d6a8 | j_mayer | /* Conversion */
|
5999 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efscfui); |
6000 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efscfsi); |
6001 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efscfuf); |
6002 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efscfsf); |
6003 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efsctui); |
6004 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efsctsi); |
6005 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efsctuf); |
6006 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efsctsf); |
6007 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efsctuiz); |
6008 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efsctsiz); |
6009 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efscfd); |
6010 | 0487d6a8 | j_mayer | /* Comparison */
|
6011 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efscmpgt); |
6012 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efscmplt); |
6013 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efscmpeq); |
6014 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efststgt); |
6015 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efststlt); |
6016 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efststeq); |
6017 | 0487d6a8 | j_mayer | |
6018 | 0487d6a8 | j_mayer | /* Opcodes definitions */
|
6019 | 05332d70 | j_mayer | GEN_SPE(efsadd, efssub, 0x00, 0x0B, 0x00000000, PPC_SPEFPU); // |
6020 | 0487d6a8 | j_mayer | GEN_SPE(efsabs, efsnabs, 0x02, 0x0B, 0x0000F800, PPC_SPEFPU); // |
6021 | 0487d6a8 | j_mayer | GEN_SPE(efsneg, speundef, 0x03, 0x0B, 0x0000F800, PPC_SPEFPU); // |
6022 | 0487d6a8 | j_mayer | GEN_SPE(efsmul, efsdiv, 0x04, 0x0B, 0x00000000, PPC_SPEFPU); // |
6023 | 0487d6a8 | j_mayer | GEN_SPE(efscmpgt, efscmplt, 0x06, 0x0B, 0x00600000, PPC_SPEFPU); // |
6024 | 0487d6a8 | j_mayer | GEN_SPE(efscmpeq, efscfd, 0x07, 0x0B, 0x00600000, PPC_SPEFPU); // |
6025 | 0487d6a8 | j_mayer | GEN_SPE(efscfui, efscfsi, 0x08, 0x0B, 0x00180000, PPC_SPEFPU); // |
6026 | 0487d6a8 | j_mayer | GEN_SPE(efscfuf, efscfsf, 0x09, 0x0B, 0x00180000, PPC_SPEFPU); // |
6027 | 0487d6a8 | j_mayer | GEN_SPE(efsctui, efsctsi, 0x0A, 0x0B, 0x00180000, PPC_SPEFPU); // |
6028 | 0487d6a8 | j_mayer | GEN_SPE(efsctuf, efsctsf, 0x0B, 0x0B, 0x00180000, PPC_SPEFPU); // |
6029 | 9ceb2a77 | ths | GEN_SPE(efsctuiz, speundef, 0x0C, 0x0B, 0x00180000, PPC_SPEFPU); // |
6030 | 9ceb2a77 | ths | GEN_SPE(efsctsiz, speundef, 0x0D, 0x0B, 0x00180000, PPC_SPEFPU); // |
6031 | 0487d6a8 | j_mayer | GEN_SPE(efststgt, efststlt, 0x0E, 0x0B, 0x00600000, PPC_SPEFPU); // |
6032 | 0487d6a8 | j_mayer | GEN_SPE(efststeq, speundef, 0x0F, 0x0B, 0x00600000, PPC_SPEFPU); // |
6033 | 0487d6a8 | j_mayer | |
6034 | 0487d6a8 | j_mayer | /* Double precision floating-point operations */
|
6035 | 0487d6a8 | j_mayer | /* Arithmetic */
|
6036 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(efdadd); |
6037 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(efdsub); |
6038 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(efdmul); |
6039 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH2(efddiv); |
6040 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(efdabs); |
6041 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(efdnabs); |
6042 | 0487d6a8 | j_mayer | GEN_SPEOP_ARITH1(efdneg); |
6043 | 0487d6a8 | j_mayer | /* Conversion */
|
6044 | 0487d6a8 | j_mayer | |
6045 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdcfui); |
6046 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdcfsi); |
6047 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdcfuf); |
6048 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdcfsf); |
6049 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdctui); |
6050 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdctsi); |
6051 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdctuf); |
6052 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdctsf); |
6053 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdctuiz); |
6054 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdctsiz); |
6055 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdcfs); |
6056 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdcfuid); |
6057 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdcfsid); |
6058 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdctuidz); |
6059 | 0487d6a8 | j_mayer | GEN_SPEFPUOP_CONV(efdctsidz); |
6060 | 0487d6a8 | j_mayer | /* Comparison */
|
6061 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efdcmpgt); |
6062 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efdcmplt); |
6063 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efdcmpeq); |
6064 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efdtstgt); |
6065 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efdtstlt); |
6066 | 0487d6a8 | j_mayer | GEN_SPEOP_COMP(efdtsteq); |
6067 | 0487d6a8 | j_mayer | |
6068 | 0487d6a8 | j_mayer | /* Opcodes definitions */
|
6069 | 0487d6a8 | j_mayer | GEN_SPE(efdadd, efdsub, 0x10, 0x0B, 0x00000000, PPC_SPEFPU); // |
6070 | 0487d6a8 | j_mayer | GEN_SPE(efdcfuid, efdcfsid, 0x11, 0x0B, 0x00180000, PPC_SPEFPU); // |
6071 | 0487d6a8 | j_mayer | GEN_SPE(efdabs, efdnabs, 0x12, 0x0B, 0x0000F800, PPC_SPEFPU); // |
6072 | 0487d6a8 | j_mayer | GEN_SPE(efdneg, speundef, 0x13, 0x0B, 0x0000F800, PPC_SPEFPU); // |
6073 | 0487d6a8 | j_mayer | GEN_SPE(efdmul, efddiv, 0x14, 0x0B, 0x00000000, PPC_SPEFPU); // |
6074 | 0487d6a8 | j_mayer | GEN_SPE(efdctuidz, efdctsidz, 0x15, 0x0B, 0x00180000, PPC_SPEFPU); // |
6075 | 0487d6a8 | j_mayer | GEN_SPE(efdcmpgt, efdcmplt, 0x16, 0x0B, 0x00600000, PPC_SPEFPU); // |
6076 | 0487d6a8 | j_mayer | GEN_SPE(efdcmpeq, efdcfs, 0x17, 0x0B, 0x00600000, PPC_SPEFPU); // |
6077 | 0487d6a8 | j_mayer | GEN_SPE(efdcfui, efdcfsi, 0x18, 0x0B, 0x00180000, PPC_SPEFPU); // |
6078 | 0487d6a8 | j_mayer | GEN_SPE(efdcfuf, efdcfsf, 0x19, 0x0B, 0x00180000, PPC_SPEFPU); // |
6079 | 0487d6a8 | j_mayer | GEN_SPE(efdctui, efdctsi, 0x1A, 0x0B, 0x00180000, PPC_SPEFPU); // |
6080 | 0487d6a8 | j_mayer | GEN_SPE(efdctuf, efdctsf, 0x1B, 0x0B, 0x00180000, PPC_SPEFPU); // |
6081 | 0487d6a8 | j_mayer | GEN_SPE(efdctuiz, speundef, 0x1C, 0x0B, 0x00180000, PPC_SPEFPU); // |
6082 | 0487d6a8 | j_mayer | GEN_SPE(efdctsiz, speundef, 0x1D, 0x0B, 0x00180000, PPC_SPEFPU); // |
6083 | 0487d6a8 | j_mayer | GEN_SPE(efdtstgt, efdtstlt, 0x1E, 0x0B, 0x00600000, PPC_SPEFPU); // |
6084 | 0487d6a8 | j_mayer | GEN_SPE(efdtsteq, speundef, 0x1F, 0x0B, 0x00600000, PPC_SPEFPU); // |
6085 | 0487d6a8 | j_mayer | |
6086 | 79aceca5 | bellard | /* End opcode list */
|
6087 | 79aceca5 | bellard | GEN_OPCODE_MARK(end); |
6088 | 79aceca5 | bellard | |
6089 | 3fc6c082 | bellard | #include "translate_init.c" |
6090 | 0411a972 | j_mayer | #include "helper_regs.h" |
6091 | 79aceca5 | bellard | |
6092 | 9a64fbe4 | bellard | /*****************************************************************************/
|
6093 | 3fc6c082 | bellard | /* Misc PowerPC helpers */
|
6094 | 36081602 | j_mayer | void cpu_dump_state (CPUState *env, FILE *f,
|
6095 | 36081602 | j_mayer | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
6096 | 36081602 | j_mayer | int flags)
|
6097 | 79aceca5 | bellard | { |
6098 | 3fc6c082 | bellard | #define RGPL 4 |
6099 | 3fc6c082 | bellard | #define RFPL 4 |
6100 | 3fc6c082 | bellard | |
6101 | 79aceca5 | bellard | int i;
|
6102 | 79aceca5 | bellard | |
6103 | 077fc206 | j_mayer | cpu_fprintf(f, "NIP " ADDRX " LR " ADDRX " CTR " ADDRX " XER %08x\n", |
6104 | 077fc206 | j_mayer | env->nip, env->lr, env->ctr, hreg_load_xer(env)); |
6105 | 6b542af7 | j_mayer | cpu_fprintf(f, "MSR " ADDRX " HID0 " ADDRX " HF " ADDRX " idx %d\n", |
6106 | 6b542af7 | j_mayer | env->msr, env->spr[SPR_HID0], env->hflags, env->mmu_idx); |
6107 | d9bce9d9 | j_mayer | #if !defined(NO_TIMER_DUMP)
|
6108 | 077fc206 | j_mayer | cpu_fprintf(f, "TB %08x %08x "
|
6109 | 76a66253 | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
6110 | 76a66253 | j_mayer | "DECR %08x"
|
6111 | 76a66253 | j_mayer | #endif
|
6112 | 76a66253 | j_mayer | "\n",
|
6113 | 077fc206 | j_mayer | cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) |
6114 | 76a66253 | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
6115 | 76a66253 | j_mayer | , cpu_ppc_load_decr(env) |
6116 | 76a66253 | j_mayer | #endif
|
6117 | 76a66253 | j_mayer | ); |
6118 | 077fc206 | j_mayer | #endif
|
6119 | 76a66253 | j_mayer | for (i = 0; i < 32; i++) { |
6120 | 3fc6c082 | bellard | if ((i & (RGPL - 1)) == 0) |
6121 | 3fc6c082 | bellard | cpu_fprintf(f, "GPR%02d", i);
|
6122 | 6b542af7 | j_mayer | cpu_fprintf(f, " " REGX, ppc_dump_gpr(env, i));
|
6123 | 3fc6c082 | bellard | if ((i & (RGPL - 1)) == (RGPL - 1)) |
6124 | 7fe48483 | bellard | cpu_fprintf(f, "\n");
|
6125 | 76a66253 | j_mayer | } |
6126 | 3fc6c082 | bellard | cpu_fprintf(f, "CR ");
|
6127 | 76a66253 | j_mayer | for (i = 0; i < 8; i++) |
6128 | 7fe48483 | bellard | cpu_fprintf(f, "%01x", env->crf[i]);
|
6129 | 7fe48483 | bellard | cpu_fprintf(f, " [");
|
6130 | 76a66253 | j_mayer | for (i = 0; i < 8; i++) { |
6131 | 76a66253 | j_mayer | char a = '-'; |
6132 | 76a66253 | j_mayer | if (env->crf[i] & 0x08) |
6133 | 76a66253 | j_mayer | a = 'L';
|
6134 | 76a66253 | j_mayer | else if (env->crf[i] & 0x04) |
6135 | 76a66253 | j_mayer | a = 'G';
|
6136 | 76a66253 | j_mayer | else if (env->crf[i] & 0x02) |
6137 | 76a66253 | j_mayer | a = 'E';
|
6138 | 7fe48483 | bellard | cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); |
6139 | 76a66253 | j_mayer | } |
6140 | 6b542af7 | j_mayer | cpu_fprintf(f, " ] RES " ADDRX "\n", env->reserve); |
6141 | 3fc6c082 | bellard | for (i = 0; i < 32; i++) { |
6142 | 3fc6c082 | bellard | if ((i & (RFPL - 1)) == 0) |
6143 | 3fc6c082 | bellard | cpu_fprintf(f, "FPR%02d", i);
|
6144 | 26a76461 | bellard | cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
|
6145 | 3fc6c082 | bellard | if ((i & (RFPL - 1)) == (RFPL - 1)) |
6146 | 7fe48483 | bellard | cpu_fprintf(f, "\n");
|
6147 | 79aceca5 | bellard | } |
6148 | f2e63a42 | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
6149 | 6b542af7 | j_mayer | cpu_fprintf(f, "SRR0 " ADDRX " SRR1 " ADDRX " SDR1 " ADDRX "\n", |
6150 | 3fc6c082 | bellard | env->spr[SPR_SRR0], env->spr[SPR_SRR1], env->sdr1); |
6151 | f2e63a42 | j_mayer | #endif
|
6152 | 79aceca5 | bellard | |
6153 | 3fc6c082 | bellard | #undef RGPL
|
6154 | 3fc6c082 | bellard | #undef RFPL
|
6155 | 79aceca5 | bellard | } |
6156 | 79aceca5 | bellard | |
6157 | 76a66253 | j_mayer | void cpu_dump_statistics (CPUState *env, FILE*f,
|
6158 | 76a66253 | j_mayer | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
6159 | 76a66253 | j_mayer | int flags)
|
6160 | 76a66253 | j_mayer | { |
6161 | 76a66253 | j_mayer | #if defined(DO_PPC_STATISTICS)
|
6162 | 76a66253 | j_mayer | opc_handler_t **t1, **t2, **t3, *handler; |
6163 | 76a66253 | j_mayer | int op1, op2, op3;
|
6164 | 76a66253 | j_mayer | |
6165 | 76a66253 | j_mayer | t1 = env->opcodes; |
6166 | 76a66253 | j_mayer | for (op1 = 0; op1 < 64; op1++) { |
6167 | 76a66253 | j_mayer | handler = t1[op1]; |
6168 | 76a66253 | j_mayer | if (is_indirect_opcode(handler)) {
|
6169 | 76a66253 | j_mayer | t2 = ind_table(handler); |
6170 | 76a66253 | j_mayer | for (op2 = 0; op2 < 32; op2++) { |
6171 | 76a66253 | j_mayer | handler = t2[op2]; |
6172 | 76a66253 | j_mayer | if (is_indirect_opcode(handler)) {
|
6173 | 76a66253 | j_mayer | t3 = ind_table(handler); |
6174 | 76a66253 | j_mayer | for (op3 = 0; op3 < 32; op3++) { |
6175 | 76a66253 | j_mayer | handler = t3[op3]; |
6176 | 76a66253 | j_mayer | if (handler->count == 0) |
6177 | 76a66253 | j_mayer | continue;
|
6178 | 76a66253 | j_mayer | cpu_fprintf(f, "%02x %02x %02x (%02x %04d) %16s: "
|
6179 | 76a66253 | j_mayer | "%016llx %lld\n",
|
6180 | 76a66253 | j_mayer | op1, op2, op3, op1, (op3 << 5) | op2,
|
6181 | 76a66253 | j_mayer | handler->oname, |
6182 | 76a66253 | j_mayer | handler->count, handler->count); |
6183 | 76a66253 | j_mayer | } |
6184 | 76a66253 | j_mayer | } else {
|
6185 | 76a66253 | j_mayer | if (handler->count == 0) |
6186 | 76a66253 | j_mayer | continue;
|
6187 | 76a66253 | j_mayer | cpu_fprintf(f, "%02x %02x (%02x %04d) %16s: "
|
6188 | 76a66253 | j_mayer | "%016llx %lld\n",
|
6189 | 76a66253 | j_mayer | op1, op2, op1, op2, handler->oname, |
6190 | 76a66253 | j_mayer | handler->count, handler->count); |
6191 | 76a66253 | j_mayer | } |
6192 | 76a66253 | j_mayer | } |
6193 | 76a66253 | j_mayer | } else {
|
6194 | 76a66253 | j_mayer | if (handler->count == 0) |
6195 | 76a66253 | j_mayer | continue;
|
6196 | 76a66253 | j_mayer | cpu_fprintf(f, "%02x (%02x ) %16s: %016llx %lld\n",
|
6197 | 76a66253 | j_mayer | op1, op1, handler->oname, |
6198 | 76a66253 | j_mayer | handler->count, handler->count); |
6199 | 76a66253 | j_mayer | } |
6200 | 76a66253 | j_mayer | } |
6201 | 76a66253 | j_mayer | #endif
|
6202 | 76a66253 | j_mayer | } |
6203 | 76a66253 | j_mayer | |
6204 | 9a64fbe4 | bellard | /*****************************************************************************/
|
6205 | 2cfc5f17 | ths | static always_inline void gen_intermediate_code_internal (CPUState *env, |
6206 | 2cfc5f17 | ths | TranslationBlock *tb, |
6207 | 2cfc5f17 | ths | int search_pc)
|
6208 | 79aceca5 | bellard | { |
6209 | 9fddaa0c | bellard | DisasContext ctx, *ctxp = &ctx; |
6210 | 79aceca5 | bellard | opc_handler_t **table, *handler; |
6211 | 0fa85d43 | bellard | target_ulong pc_start; |
6212 | 79aceca5 | bellard | uint16_t *gen_opc_end; |
6213 | 056401ea | j_mayer | int supervisor, little_endian;
|
6214 | 79aceca5 | bellard | int j, lj = -1; |
6215 | 2e70f6ef | pbrook | int num_insns;
|
6216 | 2e70f6ef | pbrook | int max_insns;
|
6217 | 79aceca5 | bellard | |
6218 | 79aceca5 | bellard | pc_start = tb->pc; |
6219 | 79aceca5 | bellard | gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; |
6220 | 7c58044c | j_mayer | #if defined(OPTIMIZE_FPRF_UPDATE)
|
6221 | 7c58044c | j_mayer | gen_fprf_ptr = gen_fprf_buf; |
6222 | 7c58044c | j_mayer | #endif
|
6223 | 046d6672 | bellard | ctx.nip = pc_start; |
6224 | 79aceca5 | bellard | ctx.tb = tb; |
6225 | e1833e1f | j_mayer | ctx.exception = POWERPC_EXCP_NONE; |
6226 | 3fc6c082 | bellard | ctx.spr_cb = env->spr_cb; |
6227 | 6ebbf390 | j_mayer | supervisor = env->mmu_idx; |
6228 | 6ebbf390 | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
6229 | 2857068e | j_mayer | ctx.supervisor = supervisor; |
6230 | d9bce9d9 | j_mayer | #endif
|
6231 | 056401ea | j_mayer | little_endian = env->hflags & (1 << MSR_LE) ? 1 : 0; |
6232 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
6233 | d9bce9d9 | j_mayer | ctx.sf_mode = msr_sf; |
6234 | 056401ea | j_mayer | ctx.mem_idx = (supervisor << 2) | (msr_sf << 1) | little_endian; |
6235 | 2857068e | j_mayer | #else
|
6236 | 056401ea | j_mayer | ctx.mem_idx = (supervisor << 1) | little_endian;
|
6237 | 9a64fbe4 | bellard | #endif
|
6238 | d63001d1 | j_mayer | ctx.dcache_line_size = env->dcache_line_size; |
6239 | 3cc62370 | bellard | ctx.fpu_enabled = msr_fp; |
6240 | a9d9eb8f | j_mayer | if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
|
6241 | d26bfc9a | j_mayer | ctx.spe_enabled = msr_spe; |
6242 | d26bfc9a | j_mayer | else
|
6243 | d26bfc9a | j_mayer | ctx.spe_enabled = 0;
|
6244 | a9d9eb8f | j_mayer | if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
|
6245 | a9d9eb8f | j_mayer | ctx.altivec_enabled = msr_vr; |
6246 | a9d9eb8f | j_mayer | else
|
6247 | a9d9eb8f | j_mayer | ctx.altivec_enabled = 0;
|
6248 | d26bfc9a | j_mayer | if ((env->flags & POWERPC_FLAG_SE) && msr_se)
|
6249 | 8cbcb4fa | aurel32 | ctx.singlestep_enabled = CPU_SINGLE_STEP; |
6250 | d26bfc9a | j_mayer | else
|
6251 | 8cbcb4fa | aurel32 | ctx.singlestep_enabled = 0;
|
6252 | d26bfc9a | j_mayer | if ((env->flags & POWERPC_FLAG_BE) && msr_be)
|
6253 | 8cbcb4fa | aurel32 | ctx.singlestep_enabled |= CPU_BRANCH_STEP; |
6254 | 8cbcb4fa | aurel32 | if (unlikely(env->singlestep_enabled))
|
6255 | 8cbcb4fa | aurel32 | ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP; |
6256 | 3fc6c082 | bellard | #if defined (DO_SINGLE_STEP) && 0 |
6257 | 9a64fbe4 | bellard | /* Single step trace mode */
|
6258 | 9a64fbe4 | bellard | msr_se = 1;
|
6259 | 9a64fbe4 | bellard | #endif
|
6260 | 2e70f6ef | pbrook | num_insns = 0;
|
6261 | 2e70f6ef | pbrook | max_insns = tb->cflags & CF_COUNT_MASK; |
6262 | 2e70f6ef | pbrook | if (max_insns == 0) |
6263 | 2e70f6ef | pbrook | max_insns = CF_COUNT_MASK; |
6264 | 2e70f6ef | pbrook | |
6265 | 2e70f6ef | pbrook | gen_icount_start(); |
6266 | 9a64fbe4 | bellard | /* Set env in case of segfault during code fetch */
|
6267 | e1833e1f | j_mayer | while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
|
6268 | 76a66253 | j_mayer | if (unlikely(env->nb_breakpoints > 0)) { |
6269 | 76a66253 | j_mayer | for (j = 0; j < env->nb_breakpoints; j++) { |
6270 | ea4e754f | bellard | if (env->breakpoints[j] == ctx.nip) {
|
6271 | 5fafdf24 | ths | gen_update_nip(&ctx, ctx.nip); |
6272 | ea4e754f | bellard | gen_op_debug(); |
6273 | ea4e754f | bellard | break;
|
6274 | ea4e754f | bellard | } |
6275 | ea4e754f | bellard | } |
6276 | ea4e754f | bellard | } |
6277 | 76a66253 | j_mayer | if (unlikely(search_pc)) {
|
6278 | 79aceca5 | bellard | j = gen_opc_ptr - gen_opc_buf; |
6279 | 79aceca5 | bellard | if (lj < j) {
|
6280 | 79aceca5 | bellard | lj++; |
6281 | 79aceca5 | bellard | while (lj < j)
|
6282 | 79aceca5 | bellard | gen_opc_instr_start[lj++] = 0;
|
6283 | 046d6672 | bellard | gen_opc_pc[lj] = ctx.nip; |
6284 | 79aceca5 | bellard | gen_opc_instr_start[lj] = 1;
|
6285 | 2e70f6ef | pbrook | gen_opc_icount[lj] = num_insns; |
6286 | 79aceca5 | bellard | } |
6287 | 79aceca5 | bellard | } |
6288 | 9fddaa0c | bellard | #if defined PPC_DEBUG_DISAS
|
6289 | 9fddaa0c | bellard | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
6290 | 79aceca5 | bellard | fprintf(logfile, "----------------\n");
|
6291 | 1b9eb036 | j_mayer | fprintf(logfile, "nip=" ADDRX " super=%d ir=%d\n", |
6292 | 0411a972 | j_mayer | ctx.nip, supervisor, (int)msr_ir);
|
6293 | 9a64fbe4 | bellard | } |
6294 | 9a64fbe4 | bellard | #endif
|
6295 | 2e70f6ef | pbrook | if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) |
6296 | 2e70f6ef | pbrook | gen_io_start(); |
6297 | 056401ea | j_mayer | if (unlikely(little_endian)) {
|
6298 | 056401ea | j_mayer | ctx.opcode = bswap32(ldl_code(ctx.nip)); |
6299 | 056401ea | j_mayer | } else {
|
6300 | 056401ea | j_mayer | ctx.opcode = ldl_code(ctx.nip); |
6301 | 111bfab3 | bellard | } |
6302 | 9fddaa0c | bellard | #if defined PPC_DEBUG_DISAS
|
6303 | 9fddaa0c | bellard | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
6304 | 111bfab3 | bellard | fprintf(logfile, "translate opcode %08x (%02x %02x %02x) (%s)\n",
|
6305 | 9a64fbe4 | bellard | ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode), |
6306 | 056401ea | j_mayer | opc3(ctx.opcode), little_endian ? "little" : "big"); |
6307 | 79aceca5 | bellard | } |
6308 | 79aceca5 | bellard | #endif
|
6309 | 046d6672 | bellard | ctx.nip += 4;
|
6310 | 3fc6c082 | bellard | table = env->opcodes; |
6311 | 2e70f6ef | pbrook | num_insns++; |
6312 | 79aceca5 | bellard | handler = table[opc1(ctx.opcode)]; |
6313 | 79aceca5 | bellard | if (is_indirect_opcode(handler)) {
|
6314 | 79aceca5 | bellard | table = ind_table(handler); |
6315 | 79aceca5 | bellard | handler = table[opc2(ctx.opcode)]; |
6316 | 79aceca5 | bellard | if (is_indirect_opcode(handler)) {
|
6317 | 79aceca5 | bellard | table = ind_table(handler); |
6318 | 79aceca5 | bellard | handler = table[opc3(ctx.opcode)]; |
6319 | 79aceca5 | bellard | } |
6320 | 79aceca5 | bellard | } |
6321 | 79aceca5 | bellard | /* Is opcode *REALLY* valid ? */
|
6322 | 76a66253 | j_mayer | if (unlikely(handler->handler == &gen_invalid)) {
|
6323 | 4a057712 | j_mayer | if (loglevel != 0) { |
6324 | 76a66253 | j_mayer | fprintf(logfile, "invalid/unsupported opcode: "
|
6325 | 6b542af7 | j_mayer | "%02x - %02x - %02x (%08x) " ADDRX " %d\n", |
6326 | 76a66253 | j_mayer | opc1(ctx.opcode), opc2(ctx.opcode), |
6327 | 0411a972 | j_mayer | opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir); |
6328 | 4b3686fa | bellard | } else {
|
6329 | 4b3686fa | bellard | printf("invalid/unsupported opcode: "
|
6330 | 6b542af7 | j_mayer | "%02x - %02x - %02x (%08x) " ADDRX " %d\n", |
6331 | 4b3686fa | bellard | opc1(ctx.opcode), opc2(ctx.opcode), |
6332 | 0411a972 | j_mayer | opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir); |
6333 | 4b3686fa | bellard | } |
6334 | 76a66253 | j_mayer | } else {
|
6335 | 76a66253 | j_mayer | if (unlikely((ctx.opcode & handler->inval) != 0)) { |
6336 | 4a057712 | j_mayer | if (loglevel != 0) { |
6337 | 79aceca5 | bellard | fprintf(logfile, "invalid bits: %08x for opcode: "
|
6338 | 6b542af7 | j_mayer | "%02x - %02x - %02x (%08x) " ADDRX "\n", |
6339 | 79aceca5 | bellard | ctx.opcode & handler->inval, opc1(ctx.opcode), |
6340 | 79aceca5 | bellard | opc2(ctx.opcode), opc3(ctx.opcode), |
6341 | 046d6672 | bellard | ctx.opcode, ctx.nip - 4);
|
6342 | 9a64fbe4 | bellard | } else {
|
6343 | 9a64fbe4 | bellard | printf("invalid bits: %08x for opcode: "
|
6344 | 6b542af7 | j_mayer | "%02x - %02x - %02x (%08x) " ADDRX "\n", |
6345 | 76a66253 | j_mayer | ctx.opcode & handler->inval, opc1(ctx.opcode), |
6346 | 76a66253 | j_mayer | opc2(ctx.opcode), opc3(ctx.opcode), |
6347 | 046d6672 | bellard | ctx.opcode, ctx.nip - 4);
|
6348 | 76a66253 | j_mayer | } |
6349 | e1833e1f | j_mayer | GEN_EXCP_INVAL(ctxp); |
6350 | 4b3686fa | bellard | break;
|
6351 | 79aceca5 | bellard | } |
6352 | 79aceca5 | bellard | } |
6353 | 4b3686fa | bellard | (*(handler->handler))(&ctx); |
6354 | 76a66253 | j_mayer | #if defined(DO_PPC_STATISTICS)
|
6355 | 76a66253 | j_mayer | handler->count++; |
6356 | 76a66253 | j_mayer | #endif
|
6357 | 9a64fbe4 | bellard | /* Check trace mode exceptions */
|
6358 | 8cbcb4fa | aurel32 | if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
|
6359 | 8cbcb4fa | aurel32 | (ctx.nip <= 0x100 || ctx.nip > 0xF00) && |
6360 | 8cbcb4fa | aurel32 | ctx.exception != POWERPC_SYSCALL && |
6361 | 8cbcb4fa | aurel32 | ctx.exception != POWERPC_EXCP_TRAP && |
6362 | 8cbcb4fa | aurel32 | ctx.exception != POWERPC_EXCP_BRANCH)) { |
6363 | e1833e1f | j_mayer | GEN_EXCP(ctxp, POWERPC_EXCP_TRACE, 0);
|
6364 | d26bfc9a | j_mayer | } else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) || |
6365 | 2e70f6ef | pbrook | (env->singlestep_enabled) || |
6366 | 2e70f6ef | pbrook | num_insns >= max_insns)) { |
6367 | d26bfc9a | j_mayer | /* if we reach a page boundary or are single stepping, stop
|
6368 | d26bfc9a | j_mayer | * generation
|
6369 | d26bfc9a | j_mayer | */
|
6370 | 8dd4983c | bellard | break;
|
6371 | 76a66253 | j_mayer | } |
6372 | 3fc6c082 | bellard | #if defined (DO_SINGLE_STEP)
|
6373 | 3fc6c082 | bellard | break;
|
6374 | 3fc6c082 | bellard | #endif
|
6375 | 3fc6c082 | bellard | } |
6376 | 2e70f6ef | pbrook | if (tb->cflags & CF_LAST_IO)
|
6377 | 2e70f6ef | pbrook | gen_io_end(); |
6378 | e1833e1f | j_mayer | if (ctx.exception == POWERPC_EXCP_NONE) {
|
6379 | c1942362 | bellard | gen_goto_tb(&ctx, 0, ctx.nip);
|
6380 | e1833e1f | j_mayer | } else if (ctx.exception != POWERPC_EXCP_BRANCH) { |
6381 | 8cbcb4fa | aurel32 | if (unlikely(env->singlestep_enabled)) {
|
6382 | 8cbcb4fa | aurel32 | gen_update_nip(&ctx, ctx.nip); |
6383 | 8cbcb4fa | aurel32 | gen_op_debug(); |
6384 | 8cbcb4fa | aurel32 | } |
6385 | 76a66253 | j_mayer | /* Generate the return instruction */
|
6386 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
6387 | 9a64fbe4 | bellard | } |
6388 | 2e70f6ef | pbrook | gen_icount_end(tb, num_insns); |
6389 | 79aceca5 | bellard | *gen_opc_ptr = INDEX_op_end; |
6390 | 76a66253 | j_mayer | if (unlikely(search_pc)) {
|
6391 | 9a64fbe4 | bellard | j = gen_opc_ptr - gen_opc_buf; |
6392 | 9a64fbe4 | bellard | lj++; |
6393 | 9a64fbe4 | bellard | while (lj <= j)
|
6394 | 9a64fbe4 | bellard | gen_opc_instr_start[lj++] = 0;
|
6395 | 9a64fbe4 | bellard | } else {
|
6396 | 046d6672 | bellard | tb->size = ctx.nip - pc_start; |
6397 | 2e70f6ef | pbrook | tb->icount = num_insns; |
6398 | 9a64fbe4 | bellard | } |
6399 | d9bce9d9 | j_mayer | #if defined(DEBUG_DISAS)
|
6400 | 9fddaa0c | bellard | if (loglevel & CPU_LOG_TB_CPU) {
|
6401 | 9a64fbe4 | bellard | fprintf(logfile, "---------------- excp: %04x\n", ctx.exception);
|
6402 | 7fe48483 | bellard | cpu_dump_state(env, logfile, fprintf, 0);
|
6403 | 9fddaa0c | bellard | } |
6404 | 9fddaa0c | bellard | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
6405 | 76a66253 | j_mayer | int flags;
|
6406 | 237c0af0 | j_mayer | flags = env->bfd_mach; |
6407 | 056401ea | j_mayer | flags |= little_endian << 16;
|
6408 | 0fa85d43 | bellard | fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
|
6409 | 76a66253 | j_mayer | target_disas(logfile, pc_start, ctx.nip - pc_start, flags); |
6410 | 79aceca5 | bellard | fprintf(logfile, "\n");
|
6411 | 9fddaa0c | bellard | } |
6412 | 79aceca5 | bellard | #endif
|
6413 | 79aceca5 | bellard | } |
6414 | 79aceca5 | bellard | |
6415 | 2cfc5f17 | ths | void gen_intermediate_code (CPUState *env, struct TranslationBlock *tb) |
6416 | 79aceca5 | bellard | { |
6417 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 0);
|
6418 | 79aceca5 | bellard | } |
6419 | 79aceca5 | bellard | |
6420 | 2cfc5f17 | ths | void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb) |
6421 | 79aceca5 | bellard | { |
6422 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 1);
|
6423 | 79aceca5 | bellard | } |
6424 | d2856f1a | aurel32 | |
6425 | d2856f1a | aurel32 | void gen_pc_load(CPUState *env, TranslationBlock *tb,
|
6426 | d2856f1a | aurel32 | unsigned long searched_pc, int pc_pos, void *puc) |
6427 | d2856f1a | aurel32 | { |
6428 | d2856f1a | aurel32 | int type, c;
|
6429 | d2856f1a | aurel32 | /* for PPC, we need to look at the micro operation to get the
|
6430 | d2856f1a | aurel32 | * access type */
|
6431 | d2856f1a | aurel32 | env->nip = gen_opc_pc[pc_pos]; |
6432 | d2856f1a | aurel32 | c = gen_opc_buf[pc_pos]; |
6433 | d2856f1a | aurel32 | switch(c) {
|
6434 | d2856f1a | aurel32 | #if defined(CONFIG_USER_ONLY)
|
6435 | d2856f1a | aurel32 | #define CASE3(op)\
|
6436 | d2856f1a | aurel32 | case INDEX_op_ ## op ## _raw |
6437 | d2856f1a | aurel32 | #else
|
6438 | d2856f1a | aurel32 | #define CASE3(op)\
|
6439 | d2856f1a | aurel32 | case INDEX_op_ ## op ## _user:\ |
6440 | d2856f1a | aurel32 | case INDEX_op_ ## op ## _kernel:\ |
6441 | d2856f1a | aurel32 | case INDEX_op_ ## op ## _hypv |
6442 | d2856f1a | aurel32 | #endif
|
6443 | d2856f1a | aurel32 | |
6444 | d2856f1a | aurel32 | CASE3(stfd): |
6445 | d2856f1a | aurel32 | CASE3(stfs): |
6446 | d2856f1a | aurel32 | CASE3(lfd): |
6447 | d2856f1a | aurel32 | CASE3(lfs): |
6448 | d2856f1a | aurel32 | type = ACCESS_FLOAT; |
6449 | d2856f1a | aurel32 | break;
|
6450 | d2856f1a | aurel32 | CASE3(lwarx): |
6451 | d2856f1a | aurel32 | type = ACCESS_RES; |
6452 | d2856f1a | aurel32 | break;
|
6453 | d2856f1a | aurel32 | CASE3(stwcx): |
6454 | d2856f1a | aurel32 | type = ACCESS_RES; |
6455 | d2856f1a | aurel32 | break;
|
6456 | d2856f1a | aurel32 | CASE3(eciwx): |
6457 | d2856f1a | aurel32 | CASE3(ecowx): |
6458 | d2856f1a | aurel32 | type = ACCESS_EXT; |
6459 | d2856f1a | aurel32 | break;
|
6460 | d2856f1a | aurel32 | default:
|
6461 | d2856f1a | aurel32 | type = ACCESS_INT; |
6462 | d2856f1a | aurel32 | break;
|
6463 | d2856f1a | aurel32 | } |
6464 | d2856f1a | aurel32 | env->access_type = type; |
6465 | d2856f1a | aurel32 | } |