dyn_inst_impl.hh revision 5702
11689SN/A/* 22316SN/A * Copyright (c) 2004-2006 The Regents of The University of Michigan 31689SN/A * All rights reserved. 41689SN/A * 51689SN/A * Redistribution and use in source and binary forms, with or without 61689SN/A * modification, are permitted provided that the following conditions are 71689SN/A * met: redistributions of source code must retain the above copyright 81689SN/A * notice, this list of conditions and the following disclaimer; 91689SN/A * redistributions in binary form must reproduce the above copyright 101689SN/A * notice, this list of conditions and the following disclaimer in the 111689SN/A * documentation and/or other materials provided with the distribution; 121689SN/A * neither the name of the copyright holders nor the names of its 131689SN/A * contributors may be used to endorse or promote products derived from 141689SN/A * this software without specific prior written permission. 151689SN/A * 161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A * 282665SN/A * Authors: Kevin Lim 291689SN/A */ 301061SN/A 315596Sgblack@eecs.umich.edu#include "cpu/o3/dyn_inst.hh" 321061SN/A 331061SN/Atemplate <class Impl> 345596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::BaseO3DynInst(StaticInstPtr staticInst, 355596Sgblack@eecs.umich.edu Addr PC, Addr NPC, Addr microPC, 365596Sgblack@eecs.umich.edu Addr Pred_PC, Addr Pred_NPC, 375596Sgblack@eecs.umich.edu Addr Pred_MicroPC, 385596Sgblack@eecs.umich.edu InstSeqNum seq_num, O3CPU *cpu) 394637SN/A : BaseDynInst<Impl>(staticInst, PC, NPC, microPC, 405596Sgblack@eecs.umich.edu Pred_PC, Pred_NPC, Pred_MicroPC, seq_num, cpu) 414637SN/A{ 424637SN/A initVars(); 434637SN/A} 444637SN/A 454637SN/Atemplate <class Impl> 465596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::BaseO3DynInst(ExtMachInst inst, 475596Sgblack@eecs.umich.edu Addr PC, Addr NPC, Addr microPC, 485596Sgblack@eecs.umich.edu Addr Pred_PC, Addr Pred_NPC, 495596Sgblack@eecs.umich.edu Addr Pred_MicroPC, 505596Sgblack@eecs.umich.edu InstSeqNum seq_num, O3CPU *cpu) 514637SN/A : BaseDynInst<Impl>(inst, PC, NPC, microPC, 525596Sgblack@eecs.umich.edu Pred_PC, Pred_NPC, Pred_MicroPC, seq_num, cpu) 531061SN/A{ 542292SN/A initVars(); 551061SN/A} 561061SN/A 571061SN/Atemplate <class Impl> 585596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::BaseO3DynInst(StaticInstPtr &_staticInst) 591464SN/A : BaseDynInst<Impl>(_staticInst) 601061SN/A{ 612292SN/A initVars(); 622292SN/A} 632292SN/A 642292SN/Atemplate <class Impl> 652292SN/Avoid 665596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::initVars() 672292SN/A{ 681464SN/A // Make sure to have the renamed register entries set to the same 691464SN/A // as the normal register entries. It will allow the IQ to work 701464SN/A // without any modifications. 712292SN/A for (int i = 0; i < this->staticInst->numDestRegs(); i++) { 723782SN/A this->_destRegIdx[i] = this->staticInst->destRegIdx(i); 731464SN/A } 741464SN/A 752292SN/A for (int i = 0; i < this->staticInst->numSrcRegs(); i++) { 763782SN/A this->_srcRegIdx[i] = this->staticInst->srcRegIdx(i); 772292SN/A this->_readySrcRegIdx[i] = 0; 781464SN/A } 791061SN/A} 801061SN/A 812292SN/Atemplate <class Impl> 822292SN/AFault 835596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::execute() 842292SN/A{ 852348SN/A // @todo: Pretty convoluted way to avoid squashing from happening 862680SN/A // when using the TC during an instruction's execution 872348SN/A // (specifically for instructions that have side-effects that use 882680SN/A // the TC). Fix this. 892292SN/A bool in_syscall = this->thread->inSyscall; 902292SN/A this->thread->inSyscall = true; 912292SN/A 922292SN/A this->fault = this->staticInst->execute(this, this->traceData); 932292SN/A 942292SN/A this->thread->inSyscall = in_syscall; 952292SN/A 962292SN/A return this->fault; 972292SN/A} 982292SN/A 992292SN/Atemplate <class Impl> 1002292SN/AFault 1015596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::initiateAcc() 1022292SN/A{ 1032348SN/A // @todo: Pretty convoluted way to avoid squashing from happening 1042680SN/A // when using the TC during an instruction's execution 1052348SN/A // (specifically for instructions that have side-effects that use 1062680SN/A // the TC). Fix this. 1072292SN/A bool in_syscall = this->thread->inSyscall; 1082292SN/A this->thread->inSyscall = true; 1092292SN/A 1102292SN/A this->fault = this->staticInst->initiateAcc(this, this->traceData); 1112292SN/A 1122292SN/A this->thread->inSyscall = in_syscall; 1132292SN/A 1142292SN/A return this->fault; 1152292SN/A} 1162292SN/A 1172292SN/Atemplate <class Impl> 1182292SN/AFault 1195596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::completeAcc(PacketPtr pkt) 1202292SN/A{ 1212790SN/A this->fault = this->staticInst->completeAcc(pkt, this, this->traceData); 1222292SN/A 1232292SN/A return this->fault; 1242292SN/A} 1252292SN/A 1261858SN/A#if FULL_SYSTEM 1271061SN/Atemplate <class Impl> 1285702Ssaidi@eecs.umich.eduFault 1295702Ssaidi@eecs.umich.eduBaseO3DynInst<Impl>::hwrei() 1305702Ssaidi@eecs.umich.edu{ 1315702Ssaidi@eecs.umich.edu#if THE_ISA == ALPHA_ISA 1325702Ssaidi@eecs.umich.edu // Can only do a hwrei when in pal mode. 1335702Ssaidi@eecs.umich.edu if (!(this->readPC() & 0x3)) 1345702Ssaidi@eecs.umich.edu return new AlphaISA::UnimplementedOpcodeFault; 1355702Ssaidi@eecs.umich.edu 1365702Ssaidi@eecs.umich.edu // Set the next PC based on the value of the EXC_ADDR IPR. 1375702Ssaidi@eecs.umich.edu this->setNextPC(this->cpu->readMiscRegNoEffect(AlphaISA::IPR_EXC_ADDR, 1385702Ssaidi@eecs.umich.edu this->threadNumber)); 1395702Ssaidi@eecs.umich.edu 1405702Ssaidi@eecs.umich.edu // Tell CPU to clear any state it needs to if a hwrei is taken. 1415702Ssaidi@eecs.umich.edu this->cpu->hwrei(this->threadNumber); 1425702Ssaidi@eecs.umich.edu#else 1435702Ssaidi@eecs.umich.edu 1445702Ssaidi@eecs.umich.edu#endif 1455702Ssaidi@eecs.umich.edu // FIXME: XXX check for interrupts? XXX 1465702Ssaidi@eecs.umich.edu return NoFault; 1475702Ssaidi@eecs.umich.edu} 1485702Ssaidi@eecs.umich.edu 1495702Ssaidi@eecs.umich.edutemplate <class Impl> 1501061SN/Avoid 1515596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::trap(Fault fault) 1521061SN/A{ 1532292SN/A this->cpu->trap(fault, this->threadNumber); 1541061SN/A} 1555702Ssaidi@eecs.umich.edu 1565702Ssaidi@eecs.umich.edutemplate <class Impl> 1575702Ssaidi@eecs.umich.edubool 1585702Ssaidi@eecs.umich.eduBaseO3DynInst<Impl>::simPalCheck(int palFunc) 1595702Ssaidi@eecs.umich.edu{ 1605702Ssaidi@eecs.umich.edu#if THE_ISA != ALPHA_ISA 1615702Ssaidi@eecs.umich.edu panic("simPalCheck called, but PAL only exists in Alpha!\n"); 1625702Ssaidi@eecs.umich.edu#endif 1635702Ssaidi@eecs.umich.edu return this->cpu->simPalCheck(palFunc, this->threadNumber); 1645702Ssaidi@eecs.umich.edu} 1651061SN/A#else 1661061SN/Atemplate <class Impl> 1671061SN/Avoid 1685596Sgblack@eecs.umich.eduBaseO3DynInst<Impl>::syscall(int64_t callnum) 1691061SN/A{ 1705556SN/A // HACK: check CPU's nextPC before and after syscall. If it 1715556SN/A // changes, update this instruction's nextPC because the syscall 1725556SN/A // must have changed the nextPC. 1735556SN/A Addr cpu_next_pc = this->cpu->readNextPC(this->threadNumber); 1742669SN/A this->cpu->syscall(callnum, this->threadNumber); 1755556SN/A Addr new_next_pc = this->cpu->readNextPC(this->threadNumber); 1765556SN/A if (cpu_next_pc != new_next_pc) { 1775556SN/A this->setNextPC(new_next_pc); 1785556SN/A } 1791061SN/A} 1801061SN/A#endif 1811061SN/A 182