📄 ss.def
字号:
/* This doesn't look like -*- C -*-, but it is! * * ss.def - simplescalar machine definition * * This file is a part of the SimpleScalar tool suite written by * Todd M. Austin as a part of the Multiscalar Research Project. * * The tool suite is currently maintained by Doug Burger and Todd M. Austin. * * Copyright (C) 1994, 1995, 1996, 1997 by Todd M. Austin * * This source file is distributed "as is" in the hope that it will be * useful. The tool set comes with no warranty, and no author or * distributor accepts any responsibility for the consequences of its * use. * * Everyone is granted permission to copy, modify and redistribute * this tool set under the following conditions: * * This source code is distributed for non-commercial use only. * Please contact the maintainer for restrictions applying to * commercial use. * * Permission is granted to anyone to make or distribute copies * of this source code, either as received or modified, in any * medium, provided that all copyright notices, permission and * nonwarranty notices are preserved, and that the distributor * grants the recipient permission for further redistribution as * permitted by this document. * * Permission is granted to distribute this file in compiled * or executable form under the same conditions that apply for * source code, provided that either: * * A. it is accompanied by the corresponding machine-readable * source code, * B. it is accompanied by a written offer, with no time limit, * to give anyone a machine-readable copy of the corresponding * source code in return for reimbursement of the cost of * distribution. This written offer must permit verbatim * duplication by anyone, or * C. it is distributed by someone who received only the * executable form, and is accompanied by a copy of the * written offer of source code that they received concurrently. * * In other words, you are welcome to use, share and improve this * source file. You are forbidden to forbid anyone else to use, share * and improve what you give them. * * INTERNET: dburger@cs.wisc.edu * US Mail: 1210 W. Dayton Street, Madison, WI 53706 * * $Id: ss.def,v 1.6 1997/04/16 22:11:30 taustin Exp taustin $ * * $Log: ss.def,v $# Revision 1.6 1997/04/16 22:11:30 taustin# fixed header comments## Revision 1.5 1997/03/11 01:40:00 taustin# updated copyrights# removed inter-dependency between dependency and semantic macros# supported added for non-GNU C compilers## Revision 1.4 1997/01/06 16:07:49 taustin# comments updated# functional unit definitions moved to ss.h and ss.c## Revision 1.3 1996/12/27 15:55:09 taustin# eliminated compiler warnings## Revision 1.1 1996/12/05 18:55:22 taustin# Initial revision# * *//* This file defines all aspects of the SimpleScalar instruction set * architecture. Each instruction set in the architecture has a DEFINST() * macro call included below. The contents of a instruction definition are * as follows: * * DEFINST(<enum>, <opcode>, * <opname>, <operands>, * <fu_req>, <iflags>, * <output deps...>, <input deps...>, * <expr>) * * Where: * * <enum> - is an enumerator that is returned when an instruction is * decoded by SS_OP_ENUM() * <opcode> - is the opcode of this instruction * <opname> - name of this instruction as a string, used by disassembler * <operands> - specified the instruction operand fields and their printed * order for disassembly, used by disassembler, the recognized * operand field are (the instruction format is detailed in * the header file ss.h): * J - target field * j - PC relative target (offset + PC) * s - S register field * b - S register field (base register) * t - T register field * d - D register field * S - S register field (FP register) * T - T register field (FP register) * D - D register field (FP register) * o - load address offset (offset) * i - signed immediate field value * u - unsigned immediate field value * U - upper immediate field value * H - shift amount immediate field value * B - break code * * <fu_req> - functional unit requirements for this instruction * <iflags> - instruction flags, accessible via the SS_OP_FLAGS() * macro, flags are defined with F_* prefix in ss.h * <output deps...> * - a list of up to two output dependency designators, the * following designators are recognized (place an DNA in any * unused fields: * DGPR(N) - general purpose register N * DGPR_D(N) - double word general purpose register N * DCGPR(N) - general purpose register conditional on * pre/post- increment/decrement mode * DFPR_L(N) - floating-point register N, as word * DFPR_F(N) - floating-point reg N, as single-prec float * DFPR_D(N) - floating-point reg N, as double-prec double * DHI - HI result register * DLO - LO result register * DFCC - floating point condition codes * DCPC - current PC * DNPC - next PC * DNA - no dependence * * <input deps...> * - a list of up to three input dependency designators, the * designators are defined above (place an DNA in any unused * fields. * * <expr> - a C expression that implements the instruction being * defined, the expression must modify all architected state * affected by the instruction's execution, by default, the * next PC (NPC) value defaults to the current PC (CPC) plus * SS_INST_SIZE, as a result, only taken branches need to set * NPC * * The following predefined macros are available for use in * DEFINST() instruction expressions to access the value of * instruction operand/opcode field values: * * RS - RS register field value * RT - RT register field value * RD - RD register field value * FS - RS register field value * FT - RT register field value * FD - RD register field value * BS - RS register field value * TARG - jump target field value * OFS - signed offset field value * IMM - signed offset field value * UIMM - unsigned offset field value * SHAMT - shift amount field value * BCODE - break code field value * * To facilitate the construction of performance simulators * (which may want to specialize their architected state * storage format), all architected register and memory state * is accessed through the following macros: * * GPR(N) - read general purpose register N * SET_GPR(N,E) - write general purpose register N with E * GPR_D(N) - read double word general purpose reg N * SET_GPR_D(N,E) - write double word gen purpose reg N w/ E * FPR_L(N) - read floating-point register N, as word * SET_FPR_L(N,E) - floating-point reg N, as word, with E * FPR_F(N) - read FP reg N, as single-prec float * SET_FPR_F(N,E) - write FP reg N, as single-prec float w/ E * FPR_D(N) - read FP reg N, as double-prec double * SET_FPR_D(N,E) - write FP reg N, as double-prec double w/E * HI - read HI result register * SET_HI(E) - write HI result register with E * LO - read LO result register * SET_LO(E) - write LO result register with E * FCC - read floating point condition codes * SET_FCC(E) - write floating point condition codes w/ E * CPC - read current PC register * NPC - read next PC register * SET_NPC(E) - write next PC register with E * TPC - read target PC register * SET_TPC(E) - write target PC register with E * * READ_SIGNED_BYTE(A) - read signed byte from address A * READ_UNSIGNED_BYTE(A) - read unsigned byte from address A * READ_SIGNED_HALF(A) - read signed half from address A * READ_UNSIGNED_HALF(A) - read unsigned half from address A * READ_WORD(A) - read word from address A * WRITE_BYTE(E,A) - write byte value E to address A * WRITE_HALF(E,A) - write half value E to address A * WRITE_WORD(E,A) - write word value E to address A * * Finally, the following helper functions are available to * assist in the construction of instruction expressions: * * INC_DEC(E,N,S) - execute E and update N as per pre/post- * incr/decr addressing sementics for an * access of S bytes * OVER(X,Y) - check for overflow for X+Y, both signed * UNDER(X,Y) - check for umderflow for X-Y, both signed * DIV0(N) - check for divide by zero, N is denom * INTALIGN(N) - check double word int reg N alignment * FPALIGN(N) - check double word FP reg N alignment * TALIGN(T) - check jump target T alignment *//* no operation */DEFINST(NOP, 0x00, "nop", "", IntALU, F_ICOMP, DNA, DNA, DNA, DNA, DNA, /* do nothing */((void) 0))/* * control operations */DEFINST(JUMP, 0x01, "j", "J", NA, F_CTRL|F_UNCOND|F_DIRJMP, DNA, DNA, DNA, DNA, DNA, (SET_TPC((CPC & 036000000000) | (TARG << 2)), SET_NPC((CPC & 036000000000) | (TARG << 2))))DEFINST(JAL, 0x02, "jal", "J", IntALU, F_CTRL|F_UNCOND|F_DIRJMP|F_CALL, DGPR(31), DNA, DNA, DNA, DNA, (SET_TPC((CPC & 036000000000) | (TARG << 2)), SET_NPC((CPC & 036000000000) | (TARG << 2)), SET_GPR(31, CPC + 8)))DEFINST(JR, 0x03, "jr", "s", NA, F_CTRL|F_UNCOND|F_INDIRJMP, DNA, DNA, DGPR(RS), DNA, DNA, (TALIGN(GPR(RS)), SET_TPC(GPR(RS)), SET_NPC(GPR(RS))))DEFINST(JALR, 0x04, "jalr", "d,s", IntALU, F_CTRL|F_UNCOND|F_INDIRJMP|F_CALL, DGPR(RD), DNA, DGPR(RS), DNA, DNA, (TALIGN(GPR(RS)), SET_GPR(RD, CPC + 8), SET_TPC(GPR(RS)), SET_NPC(GPR(RS))))DEFINST(BEQ, 0x05, "beq", "s,t,j", IntALU, F_CTRL|F_COND|F_DIRJMP, DNA, DNA, DGPR(RS), DGPR(RT), DNA, (SET_TPC(CPC + 8 + (OFS << 2)), (GPR(RS) == GPR(RT)) ? SET_NPC(CPC + 8 + (OFS << 2)) : 0))DEFINST(BNE, 0x06, "bne", "s,t,j", IntALU, F_CTRL|F_COND|F_DIRJMP, DNA, DNA, DGPR(RS), DGPR(RT), DNA, (SET_TPC(CPC + 8 + (OFS << 2)), (GPR(RS) != GPR(RT)) ? SET_NPC(CPC + 8 + (OFS << 2)) : 0))DEFINST(BLEZ, 0x07, "blez", "s,j", IntALU, F_CTRL|F_COND|F_DIRJMP, DNA, DNA, DGPR(RS), DNA, DNA, (SET_TPC(CPC + 8 + (OFS << 2)), (GPR(RS) <= 0) ? SET_NPC(CPC + 8 + (OFS << 2)) : 0))DEFINST(BGTZ, 0x08, "bgtz", "s,j", IntALU, F_CTRL|F_COND|F_DIRJMP, DNA, DNA, DGPR(RS), DNA, DNA, (SET_TPC(CPC + 8 + (OFS << 2)), (GPR(RS) > 0) ? SET_NPC(CPC + 8 + (OFS << 2)) : 0))DEFINST(BLTZ, 0x09, "bltz", "s,j", IntALU, F_CTRL|F_COND|F_DIRJMP, DNA, DNA, DGPR(RS), DNA, DNA, (SET_TPC(CPC + 8 + (OFS << 2)), (GPR(RS) < 0) ? SET_NPC(CPC + 8 + (OFS << 2)) : 0))DEFINST(BGEZ, 0x0a, "bgez", "s,j", IntALU, F_CTRL|F_COND|F_DIRJMP, DNA, DNA, DGPR(RS), DNA, DNA, (SET_TPC(CPC + 8 + (OFS << 2)), (GPR(RS) >= 0) ? SET_NPC(CPC + 8 + (OFS << 2)) : 0))DEFINST(BC1F, 0x0b, "bc1f", "j", IntALU, F_CTRL|F_COND|F_DIRJMP|F_FPCOND, DNA, DNA, DFCC, DNA, DNA, (SET_TPC(CPC + 8 + (OFS << 2)), (!FCC) ? SET_NPC(CPC + 8 + (OFS << 2)) : 0))DEFINST(BC1T, 0x0c, "bc1t", "j", IntALU, F_CTRL|F_COND|F_DIRJMP|F_FPCOND, DNA, DNA, DFCC, DNA, DNA, (SET_TPC(CPC + 8 + (OFS << 2)), (FCC) ? SET_NPC(CPC + 8 + (OFS << 2)) : 0))/* * load/store operations * * NOTE: the out-of-order issue simulator(s) require that load and store * address computation input dependencies be placed in slots 1 and 2 of * the input dependency list slot 0 is reserved for the input dependency * of store values for store instructions */DEFINST(LB, 0x20, "lb", "t,o(b)", RdPort, F_MEM|F_LOAD|F_DISP, DGPR(RT), DCGPR(BS), DNA, DGPR(BS), DNA, INC_DEC(SET_GPR(RT, READ_SIGNED_BYTE(GPR(BS)+OFS)), BS, 1))DEFINST(LBU, 0x22, "lbu", "t,o(b)", RdPort, F_MEM|F_LOAD|F_DISP, DGPR(RT), DCGPR(BS), DNA, DGPR(BS), DNA, INC_DEC(SET_GPR(RT, READ_UNSIGNED_BYTE(GPR(BS)+OFS)), BS, 1))DEFINST(LH, 0x24, "lh", "t,o(b)", RdPort, F_MEM|F_LOAD|F_DISP, DGPR(RT), DCGPR(BS), DNA, DGPR(BS), DNA, INC_DEC(SET_GPR(RT, READ_SIGNED_HALF(GPR(BS)+OFS)), BS, 2))DEFINST(LHU, 0x26, "lhu", "t,o(b)", RdPort, F_MEM|F_LOAD|F_DISP, DGPR(RT), DCGPR(BS), DNA, DGPR(BS), DNA, INC_DEC(SET_GPR(RT, READ_UNSIGNED_HALF(GPR(BS)+OFS)), BS, 2))DEFINST(LW, 0x28, "lw", "t,o(b)", RdPort, F_MEM|F_LOAD|F_DISP, DGPR(RT), DCGPR(BS), DNA, DGPR(BS), DNA, INC_DEC(SET_GPR(RT, READ_WORD(GPR(BS)+OFS)), BS, 4))DEFINST(DLW, 0x29, "dlw", "t,o(b)", RdPort, F_MEM|F_LOAD|F_DISP, DGPR_D(RT), DCGPR(BS), DNA, DGPR(BS), DNA, INC_DEC((INTALIGN(RT), temp_bs = GPR(BS), SET_GPR((RT)^sim_swap_words, READ_WORD(temp_bs+OFS)), SET_GPR(((RT)+1)^sim_swap_words, READ_WORD(temp_bs+OFS+4))), BS, 8))DEFINST(L_S, 0x2a, "l.s", "T,o(b)", RdPort, F_MEM|F_LOAD|F_DISP, DFPR_L(FT), DCGPR(BS), DNA, DGPR(BS), DNA, INC_DEC(SET_FPR_L(FT, READ_WORD(GPR(BS)+OFS)), BS, 4))DEFINST(L_D, 0x2b, "l.d", "T,o(b)", RdPort, F_MEM|F_LOAD|F_DISP, DFPR_D(FT), DCGPR(BS), DNA, DGPR(BS), DNA, INC_DEC((FPALIGN(FT), SET_FPR_L((FT)^sim_swap_words, READ_WORD(GPR(BS)+OFS)), SET_FPR_L(((FT)+1)^sim_swap_words, READ_WORD(GPR(BS)+OFS+4))), BS, 8))DEFINST(LWL, 0x2c, "lwl", "t,o(b)", RdPort, F_MEM|F_LOAD|F_DISP, DGPR(RT), DNA, DNA, DGPR(BS), DNA, (/* inc/dec not supported */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -