opcodes.h 8.18 KB
/*
 * Copyright (C) 1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * Copyright (C) 1998 Digital Equipment Corporation
 *
 * This file is part of the SimOS distribution.
 * See LICENSE file for terms of the license.
 *
 */

#ifdef _OPCODES_H_  /* make a nop */
#define _OPCODES_H_

/* 
 * Definitions of opnums for Alpha opcodes so that all instructions can
 * be treated uniformly by using the desc_table array
 */

#include <alpha/inst.h>
#include <alpha/pal.h>


#define OP(NAME) icode_ptr NAME(icode_ptr picode, thread_ptr pthread)



#define UNIMPLEMENTED(NAME) \
icode_ptr NAME(icode_ptr picode, thread_ptr pthread) \
{unimplemented_op(picode, pthread); return 0; }

#define RESERVED(NAME) \
icode_ptr NAME(icode_ptr picode, thread_ptr pthread) \
{reserved_op(picode, pthread); return 0; }

#define EMPTY_OP(NAME) \
icode_ptr NAME(icode_ptr picode, thread_ptr pthread) \
{return picode->next; }

#ifdef GAMMA
typedef enum {
    reserved, PAL, memory, operate, branch, floating,
    lda, ldah, memory_read,memory_write, jsr, misc
} instr_format;

#else 
typedef enum {
    reserved, PAL, memory, operate, branch, floating
} instr_format;

#endif
extern instr_format op_format[];

typedef enum opnum_e {
    default_opnum = 0,
    /* PAL group: see <alpha/pal.h> */
    pal_gentrap, pal_rduniq, pal_wruniq, pal_bpt,
    pal_bugchk, pal_chmk, pal_callsys, pal_imb,
    pal_halt, pal_draina, pal_nphalt, pal_cobratt,
    pal_cserve, pal_ipir, pal_cflush, pal_rti,
    pal_rtsys, pal_whami, pal_rdusp, pal_wrperfmon,
    pal_wrusp, pal_wrkgp, pal_rdps, pal_swpipl,
    pal_wrent, pal_tbi, pal_rdval, pal_wrval,
    pal_swpctx, pal_jtopal, pal_wrvptptr, pal_wrfen,
    pal_mtpr_mces,

    /* Opcodes corresponding to single instructions */
    res_opc01, res_opc02, res_opc03,
    res_opc04, res_opc05, res_opc06, res_opc07,
    lda_opn, ldah_opn, res_opc0a, ldq_u_opn,
    res_opc0c, res_opc0d, res_opc0e, stq_u_opn,

    /* Integer arithmetic group */
    addl_opn, s4addl_opn, subl_opn, s4subl_opn,
    cmpbge_opn, s8addl_opn, s8subl_opn, cmpult_opn,
    addq_opn, s4addq_opn, subq_opn, s4subq_opn,
    cmpeq_opn, s8addq_opn, s8subq_opn, cmpule_opn,
    addlv_opn, sublv_opn, cmplt_opn, addqv_opn,
    subqv_opn, cmple_opn,

    /* Integer logical group */
    and_opn, bic_opn,
    cmovlbs_opn, cmovlbc_opn, bis_opn, cmoveq_opn,
    cmovne_opn, ornot_opn, xor_opn, cmovlt_opn,
    cmovge_opn, eqv_opn, cmovle_opn, cmovgt_opn,

    /* Integer  group */
    mskbl_opn, extbl_opn, insbl_opn, mskwl_opn,
    extwl_opn, inswl_opn, mskll_opn, extll_opn,
    insll_opn, zap_opn, zapnot_opn, mskql_opn,
    srl_opn, extql_opn, sll_opn, insql_opn,
    sra_opn, mskwh_opn, inswh_opn, extwh_opn,
    msklh_opn, inslh_opn, extlh_opn, mskqh_opn,
    insqh_opn, extqh_opn,

    /* integer multiply group */
    mull_opn, mulq_opn,
    umulh_opn, mullv_opn, mulqv_opn,

    res_opc14,

    /* vax floating point group */
    addfc_opn, subfc_opn, mulfc_opn, divfc_opn,
    cvtdgc_opn, addgc_opn, subgc_opn, mulgc_opn,
    divgc_opn, cvtgfc_opn, cvtgdc_opn, cvtgqc_opn,
    cvtqfc_opn, cvtqgc_opn, addf_opn, subf_opn,
    mulf_opn, divf_opn, cvtdg_opn, addg_opn,
    subg_opn, mulg_opn, divg_opn, cmpgeq_opn,
    cmpglt_opn, cmpgle_opn, cvtgf_opn, cvtgd_opn,
    cvtgq_opn, cvtqf_opn, cvtqg_opn, addfuc_opn,
    subfuc_opn, mulfuc_opn,
    divfuc_opn, cvtdguc_opn, addguc_opn, subguc_opn,
    mulguc_opn, divguc_opn, cvtgfuc_opn, cvtgduc_opn,
    cvtgqvc_opn, addfu_opn, subfu_opn, mulfu_opn,
    divfu_opn, cvtdgu_opn, addgu_opn, subgu_opn,
    mulgu_opn, divgu_opn, cvtgfu_opn, cvtgdu_opn,
    cvtgqv_opn, addfsc_opn, subfsc_opn, mulfsc_opn,
    divfsc_opn, cvtdgsc_opn, addgsc_opn, subgsc_opn,
    mulgsc_opn, divgsc_opn, cvtgfsc_opn, cvtgdsc_opn,
    cvtgqsc_opn, addfs_opn, subfs_opn, mulfs_opn,
    divfs_opn, cvtdgs_opn, addgs_opn, subgs_opn,
    mulgs_opn, divgs_opn, cmpgeqs_opn, cmpglts_opn,
    cmpgles_opn, cvtgfs_opn, cvtgds_opn, cvtgqs_opn,
    addfsuc_opn, subfsuc_opn, mulfsuc_opn, divfsuc_opn,
    cvtdgsuc_opn, addgsuc_opn, subgsuc_opn, mulgsuc_opn,
    divgsuc_opn, cvtgfsuc_opn, cvtgdsuc_opn, cvtgqsvc_opn,
    addfsu_opn, subfsu_opn, mulfsu_opn, divfsu_opn,
    cvtdgsu_opn, addgsu_opn, subgsu_opn, mulgsu_opn,
    divgsu_opn, cvtgfsu_opn, cvtgdsu_opn, cvtgqsv_opn,

    /* ieee floating point group */

    addsc_opn, subsc_opn, mulsc_opn, divsc_opn,
    addtc_opn, subtc_opn, multc_opn, divtc_opn, cvttsc_opn,
    cvttqc_opn, cvtqsc_opn, cvtqtc_opn, addsm_opn,
    subsm_opn, mulsm_opn, divsm_opn, addtm_opn,
    subtm_opn, multm_opn, divtm_opn, cvttsm_opn, cvttqm_opn,
    cvtqsm_opn, cvtqtm_opn, adds_opn, subs_opn,
    muls_opn, divs_opn, addt_opn, subt_opn,
    mult_opn, divt_opn, cmptun_opn, cmpteq_opn,
    cmptlt_opn, cmptle_opn, cvtts_opn, cvttq_opn,
    cvtqs_opn, cvtqt_opn, addsd_opn, subsd_opn,
    mulsd_opn, divsd_opn, addtd_opn, subtd_opn,
    multd_opn, divtd_opn, cvttsd_opn, cvttqd_opn,
    cvtqsd_opn, cvtqtd_opn, addsuc_opn, subsuc_opn,
    mulsuc_opn, divsuc_opn, addtuc_opn, subtuc_opn,
    multuc_opn, divtuc_opn, cvttsuc_opn, cvttqvc_opn,
    addsum_opn, subsum_opn, mulsum_opn, divsum_opn,
    addtum_opn, subtum_opn, multum_opn, divtum_opn,
    cvttsum_opn, cvttqvm_opn, addsu_opn, subsu_opn,
    mulsu_opn, divsu_opn, addtu_opn, subtu_opn,
    multu_opn, divtu_opn, cvttsu_opn, cvttqv_opn,
    addsud_opn, subsud_opn, mulsud_opn, divsud_opn,
    addtud_opn, subtud_opn, multud_opn, divtud_opn,
    cvttsud_opn, cvttqvd_opn, cvtst_opn, cvtsts_opn,
    addssuc_opn, subssuc_opn, mulssuc_opn, divssuc_opn,
    addtsuc_opn, subtsuc_opn, multsuc_opn, divtsuc_opn,
    cvttssuc_opn, cvttqsvc_opn, addssum_opn, subssum_opn,
    mulssum_opn, divssum_opn, addtsum_opn, subtsum_opn,
    multsum_opn, divtsum_opn, cvttssum_opn, cvttqsvm_opn,
    addssu_opn, subssu_opn, mulssu_opn, divssu_opn,
    addtsu_opn, subtsu_opn, multsu_opn, divtsu_opn,
    cmptunsu_opn, cmpteqsu_opn, cmptltsu_opn, cmptlesu_opn,
    cvttssu_opn, cvttqsv_opn, addssud_opn, subssud_opn,
    mulssud_opn, divssud_opn, addtsud_opn, subtsud_opn,
    multsud_opn, divtsud_opn, cvttssud_opn, cvttqsvd_opn,
    /* cvttss_opn, */ addssuic_opn, subssuic_opn, mulssuic_opn,
    divssuic_opn, addtsuic_opn, subtsuic_opn, multsuic_opn,
    divtsuic_opn, cvttssuic_opn, cvttqsvic_opn, cvtqssuic_opn,
    cvtqtsuic_opn, addssuim_opn, subssuim_opn, mulssuim_opn,
    divssuim_opn, addtsuim_opn, subtsuim_opn, multsuim_opn,
    divtsuim_opn, cvttssuim_opn, cvttqsvim_opn, cvtqssuim_opn,
    cvtqtsuim_opn, addssui_opn, subssui_opn, mulssui_opn,
    divssui_opn, addtsui_opn, subtsui_opn, multsui_opn,
    divtsui_opn, cvttssui_opn, cvttqsvi_opn, cvtqssui_opn,
    cvtqtsui_opn, addssuid_opn, subssuid_opn, mulssuid_opn,
    divssuid_opn, addtsuid_opn, subtsuid_opn, multsuid_opn,
    divtsuid_opn, cvttssuid_opn, cvttqsvid_opn, cvtqssuid_opn,
    cvtqtsuid_opn,

    /* Datatype independent floating point group */
    cvtlq_opn, cpys_opn, cpysn_opn,
    cpyse_opn, mt_fpcr_opn, mf_fpcr_opn, fcmoveq_opn,
    fcmovne_opn, fcmovlt_opn, fcmovge_opn,
    fcmovle_opn, fcmovgt_opn, cvtql_opn, cvtqlv_opn,
    cvtqlsv_opn,

    /* Miscellaneous ops group */
    trapb_opn, excb_opn, mb_opn,
    wmb_opn, fetch_opn, fetch_m_opn, rpcc_opn,
    rc_opn, rs_opn,

    pal19_opn,

    /* jsr group */
    jmp_opn,
    jsr_opn, ret_opn, jsr_coroutine_opn,

    pal1b_opn,
    res_opc1c, pal1d_opn, pal1e_opn, pal1f_opn,
    ldf_opn, ldg_opn, lds_opn, ldt_opn,
    stf_opn, stg_opn, sts_opn, stt_opn,
    ldl_opn, ldq_opn, ldl_l_opn, ldq_l_opn,
    stl_opn, stq_opn, stl_c_opn, stq_c_opn,
    br_opn, fbeq_opn, fblt_opn, fble_opn,
    bsr_opn, fbne_opn, fbge_opn, fbgt_opn,
    blbc_opn, beq_opn, blt_opn, ble_opn,
    blbs_opn, bne_opn, bge_opn, bgt_opn
} opnum_t;

/* Structure for decoding instructions in different groups. */

typedef struct group_struct {
    int opkey;
    opnum_t opnum;
} group_t;


extern group_t pal_group[], inta_group[], intl_group[], intm_group[],
    ints_group[], fltv_group[], flti_group[], fltl_group[], misc_group[],
    jsr_group[], defgroup[];


struct op_desc {
    char *opname;
    interpreter_t func;
    int iflags;
};

extern struct op_desc desc_table[];

/* Function prototypes */
icode_ptr terminator1(icode_ptr picode, thread_ptr pthread);
icode_ptr terminator2(icode_ptr picode, thread_ptr pthread);

#endif /* _OPCODE_H_ */