1fcf5ef2aSThomas Huth /*
2fcf5ef2aSThomas Huth * Helpers for vax floating point instructions.
3fcf5ef2aSThomas Huth *
4fcf5ef2aSThomas Huth * Copyright (c) 2007 Jocelyn Mayer
5fcf5ef2aSThomas Huth *
6fcf5ef2aSThomas Huth * This library is free software; you can redistribute it and/or
7fcf5ef2aSThomas Huth * modify it under the terms of the GNU Lesser General Public
8fcf5ef2aSThomas Huth * License as published by the Free Software Foundation; either
9*d6ea4236SChetan Pant * version 2.1 of the License, or (at your option) any later version.
10fcf5ef2aSThomas Huth *
11fcf5ef2aSThomas Huth * This library is distributed in the hope that it will be useful,
12fcf5ef2aSThomas Huth * but WITHOUT ANY WARRANTY; without even the implied warranty of
13fcf5ef2aSThomas Huth * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14fcf5ef2aSThomas Huth * Lesser General Public License for more details.
15fcf5ef2aSThomas Huth *
16fcf5ef2aSThomas Huth * You should have received a copy of the GNU Lesser General Public
17fcf5ef2aSThomas Huth * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18fcf5ef2aSThomas Huth */
19fcf5ef2aSThomas Huth
20fcf5ef2aSThomas Huth #include "qemu/osdep.h"
21fcf5ef2aSThomas Huth #include "cpu.h"
22fcf5ef2aSThomas Huth #include "exec/exec-all.h"
23fcf5ef2aSThomas Huth #include "exec/helper-proto.h"
24fcf5ef2aSThomas Huth #include "fpu/softfloat.h"
25fcf5ef2aSThomas Huth
26fcf5ef2aSThomas Huth #define FP_STATUS (env->fp_status)
27fcf5ef2aSThomas Huth
28fcf5ef2aSThomas Huth
29fcf5ef2aSThomas Huth /* F floating (VAX) */
float32_to_f(float32 fa)30fcf5ef2aSThomas Huth static uint64_t float32_to_f(float32 fa)
31fcf5ef2aSThomas Huth {
32fcf5ef2aSThomas Huth uint64_t r, exp, mant, sig;
33fcf5ef2aSThomas Huth CPU_FloatU a;
34fcf5ef2aSThomas Huth
35fcf5ef2aSThomas Huth a.f = fa;
36fcf5ef2aSThomas Huth sig = ((uint64_t)a.l & 0x80000000) << 32;
37fcf5ef2aSThomas Huth exp = (a.l >> 23) & 0xff;
38fcf5ef2aSThomas Huth mant = ((uint64_t)a.l & 0x007fffff) << 29;
39fcf5ef2aSThomas Huth
40fcf5ef2aSThomas Huth if (exp == 255) {
41fcf5ef2aSThomas Huth /* NaN or infinity */
42fcf5ef2aSThomas Huth r = 1; /* VAX dirty zero */
43fcf5ef2aSThomas Huth } else if (exp == 0) {
44fcf5ef2aSThomas Huth if (mant == 0) {
45fcf5ef2aSThomas Huth /* Zero */
46fcf5ef2aSThomas Huth r = 0;
47fcf5ef2aSThomas Huth } else {
48fcf5ef2aSThomas Huth /* Denormalized */
49fcf5ef2aSThomas Huth r = sig | ((exp + 1) << 52) | mant;
50fcf5ef2aSThomas Huth }
51fcf5ef2aSThomas Huth } else {
52fcf5ef2aSThomas Huth if (exp >= 253) {
53fcf5ef2aSThomas Huth /* Overflow */
54fcf5ef2aSThomas Huth r = 1; /* VAX dirty zero */
55fcf5ef2aSThomas Huth } else {
56fcf5ef2aSThomas Huth r = sig | ((exp + 2) << 52);
57fcf5ef2aSThomas Huth }
58fcf5ef2aSThomas Huth }
59fcf5ef2aSThomas Huth
60fcf5ef2aSThomas Huth return r;
61fcf5ef2aSThomas Huth }
62fcf5ef2aSThomas Huth
f_to_float32(CPUAlphaState * env,uintptr_t retaddr,uint64_t a)63fcf5ef2aSThomas Huth static float32 f_to_float32(CPUAlphaState *env, uintptr_t retaddr, uint64_t a)
64fcf5ef2aSThomas Huth {
65fcf5ef2aSThomas Huth uint32_t exp, mant_sig;
66fcf5ef2aSThomas Huth CPU_FloatU r;
67fcf5ef2aSThomas Huth
68fcf5ef2aSThomas Huth exp = ((a >> 55) & 0x80) | ((a >> 52) & 0x7f);
69fcf5ef2aSThomas Huth mant_sig = ((a >> 32) & 0x80000000) | ((a >> 29) & 0x007fffff);
70fcf5ef2aSThomas Huth
71fcf5ef2aSThomas Huth if (unlikely(!exp && mant_sig)) {
72fcf5ef2aSThomas Huth /* Reserved operands / Dirty zero */
73fcf5ef2aSThomas Huth dynamic_excp(env, retaddr, EXCP_OPCDEC, 0);
74fcf5ef2aSThomas Huth }
75fcf5ef2aSThomas Huth
76fcf5ef2aSThomas Huth if (exp < 3) {
77fcf5ef2aSThomas Huth /* Underflow */
78fcf5ef2aSThomas Huth r.l = 0;
79fcf5ef2aSThomas Huth } else {
80fcf5ef2aSThomas Huth r.l = ((exp - 2) << 23) | mant_sig;
81fcf5ef2aSThomas Huth }
82fcf5ef2aSThomas Huth
83fcf5ef2aSThomas Huth return r.f;
84fcf5ef2aSThomas Huth }
85fcf5ef2aSThomas Huth
helper_f_to_memory(uint64_t a)86fcf5ef2aSThomas Huth uint32_t helper_f_to_memory(uint64_t a)
87fcf5ef2aSThomas Huth {
88fcf5ef2aSThomas Huth uint32_t r;
89fcf5ef2aSThomas Huth r = (a & 0x00001fffe0000000ull) >> 13;
90fcf5ef2aSThomas Huth r |= (a & 0x07ffe00000000000ull) >> 45;
91fcf5ef2aSThomas Huth r |= (a & 0xc000000000000000ull) >> 48;
92fcf5ef2aSThomas Huth return r;
93fcf5ef2aSThomas Huth }
94fcf5ef2aSThomas Huth
helper_memory_to_f(uint32_t a)95fcf5ef2aSThomas Huth uint64_t helper_memory_to_f(uint32_t a)
96fcf5ef2aSThomas Huth {
97fcf5ef2aSThomas Huth uint64_t r;
98fcf5ef2aSThomas Huth r = ((uint64_t)(a & 0x0000c000)) << 48;
99fcf5ef2aSThomas Huth r |= ((uint64_t)(a & 0x003fffff)) << 45;
100fcf5ef2aSThomas Huth r |= ((uint64_t)(a & 0xffff0000)) << 13;
101fcf5ef2aSThomas Huth if (!(a & 0x00004000)) {
102fcf5ef2aSThomas Huth r |= 0x7ll << 59;
103fcf5ef2aSThomas Huth }
104fcf5ef2aSThomas Huth return r;
105fcf5ef2aSThomas Huth }
106fcf5ef2aSThomas Huth
107fcf5ef2aSThomas Huth /* ??? Emulating VAX arithmetic with IEEE arithmetic is wrong. We should
108fcf5ef2aSThomas Huth either implement VAX arithmetic properly or just signal invalid opcode. */
109fcf5ef2aSThomas Huth
helper_addf(CPUAlphaState * env,uint64_t a,uint64_t b)110fcf5ef2aSThomas Huth uint64_t helper_addf(CPUAlphaState *env, uint64_t a, uint64_t b)
111fcf5ef2aSThomas Huth {
112fcf5ef2aSThomas Huth float32 fa, fb, fr;
113fcf5ef2aSThomas Huth
114fcf5ef2aSThomas Huth fa = f_to_float32(env, GETPC(), a);
115fcf5ef2aSThomas Huth fb = f_to_float32(env, GETPC(), b);
116fcf5ef2aSThomas Huth fr = float32_add(fa, fb, &FP_STATUS);
117fcf5ef2aSThomas Huth return float32_to_f(fr);
118fcf5ef2aSThomas Huth }
119fcf5ef2aSThomas Huth
helper_subf(CPUAlphaState * env,uint64_t a,uint64_t b)120fcf5ef2aSThomas Huth uint64_t helper_subf(CPUAlphaState *env, uint64_t a, uint64_t b)
121fcf5ef2aSThomas Huth {
122fcf5ef2aSThomas Huth float32 fa, fb, fr;
123fcf5ef2aSThomas Huth
124fcf5ef2aSThomas Huth fa = f_to_float32(env, GETPC(), a);
125fcf5ef2aSThomas Huth fb = f_to_float32(env, GETPC(), b);
126fcf5ef2aSThomas Huth fr = float32_sub(fa, fb, &FP_STATUS);
127fcf5ef2aSThomas Huth return float32_to_f(fr);
128fcf5ef2aSThomas Huth }
129fcf5ef2aSThomas Huth
helper_mulf(CPUAlphaState * env,uint64_t a,uint64_t b)130fcf5ef2aSThomas Huth uint64_t helper_mulf(CPUAlphaState *env, uint64_t a, uint64_t b)
131fcf5ef2aSThomas Huth {
132fcf5ef2aSThomas Huth float32 fa, fb, fr;
133fcf5ef2aSThomas Huth
134fcf5ef2aSThomas Huth fa = f_to_float32(env, GETPC(), a);
135fcf5ef2aSThomas Huth fb = f_to_float32(env, GETPC(), b);
136fcf5ef2aSThomas Huth fr = float32_mul(fa, fb, &FP_STATUS);
137fcf5ef2aSThomas Huth return float32_to_f(fr);
138fcf5ef2aSThomas Huth }
139fcf5ef2aSThomas Huth
helper_divf(CPUAlphaState * env,uint64_t a,uint64_t b)140fcf5ef2aSThomas Huth uint64_t helper_divf(CPUAlphaState *env, uint64_t a, uint64_t b)
141fcf5ef2aSThomas Huth {
142fcf5ef2aSThomas Huth float32 fa, fb, fr;
143fcf5ef2aSThomas Huth
144fcf5ef2aSThomas Huth fa = f_to_float32(env, GETPC(), a);
145fcf5ef2aSThomas Huth fb = f_to_float32(env, GETPC(), b);
146fcf5ef2aSThomas Huth fr = float32_div(fa, fb, &FP_STATUS);
147fcf5ef2aSThomas Huth return float32_to_f(fr);
148fcf5ef2aSThomas Huth }
149fcf5ef2aSThomas Huth
helper_sqrtf(CPUAlphaState * env,uint64_t t)150fcf5ef2aSThomas Huth uint64_t helper_sqrtf(CPUAlphaState *env, uint64_t t)
151fcf5ef2aSThomas Huth {
152fcf5ef2aSThomas Huth float32 ft, fr;
153fcf5ef2aSThomas Huth
154fcf5ef2aSThomas Huth ft = f_to_float32(env, GETPC(), t);
155fcf5ef2aSThomas Huth fr = float32_sqrt(ft, &FP_STATUS);
156fcf5ef2aSThomas Huth return float32_to_f(fr);
157fcf5ef2aSThomas Huth }
158fcf5ef2aSThomas Huth
159fcf5ef2aSThomas Huth
160fcf5ef2aSThomas Huth /* G floating (VAX) */
float64_to_g(float64 fa)161fcf5ef2aSThomas Huth static uint64_t float64_to_g(float64 fa)
162fcf5ef2aSThomas Huth {
163fcf5ef2aSThomas Huth uint64_t r, exp, mant, sig;
164fcf5ef2aSThomas Huth CPU_DoubleU a;
165fcf5ef2aSThomas Huth
166fcf5ef2aSThomas Huth a.d = fa;
167fcf5ef2aSThomas Huth sig = a.ll & 0x8000000000000000ull;
168fcf5ef2aSThomas Huth exp = (a.ll >> 52) & 0x7ff;
169fcf5ef2aSThomas Huth mant = a.ll & 0x000fffffffffffffull;
170fcf5ef2aSThomas Huth
171fcf5ef2aSThomas Huth if (exp == 2047) {
172fcf5ef2aSThomas Huth /* NaN or infinity */
173fcf5ef2aSThomas Huth r = 1; /* VAX dirty zero */
174fcf5ef2aSThomas Huth } else if (exp == 0) {
175fcf5ef2aSThomas Huth if (mant == 0) {
176fcf5ef2aSThomas Huth /* Zero */
177fcf5ef2aSThomas Huth r = 0;
178fcf5ef2aSThomas Huth } else {
179fcf5ef2aSThomas Huth /* Denormalized */
180fcf5ef2aSThomas Huth r = sig | ((exp + 1) << 52) | mant;
181fcf5ef2aSThomas Huth }
182fcf5ef2aSThomas Huth } else {
183fcf5ef2aSThomas Huth if (exp >= 2045) {
184fcf5ef2aSThomas Huth /* Overflow */
185fcf5ef2aSThomas Huth r = 1; /* VAX dirty zero */
186fcf5ef2aSThomas Huth } else {
187fcf5ef2aSThomas Huth r = sig | ((exp + 2) << 52);
188fcf5ef2aSThomas Huth }
189fcf5ef2aSThomas Huth }
190fcf5ef2aSThomas Huth
191fcf5ef2aSThomas Huth return r;
192fcf5ef2aSThomas Huth }
193fcf5ef2aSThomas Huth
g_to_float64(CPUAlphaState * env,uintptr_t retaddr,uint64_t a)194fcf5ef2aSThomas Huth static float64 g_to_float64(CPUAlphaState *env, uintptr_t retaddr, uint64_t a)
195fcf5ef2aSThomas Huth {
196fcf5ef2aSThomas Huth uint64_t exp, mant_sig;
197fcf5ef2aSThomas Huth CPU_DoubleU r;
198fcf5ef2aSThomas Huth
199fcf5ef2aSThomas Huth exp = (a >> 52) & 0x7ff;
200fcf5ef2aSThomas Huth mant_sig = a & 0x800fffffffffffffull;
201fcf5ef2aSThomas Huth
202fcf5ef2aSThomas Huth if (!exp && mant_sig) {
203fcf5ef2aSThomas Huth /* Reserved operands / Dirty zero */
204fcf5ef2aSThomas Huth dynamic_excp(env, retaddr, EXCP_OPCDEC, 0);
205fcf5ef2aSThomas Huth }
206fcf5ef2aSThomas Huth
207fcf5ef2aSThomas Huth if (exp < 3) {
208fcf5ef2aSThomas Huth /* Underflow */
209fcf5ef2aSThomas Huth r.ll = 0;
210fcf5ef2aSThomas Huth } else {
211fcf5ef2aSThomas Huth r.ll = ((exp - 2) << 52) | mant_sig;
212fcf5ef2aSThomas Huth }
213fcf5ef2aSThomas Huth
214fcf5ef2aSThomas Huth return r.d;
215fcf5ef2aSThomas Huth }
216fcf5ef2aSThomas Huth
helper_g_to_memory(uint64_t a)217fcf5ef2aSThomas Huth uint64_t helper_g_to_memory(uint64_t a)
218fcf5ef2aSThomas Huth {
219fcf5ef2aSThomas Huth uint64_t r;
220fcf5ef2aSThomas Huth r = (a & 0x000000000000ffffull) << 48;
221fcf5ef2aSThomas Huth r |= (a & 0x00000000ffff0000ull) << 16;
222fcf5ef2aSThomas Huth r |= (a & 0x0000ffff00000000ull) >> 16;
223fcf5ef2aSThomas Huth r |= (a & 0xffff000000000000ull) >> 48;
224fcf5ef2aSThomas Huth return r;
225fcf5ef2aSThomas Huth }
226fcf5ef2aSThomas Huth
helper_memory_to_g(uint64_t a)227fcf5ef2aSThomas Huth uint64_t helper_memory_to_g(uint64_t a)
228fcf5ef2aSThomas Huth {
229fcf5ef2aSThomas Huth uint64_t r;
230fcf5ef2aSThomas Huth r = (a & 0x000000000000ffffull) << 48;
231fcf5ef2aSThomas Huth r |= (a & 0x00000000ffff0000ull) << 16;
232fcf5ef2aSThomas Huth r |= (a & 0x0000ffff00000000ull) >> 16;
233fcf5ef2aSThomas Huth r |= (a & 0xffff000000000000ull) >> 48;
234fcf5ef2aSThomas Huth return r;
235fcf5ef2aSThomas Huth }
236fcf5ef2aSThomas Huth
helper_addg(CPUAlphaState * env,uint64_t a,uint64_t b)237fcf5ef2aSThomas Huth uint64_t helper_addg(CPUAlphaState *env, uint64_t a, uint64_t b)
238fcf5ef2aSThomas Huth {
239fcf5ef2aSThomas Huth float64 fa, fb, fr;
240fcf5ef2aSThomas Huth
241fcf5ef2aSThomas Huth fa = g_to_float64(env, GETPC(), a);
242fcf5ef2aSThomas Huth fb = g_to_float64(env, GETPC(), b);
243fcf5ef2aSThomas Huth fr = float64_add(fa, fb, &FP_STATUS);
244fcf5ef2aSThomas Huth return float64_to_g(fr);
245fcf5ef2aSThomas Huth }
246fcf5ef2aSThomas Huth
helper_subg(CPUAlphaState * env,uint64_t a,uint64_t b)247fcf5ef2aSThomas Huth uint64_t helper_subg(CPUAlphaState *env, uint64_t a, uint64_t b)
248fcf5ef2aSThomas Huth {
249fcf5ef2aSThomas Huth float64 fa, fb, fr;
250fcf5ef2aSThomas Huth
251fcf5ef2aSThomas Huth fa = g_to_float64(env, GETPC(), a);
252fcf5ef2aSThomas Huth fb = g_to_float64(env, GETPC(), b);
253fcf5ef2aSThomas Huth fr = float64_sub(fa, fb, &FP_STATUS);
254fcf5ef2aSThomas Huth return float64_to_g(fr);
255fcf5ef2aSThomas Huth }
256fcf5ef2aSThomas Huth
helper_mulg(CPUAlphaState * env,uint64_t a,uint64_t b)257fcf5ef2aSThomas Huth uint64_t helper_mulg(CPUAlphaState *env, uint64_t a, uint64_t b)
258fcf5ef2aSThomas Huth {
259fcf5ef2aSThomas Huth float64 fa, fb, fr;
260fcf5ef2aSThomas Huth
261fcf5ef2aSThomas Huth fa = g_to_float64(env, GETPC(), a);
262fcf5ef2aSThomas Huth fb = g_to_float64(env, GETPC(), b);
263fcf5ef2aSThomas Huth fr = float64_mul(fa, fb, &FP_STATUS);
264fcf5ef2aSThomas Huth return float64_to_g(fr);
265fcf5ef2aSThomas Huth }
266fcf5ef2aSThomas Huth
helper_divg(CPUAlphaState * env,uint64_t a,uint64_t b)267fcf5ef2aSThomas Huth uint64_t helper_divg(CPUAlphaState *env, uint64_t a, uint64_t b)
268fcf5ef2aSThomas Huth {
269fcf5ef2aSThomas Huth float64 fa, fb, fr;
270fcf5ef2aSThomas Huth
271fcf5ef2aSThomas Huth fa = g_to_float64(env, GETPC(), a);
272fcf5ef2aSThomas Huth fb = g_to_float64(env, GETPC(), b);
273fcf5ef2aSThomas Huth fr = float64_div(fa, fb, &FP_STATUS);
274fcf5ef2aSThomas Huth return float64_to_g(fr);
275fcf5ef2aSThomas Huth }
276fcf5ef2aSThomas Huth
helper_sqrtg(CPUAlphaState * env,uint64_t a)277fcf5ef2aSThomas Huth uint64_t helper_sqrtg(CPUAlphaState *env, uint64_t a)
278fcf5ef2aSThomas Huth {
279fcf5ef2aSThomas Huth float64 fa, fr;
280fcf5ef2aSThomas Huth
281fcf5ef2aSThomas Huth fa = g_to_float64(env, GETPC(), a);
282fcf5ef2aSThomas Huth fr = float64_sqrt(fa, &FP_STATUS);
283fcf5ef2aSThomas Huth return float64_to_g(fr);
284fcf5ef2aSThomas Huth }
285fcf5ef2aSThomas Huth
helper_cmpgeq(CPUAlphaState * env,uint64_t a,uint64_t b)286fcf5ef2aSThomas Huth uint64_t helper_cmpgeq(CPUAlphaState *env, uint64_t a, uint64_t b)
287fcf5ef2aSThomas Huth {
288fcf5ef2aSThomas Huth float64 fa, fb;
289fcf5ef2aSThomas Huth
290fcf5ef2aSThomas Huth fa = g_to_float64(env, GETPC(), a);
291fcf5ef2aSThomas Huth fb = g_to_float64(env, GETPC(), b);
292fcf5ef2aSThomas Huth
293fcf5ef2aSThomas Huth if (float64_eq_quiet(fa, fb, &FP_STATUS)) {
294fcf5ef2aSThomas Huth return 0x4000000000000000ULL;
295fcf5ef2aSThomas Huth } else {
296fcf5ef2aSThomas Huth return 0;
297fcf5ef2aSThomas Huth }
298fcf5ef2aSThomas Huth }
299fcf5ef2aSThomas Huth
helper_cmpgle(CPUAlphaState * env,uint64_t a,uint64_t b)300fcf5ef2aSThomas Huth uint64_t helper_cmpgle(CPUAlphaState *env, uint64_t a, uint64_t b)
301fcf5ef2aSThomas Huth {
302fcf5ef2aSThomas Huth float64 fa, fb;
303fcf5ef2aSThomas Huth
304fcf5ef2aSThomas Huth fa = g_to_float64(env, GETPC(), a);
305fcf5ef2aSThomas Huth fb = g_to_float64(env, GETPC(), b);
306fcf5ef2aSThomas Huth
307fcf5ef2aSThomas Huth if (float64_le(fa, fb, &FP_STATUS)) {
308fcf5ef2aSThomas Huth return 0x4000000000000000ULL;
309fcf5ef2aSThomas Huth } else {
310fcf5ef2aSThomas Huth return 0;
311fcf5ef2aSThomas Huth }
312fcf5ef2aSThomas Huth }
313fcf5ef2aSThomas Huth
helper_cmpglt(CPUAlphaState * env,uint64_t a,uint64_t b)314fcf5ef2aSThomas Huth uint64_t helper_cmpglt(CPUAlphaState *env, uint64_t a, uint64_t b)
315fcf5ef2aSThomas Huth {
316fcf5ef2aSThomas Huth float64 fa, fb;
317fcf5ef2aSThomas Huth
318fcf5ef2aSThomas Huth fa = g_to_float64(env, GETPC(), a);
319fcf5ef2aSThomas Huth fb = g_to_float64(env, GETPC(), b);
320fcf5ef2aSThomas Huth
321fcf5ef2aSThomas Huth if (float64_lt(fa, fb, &FP_STATUS)) {
322fcf5ef2aSThomas Huth return 0x4000000000000000ULL;
323fcf5ef2aSThomas Huth } else {
324fcf5ef2aSThomas Huth return 0;
325fcf5ef2aSThomas Huth }
326fcf5ef2aSThomas Huth }
327fcf5ef2aSThomas Huth
helper_cvtqf(CPUAlphaState * env,uint64_t a)328fcf5ef2aSThomas Huth uint64_t helper_cvtqf(CPUAlphaState *env, uint64_t a)
329fcf5ef2aSThomas Huth {
330fcf5ef2aSThomas Huth float32 fr = int64_to_float32(a, &FP_STATUS);
331fcf5ef2aSThomas Huth return float32_to_f(fr);
332fcf5ef2aSThomas Huth }
333fcf5ef2aSThomas Huth
helper_cvtgf(CPUAlphaState * env,uint64_t a)334fcf5ef2aSThomas Huth uint64_t helper_cvtgf(CPUAlphaState *env, uint64_t a)
335fcf5ef2aSThomas Huth {
336fcf5ef2aSThomas Huth float64 fa;
337fcf5ef2aSThomas Huth float32 fr;
338fcf5ef2aSThomas Huth
339fcf5ef2aSThomas Huth fa = g_to_float64(env, GETPC(), a);
340fcf5ef2aSThomas Huth fr = float64_to_float32(fa, &FP_STATUS);
341fcf5ef2aSThomas Huth return float32_to_f(fr);
342fcf5ef2aSThomas Huth }
343fcf5ef2aSThomas Huth
helper_cvtgq(CPUAlphaState * env,uint64_t a)344fcf5ef2aSThomas Huth uint64_t helper_cvtgq(CPUAlphaState *env, uint64_t a)
345fcf5ef2aSThomas Huth {
346fcf5ef2aSThomas Huth float64 fa = g_to_float64(env, GETPC(), a);
347fcf5ef2aSThomas Huth return float64_to_int64_round_to_zero(fa, &FP_STATUS);
348fcf5ef2aSThomas Huth }
349fcf5ef2aSThomas Huth
helper_cvtqg(CPUAlphaState * env,uint64_t a)350fcf5ef2aSThomas Huth uint64_t helper_cvtqg(CPUAlphaState *env, uint64_t a)
351fcf5ef2aSThomas Huth {
352fcf5ef2aSThomas Huth float64 fr;
353fcf5ef2aSThomas Huth fr = int64_to_float64(a, &FP_STATUS);
354fcf5ef2aSThomas Huth return float64_to_g(fr);
355fcf5ef2aSThomas Huth }
356