base_dyn_inst.hh revision 8832
110259SAndrew.Bardsley@arm.com/* 210259SAndrew.Bardsley@arm.com * Copyright (c) 2011 ARM Limited 310259SAndrew.Bardsley@arm.com * All rights reserved. 410259SAndrew.Bardsley@arm.com * 510259SAndrew.Bardsley@arm.com * The license below extends only to copyright in the software and shall 610259SAndrew.Bardsley@arm.com * not be construed as granting a license to any other intellectual 710259SAndrew.Bardsley@arm.com * property including but not limited to intellectual property relating 810259SAndrew.Bardsley@arm.com * to a hardware implementation of the functionality of the software 910259SAndrew.Bardsley@arm.com * licensed hereunder. You may use the software subject to the license 1010259SAndrew.Bardsley@arm.com * terms below provided that you ensure that this notice is replicated 1110259SAndrew.Bardsley@arm.com * unmodified and in its entirety in all distributions of the software, 1210259SAndrew.Bardsley@arm.com * modified or unmodified, in source code or in binary form. 1310259SAndrew.Bardsley@arm.com * 1410259SAndrew.Bardsley@arm.com * Copyright (c) 2004-2006 The Regents of The University of Michigan 1510259SAndrew.Bardsley@arm.com * Copyright (c) 2009 The University of Edinburgh 1610259SAndrew.Bardsley@arm.com * All rights reserved. 1710259SAndrew.Bardsley@arm.com * 1810259SAndrew.Bardsley@arm.com * Redistribution and use in source and binary forms, with or without 1910259SAndrew.Bardsley@arm.com * modification, are permitted provided that the following conditions are 2010259SAndrew.Bardsley@arm.com * met: redistributions of source code must retain the above copyright 2110259SAndrew.Bardsley@arm.com * notice, this list of conditions and the following disclaimer; 2210259SAndrew.Bardsley@arm.com * redistributions in binary form must reproduce the above copyright 2310259SAndrew.Bardsley@arm.com * notice, this list of conditions and the following disclaimer in the 2410259SAndrew.Bardsley@arm.com * documentation and/or other materials provided with the distribution; 2510259SAndrew.Bardsley@arm.com * neither the name of the copyright holders nor the names of its 2610259SAndrew.Bardsley@arm.com * contributors may be used to endorse or promote products derived from 2710259SAndrew.Bardsley@arm.com * this software without specific prior written permission. 2810259SAndrew.Bardsley@arm.com * 2910259SAndrew.Bardsley@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3010259SAndrew.Bardsley@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3110259SAndrew.Bardsley@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3210259SAndrew.Bardsley@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3310259SAndrew.Bardsley@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3410259SAndrew.Bardsley@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3510259SAndrew.Bardsley@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3610259SAndrew.Bardsley@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3710259SAndrew.Bardsley@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3810259SAndrew.Bardsley@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3910259SAndrew.Bardsley@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4010259SAndrew.Bardsley@arm.com * 4110259SAndrew.Bardsley@arm.com * Authors: Kevin Lim 4210259SAndrew.Bardsley@arm.com * Timothy M. Jones 4310259SAndrew.Bardsley@arm.com */ 4410259SAndrew.Bardsley@arm.com 4510259SAndrew.Bardsley@arm.com#ifndef __CPU_BASE_DYN_INST_HH__ 4610259SAndrew.Bardsley@arm.com#define __CPU_BASE_DYN_INST_HH__ 4710259SAndrew.Bardsley@arm.com 4810259SAndrew.Bardsley@arm.com#include <bitset> 4910259SAndrew.Bardsley@arm.com#include <list> 5010259SAndrew.Bardsley@arm.com#include <string> 5110259SAndrew.Bardsley@arm.com#include <queue> 5210259SAndrew.Bardsley@arm.com 5310259SAndrew.Bardsley@arm.com#include "arch/utility.hh" 5410259SAndrew.Bardsley@arm.com#include "base/fast_alloc.hh" 5510259SAndrew.Bardsley@arm.com#include "base/trace.hh" 5610319SAndreas.Sandberg@ARM.com#include "config/the_isa.hh" 5710259SAndrew.Bardsley@arm.com#include "config/use_checker.hh" 5810259SAndrew.Bardsley@arm.com#include "cpu/o3/comm.hh" 5910259SAndrew.Bardsley@arm.com#include "cpu/exetrace.hh" 6010259SAndrew.Bardsley@arm.com#include "cpu/inst_seq.hh" 6111608Snikos.nikoleris@arm.com#include "cpu/op_class.hh" 6210259SAndrew.Bardsley@arm.com#include "cpu/static_inst.hh" 6310259SAndrew.Bardsley@arm.com#include "cpu/translation.hh" 6410259SAndrew.Bardsley@arm.com#include "mem/packet.hh" 6510259SAndrew.Bardsley@arm.com#include "sim/byteswap.hh" 6610259SAndrew.Bardsley@arm.com#include "sim/fault_fwd.hh" 6710259SAndrew.Bardsley@arm.com#include "sim/system.hh" 6810259SAndrew.Bardsley@arm.com#include "sim/tlb.hh" 6910259SAndrew.Bardsley@arm.com 7010259SAndrew.Bardsley@arm.com/** 7110259SAndrew.Bardsley@arm.com * @file 7210259SAndrew.Bardsley@arm.com * Defines a dynamic instruction context. 7310259SAndrew.Bardsley@arm.com */ 7410319SAndreas.Sandberg@ARM.com 7510259SAndrew.Bardsley@arm.comtemplate <class Impl> 7610259SAndrew.Bardsley@arm.comclass BaseDynInst : public FastAlloc, public RefCounted 7710259SAndrew.Bardsley@arm.com{ 7810259SAndrew.Bardsley@arm.com public: 7910259SAndrew.Bardsley@arm.com // Typedef for the CPU. 8010259SAndrew.Bardsley@arm.com typedef typename Impl::CPUType ImplCPU; 8110259SAndrew.Bardsley@arm.com typedef typename ImplCPU::ImplState ImplState; 8210259SAndrew.Bardsley@arm.com 8310259SAndrew.Bardsley@arm.com // Logical register index type. 8410259SAndrew.Bardsley@arm.com typedef TheISA::RegIndex RegIndex; 8510259SAndrew.Bardsley@arm.com // Integer register type. 8610259SAndrew.Bardsley@arm.com typedef TheISA::IntReg IntReg; 8710259SAndrew.Bardsley@arm.com // Floating point register type. 8810259SAndrew.Bardsley@arm.com typedef TheISA::FloatReg FloatReg; 8910259SAndrew.Bardsley@arm.com 9010259SAndrew.Bardsley@arm.com // The DynInstPtr type. 9110259SAndrew.Bardsley@arm.com typedef typename Impl::DynInstPtr DynInstPtr; 9210259SAndrew.Bardsley@arm.com typedef RefCountingPtr<BaseDynInst<Impl> > BaseDynInstPtr; 9310259SAndrew.Bardsley@arm.com 9410259SAndrew.Bardsley@arm.com // The list of instructions iterator type. 9510259SAndrew.Bardsley@arm.com typedef typename std::list<DynInstPtr>::iterator ListIt; 9610259SAndrew.Bardsley@arm.com 9710259SAndrew.Bardsley@arm.com enum { 9810259SAndrew.Bardsley@arm.com MaxInstSrcRegs = TheISA::MaxInstSrcRegs, /// Max source regs 9910259SAndrew.Bardsley@arm.com MaxInstDestRegs = TheISA::MaxInstDestRegs, /// Max dest regs 10010259SAndrew.Bardsley@arm.com }; 10110259SAndrew.Bardsley@arm.com 10210259SAndrew.Bardsley@arm.com /** The StaticInst used by this BaseDynInst. */ 10310259SAndrew.Bardsley@arm.com StaticInstPtr staticInst; 10410259SAndrew.Bardsley@arm.com StaticInstPtr macroop; 10510259SAndrew.Bardsley@arm.com 10610259SAndrew.Bardsley@arm.com //////////////////////////////////////////// 10711608Snikos.nikoleris@arm.com // 10810259SAndrew.Bardsley@arm.com // INSTRUCTION EXECUTION 10911303Ssteve.reinhardt@amd.com // 11010259SAndrew.Bardsley@arm.com //////////////////////////////////////////// 11110259SAndrew.Bardsley@arm.com /** InstRecord that tracks this instructions. */ 11210259SAndrew.Bardsley@arm.com Trace::InstRecord *traceData; 11310259SAndrew.Bardsley@arm.com 11410259SAndrew.Bardsley@arm.com void demapPage(Addr vaddr, uint64_t asn) 11510259SAndrew.Bardsley@arm.com { 11611611SReiley.Jeyapaul@arm.com cpu->demapPage(vaddr, asn); 11710259SAndrew.Bardsley@arm.com } 11810259SAndrew.Bardsley@arm.com void demapInstPage(Addr vaddr, uint64_t asn) 11910259SAndrew.Bardsley@arm.com { 12010259SAndrew.Bardsley@arm.com cpu->demapPage(vaddr, asn); 12110259SAndrew.Bardsley@arm.com } 12210259SAndrew.Bardsley@arm.com void demapDataPage(Addr vaddr, uint64_t asn) 12310319SAndreas.Sandberg@ARM.com { 12411611SReiley.Jeyapaul@arm.com cpu->demapPage(vaddr, asn); 12510259SAndrew.Bardsley@arm.com } 12610259SAndrew.Bardsley@arm.com 12710259SAndrew.Bardsley@arm.com Fault readMem(Addr addr, uint8_t *data, unsigned size, unsigned flags); 12810259SAndrew.Bardsley@arm.com 12910259SAndrew.Bardsley@arm.com Fault writeMem(uint8_t *data, unsigned size, 13011611SReiley.Jeyapaul@arm.com Addr addr, unsigned flags, uint64_t *res); 13110259SAndrew.Bardsley@arm.com 13210259SAndrew.Bardsley@arm.com /** Splits a request in two if it crosses a dcache block. */ 13310259SAndrew.Bardsley@arm.com void splitRequest(RequestPtr req, RequestPtr &sreqLow, 13410259SAndrew.Bardsley@arm.com RequestPtr &sreqHigh); 13510259SAndrew.Bardsley@arm.com 13610259SAndrew.Bardsley@arm.com /** Initiate a DTB address translation. */ 13711611SReiley.Jeyapaul@arm.com void initiateTranslation(RequestPtr req, RequestPtr sreqLow, 13810259SAndrew.Bardsley@arm.com RequestPtr sreqHigh, uint64_t *res, 13910259SAndrew.Bardsley@arm.com BaseTLB::Mode mode); 14010259SAndrew.Bardsley@arm.com 14110259SAndrew.Bardsley@arm.com /** Finish a DTB address translation. */ 14210259SAndrew.Bardsley@arm.com void finishTranslation(WholeTranslationState *state); 14310259SAndrew.Bardsley@arm.com 14411611SReiley.Jeyapaul@arm.com /** True if the DTB address translation has started. */ 14510259SAndrew.Bardsley@arm.com bool translationStarted; 14610259SAndrew.Bardsley@arm.com 14710259SAndrew.Bardsley@arm.com /** True if the DTB address translation has completed. */ 14810259SAndrew.Bardsley@arm.com bool translationCompleted; 14910259SAndrew.Bardsley@arm.com 15010259SAndrew.Bardsley@arm.com /** True if this address was found to match a previous load and they issued 15111611SReiley.Jeyapaul@arm.com * out of order. If that happend, then it's only a problem if an incoming 15210259SAndrew.Bardsley@arm.com * snoop invalidate modifies the line, in which case we need to squash. 15310259SAndrew.Bardsley@arm.com * If nothing modified the line the order doesn't matter. 15410259SAndrew.Bardsley@arm.com */ 15510259SAndrew.Bardsley@arm.com bool possibleLoadViolation; 15610259SAndrew.Bardsley@arm.com 15710259SAndrew.Bardsley@arm.com /** True if the address hit a external snoop while sitting in the LSQ. 15810259SAndrew.Bardsley@arm.com * If this is true and a older instruction sees it, this instruction must 15911611SReiley.Jeyapaul@arm.com * reexecute 16010259SAndrew.Bardsley@arm.com */ 16110259SAndrew.Bardsley@arm.com bool hitExternalSnoop; 16210259SAndrew.Bardsley@arm.com 16310259SAndrew.Bardsley@arm.com /** 16410259SAndrew.Bardsley@arm.com * Returns true if the DTB address translation is being delayed due to a hw 16510259SAndrew.Bardsley@arm.com * page table walk. 16611611SReiley.Jeyapaul@arm.com */ 16710259SAndrew.Bardsley@arm.com bool isTranslationDelayed() const 16810259SAndrew.Bardsley@arm.com { 16910259SAndrew.Bardsley@arm.com return (translationStarted && !translationCompleted); 17010259SAndrew.Bardsley@arm.com } 17110259SAndrew.Bardsley@arm.com 17211611SReiley.Jeyapaul@arm.com /** 17310259SAndrew.Bardsley@arm.com * Saved memory requests (needed when the DTB address translation is 17410259SAndrew.Bardsley@arm.com * delayed due to a hw page table walk). 17510259SAndrew.Bardsley@arm.com */ 17610259SAndrew.Bardsley@arm.com RequestPtr savedReq; 17710259SAndrew.Bardsley@arm.com RequestPtr savedSreqLow; 17811611SReiley.Jeyapaul@arm.com RequestPtr savedSreqHigh; 17910259SAndrew.Bardsley@arm.com 18010259SAndrew.Bardsley@arm.com#if USE_CHECKER 18110259SAndrew.Bardsley@arm.com // Need a copy of main request pointer to verify on writes. 18210259SAndrew.Bardsley@arm.com RequestPtr reqToVerify; 18310259SAndrew.Bardsley@arm.com#endif //USE_CHECKER 18411611SReiley.Jeyapaul@arm.com 18510259SAndrew.Bardsley@arm.com /** @todo: Consider making this private. */ 18610259SAndrew.Bardsley@arm.com public: 18710259SAndrew.Bardsley@arm.com /** The sequence number of the instruction. */ 18810259SAndrew.Bardsley@arm.com InstSeqNum seqNum; 18910259SAndrew.Bardsley@arm.com 19010698Sandreas.hansson@arm.com enum Status { 19110259SAndrew.Bardsley@arm.com IqEntry, /// Instruction is in the IQ 19210259SAndrew.Bardsley@arm.com RobEntry, /// Instruction is in the ROB 19310259SAndrew.Bardsley@arm.com LsqEntry, /// Instruction is in the LSQ 19410259SAndrew.Bardsley@arm.com Completed, /// Instruction has completed 19510259SAndrew.Bardsley@arm.com ResultReady, /// Instruction has its result 19611611SReiley.Jeyapaul@arm.com CanIssue, /// Instruction can issue and execute 19710259SAndrew.Bardsley@arm.com Issued, /// Instruction has issued 19810259SAndrew.Bardsley@arm.com Executed, /// Instruction has executed 19910259SAndrew.Bardsley@arm.com CanCommit, /// Instruction can commit 20010259SAndrew.Bardsley@arm.com AtCommit, /// Instruction has reached commit 20110259SAndrew.Bardsley@arm.com Committed, /// Instruction has committed 20211611SReiley.Jeyapaul@arm.com Squashed, /// Instruction is squashed 20310259SAndrew.Bardsley@arm.com SquashedInIQ, /// Instruction is squashed in the IQ 20410259SAndrew.Bardsley@arm.com SquashedInLSQ, /// Instruction is squashed in the LSQ 20510259SAndrew.Bardsley@arm.com SquashedInROB, /// Instruction is squashed in the ROB 20610259SAndrew.Bardsley@arm.com RecoverInst, /// Is a recover instruction 20710259SAndrew.Bardsley@arm.com BlockingInst, /// Is a blocking instruction 20811611SReiley.Jeyapaul@arm.com ThreadsyncWait, /// Is a thread synchronization instruction 20910259SAndrew.Bardsley@arm.com SerializeBefore, /// Needs to serialize on 21010259SAndrew.Bardsley@arm.com /// instructions ahead of it 21110259SAndrew.Bardsley@arm.com SerializeAfter, /// Needs to serialize instructions behind it 21210259SAndrew.Bardsley@arm.com SerializeHandled, /// Serialization has been handled 21310259SAndrew.Bardsley@arm.com NumStatus 21410259SAndrew.Bardsley@arm.com }; 21510259SAndrew.Bardsley@arm.com 21611611SReiley.Jeyapaul@arm.com /** The status of this BaseDynInst. Several bits can be set. */ 21710259SAndrew.Bardsley@arm.com std::bitset<NumStatus> status; 21810259SAndrew.Bardsley@arm.com 21910259SAndrew.Bardsley@arm.com /** The thread this instruction is from. */ 22010259SAndrew.Bardsley@arm.com ThreadID threadNumber; 22110259SAndrew.Bardsley@arm.com 22210259SAndrew.Bardsley@arm.com /** data address space ID, for loads & stores. */ 22311611SReiley.Jeyapaul@arm.com short asid; 22410259SAndrew.Bardsley@arm.com 22510259SAndrew.Bardsley@arm.com /** How many source registers are ready. */ 22610259SAndrew.Bardsley@arm.com unsigned readyRegs; 22710259SAndrew.Bardsley@arm.com 22810259SAndrew.Bardsley@arm.com /** Pointer to the Impl's CPU object. */ 22910259SAndrew.Bardsley@arm.com ImplCPU *cpu; 23010259SAndrew.Bardsley@arm.com 23110259SAndrew.Bardsley@arm.com /** Pointer to the thread state. */ 23210259SAndrew.Bardsley@arm.com ImplState *thread; 23311611SReiley.Jeyapaul@arm.com 23410259SAndrew.Bardsley@arm.com /** The kind of fault this instruction has generated. */ 23510259SAndrew.Bardsley@arm.com Fault fault; 23610259SAndrew.Bardsley@arm.com 23710259SAndrew.Bardsley@arm.com /** Pointer to the data for the memory access. */ 23810259SAndrew.Bardsley@arm.com uint8_t *memData; 23910259SAndrew.Bardsley@arm.com 24010259SAndrew.Bardsley@arm.com /** The effective virtual address (lds & stores only). */ 24110259SAndrew.Bardsley@arm.com Addr effAddr; 24210259SAndrew.Bardsley@arm.com 24311611SReiley.Jeyapaul@arm.com /** The size of the request */ 24411611SReiley.Jeyapaul@arm.com Addr effSize; 24510259SAndrew.Bardsley@arm.com 24610259SAndrew.Bardsley@arm.com /** Is the effective virtual address valid. */ 24710259SAndrew.Bardsley@arm.com bool effAddrValid; 24810259SAndrew.Bardsley@arm.com 24910259SAndrew.Bardsley@arm.com /** The effective physical address. */ 25010259SAndrew.Bardsley@arm.com Addr physEffAddr; 25111611SReiley.Jeyapaul@arm.com 25210259SAndrew.Bardsley@arm.com /** The memory request flags (from translation). */ 25310259SAndrew.Bardsley@arm.com unsigned memReqFlags; 25411611SReiley.Jeyapaul@arm.com 25511611SReiley.Jeyapaul@arm.com union Result { 25610259SAndrew.Bardsley@arm.com uint64_t integer; 25711005Sandreas.sandberg@arm.com double dbl; 25810259SAndrew.Bardsley@arm.com void set(uint64_t i) { integer = i; } 25910259SAndrew.Bardsley@arm.com void set(double d) { dbl = d; } 26010259SAndrew.Bardsley@arm.com void get(uint64_t& i) { i = integer; } 26110259SAndrew.Bardsley@arm.com void get(double& d) { d = dbl; } 26211611SReiley.Jeyapaul@arm.com }; 26310259SAndrew.Bardsley@arm.com 26410259SAndrew.Bardsley@arm.com /** The result of the instruction; assumes an instruction can have many 26510259SAndrew.Bardsley@arm.com * destination registers. 26610259SAndrew.Bardsley@arm.com */ 26710259SAndrew.Bardsley@arm.com std::queue<Result> instResult; 26810935Snilay@cs.wisc.edu 26911611SReiley.Jeyapaul@arm.com /** Records changes to result? */ 27010935Snilay@cs.wisc.edu bool recordResult; 27110935Snilay@cs.wisc.edu 27210935Snilay@cs.wisc.edu /** Did this instruction execute, or is it predicated false */ 27310935Snilay@cs.wisc.edu bool predicate; 27410935Snilay@cs.wisc.edu 27510935Snilay@cs.wisc.edu protected: 27611611SReiley.Jeyapaul@arm.com /** PC state for this instruction. */ 27710935Snilay@cs.wisc.edu TheISA::PCState pc; 27810935Snilay@cs.wisc.edu 27910935Snilay@cs.wisc.edu /** Predicted PC state after this instruction. */ 28010935Snilay@cs.wisc.edu TheISA::PCState predPC; 28110935Snilay@cs.wisc.edu 28210259SAndrew.Bardsley@arm.com /** If this is a branch that was predicted taken */ 28310259SAndrew.Bardsley@arm.com bool predTaken; 28410259SAndrew.Bardsley@arm.com 28510259SAndrew.Bardsley@arm.com public: 28610259SAndrew.Bardsley@arm.com 28710259SAndrew.Bardsley@arm.com#ifdef DEBUG 28810259SAndrew.Bardsley@arm.com void dumpSNList(); 28910259SAndrew.Bardsley@arm.com#endif 29010259SAndrew.Bardsley@arm.com 29110259SAndrew.Bardsley@arm.com /** Whether or not the source register is ready. 29210259SAndrew.Bardsley@arm.com * @todo: Not sure this should be here vs the derived class. 29310259SAndrew.Bardsley@arm.com */ 29410259SAndrew.Bardsley@arm.com bool _readySrcRegIdx[MaxInstSrcRegs]; 29511611SReiley.Jeyapaul@arm.com 29610259SAndrew.Bardsley@arm.com protected: 29710259SAndrew.Bardsley@arm.com /** Flattened register index of the destination registers of this 29810259SAndrew.Bardsley@arm.com * instruction. 29910259SAndrew.Bardsley@arm.com */ 30010259SAndrew.Bardsley@arm.com TheISA::RegIndex _flatDestRegIdx[TheISA::MaxInstDestRegs]; 30110259SAndrew.Bardsley@arm.com 30210259SAndrew.Bardsley@arm.com /** Flattened register index of the source registers of this 30311611SReiley.Jeyapaul@arm.com * instruction. 30410259SAndrew.Bardsley@arm.com */ 30510259SAndrew.Bardsley@arm.com TheISA::RegIndex _flatSrcRegIdx[TheISA::MaxInstSrcRegs]; 30610259SAndrew.Bardsley@arm.com 30710259SAndrew.Bardsley@arm.com /** Physical register index of the destination registers of this 30810259SAndrew.Bardsley@arm.com * instruction. 30910259SAndrew.Bardsley@arm.com */ 31010319SAndreas.Sandberg@ARM.com PhysRegIndex _destRegIdx[TheISA::MaxInstDestRegs]; 31110259SAndrew.Bardsley@arm.com 31210259SAndrew.Bardsley@arm.com /** Physical register index of the source registers of this 31310259SAndrew.Bardsley@arm.com * instruction. 31410259SAndrew.Bardsley@arm.com */ 31510259SAndrew.Bardsley@arm.com PhysRegIndex _srcRegIdx[TheISA::MaxInstSrcRegs]; 31610259SAndrew.Bardsley@arm.com 31710259SAndrew.Bardsley@arm.com /** Physical register index of the previous producers of the 31810259SAndrew.Bardsley@arm.com * architected destinations. 31910259SAndrew.Bardsley@arm.com */ 32010259SAndrew.Bardsley@arm.com PhysRegIndex _prevDestRegIdx[TheISA::MaxInstDestRegs]; 32110259SAndrew.Bardsley@arm.com 32210259SAndrew.Bardsley@arm.com public: 32310259SAndrew.Bardsley@arm.com 32410259SAndrew.Bardsley@arm.com /** Returns the physical register index of the i'th destination 32510259SAndrew.Bardsley@arm.com * register. 32610259SAndrew.Bardsley@arm.com */ 32710319SAndreas.Sandberg@ARM.com PhysRegIndex renamedDestRegIdx(int idx) const 32810259SAndrew.Bardsley@arm.com { 32910259SAndrew.Bardsley@arm.com return _destRegIdx[idx]; 33010259SAndrew.Bardsley@arm.com } 33110259SAndrew.Bardsley@arm.com 33210259SAndrew.Bardsley@arm.com /** Returns the physical register index of the i'th source register. */ 33310259SAndrew.Bardsley@arm.com PhysRegIndex renamedSrcRegIdx(int idx) const 33410259SAndrew.Bardsley@arm.com { 33510259SAndrew.Bardsley@arm.com return _srcRegIdx[idx]; 33610259SAndrew.Bardsley@arm.com } 33710259SAndrew.Bardsley@arm.com 33810259SAndrew.Bardsley@arm.com /** Returns the flattened register index of the i'th destination 33910259SAndrew.Bardsley@arm.com * register. 34010259SAndrew.Bardsley@arm.com */ 34110259SAndrew.Bardsley@arm.com TheISA::RegIndex flattenedDestRegIdx(int idx) const 34210259SAndrew.Bardsley@arm.com { 34310529Smorr@cs.wisc.edu return _flatDestRegIdx[idx]; 34410529Smorr@cs.wisc.edu } 34510529Smorr@cs.wisc.edu 34611611SReiley.Jeyapaul@arm.com /** Returns the flattened register index of the i'th source register */ 34711567Smitch.hayenga@arm.com TheISA::RegIndex flattenedSrcRegIdx(int idx) const 34811567Smitch.hayenga@arm.com { 34911611SReiley.Jeyapaul@arm.com return _flatSrcRegIdx[idx]; 35011567Smitch.hayenga@arm.com } 35111567Smitch.hayenga@arm.com 35211611SReiley.Jeyapaul@arm.com /** Returns the physical register index of the previous physical register 35311567Smitch.hayenga@arm.com * that remapped to the same logical register index. 35411567Smitch.hayenga@arm.com */ 35511611SReiley.Jeyapaul@arm.com PhysRegIndex prevDestRegIdx(int idx) const 35611567Smitch.hayenga@arm.com { 35710259SAndrew.Bardsley@arm.com return _prevDestRegIdx[idx]; 35810259SAndrew.Bardsley@arm.com } 35910259SAndrew.Bardsley@arm.com 36010259SAndrew.Bardsley@arm.com /** Renames a destination register to a physical register. Also records 36110259SAndrew.Bardsley@arm.com * the previous physical register that the logical register mapped to. 362 */ 363 void renameDestReg(int idx, 364 PhysRegIndex renamed_dest, 365 PhysRegIndex previous_rename) 366 { 367 _destRegIdx[idx] = renamed_dest; 368 _prevDestRegIdx[idx] = previous_rename; 369 } 370 371 /** Renames a source logical register to the physical register which 372 * has/will produce that logical register's result. 373 * @todo: add in whether or not the source register is ready. 374 */ 375 void renameSrcReg(int idx, PhysRegIndex renamed_src) 376 { 377 _srcRegIdx[idx] = renamed_src; 378 } 379 380 /** Flattens a source architectural register index into a logical index. 381 */ 382 void flattenSrcReg(int idx, TheISA::RegIndex flattened_src) 383 { 384 _flatSrcRegIdx[idx] = flattened_src; 385 } 386 387 /** Flattens a destination architectural register index into a logical 388 * index. 389 */ 390 void flattenDestReg(int idx, TheISA::RegIndex flattened_dest) 391 { 392 _flatDestRegIdx[idx] = flattened_dest; 393 } 394 /** BaseDynInst constructor given a binary instruction. 395 * @param staticInst A StaticInstPtr to the underlying instruction. 396 * @param pc The PC state for the instruction. 397 * @param predPC The predicted next PC state for the instruction. 398 * @param seq_num The sequence number of the instruction. 399 * @param cpu Pointer to the instruction's CPU. 400 */ 401 BaseDynInst(StaticInstPtr staticInst, StaticInstPtr macroop, 402 TheISA::PCState pc, TheISA::PCState predPC, 403 InstSeqNum seq_num, ImplCPU *cpu); 404 405 /** BaseDynInst constructor given a StaticInst pointer. 406 * @param _staticInst The StaticInst for this BaseDynInst. 407 */ 408 BaseDynInst(StaticInstPtr staticInst, StaticInstPtr macroop); 409 410 /** BaseDynInst destructor. */ 411 ~BaseDynInst(); 412 413 private: 414 /** Function to initialize variables in the constructors. */ 415 void initVars(); 416 417 public: 418 /** Dumps out contents of this BaseDynInst. */ 419 void dump(); 420 421 /** Dumps out contents of this BaseDynInst into given string. */ 422 void dump(std::string &outstring); 423 424 /** Read this CPU's ID. */ 425 int cpuId() { return cpu->cpuId(); } 426 427 /** Read this CPU's data requestor ID */ 428 MasterID masterId() { return cpu->dataMasterId(); } 429 430 /** Read this context's system-wide ID **/ 431 int contextId() { return thread->contextId(); } 432 433 /** Returns the fault type. */ 434 Fault getFault() { return fault; } 435 436 /** Checks whether or not this instruction has had its branch target 437 * calculated yet. For now it is not utilized and is hacked to be 438 * always false. 439 * @todo: Actually use this instruction. 440 */ 441 bool doneTargCalc() { return false; } 442 443 /** Set the predicted target of this current instruction. */ 444 void setPredTarg(const TheISA::PCState &_predPC) 445 { 446 predPC = _predPC; 447 } 448 449 const TheISA::PCState &readPredTarg() { return predPC; } 450 451 /** Returns the predicted PC immediately after the branch. */ 452 Addr predInstAddr() { return predPC.instAddr(); } 453 454 /** Returns the predicted PC two instructions after the branch */ 455 Addr predNextInstAddr() { return predPC.nextInstAddr(); } 456 457 /** Returns the predicted micro PC after the branch */ 458 Addr predMicroPC() { return predPC.microPC(); } 459 460 /** Returns whether the instruction was predicted taken or not. */ 461 bool readPredTaken() 462 { 463 return predTaken; 464 } 465 466 void setPredTaken(bool predicted_taken) 467 { 468 predTaken = predicted_taken; 469 } 470 471 /** Returns whether the instruction mispredicted. */ 472 bool mispredicted() 473 { 474 TheISA::PCState tempPC = pc; 475 TheISA::advancePC(tempPC, staticInst); 476 return !(tempPC == predPC); 477 } 478 479 // 480 // Instruction types. Forward checks to StaticInst object. 481 // 482 bool isNop() const { return staticInst->isNop(); } 483 bool isMemRef() const { return staticInst->isMemRef(); } 484 bool isLoad() const { return staticInst->isLoad(); } 485 bool isStore() const { return staticInst->isStore(); } 486 bool isStoreConditional() const 487 { return staticInst->isStoreConditional(); } 488 bool isInstPrefetch() const { return staticInst->isInstPrefetch(); } 489 bool isDataPrefetch() const { return staticInst->isDataPrefetch(); } 490 bool isInteger() const { return staticInst->isInteger(); } 491 bool isFloating() const { return staticInst->isFloating(); } 492 bool isControl() const { return staticInst->isControl(); } 493 bool isCall() const { return staticInst->isCall(); } 494 bool isReturn() const { return staticInst->isReturn(); } 495 bool isDirectCtrl() const { return staticInst->isDirectCtrl(); } 496 bool isIndirectCtrl() const { return staticInst->isIndirectCtrl(); } 497 bool isCondCtrl() const { return staticInst->isCondCtrl(); } 498 bool isUncondCtrl() const { return staticInst->isUncondCtrl(); } 499 bool isCondDelaySlot() const { return staticInst->isCondDelaySlot(); } 500 bool isThreadSync() const { return staticInst->isThreadSync(); } 501 bool isSerializing() const { return staticInst->isSerializing(); } 502 bool isSerializeBefore() const 503 { return staticInst->isSerializeBefore() || status[SerializeBefore]; } 504 bool isSerializeAfter() const 505 { return staticInst->isSerializeAfter() || status[SerializeAfter]; } 506 bool isSquashAfter() const { return staticInst->isSquashAfter(); } 507 bool isMemBarrier() const { return staticInst->isMemBarrier(); } 508 bool isWriteBarrier() const { return staticInst->isWriteBarrier(); } 509 bool isNonSpeculative() const { return staticInst->isNonSpeculative(); } 510 bool isQuiesce() const { return staticInst->isQuiesce(); } 511 bool isIprAccess() const { return staticInst->isIprAccess(); } 512 bool isUnverifiable() const { return staticInst->isUnverifiable(); } 513 bool isSyscall() const { return staticInst->isSyscall(); } 514 bool isMacroop() const { return staticInst->isMacroop(); } 515 bool isMicroop() const { return staticInst->isMicroop(); } 516 bool isDelayedCommit() const { return staticInst->isDelayedCommit(); } 517 bool isLastMicroop() const { return staticInst->isLastMicroop(); } 518 bool isFirstMicroop() const { return staticInst->isFirstMicroop(); } 519 bool isMicroBranch() const { return staticInst->isMicroBranch(); } 520 521 /** Temporarily sets this instruction as a serialize before instruction. */ 522 void setSerializeBefore() { status.set(SerializeBefore); } 523 524 /** Clears the serializeBefore part of this instruction. */ 525 void clearSerializeBefore() { status.reset(SerializeBefore); } 526 527 /** Checks if this serializeBefore is only temporarily set. */ 528 bool isTempSerializeBefore() { return status[SerializeBefore]; } 529 530 /** Temporarily sets this instruction as a serialize after instruction. */ 531 void setSerializeAfter() { status.set(SerializeAfter); } 532 533 /** Clears the serializeAfter part of this instruction.*/ 534 void clearSerializeAfter() { status.reset(SerializeAfter); } 535 536 /** Checks if this serializeAfter is only temporarily set. */ 537 bool isTempSerializeAfter() { return status[SerializeAfter]; } 538 539 /** Sets the serialization part of this instruction as handled. */ 540 void setSerializeHandled() { status.set(SerializeHandled); } 541 542 /** Checks if the serialization part of this instruction has been 543 * handled. This does not apply to the temporary serializing 544 * state; it only applies to this instruction's own permanent 545 * serializing state. 546 */ 547 bool isSerializeHandled() { return status[SerializeHandled]; } 548 549 /** Returns the opclass of this instruction. */ 550 OpClass opClass() const { return staticInst->opClass(); } 551 552 /** Returns the branch target address. */ 553 TheISA::PCState branchTarget() const 554 { return staticInst->branchTarget(pc); } 555 556 /** Returns the number of source registers. */ 557 int8_t numSrcRegs() const { return staticInst->numSrcRegs(); } 558 559 /** Returns the number of destination registers. */ 560 int8_t numDestRegs() const { return staticInst->numDestRegs(); } 561 562 // the following are used to track physical register usage 563 // for machines with separate int & FP reg files 564 int8_t numFPDestRegs() const { return staticInst->numFPDestRegs(); } 565 int8_t numIntDestRegs() const { return staticInst->numIntDestRegs(); } 566 567 /** Returns the logical register index of the i'th destination register. */ 568 RegIndex destRegIdx(int i) const { return staticInst->destRegIdx(i); } 569 570 /** Returns the logical register index of the i'th source register. */ 571 RegIndex srcRegIdx(int i) const { return staticInst->srcRegIdx(i); } 572 573 /** Pops a result off the instResult queue */ 574 template <class T> 575 void popResult(T& t) 576 { 577 if (!instResult.empty()) { 578 instResult.front().get(t); 579 instResult.pop(); 580 } 581 } 582 583 /** Read the most recent result stored by this instruction */ 584 template <class T> 585 void readResult(T& t) 586 { 587 instResult.back().get(t); 588 } 589 590 /** Pushes a result onto the instResult queue */ 591 template <class T> 592 void setResult(T t) 593 { 594 if (recordResult) { 595 Result instRes; 596 instRes.set(t); 597 instResult.push(instRes); 598 } 599 } 600 601 /** Records an integer register being set to a value. */ 602 void setIntRegOperand(const StaticInst *si, int idx, uint64_t val) 603 { 604 setResult<uint64_t>(val); 605 } 606 607 /** Records an fp register being set to a value. */ 608 void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val, 609 int width) 610 { 611 if (width == 32 || width == 64) { 612 setResult<double>(val); 613 } else { 614 panic("Unsupported width!"); 615 } 616 } 617 618 /** Records an fp register being set to a value. */ 619 void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val) 620 { 621 setResult<double>(val); 622 } 623 624 /** Records an fp register being set to an integer value. */ 625 void setFloatRegOperandBits(const StaticInst *si, int idx, uint64_t val, 626 int width) 627 { 628 setResult<uint64_t>(val); 629 } 630 631 /** Records an fp register being set to an integer value. */ 632 void setFloatRegOperandBits(const StaticInst *si, int idx, uint64_t val) 633 { 634 setResult<uint64_t>(val); 635 } 636 637 /** Records that one of the source registers is ready. */ 638 void markSrcRegReady(); 639 640 /** Marks a specific register as ready. */ 641 void markSrcRegReady(RegIndex src_idx); 642 643 /** Returns if a source register is ready. */ 644 bool isReadySrcRegIdx(int idx) const 645 { 646 return this->_readySrcRegIdx[idx]; 647 } 648 649 /** Sets this instruction as completed. */ 650 void setCompleted() { status.set(Completed); } 651 652 /** Returns whether or not this instruction is completed. */ 653 bool isCompleted() const { return status[Completed]; } 654 655 /** Marks the result as ready. */ 656 void setResultReady() { status.set(ResultReady); } 657 658 /** Returns whether or not the result is ready. */ 659 bool isResultReady() const { return status[ResultReady]; } 660 661 /** Sets this instruction as ready to issue. */ 662 void setCanIssue() { status.set(CanIssue); } 663 664 /** Returns whether or not this instruction is ready to issue. */ 665 bool readyToIssue() const { return status[CanIssue]; } 666 667 /** Clears this instruction being able to issue. */ 668 void clearCanIssue() { status.reset(CanIssue); } 669 670 /** Sets this instruction as issued from the IQ. */ 671 void setIssued() { status.set(Issued); } 672 673 /** Returns whether or not this instruction has issued. */ 674 bool isIssued() const { return status[Issued]; } 675 676 /** Clears this instruction as being issued. */ 677 void clearIssued() { status.reset(Issued); } 678 679 /** Sets this instruction as executed. */ 680 void setExecuted() { status.set(Executed); } 681 682 /** Returns whether or not this instruction has executed. */ 683 bool isExecuted() const { return status[Executed]; } 684 685 /** Sets this instruction as ready to commit. */ 686 void setCanCommit() { status.set(CanCommit); } 687 688 /** Clears this instruction as being ready to commit. */ 689 void clearCanCommit() { status.reset(CanCommit); } 690 691 /** Returns whether or not this instruction is ready to commit. */ 692 bool readyToCommit() const { return status[CanCommit]; } 693 694 void setAtCommit() { status.set(AtCommit); } 695 696 bool isAtCommit() { return status[AtCommit]; } 697 698 /** Sets this instruction as committed. */ 699 void setCommitted() { status.set(Committed); } 700 701 /** Returns whether or not this instruction is committed. */ 702 bool isCommitted() const { return status[Committed]; } 703 704 /** Sets this instruction as squashed. */ 705 void setSquashed() { status.set(Squashed); } 706 707 /** Returns whether or not this instruction is squashed. */ 708 bool isSquashed() const { return status[Squashed]; } 709 710 //Instruction Queue Entry 711 //----------------------- 712 /** Sets this instruction as a entry the IQ. */ 713 void setInIQ() { status.set(IqEntry); } 714 715 /** Sets this instruction as a entry the IQ. */ 716 void clearInIQ() { status.reset(IqEntry); } 717 718 /** Returns whether or not this instruction has issued. */ 719 bool isInIQ() const { return status[IqEntry]; } 720 721 /** Sets this instruction as squashed in the IQ. */ 722 void setSquashedInIQ() { status.set(SquashedInIQ); status.set(Squashed);} 723 724 /** Returns whether or not this instruction is squashed in the IQ. */ 725 bool isSquashedInIQ() const { return status[SquashedInIQ]; } 726 727 728 //Load / Store Queue Functions 729 //----------------------- 730 /** Sets this instruction as a entry the LSQ. */ 731 void setInLSQ() { status.set(LsqEntry); } 732 733 /** Sets this instruction as a entry the LSQ. */ 734 void removeInLSQ() { status.reset(LsqEntry); } 735 736 /** Returns whether or not this instruction is in the LSQ. */ 737 bool isInLSQ() const { return status[LsqEntry]; } 738 739 /** Sets this instruction as squashed in the LSQ. */ 740 void setSquashedInLSQ() { status.set(SquashedInLSQ);} 741 742 /** Returns whether or not this instruction is squashed in the LSQ. */ 743 bool isSquashedInLSQ() const { return status[SquashedInLSQ]; } 744 745 746 //Reorder Buffer Functions 747 //----------------------- 748 /** Sets this instruction as a entry the ROB. */ 749 void setInROB() { status.set(RobEntry); } 750 751 /** Sets this instruction as a entry the ROB. */ 752 void clearInROB() { status.reset(RobEntry); } 753 754 /** Returns whether or not this instruction is in the ROB. */ 755 bool isInROB() const { return status[RobEntry]; } 756 757 /** Sets this instruction as squashed in the ROB. */ 758 void setSquashedInROB() { status.set(SquashedInROB); } 759 760 /** Returns whether or not this instruction is squashed in the ROB. */ 761 bool isSquashedInROB() const { return status[SquashedInROB]; } 762 763 /** Read the PC state of this instruction. */ 764 const TheISA::PCState pcState() const { return pc; } 765 766 /** Set the PC state of this instruction. */ 767 const void pcState(const TheISA::PCState &val) { pc = val; } 768 769 /** Read the PC of this instruction. */ 770 const Addr instAddr() const { return pc.instAddr(); } 771 772 /** Read the PC of the next instruction. */ 773 const Addr nextInstAddr() const { return pc.nextInstAddr(); } 774 775 /**Read the micro PC of this instruction. */ 776 const Addr microPC() const { return pc.microPC(); } 777 778 bool readPredicate() 779 { 780 return predicate; 781 } 782 783 void setPredicate(bool val) 784 { 785 predicate = val; 786 787 if (traceData) { 788 traceData->setPredicate(val); 789 } 790 } 791 792 /** Sets the ASID. */ 793 void setASID(short addr_space_id) { asid = addr_space_id; } 794 795 /** Sets the thread id. */ 796 void setTid(ThreadID tid) { threadNumber = tid; } 797 798 /** Sets the pointer to the thread state. */ 799 void setThreadState(ImplState *state) { thread = state; } 800 801 /** Returns the thread context. */ 802 ThreadContext *tcBase() { return thread->getTC(); } 803 804 private: 805 /** Instruction effective address. 806 * @todo: Consider if this is necessary or not. 807 */ 808 Addr instEffAddr; 809 810 /** Whether or not the effective address calculation is completed. 811 * @todo: Consider if this is necessary or not. 812 */ 813 bool eaCalcDone; 814 815 /** Is this instruction's memory access uncacheable. */ 816 bool isUncacheable; 817 818 /** Has this instruction generated a memory request. */ 819 bool reqMade; 820 821 public: 822 /** Sets the effective address. */ 823 void setEA(Addr &ea) { instEffAddr = ea; eaCalcDone = true; } 824 825 /** Returns the effective address. */ 826 const Addr &getEA() const { return instEffAddr; } 827 828 /** Returns whether or not the eff. addr. calculation has been completed. */ 829 bool doneEACalc() { return eaCalcDone; } 830 831 /** Returns whether or not the eff. addr. source registers are ready. */ 832 bool eaSrcsReady(); 833 834 /** Whether or not the memory operation is done. */ 835 bool memOpDone; 836 837 /** Is this instruction's memory access uncacheable. */ 838 bool uncacheable() { return isUncacheable; } 839 840 /** Has this instruction generated a memory request. */ 841 bool hasRequest() { return reqMade; } 842 843 public: 844 /** Load queue index. */ 845 int16_t lqIdx; 846 847 /** Store queue index. */ 848 int16_t sqIdx; 849 850 /** Iterator pointing to this BaseDynInst in the list of all insts. */ 851 ListIt instListIt; 852 853 /** Returns iterator to this instruction in the list of all insts. */ 854 ListIt &getInstListIt() { return instListIt; } 855 856 /** Sets iterator for this instruction in the list of all insts. */ 857 void setInstListIt(ListIt _instListIt) { instListIt = _instListIt; } 858 859 public: 860 /** Returns the number of consecutive store conditional failures. */ 861 unsigned readStCondFailures() 862 { return thread->storeCondFailures; } 863 864 /** Sets the number of consecutive store conditional failures. */ 865 void setStCondFailures(unsigned sc_failures) 866 { thread->storeCondFailures = sc_failures; } 867}; 868 869template<class Impl> 870Fault 871BaseDynInst<Impl>::readMem(Addr addr, uint8_t *data, 872 unsigned size, unsigned flags) 873{ 874 reqMade = true; 875 Request *req = NULL; 876 Request *sreqLow = NULL; 877 Request *sreqHigh = NULL; 878 879 if (reqMade && translationStarted) { 880 req = savedReq; 881 sreqLow = savedSreqLow; 882 sreqHigh = savedSreqHigh; 883 } else { 884 req = new Request(asid, addr, size, flags, masterId(), this->pc.instAddr(), 885 thread->contextId(), threadNumber); 886 887 // Only split the request if the ISA supports unaligned accesses. 888 if (TheISA::HasUnalignedMemAcc) { 889 splitRequest(req, sreqLow, sreqHigh); 890 } 891 initiateTranslation(req, sreqLow, sreqHigh, NULL, BaseTLB::Read); 892 } 893 894 if (translationCompleted) { 895 if (fault == NoFault) { 896 effAddr = req->getVaddr(); 897 effSize = size; 898 effAddrValid = true; 899#if USE_CHECKER 900 if (reqToVerify != NULL) { 901 delete reqToVerify; 902 } 903 reqToVerify = new Request(*req); 904#endif //USE_CHECKER 905 fault = cpu->read(req, sreqLow, sreqHigh, data, lqIdx); 906 } else { 907 // Commit will have to clean up whatever happened. Set this 908 // instruction as executed. 909 this->setExecuted(); 910 } 911 912 if (fault != NoFault) { 913 // Return a fixed value to keep simulation deterministic even 914 // along misspeculated paths. 915 if (data) 916 bzero(data, size); 917 } 918 } 919 920 if (traceData) { 921 traceData->setAddr(addr); 922 } 923 924 return fault; 925} 926 927template<class Impl> 928Fault 929BaseDynInst<Impl>::writeMem(uint8_t *data, unsigned size, 930 Addr addr, unsigned flags, uint64_t *res) 931{ 932 if (traceData) { 933 traceData->setAddr(addr); 934 } 935 936 reqMade = true; 937 Request *req = NULL; 938 Request *sreqLow = NULL; 939 Request *sreqHigh = NULL; 940 941 if (reqMade && translationStarted) { 942 req = savedReq; 943 sreqLow = savedSreqLow; 944 sreqHigh = savedSreqHigh; 945 } else { 946 req = new Request(asid, addr, size, flags, masterId(), this->pc.instAddr(), 947 thread->contextId(), threadNumber); 948 949 // Only split the request if the ISA supports unaligned accesses. 950 if (TheISA::HasUnalignedMemAcc) { 951 splitRequest(req, sreqLow, sreqHigh); 952 } 953 initiateTranslation(req, sreqLow, sreqHigh, res, BaseTLB::Write); 954 } 955 956 if (fault == NoFault && translationCompleted) { 957 effAddr = req->getVaddr(); 958 effSize = size; 959 effAddrValid = true; 960#if USE_CHECKER 961 if (reqToVerify != NULL) { 962 delete reqToVerify; 963 } 964 reqToVerify = new Request(*req); 965#endif // USE_CHECKER 966 fault = cpu->write(req, sreqLow, sreqHigh, data, sqIdx); 967 } 968 969 return fault; 970} 971 972template<class Impl> 973inline void 974BaseDynInst<Impl>::splitRequest(RequestPtr req, RequestPtr &sreqLow, 975 RequestPtr &sreqHigh) 976{ 977 // Check to see if the request crosses the next level block boundary. 978 unsigned block_size = cpu->getDcachePort()->peerBlockSize(); 979 Addr addr = req->getVaddr(); 980 Addr split_addr = roundDown(addr + req->getSize() - 1, block_size); 981 assert(split_addr <= addr || split_addr - addr < block_size); 982 983 // Spans two blocks. 984 if (split_addr > addr) { 985 req->splitOnVaddr(split_addr, sreqLow, sreqHigh); 986 } 987} 988 989template<class Impl> 990inline void 991BaseDynInst<Impl>::initiateTranslation(RequestPtr req, RequestPtr sreqLow, 992 RequestPtr sreqHigh, uint64_t *res, 993 BaseTLB::Mode mode) 994{ 995 translationStarted = true; 996 997 if (!TheISA::HasUnalignedMemAcc || sreqLow == NULL) { 998 WholeTranslationState *state = 999 new WholeTranslationState(req, NULL, res, mode); 1000 1001 // One translation if the request isn't split. 1002 DataTranslation<BaseDynInstPtr> *trans = 1003 new DataTranslation<BaseDynInstPtr>(this, state); 1004 cpu->dtb->translateTiming(req, thread->getTC(), trans, mode); 1005 if (!translationCompleted) { 1006 // Save memory requests. 1007 savedReq = state->mainReq; 1008 savedSreqLow = state->sreqLow; 1009 savedSreqHigh = state->sreqHigh; 1010 } 1011 } else { 1012 WholeTranslationState *state = 1013 new WholeTranslationState(req, sreqLow, sreqHigh, NULL, res, mode); 1014 1015 // Two translations when the request is split. 1016 DataTranslation<BaseDynInstPtr> *stransLow = 1017 new DataTranslation<BaseDynInstPtr>(this, state, 0); 1018 DataTranslation<BaseDynInstPtr> *stransHigh = 1019 new DataTranslation<BaseDynInstPtr>(this, state, 1); 1020 1021 cpu->dtb->translateTiming(sreqLow, thread->getTC(), stransLow, mode); 1022 cpu->dtb->translateTiming(sreqHigh, thread->getTC(), stransHigh, mode); 1023 if (!translationCompleted) { 1024 // Save memory requests. 1025 savedReq = state->mainReq; 1026 savedSreqLow = state->sreqLow; 1027 savedSreqHigh = state->sreqHigh; 1028 } 1029 } 1030} 1031 1032template<class Impl> 1033inline void 1034BaseDynInst<Impl>::finishTranslation(WholeTranslationState *state) 1035{ 1036 fault = state->getFault(); 1037 1038 if (state->isUncacheable()) 1039 isUncacheable = true; 1040 1041 if (fault == NoFault) { 1042 physEffAddr = state->getPaddr(); 1043 memReqFlags = state->getFlags(); 1044 1045 if (state->mainReq->isCondSwap()) { 1046 assert(state->res); 1047 state->mainReq->setExtraData(*state->res); 1048 } 1049 1050 } else { 1051 state->deleteReqs(); 1052 } 1053 delete state; 1054 1055 translationCompleted = true; 1056} 1057 1058#endif // __CPU_BASE_DYN_INST_HH__ 1059