?? mips.h.svn-base
字號:
/*
* mips.h - SimpleScalar MIPS ISA (mips) definitions
*
* 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, 1998 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: mips.h,v 1.1.1.1 2006/09/08 09:21:43 cvsuser Exp $
*
* $Log: mips.h,v $
* Revision 1.1.1.1 2006/09/08 09:21:43 cvsuser
* Godson-3 simulator
*
* Revision 1.1 2005/01/27 03:18:24 fxzhang
* create godson2 cvs
*
* Revision 1.2 2005/01/27 03:14:38 fxzhang
* tmp
*
* Revision 1.1.1.1 2004/12/05 14:36:32 fxzhang
* initial import of ss-mips
*
* Revision 1.3 2004/11/17 05:04:58 fxzhang
* dump checkpoint support start running
*
* Revision 1.2 2004/08/03 09:50:06 fxzhang
* merge back changes on AMD64
*
* Revision 1.2 2004/07/30 02:48:22 fxzhang
* fix stat64/lstat64
*
* Revision 1.2 2004/07/15 07:31:03 fxzhang
* fix syscall on x86-64
*
* Revision 1.1.1.1 2004/07/15 01:26:34 fxzhang
* import
*
* Revision 1.1.1.1 2004/07/10 16:46:48 fxzhang
* initial
*
* Revision 1.1.1.1 2000/05/26 15:21:54 taustin
* SimpleScalar Tool Set
*
*
* Revision 1.9 1999/12/31 19:03:38 taustin
* quad_t naming conflicts removed
*
* Revision 1.8 1999/12/13 19:00:56 taustin
* cross endian execution support added
*
* Revision 1.7 1998/08/31 17:13:14 taustin
* added register checksuming routines
*
* Revision 1.6 1998/08/27 17:05:36 taustin
* added target interface support
* moved target-dependent definitions to target files
* added support for register and memory contexts
* LWL/LWR/SWL/SWR semantics fixed in ss.def, these instruction now
* appear to work correctly on big- and little-endian machines, this
* fixes all previous problems with IJPEG failing during functional
* simulation
*
*
*/
#ifndef MIPS_H
#define MIPS_H
#include <stdio.h>
#include "host.h"
#include "misc.h"
#include "endian.h"
/*
* This file contains various definitions needed to decode, disassemble, and
* execute MIPS instructions.
*/
/* build for MIPS target */
#define TARGET_MIPS
#ifndef TARGET_MIPS_BIG
#ifndef TARGET_MIPS_LITTLE
/* no cross-endian support, default to host endian */
#ifdef BYTES_BIG_ENDIAN
#define TARGET_MIPS_BIG
#else
#define TARGET_MIPS_LITTLE
#endif
#endif /* TARGET_MIPS_LITTLE */
#endif /* TARGET_MIPS_BIG */
/* probe cross-endian execution */
#if defined(BYTES_BIG_ENDIAN) && defined(TARGET_MIPS_LITTLE)
#define MD_CROSS_ENDIAN
#endif
#if defined(BYTES_LITTLE_ENDIAN) && defined(TARGET_MIPS_BIG)
#define MD_CROSS_ENDIAN
#endif
/* not applicable/available, usable in most definition contexts */
#define NA 0
/*
* target-dependent type definitions
*/
/* define MD_QWORD_ADDRS if the target requires 64-bit (qword) addresses */
#undef MD_QWORD_ADDRS
/* address type definition */
typedef word_t md_addr_t;
/*
* target-dependent memory module configuration
*/
/* physical memory page size (must be a power-of-two) */
#if 0
#define MD_PAGE_SIZE 4096
#define MD_LOG_PAGE_SIZE 12
#else
#define MD_PAGE_SIZE 16384
#define MD_LOG_PAGE_SIZE 14
#endif
/*
* target-dependent instruction faults
*/
enum md_fault_type {
md_fault_none = 0, /* no fault */
md_fault_access, /* storage access fault */
md_fault_alignment, /* storage alignment fault */
md_fault_overflow, /* signed arithmetic overflow fault */
md_fault_div0, /* division by zero fault */
md_fault_break, /* BREAK instruction fault */
md_fault_unimpl, /* unimplemented instruction fault */
md_fault_internal /* internal S/W fault */
};
/*
* target-dependent register file definitions, used by regs.[hc]
*/
/* number of integer registers */
#define MD_NUM_IREGS 32
/* number of floating point registers */
#define MD_NUM_FREGS 32
/* number of control registers */
#define MD_NUM_CREGS 3
/* total number of registers, excluding PC and NPC */
#define MD_TOTAL_REGS \
(/*int*/32 + /*fp*/32 + /*misc*/3 + /*tmp*/1 + /*mem*/1 + /*ctrl*/1)
/* general purpose (integer) register file entry type */
typedef sword_t md_gpr_t[MD_NUM_IREGS];
/* floating point register file entry type */
typedef union {
sword_t l[MD_NUM_FREGS]; /* integer word view */
sfloat_t f[MD_NUM_FREGS]; /* single-precision floating point view */
dfloat_t d[MD_NUM_FREGS/2]; /* double-prediction floating point view */
} md_fpr_t;
/* control register file contents */
typedef struct {
sword_t hi, lo; /* multiplier HI/LO result registers */
int fcc; /* floating point condition codes */
} md_ctrl_t;
/* well known registers */
enum md_reg_names {
MD_REG_ZERO = 0, /* zero register */
MD_REG_GP = 28, /* global data section pointer */
MD_REG_SP = 29, /* stack pointer */
MD_REG_FP = 30 /* frame pointer */
};
/*
* target-dependent instruction format definition
*/
/* instruction formats */
typedef word_t md_inst_t;
/* preferred nop instruction definition */
extern md_inst_t MD_NOP_INST;
/* target swap support */
#ifdef MD_CROSS_ENDIAN
#define MD_SWAPH(X) SWAP_HALF(X)
#define MD_SWAPW(X) SWAP_WORD(X)
#define MD_SWAPQ(X) SWAP_QWORD(X)
#define MD_SWAPI(X) (X).b = SWAP_WORD((X).b))
#else /* !MD_CROSS_ENDIAN */
#define MD_SWAPH(X) (X)
#define MD_SWAPW(X) (X)
#define MD_SWAPQ(X) (X)
#define MD_SWAPD(X) (X)
#define MD_SWAPI(X) (X)
#endif
/* fetch an instruction */
#define MD_FETCH_INST(INST, MEM, PC) \
{ (INST) = MEM_READ_WORD((MEM), (PC)); }
/*
* target-dependent loader module configuration
*/
/* virtual memory segment limits */
#if 0
#define MD_TEXT_BASE 0x00400000
#else
#define MD_TEXT_BASE 0x04000000
#endif
#define MD_DATA_BASE 0x10000000
#define MD_STACK_BASE 0x7fff8000
/* maximum size of argc+argv+envp environment */
#define MD_MAX_ENVIRON 16384
/*
* machine.def specific definitions
*/
/* inst -> enum md_opcode mapping, use this macro to decode insts */
#define MD_TOP_OP(INST) (((INST) >> 26) & 0x3f)
#define MD_SET_OPCODE(OP, INST) \
{ OP = md_mask2op[MD_TOP_OP(INST)]; \
while (md_opmask[OP]) \
OP = md_mask2op[((INST >> md_opshift[OP]) & md_opmask[OP]) \
+ md_opoffset[OP]]; }
/* largest opcode field value (currently upper 8-bit are used for pre/post-
incr/decr operation specifiers */
#define MD_MAX_MASK 2048
/* internal decoder state */
extern enum md_opcode md_mask2op[];
extern unsigned int md_opoffset[];
extern unsigned int md_opmask[];
extern unsigned int md_opshift[];
/* global opcode names, these are returned by the decoder (MD_OP_ENUM()) */
enum md_opcode {
OP_NA = 0, /* NA */
#define DEFINST(OP,MSK,NAME,OPFORM,RES,FLAGS,O1,O2,I1,I2,I3) OP,
#define DEFLINK(OP,MSK,NAME,MASK,SHIFT) OP,
#define CONNECT(OP)
#include "machine.def"
OP_MAX /* number of opcodes + NA */
};
/* enum md_opcode -> description string */
#define MD_OP_NAME(OP) (md_op2name[OP])
extern char *md_op2name[];
/* enum md_opcode -> opcode operand format, used by disassembler */
#define MD_OP_FORMAT(OP) (md_op2format[OP])
extern char *md_op2format[];
/* function unit classes, update md_fu2name if you update this definition */
enum md_fu_class {
FUClass_NA = 0, /* inst does not use a functional unit */
IntALU, /* integer ALU */
IntMULT, /* integer multiplier */
IntDIV, /* integer divider */
FloatADD, /* floating point adder/subtractor */
FloatCMP, /* floating point comparator */
FloatCVT, /* floating point<->integer converter */
FloatMULT, /* floating point multiplier */
FloatDIV, /* floating point divider */
FloatSQRT, /* floating point square root */
RdPort, /* memory read port */
WrPort, /* memory write port */
NUM_FU_CLASSES /* total functional unit classes */
};
/* enum md_opcode -> enum md_fu_class, used by performance simulators */
#define MD_OP_FUCLASS(OP) (md_op2fu[OP])
extern enum md_fu_class md_op2fu[];
/* enum md_fu_class -> description string */
#define MD_FU_NAME(FU) (md_fu2name[FU])
extern char *md_fu2name[];
/* instruction flags */
#define F_ICOMP 0x00000001 /* integer computation */
#define F_FCOMP 0x00000002 /* FP computation */
#define F_CTRL 0x00000004 /* control inst */
#define F_UNCOND 0x00000008 /* unconditional change */
#define F_COND 0x00000010 /* conditional change */
#define F_MEM 0x00000020 /* memory access inst */
#define F_LOAD 0x00000040 /* load inst */
#define F_STORE 0x00000080 /* store inst */
#define F_DISP 0x00000100 /* displaced (R+C) addr mode */
#define F_RR 0x00000200 /* R+R addr mode */
#define F_DIRECT 0x00000400 /* direct addressing mode */
#define F_TRAP 0x00000800 /* traping inst */
#define F_LONGLAT 0x00001000 /* long latency inst (for sched) */
#define F_DIRJMP 0x00002000 /* direct jump */
#define F_INDIRJMP 0x00004000 /* indirect jump */
#define F_CALL 0x00008000 /* function call */
#define F_FPCOND 0x00010000 /* FP conditional branch */
#define F_IMM 0x00020000 /* instruction has immediate operand */
/* enum md_opcode -> opcode flags, used by simulators */
#define MD_OP_FLAGS(OP) (md_op2flags[OP])
extern unsigned int md_op2flags[];
/* integer register specifiers */
#undef RS /* defined in /usr/include/sys/syscall.h on HPUX boxes */
#define RS ((inst >> 21) & 0x1f) /* reg source #1 */
#define RT ((inst >> 16) & 0x1f) /* reg source #2 */
#define RD ((inst >> 11) & 0x1f) /* reg dest */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -