;
; alpha/core.jit
;
;
; $Id: /mirror/trunk/src/jit/alpha/core.jit 15384 2006-11-11T21:22:03.445171Z chromatic  $
;

Parrot_noop {
    emit_nop(NATIVECODE);
}

Parrot_set_i_i {
    if (MAP[1] && MAP[2]) {
        jit_emit_mov_rr(NATIVECODE, MAP[2], MAP[1]);
    }
    else if (MAP[1]) {
        jit_emit_mov_rm_i(NATIVECODE, MAP[1], &INT_REG[2]);
    }
    else if (MAP[2]) {
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], MAP[2]);
    }
    else {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[2]);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
}

Parrot_set_i_ic {
    if (MAP[1]) {
        jit_emit_mov_ri_i(NATIVECODE, MAP[1], *INT_CONST[2]);
    }
    else {
        jit_emit_mov_ri_i(NATIVECODE, ISR1, *INT_CONST[2]);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
}

Parrot_sub_i_i_i {
    if (MAP[1] && MAP[2] && MAP[3]) {
        jit_emit_sub_rrr(NATIVECODE, MAP[2], MAP[3], MAP[1]);
    }
    else if (MAP[1] && MAP[2]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[3]);
        jit_emit_sub_rrr(NATIVECODE, MAP[2], ISR1, MAP[1]);
    }
    else if (MAP[1] && MAP[3]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[2]);
        jit_emit_sub_rrr(NATIVECODE, ISR1, MAP[3], MAP[1]);
    }
    else if (MAP[2] && MAP[3]) {
        jit_emit_sub_rrr(NATIVECODE, MAP[2], MAP[3], ISR1);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
    else if (MAP[1]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[3]);
        jit_emit_mov_rm_i(NATIVECODE, ISR2, &INT_REG[2]);
        jit_emit_sub_rrr(NATIVECODE, ISR2, ISR1, MAP[1]);
    }
    else if (MAP[2]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[3]);
        jit_emit_sub_rrr(NATIVECODE, MAP[2], ISR1, ISR1);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
    else if (MAP[3]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[2]);
        jit_emit_sub_rrr(NATIVECODE, ISR1, MAP[3], ISR1);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
    else {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[3]);
        jit_emit_mov_rm_i(NATIVECODE, ISR2, &INT_REG[2]);
        jit_emit_sub_rrr(NATIVECODE, ISR1, ISR2, ISR1);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
}

Parrot_add_i_i_i {
    if (MAP[1] && MAP[2] && MAP[3]) {
        jit_emit_add_rrr(NATIVECODE, MAP[2], MAP[3], MAP[1]);
    }
    else if (MAP[1] && MAP[2]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[3]);
        jit_emit_add_rrr(NATIVECODE, MAP[2], ISR1, MAP[1]);
    }
    else if (MAP[1] && MAP[3]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[2]);
        jit_emit_add_rrr(NATIVECODE, ISR1, MAP[3], MAP[1]);
    }
    else if (MAP[2] && MAP[3]) {
        jit_emit_add_rrr(NATIVECODE, MAP[2], MAP[3], ISR1);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
    else if (MAP[1]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[3]);
        jit_emit_mov_rm_i(NATIVECODE, ISR2, &INT_REG[2]);
        jit_emit_add_rrr(NATIVECODE, ISR2, ISR1, MAP[1]);
    }
    else if (MAP[2]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[3]);
        jit_emit_add_rrr(NATIVECODE, MAP[2], ISR1, ISR1);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
    else if (MAP[3]) {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[2]);
        jit_emit_add_rrr(NATIVECODE, ISR1, MAP[3], ISR1);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
    else {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[3]);
        jit_emit_mov_rm_i(NATIVECODE, ISR2, &INT_REG[2]);
        jit_emit_add_rrr(NATIVECODE, ISR1, ISR2, ISR1);
        jit_emit_mov_mr_i(NATIVECODE, &INT_REG[1], ISR1);
    }
}

Parrot_if_i_ic {
    if (MAP[1]) {
        emit_bne(NATIVECODE, MAP[1], *INT_CONST[2]);
    }
    else {
        jit_emit_mov_rm_i(NATIVECODE, ISR1, &INT_REG[1]);
        emit_bne(NATIVECODE, ISR1, *INT_CONST[2]);
    }
}

Parrot_end {
;   jit_emit_mov_rr(NATIVECODE, REG15_s6, REG30_sp);
    emit_ldq_b(NATIVECODE, REG26_ra, 0, REG30_sp);
    emit_ldq_b(NATIVECODE, REG15_s6, 8, REG30_sp);
    emit_lda_b(NATIVECODE, REG30_sp, 16, REG30_sp);
    emit_ret(NATIVECODE);
}

/*
 * Local variables:
 * c-indentation-style: bsd
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 *
 * vim: expandtab shiftwidth=4:
 */
