static_inst.hh
来自「M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作」· HH 代码 · 共 654 行 · 第 1/2 页
HH
654 行
/* * Copyright (c) 2003, 2004, 2005 * 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: Steven K. Reinhardt */#ifndef __CPU_STATIC_INST_HH__#define __CPU_STATIC_INST_HH__#include <bitset>#include <string>#include "arch/isa_traits.hh"#include "arch/utility.hh"#include "sim/faults.hh"#include "base/bitfield.hh"#include "base/hashmap.hh"#include "base/misc.hh"#include "base/refcnt.hh"#include "cpu/op_class.hh"#include "cpu/o3/dyn_inst.hh"#include "sim/faults.hh"#include "sim/host.hh"// forward declarationsstruct AlphaSimpleImpl;struct OzoneImpl;struct SimpleImpl;class ThreadContext;class DynInst;class Packet;template <class Impl>class OzoneDynInst;class CheckerCPU;class FastCPU;class AtomicSimpleCPU;class TimingSimpleCPU;class InorderCPU;class SymbolTable;class AddrDecodePage;namespace Trace { class InstRecord;}typedef uint32_t MicroPC;/** * Base, ISA-independent static instruction class. * * The main component of this class is the vector of flags and the * associated methods for reading them. Any object that can rely * solely on these flags can process instructions without being * recompiled for multiple ISAs. */class StaticInstBase : public RefCounted{ protected: /// Set of boolean static instruction properties. /// /// Notes: /// - The IsInteger and IsFloating flags are based on the class of /// registers accessed by the instruction. Although most /// instructions will have exactly one of these two flags set, it /// is possible for an instruction to have neither (e.g., direct /// unconditional branches, memory barriers) or both (e.g., an /// FP/int conversion). /// - If IsMemRef is set, then exactly one of IsLoad or IsStore /// will be set. /// - If IsControl is set, then exactly one of IsDirectControl or /// IsIndirect Control will be set, and exactly one of /// IsCondControl or IsUncondControl will be set. /// - IsSerializing, IsMemBarrier, and IsWriteBarrier are /// implemented as flags since in the current model there's no /// other way for instructions to inject behavior into the /// pipeline outside of fetch. Once we go to an exec-in-exec CPU /// model we should be able to get rid of these flags and /// implement this behavior via the execute() methods. /// enum Flags { IsNop, ///< Is a no-op (no effect at all). IsInteger, ///< References integer regs. IsFloating, ///< References FP regs. IsMemRef, ///< References memory (load, store, or prefetch). IsLoad, ///< Reads from memory (load or prefetch). IsStore, ///< Writes to memory. IsStoreConditional, ///< Store conditional instruction. IsIndexed, ///< Accesses memory with an indexed address computation IsInstPrefetch, ///< Instruction-cache prefetch. IsDataPrefetch, ///< Data-cache prefetch. IsCopy, ///< Fast Cache block copy IsControl, ///< Control transfer instruction. IsDirectControl, ///< PC relative control transfer. IsIndirectControl, ///< Register indirect control transfer. IsCondControl, ///< Conditional control transfer. IsUncondControl, ///< Unconditional control transfer. IsCall, ///< Subroutine call. IsReturn, ///< Subroutine return. IsCondDelaySlot,///< Conditional Delay-Slot Instruction IsThreadSync, ///< Thread synchronization operation. IsSerializing, ///< Serializes pipeline: won't execute until all /// older instructions have committed. IsSerializeBefore, IsSerializeAfter, IsMemBarrier, ///< Is a memory barrier IsWriteBarrier, ///< Is a write barrier IsERET, /// <- Causes the IFU to stall (MIPS ISA) IsNonSpeculative, ///< Should not be executed speculatively IsQuiesce, ///< Is a quiesce instruction IsIprAccess, ///< Accesses IPRs IsUnverifiable, ///< Can't be verified by a checker IsSyscall, ///< Causes a system call to be emulated in syscall /// emulation mode. //Flags for microcode IsMacroop, ///< Is a macroop containing microops IsMicroop, ///< Is a microop IsDelayedCommit, ///< This microop doesn't commit right away IsLastMicroop, ///< This microop ends a microop sequence IsFirstMicroop, ///< This microop begins a microop sequence //This flag doesn't do anything yet IsMicroBranch, ///< This microop branches within the microcode for a macroop IsDspOp, NumFlags }; /// Flag values for this instruction. std::bitset<NumFlags> flags; /// See opClass(). OpClass _opClass; /// See numSrcRegs(). int8_t _numSrcRegs; /// See numDestRegs(). int8_t _numDestRegs; /// The following are used to track physical register usage /// for machines with separate int & FP reg files. //@{ int8_t _numFPDestRegs; int8_t _numIntDestRegs; //@} /// Constructor. /// It's important to initialize everything here to a sane /// default, since the decoder generally only overrides /// the fields that are meaningful for the particular /// instruction. StaticInstBase(OpClass __opClass) : _opClass(__opClass), _numSrcRegs(0), _numDestRegs(0), _numFPDestRegs(0), _numIntDestRegs(0) { } public: /// @name Register information. /// The sum of numFPDestRegs() and numIntDestRegs() equals /// numDestRegs(). The former two functions are used to track /// physical register usage for machines with separate int & FP /// reg files. //@{ /// Number of source registers. int8_t numSrcRegs() const { return _numSrcRegs; } /// Number of destination registers. int8_t numDestRegs() const { return _numDestRegs; } /// Number of floating-point destination regs. int8_t numFPDestRegs() const { return _numFPDestRegs; } /// Number of integer destination regs. int8_t numIntDestRegs() const { return _numIntDestRegs; } //@} /// @name Flag accessors. /// These functions are used to access the values of the various /// instruction property flags. See StaticInstBase::Flags for descriptions /// of the individual flags. //@{ bool isNop() const { return flags[IsNop]; } bool isMemRef() const { return flags[IsMemRef]; } bool isLoad() const { return flags[IsLoad]; } bool isStore() const { return flags[IsStore]; } bool isStoreConditional() const { return flags[IsStoreConditional]; } bool isInstPrefetch() const { return flags[IsInstPrefetch]; } bool isDataPrefetch() const { return flags[IsDataPrefetch]; } bool isCopy() const { return flags[IsCopy];} bool isInteger() const { return flags[IsInteger]; } bool isFloating() const { return flags[IsFloating]; } bool isControl() const { return flags[IsControl]; } bool isCall() const { return flags[IsCall]; } bool isReturn() const { return flags[IsReturn]; } bool isDirectCtrl() const { return flags[IsDirectControl]; } bool isIndirectCtrl() const { return flags[IsIndirectControl]; } bool isCondCtrl() const { return flags[IsCondControl]; } bool isUncondCtrl() const { return flags[IsUncondControl]; } bool isCondDelaySlot() const { return flags[IsCondDelaySlot]; } bool isThreadSync() const { return flags[IsThreadSync]; } bool isSerializing() const { return flags[IsSerializing] || flags[IsSerializeBefore] || flags[IsSerializeAfter]; } bool isSerializeBefore() const { return flags[IsSerializeBefore]; } bool isSerializeAfter() const { return flags[IsSerializeAfter]; } bool isMemBarrier() const { return flags[IsMemBarrier]; } bool isWriteBarrier() const { return flags[IsWriteBarrier]; } bool isNonSpeculative() const { return flags[IsNonSpeculative]; } bool isQuiesce() const { return flags[IsQuiesce]; } bool isIprAccess() const { return flags[IsIprAccess]; } bool isUnverifiable() const { return flags[IsUnverifiable]; } bool isSyscall() const { return flags[IsSyscall]; } bool isMacroop() const { return flags[IsMacroop]; } bool isMicroop() const { return flags[IsMicroop]; } bool isDelayedCommit() const { return flags[IsDelayedCommit]; } bool isLastMicroop() const { return flags[IsLastMicroop]; } bool isFirstMicroop() const { return flags[IsFirstMicroop]; } //This flag doesn't do anything yet bool isMicroBranch() const { return flags[IsMicroBranch]; } //@} void setLastMicroop() { flags[IsLastMicroop] = true; } /// Operation class. Used to select appropriate function unit in issue. OpClass opClass() const { return _opClass; }};// forward declarationclass StaticInstPtr;/** * Generic yet ISA-dependent static instruction class. * * This class builds on StaticInstBase, defining fields and interfaces * that are generic across all ISAs but that differ in details * according to the specific ISA being used. */class StaticInst : public StaticInstBase{ public: /// Binary machine instruction type. typedef TheISA::MachInst MachInst; /// Binary extended machine instruction type. typedef TheISA::ExtMachInst ExtMachInst; /// Logical register index type. typedef TheISA::RegIndex RegIndex; enum { MaxInstSrcRegs = TheISA::MaxInstSrcRegs, //< Max source regs MaxInstDestRegs = TheISA::MaxInstDestRegs, //< Max dest regs }; /// Return logical index (architectural reg num) of i'th destination reg. /// Only the entries from 0 through numDestRegs()-1 are valid. RegIndex destRegIdx(int i) const { return _destRegIdx[i]; } /// Return logical index (architectural reg num) of i'th source reg. /// Only the entries from 0 through numSrcRegs()-1 are valid. RegIndex srcRegIdx(int i) const { return _srcRegIdx[i]; } /// Pointer to a statically allocated "null" instruction object. /// Used to give eaCompInst() and memAccInst() something to return /// when called on non-memory instructions. static StaticInstPtr nullStaticInstPtr; /** * Memory references only: returns "fake" instruction representing * the effective address part of the memory operation. Used to * obtain the dependence info (numSrcRegs and srcRegIdx[]) for * just the EA computation. */ virtual const StaticInstPtr &eaCompInst() const { return nullStaticInstPtr; } /** * Memory references only: returns "fake" instruction representing * the memory access part of the memory operation. Used to * obtain the dependence info (numSrcRegs and srcRegIdx[]) for * just the memory access (not the EA computation). */ virtual const StaticInstPtr &memAccInst() const { return nullStaticInstPtr; } /// The binary machine instruction. const ExtMachInst machInst;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?