dyn_inst_impl.hh revision 2680
16129Snate@binkert.org/*
26129Snate@binkert.org * Copyright (c) 2004-2006 The Regents of The University of Michigan
36129Snate@binkert.org * All rights reserved.
46129Snate@binkert.org *
56129Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66129Snate@binkert.org * modification, are permitted provided that the following conditions are
76129Snate@binkert.org * met: redistributions of source code must retain the above copyright
86129Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96129Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106129Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116129Snate@binkert.org * documentation and/or other materials provided with the distribution;
126129Snate@binkert.org * neither the name of the copyright holders nor the names of its
136129Snate@binkert.org * contributors may be used to endorse or promote products derived from
146129Snate@binkert.org * this software without specific prior written permission.
156129Snate@binkert.org *
166129Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176129Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186129Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196129Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206129Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216129Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226129Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236129Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246129Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256129Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266129Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276129Snate@binkert.org *
286129Snate@binkert.org * Authors: Kevin Lim
296129Snate@binkert.org */
306129Snate@binkert.org
316169Snate@binkert.org#include "cpu/o3/alpha_dyn_inst.hh"
326169Snate@binkert.org
336169Snate@binkert.orgtemplate <class Impl>
348229Snate@binkert.orgAlphaDynInst<Impl>::AlphaDynInst(ExtMachInst inst, Addr PC, Addr Pred_PC,
356130Snate@binkert.org                                 InstSeqNum seq_num, FullCPU *cpu)
366129Snate@binkert.org    : BaseDynInst<Impl>(inst, PC, Pred_PC, seq_num, cpu)
376129Snate@binkert.org{
386129Snate@binkert.org    initVars();
3914266Sandreas.sandberg@arm.com}
4014266Sandreas.sandberg@arm.com
416130Snate@binkert.orgtemplate <class Impl>
426130Snate@binkert.orgAlphaDynInst<Impl>::AlphaDynInst(StaticInstPtr &_staticInst)
436130Snate@binkert.org    : BaseDynInst<Impl>(_staticInst)
446130Snate@binkert.org{
456130Snate@binkert.org    initVars();
466130Snate@binkert.org}
476130Snate@binkert.org
486130Snate@binkert.orgtemplate <class Impl>
497462Snate@binkert.orgvoid
506130Snate@binkert.orgAlphaDynInst<Impl>::initVars()
516130Snate@binkert.org{
526130Snate@binkert.org    // Make sure to have the renamed register entries set to the same
536130Snate@binkert.org    // as the normal register entries.  It will allow the IQ to work
546130Snate@binkert.org    // without any modifications.
556130Snate@binkert.org    for (int i = 0; i < this->staticInst->numDestRegs(); i++) {
566130Snate@binkert.org        _destRegIdx[i] = this->staticInst->destRegIdx(i);
576130Snate@binkert.org    }
586130Snate@binkert.org
596130Snate@binkert.org    for (int i = 0; i < this->staticInst->numSrcRegs(); i++) {
606130Snate@binkert.org        _srcRegIdx[i] = this->staticInst->srcRegIdx(i);
616130Snate@binkert.org        this->_readySrcRegIdx[i] = 0;
629743Snilay@cs.wisc.edu    }
639743Snilay@cs.wisc.edu}
646130Snate@binkert.org
656130Snate@binkert.orgtemplate <class Impl>
667462Snate@binkert.orgFault
676130Snate@binkert.orgAlphaDynInst<Impl>::execute()
687505Snate@binkert.org{
698296Snate@binkert.org    // @todo: Pretty convoluted way to avoid squashing from happening
706129Snate@binkert.org    // when using the TC during an instruction's execution
716129Snate@binkert.org    // (specifically for instructions that have side-effects that use
726129Snate@binkert.org    // the TC).  Fix this.
736129Snate@binkert.org    bool in_syscall = this->thread->inSyscall;
746129Snate@binkert.org    this->thread->inSyscall = true;
756129Snate@binkert.org
768243Sbradley.danofsky@amd.com    this->fault = this->staticInst->execute(this, this->traceData);
778243Sbradley.danofsky@amd.com
786129Snate@binkert.org    this->thread->inSyscall = in_syscall;
796129Snate@binkert.org
806129Snate@binkert.org    return this->fault;
816130Snate@binkert.org}
826129Snate@binkert.org
836129Snate@binkert.orgtemplate <class Impl>
846129Snate@binkert.orgFault
856129Snate@binkert.orgAlphaDynInst<Impl>::initiateAcc()
866129Snate@binkert.org{
876129Snate@binkert.org    // @todo: Pretty convoluted way to avoid squashing from happening
886129Snate@binkert.org    // when using the TC during an instruction's execution
896129Snate@binkert.org    // (specifically for instructions that have side-effects that use
906129Snate@binkert.org    // the TC).  Fix this.
916129Snate@binkert.org    bool in_syscall = this->thread->inSyscall;
926129Snate@binkert.org    this->thread->inSyscall = true;
936129Snate@binkert.org
946129Snate@binkert.org    this->fault = this->staticInst->initiateAcc(this, this->traceData);
956129Snate@binkert.org
966129Snate@binkert.org    this->thread->inSyscall = in_syscall;
976129Snate@binkert.org
986129Snate@binkert.org    return this->fault;
996129Snate@binkert.org}
1006129Snate@binkert.org
1016129Snate@binkert.orgtemplate <class Impl>
10214266Sandreas.sandberg@arm.comFault
1038243Sbradley.danofsky@amd.comAlphaDynInst<Impl>::completeAcc(Packet *pkt)
1046129Snate@binkert.org{
1056129Snate@binkert.org    if (this->isLoad()) {
1066129Snate@binkert.org        this->fault = this->staticInst->completeAcc(pkt, this,
1076129Snate@binkert.org                                                    this->traceData);
1086129Snate@binkert.org    } else if (this->isStore()) {
1096129Snate@binkert.org        this->fault = this->staticInst->completeAcc(pkt, this,
1106129Snate@binkert.org                                                    this->traceData);
1116129Snate@binkert.org    } else {
1126129Snate@binkert.org        panic("Unknown type!");
1136129Snate@binkert.org    }
1146129Snate@binkert.org
1156129Snate@binkert.org    return this->fault;
1166129Snate@binkert.org}
1176129Snate@binkert.org
1186129Snate@binkert.org#if FULL_SYSTEM
1196129Snate@binkert.orgtemplate <class Impl>
1206129Snate@binkert.orgFault
1216129Snate@binkert.orgAlphaDynInst<Impl>::hwrei()
1226129Snate@binkert.org{
1236129Snate@binkert.org    // Can only do a hwrei when in pal mode.
1246129Snate@binkert.org    if (!this->cpu->inPalMode(this->readPC()))
1256129Snate@binkert.org        return new AlphaISA::UnimplementedOpcodeFault;
1266129Snate@binkert.org
1276129Snate@binkert.org    // Set the next PC based on the value of the EXC_ADDR IPR.
1286129Snate@binkert.org    this->setNextPC(this->cpu->readMiscReg(AlphaISA::IPR_EXC_ADDR,
1296129Snate@binkert.org                                           this->threadNumber));
1306129Snate@binkert.org
1316129Snate@binkert.org    // Tell CPU to clear any state it needs to if a hwrei is taken.
1326129Snate@binkert.org    this->cpu->hwrei(this->threadNumber);
1336129Snate@binkert.org
1346129Snate@binkert.org    // FIXME: XXX check for interrupts? XXX
1356129Snate@binkert.org    return NoFault;
1366129Snate@binkert.org}
1378296Snate@binkert.org
1386129Snate@binkert.orgtemplate <class Impl>
1396129Snate@binkert.orgint
1406129Snate@binkert.orgAlphaDynInst<Impl>::readIntrFlag()
1416129Snate@binkert.org{
1426129Snate@binkert.org    return this->cpu->readIntrFlag();
1436129Snate@binkert.org}
1446129Snate@binkert.org
1456129Snate@binkert.orgtemplate <class Impl>
1466129Snate@binkert.orgvoid
1476129Snate@binkert.orgAlphaDynInst<Impl>::setIntrFlag(int val)
1486129Snate@binkert.org{
1496129Snate@binkert.org    this->cpu->setIntrFlag(val);
1506129Snate@binkert.org}
1516129Snate@binkert.org
1526129Snate@binkert.orgtemplate <class Impl>
1536129Snate@binkert.orgbool
1546129Snate@binkert.orgAlphaDynInst<Impl>::inPalMode()
1556129Snate@binkert.org{
1566129Snate@binkert.org    return this->cpu->inPalMode(this->PC);
1576129Snate@binkert.org}
1586129Snate@binkert.org
1596129Snate@binkert.orgtemplate <class Impl>
1606129Snate@binkert.orgvoid
1616129Snate@binkert.orgAlphaDynInst<Impl>::trap(Fault fault)
1626129Snate@binkert.org{
1636129Snate@binkert.org    this->cpu->trap(fault, this->threadNumber);
1646129Snate@binkert.org}
1656129Snate@binkert.org
1666129Snate@binkert.orgtemplate <class Impl>
1676129Snate@binkert.orgbool
1686129Snate@binkert.orgAlphaDynInst<Impl>::simPalCheck(int palFunc)
1696129Snate@binkert.org{
1706129Snate@binkert.org    return this->cpu->simPalCheck(palFunc, this->threadNumber);
1716129Snate@binkert.org}
1726129Snate@binkert.org#else
1736129Snate@binkert.orgtemplate <class Impl>
1746129Snate@binkert.orgvoid
1757831Snate@binkert.orgAlphaDynInst<Impl>::syscall(int64_t callnum)
1767505Snate@binkert.org{
1776129Snate@binkert.org    this->cpu->syscall(callnum, this->threadNumber);
1786129Snate@binkert.org}
1797505Snate@binkert.org#endif
1807505Snate@binkert.org
1817505Snate@binkert.org