Revision 9ee6e8bb target-arm/op_helper.c

b/target-arm/op_helper.c
1 1
/*
2 2
 *  ARM helper routines
3 3
 *
4
 *  Copyright (c) 2005 CodeSourcery, LLC
4
 *  Copyright (c) 2005-2007 CodeSourcery, LLC
5 5
 *
6 6
 * This library is free software; you can redistribute it and/or
7 7
 * modify it under the terms of the GNU Lesser General Public
......
175 175
    T0 |= vfp_exceptbits_from_host(i);
176 176
}
177 177

  
178
float32 helper_recps_f32(float32 a, float32 b)
179
{
180
    float_status *s = &env->vfp.fp_status;
181
    float32 two = int32_to_float32(2, s);
182
    return float32_sub(two, float32_mul(a, b, s), s);
183
}
184

  
185
float32 helper_rsqrts_f32(float32 a, float32 b)
186
{
187
    float_status *s = &env->vfp.fp_status;
188
    float32 three = int32_to_float32(3, s);
189
    return float32_sub(three, float32_mul(a, b, s), s);
190
}
191

  
192
/* TODO: The architecture specifies the value that the estimate functions
193
   should return.  We return the exact reciprocal/root instead.  */
194
float32 helper_recpe_f32(float32 a)
195
{
196
    float_status *s = &env->vfp.fp_status;
197
    float32 one = int32_to_float32(1, s);
198
    return float32_div(one, a, s);
199
}
200

  
201
float32 helper_rsqrte_f32(float32 a)
202
{
203
    float_status *s = &env->vfp.fp_status;
204
    float32 one = int32_to_float32(1, s);
205
    return float32_div(one, float32_sqrt(a, s), s);
206
}
207

  
208
uint32_t helper_recpe_u32(uint32_t a)
209
{
210
    float_status *s = &env->vfp.fp_status;
211
    float32 tmp;
212
    tmp = int32_to_float32(a, s);
213
    tmp = float32_scalbn(tmp, -32, s);
214
    tmp = helper_recpe_f32(tmp);
215
    tmp = float32_scalbn(tmp, 31, s);
216
    return float32_to_int32(tmp, s);
217
}
218

  
219
uint32_t helper_rsqrte_u32(uint32_t a)
220
{
221
    float_status *s = &env->vfp.fp_status;
222
    float32 tmp;
223
    tmp = int32_to_float32(a, s);
224
    tmp = float32_scalbn(tmp, -32, s);
225
    tmp = helper_rsqrte_f32(tmp);
226
    tmp = float32_scalbn(tmp, 31, s);
227
    return float32_to_int32(tmp, s);
228
}
229

  
230
void helper_neon_tbl(int rn, int maxindex)
231
{
232
    uint32_t val;
233
    uint32_t mask;
234
    uint32_t tmp;
235
    int index;
236
    int shift;
237
    uint64_t *table;
238
    table = (uint64_t *)&env->vfp.regs[rn];
239
    val = 0;
240
    mask = 0;
241
    for (shift = 0; shift < 32; shift += 8) {
242
        index = (T1 >> shift) & 0xff;
243
        if (index <= maxindex) {
244
            tmp = (table[index >> 3] >> (index & 7)) & 0xff;
245
            val |= tmp << shift;
246
        } else {
247
            val |= T0 & (0xff << shift);
248
        }
249
    }
250
    T0 = val;
251
}
252

  
178 253
#if !defined(CONFIG_USER_ONLY)
179 254

  
180 255
#define MMUSUFFIX _mmu
......
227 302
    }
228 303
    env = saved_env;
229 304
}
230

  
231 305
#endif

Also available in: Unified diff