⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 machine.h

📁 一个很有名的硬件模拟器。可以模拟CPU
💻 H
📖 第 1 页 / 共 2 页
字号:
/* alpha.h - Alpha ISA definitions *//* SimpleScalar(TM) Tool Suite * Copyright (C) 1994-2003 by Todd M. Austin, Ph.D. and SimpleScalar, LLC. * All Rights Reserved.  *  * THIS IS A LEGAL DOCUMENT, BY USING SIMPLESCALAR, * YOU ARE AGREEING TO THESE TERMS AND CONDITIONS. *  * No portion of this work may be used by any commercial entity, or for any * commercial purpose, without the prior, written permission of SimpleScalar, * LLC (info@simplescalar.com). Nonprofit and noncommercial use is permitted * as described below. *  * 1. SimpleScalar is provided AS IS, with no warranty of any kind, express * or implied. The user of the program accepts full responsibility for the * application of the program and the use of any results. *  * 2. Nonprofit and noncommercial use is encouraged. SimpleScalar may be * downloaded, compiled, executed, copied, and modified solely for nonprofit, * educational, noncommercial research, and noncommercial scholarship * purposes provided that this notice in its entirety accompanies all copies. * Copies of the modified software can be delivered to persons who use it * solely for nonprofit, educational, noncommercial research, and * noncommercial scholarship purposes provided that this notice in its * entirety accompanies all copies. *  * 3. ALL COMMERCIAL USE, AND ALL USE BY FOR PROFIT ENTITIES, IS EXPRESSLY * PROHIBITED WITHOUT A LICENSE FROM SIMPLESCALAR, LLC (info@simplescalar.com). *  * 4. No nonprofit user may place any restrictions on the use of this software, * including as modified by the user, by any other authorized user. *  * 5. Noncommercial and nonprofit users may distribute copies of SimpleScalar * in compiled or executable form as set forth in Section 2, provided that * either: (A) it is accompanied by the corresponding machine-readable source * code, or (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. *  * 6. SimpleScalar was developed by Todd M. Austin, Ph.D. The tool suite is * currently maintained by SimpleScalar LLC (info@simplescalar.com). US Mail: * 2395 Timbercrest Court, Ann Arbor, MI 48105. *  * Copyright (C) 1994-2003 by Todd M. Austin, Ph.D. and SimpleScalar, LLC. */#ifndef ALPHA_H#define ALPHA_H#include <stdio.h>#include "host.h"#include "misc.h"#include "config.h"#include "endian.h"/* * This file contains various definitions needed to decode, disassemble, and * execute Alpha AXP instructions. *//* build for Alpha AXP target */#define TARGET_ALPHA/* probe cross-endian execution */#if defined(BYTES_BIG_ENDIAN)#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 */#define MD_QWORD_ADDRS/* address type definition */typedef qword_t md_addr_t;/* * target-dependent memory module configuration *//* physical memory page size (must be a power-of-two) */#define MD_PAGE_SIZE		8192#define MD_LOG_PAGE_SIZE	13/* * 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_invalid,             /* invalid arithmetic operation */                                 /* added to allow SQRT{S,T} in FIX exts */  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		2/* total number of registers, excluding PC and NPC */#define MD_TOTAL_REGS							\  (/*int*/32 + /*fp*/32 + /*misc*/2 + /*tmp*/1 + /*mem*/1 + /*ctrl*/1)/* general purpose (integer) register file entry type */typedef qword_t md_gpr_t[MD_NUM_IREGS];/* floating point register file entry type */typedef union {  qword_t q[MD_NUM_FREGS];	/* integer qword view */  dfloat_t d[MD_NUM_FREGS];	/* double-precision floating point view */} md_fpr_t;/* control register file contents */typedef struct {  qword_t fpcr;			/* floating point condition codes */  qword_t uniq;			/* process-unique register */} md_ctrl_t;/* well known registers */enum md_reg_names {  MD_REG_V0 = 0,	/* return value reg */  MD_REG_ERR = 7,  MD_REG_FP = 15,	/* frame pointer */  MD_REG_A0 = 16,	/* argument regs */  MD_REG_A1 = 17,  MD_REG_A2 = 18,  MD_REG_A3 = 19,  MD_REG_A4 = 20,  MD_REG_A5 = 21,  MD_REG_RA = 26,	/* return address reg */  MD_REG_GP = 29,	/* global data section pointer */  MD_REG_SP = 30,	/* stack pointer */  MD_REG_ZERO = 31	/* zero register */};/* * 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)		SWAP_WORD(X)#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 *//* 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 {  FUClamd_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 */#define RA		((inst >> 21) & 0x1f)		/* reg source #1 */#define RB		((inst >> 16) & 0x1f)		/* reg source #2 */#define RC		(inst & 0x1f)			/* reg dest *//* returns 8-bit unsigned immediate field value */#define IMM		((qword_t)((inst >> 13) & 0xff))/* returns 21-bit unsigned absolute jump target field value */#define TARG		(inst & 0x1fffff)/* load/store 16-bit unsigned offset field value */#define OFS		(inst & 0xffff)/* sign-extend operands */#define SEXT(X)								\  (((X) & 0x8000) ? ((sqword_t)(X) | LL(0xffffffffffff0000)) : (sqword_t)(X))#define SEXT21(X)							\  (((X) & 0x100000) ? ((sqword_t)(X) | LL(0xffffffffffe00000)) : (sqword_t)(X))#define SEXT32(X)							\  (((X) & 0x80000000) ? ((sqword_t)(X)|LL(0xffffffff00000000)) : (sqword_t)(X))/* test for arithmetic overflow */#define ARITH_OVFL(RESULT, OP1, OP2) ((RESULT) < (OP1) || (RESULT) < (OP2))/* test for NaN */#define IEEEFP_DBL_SIGN(Q)	((Q) >> 63)#define IEEEFP_DBL_EXPONENT(Q)	(((Q) >> 52) & 0x7ff)#define IEEEFP_DBL_FRACTION(Q)	((Q) & ULL(0xfffffffffffff))#define IS_IEEEFP_DBL_NAN(Q)						\  ((IEEEFP_DBL_EXPONENT(Q) == 0x7ff) && (IEEEFP_DBL_FRACTION(Q)))/* default target PC handling */#ifndef SET_TPC#define SET_TPC(PC)	(void)0#endif /* SET_TPC *//* * various other helper macros/functions */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -