root / target-m68k / op-hacks.h @ 89fc88da
History | View | Annotate | Download (2.4 kB)
1 | e6e5906b | pbrook | /* Various hacks to make code written for a dynamic code generator work
|
---|---|---|---|
2 | e6e5906b | pbrook | with regular QEMU. */
|
3 | e6e5906b | pbrook | |
4 | e6e5906b | pbrook | static int free_qreg; |
5 | e6e5906b | pbrook | |
6 | e6e5906b | pbrook | #define QMODE_I32 1 |
7 | e6e5906b | pbrook | #define QMODE_F32 1 |
8 | e6e5906b | pbrook | #define QMODE_F64 2 |
9 | e6e5906b | pbrook | |
10 | e6e5906b | pbrook | static inline int gen_new_qreg(int mode) |
11 | e6e5906b | pbrook | { |
12 | e6e5906b | pbrook | int qreg;
|
13 | e6e5906b | pbrook | |
14 | e6e5906b | pbrook | qreg = free_qreg; |
15 | e6e5906b | pbrook | free_qreg += mode; |
16 | e6e5906b | pbrook | if (free_qreg > MAX_QREGS) {
|
17 | e6e5906b | pbrook | fprintf(stderr, "qreg overflow\n");
|
18 | e6e5906b | pbrook | abort(); |
19 | e6e5906b | pbrook | } |
20 | e6e5906b | pbrook | return qreg + TARGET_NUM_QREGS;
|
21 | e6e5906b | pbrook | } |
22 | e6e5906b | pbrook | |
23 | e6e5906b | pbrook | static inline int gen_im32(uint32_t i) |
24 | e6e5906b | pbrook | { |
25 | e6e5906b | pbrook | int qreg = gen_new_qreg(QMODE_I32);
|
26 | e6e5906b | pbrook | gen_op_mov32_im(qreg, i); |
27 | e6e5906b | pbrook | return qreg;
|
28 | e6e5906b | pbrook | } |
29 | e6e5906b | pbrook | |
30 | 0633879f | pbrook | static inline void gen_op_ldf32_raw(int dest, int addr) |
31 | e6e5906b | pbrook | { |
32 | 0633879f | pbrook | gen_op_ld32_raw(dest, addr); |
33 | e6e5906b | pbrook | } |
34 | e6e5906b | pbrook | |
35 | 0633879f | pbrook | static inline void gen_op_stf32_raw(int addr, int dest) |
36 | e6e5906b | pbrook | { |
37 | 0633879f | pbrook | gen_op_st32_raw(addr, dest); |
38 | e6e5906b | pbrook | } |
39 | e6e5906b | pbrook | |
40 | 0633879f | pbrook | #if !defined(CONFIG_USER_ONLY)
|
41 | 0633879f | pbrook | static inline void gen_op_ldf32_user(int dest, int addr) |
42 | 0633879f | pbrook | { |
43 | 0633879f | pbrook | gen_op_ld32_user(dest, addr); |
44 | 0633879f | pbrook | } |
45 | 0633879f | pbrook | |
46 | 0633879f | pbrook | static inline void gen_op_stf32_user(int addr, int dest) |
47 | 0633879f | pbrook | { |
48 | 0633879f | pbrook | gen_op_st32_user(addr, dest); |
49 | 0633879f | pbrook | } |
50 | 0633879f | pbrook | |
51 | 0633879f | pbrook | static inline void gen_op_ldf32_kernel(int dest, int addr) |
52 | 0633879f | pbrook | { |
53 | 0633879f | pbrook | gen_op_ld32_kernel(dest, addr); |
54 | 0633879f | pbrook | } |
55 | 0633879f | pbrook | |
56 | 0633879f | pbrook | static inline void gen_op_stf32_kernel(int addr, int dest) |
57 | 0633879f | pbrook | { |
58 | 0633879f | pbrook | gen_op_st32_kernel(addr, dest); |
59 | 0633879f | pbrook | } |
60 | 0633879f | pbrook | #endif
|
61 | 0633879f | pbrook | |
62 | e6e5906b | pbrook | static inline void gen_op_pack_32_f32(int dest, int src) |
63 | e6e5906b | pbrook | { |
64 | e6e5906b | pbrook | gen_op_mov32(dest, src); |
65 | e6e5906b | pbrook | } |
66 | e6e5906b | pbrook | |
67 | e6e5906b | pbrook | static inline void gen_op_pack_f32_32(int dest, int src) |
68 | e6e5906b | pbrook | { |
69 | e6e5906b | pbrook | gen_op_mov32(dest, src); |
70 | e6e5906b | pbrook | } |
71 | e6e5906b | pbrook | |
72 | e6e5906b | pbrook | static inline void gen_op_flags_set(void) |
73 | e6e5906b | pbrook | { |
74 | e6e5906b | pbrook | /* Dummy op. */
|
75 | e6e5906b | pbrook | } |
76 | e6e5906b | pbrook | |
77 | e6e5906b | pbrook | static inline void gen_op_shl_im_cc(int val, int shift) |
78 | e6e5906b | pbrook | { |
79 | e6e5906b | pbrook | gen_op_shl_cc(val, gen_im32(shift)); |
80 | e6e5906b | pbrook | } |
81 | e6e5906b | pbrook | |
82 | e6e5906b | pbrook | static inline void gen_op_shr_im_cc(int val, int shift) |
83 | e6e5906b | pbrook | { |
84 | e6e5906b | pbrook | gen_op_shr_cc(val, gen_im32(shift)); |
85 | e6e5906b | pbrook | } |
86 | e6e5906b | pbrook | |
87 | e6e5906b | pbrook | static inline void gen_op_sar_im_cc(int val, int shift) |
88 | e6e5906b | pbrook | { |
89 | e6e5906b | pbrook | gen_op_sar_cc(val, gen_im32(shift)); |
90 | e6e5906b | pbrook | } |
91 | e6e5906b | pbrook | |
92 | e6e5906b | pbrook | #ifdef USE_DIRECT_JUMP
|
93 | e6e5906b | pbrook | #define TBPARAM(x)
|
94 | e6e5906b | pbrook | #else
|
95 | e6e5906b | pbrook | #define TBPARAM(x) (long)(x) |
96 | e6e5906b | pbrook | #endif
|
97 | e6e5906b | pbrook | |
98 | e6e5906b | pbrook | static inline void gen_op_goto_tb(int dummy, int n, long tb) |
99 | e6e5906b | pbrook | { |
100 | e6e5906b | pbrook | if (n == 0) { |
101 | e6e5906b | pbrook | gen_op_goto_tb0(TBPARAM(tb)); |
102 | e6e5906b | pbrook | } else {
|
103 | e6e5906b | pbrook | gen_op_goto_tb1(TBPARAM(tb)); |
104 | e6e5906b | pbrook | } |
105 | e6e5906b | pbrook | } |
106 | 06d92f40 | pbrook | |
107 | 06d92f40 | pbrook | static inline void gen_op_jmp_z32(int val, int label) |
108 | 06d92f40 | pbrook | { |
109 | 06d92f40 | pbrook | gen_op_set_T0_z32(val); |
110 | 06d92f40 | pbrook | gen_op_jmp_T0(label); |
111 | 06d92f40 | pbrook | } |
112 | 06d92f40 | pbrook | |
113 | 06d92f40 | pbrook | static inline void gen_op_jmp_nz32(int val, int label) |
114 | 06d92f40 | pbrook | { |
115 | 06d92f40 | pbrook | gen_op_set_T0_nz32(val); |
116 | 06d92f40 | pbrook | gen_op_jmp_T0(label); |
117 | 06d92f40 | pbrook | } |
118 | 06d92f40 | pbrook | |
119 | 06d92f40 | pbrook | static inline void gen_op_jmp_s32(int val, int label) |
120 | 06d92f40 | pbrook | { |
121 | 06d92f40 | pbrook | gen_op_set_T0_s32(val); |
122 | 06d92f40 | pbrook | gen_op_jmp_T0(label); |
123 | 06d92f40 | pbrook | } |
124 | 06d92f40 | pbrook | |
125 | 06d92f40 | pbrook | static inline void gen_op_jmp_ns32(int val, int label) |
126 | 06d92f40 | pbrook | { |
127 | 06d92f40 | pbrook | gen_op_set_T0_ns32(val); |
128 | 06d92f40 | pbrook | gen_op_jmp_T0(label); |
129 | 06d92f40 | pbrook | } |