/*
   SPARC micro operations

   Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include "exec.h"

 /*XXX*/
#define REGNAME g0
#define REG (env->gregs[0])
#include "op_template.h"
#define REGNAME g1
#define REG (env->gregs[1])
#include "op_template.h"
#define REGNAME g2
#define REG (env->gregs[2])
#include "op_template.h"
#define REGNAME g3
#define REG (env->gregs[3])
#include "op_template.h"
#define REGNAME g4
#define REG (env->gregs[4])
#include "op_template.h"
#define REGNAME g5
#define REG (env->gregs[5])
#include "op_template.h"
#define REGNAME g6
#define REG (env->gregs[6])
#include "op_template.h"
#define REGNAME g7
#define REG (env->gregs[7])
#include "op_template.h"
#define REGNAME i0
#define REG (REGWPTR[16])
#include "op_template.h"
#define REGNAME i1
#define REG (REGWPTR[17])
#include "op_template.h"
#define REGNAME i2
#define REG (REGWPTR[18])
#include "op_template.h"
#define REGNAME i3
#define REG (REGWPTR[19])
#include "op_template.h"
#define REGNAME i4
#define REG (REGWPTR[20])
#include "op_template.h"
#define REGNAME i5
#define REG (REGWPTR[21])
#include "op_template.h"
#define REGNAME i6
#define REG (REGWPTR[22])
#include "op_template.h"
#define REGNAME i7
#define REG (REGWPTR[23])
#include "op_template.h"
#define REGNAME l0
#define REG (REGWPTR[8])
#include "op_template.h"
#define REGNAME l1
#define REG (REGWPTR[9])
#include "op_template.h"
#define REGNAME l2
#define REG (REGWPTR[10])
#include "op_template.h"
#define REGNAME l3
#define REG (REGWPTR[11])
#include "op_template.h"
#define REGNAME l4
#define REG (REGWPTR[12])
#include "op_template.h"
#define REGNAME l5
#define REG (REGWPTR[13])
#include "op_template.h"
#define REGNAME l6
#define REG (REGWPTR[14])
#include "op_template.h"
#define REGNAME l7
#define REG (REGWPTR[15])
#include "op_template.h"
#define REGNAME o0
#define REG (REGWPTR[0])
#include "op_template.h"
#define REGNAME o1
#define REG (REGWPTR[1])
#include "op_template.h"
#define REGNAME o2
#define REG (REGWPTR[2])
#include "op_template.h"
#define REGNAME o3
#define REG (REGWPTR[3])
#include "op_template.h"
#define REGNAME o4
#define REG (REGWPTR[4])
#include "op_template.h"
#define REGNAME o5
#define REG (REGWPTR[5])
#include "op_template.h"
#define REGNAME o6
#define REG (REGWPTR[6])
#include "op_template.h"
#define REGNAME o7
#define REG (REGWPTR[7])
#include "op_template.h"

#define REGNAME f0
#define REG (env->fpr[0])
#include "fop_template.h"
#define REGNAME f1
#define REG (env->fpr[1])
#include "fop_template.h"
#define REGNAME f2
#define REG (env->fpr[2])
#include "fop_template.h"
#define REGNAME f3
#define REG (env->fpr[3])
#include "fop_template.h"
#define REGNAME f4
#define REG (env->fpr[4])
#include "fop_template.h"
#define REGNAME f5
#define REG (env->fpr[5])
#include "fop_template.h"
#define REGNAME f6
#define REG (env->fpr[6])
#include "fop_template.h"
#define REGNAME f7
#define REG (env->fpr[7])
#include "fop_template.h"
#define REGNAME f8
#define REG (env->fpr[8])
#include "fop_template.h"
#define REGNAME f9
#define REG (env->fpr[9])
#include "fop_template.h"
#define REGNAME f10
#define REG (env->fpr[10])
#include "fop_template.h"
#define REGNAME f11
#define REG (env->fpr[11])
#include "fop_template.h"
#define REGNAME f12
#define REG (env->fpr[12])
#include "fop_template.h"
#define REGNAME f13
#define REG (env->fpr[13])
#include "fop_template.h"
#define REGNAME f14
#define REG (env->fpr[14])
#include "fop_template.h"
#define REGNAME f15
#define REG (env->fpr[15])
#include "fop_template.h"
#define REGNAME f16
#define REG (env->fpr[16])
#include "fop_template.h"
#define REGNAME f17
#define REG (env->fpr[17])
#include "fop_template.h"
#define REGNAME f18
#define REG (env->fpr[18])
#include "fop_template.h"
#define REGNAME f19
#define REG (env->fpr[19])
#include "fop_template.h"
#define REGNAME f20
#define REG (env->fpr[20])
#include "fop_template.h"
#define REGNAME f21
#define REG (env->fpr[21])
#include "fop_template.h"
#define REGNAME f22
#define REG (env->fpr[22])
#include "fop_template.h"
#define REGNAME f23
#define REG (env->fpr[23])
#include "fop_template.h"
#define REGNAME f24
#define REG (env->fpr[24])
#include "fop_template.h"
#define REGNAME f25
#define REG (env->fpr[25])
#include "fop_template.h"
#define REGNAME f26
#define REG (env->fpr[26])
#include "fop_template.h"
#define REGNAME f27
#define REG (env->fpr[27])
#include "fop_template.h"
#define REGNAME f28
#define REG (env->fpr[28])
#include "fop_template.h"
#define REGNAME f29
#define REG (env->fpr[29])
#include "fop_template.h"
#define REGNAME f30
#define REG (env->fpr[30])
#include "fop_template.h"
#define REGNAME f31
#define REG (env->fpr[31])
#include "fop_template.h"

#ifdef TARGET_SPARC64
#define REGNAME f32
#define REG (env->fpr[32])
#include "fop_template.h"
#define REGNAME f34
#define REG (env->fpr[34])
#include "fop_template.h"
#define REGNAME f36
#define REG (env->fpr[36])
#include "fop_template.h"
#define REGNAME f38
#define REG (env->fpr[38])
#include "fop_template.h"
#define REGNAME f40
#define REG (env->fpr[40])
#include "fop_template.h"
#define REGNAME f42
#define REG (env->fpr[42])
#include "fop_template.h"
#define REGNAME f44
#define REG (env->fpr[44])
#include "fop_template.h"
#define REGNAME f46
#define REG (env->fpr[46])
#include "fop_template.h"
#define REGNAME f48
#define REG (env->fpr[47])
#include "fop_template.h"
#define REGNAME f50
#define REG (env->fpr[50])
#include "fop_template.h"
#define REGNAME f52
#define REG (env->fpr[52])
#include "fop_template.h"
#define REGNAME f54
#define REG (env->fpr[54])
#include "fop_template.h"
#define REGNAME f56
#define REG (env->fpr[56])
#include "fop_template.h"
#define REGNAME f58
#define REG (env->fpr[58])
#include "fop_template.h"
#define REGNAME f60
#define REG (env->fpr[60])
#include "fop_template.h"
#define REGNAME f62
#define REG (env->fpr[62])
#include "fop_template.h"
#endif

#ifdef TARGET_SPARC64
#ifdef WORDS_BIGENDIAN
typedef union UREG64 {
    struct { uint16_t v3, v2, v1, v0; } w;
    struct { uint32_t v1, v0; } l;
    uint64_t q;
} UREG64;
#else
typedef union UREG64 {
    struct { uint16_t v0, v1, v2, v3; } w;
    struct { uint32_t v0, v1; } l;
    uint64_t q;
} UREG64;
#endif

#define PARAMQ1 \
({\
    UREG64 __p;\
    __p.l.v1 = PARAM1;\
    __p.l.v0 = PARAM2;\
    __p.q;\
}) 

void OPPROTO op_movq_T0_im64(void)
{
    T0 = PARAMQ1;
}

void OPPROTO op_movq_T1_im64(void)
{
    T1 = PARAMQ1;
}

#define XFLAG_SET(x) ((env->xcc&x)?1:0)

#else
#define EIP (env->pc)
#endif

#define FLAG_SET(x) ((env->psr&x)?1:0)

void OPPROTO op_movl_T0_0(void)
{
    T0 = 0;
}

void OPPROTO op_movl_T0_im(void)
{
    T0 = (uint32_t)PARAM1;
}

void OPPROTO op_movl_T1_im(void)
{
    T1 = (uint32_t)PARAM1;
}

void OPPROTO op_movl_T2_im(void)
{
    T2 = (uint32_t)PARAM1;
}

void OPPROTO op_movl_T0_sim(void)
{
    T0 = (int32_t)PARAM1;
}

void OPPROTO op_movl_T1_sim(void)
{
    T1 = (int32_t)PARAM1;
}

void OPPROTO op_movl_T2_sim(void)
{
    T2 = (int32_t)PARAM1;
}

void OPPROTO op_movl_T0_env(void)
{
    T0 = *(uint32_t *)((char *)env + PARAM1);
}

void OPPROTO op_movl_env_T0(void)
{
    *(uint32_t *)((char *)env + PARAM1) = T0;
}

void OPPROTO op_movtl_T0_env(void)
{
    T0 = *(target_ulong *)((char *)env + PARAM1);
}

void OPPROTO op_movtl_env_T0(void)
{
    *(target_ulong *)((char *)env + PARAM1) = T0;
}

void OPPROTO op_add_T1_T0(void)
{
    T0 += T1;
}

void OPPROTO op_add_T1_T0_cc(void)
{
    target_ulong src1;

    src1 = T0;
    T0 += T1;
    env->psr = 0;
#ifdef TARGET_SPARC64
    if (!(T0 & 0xffffffff))
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if ((src1 & 0xffffffff) < (T1 & 0xffffffff))
	env->psr |= PSR_CARRY;
    if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff) ^ -1) &
	 ((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
	env->psr |= PSR_OVF;

    env->xcc = 0;
    if (!T0)
	env->xcc |= PSR_ZERO;
    if ((int64_t) T0 < 0)
	env->xcc |= PSR_NEG;
    if (T0 < src1)
	env->xcc |= PSR_CARRY;
    if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1ULL << 63))
	env->xcc |= PSR_OVF;
#else
    if (!T0)
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if (T0 < src1)
	env->psr |= PSR_CARRY;
    if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
	env->psr |= PSR_OVF;
#endif
    FORCE_RET();
}

void OPPROTO op_addx_T1_T0(void)
{
    T0 += T1 + FLAG_SET(PSR_CARRY);
}

void OPPROTO op_addx_T1_T0_cc(void)
{
    target_ulong src1;

    src1 = T0;
    T0 += T1 + FLAG_SET(PSR_CARRY);
    env->psr = 0;
#ifdef TARGET_SPARC64
    if (!(T0 & 0xffffffff))
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if ((src1 & 0xffffffff) < (T1 & 0xffffffff))
	env->psr |= PSR_CARRY;
    if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff) ^ -1) &
	 ((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
	env->psr |= PSR_OVF;

    env->xcc = 0;
    if (!T0)
	env->xcc |= PSR_ZERO;
    if ((int64_t) T0 < 0)
	env->xcc |= PSR_NEG;
    if (T0 < src1)
	env->xcc |= PSR_CARRY;
    if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1ULL << 63))
	env->xcc |= PSR_OVF;
#else
    if (!T0)
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if (T0 < src1)
	env->psr |= PSR_CARRY;
    if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
	env->psr |= PSR_OVF;
#endif
    FORCE_RET();
}

void OPPROTO op_sub_T1_T0(void)
{
    T0 -= T1;
}

void OPPROTO op_sub_T1_T0_cc(void)
{
    target_ulong src1;

    src1 = T0;
    T0 -= T1;
    env->psr = 0;
#ifdef TARGET_SPARC64
    if (!(T0 & 0xffffffff))
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if ((src1 & 0xffffffff) < (T1 & 0xffffffff))
	env->psr |= PSR_CARRY;
    if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff)) &
	 ((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
	env->psr |= PSR_OVF;

    env->xcc = 0;
    if (!T0)
	env->xcc |= PSR_ZERO;
    if ((int64_t) T0 < 0)
	env->xcc |= PSR_NEG;
    if (T0 < src1)
	env->xcc |= PSR_CARRY;
    if (((src1 ^ T1) & (src1 ^ T0)) & (1ULL << 63))
	env->xcc |= PSR_OVF;
#else
    if (!T0)
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if (src1 < T1)
	env->psr |= PSR_CARRY;
    if (((src1 ^ T1) & (src1 ^ T0)) & (1 << 31))
	env->psr |= PSR_OVF;
#endif
    FORCE_RET();
}

void OPPROTO op_subx_T1_T0(void)
{
    T0 -= T1 + FLAG_SET(PSR_CARRY);
}

void OPPROTO op_subx_T1_T0_cc(void)
{
    target_ulong src1;

    src1 = T0;
    T0 -= T1 + FLAG_SET(PSR_CARRY);
    env->psr = 0;
#ifdef TARGET_SPARC64
    if (!(T0 & 0xffffffff))
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if ((src1 & 0xffffffff) < (T1 & 0xffffffff))
	env->psr |= PSR_CARRY;
    if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff)) &
	 ((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
	env->psr |= PSR_OVF;

    env->xcc = 0;
    if (!T0)
	env->xcc |= PSR_ZERO;
    if ((int64_t) T0 < 0)
	env->xcc |= PSR_NEG;
    if (T0 < src1)
	env->xcc |= PSR_CARRY;
    if (((src1 ^ T1) & (src1 ^ T0)) & (1ULL << 63))
	env->xcc |= PSR_OVF;
#else
    if (!T0)
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if (src1 < T1)
	env->psr |= PSR_CARRY;
    if (((src1 ^ T1) & (src1 ^ T0)) & (1 << 31))
	env->psr |= PSR_OVF;
#endif
    FORCE_RET();
}

void OPPROTO op_and_T1_T0(void)
{
    T0 &= T1;
}

void OPPROTO op_or_T1_T0(void)
{
    T0 |= T1;
}

void OPPROTO op_xor_T1_T0(void)
{
    T0 ^= T1;
}

void OPPROTO op_andn_T1_T0(void)
{
    T0 &= ~T1;
}

void OPPROTO op_orn_T1_T0(void)
{
    T0 |= ~T1;
}

void OPPROTO op_xnor_T1_T0(void)
{
    T0 ^= ~T1;
}

void OPPROTO op_umul_T1_T0(void)
{
    uint64_t res;
    res = (uint64_t) T0 * (uint64_t) T1;
#ifdef TARGET_SPARC64
    T0 = res;
#else
    T0 = res & 0xffffffff;
#endif
    env->y = res >> 32;
}

void OPPROTO op_smul_T1_T0(void)
{
    uint64_t res;
    res = (int64_t) ((int32_t) T0) * (int64_t) ((int32_t) T1);
#ifdef TARGET_SPARC64
    T0 = res;
#else
    T0 = res & 0xffffffff;
#endif
    env->y = res >> 32;
}

void OPPROTO op_mulscc_T1_T0(void)
{
    unsigned int b1, N, V, b2;
    target_ulong src1;

    N = FLAG_SET(PSR_NEG);
    V = FLAG_SET(PSR_OVF);
    b1 = N ^ V;
    b2 = T0 & 1;
    T0 = (b1 << 31) | (T0 >> 1);
    if (!(env->y & 1))
        T1 = 0;
    /* do addition and update flags */
    src1 = T0;
    T0 += T1;
    env->psr = 0;
    if (!T0)
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if (T0 < src1)
	env->psr |= PSR_CARRY;
    if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
	env->psr |= PSR_OVF;
    env->y = (b2 << 31) | (env->y >> 1);
    FORCE_RET();
}

void OPPROTO op_udiv_T1_T0(void)
{
    uint64_t x0;
    uint32_t x1;

    x0 = T0 | ((uint64_t) (env->y) << 32);
    x1 = T1;
    x0 = x0 / x1;
    if (x0 > 0xffffffff) {
	T0 = 0xffffffff;
	T1 = 1;
    } else {
	T0 = x0;
	T1 = 0;
    }
    FORCE_RET();
}

void OPPROTO op_sdiv_T1_T0(void)
{
    int64_t x0;
    int32_t x1;

    x0 = T0 | ((int64_t) (env->y) << 32);
    x1 = T1;
    x0 = x0 / x1;
    if ((int32_t) x0 != x0) {
	T0 = x0 < 0? 0x80000000: 0x7fffffff;
	T1 = 1;
    } else {
	T0 = x0;
	T1 = 0;
    }
    FORCE_RET();
}

void OPPROTO op_div_cc(void)
{
    env->psr = 0;
#ifdef TARGET_SPARC64
    if (!T0)
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if (T1)
	env->psr |= PSR_OVF;

    env->xcc = 0;
    if (!T0)
	env->xcc |= PSR_ZERO;
    if ((int64_t) T0 < 0)
	env->xcc |= PSR_NEG;
#else
    if (!T0)
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
    if (T1)
	env->psr |= PSR_OVF;
#endif
    FORCE_RET();
}

#ifdef TARGET_SPARC64
void OPPROTO op_mulx_T1_T0(void)
{
    T0 *= T1;
    FORCE_RET();
}

void OPPROTO op_udivx_T1_T0(void)
{
    T0 /= T1;
    FORCE_RET();
}

void OPPROTO op_sdivx_T1_T0(void)
{
    if (T0 == INT64_MIN && T1 == -1)
	T0 = INT64_MIN;
    else
	T0 /= (target_long) T1;
    FORCE_RET();
}
#endif

void OPPROTO op_logic_T0_cc(void)
{
    env->psr = 0;
#ifdef TARGET_SPARC64
    if (!(T0 & 0xffffffff))
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;

    env->xcc = 0;
    if (!T0)
	env->xcc |= PSR_ZERO;
    if ((int64_t) T0 < 0)
	env->xcc |= PSR_NEG;
#else
    if (!T0)
	env->psr |= PSR_ZERO;
    if ((int32_t) T0 < 0)
	env->psr |= PSR_NEG;
#endif
    FORCE_RET();
}

void OPPROTO op_sll(void)
{
    T0 <<= T1;
}

#ifdef TARGET_SPARC64
void OPPROTO op_srl(void)
{
    T0 = (T0 & 0xffffffff) >> T1;
}

void OPPROTO op_srlx(void)
{
    T0 >>= T1;
}

void OPPROTO op_sra(void)
{
    T0 = ((int32_t) (T0 & 0xffffffff)) >> T1;
}

void OPPROTO op_srax(void)
{
    T0 = ((int64_t) T0) >> T1;
}
#else
void OPPROTO op_srl(void)
{
    T0 >>= T1;
}

void OPPROTO op_sra(void)
{
    T0 = ((int32_t) T0) >> T1;
}
#endif

/* Load and store */
#define MEMSUFFIX _raw
#include "op_mem.h"
#if !defined(CONFIG_USER_ONLY)
#define MEMSUFFIX _user
#include "op_mem.h"

#define MEMSUFFIX _kernel
#include "op_mem.h"
#endif

void OPPROTO op_ldfsr(void)
{
    PUT_FSR32(env, *((uint32_t *) &FT0));
    helper_ldfsr();
}

void OPPROTO op_stfsr(void)
{
    *((uint32_t *) &FT0) = GET_FSR32(env);
}

#ifndef TARGET_SPARC64
void OPPROTO op_rdpsr(void)
{
    do_rdpsr();
}

void OPPROTO op_wrpsr(void)
{
    do_wrpsr();
    FORCE_RET();
}

void OPPROTO op_rett(void)
{
    helper_rett();
    FORCE_RET();
}

/* XXX: use another pointer for %iN registers to avoid slow wrapping
   handling ? */
void OPPROTO op_save(void)
{
    uint32_t cwp;
    cwp = (env->cwp - 1) & (NWINDOWS - 1); 
    if (env->wim & (1 << cwp)) {
        raise_exception(TT_WIN_OVF);
    }
    set_cwp(cwp);
    FORCE_RET();
}

void OPPROTO op_restore(void)
{
    uint32_t cwp;
    cwp = (env->cwp + 1) & (NWINDOWS - 1); 
    if (env->wim & (1 << cwp)) {
        raise_exception(TT_WIN_UNF);
    }
    set_cwp(cwp);
    FORCE_RET();
}
#else
void OPPROTO op_rdccr(void)
{
    T0 = GET_CCR(env);
}

void OPPROTO op_wrccr(void)
{
    PUT_CCR(env, T0);
}

void OPPROTO op_rdtick(void)
{
    T0 = 0; // XXX read cycle counter and bit 31
}

void OPPROTO op_wrtick(void)
{
    // XXX write cycle counter and bit 31
}

void OPPROTO op_rdtpc(void)
{
    T0 = env->tpc[env->tl];
}

void OPPROTO op_wrtpc(void)
{
    env->tpc[env->tl] = T0;
}

void OPPROTO op_rdtnpc(void)
{
    T0 = env->tnpc[env->tl];
}

void OPPROTO op_wrtnpc(void)
{
    env->tnpc[env->tl] = T0;
}

void OPPROTO op_rdtstate(void)
{
    T0 = env->tstate[env->tl];
}

void OPPROTO op_wrtstate(void)
{
    env->tstate[env->tl] = T0;
}

void OPPROTO op_rdtt(void)
{
    T0 = env->tt[env->tl];
}

void OPPROTO op_wrtt(void)
{
    env->tt[env->tl] = T0;
}

void OPPROTO op_rdpstate(void)
{
    T0 = env->pstate;
}

void OPPROTO op_wrpstate(void)
{
    do_wrpstate();
}

// CWP handling is reversed in V9, but we still use the V8 register
// order.
void OPPROTO op_rdcwp(void)
{
    T0 = NWINDOWS - 1 - env->cwp;
}

void OPPROTO op_wrcwp(void)
{
    env->cwp = NWINDOWS - 1 - T0;
}

/* XXX: use another pointer for %iN registers to avoid slow wrapping
   handling ? */
void OPPROTO op_save(void)
{
    uint32_t cwp;
    cwp = (env->cwp - 1) & (NWINDOWS - 1); 
    if (env->cansave == 0) {
        raise_exception(TT_SPILL | (env->otherwin != 0 ? 
				    (TT_WOTHER | ((env->wstate & 0x38) >> 1)):
				    ((env->wstate & 0x7) << 2)));
    } else {
	if (env->cleanwin - env->canrestore == 0) {
	    // XXX Clean windows without trap
	    raise_exception(TT_CLRWIN);
	} else {
	    env->cansave--;
	    env->canrestore++;
	    set_cwp(cwp);
	}
    }
    FORCE_RET();
}

void OPPROTO op_restore(void)
{
    uint32_t cwp;
    cwp = (env->cwp + 1) & (NWINDOWS - 1); 
    if (env->canrestore == 0) {
        raise_exception(TT_FILL | (env->otherwin != 0 ? 
				   (TT_WOTHER | ((env->wstate & 0x38) >> 1)):
				   ((env->wstate & 0x7) << 2)));
    } else {
	env->cansave++;
	env->canrestore--;
	set_cwp(cwp);
    }
    FORCE_RET();
}
#endif

void OPPROTO op_exception(void)
{
    env->exception_index = PARAM1;
    cpu_loop_exit();
}

void OPPROTO op_trap_T0(void)
{
    env->exception_index = TT_TRAP + (T0 & 0x7f);
    cpu_loop_exit();
}

void OPPROTO op_trapcc_T0(void)
{
    if (T2) {
        env->exception_index = TT_TRAP + (T0 & 0x7f);
        cpu_loop_exit();
    }
    FORCE_RET();
}

void OPPROTO op_trap_ifnofpu(void)
{
    if (!env->psref) {
        env->exception_index = TT_NFPU_INSN;
        cpu_loop_exit();
    }
    FORCE_RET();
}

void OPPROTO op_fpexception_im(void)
{
    env->exception_index = TT_FP_EXCP;
    env->fsr &= ~FSR_FTT_MASK;
    env->fsr |= PARAM1;
    cpu_loop_exit();
    FORCE_RET();
}

void OPPROTO op_debug(void)
{
    helper_debug();
}

void OPPROTO op_exit_tb(void)
{
    EXIT_TB();
}

void OPPROTO op_eval_ba(void)
{
    T2 = 1;
}

void OPPROTO op_eval_be(void)
{
    T2 = FLAG_SET(PSR_ZERO);
}

void OPPROTO op_eval_ble(void)
{
    target_ulong Z = FLAG_SET(PSR_ZERO), N = FLAG_SET(PSR_NEG), V = FLAG_SET(PSR_OVF);
    
    T2 = Z | (N ^ V);
}

void OPPROTO op_eval_bl(void)
{
    target_ulong N = FLAG_SET(PSR_NEG), V = FLAG_SET(PSR_OVF);

    T2 = N ^ V;
}

void OPPROTO op_eval_bleu(void)
{
    target_ulong Z = FLAG_SET(PSR_ZERO), C = FLAG_SET(PSR_CARRY);

    T2 = C | Z;
}

void OPPROTO op_eval_bcs(void)
{
    T2 = FLAG_SET(PSR_CARRY);
}

void OPPROTO op_eval_bvs(void)
{
    T2 = FLAG_SET(PSR_OVF);
}

void OPPROTO op_eval_bn(void)
{
    T2 = 0;
}

void OPPROTO op_eval_bneg(void)
{
    T2 = FLAG_SET(PSR_NEG);
}

void OPPROTO op_eval_bne(void)
{
    T2 = !FLAG_SET(PSR_ZERO);
}

void OPPROTO op_eval_bg(void)
{
    target_ulong Z = FLAG_SET(PSR_ZERO), N = FLAG_SET(PSR_NEG), V = FLAG_SET(PSR_OVF);

    T2 = !(Z | (N ^ V));
}

void OPPROTO op_eval_bge(void)
{
    target_ulong N = FLAG_SET(PSR_NEG), V = FLAG_SET(PSR_OVF);

    T2 = !(N ^ V);
}

void OPPROTO op_eval_bgu(void)
{
    target_ulong Z = FLAG_SET(PSR_ZERO), C = FLAG_SET(PSR_CARRY);

    T2 = !(C | Z);
}

void OPPROTO op_eval_bcc(void)
{
    T2 = !FLAG_SET(PSR_CARRY);
}

void OPPROTO op_eval_bpos(void)
{
    T2 = !FLAG_SET(PSR_NEG);
}

void OPPROTO op_eval_bvc(void)
{
    T2 = !FLAG_SET(PSR_OVF);
}

#ifdef TARGET_SPARC64
void OPPROTO op_eval_xbe(void)
{
    T2 = XFLAG_SET(PSR_ZERO);
}

void OPPROTO op_eval_xble(void)
{
    target_ulong Z = XFLAG_SET(PSR_ZERO), N = XFLAG_SET(PSR_NEG), V = XFLAG_SET(PSR_OVF);
    
    T2 = Z | (N ^ V);
}

void OPPROTO op_eval_xbl(void)
{
    target_ulong N = XFLAG_SET(PSR_NEG), V = XFLAG_SET(PSR_OVF);

    T2 = N ^ V;
}

void OPPROTO op_eval_xbleu(void)
{
    target_ulong Z = XFLAG_SET(PSR_ZERO), C = XFLAG_SET(PSR_CARRY);

    T2 = C | Z;
}

void OPPROTO op_eval_xbcs(void)
{
    T2 = XFLAG_SET(PSR_CARRY);
}

void OPPROTO op_eval_xbvs(void)
{
    T2 = XFLAG_SET(PSR_OVF);
}

void OPPROTO op_eval_xbneg(void)
{
    T2 = XFLAG_SET(PSR_NEG);
}

void OPPROTO op_eval_xbne(void)
{
    T2 = !XFLAG_SET(PSR_ZERO);
}

void OPPROTO op_eval_xbg(void)
{
    target_ulong Z = XFLAG_SET(PSR_ZERO), N = XFLAG_SET(PSR_NEG), V = XFLAG_SET(PSR_OVF);

    T2 = !(Z | (N ^ V));
}

void OPPROTO op_eval_xbge(void)
{
    target_ulong N = XFLAG_SET(PSR_NEG), V = XFLAG_SET(PSR_OVF);

    T2 = !(N ^ V);
}

void OPPROTO op_eval_xbgu(void)
{
    target_ulong Z = XFLAG_SET(PSR_ZERO), C = XFLAG_SET(PSR_CARRY);

    T2 = !(C | Z);
}

void OPPROTO op_eval_xbcc(void)
{
    T2 = !XFLAG_SET(PSR_CARRY);
}

void OPPROTO op_eval_xbpos(void)
{
    T2 = !XFLAG_SET(PSR_NEG);
}

void OPPROTO op_eval_xbvc(void)
{
    T2 = !XFLAG_SET(PSR_OVF);
}
#endif

#define FCC
#define FFLAG_SET(x) (env->fsr & x? 1: 0)
#include "fbranch_template.h"

#ifdef TARGET_SPARC64
#define FCC _fcc1
#define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 32))? 1: 0)
#include "fbranch_template.h"
#define FCC _fcc2
#define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 34))? 1: 0)
#include "fbranch_template.h"
#define FCC _fcc3
#define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 36))? 1: 0)
#include "fbranch_template.h"
#endif

#ifdef TARGET_SPARC64
void OPPROTO op_eval_brz(void)
{
    T2 = (T0 == 0);
}

void OPPROTO op_eval_brnz(void)
{
    T2 = (T0 != 0);
}

void OPPROTO op_eval_brlz(void)
{
    T2 = ((int64_t)T0 < 0);
}

void OPPROTO op_eval_brlez(void)
{
    T2 = ((int64_t)T0 <= 0);
}

void OPPROTO op_eval_brgz(void)
{
    T2 = ((int64_t)T0 > 0);
}

void OPPROTO op_eval_brgez(void)
{
    T2 = ((int64_t)T0 >= 0);
}

void OPPROTO op_jmp_im64(void)
{
    env->pc = PARAMQ1;
}

void OPPROTO op_movq_npc_im64(void)
{
    env->npc = PARAMQ1;
}
#endif

void OPPROTO op_jmp_im(void)
{
    env->pc = (uint32_t)PARAM1;
}

void OPPROTO op_movl_npc_im(void)
{
    env->npc = (uint32_t)PARAM1;
}

void OPPROTO op_movl_npc_T0(void)
{
    env->npc = T0;
}

void OPPROTO op_mov_pc_npc(void)
{
    env->pc = env->npc;
}

void OPPROTO op_next_insn(void)
{
    env->pc = env->npc;
    env->npc = env->npc + 4;
}

void OPPROTO op_goto_tb0(void)
{
    GOTO_TB(op_goto_tb0, PARAM1, 0);
}

void OPPROTO op_goto_tb1(void)
{
    GOTO_TB(op_goto_tb1, PARAM1, 1);
}

void OPPROTO op_jmp_label(void)
{
    GOTO_LABEL_PARAM(1);
}

void OPPROTO op_jnz_T2_label(void)
{
    if (T2)
        GOTO_LABEL_PARAM(1);
    FORCE_RET();
}

void OPPROTO op_jz_T2_label(void)
{
    if (!T2)
        GOTO_LABEL_PARAM(1);
    FORCE_RET();
}

void OPPROTO op_flush_T0(void)
{
    helper_flush(T0);
}

void OPPROTO op_fnegs(void)
{
    FT0 = -FT1;
}

void OPPROTO op_fabss(void)
{
    do_fabss();
}

#ifdef TARGET_SPARC64
void OPPROTO op_fnegd(void)
{
    DT0 = -DT1;
}

void OPPROTO op_fabsd(void)
{
    do_fabsd();
}
#endif

void OPPROTO op_fsqrts(void)
{
    do_fsqrts();
}

void OPPROTO op_fsqrtd(void)
{
    do_fsqrtd();
}

void OPPROTO op_fmuls(void)
{
    FT0 *= FT1;
}

void OPPROTO op_fmuld(void)
{
    DT0 *= DT1;
}

void OPPROTO op_fsmuld(void)
{
    DT0 = FT0 * FT1;
}

void OPPROTO op_fadds(void)
{
    FT0 += FT1;
}

void OPPROTO op_faddd(void)
{
    DT0 += DT1;
}

void OPPROTO op_fsubs(void)
{
    FT0 -= FT1;
}

void OPPROTO op_fsubd(void)
{
    DT0 -= DT1;
}

void OPPROTO op_fdivs(void)
{
    FT0 /= FT1;
}

void OPPROTO op_fdivd(void)
{
    DT0 /= DT1;
}

void OPPROTO op_fcmps(void)
{
    do_fcmps();
}

void OPPROTO op_fcmpd(void)
{
    do_fcmpd();
}

#ifdef TARGET_SPARC64
void OPPROTO op_fcmps_fcc1(void)
{
    do_fcmps_fcc1();
}

void OPPROTO op_fcmpd_fcc1(void)
{
    do_fcmpd_fcc1();
}

void OPPROTO op_fcmps_fcc2(void)
{
    do_fcmps_fcc2();
}

void OPPROTO op_fcmpd_fcc2(void)
{
    do_fcmpd_fcc2();
}

void OPPROTO op_fcmps_fcc3(void)
{
    do_fcmps_fcc3();
}

void OPPROTO op_fcmpd_fcc3(void)
{
    do_fcmpd_fcc3();
}
#endif

#ifdef USE_INT_TO_FLOAT_HELPERS
void OPPROTO op_fitos(void)
{
    do_fitos();
}

void OPPROTO op_fitod(void)
{
    do_fitod();
}
#else
void OPPROTO op_fitos(void)
{
    FT0 = (float) *((int32_t *)&FT1);
}

void OPPROTO op_fitod(void)
{
    DT0 = (double) *((int32_t *)&FT1);
}

#ifdef TARGET_SPARC64
void OPPROTO op_fxtos(void)
{
    FT0 = (float) *((int64_t *)&DT1);
}

void OPPROTO op_fxtod(void)
{
    DT0 = (double) *((int64_t *)&DT1);
}
#endif
#endif

void OPPROTO op_fdtos(void)
{
    FT0 = (float) DT1;
}

void OPPROTO op_fstod(void)
{
    DT0 = (double) FT1;
}

void OPPROTO op_fstoi(void)
{
    *((int32_t *)&FT0) = (int32_t) FT1;
}

void OPPROTO op_fdtoi(void)
{
    *((int32_t *)&FT0) = (int32_t) DT1;
}

#ifdef TARGET_SPARC64
void OPPROTO op_fstox(void)
{
    *((int64_t *)&DT0) = (int64_t) FT1;
}

void OPPROTO op_fdtox(void)
{
    *((int64_t *)&DT0) = (int64_t) DT1;
}

void OPPROTO op_fmovs_cc(void)
{
    if (T2)
	FT0 = FT1;
}

void OPPROTO op_fmovd_cc(void)
{
    if (T2)
	DT0 = DT1;
}

void OPPROTO op_mov_cc(void)
{
    if (T2)
	T0 = T1;
}

void OPPROTO op_flushw(void)
{
    if (env->cansave != NWINDOWS - 2) {
        raise_exception(TT_SPILL | (env->otherwin != 0 ? 
				    (TT_WOTHER | ((env->wstate & 0x38) >> 1)):
				    ((env->wstate & 0x7) << 2)));
    }
}

void OPPROTO op_saved(void)
{
    env->cansave++;
    if (env->otherwin == 0)
	env->canrestore--;
}

void OPPROTO op_restored(void)
{
    env->canrestore++;
    if (env->cleanwin < NWINDOWS - 1)
	env->cleanwin++;
    if (env->otherwin == 0)
	env->cansave--;
    else
	env->otherwin--;
}

void OPPROTO op_popc(void)
{
    do_popc();
}

void OPPROTO op_done(void)
{
    do_done();
}

void OPPROTO op_retry(void)
{
    do_retry();
}

void OPPROTO op_sir(void)
{
    // XXX

}

void OPPROTO op_ld_asi_reg()
{
    T0 += PARAM1;
    helper_ld_asi(env->asi, PARAM2, PARAM3);
}

void OPPROTO op_st_asi_reg()
{
    T0 += PARAM1;
    helper_st_asi(env->asi, PARAM2, PARAM3);
}
#endif

void OPPROTO op_ld_asi()
{
    helper_ld_asi(PARAM1, PARAM2, PARAM3);
}

void OPPROTO op_st_asi()
{
    helper_st_asi(PARAM1, PARAM2, PARAM3);
}

