Call most FP helpers without deroute through op.c
[qemu] / target-mips / exec.h
1 #if !defined(__QEMU_MIPS_EXEC_H__)
2 #define __QEMU_MIPS_EXEC_H__
3
4 //#define DEBUG_OP
5
6 #include "config.h"
7 #include "mips-defs.h"
8 #include "dyngen-exec.h"
9 #include "cpu-defs.h"
10
11 register struct CPUMIPSState *env asm(AREG0);
12
13 #if TARGET_LONG_BITS > HOST_LONG_BITS
14 #define T0 (env->t0)
15 #define T1 (env->t1)
16 #else
17 register target_ulong T0 asm(AREG1);
18 register target_ulong T1 asm(AREG2);
19 #endif
20
21 #if defined (USE_HOST_FLOAT_REGS)
22 #error "implement me."
23 #else
24 #define FDT0 (env->ft0.fd)
25 #define FDT1 (env->ft1.fd)
26 #define FDT2 (env->ft2.fd)
27 #define FST0 (env->ft0.fs[FP_ENDIAN_IDX])
28 #define FST1 (env->ft1.fs[FP_ENDIAN_IDX])
29 #define FST2 (env->ft2.fs[FP_ENDIAN_IDX])
30 #define FSTH0 (env->ft0.fs[!FP_ENDIAN_IDX])
31 #define FSTH1 (env->ft1.fs[!FP_ENDIAN_IDX])
32 #define FSTH2 (env->ft2.fs[!FP_ENDIAN_IDX])
33 #define DT0 (env->ft0.d)
34 #define DT1 (env->ft1.d)
35 #define DT2 (env->ft2.d)
36 #define WT0 (env->ft0.w[FP_ENDIAN_IDX])
37 #define WT1 (env->ft1.w[FP_ENDIAN_IDX])
38 #define WT2 (env->ft2.w[FP_ENDIAN_IDX])
39 #define WTH0 (env->ft0.w[!FP_ENDIAN_IDX])
40 #define WTH1 (env->ft1.w[!FP_ENDIAN_IDX])
41 #define WTH2 (env->ft2.w[!FP_ENDIAN_IDX])
42 #endif
43
44 #include "cpu.h"
45 #include "exec-all.h"
46
47 #if !defined(CONFIG_USER_ONLY)
48 #include "softmmu_exec.h"
49 #endif /* !defined(CONFIG_USER_ONLY) */
50
51 #if TARGET_LONG_BITS > HOST_LONG_BITS
52 void do_mult (void);
53 void do_multu (void);
54 void do_madd (void);
55 void do_maddu (void);
56 void do_msub (void);
57 void do_msubu (void);
58 void do_muls (void);
59 void do_mulsu (void);
60 void do_macc (void);
61 void do_macchi (void);
62 void do_maccu (void);
63 void do_macchiu (void);
64 void do_msac (void);
65 void do_msachi (void);
66 void do_msacu (void);
67 void do_msachiu (void);
68 void do_mulhi (void);
69 void do_mulhiu (void);
70 void do_mulshi (void);
71 void do_mulshiu (void);
72 #endif
73
74 void do_mtc0_status_debug(uint32_t old, uint32_t val);
75 void do_mtc0_status_irqraise_debug(void);
76 void dump_fpu(CPUState *env);
77 void fpu_dump_state(CPUState *env, FILE *f,
78                     int (*fpu_fprintf)(FILE *f, const char *fmt, ...),
79                     int flags);
80 void dump_sc (void);
81 void do_pmon (int function);
82
83 int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
84                                int mmu_idx, int is_softmmu);
85 void do_interrupt (CPUState *env);
86 void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra);
87
88 void cpu_loop_exit(void);
89 void do_raise_exception_err (uint32_t exception, int error_code);
90 void do_raise_exception (uint32_t exception);
91
92 void cpu_dump_state(CPUState *env, FILE *f,
93                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
94                     int flags);
95 void cpu_mips_irqctrl_init (void);
96 uint32_t cpu_mips_get_random (CPUState *env);
97 uint32_t cpu_mips_get_count (CPUState *env);
98 void cpu_mips_store_count (CPUState *env, uint32_t value);
99 void cpu_mips_store_compare (CPUState *env, uint32_t value);
100 void cpu_mips_start_count(CPUState *env);
101 void cpu_mips_stop_count(CPUState *env);
102 void cpu_mips_update_irq (CPUState *env);
103 void cpu_mips_clock_init (CPUState *env);
104 void cpu_mips_tlb_flush (CPUState *env, int flush_global);
105
106 static always_inline void env_to_regs(void)
107 {
108 }
109
110 static always_inline void regs_to_env(void)
111 {
112 }
113
114 static always_inline int cpu_halted(CPUState *env)
115 {
116     if (!env->halted)
117         return 0;
118     if (env->interrupt_request &
119         (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER)) {
120         env->halted = 0;
121         return 0;
122     }
123     return EXCP_HALTED;
124 }
125
126 static always_inline void compute_hflags(CPUState *env)
127 {
128     env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |
129                      MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU);
130     if (!(env->CP0_Status & (1 << CP0St_EXL)) &&
131         !(env->CP0_Status & (1 << CP0St_ERL)) &&
132         !(env->hflags & MIPS_HFLAG_DM)) {
133         env->hflags |= (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU;
134     }
135 #if defined(TARGET_MIPS64)
136     if (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_UM) ||
137         (env->CP0_Status & (1 << CP0St_PX)) ||
138         (env->CP0_Status & (1 << CP0St_UX)))
139         env->hflags |= MIPS_HFLAG_64;
140 #endif
141     if ((env->CP0_Status & (1 << CP0St_CU0)) ||
142         !(env->hflags & MIPS_HFLAG_KSU))
143         env->hflags |= MIPS_HFLAG_CP0;
144     if (env->CP0_Status & (1 << CP0St_CU1))
145         env->hflags |= MIPS_HFLAG_FPU;
146     if (env->CP0_Status & (1 << CP0St_FR))
147         env->hflags |= MIPS_HFLAG_F64;
148     if (env->insn_flags & ISA_MIPS32R2) {
149         if (env->fpu->fcr0 & (1 << FCR0_F64))
150             env->hflags |= MIPS_HFLAG_COP1X;
151     } else if (env->insn_flags & ISA_MIPS32) {
152         if (env->hflags & MIPS_HFLAG_64)
153             env->hflags |= MIPS_HFLAG_COP1X;
154     } else if (env->insn_flags & ISA_MIPS4) {
155         /* All supported MIPS IV CPUs use the XX (CU3) to enable
156            and disable the MIPS IV extensions to the MIPS III ISA.
157            Some other MIPS IV CPUs ignore the bit, so the check here
158            would be too restrictive for them.  */
159         if (env->CP0_Status & (1 << CP0St_CU3))
160             env->hflags |= MIPS_HFLAG_COP1X;
161     }
162 }
163
164 #endif /* !defined(__QEMU_MIPS_EXEC_H__) */