[PATCH 22/57][Arm][GAS] Add support for MVE instructions: vmlaldav, vmlalv, vmlsldav...
[binutils-gdb.git] / sim / common / cgen-fpu.h
blob5f9b55d32eecc373362e6270241645bf328936a0
1 /* CGEN fpu support
2 Copyright (C) 1999 Cygnus Solutions.
3 Copyright (C) 2010 Doug Evans. */
5 #ifndef CGEN_FPU_H
6 #define CGEN_FPU_H
8 /* Floating point support is a little more complicated.
9 We want to support using either host fp insns or an accurate fp library.
10 We also want to support easily added variants (e.g. modified ieee).
11 This is done by vectoring all calls through a table. */
13 typedef USI SF;
14 typedef UDI DF;
15 typedef struct { SI parts[3]; } XF;
16 typedef struct { SI parts[4]; } TF;
18 #ifndef TARGET_EXT_FP_WORDS
19 #define TARGET_EXT_FP_WORDS 4
20 #endif
22 /* Supported floating point conversion kinds (rounding modes).
23 FIXME: The IEEE rounding modes need to be implemented. */
25 typedef enum {
26 FPCONV_DEFAULT = 0,
27 FPCONV_TIES_TO_EVEN = 1,
28 FPCONV_TIES_TO_AWAY = 2,
29 FPCONV_TOWARD_ZERO = 3,
30 FPCONV_TOWARD_POSITIVE = 4,
31 FPCONV_TOWARD_NEGATIVE = 5
32 } CGEN_FPCONV_KIND;
34 /* forward decl */
35 typedef struct cgen_fp_ops CGEN_FP_OPS;
37 /* Instance of an fpu. */
39 typedef struct {
40 /* Usually a pointer back to the SIM_CPU struct. */
41 void* owner;
42 /* Pointer to ops struct, rather than copy of it, to avoid bloating
43 SIM_CPU struct. */
44 CGEN_FP_OPS* ops;
45 } CGEN_FPU;
47 /* result of cmp */
49 typedef enum {
50 /* ??? May wish to distinguish qnan/snan here. */
51 FP_CMP_EQ, FP_CMP_LT, FP_CMP_GT, FP_CMP_NAN
52 } CGEN_FP_CMP;
54 /* error handler */
56 typedef void (CGEN_FPU_ERROR_FN) (CGEN_FPU*, int);
58 /* fpu operation table */
60 struct cgen_fp_ops {
62 /* error (e.g. signalling nan) handler, supplied by owner */
64 CGEN_FPU_ERROR_FN *error;
66 /* basic SF ops */
68 SF (*addsf) (CGEN_FPU*, SF, SF);
69 SF (*subsf) (CGEN_FPU*, SF, SF);
70 SF (*mulsf) (CGEN_FPU*, SF, SF);
71 SF (*divsf) (CGEN_FPU*, SF, SF);
72 SF (*remsf) (CGEN_FPU*, SF, SF);
73 SF (*negsf) (CGEN_FPU*, SF);
74 SF (*abssf) (CGEN_FPU*, SF);
75 SF (*sqrtsf) (CGEN_FPU*, SF);
76 SF (*invsf) (CGEN_FPU*, SF);
77 SF (*cossf) (CGEN_FPU*, SF);
78 SF (*sinsf) (CGEN_FPU*, SF);
79 SF (*minsf) (CGEN_FPU*, SF, SF);
80 SF (*maxsf) (CGEN_FPU*, SF, SF);
82 /* ??? to be revisited */
83 CGEN_FP_CMP (*cmpsf) (CGEN_FPU*, SF, SF);
84 int (*eqsf) (CGEN_FPU*, SF, SF);
85 int (*nesf) (CGEN_FPU*, SF, SF);
86 int (*ltsf) (CGEN_FPU*, SF, SF);
87 int (*lesf) (CGEN_FPU*, SF, SF);
88 int (*gtsf) (CGEN_FPU*, SF, SF);
89 int (*gesf) (CGEN_FPU*, SF, SF);
91 /* basic DF ops */
93 DF (*adddf) (CGEN_FPU*, DF, DF);
94 DF (*subdf) (CGEN_FPU*, DF, DF);
95 DF (*muldf) (CGEN_FPU*, DF, DF);
96 DF (*divdf) (CGEN_FPU*, DF, DF);
97 DF (*remdf) (CGEN_FPU*, DF, DF);
98 DF (*negdf) (CGEN_FPU*, DF);
99 DF (*absdf) (CGEN_FPU*, DF);
100 DF (*sqrtdf) (CGEN_FPU*, DF);
101 DF (*invdf) (CGEN_FPU*, DF);
102 DF (*cosdf) (CGEN_FPU*, DF);
103 DF (*sindf) (CGEN_FPU*, DF);
104 DF (*mindf) (CGEN_FPU*, DF, DF);
105 DF (*maxdf) (CGEN_FPU*, DF, DF);
107 /* ??? to be revisited */
108 CGEN_FP_CMP (*cmpdf) (CGEN_FPU*, DF, DF);
109 int (*eqdf) (CGEN_FPU*, DF, DF);
110 int (*nedf) (CGEN_FPU*, DF, DF);
111 int (*ltdf) (CGEN_FPU*, DF, DF);
112 int (*ledf) (CGEN_FPU*, DF, DF);
113 int (*gtdf) (CGEN_FPU*, DF, DF);
114 int (*gedf) (CGEN_FPU*, DF, DF);
116 /* SF/DF conversion ops */
118 DF (*fextsfdf) (CGEN_FPU*, int, SF);
119 SF (*ftruncdfsf) (CGEN_FPU*, int, DF);
121 SF (*floatsisf) (CGEN_FPU*, int, SI);
122 SF (*floatdisf) (CGEN_FPU*, int, DI);
123 SF (*ufloatsisf) (CGEN_FPU*, int, USI);
124 SF (*ufloatdisf) (CGEN_FPU*, int, UDI);
126 SI (*fixsfsi) (CGEN_FPU*, int, SF);
127 DI (*fixsfdi) (CGEN_FPU*, int, SF);
128 USI (*ufixsfsi) (CGEN_FPU*, int, SF);
129 UDI (*ufixsfdi) (CGEN_FPU*, int, SF);
131 DF (*floatsidf) (CGEN_FPU*, int, SI);
132 DF (*floatdidf) (CGEN_FPU*, int, DI);
133 DF (*ufloatsidf) (CGEN_FPU*, int, USI);
134 DF (*ufloatdidf) (CGEN_FPU*, int, UDI);
136 SI (*fixdfsi) (CGEN_FPU*, int, DF);
137 DI (*fixdfdi) (CGEN_FPU*, int, DF);
138 USI (*ufixdfsi) (CGEN_FPU*, int, DF);
139 UDI (*ufixdfdi) (CGEN_FPU*, int, DF);
141 /* XF mode support (kept separate 'cus not always present) */
143 XF (*addxf) (CGEN_FPU*, XF, XF);
144 XF (*subxf) (CGEN_FPU*, XF, XF);
145 XF (*mulxf) (CGEN_FPU*, XF, XF);
146 XF (*divxf) (CGEN_FPU*, XF, XF);
147 XF (*remxf) (CGEN_FPU*, XF, XF);
148 XF (*negxf) (CGEN_FPU*, XF);
149 XF (*absxf) (CGEN_FPU*, XF);
150 XF (*sqrtxf) (CGEN_FPU*, XF);
151 XF (*invxf) (CGEN_FPU*, XF);
152 XF (*cosxf) (CGEN_FPU*, XF);
153 XF (*sinxf) (CGEN_FPU*, XF);
154 XF (*minxf) (CGEN_FPU*, XF, XF);
155 XF (*maxxf) (CGEN_FPU*, XF, XF);
157 CGEN_FP_CMP (*cmpxf) (CGEN_FPU*, XF, XF);
158 int (*eqxf) (CGEN_FPU*, XF, XF);
159 int (*nexf) (CGEN_FPU*, XF, XF);
160 int (*ltxf) (CGEN_FPU*, XF, XF);
161 int (*lexf) (CGEN_FPU*, XF, XF);
162 int (*gtxf) (CGEN_FPU*, XF, XF);
163 int (*gexf) (CGEN_FPU*, XF, XF);
165 XF (*extsfxf) (CGEN_FPU*, int, SF);
166 XF (*extdfxf) (CGEN_FPU*, int, DF);
167 SF (*truncxfsf) (CGEN_FPU*, int, XF);
168 DF (*truncxfdf) (CGEN_FPU*, int, XF);
170 XF (*floatsixf) (CGEN_FPU*, int, SI);
171 XF (*floatdixf) (CGEN_FPU*, int, DI);
172 XF (*ufloatsixf) (CGEN_FPU*, int, USI);
173 XF (*ufloatdixf) (CGEN_FPU*, int, UDI);
175 SI (*fixxfsi) (CGEN_FPU*, int, XF);
176 DI (*fixxfdi) (CGEN_FPU*, int, XF);
177 USI (*ufixxfsi) (CGEN_FPU*, int, XF);
178 UDI (*ufixxfdi) (CGEN_FPU*, int, XF);
180 /* TF mode support (kept separate 'cus not always present) */
182 TF (*addtf) (CGEN_FPU*, TF, TF);
183 TF (*subtf) (CGEN_FPU*, TF, TF);
184 TF (*multf) (CGEN_FPU*, TF, TF);
185 TF (*divtf) (CGEN_FPU*, TF, TF);
186 TF (*remtf) (CGEN_FPU*, TF, TF);
187 TF (*negtf) (CGEN_FPU*, TF);
188 TF (*abstf) (CGEN_FPU*, TF);
189 TF (*sqrttf) (CGEN_FPU*, TF);
190 TF (*invtf) (CGEN_FPU*, TF);
191 TF (*costf) (CGEN_FPU*, TF);
192 TF (*sintf) (CGEN_FPU*, TF);
193 TF (*mintf) (CGEN_FPU*, TF, TF);
194 TF (*maxtf) (CGEN_FPU*, TF, TF);
196 CGEN_FP_CMP (*cmptf) (CGEN_FPU*, TF, TF);
197 int (*eqtf) (CGEN_FPU*, TF, TF);
198 int (*netf) (CGEN_FPU*, TF, TF);
199 int (*lttf) (CGEN_FPU*, TF, TF);
200 int (*letf) (CGEN_FPU*, TF, TF);
201 int (*gttf) (CGEN_FPU*, TF, TF);
202 int (*getf) (CGEN_FPU*, TF, TF);
204 TF (*extsftf) (CGEN_FPU*, int, SF);
205 TF (*extdftf) (CGEN_FPU*, int, DF);
206 SF (*trunctfsf) (CGEN_FPU*, int, TF);
207 DF (*trunctfdf) (CGEN_FPU*, int, TF);
209 TF (*floatsitf) (CGEN_FPU*, int, SI);
210 TF (*floatditf) (CGEN_FPU*, int, DI);
211 TF (*ufloatsitf) (CGEN_FPU*, int, USI);
212 TF (*ufloatditf) (CGEN_FPU*, int, UDI);
214 SI (*fixtfsi) (CGEN_FPU*, int, TF);
215 DI (*fixtfdi) (CGEN_FPU*, int, TF);
216 USI (*ufixtfsi) (CGEN_FPU*, int, TF);
217 UDI (*ufixtfdi) (CGEN_FPU*, int, TF);
221 extern void cgen_init_accurate_fpu (SIM_CPU*, CGEN_FPU*, CGEN_FPU_ERROR_FN*);
223 BI cgen_sf_snan_p (CGEN_FPU*, SF);
224 BI cgen_df_snan_p (CGEN_FPU*, DF);
226 /* no-op fp error handler */
227 extern CGEN_FPU_ERROR_FN cgen_fpu_ignore_errors;
229 #endif /* CGEN_FPU_H */