cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

fpu_helper.c (19468B)


      1/*
      2 *  m68k FPU helpers
      3 *
      4 *  Copyright (c) 2006-2007 CodeSourcery
      5 *  Written by Paul Brook
      6 *
      7 * This library is free software; you can redistribute it and/or
      8 * modify it under the terms of the GNU Lesser General Public
      9 * License as published by the Free Software Foundation; either
     10 * version 2.1 of the License, or (at your option) any later version.
     11 *
     12 * This library is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15 * Lesser General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU Lesser General Public
     18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
     19 */
     20
     21#include "qemu/osdep.h"
     22#include "cpu.h"
     23#include "exec/helper-proto.h"
     24#include "exec/exec-all.h"
     25#include "exec/cpu_ldst.h"
     26#include "softfloat.h"
     27
     28/*
     29 * Undefined offsets may be different on various FPU.
     30 * On 68040 they return 0.0 (floatx80_zero)
     31 */
     32
     33static const floatx80 fpu_rom[128] = {
     34    [0x00] = make_floatx80_init(0x4000, 0xc90fdaa22168c235ULL),  /* Pi       */
     35    [0x0b] = make_floatx80_init(0x3ffd, 0x9a209a84fbcff798ULL),  /* Log10(2) */
     36    [0x0c] = make_floatx80_init(0x4000, 0xadf85458a2bb4a9aULL),  /* e        */
     37    [0x0d] = make_floatx80_init(0x3fff, 0xb8aa3b295c17f0bcULL),  /* Log2(e)  */
     38    [0x0e] = make_floatx80_init(0x3ffd, 0xde5bd8a937287195ULL),  /* Log10(e) */
     39    [0x0f] = make_floatx80_init(0x0000, 0x0000000000000000ULL),  /* Zero     */
     40    [0x30] = make_floatx80_init(0x3ffe, 0xb17217f7d1cf79acULL),  /* ln(2)    */
     41    [0x31] = make_floatx80_init(0x4000, 0x935d8dddaaa8ac17ULL),  /* ln(10)   */
     42    [0x32] = make_floatx80_init(0x3fff, 0x8000000000000000ULL),  /* 10^0     */
     43    [0x33] = make_floatx80_init(0x4002, 0xa000000000000000ULL),  /* 10^1     */
     44    [0x34] = make_floatx80_init(0x4005, 0xc800000000000000ULL),  /* 10^2     */
     45    [0x35] = make_floatx80_init(0x400c, 0x9c40000000000000ULL),  /* 10^4     */
     46    [0x36] = make_floatx80_init(0x4019, 0xbebc200000000000ULL),  /* 10^8     */
     47    [0x37] = make_floatx80_init(0x4034, 0x8e1bc9bf04000000ULL),  /* 10^16    */
     48    [0x38] = make_floatx80_init(0x4069, 0x9dc5ada82b70b59eULL),  /* 10^32    */
     49    [0x39] = make_floatx80_init(0x40d3, 0xc2781f49ffcfa6d5ULL),  /* 10^64    */
     50    [0x3a] = make_floatx80_init(0x41a8, 0x93ba47c980e98ce0ULL),  /* 10^128   */
     51    [0x3b] = make_floatx80_init(0x4351, 0xaa7eebfb9df9de8eULL),  /* 10^256   */
     52    [0x3c] = make_floatx80_init(0x46a3, 0xe319a0aea60e91c7ULL),  /* 10^512   */
     53    [0x3d] = make_floatx80_init(0x4d48, 0xc976758681750c17ULL),  /* 10^1024  */
     54    [0x3e] = make_floatx80_init(0x5a92, 0x9e8b3b5dc53d5de5ULL),  /* 10^2048  */
     55    [0x3f] = make_floatx80_init(0x7525, 0xc46052028a20979bULL),  /* 10^4096  */
     56};
     57
     58int32_t HELPER(reds32)(CPUM68KState *env, FPReg *val)
     59{
     60    return floatx80_to_int32(val->d, &env->fp_status);
     61}
     62
     63float32 HELPER(redf32)(CPUM68KState *env, FPReg *val)
     64{
     65    return floatx80_to_float32(val->d, &env->fp_status);
     66}
     67
     68void HELPER(exts32)(CPUM68KState *env, FPReg *res, int32_t val)
     69{
     70    res->d = int32_to_floatx80(val, &env->fp_status);
     71}
     72
     73void HELPER(extf32)(CPUM68KState *env, FPReg *res, float32 val)
     74{
     75    res->d = float32_to_floatx80(val, &env->fp_status);
     76}
     77
     78void HELPER(extf64)(CPUM68KState *env, FPReg *res, float64 val)
     79{
     80    res->d = float64_to_floatx80(val, &env->fp_status);
     81}
     82
     83float64 HELPER(redf64)(CPUM68KState *env, FPReg *val)
     84{
     85    return floatx80_to_float64(val->d, &env->fp_status);
     86}
     87
     88void HELPER(firound)(CPUM68KState *env, FPReg *res, FPReg *val)
     89{
     90    res->d = floatx80_round_to_int(val->d, &env->fp_status);
     91}
     92
     93static void m68k_restore_precision_mode(CPUM68KState *env)
     94{
     95    switch (env->fpcr & FPCR_PREC_MASK) {
     96    case FPCR_PREC_X: /* extended */
     97        set_floatx80_rounding_precision(floatx80_precision_x, &env->fp_status);
     98        break;
     99    case FPCR_PREC_S: /* single */
    100        set_floatx80_rounding_precision(floatx80_precision_s, &env->fp_status);
    101        break;
    102    case FPCR_PREC_D: /* double */
    103        set_floatx80_rounding_precision(floatx80_precision_d, &env->fp_status);
    104        break;
    105    case FPCR_PREC_U: /* undefined */
    106    default:
    107        break;
    108    }
    109}
    110
    111static void cf_restore_precision_mode(CPUM68KState *env)
    112{
    113    if (env->fpcr & FPCR_PREC_S) { /* single */
    114        set_floatx80_rounding_precision(floatx80_precision_s, &env->fp_status);
    115    } else { /* double */
    116        set_floatx80_rounding_precision(floatx80_precision_d, &env->fp_status);
    117    }
    118}
    119
    120static void restore_rounding_mode(CPUM68KState *env)
    121{
    122    switch (env->fpcr & FPCR_RND_MASK) {
    123    case FPCR_RND_N: /* round to nearest */
    124        set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
    125        break;
    126    case FPCR_RND_Z: /* round to zero */
    127        set_float_rounding_mode(float_round_to_zero, &env->fp_status);
    128        break;
    129    case FPCR_RND_M: /* round toward minus infinity */
    130        set_float_rounding_mode(float_round_down, &env->fp_status);
    131        break;
    132    case FPCR_RND_P: /* round toward positive infinity */
    133        set_float_rounding_mode(float_round_up, &env->fp_status);
    134        break;
    135    }
    136}
    137
    138void cpu_m68k_restore_fp_status(CPUM68KState *env)
    139{
    140    if (m68k_feature(env, M68K_FEATURE_CF_FPU)) {
    141        cf_restore_precision_mode(env);
    142    } else {
    143        m68k_restore_precision_mode(env);
    144    }
    145    restore_rounding_mode(env);
    146}
    147
    148void cpu_m68k_set_fpcr(CPUM68KState *env, uint32_t val)
    149{
    150    env->fpcr = val & 0xffff;
    151    cpu_m68k_restore_fp_status(env);
    152}
    153
    154void HELPER(fitrunc)(CPUM68KState *env, FPReg *res, FPReg *val)
    155{
    156    FloatRoundMode rounding_mode = get_float_rounding_mode(&env->fp_status);
    157    set_float_rounding_mode(float_round_to_zero, &env->fp_status);
    158    res->d = floatx80_round_to_int(val->d, &env->fp_status);
    159    set_float_rounding_mode(rounding_mode, &env->fp_status);
    160}
    161
    162void HELPER(set_fpcr)(CPUM68KState *env, uint32_t val)
    163{
    164    cpu_m68k_set_fpcr(env, val);
    165}
    166
    167#define PREC_BEGIN(prec)                                        \
    168    do {                                                        \
    169        FloatX80RoundPrec old =                                 \
    170            get_floatx80_rounding_precision(&env->fp_status);   \
    171        set_floatx80_rounding_precision(prec, &env->fp_status)  \
    172
    173#define PREC_END()                                              \
    174        set_floatx80_rounding_precision(old, &env->fp_status);  \
    175    } while (0)
    176
    177void HELPER(fsround)(CPUM68KState *env, FPReg *res, FPReg *val)
    178{
    179    PREC_BEGIN(floatx80_precision_s);
    180    res->d = floatx80_round(val->d, &env->fp_status);
    181    PREC_END();
    182}
    183
    184void HELPER(fdround)(CPUM68KState *env, FPReg *res, FPReg *val)
    185{
    186    PREC_BEGIN(floatx80_precision_d);
    187    res->d = floatx80_round(val->d, &env->fp_status);
    188    PREC_END();
    189}
    190
    191void HELPER(fsqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
    192{
    193    res->d = floatx80_sqrt(val->d, &env->fp_status);
    194}
    195
    196void HELPER(fssqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
    197{
    198    PREC_BEGIN(floatx80_precision_s);
    199    res->d = floatx80_sqrt(val->d, &env->fp_status);
    200    PREC_END();
    201}
    202
    203void HELPER(fdsqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
    204{
    205    PREC_BEGIN(floatx80_precision_d);
    206    res->d = floatx80_sqrt(val->d, &env->fp_status);
    207    PREC_END();
    208}
    209
    210void HELPER(fabs)(CPUM68KState *env, FPReg *res, FPReg *val)
    211{
    212    res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
    213}
    214
    215void HELPER(fsabs)(CPUM68KState *env, FPReg *res, FPReg *val)
    216{
    217    PREC_BEGIN(floatx80_precision_s);
    218    res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
    219    PREC_END();
    220}
    221
    222void HELPER(fdabs)(CPUM68KState *env, FPReg *res, FPReg *val)
    223{
    224    PREC_BEGIN(floatx80_precision_d);
    225    res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
    226    PREC_END();
    227}
    228
    229void HELPER(fneg)(CPUM68KState *env, FPReg *res, FPReg *val)
    230{
    231    res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
    232}
    233
    234void HELPER(fsneg)(CPUM68KState *env, FPReg *res, FPReg *val)
    235{
    236    PREC_BEGIN(floatx80_precision_s);
    237    res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
    238    PREC_END();
    239}
    240
    241void HELPER(fdneg)(CPUM68KState *env, FPReg *res, FPReg *val)
    242{
    243    PREC_BEGIN(floatx80_precision_d);
    244    res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
    245    PREC_END();
    246}
    247
    248void HELPER(fadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    249{
    250    res->d = floatx80_add(val0->d, val1->d, &env->fp_status);
    251}
    252
    253void HELPER(fsadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    254{
    255    PREC_BEGIN(floatx80_precision_s);
    256    res->d = floatx80_add(val0->d, val1->d, &env->fp_status);
    257    PREC_END();
    258}
    259
    260void HELPER(fdadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    261{
    262    PREC_BEGIN(floatx80_precision_d);
    263    res->d = floatx80_add(val0->d, val1->d, &env->fp_status);
    264    PREC_END();
    265}
    266
    267void HELPER(fsub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    268{
    269    res->d = floatx80_sub(val1->d, val0->d, &env->fp_status);
    270}
    271
    272void HELPER(fssub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    273{
    274    PREC_BEGIN(floatx80_precision_s);
    275    res->d = floatx80_sub(val1->d, val0->d, &env->fp_status);
    276    PREC_END();
    277}
    278
    279void HELPER(fdsub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    280{
    281    PREC_BEGIN(floatx80_precision_d);
    282    res->d = floatx80_sub(val1->d, val0->d, &env->fp_status);
    283    PREC_END();
    284}
    285
    286void HELPER(fmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    287{
    288    res->d = floatx80_mul(val0->d, val1->d, &env->fp_status);
    289}
    290
    291void HELPER(fsmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    292{
    293    PREC_BEGIN(floatx80_precision_s);
    294    res->d = floatx80_mul(val0->d, val1->d, &env->fp_status);
    295    PREC_END();
    296}
    297
    298void HELPER(fdmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    299{
    300    PREC_BEGIN(floatx80_precision_d);
    301    res->d = floatx80_mul(val0->d, val1->d, &env->fp_status);
    302    PREC_END();
    303}
    304
    305void HELPER(fsglmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    306{
    307    FloatRoundMode rounding_mode = get_float_rounding_mode(&env->fp_status);
    308    floatx80 a, b;
    309
    310    PREC_BEGIN(floatx80_precision_s);
    311    set_float_rounding_mode(float_round_to_zero, &env->fp_status);
    312    a = floatx80_round(val0->d, &env->fp_status);
    313    b = floatx80_round(val1->d, &env->fp_status);
    314    set_float_rounding_mode(rounding_mode, &env->fp_status);
    315    res->d = floatx80_mul(a, b, &env->fp_status);
    316    PREC_END();
    317}
    318
    319void HELPER(fdiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    320{
    321    res->d = floatx80_div(val1->d, val0->d, &env->fp_status);
    322}
    323
    324void HELPER(fsdiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    325{
    326    PREC_BEGIN(floatx80_precision_s);
    327    res->d = floatx80_div(val1->d, val0->d, &env->fp_status);
    328    PREC_END();
    329}
    330
    331void HELPER(fddiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    332{
    333    PREC_BEGIN(floatx80_precision_d);
    334    res->d = floatx80_div(val1->d, val0->d, &env->fp_status);
    335    PREC_END();
    336}
    337
    338void HELPER(fsgldiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    339{
    340    FloatRoundMode rounding_mode = get_float_rounding_mode(&env->fp_status);
    341    floatx80 a, b;
    342
    343    PREC_BEGIN(floatx80_precision_s);
    344    set_float_rounding_mode(float_round_to_zero, &env->fp_status);
    345    a = floatx80_round(val1->d, &env->fp_status);
    346    b = floatx80_round(val0->d, &env->fp_status);
    347    set_float_rounding_mode(rounding_mode, &env->fp_status);
    348    res->d = floatx80_div(a, b, &env->fp_status);
    349    PREC_END();
    350}
    351
    352static int float_comp_to_cc(int float_compare)
    353{
    354    switch (float_compare) {
    355    case float_relation_equal:
    356        return FPSR_CC_Z;
    357    case float_relation_less:
    358        return FPSR_CC_N;
    359    case float_relation_unordered:
    360        return FPSR_CC_A;
    361    case float_relation_greater:
    362        return 0;
    363    default:
    364        g_assert_not_reached();
    365    }
    366}
    367
    368void HELPER(fcmp)(CPUM68KState *env, FPReg *val0, FPReg *val1)
    369{
    370    int float_compare;
    371
    372    float_compare = floatx80_compare(val1->d, val0->d, &env->fp_status);
    373    env->fpsr = (env->fpsr & ~FPSR_CC_MASK) | float_comp_to_cc(float_compare);
    374}
    375
    376void HELPER(ftst)(CPUM68KState *env, FPReg *val)
    377{
    378    uint32_t cc = 0;
    379
    380    if (floatx80_is_neg(val->d)) {
    381        cc |= FPSR_CC_N;
    382    }
    383
    384    if (floatx80_is_any_nan(val->d)) {
    385        cc |= FPSR_CC_A;
    386    } else if (floatx80_is_infinity(val->d)) {
    387        cc |= FPSR_CC_I;
    388    } else if (floatx80_is_zero(val->d)) {
    389        cc |= FPSR_CC_Z;
    390    }
    391    env->fpsr = (env->fpsr & ~FPSR_CC_MASK) | cc;
    392}
    393
    394void HELPER(fconst)(CPUM68KState *env, FPReg *val, uint32_t offset)
    395{
    396    val->d = fpu_rom[offset];
    397}
    398
    399typedef int (*float_access)(CPUM68KState *env, uint32_t addr, FPReg *fp,
    400                            uintptr_t ra);
    401
    402static uint32_t fmovem_predec(CPUM68KState *env, uint32_t addr, uint32_t mask,
    403                              float_access access_fn)
    404{
    405    uintptr_t ra = GETPC();
    406    int i, size;
    407
    408    for (i = 7; i >= 0; i--, mask <<= 1) {
    409        if (mask & 0x80) {
    410            size = access_fn(env, addr, &env->fregs[i], ra);
    411            if ((mask & 0xff) != 0x80) {
    412                addr -= size;
    413            }
    414        }
    415    }
    416
    417    return addr;
    418}
    419
    420static uint32_t fmovem_postinc(CPUM68KState *env, uint32_t addr, uint32_t mask,
    421                               float_access access_fn)
    422{
    423    uintptr_t ra = GETPC();
    424    int i, size;
    425
    426    for (i = 0; i < 8; i++, mask <<= 1) {
    427        if (mask & 0x80) {
    428            size = access_fn(env, addr, &env->fregs[i], ra);
    429            addr += size;
    430        }
    431    }
    432
    433    return addr;
    434}
    435
    436static int cpu_ld_floatx80_ra(CPUM68KState *env, uint32_t addr, FPReg *fp,
    437                              uintptr_t ra)
    438{
    439    uint32_t high;
    440    uint64_t low;
    441
    442    high = cpu_ldl_data_ra(env, addr, ra);
    443    low = cpu_ldq_data_ra(env, addr + 4, ra);
    444
    445    fp->l.upper = high >> 16;
    446    fp->l.lower = low;
    447
    448    return 12;
    449}
    450
    451static int cpu_st_floatx80_ra(CPUM68KState *env, uint32_t addr, FPReg *fp,
    452                               uintptr_t ra)
    453{
    454    cpu_stl_data_ra(env, addr, fp->l.upper << 16, ra);
    455    cpu_stq_data_ra(env, addr + 4, fp->l.lower, ra);
    456
    457    return 12;
    458}
    459
    460static int cpu_ld_float64_ra(CPUM68KState *env, uint32_t addr, FPReg *fp,
    461                             uintptr_t ra)
    462{
    463    uint64_t val;
    464
    465    val = cpu_ldq_data_ra(env, addr, ra);
    466    fp->d = float64_to_floatx80(*(float64 *)&val, &env->fp_status);
    467
    468    return 8;
    469}
    470
    471static int cpu_st_float64_ra(CPUM68KState *env, uint32_t addr, FPReg *fp,
    472                             uintptr_t ra)
    473{
    474    float64 val;
    475
    476    val = floatx80_to_float64(fp->d, &env->fp_status);
    477    cpu_stq_data_ra(env, addr, *(uint64_t *)&val, ra);
    478
    479    return 8;
    480}
    481
    482uint32_t HELPER(fmovemx_st_predec)(CPUM68KState *env, uint32_t addr,
    483                                   uint32_t mask)
    484{
    485    return fmovem_predec(env, addr, mask, cpu_st_floatx80_ra);
    486}
    487
    488uint32_t HELPER(fmovemx_st_postinc)(CPUM68KState *env, uint32_t addr,
    489                                    uint32_t mask)
    490{
    491    return fmovem_postinc(env, addr, mask, cpu_st_floatx80_ra);
    492}
    493
    494uint32_t HELPER(fmovemx_ld_postinc)(CPUM68KState *env, uint32_t addr,
    495                                    uint32_t mask)
    496{
    497    return fmovem_postinc(env, addr, mask, cpu_ld_floatx80_ra);
    498}
    499
    500uint32_t HELPER(fmovemd_st_predec)(CPUM68KState *env, uint32_t addr,
    501                                   uint32_t mask)
    502{
    503    return fmovem_predec(env, addr, mask, cpu_st_float64_ra);
    504}
    505
    506uint32_t HELPER(fmovemd_st_postinc)(CPUM68KState *env, uint32_t addr,
    507                                    uint32_t mask)
    508{
    509    return fmovem_postinc(env, addr, mask, cpu_st_float64_ra);
    510}
    511
    512uint32_t HELPER(fmovemd_ld_postinc)(CPUM68KState *env, uint32_t addr,
    513                                    uint32_t mask)
    514{
    515    return fmovem_postinc(env, addr, mask, cpu_ld_float64_ra);
    516}
    517
    518static void make_quotient(CPUM68KState *env, floatx80 val)
    519{
    520    int32_t quotient;
    521    int sign;
    522
    523    if (floatx80_is_any_nan(val)) {
    524        return;
    525    }
    526
    527    quotient = floatx80_to_int32(val, &env->fp_status);
    528    sign = quotient < 0;
    529    if (sign) {
    530        quotient = -quotient;
    531    }
    532
    533    quotient = (sign << 7) | (quotient & 0x7f);
    534    env->fpsr = (env->fpsr & ~FPSR_QT_MASK) | (quotient << FPSR_QT_SHIFT);
    535}
    536
    537void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    538{
    539    res->d = floatx80_mod(val1->d, val0->d, &env->fp_status);
    540
    541    make_quotient(env, res->d);
    542}
    543
    544void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    545{
    546    res->d = floatx80_rem(val1->d, val0->d, &env->fp_status);
    547
    548    make_quotient(env, res->d);
    549}
    550
    551void HELPER(fgetexp)(CPUM68KState *env, FPReg *res, FPReg *val)
    552{
    553    res->d = floatx80_getexp(val->d, &env->fp_status);
    554}
    555
    556void HELPER(fgetman)(CPUM68KState *env, FPReg *res, FPReg *val)
    557{
    558    res->d = floatx80_getman(val->d, &env->fp_status);
    559}
    560
    561void HELPER(fscale)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
    562{
    563    res->d = floatx80_scale(val1->d, val0->d, &env->fp_status);
    564}
    565
    566void HELPER(flognp1)(CPUM68KState *env, FPReg *res, FPReg *val)
    567{
    568    res->d = floatx80_lognp1(val->d, &env->fp_status);
    569}
    570
    571void HELPER(flogn)(CPUM68KState *env, FPReg *res, FPReg *val)
    572{
    573    res->d = floatx80_logn(val->d, &env->fp_status);
    574}
    575
    576void HELPER(flog10)(CPUM68KState *env, FPReg *res, FPReg *val)
    577{
    578    res->d = floatx80_log10(val->d, &env->fp_status);
    579}
    580
    581void HELPER(flog2)(CPUM68KState *env, FPReg *res, FPReg *val)
    582{
    583    res->d = floatx80_log2(val->d, &env->fp_status);
    584}
    585
    586void HELPER(fetox)(CPUM68KState *env, FPReg *res, FPReg *val)
    587{
    588    res->d = floatx80_etox(val->d, &env->fp_status);
    589}
    590
    591void HELPER(ftwotox)(CPUM68KState *env, FPReg *res, FPReg *val)
    592{
    593    res->d = floatx80_twotox(val->d, &env->fp_status);
    594}
    595
    596void HELPER(ftentox)(CPUM68KState *env, FPReg *res, FPReg *val)
    597{
    598    res->d = floatx80_tentox(val->d, &env->fp_status);
    599}
    600
    601void HELPER(ftan)(CPUM68KState *env, FPReg *res, FPReg *val)
    602{
    603    res->d = floatx80_tan(val->d, &env->fp_status);
    604}
    605
    606void HELPER(fsin)(CPUM68KState *env, FPReg *res, FPReg *val)
    607{
    608    res->d = floatx80_sin(val->d, &env->fp_status);
    609}
    610
    611void HELPER(fcos)(CPUM68KState *env, FPReg *res, FPReg *val)
    612{
    613    res->d = floatx80_cos(val->d, &env->fp_status);
    614}
    615
    616void HELPER(fsincos)(CPUM68KState *env, FPReg *res0, FPReg *res1, FPReg *val)
    617{
    618    floatx80 a = val->d;
    619    /*
    620     * If res0 and res1 specify the same floating-point data register,
    621     * the sine result is stored in the register, and the cosine
    622     * result is discarded.
    623     */
    624    res1->d = floatx80_cos(a, &env->fp_status);
    625    res0->d = floatx80_sin(a, &env->fp_status);
    626}
    627
    628void HELPER(fatan)(CPUM68KState *env, FPReg *res, FPReg *val)
    629{
    630    res->d = floatx80_atan(val->d, &env->fp_status);
    631}
    632
    633void HELPER(fasin)(CPUM68KState *env, FPReg *res, FPReg *val)
    634{
    635    res->d = floatx80_asin(val->d, &env->fp_status);
    636}
    637
    638void HELPER(facos)(CPUM68KState *env, FPReg *res, FPReg *val)
    639{
    640    res->d = floatx80_acos(val->d, &env->fp_status);
    641}
    642
    643void HELPER(fatanh)(CPUM68KState *env, FPReg *res, FPReg *val)
    644{
    645    res->d = floatx80_atanh(val->d, &env->fp_status);
    646}
    647
    648void HELPER(fetoxm1)(CPUM68KState *env, FPReg *res, FPReg *val)
    649{
    650    res->d = floatx80_etoxm1(val->d, &env->fp_status);
    651}
    652
    653void HELPER(ftanh)(CPUM68KState *env, FPReg *res, FPReg *val)
    654{
    655    res->d = floatx80_tanh(val->d, &env->fp_status);
    656}
    657
    658void HELPER(fsinh)(CPUM68KState *env, FPReg *res, FPReg *val)
    659{
    660    res->d = floatx80_sinh(val->d, &env->fp_status);
    661}
    662
    663void HELPER(fcosh)(CPUM68KState *env, FPReg *res, FPReg *val)
    664{
    665    res->d = floatx80_cosh(val->d, &env->fp_status);
    666}