base_dyn_inst.hh
来自「M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作」· HH 代码 · 共 1,003 行 · 第 1/3 页
HH
1,003 行
/* * Copyright (c) 2004, 2005, 2006 * The Regents of The University of Michigan * All Rights Reserved * * This code is part of the M5 simulator. * * Permission is granted to use, copy, create derivative works and * redistribute this software and such derivative works for any * purpose, so long as the copyright notice above, this grant of * permission, and the disclaimer below appear in all copies made; and * so long as the name of The University of Michigan is not used in * any advertising or publicity pertaining to the use or distribution * of this software without specific, written prior authorization. * * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND * WITHOUT WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. THE REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE * LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, SPECIAL, INDIRECT, * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM * ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES. * * Authors: Kevin T. Lim */#ifndef __CPU_BASE_DYN_INST_HH__#define __CPU_BASE_DYN_INST_HH__#include <bitset>#include <list>#include <string>#include "arch/faults.hh"#include "base/fast_alloc.hh"#include "base/trace.hh"#include "config/full_system.hh"#include "cpu/o3/comm.hh"#include "cpu/exetrace.hh"#include "cpu/inst_seq.hh"#include "cpu/op_class.hh"#include "cpu/static_inst.hh"#include "mem/packet.hh"#include "sim/system.hh"/** * @file * Defines a dynamic instruction context. */// Forward declaration.class StaticInstPtr;template <class Impl>class BaseDynInst : public FastAlloc, public RefCounted{ public: // Typedef for the CPU. typedef typename Impl::CPUType ImplCPU; typedef typename ImplCPU::ImplState ImplState; // Logical register index type. typedef TheISA::RegIndex RegIndex; // Integer register type. typedef TheISA::IntReg IntReg; // Floating point register type. typedef TheISA::FloatReg FloatReg; // The DynInstPtr type. typedef typename Impl::DynInstPtr DynInstPtr; // The list of instructions iterator type. typedef typename std::list<DynInstPtr>::iterator ListIt; enum { MaxInstSrcRegs = TheISA::MaxInstSrcRegs, /// Max source regs MaxInstDestRegs = TheISA::MaxInstDestRegs, /// Max dest regs }; /** The StaticInst used by this BaseDynInst. */ StaticInstPtr staticInst; //////////////////////////////////////////// // // INSTRUCTION EXECUTION // //////////////////////////////////////////// /** InstRecord that tracks this instructions. */ Trace::InstRecord *traceData; void demapPage(Addr vaddr, uint64_t asn) { cpu->demapPage(vaddr, asn); } void demapInstPage(Addr vaddr, uint64_t asn) { cpu->demapPage(vaddr, asn); } void demapDataPage(Addr vaddr, uint64_t asn) { cpu->demapPage(vaddr, asn); } /** * Does a read to a given address. * @param addr The address to read. * @param data The read's data is written into this parameter. * @param flags The request's flags. * @return Returns any fault due to the read. */ template <class T> Fault read(Addr addr, T &data, unsigned flags); Fault translateDataReadAddr(Addr vaddr, Addr &paddr, int size, unsigned flags); /** * Does a write to a given address. * @param data The data to be written. * @param addr The address to write to. * @param flags The request's flags. * @param res The result of the write (for load locked/store conditionals). * @return Returns any fault due to the write. */ template <class T> Fault write(T data, Addr addr, unsigned flags, uint64_t *res); Fault translateDataWriteAddr(Addr vaddr, Addr &paddr, int size, unsigned flags); void prefetch(Addr addr, unsigned flags); void writeHint(Addr addr, int size, unsigned flags); Fault copySrcTranslate(Addr src); Fault copy(Addr dest); /** @todo: Consider making this private. */ public: /** The sequence number of the instruction. */ InstSeqNum seqNum; enum Status { IqEntry, /// Instruction is in the IQ RobEntry, /// Instruction is in the ROB LsqEntry, /// Instruction is in the LSQ Completed, /// Instruction has completed ResultReady, /// Instruction has its result CanIssue, /// Instruction can issue and execute Issued, /// Instruction has issued Executed, /// Instruction has executed CanCommit, /// Instruction can commit AtCommit, /// Instruction has reached commit Committed, /// Instruction has committed Squashed, /// Instruction is squashed SquashedInIQ, /// Instruction is squashed in the IQ SquashedInLSQ, /// Instruction is squashed in the LSQ SquashedInROB, /// Instruction is squashed in the ROB RecoverInst, /// Is a recover instruction BlockingInst, /// Is a blocking instruction ThreadsyncWait, /// Is a thread synchronization instruction SerializeBefore, /// Needs to serialize on /// instructions ahead of it SerializeAfter, /// Needs to serialize instructions behind it SerializeHandled, /// Serialization has been handled NumStatus }; /** The status of this BaseDynInst. Several bits can be set. */ std::bitset<NumStatus> status; /** The thread this instruction is from. */ short threadNumber; /** data address space ID, for loads & stores. */ short asid; /** How many source registers are ready. */ unsigned readyRegs; /** Pointer to the Impl's CPU object. */ ImplCPU *cpu; /** Pointer to the thread state. */ ImplState *thread; /** The kind of fault this instruction has generated. */ Fault fault; /** Pointer to the data for the memory access. */ uint8_t *memData; /** The effective virtual address (lds & stores only). */ Addr effAddr; /** Is the effective virtual address valid. */ bool effAddrValid; /** The effective physical address. */ Addr physEffAddr; /** Effective virtual address for a copy source. */ Addr copySrcEffAddr; /** Effective physical address for a copy source. */ Addr copySrcPhysEffAddr; /** The memory request flags (from translation). */ unsigned memReqFlags; union Result { uint64_t integer;// float fp; double dbl; }; /** The result of the instruction; assumes for now that there's only one * destination register. */ Result instResult; /** Records changes to result? */ bool recordResult; /** PC of this instruction. */ Addr PC; /** Micro PC of this instruction. */ Addr microPC; protected: /** Next non-speculative PC. It is not filled in at fetch, but rather * once the target of the branch is truly known (either decode or * execute). */ Addr nextPC; /** Next non-speculative NPC. Target PC for Mips or Sparc. */ Addr nextNPC; /** Next non-speculative micro PC. */ Addr nextMicroPC; /** Predicted next PC. */ Addr predPC; /** Predicted next NPC. */ Addr predNPC; /** Predicted next microPC */ Addr predMicroPC; /** If this is a branch that was predicted taken */ bool predTaken; public: /** Count of total number of dynamic instructions. */ static int instcount;#ifdef DEBUG void dumpSNList();#endif /** Whether or not the source register is ready. * @todo: Not sure this should be here vs the derived class. */ bool _readySrcRegIdx[MaxInstSrcRegs]; protected: /** Flattened register index of the destination registers of this * instruction. */ TheISA::RegIndex _flatDestRegIdx[TheISA::MaxInstDestRegs]; /** Flattened register index of the source registers of this * instruction. */ TheISA::RegIndex _flatSrcRegIdx[TheISA::MaxInstSrcRegs]; /** Physical register index of the destination registers of this * instruction. */ PhysRegIndex _destRegIdx[TheISA::MaxInstDestRegs]; /** Physical register index of the source registers of this * instruction. */ PhysRegIndex _srcRegIdx[TheISA::MaxInstSrcRegs]; /** Physical register index of the previous producers of the * architected destinations. */ PhysRegIndex _prevDestRegIdx[TheISA::MaxInstDestRegs]; public: /** Returns the physical register index of the i'th destination * register. */ PhysRegIndex renamedDestRegIdx(int idx) const { return _destRegIdx[idx]; } /** Returns the physical register index of the i'th source register. */ PhysRegIndex renamedSrcRegIdx(int idx) const { return _srcRegIdx[idx]; } /** Returns the flattened register index of the i'th destination * register. */ TheISA::RegIndex flattenedDestRegIdx(int idx) const { return _flatDestRegIdx[idx]; } /** Returns the flattened register index of the i'th source register */ TheISA::RegIndex flattenedSrcRegIdx(int idx) const { return _flatSrcRegIdx[idx]; } /** Returns the physical register index of the previous physical register * that remapped to the same logical register index. */ PhysRegIndex prevDestRegIdx(int idx) const { return _prevDestRegIdx[idx]; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?