dyn_inst_impl.hh revision 9382
11689SN/A/* 28733Sgeoffrey.blake@arm.com * Copyright (c) 2010-2011 ARM Limited 37783SGiacomo.Gabrielli@arm.com * All rights reserved 47783SGiacomo.Gabrielli@arm.com * 57783SGiacomo.Gabrielli@arm.com * The license below extends only to copyright in the software and shall 67783SGiacomo.Gabrielli@arm.com * not be construed as granting a license to any other intellectual 77783SGiacomo.Gabrielli@arm.com * property including but not limited to intellectual property relating 87783SGiacomo.Gabrielli@arm.com * to a hardware implementation of the functionality of the software 97783SGiacomo.Gabrielli@arm.com * licensed hereunder. You may use the software subject to the license 107783SGiacomo.Gabrielli@arm.com * terms below provided that you ensure that this notice is replicated 117783SGiacomo.Gabrielli@arm.com * unmodified and in its entirety in all distributions of the software, 127783SGiacomo.Gabrielli@arm.com * modified or unmodified, in source code or in binary form. 137783SGiacomo.Gabrielli@arm.com * 142316SN/A * Copyright (c) 2004-2006 The Regents of The University of Michigan 151689SN/A * All rights reserved. 161689SN/A * 171689SN/A * Redistribution and use in source and binary forms, with or without 181689SN/A * modification, are permitted provided that the following conditions are 191689SN/A * met: redistributions of source code must retain the above copyright 201689SN/A * notice, this list of conditions and the following disclaimer; 211689SN/A * redistributions in binary form must reproduce the above copyright 221689SN/A * notice, this list of conditions and the following disclaimer in the 231689SN/A * documentation and/or other materials provided with the distribution; 241689SN/A * neither the name of the copyright holders nor the names of its 251689SN/A * contributors may be used to endorse or promote products derived from 261689SN/A * this software without specific prior written permission. 271689SN/A * 281689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 291689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 301689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 311689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 321689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 331689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 341689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 351689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 361689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 371689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 381689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392665SN/A * 402665SN/A * Authors: Kevin Lim 411689SN/A */ 421061SN/A 435953Ssaidi@eecs.umich.edu#include "base/cp_annotate.hh" 445596Sgblack@eecs.umich.edu#include "cpu/o3/dyn_inst.hh" 458779Sgblack@eecs.umich.edu#include "sim/full_system.hh" 469252Sdjordje.kovacevic@arm.com#include "debug/O3PipeView.hh" 471061SN/A 481061SN/Atemplate <class Impl> 495596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::BaseO3DynInst(StaticInstPtr staticInst, 508502Sgblack@eecs.umich.edu StaticInstPtr macroop, 517720Sgblack@eecs.umich.edu TheISA::PCState pc, TheISA::PCState predPC, 525596Sgblack@eecs.umich.edu InstSeqNum seq_num, O3CPU *cpu) 538502Sgblack@eecs.umich.edu : BaseDynInst<Impl>(staticInst, macroop, pc, predPC, seq_num, cpu) 544637SN/A{ 554637SN/A initVars(); 564637SN/A} 574637SN/A 584637SN/Atemplate <class Impl> 598502Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::BaseO3DynInst(StaticInstPtr _staticInst, 608502Sgblack@eecs.umich.edu StaticInstPtr _macroop) 618502Sgblack@eecs.umich.edu : BaseDynInst<Impl>(_staticInst, _macroop) 621061SN/A{ 632292SN/A initVars(); 642292SN/A} 652292SN/A 669252Sdjordje.kovacevic@arm.comtemplate <class Impl>BaseO3DynInst<Impl>::~BaseO3DynInst() 679252Sdjordje.kovacevic@arm.com{ 689252Sdjordje.kovacevic@arm.com#if TRACING_ON 699252Sdjordje.kovacevic@arm.com Tick val, fetch = this->fetchTick; 709252Sdjordje.kovacevic@arm.com // Print info needed by the pipeline activity viewer. 719252Sdjordje.kovacevic@arm.com DPRINTFR(O3PipeView, "O3PipeView:fetch:%llu:0x%08llx:%d:%llu:%s\n", 729252Sdjordje.kovacevic@arm.com fetch, 739252Sdjordje.kovacevic@arm.com this->instAddr(), 749252Sdjordje.kovacevic@arm.com this->microPC(), 759252Sdjordje.kovacevic@arm.com this->seqNum, 769252Sdjordje.kovacevic@arm.com this->staticInst->disassemble(this->instAddr())); 779252Sdjordje.kovacevic@arm.com val = (this->decodeTick == -1) ? 0 : fetch + this->decodeTick; 789252Sdjordje.kovacevic@arm.com DPRINTFR(O3PipeView, "O3PipeView:decode:%llu\n", val); 799252Sdjordje.kovacevic@arm.com val = (this->renameTick == -1) ? 0 : fetch + this->renameTick; 809252Sdjordje.kovacevic@arm.com DPRINTFR(O3PipeView, "O3PipeView:rename:%llu\n", val); 819252Sdjordje.kovacevic@arm.com val = (this->dispatchTick == -1) ? 0 : fetch + this->dispatchTick; 829252Sdjordje.kovacevic@arm.com DPRINTFR(O3PipeView, "O3PipeView:dispatch:%llu\n", val); 839252Sdjordje.kovacevic@arm.com val = (this->issueTick == -1) ? 0 : fetch + this->issueTick; 849252Sdjordje.kovacevic@arm.com DPRINTFR(O3PipeView, "O3PipeView:issue:%llu\n", val); 859252Sdjordje.kovacevic@arm.com val = (this->completeTick == -1) ? 0 : fetch + this->completeTick; 869252Sdjordje.kovacevic@arm.com DPRINTFR(O3PipeView, "O3PipeView:complete:%llu\n", val); 879252Sdjordje.kovacevic@arm.com val = (this->commitTick == -1) ? 0 : fetch + this->commitTick; 889252Sdjordje.kovacevic@arm.com DPRINTFR(O3PipeView, "O3PipeView:retire:%llu\n", val); 899252Sdjordje.kovacevic@arm.com#endif 909252Sdjordje.kovacevic@arm.com}; 919252Sdjordje.kovacevic@arm.com 929252Sdjordje.kovacevic@arm.com 932292SN/Atemplate <class Impl> 942292SN/Avoid 955596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::initVars() 962292SN/A{ 971464SN/A // Make sure to have the renamed register entries set to the same 981464SN/A // as the normal register entries. It will allow the IQ to work 991464SN/A // without any modifications. 1002292SN/A for (int i = 0; i < this->staticInst->numDestRegs(); i++) { 1013782SN/A this->_destRegIdx[i] = this->staticInst->destRegIdx(i); 1021464SN/A } 1031464SN/A 1042292SN/A for (int i = 0; i < this->staticInst->numSrcRegs(); i++) { 1053782SN/A this->_srcRegIdx[i] = this->staticInst->srcRegIdx(i); 1061464SN/A } 1077783SGiacomo.Gabrielli@arm.com 1089046SAli.Saidi@ARM.com this->_readySrcRegIdx.reset(); 1099046SAli.Saidi@ARM.com 1107783SGiacomo.Gabrielli@arm.com _numDestMiscRegs = 0; 1118471SGiacomo.Gabrielli@arm.com 1128471SGiacomo.Gabrielli@arm.com#if TRACING_ON 1139252Sdjordje.kovacevic@arm.com // Value -1 indicates that particular phase 1149252Sdjordje.kovacevic@arm.com // hasn't happened (yet). 1159252Sdjordje.kovacevic@arm.com fetchTick = -1; 1169252Sdjordje.kovacevic@arm.com decodeTick = -1; 1179252Sdjordje.kovacevic@arm.com renameTick = -1; 1189252Sdjordje.kovacevic@arm.com dispatchTick = -1; 1199252Sdjordje.kovacevic@arm.com issueTick = -1; 1209252Sdjordje.kovacevic@arm.com completeTick = -1; 1219252Sdjordje.kovacevic@arm.com commitTick = -1; 1228471SGiacomo.Gabrielli@arm.com#endif 1231061SN/A} 1241061SN/A 1252292SN/Atemplate <class Impl> 1262292SN/AFault 1275596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::execute() 1282292SN/A{ 1292348SN/A // @todo: Pretty convoluted way to avoid squashing from happening 1302680SN/A // when using the TC during an instruction's execution 1312348SN/A // (specifically for instructions that have side-effects that use 1322680SN/A // the TC). Fix this. 1339382SAli.Saidi@ARM.com bool no_squash_from_TC = this->thread->noSquashFromTC; 1349382SAli.Saidi@ARM.com this->thread->noSquashFromTC = true; 1352292SN/A 1362292SN/A this->fault = this->staticInst->execute(this, this->traceData); 1372292SN/A 1389382SAli.Saidi@ARM.com this->thread->noSquashFromTC = no_squash_from_TC; 1392292SN/A 1402292SN/A return this->fault; 1412292SN/A} 1422292SN/A 1432292SN/Atemplate <class Impl> 1442292SN/AFault 1455596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::initiateAcc() 1462292SN/A{ 1472348SN/A // @todo: Pretty convoluted way to avoid squashing from happening 1482680SN/A // when using the TC during an instruction's execution 1492348SN/A // (specifically for instructions that have side-effects that use 1502680SN/A // the TC). Fix this. 1519382SAli.Saidi@ARM.com bool no_squash_from_TC = this->thread->noSquashFromTC; 1529382SAli.Saidi@ARM.com this->thread->noSquashFromTC = true; 1532292SN/A 1542292SN/A this->fault = this->staticInst->initiateAcc(this, this->traceData); 1552292SN/A 1569382SAli.Saidi@ARM.com this->thread->noSquashFromTC = no_squash_from_TC; 1572292SN/A 1582292SN/A return this->fault; 1592292SN/A} 1602292SN/A 1612292SN/Atemplate <class Impl> 1622292SN/AFault 1635596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::completeAcc(PacketPtr pkt) 1642292SN/A{ 1657758Sminkyu.jeong@arm.com // @todo: Pretty convoluted way to avoid squashing from happening 1667758Sminkyu.jeong@arm.com // when using the TC during an instruction's execution 1677758Sminkyu.jeong@arm.com // (specifically for instructions that have side-effects that use 1687758Sminkyu.jeong@arm.com // the TC). Fix this. 1699382SAli.Saidi@ARM.com bool no_squash_from_TC = this->thread->noSquashFromTC; 1709382SAli.Saidi@ARM.com this->thread->noSquashFromTC = true; 1717758Sminkyu.jeong@arm.com 1728887Sgeoffrey.blake@arm.com if (this->cpu->checker) { 1738887Sgeoffrey.blake@arm.com if (this->isStoreConditional()) { 1748887Sgeoffrey.blake@arm.com this->reqToVerify->setExtraData(pkt->req->getExtraData()); 1758887Sgeoffrey.blake@arm.com } 1768733Sgeoffrey.blake@arm.com } 1778887Sgeoffrey.blake@arm.com 1782790SN/A this->fault = this->staticInst->completeAcc(pkt, this, this->traceData); 1792292SN/A 1809382SAli.Saidi@ARM.com this->thread->noSquashFromTC = no_squash_from_TC; 1817758Sminkyu.jeong@arm.com 1822292SN/A return this->fault; 1832292SN/A} 1842292SN/A 1851061SN/Atemplate <class Impl> 1865702Ssaidi@eecs.umich.eduFault 1875702Ssaidi@eecs.umich.eduBaseO3DynInst<Impl>::hwrei() 1885702Ssaidi@eecs.umich.edu{ 1895702Ssaidi@eecs.umich.edu#if THE_ISA == ALPHA_ISA 1905702Ssaidi@eecs.umich.edu // Can only do a hwrei when in pal mode. 1917720Sgblack@eecs.umich.edu if (!(this->instAddr() & 0x3)) 1925702Ssaidi@eecs.umich.edu return new AlphaISA::UnimplementedOpcodeFault; 1935702Ssaidi@eecs.umich.edu 1945702Ssaidi@eecs.umich.edu // Set the next PC based on the value of the EXC_ADDR IPR. 1957720Sgblack@eecs.umich.edu AlphaISA::PCState pc = this->pcState(); 1967720Sgblack@eecs.umich.edu pc.npc(this->cpu->readMiscRegNoEffect(AlphaISA::IPR_EXC_ADDR, 1977720Sgblack@eecs.umich.edu this->threadNumber)); 1987720Sgblack@eecs.umich.edu this->pcState(pc); 1995953Ssaidi@eecs.umich.edu if (CPA::available()) { 2005953Ssaidi@eecs.umich.edu ThreadContext *tc = this->cpu->tcBase(this->threadNumber); 2017720Sgblack@eecs.umich.edu CPA::cpa()->swAutoBegin(tc, this->nextInstAddr()); 2025953Ssaidi@eecs.umich.edu } 2035702Ssaidi@eecs.umich.edu 2045702Ssaidi@eecs.umich.edu // Tell CPU to clear any state it needs to if a hwrei is taken. 2055702Ssaidi@eecs.umich.edu this->cpu->hwrei(this->threadNumber); 2065702Ssaidi@eecs.umich.edu#else 2075702Ssaidi@eecs.umich.edu 2085702Ssaidi@eecs.umich.edu#endif 2095702Ssaidi@eecs.umich.edu // FIXME: XXX check for interrupts? XXX 2105702Ssaidi@eecs.umich.edu return NoFault; 2115702Ssaidi@eecs.umich.edu} 2125702Ssaidi@eecs.umich.edu 2135702Ssaidi@eecs.umich.edutemplate <class Impl> 2141061SN/Avoid 2155596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::trap(Fault fault) 2161061SN/A{ 2177684Sgblack@eecs.umich.edu this->cpu->trap(fault, this->threadNumber, this->staticInst); 2181061SN/A} 2195702Ssaidi@eecs.umich.edu 2205702Ssaidi@eecs.umich.edutemplate <class Impl> 2215702Ssaidi@eecs.umich.edubool 2225702Ssaidi@eecs.umich.eduBaseO3DynInst<Impl>::simPalCheck(int palFunc) 2235702Ssaidi@eecs.umich.edu{ 2245702Ssaidi@eecs.umich.edu#if THE_ISA != ALPHA_ISA 2255702Ssaidi@eecs.umich.edu panic("simPalCheck called, but PAL only exists in Alpha!\n"); 2265702Ssaidi@eecs.umich.edu#endif 2275702Ssaidi@eecs.umich.edu return this->cpu->simPalCheck(palFunc, this->threadNumber); 2285702Ssaidi@eecs.umich.edu} 2298557Sgblack@eecs.umich.edu 2301061SN/Atemplate <class Impl> 2311061SN/Avoid 2325596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::syscall(int64_t callnum) 2331061SN/A{ 2348806Sgblack@eecs.umich.edu if (FullSystem) 2358779Sgblack@eecs.umich.edu panic("Syscall emulation isn't available in FS mode.\n"); 2368806Sgblack@eecs.umich.edu 2375556SN/A // HACK: check CPU's nextPC before and after syscall. If it 2385556SN/A // changes, update this instruction's nextPC because the syscall 2395556SN/A // must have changed the nextPC. 2407720Sgblack@eecs.umich.edu TheISA::PCState curPC = this->cpu->pcState(this->threadNumber); 2412669SN/A this->cpu->syscall(callnum, this->threadNumber); 2427720Sgblack@eecs.umich.edu TheISA::PCState newPC = this->cpu->pcState(this->threadNumber); 2437720Sgblack@eecs.umich.edu if (!(curPC == newPC)) { 2447720Sgblack@eecs.umich.edu this->pcState(newPC); 2455556SN/A } 2461061SN/A} 2471061SN/A 248