root / tcg / hppa / tcg-target.c @ 678803ab
History | View | Annotate | Download (28.9 kB)
1 | f54b3f92 | aurel32 | /*
|
---|---|---|---|
2 | f54b3f92 | aurel32 | * Tiny Code Generator for QEMU
|
3 | f54b3f92 | aurel32 | *
|
4 | f54b3f92 | aurel32 | * Copyright (c) 2008 Fabrice Bellard
|
5 | f54b3f92 | aurel32 | *
|
6 | f54b3f92 | aurel32 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | f54b3f92 | aurel32 | * of this software and associated documentation files (the "Software"), to deal
|
8 | f54b3f92 | aurel32 | * in the Software without restriction, including without limitation the rights
|
9 | f54b3f92 | aurel32 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | f54b3f92 | aurel32 | * copies of the Software, and to permit persons to whom the Software is
|
11 | f54b3f92 | aurel32 | * furnished to do so, subject to the following conditions:
|
12 | f54b3f92 | aurel32 | *
|
13 | f54b3f92 | aurel32 | * The above copyright notice and this permission notice shall be included in
|
14 | f54b3f92 | aurel32 | * all copies or substantial portions of the Software.
|
15 | f54b3f92 | aurel32 | *
|
16 | f54b3f92 | aurel32 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | f54b3f92 | aurel32 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | f54b3f92 | aurel32 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | f54b3f92 | aurel32 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | f54b3f92 | aurel32 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | f54b3f92 | aurel32 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | f54b3f92 | aurel32 | * THE SOFTWARE.
|
23 | f54b3f92 | aurel32 | */
|
24 | f54b3f92 | aurel32 | |
25 | f54b3f92 | aurel32 | static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { |
26 | f54b3f92 | aurel32 | "%r0",
|
27 | f54b3f92 | aurel32 | "%r1",
|
28 | f54b3f92 | aurel32 | "%rp",
|
29 | f54b3f92 | aurel32 | "%r3",
|
30 | f54b3f92 | aurel32 | "%r4",
|
31 | f54b3f92 | aurel32 | "%r5",
|
32 | f54b3f92 | aurel32 | "%r6",
|
33 | f54b3f92 | aurel32 | "%r7",
|
34 | f54b3f92 | aurel32 | "%r8",
|
35 | f54b3f92 | aurel32 | "%r9",
|
36 | f54b3f92 | aurel32 | "%r10",
|
37 | f54b3f92 | aurel32 | "%r11",
|
38 | f54b3f92 | aurel32 | "%r12",
|
39 | f54b3f92 | aurel32 | "%r13",
|
40 | f54b3f92 | aurel32 | "%r14",
|
41 | f54b3f92 | aurel32 | "%r15",
|
42 | f54b3f92 | aurel32 | "%r16",
|
43 | f54b3f92 | aurel32 | "%r17",
|
44 | f54b3f92 | aurel32 | "%r18",
|
45 | f54b3f92 | aurel32 | "%r19",
|
46 | f54b3f92 | aurel32 | "%r20",
|
47 | f54b3f92 | aurel32 | "%r21",
|
48 | f54b3f92 | aurel32 | "%r22",
|
49 | f54b3f92 | aurel32 | "%r23",
|
50 | f54b3f92 | aurel32 | "%r24",
|
51 | f54b3f92 | aurel32 | "%r25",
|
52 | f54b3f92 | aurel32 | "%r26",
|
53 | f54b3f92 | aurel32 | "%dp",
|
54 | f54b3f92 | aurel32 | "%ret0",
|
55 | f54b3f92 | aurel32 | "%ret1",
|
56 | f54b3f92 | aurel32 | "%sp",
|
57 | f54b3f92 | aurel32 | "%r31",
|
58 | f54b3f92 | aurel32 | }; |
59 | f54b3f92 | aurel32 | |
60 | f54b3f92 | aurel32 | static const int tcg_target_reg_alloc_order[] = { |
61 | f54b3f92 | aurel32 | TCG_REG_R4, |
62 | f54b3f92 | aurel32 | TCG_REG_R5, |
63 | f54b3f92 | aurel32 | TCG_REG_R6, |
64 | f54b3f92 | aurel32 | TCG_REG_R7, |
65 | f54b3f92 | aurel32 | TCG_REG_R8, |
66 | f54b3f92 | aurel32 | TCG_REG_R9, |
67 | f54b3f92 | aurel32 | TCG_REG_R10, |
68 | f54b3f92 | aurel32 | TCG_REG_R11, |
69 | f54b3f92 | aurel32 | TCG_REG_R12, |
70 | f54b3f92 | aurel32 | TCG_REG_R13, |
71 | f54b3f92 | aurel32 | |
72 | f54b3f92 | aurel32 | TCG_REG_R17, |
73 | f54b3f92 | aurel32 | TCG_REG_R14, |
74 | f54b3f92 | aurel32 | TCG_REG_R15, |
75 | f54b3f92 | aurel32 | TCG_REG_R16, |
76 | f54b3f92 | aurel32 | }; |
77 | f54b3f92 | aurel32 | |
78 | f54b3f92 | aurel32 | static const int tcg_target_call_iarg_regs[4] = { |
79 | f54b3f92 | aurel32 | TCG_REG_R26, |
80 | f54b3f92 | aurel32 | TCG_REG_R25, |
81 | f54b3f92 | aurel32 | TCG_REG_R24, |
82 | f54b3f92 | aurel32 | TCG_REG_R23, |
83 | f54b3f92 | aurel32 | }; |
84 | f54b3f92 | aurel32 | |
85 | f54b3f92 | aurel32 | static const int tcg_target_call_oarg_regs[2] = { |
86 | f54b3f92 | aurel32 | TCG_REG_RET0, |
87 | f54b3f92 | aurel32 | TCG_REG_RET1, |
88 | f54b3f92 | aurel32 | }; |
89 | f54b3f92 | aurel32 | |
90 | f54b3f92 | aurel32 | static void patch_reloc(uint8_t *code_ptr, int type, |
91 | f54b3f92 | aurel32 | tcg_target_long value, tcg_target_long addend) |
92 | f54b3f92 | aurel32 | { |
93 | f54b3f92 | aurel32 | switch (type) {
|
94 | f54b3f92 | aurel32 | case R_PARISC_PCREL17F:
|
95 | f54b3f92 | aurel32 | hppa_patch17f((uint32_t *)code_ptr, value, addend); |
96 | f54b3f92 | aurel32 | break;
|
97 | f54b3f92 | aurel32 | default:
|
98 | f54b3f92 | aurel32 | tcg_abort(); |
99 | f54b3f92 | aurel32 | } |
100 | f54b3f92 | aurel32 | } |
101 | f54b3f92 | aurel32 | |
102 | f54b3f92 | aurel32 | /* maximum number of register used for input function arguments */
|
103 | f54b3f92 | aurel32 | static inline int tcg_target_get_call_iarg_regs_count(int flags) |
104 | f54b3f92 | aurel32 | { |
105 | f54b3f92 | aurel32 | return 4; |
106 | f54b3f92 | aurel32 | } |
107 | f54b3f92 | aurel32 | |
108 | f54b3f92 | aurel32 | /* parse target specific constraints */
|
109 | f54b3f92 | aurel32 | int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) |
110 | f54b3f92 | aurel32 | { |
111 | f54b3f92 | aurel32 | const char *ct_str; |
112 | f54b3f92 | aurel32 | |
113 | f54b3f92 | aurel32 | ct_str = *pct_str; |
114 | f54b3f92 | aurel32 | switch (ct_str[0]) { |
115 | f54b3f92 | aurel32 | case 'r': |
116 | f54b3f92 | aurel32 | ct->ct |= TCG_CT_REG; |
117 | f54b3f92 | aurel32 | tcg_regset_set32(ct->u.regs, 0, 0xffffffff); |
118 | f54b3f92 | aurel32 | break;
|
119 | f54b3f92 | aurel32 | case 'L': /* qemu_ld/st constraint */ |
120 | f54b3f92 | aurel32 | ct->ct |= TCG_CT_REG; |
121 | f54b3f92 | aurel32 | tcg_regset_set32(ct->u.regs, 0, 0xffffffff); |
122 | f54b3f92 | aurel32 | tcg_regset_reset_reg(ct->u.regs, TCG_REG_R26); |
123 | f54b3f92 | aurel32 | tcg_regset_reset_reg(ct->u.regs, TCG_REG_R25); |
124 | f54b3f92 | aurel32 | tcg_regset_reset_reg(ct->u.regs, TCG_REG_R24); |
125 | f54b3f92 | aurel32 | tcg_regset_reset_reg(ct->u.regs, TCG_REG_R23); |
126 | f54b3f92 | aurel32 | break;
|
127 | f54b3f92 | aurel32 | default:
|
128 | f54b3f92 | aurel32 | return -1; |
129 | f54b3f92 | aurel32 | } |
130 | f54b3f92 | aurel32 | ct_str++; |
131 | f54b3f92 | aurel32 | *pct_str = ct_str; |
132 | f54b3f92 | aurel32 | return 0; |
133 | f54b3f92 | aurel32 | } |
134 | f54b3f92 | aurel32 | |
135 | f54b3f92 | aurel32 | /* test if a constant matches the constraint */
|
136 | f54b3f92 | aurel32 | static inline int tcg_target_const_match(tcg_target_long val, |
137 | f54b3f92 | aurel32 | const TCGArgConstraint *arg_ct)
|
138 | f54b3f92 | aurel32 | { |
139 | f54b3f92 | aurel32 | int ct;
|
140 | f54b3f92 | aurel32 | |
141 | f54b3f92 | aurel32 | ct = arg_ct->ct; |
142 | f54b3f92 | aurel32 | |
143 | f54b3f92 | aurel32 | /* TODO */
|
144 | f54b3f92 | aurel32 | |
145 | f54b3f92 | aurel32 | return 0; |
146 | f54b3f92 | aurel32 | } |
147 | f54b3f92 | aurel32 | |
148 | f54b3f92 | aurel32 | #define INSN_OP(x) ((x) << 26) |
149 | f54b3f92 | aurel32 | #define INSN_EXT3BR(x) ((x) << 13) |
150 | f54b3f92 | aurel32 | #define INSN_EXT3SH(x) ((x) << 10) |
151 | f54b3f92 | aurel32 | #define INSN_EXT4(x) ((x) << 6) |
152 | f54b3f92 | aurel32 | #define INSN_EXT5(x) (x)
|
153 | f54b3f92 | aurel32 | #define INSN_EXT6(x) ((x) << 6) |
154 | f54b3f92 | aurel32 | #define INSN_EXT7(x) ((x) << 6) |
155 | f54b3f92 | aurel32 | #define INSN_EXT8A(x) ((x) << 6) |
156 | f54b3f92 | aurel32 | #define INSN_EXT8B(x) ((x) << 5) |
157 | f54b3f92 | aurel32 | #define INSN_T(x) (x)
|
158 | f54b3f92 | aurel32 | #define INSN_R1(x) ((x) << 16) |
159 | f54b3f92 | aurel32 | #define INSN_R2(x) ((x) << 21) |
160 | f54b3f92 | aurel32 | #define INSN_DEP_LEN(x) (32 - (x)) |
161 | f54b3f92 | aurel32 | #define INSN_SHDEP_CP(x) ((31 - (x)) << 5) |
162 | f54b3f92 | aurel32 | #define INSN_SHDEP_P(x) ((x) << 5) |
163 | f54b3f92 | aurel32 | #define INSN_COND(x) ((x) << 13) |
164 | f54b3f92 | aurel32 | |
165 | f54b3f92 | aurel32 | #define COND_NEVER 0 |
166 | f54b3f92 | aurel32 | #define COND_EQUAL 1 |
167 | f54b3f92 | aurel32 | #define COND_LT 2 |
168 | f54b3f92 | aurel32 | #define COND_LTEQ 3 |
169 | f54b3f92 | aurel32 | #define COND_LTU 4 |
170 | f54b3f92 | aurel32 | #define COND_LTUEQ 5 |
171 | f54b3f92 | aurel32 | #define COND_SV 6 |
172 | f54b3f92 | aurel32 | #define COND_OD 7 |
173 | f54b3f92 | aurel32 | |
174 | f54b3f92 | aurel32 | |
175 | f54b3f92 | aurel32 | /* Logical ADD */
|
176 | f54b3f92 | aurel32 | #define ARITH_ADD (INSN_OP(0x02) | INSN_EXT6(0x28)) |
177 | f54b3f92 | aurel32 | #define ARITH_AND (INSN_OP(0x02) | INSN_EXT6(0x08)) |
178 | f54b3f92 | aurel32 | #define ARITH_OR (INSN_OP(0x02) | INSN_EXT6(0x09)) |
179 | f54b3f92 | aurel32 | #define ARITH_XOR (INSN_OP(0x02) | INSN_EXT6(0x0a)) |
180 | f54b3f92 | aurel32 | #define ARITH_SUB (INSN_OP(0x02) | INSN_EXT6(0x10)) |
181 | f54b3f92 | aurel32 | |
182 | f54b3f92 | aurel32 | #define SHD (INSN_OP(0x34) | INSN_EXT3SH(2)) |
183 | f54b3f92 | aurel32 | #define VSHD (INSN_OP(0x34) | INSN_EXT3SH(0)) |
184 | f54b3f92 | aurel32 | #define DEP (INSN_OP(0x35) | INSN_EXT3SH(3)) |
185 | f54b3f92 | aurel32 | #define ZDEP (INSN_OP(0x35) | INSN_EXT3SH(2)) |
186 | f54b3f92 | aurel32 | #define ZVDEP (INSN_OP(0x35) | INSN_EXT3SH(0)) |
187 | f54b3f92 | aurel32 | #define EXTRU (INSN_OP(0x34) | INSN_EXT3SH(6)) |
188 | f54b3f92 | aurel32 | #define EXTRS (INSN_OP(0x34) | INSN_EXT3SH(7)) |
189 | f54b3f92 | aurel32 | #define VEXTRS (INSN_OP(0x34) | INSN_EXT3SH(5)) |
190 | f54b3f92 | aurel32 | |
191 | f54b3f92 | aurel32 | #define SUBI (INSN_OP(0x25)) |
192 | f54b3f92 | aurel32 | #define MTCTL (INSN_OP(0x00) | INSN_EXT8B(0xc2)) |
193 | f54b3f92 | aurel32 | |
194 | f54b3f92 | aurel32 | #define BL (INSN_OP(0x3a) | INSN_EXT3BR(0)) |
195 | f54b3f92 | aurel32 | #define BLE_SR4 (INSN_OP(0x39) | (1 << 13)) |
196 | f54b3f92 | aurel32 | #define BV (INSN_OP(0x3a) | INSN_EXT3BR(6)) |
197 | f54b3f92 | aurel32 | #define BV_N (INSN_OP(0x3a) | INSN_EXT3BR(6) | 2) |
198 | f54b3f92 | aurel32 | #define LDIL (INSN_OP(0x08)) |
199 | f54b3f92 | aurel32 | #define LDO (INSN_OP(0x0d)) |
200 | f54b3f92 | aurel32 | |
201 | f54b3f92 | aurel32 | #define LDB (INSN_OP(0x10)) |
202 | f54b3f92 | aurel32 | #define LDH (INSN_OP(0x11)) |
203 | f54b3f92 | aurel32 | #define LDW (INSN_OP(0x12)) |
204 | f54b3f92 | aurel32 | #define LDWM (INSN_OP(0x13)) |
205 | f54b3f92 | aurel32 | |
206 | f54b3f92 | aurel32 | #define STB (INSN_OP(0x18)) |
207 | f54b3f92 | aurel32 | #define STH (INSN_OP(0x19)) |
208 | f54b3f92 | aurel32 | #define STW (INSN_OP(0x1a)) |
209 | f54b3f92 | aurel32 | #define STWM (INSN_OP(0x1b)) |
210 | f54b3f92 | aurel32 | |
211 | f54b3f92 | aurel32 | #define COMBT (INSN_OP(0x20)) |
212 | f54b3f92 | aurel32 | #define COMBF (INSN_OP(0x22)) |
213 | f54b3f92 | aurel32 | |
214 | f54b3f92 | aurel32 | static int lowsignext(uint32_t val, int start, int length) |
215 | f54b3f92 | aurel32 | { |
216 | f54b3f92 | aurel32 | return (((val << 1) & ~(~0 << length)) | |
217 | f54b3f92 | aurel32 | ((val >> (length - 1)) & 1)) << start; |
218 | f54b3f92 | aurel32 | } |
219 | f54b3f92 | aurel32 | |
220 | f54b3f92 | aurel32 | static inline void tcg_out_mov(TCGContext *s, int ret, int arg) |
221 | f54b3f92 | aurel32 | { |
222 | f54b3f92 | aurel32 | /* PA1.1 defines COPY as OR r,0,t */
|
223 | f54b3f92 | aurel32 | tcg_out32(s, ARITH_OR | INSN_T(ret) | INSN_R1(arg) | INSN_R2(TCG_REG_R0)); |
224 | f54b3f92 | aurel32 | |
225 | f54b3f92 | aurel32 | /* PA2.0 defines COPY as LDO 0(r),t
|
226 | f54b3f92 | aurel32 | * but hppa-dis.c is unaware of this definition */
|
227 | f54b3f92 | aurel32 | /* tcg_out32(s, LDO | INSN_R1(ret) | INSN_R2(arg) | reassemble_14(0)); */
|
228 | f54b3f92 | aurel32 | } |
229 | f54b3f92 | aurel32 | |
230 | f54b3f92 | aurel32 | static inline void tcg_out_movi(TCGContext *s, TCGType type, |
231 | f54b3f92 | aurel32 | int ret, tcg_target_long arg)
|
232 | f54b3f92 | aurel32 | { |
233 | f54b3f92 | aurel32 | if (arg == (arg & 0x1fff)) { |
234 | f54b3f92 | aurel32 | tcg_out32(s, LDO | INSN_R1(ret) | INSN_R2(TCG_REG_R0) | |
235 | f54b3f92 | aurel32 | reassemble_14(arg)); |
236 | f54b3f92 | aurel32 | } else {
|
237 | f54b3f92 | aurel32 | tcg_out32(s, LDIL | INSN_R2(ret) | |
238 | f54b3f92 | aurel32 | reassemble_21(lrsel((uint32_t)arg, 0)));
|
239 | f54b3f92 | aurel32 | if (arg & 0x7ff) |
240 | f54b3f92 | aurel32 | tcg_out32(s, LDO | INSN_R1(ret) | INSN_R2(ret) | |
241 | f54b3f92 | aurel32 | reassemble_14(rrsel((uint32_t)arg, 0)));
|
242 | f54b3f92 | aurel32 | } |
243 | f54b3f92 | aurel32 | } |
244 | f54b3f92 | aurel32 | |
245 | f54b3f92 | aurel32 | static inline void tcg_out_ld_raw(TCGContext *s, int ret, |
246 | f54b3f92 | aurel32 | tcg_target_long arg) |
247 | f54b3f92 | aurel32 | { |
248 | f54b3f92 | aurel32 | tcg_out32(s, LDIL | INSN_R2(ret) | |
249 | f54b3f92 | aurel32 | reassemble_21(lrsel((uint32_t)arg, 0)));
|
250 | f54b3f92 | aurel32 | tcg_out32(s, LDW | INSN_R1(ret) | INSN_R2(ret) | |
251 | f54b3f92 | aurel32 | reassemble_14(rrsel((uint32_t)arg, 0)));
|
252 | f54b3f92 | aurel32 | } |
253 | f54b3f92 | aurel32 | |
254 | f54b3f92 | aurel32 | static inline void tcg_out_ld_ptr(TCGContext *s, int ret, |
255 | f54b3f92 | aurel32 | tcg_target_long arg) |
256 | f54b3f92 | aurel32 | { |
257 | f54b3f92 | aurel32 | tcg_out_ld_raw(s, ret, arg); |
258 | f54b3f92 | aurel32 | } |
259 | f54b3f92 | aurel32 | |
260 | f54b3f92 | aurel32 | static inline void tcg_out_ldst(TCGContext *s, int ret, int addr, int offset, |
261 | f54b3f92 | aurel32 | int op)
|
262 | f54b3f92 | aurel32 | { |
263 | f54b3f92 | aurel32 | if (offset == (offset & 0xfff)) |
264 | f54b3f92 | aurel32 | tcg_out32(s, op | INSN_R1(ret) | INSN_R2(addr) | |
265 | f54b3f92 | aurel32 | reassemble_14(offset)); |
266 | f54b3f92 | aurel32 | else {
|
267 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented %s with offset %d\n", __func__, offset);
|
268 | f54b3f92 | aurel32 | tcg_abort(); |
269 | f54b3f92 | aurel32 | } |
270 | f54b3f92 | aurel32 | } |
271 | f54b3f92 | aurel32 | |
272 | f54b3f92 | aurel32 | static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, |
273 | f54b3f92 | aurel32 | int arg1, tcg_target_long arg2)
|
274 | f54b3f92 | aurel32 | { |
275 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented %s\n", __func__);
|
276 | f54b3f92 | aurel32 | tcg_abort(); |
277 | f54b3f92 | aurel32 | } |
278 | f54b3f92 | aurel32 | |
279 | f54b3f92 | aurel32 | static inline void tcg_out_st(TCGContext *s, TCGType type, int ret, |
280 | f54b3f92 | aurel32 | int arg1, tcg_target_long arg2)
|
281 | f54b3f92 | aurel32 | { |
282 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented %s\n", __func__);
|
283 | f54b3f92 | aurel32 | tcg_abort(); |
284 | f54b3f92 | aurel32 | } |
285 | f54b3f92 | aurel32 | |
286 | f54b3f92 | aurel32 | static inline void tcg_out_arith(TCGContext *s, int t, int r1, int r2, int op) |
287 | f54b3f92 | aurel32 | { |
288 | f54b3f92 | aurel32 | tcg_out32(s, op | INSN_T(t) | INSN_R1(r1) | INSN_R2(r2)); |
289 | f54b3f92 | aurel32 | } |
290 | f54b3f92 | aurel32 | |
291 | f54b3f92 | aurel32 | static inline void tcg_out_arithi(TCGContext *s, int t, int r1, |
292 | f54b3f92 | aurel32 | tcg_target_long val, int op)
|
293 | f54b3f92 | aurel32 | { |
294 | f54b3f92 | aurel32 | tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R20, val); |
295 | f54b3f92 | aurel32 | tcg_out_arith(s, t, r1, TCG_REG_R20, op); |
296 | f54b3f92 | aurel32 | } |
297 | f54b3f92 | aurel32 | |
298 | f54b3f92 | aurel32 | static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val) |
299 | f54b3f92 | aurel32 | { |
300 | f54b3f92 | aurel32 | tcg_out_arithi(s, reg, reg, val, ARITH_ADD); |
301 | f54b3f92 | aurel32 | } |
302 | f54b3f92 | aurel32 | |
303 | f54b3f92 | aurel32 | static inline void tcg_out_nop(TCGContext *s) |
304 | f54b3f92 | aurel32 | { |
305 | f54b3f92 | aurel32 | tcg_out32(s, ARITH_OR | INSN_T(TCG_REG_R0) | INSN_R1(TCG_REG_R0) | |
306 | f54b3f92 | aurel32 | INSN_R2(TCG_REG_R0)); |
307 | f54b3f92 | aurel32 | } |
308 | f54b3f92 | aurel32 | |
309 | f54b3f92 | aurel32 | static inline void tcg_out_ext8s(TCGContext *s, int ret, int arg) { |
310 | f54b3f92 | aurel32 | tcg_out32(s, EXTRS | INSN_R1(ret) | INSN_R2(arg) | |
311 | f54b3f92 | aurel32 | INSN_SHDEP_P(31) | INSN_DEP_LEN(8)); |
312 | f54b3f92 | aurel32 | } |
313 | f54b3f92 | aurel32 | |
314 | f54b3f92 | aurel32 | static inline void tcg_out_ext16s(TCGContext *s, int ret, int arg) { |
315 | f54b3f92 | aurel32 | tcg_out32(s, EXTRS | INSN_R1(ret) | INSN_R2(arg) | |
316 | f54b3f92 | aurel32 | INSN_SHDEP_P(31) | INSN_DEP_LEN(16)); |
317 | f54b3f92 | aurel32 | } |
318 | f54b3f92 | aurel32 | |
319 | f54b3f92 | aurel32 | static inline void tcg_out_bswap16(TCGContext *s, int ret, int arg) { |
320 | f54b3f92 | aurel32 | if(ret != arg)
|
321 | f54b3f92 | aurel32 | tcg_out_mov(s, ret, arg); |
322 | f54b3f92 | aurel32 | tcg_out32(s, DEP | INSN_R2(ret) | INSN_R1(ret) | |
323 | f54b3f92 | aurel32 | INSN_SHDEP_CP(15) | INSN_DEP_LEN(8)); |
324 | f54b3f92 | aurel32 | tcg_out32(s, SHD | INSN_T(ret) | INSN_R1(TCG_REG_R0) | |
325 | f54b3f92 | aurel32 | INSN_R2(ret) | INSN_SHDEP_CP(8));
|
326 | f54b3f92 | aurel32 | } |
327 | f54b3f92 | aurel32 | |
328 | f54b3f92 | aurel32 | static inline void tcg_out_bswap32(TCGContext *s, int ret, int arg, int temp) { |
329 | f54b3f92 | aurel32 | tcg_out32(s, SHD | INSN_T(temp) | INSN_R1(arg) | |
330 | f54b3f92 | aurel32 | INSN_R2(arg) | INSN_SHDEP_CP(16));
|
331 | f54b3f92 | aurel32 | tcg_out32(s, DEP | INSN_R2(temp) | INSN_R1(temp) | |
332 | f54b3f92 | aurel32 | INSN_SHDEP_CP(15) | INSN_DEP_LEN(8)); |
333 | f54b3f92 | aurel32 | tcg_out32(s, SHD | INSN_T(ret) | INSN_R1(arg) | |
334 | f54b3f92 | aurel32 | INSN_R2(temp) | INSN_SHDEP_CP(8));
|
335 | f54b3f92 | aurel32 | } |
336 | f54b3f92 | aurel32 | |
337 | f54b3f92 | aurel32 | static inline void tcg_out_call(TCGContext *s, void *func) |
338 | f54b3f92 | aurel32 | { |
339 | f54b3f92 | aurel32 | uint32_t val = (uint32_t)__canonicalize_funcptr_for_compare(func); |
340 | f54b3f92 | aurel32 | tcg_out32(s, LDIL | INSN_R2(TCG_REG_R20) | |
341 | f54b3f92 | aurel32 | reassemble_21(lrsel(val, 0)));
|
342 | f54b3f92 | aurel32 | tcg_out32(s, BLE_SR4 | INSN_R2(TCG_REG_R20) | |
343 | f54b3f92 | aurel32 | reassemble_17(rrsel(val, 0) >> 2)); |
344 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_RP, TCG_REG_R31); |
345 | f54b3f92 | aurel32 | } |
346 | f54b3f92 | aurel32 | |
347 | f54b3f92 | aurel32 | #if defined(CONFIG_SOFTMMU)
|
348 | f54b3f92 | aurel32 | extern void __ldb_mmu(void); |
349 | f54b3f92 | aurel32 | extern void __ldw_mmu(void); |
350 | f54b3f92 | aurel32 | extern void __ldl_mmu(void); |
351 | f54b3f92 | aurel32 | extern void __ldq_mmu(void); |
352 | f54b3f92 | aurel32 | |
353 | f54b3f92 | aurel32 | extern void __stb_mmu(void); |
354 | f54b3f92 | aurel32 | extern void __stw_mmu(void); |
355 | f54b3f92 | aurel32 | extern void __stl_mmu(void); |
356 | f54b3f92 | aurel32 | extern void __stq_mmu(void); |
357 | f54b3f92 | aurel32 | |
358 | f54b3f92 | aurel32 | static void *qemu_ld_helpers[4] = { |
359 | f54b3f92 | aurel32 | __ldb_mmu, |
360 | f54b3f92 | aurel32 | __ldw_mmu, |
361 | f54b3f92 | aurel32 | __ldl_mmu, |
362 | f54b3f92 | aurel32 | __ldq_mmu, |
363 | f54b3f92 | aurel32 | }; |
364 | f54b3f92 | aurel32 | |
365 | f54b3f92 | aurel32 | static void *qemu_st_helpers[4] = { |
366 | f54b3f92 | aurel32 | __stb_mmu, |
367 | f54b3f92 | aurel32 | __stw_mmu, |
368 | f54b3f92 | aurel32 | __stl_mmu, |
369 | f54b3f92 | aurel32 | __stq_mmu, |
370 | f54b3f92 | aurel32 | }; |
371 | f54b3f92 | aurel32 | #endif
|
372 | f54b3f92 | aurel32 | |
373 | f54b3f92 | aurel32 | static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc) |
374 | f54b3f92 | aurel32 | { |
375 | f54b3f92 | aurel32 | int addr_reg, data_reg, data_reg2, r0, r1, mem_index, s_bits, bswap;
|
376 | f54b3f92 | aurel32 | #if defined(CONFIG_SOFTMMU)
|
377 | f54b3f92 | aurel32 | uint32_t *label1_ptr, *label2_ptr; |
378 | f54b3f92 | aurel32 | #endif
|
379 | f54b3f92 | aurel32 | #if TARGET_LONG_BITS == 64 |
380 | f54b3f92 | aurel32 | #if defined(CONFIG_SOFTMMU)
|
381 | f54b3f92 | aurel32 | uint32_t *label3_ptr; |
382 | f54b3f92 | aurel32 | #endif
|
383 | f54b3f92 | aurel32 | int addr_reg2;
|
384 | f54b3f92 | aurel32 | #endif
|
385 | f54b3f92 | aurel32 | |
386 | f54b3f92 | aurel32 | data_reg = *args++; |
387 | f54b3f92 | aurel32 | if (opc == 3) |
388 | f54b3f92 | aurel32 | data_reg2 = *args++; |
389 | f54b3f92 | aurel32 | else
|
390 | f54b3f92 | aurel32 | data_reg2 = 0; /* surpress warning */ |
391 | f54b3f92 | aurel32 | addr_reg = *args++; |
392 | f54b3f92 | aurel32 | #if TARGET_LONG_BITS == 64 |
393 | f54b3f92 | aurel32 | addr_reg2 = *args++; |
394 | f54b3f92 | aurel32 | #endif
|
395 | f54b3f92 | aurel32 | mem_index = *args; |
396 | f54b3f92 | aurel32 | s_bits = opc & 3;
|
397 | f54b3f92 | aurel32 | |
398 | f54b3f92 | aurel32 | r0 = TCG_REG_R26; |
399 | f54b3f92 | aurel32 | r1 = TCG_REG_R25; |
400 | f54b3f92 | aurel32 | |
401 | f54b3f92 | aurel32 | #if defined(CONFIG_SOFTMMU)
|
402 | f54b3f92 | aurel32 | tcg_out_mov(s, r1, addr_reg); |
403 | f54b3f92 | aurel32 | |
404 | f54b3f92 | aurel32 | tcg_out_mov(s, r0, addr_reg); |
405 | f54b3f92 | aurel32 | |
406 | f54b3f92 | aurel32 | tcg_out32(s, SHD | INSN_T(r1) | INSN_R1(TCG_REG_R0) | INSN_R2(r1) | |
407 | f54b3f92 | aurel32 | INSN_SHDEP_CP(TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS)); |
408 | f54b3f92 | aurel32 | |
409 | f54b3f92 | aurel32 | tcg_out_arithi(s, r0, r0, TARGET_PAGE_MASK | ((1 << s_bits) - 1), |
410 | f54b3f92 | aurel32 | ARITH_AND); |
411 | f54b3f92 | aurel32 | |
412 | f54b3f92 | aurel32 | tcg_out_arithi(s, r1, r1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS,
|
413 | f54b3f92 | aurel32 | ARITH_AND); |
414 | f54b3f92 | aurel32 | |
415 | f54b3f92 | aurel32 | tcg_out_arith(s, r1, r1, TCG_AREG0, ARITH_ADD); |
416 | f54b3f92 | aurel32 | tcg_out_arithi(s, r1, r1, |
417 | f54b3f92 | aurel32 | offsetof(CPUState, tlb_table[mem_index][0].addr_read),
|
418 | f54b3f92 | aurel32 | ARITH_ADD); |
419 | f54b3f92 | aurel32 | |
420 | f54b3f92 | aurel32 | tcg_out_ldst(s, TCG_REG_R20, r1, 0, LDW);
|
421 | f54b3f92 | aurel32 | |
422 | f54b3f92 | aurel32 | #if TARGET_LONG_BITS == 32 |
423 | f54b3f92 | aurel32 | /* if equal, jump to label1 */
|
424 | f54b3f92 | aurel32 | label1_ptr = (uint32_t *)s->code_ptr; |
425 | f54b3f92 | aurel32 | tcg_out32(s, COMBT | INSN_R1(TCG_REG_R20) | INSN_R2(r0) | |
426 | f54b3f92 | aurel32 | INSN_COND(COND_EQUAL)); |
427 | f54b3f92 | aurel32 | tcg_out_mov(s, r0, addr_reg); /* delay slot */
|
428 | f54b3f92 | aurel32 | #else
|
429 | f54b3f92 | aurel32 | /* if not equal, jump to label3 */
|
430 | f54b3f92 | aurel32 | label3_ptr = (uint32_t *)s->code_ptr; |
431 | f54b3f92 | aurel32 | tcg_out32(s, COMBF | INSN_R1(TCG_REG_R20) | INSN_R2(r0) | |
432 | f54b3f92 | aurel32 | INSN_COND(COND_EQUAL)); |
433 | f54b3f92 | aurel32 | tcg_out_mov(s, r0, addr_reg); /* delay slot */
|
434 | f54b3f92 | aurel32 | |
435 | f54b3f92 | aurel32 | tcg_out_ldst(s, TCG_REG_R20, r1, 4, LDW);
|
436 | f54b3f92 | aurel32 | |
437 | f54b3f92 | aurel32 | /* if equal, jump to label1 */
|
438 | f54b3f92 | aurel32 | label1_ptr = (uint32_t *)s->code_ptr; |
439 | f54b3f92 | aurel32 | tcg_out32(s, COMBT | INSN_R1(TCG_REG_R20) | INSN_R2(addr_reg2) | |
440 | f54b3f92 | aurel32 | INSN_COND(COND_EQUAL)); |
441 | f54b3f92 | aurel32 | tcg_out_nop(s); /* delay slot */
|
442 | f54b3f92 | aurel32 | |
443 | f54b3f92 | aurel32 | /* label3: */
|
444 | f54b3f92 | aurel32 | *label3_ptr |= reassemble_12((uint32_t *)s->code_ptr - label3_ptr - 2);
|
445 | f54b3f92 | aurel32 | #endif
|
446 | f54b3f92 | aurel32 | |
447 | f54b3f92 | aurel32 | #if TARGET_LONG_BITS == 32 |
448 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R26, addr_reg); |
449 | f54b3f92 | aurel32 | tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R25, mem_index); |
450 | f54b3f92 | aurel32 | #else
|
451 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R26, addr_reg); |
452 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R25, addr_reg2); |
453 | f54b3f92 | aurel32 | tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R24, mem_index); |
454 | f54b3f92 | aurel32 | #endif
|
455 | f54b3f92 | aurel32 | |
456 | f54b3f92 | aurel32 | tcg_out_call(s, qemu_ld_helpers[s_bits]); |
457 | f54b3f92 | aurel32 | |
458 | f54b3f92 | aurel32 | switch(opc) {
|
459 | f54b3f92 | aurel32 | case 0 | 4: |
460 | f54b3f92 | aurel32 | tcg_out_ext8s(s, data_reg, TCG_REG_RET0); |
461 | f54b3f92 | aurel32 | break;
|
462 | f54b3f92 | aurel32 | case 1 | 4: |
463 | f54b3f92 | aurel32 | tcg_out_ext16s(s, data_reg, TCG_REG_RET0); |
464 | f54b3f92 | aurel32 | break;
|
465 | f54b3f92 | aurel32 | case 0: |
466 | f54b3f92 | aurel32 | case 1: |
467 | f54b3f92 | aurel32 | case 2: |
468 | f54b3f92 | aurel32 | default:
|
469 | f54b3f92 | aurel32 | tcg_out_mov(s, data_reg, TCG_REG_RET0); |
470 | f54b3f92 | aurel32 | break;
|
471 | f54b3f92 | aurel32 | case 3: |
472 | f54b3f92 | aurel32 | tcg_abort(); |
473 | f54b3f92 | aurel32 | tcg_out_mov(s, data_reg, TCG_REG_RET0); |
474 | f54b3f92 | aurel32 | tcg_out_mov(s, data_reg2, TCG_REG_RET1); |
475 | f54b3f92 | aurel32 | break;
|
476 | f54b3f92 | aurel32 | } |
477 | f54b3f92 | aurel32 | |
478 | f54b3f92 | aurel32 | /* jump to label2 */
|
479 | f54b3f92 | aurel32 | label2_ptr = (uint32_t *)s->code_ptr; |
480 | f54b3f92 | aurel32 | tcg_out32(s, BL | INSN_R2(TCG_REG_R0) | 2);
|
481 | f54b3f92 | aurel32 | |
482 | f54b3f92 | aurel32 | /* label1: */
|
483 | f54b3f92 | aurel32 | *label1_ptr |= reassemble_12((uint32_t *)s->code_ptr - label1_ptr - 2);
|
484 | f54b3f92 | aurel32 | |
485 | f54b3f92 | aurel32 | tcg_out_arithi(s, TCG_REG_R20, r1, |
486 | f54b3f92 | aurel32 | offsetof(CPUTLBEntry, addend) - offsetof(CPUTLBEntry, addr_read), |
487 | f54b3f92 | aurel32 | ARITH_ADD); |
488 | f54b3f92 | aurel32 | tcg_out_ldst(s, TCG_REG_R20, TCG_REG_R20, 0, LDW);
|
489 | f54b3f92 | aurel32 | tcg_out_arith(s, r0, r0, TCG_REG_R20, ARITH_ADD); |
490 | f54b3f92 | aurel32 | #else
|
491 | f54b3f92 | aurel32 | r0 = addr_reg; |
492 | f54b3f92 | aurel32 | #endif
|
493 | f54b3f92 | aurel32 | |
494 | f54b3f92 | aurel32 | #ifdef TARGET_WORDS_BIGENDIAN
|
495 | f54b3f92 | aurel32 | bswap = 0;
|
496 | f54b3f92 | aurel32 | #else
|
497 | f54b3f92 | aurel32 | bswap = 1;
|
498 | f54b3f92 | aurel32 | #endif
|
499 | f54b3f92 | aurel32 | switch (opc) {
|
500 | f54b3f92 | aurel32 | case 0: |
501 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, LDB);
|
502 | f54b3f92 | aurel32 | break;
|
503 | f54b3f92 | aurel32 | case 0 | 4: |
504 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, LDB);
|
505 | f54b3f92 | aurel32 | tcg_out_ext8s(s, data_reg, data_reg); |
506 | f54b3f92 | aurel32 | break;
|
507 | f54b3f92 | aurel32 | case 1: |
508 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, LDH);
|
509 | f54b3f92 | aurel32 | if (bswap)
|
510 | f54b3f92 | aurel32 | tcg_out_bswap16(s, data_reg, data_reg); |
511 | f54b3f92 | aurel32 | break;
|
512 | f54b3f92 | aurel32 | case 1 | 4: |
513 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, LDH);
|
514 | f54b3f92 | aurel32 | if (bswap)
|
515 | f54b3f92 | aurel32 | tcg_out_bswap16(s, data_reg, data_reg); |
516 | f54b3f92 | aurel32 | tcg_out_ext16s(s, data_reg, data_reg); |
517 | f54b3f92 | aurel32 | break;
|
518 | f54b3f92 | aurel32 | case 2: |
519 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, LDW);
|
520 | f54b3f92 | aurel32 | if (bswap)
|
521 | f54b3f92 | aurel32 | tcg_out_bswap32(s, data_reg, data_reg, TCG_REG_R20); |
522 | f54b3f92 | aurel32 | break;
|
523 | f54b3f92 | aurel32 | case 3: |
524 | f54b3f92 | aurel32 | tcg_abort(); |
525 | f54b3f92 | aurel32 | if (!bswap) {
|
526 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, LDW);
|
527 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg2, r0, 4, LDW);
|
528 | f54b3f92 | aurel32 | } else {
|
529 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 4, LDW);
|
530 | f54b3f92 | aurel32 | tcg_out_bswap32(s, data_reg, data_reg, TCG_REG_R20); |
531 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg2, r0, 0, LDW);
|
532 | f54b3f92 | aurel32 | tcg_out_bswap32(s, data_reg2, data_reg2, TCG_REG_R20); |
533 | f54b3f92 | aurel32 | } |
534 | f54b3f92 | aurel32 | break;
|
535 | f54b3f92 | aurel32 | default:
|
536 | f54b3f92 | aurel32 | tcg_abort(); |
537 | f54b3f92 | aurel32 | } |
538 | f54b3f92 | aurel32 | |
539 | f54b3f92 | aurel32 | #if defined(CONFIG_SOFTMMU)
|
540 | f54b3f92 | aurel32 | /* label2: */
|
541 | f54b3f92 | aurel32 | *label2_ptr |= reassemble_17((uint32_t *)s->code_ptr - label2_ptr - 2);
|
542 | f54b3f92 | aurel32 | #endif
|
543 | f54b3f92 | aurel32 | } |
544 | f54b3f92 | aurel32 | |
545 | f54b3f92 | aurel32 | static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc) |
546 | f54b3f92 | aurel32 | { |
547 | f54b3f92 | aurel32 | int addr_reg, data_reg, data_reg2, r0, r1, mem_index, s_bits, bswap;
|
548 | f54b3f92 | aurel32 | #if defined(CONFIG_SOFTMMU)
|
549 | f54b3f92 | aurel32 | uint32_t *label1_ptr, *label2_ptr; |
550 | f54b3f92 | aurel32 | #endif
|
551 | f54b3f92 | aurel32 | #if TARGET_LONG_BITS == 64 |
552 | f54b3f92 | aurel32 | #if defined(CONFIG_SOFTMMU)
|
553 | f54b3f92 | aurel32 | uint32_t *label3_ptr; |
554 | f54b3f92 | aurel32 | #endif
|
555 | f54b3f92 | aurel32 | int addr_reg2;
|
556 | f54b3f92 | aurel32 | #endif
|
557 | f54b3f92 | aurel32 | |
558 | f54b3f92 | aurel32 | data_reg = *args++; |
559 | f54b3f92 | aurel32 | if (opc == 3) |
560 | f54b3f92 | aurel32 | data_reg2 = *args++; |
561 | f54b3f92 | aurel32 | else
|
562 | f54b3f92 | aurel32 | data_reg2 = 0; /* surpress warning */ |
563 | f54b3f92 | aurel32 | addr_reg = *args++; |
564 | f54b3f92 | aurel32 | #if TARGET_LONG_BITS == 64 |
565 | f54b3f92 | aurel32 | addr_reg2 = *args++; |
566 | f54b3f92 | aurel32 | #endif
|
567 | f54b3f92 | aurel32 | mem_index = *args; |
568 | f54b3f92 | aurel32 | |
569 | f54b3f92 | aurel32 | s_bits = opc; |
570 | f54b3f92 | aurel32 | |
571 | f54b3f92 | aurel32 | r0 = TCG_REG_R26; |
572 | f54b3f92 | aurel32 | r1 = TCG_REG_R25; |
573 | f54b3f92 | aurel32 | |
574 | f54b3f92 | aurel32 | #if defined(CONFIG_SOFTMMU)
|
575 | f54b3f92 | aurel32 | tcg_out_mov(s, r1, addr_reg); |
576 | f54b3f92 | aurel32 | |
577 | f54b3f92 | aurel32 | tcg_out_mov(s, r0, addr_reg); |
578 | f54b3f92 | aurel32 | |
579 | f54b3f92 | aurel32 | tcg_out32(s, SHD | INSN_T(r1) | INSN_R1(TCG_REG_R0) | INSN_R2(r1) | |
580 | f54b3f92 | aurel32 | INSN_SHDEP_CP(TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS)); |
581 | f54b3f92 | aurel32 | |
582 | f54b3f92 | aurel32 | tcg_out_arithi(s, r0, r0, TARGET_PAGE_MASK | ((1 << s_bits) - 1), |
583 | f54b3f92 | aurel32 | ARITH_AND); |
584 | f54b3f92 | aurel32 | |
585 | f54b3f92 | aurel32 | tcg_out_arithi(s, r1, r1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS,
|
586 | f54b3f92 | aurel32 | ARITH_AND); |
587 | f54b3f92 | aurel32 | |
588 | f54b3f92 | aurel32 | tcg_out_arith(s, r1, r1, TCG_AREG0, ARITH_ADD); |
589 | f54b3f92 | aurel32 | tcg_out_arithi(s, r1, r1, |
590 | f54b3f92 | aurel32 | offsetof(CPUState, tlb_table[mem_index][0].addr_write),
|
591 | f54b3f92 | aurel32 | ARITH_ADD); |
592 | f54b3f92 | aurel32 | |
593 | f54b3f92 | aurel32 | tcg_out_ldst(s, TCG_REG_R20, r1, 0, LDW);
|
594 | f54b3f92 | aurel32 | |
595 | f54b3f92 | aurel32 | #if TARGET_LONG_BITS == 32 |
596 | f54b3f92 | aurel32 | /* if equal, jump to label1 */
|
597 | f54b3f92 | aurel32 | label1_ptr = (uint32_t *)s->code_ptr; |
598 | f54b3f92 | aurel32 | tcg_out32(s, COMBT | INSN_R1(TCG_REG_R20) | INSN_R2(r0) | |
599 | f54b3f92 | aurel32 | INSN_COND(COND_EQUAL)); |
600 | f54b3f92 | aurel32 | tcg_out_mov(s, r0, addr_reg); /* delay slot */
|
601 | f54b3f92 | aurel32 | #else
|
602 | f54b3f92 | aurel32 | /* if not equal, jump to label3 */
|
603 | f54b3f92 | aurel32 | label3_ptr = (uint32_t *)s->code_ptr; |
604 | f54b3f92 | aurel32 | tcg_out32(s, COMBF | INSN_R1(TCG_REG_R20) | INSN_R2(r0) | |
605 | f54b3f92 | aurel32 | INSN_COND(COND_EQUAL)); |
606 | f54b3f92 | aurel32 | tcg_out_mov(s, r0, addr_reg); /* delay slot */
|
607 | f54b3f92 | aurel32 | |
608 | f54b3f92 | aurel32 | tcg_out_ldst(s, TCG_REG_R20, r1, 4, LDW);
|
609 | f54b3f92 | aurel32 | |
610 | f54b3f92 | aurel32 | /* if equal, jump to label1 */
|
611 | f54b3f92 | aurel32 | label1_ptr = (uint32_t *)s->code_ptr; |
612 | f54b3f92 | aurel32 | tcg_out32(s, COMBT | INSN_R1(TCG_REG_R20) | INSN_R2(addr_reg2) | |
613 | f54b3f92 | aurel32 | INSN_COND(COND_EQUAL)); |
614 | f54b3f92 | aurel32 | tcg_out_nop(s); /* delay slot */
|
615 | f54b3f92 | aurel32 | |
616 | f54b3f92 | aurel32 | /* label3: */
|
617 | f54b3f92 | aurel32 | *label3_ptr |= reassemble_12((uint32_t *)s->code_ptr - label3_ptr - 2);
|
618 | f54b3f92 | aurel32 | #endif
|
619 | f54b3f92 | aurel32 | |
620 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R26, addr_reg); |
621 | f54b3f92 | aurel32 | #if TARGET_LONG_BITS == 64 |
622 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R25, addr_reg2); |
623 | f54b3f92 | aurel32 | if (opc == 3) { |
624 | f54b3f92 | aurel32 | tcg_abort(); |
625 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R24, data_reg); |
626 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R23, data_reg2); |
627 | f54b3f92 | aurel32 | /* TODO: push mem_index */
|
628 | f54b3f92 | aurel32 | tcg_abort(); |
629 | f54b3f92 | aurel32 | } else {
|
630 | f54b3f92 | aurel32 | switch(opc) {
|
631 | f54b3f92 | aurel32 | case 0: |
632 | f54b3f92 | aurel32 | tcg_out32(s, EXTRU | INSN_R1(TCG_REG_R24) | INSN_R2(data_reg) | |
633 | f54b3f92 | aurel32 | INSN_SHDEP_P(31) | INSN_DEP_LEN(8)); |
634 | f54b3f92 | aurel32 | break;
|
635 | f54b3f92 | aurel32 | case 1: |
636 | f54b3f92 | aurel32 | tcg_out32(s, EXTRU | INSN_R1(TCG_REG_R24) | INSN_R2(data_reg) | |
637 | f54b3f92 | aurel32 | INSN_SHDEP_P(31) | INSN_DEP_LEN(16)); |
638 | f54b3f92 | aurel32 | break;
|
639 | f54b3f92 | aurel32 | case 2: |
640 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R24, data_reg); |
641 | f54b3f92 | aurel32 | break;
|
642 | f54b3f92 | aurel32 | } |
643 | f54b3f92 | aurel32 | tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R23, mem_index); |
644 | f54b3f92 | aurel32 | } |
645 | f54b3f92 | aurel32 | #else
|
646 | f54b3f92 | aurel32 | if (opc == 3) { |
647 | f54b3f92 | aurel32 | tcg_abort(); |
648 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R25, data_reg); |
649 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R24, data_reg2); |
650 | f54b3f92 | aurel32 | tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R23, mem_index); |
651 | f54b3f92 | aurel32 | } else {
|
652 | f54b3f92 | aurel32 | switch(opc) {
|
653 | f54b3f92 | aurel32 | case 0: |
654 | f54b3f92 | aurel32 | tcg_out32(s, EXTRU | INSN_R1(TCG_REG_R25) | INSN_R2(data_reg) | |
655 | f54b3f92 | aurel32 | INSN_SHDEP_P(31) | INSN_DEP_LEN(8)); |
656 | f54b3f92 | aurel32 | break;
|
657 | f54b3f92 | aurel32 | case 1: |
658 | f54b3f92 | aurel32 | tcg_out32(s, EXTRU | INSN_R1(TCG_REG_R25) | INSN_R2(data_reg) | |
659 | f54b3f92 | aurel32 | INSN_SHDEP_P(31) | INSN_DEP_LEN(16)); |
660 | f54b3f92 | aurel32 | break;
|
661 | f54b3f92 | aurel32 | case 2: |
662 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_R25, data_reg); |
663 | f54b3f92 | aurel32 | break;
|
664 | f54b3f92 | aurel32 | } |
665 | f54b3f92 | aurel32 | tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R24, mem_index); |
666 | f54b3f92 | aurel32 | } |
667 | f54b3f92 | aurel32 | #endif
|
668 | f54b3f92 | aurel32 | tcg_out_call(s, qemu_st_helpers[s_bits]); |
669 | f54b3f92 | aurel32 | |
670 | f54b3f92 | aurel32 | /* jump to label2 */
|
671 | f54b3f92 | aurel32 | label2_ptr = (uint32_t *)s->code_ptr; |
672 | f54b3f92 | aurel32 | tcg_out32(s, BL | INSN_R2(TCG_REG_R0) | 2);
|
673 | f54b3f92 | aurel32 | |
674 | f54b3f92 | aurel32 | /* label1: */
|
675 | f54b3f92 | aurel32 | *label1_ptr |= reassemble_12((uint32_t *)s->code_ptr - label1_ptr - 2);
|
676 | f54b3f92 | aurel32 | |
677 | f54b3f92 | aurel32 | tcg_out_arithi(s, TCG_REG_R20, r1, |
678 | f54b3f92 | aurel32 | offsetof(CPUTLBEntry, addend) - offsetof(CPUTLBEntry, addr_write), |
679 | f54b3f92 | aurel32 | ARITH_ADD); |
680 | f54b3f92 | aurel32 | tcg_out_ldst(s, TCG_REG_R20, TCG_REG_R20, 0, LDW);
|
681 | f54b3f92 | aurel32 | tcg_out_arith(s, r0, r0, TCG_REG_R20, ARITH_ADD); |
682 | f54b3f92 | aurel32 | #else
|
683 | f54b3f92 | aurel32 | r0 = addr_reg; |
684 | f54b3f92 | aurel32 | #endif
|
685 | f54b3f92 | aurel32 | |
686 | f54b3f92 | aurel32 | #ifdef TARGET_WORDS_BIGENDIAN
|
687 | f54b3f92 | aurel32 | bswap = 0;
|
688 | f54b3f92 | aurel32 | #else
|
689 | f54b3f92 | aurel32 | bswap = 1;
|
690 | f54b3f92 | aurel32 | #endif
|
691 | f54b3f92 | aurel32 | switch (opc) {
|
692 | f54b3f92 | aurel32 | case 0: |
693 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, STB);
|
694 | f54b3f92 | aurel32 | break;
|
695 | f54b3f92 | aurel32 | case 1: |
696 | f54b3f92 | aurel32 | if (bswap) {
|
697 | f54b3f92 | aurel32 | tcg_out_bswap16(s, TCG_REG_R20, data_reg); |
698 | f54b3f92 | aurel32 | data_reg = TCG_REG_R20; |
699 | f54b3f92 | aurel32 | } |
700 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, STH);
|
701 | f54b3f92 | aurel32 | break;
|
702 | f54b3f92 | aurel32 | case 2: |
703 | f54b3f92 | aurel32 | if (bswap) {
|
704 | f54b3f92 | aurel32 | tcg_out_bswap32(s, TCG_REG_R20, data_reg, TCG_REG_R20); |
705 | f54b3f92 | aurel32 | data_reg = TCG_REG_R20; |
706 | f54b3f92 | aurel32 | } |
707 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, STW);
|
708 | f54b3f92 | aurel32 | break;
|
709 | f54b3f92 | aurel32 | case 3: |
710 | f54b3f92 | aurel32 | tcg_abort(); |
711 | f54b3f92 | aurel32 | if (!bswap) {
|
712 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg, r0, 0, STW);
|
713 | f54b3f92 | aurel32 | tcg_out_ldst(s, data_reg2, r0, 4, STW);
|
714 | f54b3f92 | aurel32 | } else {
|
715 | f54b3f92 | aurel32 | tcg_out_bswap32(s, TCG_REG_R20, data_reg, TCG_REG_R20); |
716 | f54b3f92 | aurel32 | tcg_out_ldst(s, TCG_REG_R20, r0, 4, STW);
|
717 | f54b3f92 | aurel32 | tcg_out_bswap32(s, TCG_REG_R20, data_reg2, TCG_REG_R20); |
718 | f54b3f92 | aurel32 | tcg_out_ldst(s, TCG_REG_R20, r0, 0, STW);
|
719 | f54b3f92 | aurel32 | } |
720 | f54b3f92 | aurel32 | break;
|
721 | f54b3f92 | aurel32 | default:
|
722 | f54b3f92 | aurel32 | tcg_abort(); |
723 | f54b3f92 | aurel32 | } |
724 | f54b3f92 | aurel32 | |
725 | f54b3f92 | aurel32 | #if defined(CONFIG_SOFTMMU)
|
726 | f54b3f92 | aurel32 | /* label2: */
|
727 | f54b3f92 | aurel32 | *label2_ptr |= reassemble_17((uint32_t *)s->code_ptr - label2_ptr - 2);
|
728 | f54b3f92 | aurel32 | #endif
|
729 | f54b3f92 | aurel32 | } |
730 | f54b3f92 | aurel32 | |
731 | f54b3f92 | aurel32 | static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, |
732 | f54b3f92 | aurel32 | const int *const_args) |
733 | f54b3f92 | aurel32 | { |
734 | f54b3f92 | aurel32 | int c;
|
735 | f54b3f92 | aurel32 | |
736 | f54b3f92 | aurel32 | switch (opc) {
|
737 | f54b3f92 | aurel32 | case INDEX_op_exit_tb:
|
738 | f54b3f92 | aurel32 | tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_RET0, args[0]);
|
739 | f54b3f92 | aurel32 | tcg_out32(s, BV_N | INSN_R2(TCG_REG_R18)); |
740 | f54b3f92 | aurel32 | break;
|
741 | f54b3f92 | aurel32 | case INDEX_op_goto_tb:
|
742 | f54b3f92 | aurel32 | if (s->tb_jmp_offset) {
|
743 | f54b3f92 | aurel32 | /* direct jump method */
|
744 | f54b3f92 | aurel32 | fprintf(stderr, "goto_tb direct\n");
|
745 | f54b3f92 | aurel32 | tcg_abort(); |
746 | f54b3f92 | aurel32 | tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R20, args[0]);
|
747 | f54b3f92 | aurel32 | tcg_out32(s, BV_N | INSN_R2(TCG_REG_R20)); |
748 | f54b3f92 | aurel32 | s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
|
749 | f54b3f92 | aurel32 | } else {
|
750 | f54b3f92 | aurel32 | /* indirect jump method */
|
751 | f54b3f92 | aurel32 | tcg_out_ld_ptr(s, TCG_REG_R20, |
752 | f54b3f92 | aurel32 | (tcg_target_long)(s->tb_next + args[0]));
|
753 | f54b3f92 | aurel32 | tcg_out32(s, BV_N | INSN_R2(TCG_REG_R20)); |
754 | f54b3f92 | aurel32 | } |
755 | f54b3f92 | aurel32 | s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
|
756 | f54b3f92 | aurel32 | break;
|
757 | f54b3f92 | aurel32 | case INDEX_op_call:
|
758 | f54b3f92 | aurel32 | tcg_out32(s, BLE_SR4 | INSN_R2(args[0]));
|
759 | f54b3f92 | aurel32 | tcg_out_mov(s, TCG_REG_RP, TCG_REG_R31); |
760 | f54b3f92 | aurel32 | break;
|
761 | f54b3f92 | aurel32 | case INDEX_op_jmp:
|
762 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented jmp\n");
|
763 | f54b3f92 | aurel32 | tcg_abort(); |
764 | f54b3f92 | aurel32 | break;
|
765 | f54b3f92 | aurel32 | case INDEX_op_br:
|
766 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented br\n");
|
767 | f54b3f92 | aurel32 | tcg_abort(); |
768 | f54b3f92 | aurel32 | break;
|
769 | f54b3f92 | aurel32 | case INDEX_op_movi_i32:
|
770 | f54b3f92 | aurel32 | tcg_out_movi(s, TCG_TYPE_I32, args[0], (uint32_t)args[1]); |
771 | f54b3f92 | aurel32 | break;
|
772 | f54b3f92 | aurel32 | |
773 | f54b3f92 | aurel32 | case INDEX_op_ld8u_i32:
|
774 | f54b3f92 | aurel32 | tcg_out_ldst(s, args[0], args[1], args[2], LDB); |
775 | f54b3f92 | aurel32 | break;
|
776 | f54b3f92 | aurel32 | case INDEX_op_ld8s_i32:
|
777 | f54b3f92 | aurel32 | tcg_out_ldst(s, args[0], args[1], args[2], LDB); |
778 | f54b3f92 | aurel32 | tcg_out_ext8s(s, args[0], args[0]); |
779 | f54b3f92 | aurel32 | break;
|
780 | f54b3f92 | aurel32 | case INDEX_op_ld16u_i32:
|
781 | f54b3f92 | aurel32 | tcg_out_ldst(s, args[0], args[1], args[2], LDH); |
782 | f54b3f92 | aurel32 | break;
|
783 | f54b3f92 | aurel32 | case INDEX_op_ld16s_i32:
|
784 | f54b3f92 | aurel32 | tcg_out_ldst(s, args[0], args[1], args[2], LDH); |
785 | f54b3f92 | aurel32 | tcg_out_ext16s(s, args[0], args[0]); |
786 | f54b3f92 | aurel32 | break;
|
787 | f54b3f92 | aurel32 | case INDEX_op_ld_i32:
|
788 | f54b3f92 | aurel32 | tcg_out_ldst(s, args[0], args[1], args[2], LDW); |
789 | f54b3f92 | aurel32 | break;
|
790 | f54b3f92 | aurel32 | |
791 | f54b3f92 | aurel32 | case INDEX_op_st8_i32:
|
792 | f54b3f92 | aurel32 | tcg_out_ldst(s, args[0], args[1], args[2], STB); |
793 | f54b3f92 | aurel32 | break;
|
794 | f54b3f92 | aurel32 | case INDEX_op_st16_i32:
|
795 | f54b3f92 | aurel32 | tcg_out_ldst(s, args[0], args[1], args[2], STH); |
796 | f54b3f92 | aurel32 | break;
|
797 | f54b3f92 | aurel32 | case INDEX_op_st_i32:
|
798 | f54b3f92 | aurel32 | tcg_out_ldst(s, args[0], args[1], args[2], STW); |
799 | f54b3f92 | aurel32 | break;
|
800 | f54b3f92 | aurel32 | |
801 | f54b3f92 | aurel32 | case INDEX_op_sub_i32:
|
802 | f54b3f92 | aurel32 | c = ARITH_SUB; |
803 | f54b3f92 | aurel32 | goto gen_arith;
|
804 | f54b3f92 | aurel32 | case INDEX_op_and_i32:
|
805 | f54b3f92 | aurel32 | c = ARITH_AND; |
806 | f54b3f92 | aurel32 | goto gen_arith;
|
807 | f54b3f92 | aurel32 | case INDEX_op_or_i32:
|
808 | f54b3f92 | aurel32 | c = ARITH_OR; |
809 | f54b3f92 | aurel32 | goto gen_arith;
|
810 | f54b3f92 | aurel32 | case INDEX_op_xor_i32:
|
811 | f54b3f92 | aurel32 | c = ARITH_XOR; |
812 | f54b3f92 | aurel32 | goto gen_arith;
|
813 | f54b3f92 | aurel32 | case INDEX_op_add_i32:
|
814 | f54b3f92 | aurel32 | c = ARITH_ADD; |
815 | f54b3f92 | aurel32 | goto gen_arith;
|
816 | f54b3f92 | aurel32 | |
817 | f54b3f92 | aurel32 | case INDEX_op_shl_i32:
|
818 | f54b3f92 | aurel32 | tcg_out32(s, SUBI | INSN_R1(TCG_REG_R20) | INSN_R2(args[2]) |
|
819 | f54b3f92 | aurel32 | lowsignext(0x1f, 0, 11)); |
820 | f54b3f92 | aurel32 | tcg_out32(s, MTCTL | INSN_R2(11) | INSN_R1(TCG_REG_R20));
|
821 | f54b3f92 | aurel32 | tcg_out32(s, ZVDEP | INSN_R2(args[0]) | INSN_R1(args[1]) | |
822 | f54b3f92 | aurel32 | INSN_DEP_LEN(32));
|
823 | f54b3f92 | aurel32 | break;
|
824 | f54b3f92 | aurel32 | case INDEX_op_shr_i32:
|
825 | f54b3f92 | aurel32 | tcg_out32(s, MTCTL | INSN_R2(11) | INSN_R1(args[2])); |
826 | f54b3f92 | aurel32 | tcg_out32(s, VSHD | INSN_T(args[0]) | INSN_R1(TCG_REG_R0) |
|
827 | f54b3f92 | aurel32 | INSN_R2(args[1]));
|
828 | f54b3f92 | aurel32 | break;
|
829 | f54b3f92 | aurel32 | case INDEX_op_sar_i32:
|
830 | f54b3f92 | aurel32 | tcg_out32(s, SUBI | INSN_R1(TCG_REG_R20) | INSN_R2(args[2]) |
|
831 | f54b3f92 | aurel32 | lowsignext(0x1f, 0, 11)); |
832 | f54b3f92 | aurel32 | tcg_out32(s, MTCTL | INSN_R2(11) | INSN_R1(TCG_REG_R20));
|
833 | f54b3f92 | aurel32 | tcg_out32(s, VEXTRS | INSN_R1(args[0]) | INSN_R2(args[1]) | |
834 | f54b3f92 | aurel32 | INSN_DEP_LEN(32));
|
835 | f54b3f92 | aurel32 | break;
|
836 | f54b3f92 | aurel32 | |
837 | f54b3f92 | aurel32 | case INDEX_op_mul_i32:
|
838 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented mul\n");
|
839 | f54b3f92 | aurel32 | tcg_abort(); |
840 | f54b3f92 | aurel32 | break;
|
841 | f54b3f92 | aurel32 | case INDEX_op_mulu2_i32:
|
842 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented mulu2\n");
|
843 | f54b3f92 | aurel32 | tcg_abort(); |
844 | f54b3f92 | aurel32 | break;
|
845 | f54b3f92 | aurel32 | case INDEX_op_div2_i32:
|
846 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented div2\n");
|
847 | f54b3f92 | aurel32 | tcg_abort(); |
848 | f54b3f92 | aurel32 | break;
|
849 | f54b3f92 | aurel32 | case INDEX_op_divu2_i32:
|
850 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented divu2\n");
|
851 | f54b3f92 | aurel32 | tcg_abort(); |
852 | f54b3f92 | aurel32 | break;
|
853 | f54b3f92 | aurel32 | |
854 | f54b3f92 | aurel32 | case INDEX_op_brcond_i32:
|
855 | f54b3f92 | aurel32 | fprintf(stderr, "unimplemented brcond\n");
|
856 | f54b3f92 | aurel32 | tcg_abort(); |
857 | f54b3f92 | aurel32 | break;
|
858 | f54b3f92 | aurel32 | |
859 | f54b3f92 | aurel32 | case INDEX_op_qemu_ld8u:
|
860 | f54b3f92 | aurel32 | tcg_out_qemu_ld(s, args, 0);
|
861 | f54b3f92 | aurel32 | break;
|
862 | f54b3f92 | aurel32 | case INDEX_op_qemu_ld8s:
|
863 | f54b3f92 | aurel32 | tcg_out_qemu_ld(s, args, 0 | 4); |
864 | f54b3f92 | aurel32 | break;
|
865 | f54b3f92 | aurel32 | case INDEX_op_qemu_ld16u:
|
866 | f54b3f92 | aurel32 | tcg_out_qemu_ld(s, args, 1);
|
867 | f54b3f92 | aurel32 | break;
|
868 | f54b3f92 | aurel32 | case INDEX_op_qemu_ld16s:
|
869 | f54b3f92 | aurel32 | tcg_out_qemu_ld(s, args, 1 | 4); |
870 | f54b3f92 | aurel32 | break;
|
871 | f54b3f92 | aurel32 | case INDEX_op_qemu_ld32u:
|
872 | f54b3f92 | aurel32 | tcg_out_qemu_ld(s, args, 2);
|
873 | f54b3f92 | aurel32 | break;
|
874 | f54b3f92 | aurel32 | |
875 | f54b3f92 | aurel32 | case INDEX_op_qemu_st8:
|
876 | f54b3f92 | aurel32 | tcg_out_qemu_st(s, args, 0);
|
877 | f54b3f92 | aurel32 | break;
|
878 | f54b3f92 | aurel32 | case INDEX_op_qemu_st16:
|
879 | f54b3f92 | aurel32 | tcg_out_qemu_st(s, args, 1);
|
880 | f54b3f92 | aurel32 | break;
|
881 | f54b3f92 | aurel32 | case INDEX_op_qemu_st32:
|
882 | f54b3f92 | aurel32 | tcg_out_qemu_st(s, args, 2);
|
883 | f54b3f92 | aurel32 | break;
|
884 | f54b3f92 | aurel32 | |
885 | f54b3f92 | aurel32 | default:
|
886 | f54b3f92 | aurel32 | fprintf(stderr, "unknown opcode 0x%x\n", opc);
|
887 | f54b3f92 | aurel32 | tcg_abort(); |
888 | f54b3f92 | aurel32 | } |
889 | f54b3f92 | aurel32 | return;
|
890 | f54b3f92 | aurel32 | |
891 | f54b3f92 | aurel32 | gen_arith:
|
892 | f54b3f92 | aurel32 | tcg_out_arith(s, args[0], args[1], args[2], c); |
893 | f54b3f92 | aurel32 | } |
894 | f54b3f92 | aurel32 | |
895 | f54b3f92 | aurel32 | static const TCGTargetOpDef hppa_op_defs[] = { |
896 | f54b3f92 | aurel32 | { INDEX_op_exit_tb, { } }, |
897 | f54b3f92 | aurel32 | { INDEX_op_goto_tb, { } }, |
898 | f54b3f92 | aurel32 | |
899 | f54b3f92 | aurel32 | { INDEX_op_call, { "r" } },
|
900 | f54b3f92 | aurel32 | { INDEX_op_jmp, { "r" } },
|
901 | f54b3f92 | aurel32 | { INDEX_op_br, { } }, |
902 | f54b3f92 | aurel32 | |
903 | f54b3f92 | aurel32 | { INDEX_op_mov_i32, { "r", "r" } }, |
904 | f54b3f92 | aurel32 | { INDEX_op_movi_i32, { "r" } },
|
905 | f54b3f92 | aurel32 | { INDEX_op_ld8u_i32, { "r", "r" } }, |
906 | f54b3f92 | aurel32 | { INDEX_op_ld8s_i32, { "r", "r" } }, |
907 | f54b3f92 | aurel32 | { INDEX_op_ld16u_i32, { "r", "r" } }, |
908 | f54b3f92 | aurel32 | { INDEX_op_ld16s_i32, { "r", "r" } }, |
909 | f54b3f92 | aurel32 | { INDEX_op_ld_i32, { "r", "r" } }, |
910 | f54b3f92 | aurel32 | { INDEX_op_st8_i32, { "r", "r" } }, |
911 | f54b3f92 | aurel32 | { INDEX_op_st16_i32, { "r", "r" } }, |
912 | f54b3f92 | aurel32 | { INDEX_op_st_i32, { "r", "r" } }, |
913 | f54b3f92 | aurel32 | |
914 | f54b3f92 | aurel32 | { INDEX_op_add_i32, { "r", "r", "r" } }, |
915 | f54b3f92 | aurel32 | { INDEX_op_sub_i32, { "r", "r", "r" } }, |
916 | f54b3f92 | aurel32 | { INDEX_op_and_i32, { "r", "r", "r" } }, |
917 | f54b3f92 | aurel32 | { INDEX_op_or_i32, { "r", "r", "r" } }, |
918 | f54b3f92 | aurel32 | { INDEX_op_xor_i32, { "r", "r", "r" } }, |
919 | f54b3f92 | aurel32 | |
920 | f54b3f92 | aurel32 | { INDEX_op_shl_i32, { "r", "r", "r" } }, |
921 | f54b3f92 | aurel32 | { INDEX_op_shr_i32, { "r", "r", "r" } }, |
922 | f54b3f92 | aurel32 | { INDEX_op_sar_i32, { "r", "r", "r" } }, |
923 | f54b3f92 | aurel32 | |
924 | f54b3f92 | aurel32 | { INDEX_op_brcond_i32, { "r", "r" } }, |
925 | f54b3f92 | aurel32 | |
926 | f54b3f92 | aurel32 | #if TARGET_LONG_BITS == 32 |
927 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld8u, { "r", "L" } }, |
928 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld8s, { "r", "L" } }, |
929 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld16u, { "r", "L" } }, |
930 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld16s, { "r", "L" } }, |
931 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld32u, { "r", "L" } }, |
932 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld64, { "r", "r", "L" } }, |
933 | f54b3f92 | aurel32 | |
934 | f54b3f92 | aurel32 | { INDEX_op_qemu_st8, { "L", "L" } }, |
935 | f54b3f92 | aurel32 | { INDEX_op_qemu_st16, { "L", "L" } }, |
936 | f54b3f92 | aurel32 | { INDEX_op_qemu_st32, { "L", "L" } }, |
937 | f54b3f92 | aurel32 | { INDEX_op_qemu_st64, { "L", "L", "L" } }, |
938 | f54b3f92 | aurel32 | #else
|
939 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld8u, { "r", "L", "L" } }, |
940 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld8s, { "r", "L", "L" } }, |
941 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld16u, { "r", "L", "L" } }, |
942 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld16s, { "r", "L", "L" } }, |
943 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld32u, { "r", "L", "L" } }, |
944 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld32s, { "r", "L", "L" } }, |
945 | f54b3f92 | aurel32 | { INDEX_op_qemu_ld64, { "r", "r", "L", "L" } }, |
946 | f54b3f92 | aurel32 | |
947 | f54b3f92 | aurel32 | { INDEX_op_qemu_st8, { "L", "L", "L" } }, |
948 | f54b3f92 | aurel32 | { INDEX_op_qemu_st16, { "L", "L", "L" } }, |
949 | f54b3f92 | aurel32 | { INDEX_op_qemu_st32, { "L", "L", "L" } }, |
950 | f54b3f92 | aurel32 | { INDEX_op_qemu_st64, { "L", "L", "L", "L" } }, |
951 | f54b3f92 | aurel32 | #endif
|
952 | f54b3f92 | aurel32 | { -1 },
|
953 | f54b3f92 | aurel32 | }; |
954 | f54b3f92 | aurel32 | |
955 | f54b3f92 | aurel32 | void tcg_target_init(TCGContext *s)
|
956 | f54b3f92 | aurel32 | { |
957 | f54b3f92 | aurel32 | tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff); |
958 | f54b3f92 | aurel32 | tcg_regset_set32(tcg_target_call_clobber_regs, 0,
|
959 | f54b3f92 | aurel32 | (1 << TCG_REG_R20) |
|
960 | f54b3f92 | aurel32 | (1 << TCG_REG_R21) |
|
961 | f54b3f92 | aurel32 | (1 << TCG_REG_R22) |
|
962 | f54b3f92 | aurel32 | (1 << TCG_REG_R23) |
|
963 | f54b3f92 | aurel32 | (1 << TCG_REG_R24) |
|
964 | f54b3f92 | aurel32 | (1 << TCG_REG_R25) |
|
965 | f54b3f92 | aurel32 | (1 << TCG_REG_R26));
|
966 | f54b3f92 | aurel32 | |
967 | f54b3f92 | aurel32 | tcg_regset_clear(s->reserved_regs); |
968 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0); /* hardwired to zero */
|
969 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_R1); /* addil target */
|
970 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_RP); /* link register */
|
971 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_R3); /* frame pointer */
|
972 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_R18); /* return pointer */
|
973 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_R19); /* clobbered w/o pic */
|
974 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_R20); /* reserved */
|
975 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_DP); /* data pointer */
|
976 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP); /* stack pointer */
|
977 | f54b3f92 | aurel32 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_R31); /* ble link reg */
|
978 | f54b3f92 | aurel32 | |
979 | f54b3f92 | aurel32 | tcg_add_target_add_op_defs(hppa_op_defs); |
980 | f54b3f92 | aurel32 | } |