base_dyn_inst.hh

来自「M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作」· HH 代码 · 共 1,003 行 · 第 1/3 页

HH
1,003
字号
    /** Renames a destination register to a physical register.  Also records     *  the previous physical register that the logical register mapped to.     */    void renameDestReg(int idx,                       PhysRegIndex renamed_dest,                       PhysRegIndex previous_rename)    {        _destRegIdx[idx] = renamed_dest;        _prevDestRegIdx[idx] = previous_rename;    }    /** Renames a source logical register to the physical register which     *  has/will produce that logical register's result.     *  @todo: add in whether or not the source register is ready.     */    void renameSrcReg(int idx, PhysRegIndex renamed_src)    {        _srcRegIdx[idx] = renamed_src;    }    /** Flattens a source architectural register index into a logical index.     */    void flattenSrcReg(int idx, TheISA::RegIndex flattened_src)    {        _flatSrcRegIdx[idx] = flattened_src;    }    /** Flattens a destination architectural register index into a logical     * index.     */    void flattenDestReg(int idx, TheISA::RegIndex flattened_dest)    {        _flatDestRegIdx[idx] = flattened_dest;    }    /** BaseDynInst constructor given a binary instruction.     *  @param staticInst A StaticInstPtr to the underlying instruction.     *  @param PC The PC of the instruction.     *  @param pred_PC The predicted next PC.     *  @param pred_NPC The predicted next NPC.     *  @param seq_num The sequence number of the instruction.     *  @param cpu Pointer to the instruction's CPU.     */    BaseDynInst(StaticInstPtr staticInst, Addr PC, Addr NPC, Addr microPC,            Addr pred_PC, Addr pred_NPC, Addr pred_MicroPC,            InstSeqNum seq_num, ImplCPU *cpu);    /** BaseDynInst constructor given a binary instruction.     *  @param inst The binary instruction.     *  @param PC The PC of the instruction.     *  @param pred_PC The predicted next PC.     *  @param pred_NPC The predicted next NPC.     *  @param seq_num The sequence number of the instruction.     *  @param cpu Pointer to the instruction's CPU.     */    BaseDynInst(TheISA::ExtMachInst inst, Addr PC, Addr NPC, Addr microPC,            Addr pred_PC, Addr pred_NPC, Addr pred_MicroPC,            InstSeqNum seq_num, ImplCPU *cpu);    /** BaseDynInst constructor given a StaticInst pointer.     *  @param _staticInst The StaticInst for this BaseDynInst.     */    BaseDynInst(StaticInstPtr &_staticInst);    /** BaseDynInst destructor. */    ~BaseDynInst();  private:    /** Function to initialize variables in the constructors. */    void initVars();  public:    /** Dumps out contents of this BaseDynInst. */    void dump();    /** Dumps out contents of this BaseDynInst into given string. */    void dump(std::string &outstring);    /** Read this CPU's ID. */    int readCpuId() { return cpu->readCpuId(); }    /** Returns the fault type. */    Fault getFault() { return fault; }    /** Checks whether or not this instruction has had its branch target     *  calculated yet.  For now it is not utilized and is hacked to be     *  always false.     *  @todo: Actually use this instruction.     */    bool doneTargCalc() { return false; }    /** Returns the next PC.  This could be the speculative next PC if it is     *  called prior to the actual branch target being calculated.     */    Addr readNextPC() { return nextPC; }    /** Returns the next NPC.  This could be the speculative next NPC if it is     *  called prior to the actual branch target being calculated.     */    Addr readNextNPC()    {#if ISA_HAS_DELAY_SLOT        return nextNPC;#else        return nextPC + sizeof(TheISA::MachInst);#endif    }    Addr readNextMicroPC()    {        return nextMicroPC;    }    /** Set the predicted target of this current instruction. */    void setPredTarg(Addr predicted_PC, Addr predicted_NPC,            Addr predicted_MicroPC)    {        predPC = predicted_PC;        predNPC = predicted_NPC;        predMicroPC = predicted_MicroPC;    }    /** Returns the predicted PC immediately after the branch. */    Addr readPredPC() { return predPC; }    /** Returns the predicted PC two instructions after the branch */    Addr readPredNPC() { return predNPC; }    /** Returns the predicted micro PC after the branch */    Addr readPredMicroPC() { return predMicroPC; }    /** Returns whether the instruction was predicted taken or not. */    bool readPredTaken()    {        return predTaken;    }    void setPredTaken(bool predicted_taken)    {        predTaken = predicted_taken;    }    /** Returns whether the instruction mispredicted. */    bool mispredicted()    {        return readPredPC() != readNextPC() ||            readPredNPC() != readNextNPC() ||            readPredMicroPC() != readNextMicroPC();    }    //    //  Instruction types.  Forward checks to StaticInst object.    //    bool isNop()	  const { return staticInst->isNop(); }    bool isMemRef()    	  const { return staticInst->isMemRef(); }    bool isLoad()	  const { return staticInst->isLoad(); }    bool isStore()	  const { return staticInst->isStore(); }    bool isStoreConditional() const    { return staticInst->isStoreConditional(); }    bool isInstPrefetch() const { return staticInst->isInstPrefetch(); }    bool isDataPrefetch() const { return staticInst->isDataPrefetch(); }    bool isCopy()         const { return staticInst->isCopy(); }    bool isInteger()	  const { return staticInst->isInteger(); }    bool isFloating()	  const { return staticInst->isFloating(); }    bool isControl()	  const { return staticInst->isControl(); }    bool isCall()	  const { return staticInst->isCall(); }    bool isReturn()	  const { return staticInst->isReturn(); }    bool isDirectCtrl()	  const { return staticInst->isDirectCtrl(); }    bool isIndirectCtrl() const { return staticInst->isIndirectCtrl(); }    bool isCondCtrl()	  const { return staticInst->isCondCtrl(); }    bool isUncondCtrl()	  const { return staticInst->isUncondCtrl(); }    bool isCondDelaySlot() const { return staticInst->isCondDelaySlot(); }    bool isThreadSync()   const { return staticInst->isThreadSync(); }    bool isSerializing()  const { return staticInst->isSerializing(); }    bool isSerializeBefore() const    { return staticInst->isSerializeBefore() || status[SerializeBefore]; }    bool isSerializeAfter() const    { return staticInst->isSerializeAfter() || status[SerializeAfter]; }    bool isMemBarrier()   const { return staticInst->isMemBarrier(); }    bool isWriteBarrier() const { return staticInst->isWriteBarrier(); }    bool isNonSpeculative() const { return staticInst->isNonSpeculative(); }    bool isQuiesce() const { return staticInst->isQuiesce(); }    bool isIprAccess() const { return staticInst->isIprAccess(); }    bool isUnverifiable() const { return staticInst->isUnverifiable(); }    bool isSyscall() const { return staticInst->isSyscall(); }    bool isMacroop() const { return staticInst->isMacroop(); }    bool isMicroop() const { return staticInst->isMicroop(); }    bool isDelayedCommit() const { return staticInst->isDelayedCommit(); }    bool isLastMicroop() const { return staticInst->isLastMicroop(); }    bool isFirstMicroop() const { return staticInst->isFirstMicroop(); }    bool isMicroBranch() const { return staticInst->isMicroBranch(); }    /** Temporarily sets this instruction as a serialize before instruction. */    void setSerializeBefore() { status.set(SerializeBefore); }    /** Clears the serializeBefore part of this instruction. */    void clearSerializeBefore() { status.reset(SerializeBefore); }    /** Checks if this serializeBefore is only temporarily set. */    bool isTempSerializeBefore() { return status[SerializeBefore]; }    /** Temporarily sets this instruction as a serialize after instruction. */    void setSerializeAfter() { status.set(SerializeAfter); }    /** Clears the serializeAfter part of this instruction.*/    void clearSerializeAfter() { status.reset(SerializeAfter); }    /** Checks if this serializeAfter is only temporarily set. */    bool isTempSerializeAfter() { return status[SerializeAfter]; }    /** Sets the serialization part of this instruction as handled. */    void setSerializeHandled() { status.set(SerializeHandled); }    /** Checks if the serialization part of this instruction has been     *  handled.  This does not apply to the temporary serializing     *  state; it only applies to this instruction's own permanent     *  serializing state.     */    bool isSerializeHandled() { return status[SerializeHandled]; }    /** Returns the opclass of this instruction. */    OpClass opClass() const { return staticInst->opClass(); }    /** Returns the branch target address. */    Addr branchTarget() const { return staticInst->branchTarget(PC); }    /** Returns the number of source registers. */    int8_t numSrcRegs()	const { return staticInst->numSrcRegs(); }    /** Returns the number of destination registers. */    int8_t numDestRegs() const { return staticInst->numDestRegs(); }    // the following are used to track physical register usage    // for machines with separate int & FP reg files    int8_t numFPDestRegs()  const { return staticInst->numFPDestRegs(); }    int8_t numIntDestRegs() const { return staticInst->numIntDestRegs(); }    /** Returns the logical register index of the i'th destination register. */    RegIndex destRegIdx(int i) const { return staticInst->destRegIdx(i); }    /** Returns the logical register index of the i'th source register. */    RegIndex srcRegIdx(int i) const { return staticInst->srcRegIdx(i); }    /** Returns the result of an integer instruction. */    uint64_t readIntResult() { return instResult.integer; }    /** Returns the result of a floating point instruction. */    float readFloatResult() { return (float)instResult.dbl; }    /** Returns the result of a floating point (double) instruction. */    double readDoubleResult() { return instResult.dbl; }    /** Records an integer register being set to a value. */    void setIntRegOperand(const StaticInst *si, int idx, uint64_t val)    {        if (recordResult)            instResult.integer = val;    }    /** Records an fp register being set to a value. */    void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val,                            int width)    {        if (recordResult) {            if (width == 32)                instResult.dbl = (double)val;            else if (width == 64)                instResult.dbl = val;            else                panic("Unsupported width!");        }    }    /** Records an fp register being set to a value. */    void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val)    {        if (recordResult)            instResult.dbl = (double)val;    }    /** Records an fp register being set to an integer value. */    void setFloatRegOperandBits(const StaticInst *si, int idx, uint64_t val,                                int width)    {        if (recordResult)            instResult.integer = val;    }    /** Records an fp register being set to an integer value. */    void setFloatRegOperandBits(const StaticInst *si, int idx, uint64_t val)    {        if (recordResult)            instResult.integer = val;    }    /** Records that one of the source registers is ready. */    void markSrcRegReady();    /** Marks a specific register as ready. */    void markSrcRegReady(RegIndex src_idx);    /** Returns if a source register is ready. */    bool isReadySrcRegIdx(int idx) const    {        return this->_readySrcRegIdx[idx];    }    /** Sets this instruction as completed. */    void setCompleted() { status.set(Completed); }    /** Returns whether or not this instruction is completed. */    bool isCompleted() const { return status[Completed]; }    /** Marks the result as ready. */    void setResultReady() { status.set(ResultReady); }    /** Returns whether or not the result is ready. */    bool isResultReady() const { return status[ResultReady]; }    /** Sets this instruction as ready to issue. */    void setCanIssue() { status.set(CanIssue); }    /** Returns whether or not this instruction is ready to issue. */    bool readyToIssue() const { return status[CanIssue]; }    /** Clears this instruction being able to issue. */    void clearCanIssue() { status.reset(CanIssue); }    /** Sets this instruction as issued from the IQ. */    void setIssued() { status.set(Issued); }    /** Returns whether or not this instruction has issued. */    bool isIssued() const { return status[Issued]; }    /** Clears this instruction as being issued. */

⌨️ 快捷键说明

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