lsq_unit_impl.hh revision 9383
12292SN/A/* 29383SAli.Saidi@ARM.com * Copyright (c) 2010-2012 ARM Limited 37597Sminkyu.jeong@arm.com * All rights reserved 47597Sminkyu.jeong@arm.com * 57597Sminkyu.jeong@arm.com * The license below extends only to copyright in the software and shall 67597Sminkyu.jeong@arm.com * not be construed as granting a license to any other intellectual 77597Sminkyu.jeong@arm.com * property including but not limited to intellectual property relating 87597Sminkyu.jeong@arm.com * to a hardware implementation of the functionality of the software 97597Sminkyu.jeong@arm.com * licensed hereunder. You may use the software subject to the license 107597Sminkyu.jeong@arm.com * terms below provided that you ensure that this notice is replicated 117597Sminkyu.jeong@arm.com * unmodified and in its entirety in all distributions of the software, 127597Sminkyu.jeong@arm.com * modified or unmodified, in source code or in binary form. 137597Sminkyu.jeong@arm.com * 142292SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan 152292SN/A * All rights reserved. 162292SN/A * 172292SN/A * Redistribution and use in source and binary forms, with or without 182292SN/A * modification, are permitted provided that the following conditions are 192292SN/A * met: redistributions of source code must retain the above copyright 202292SN/A * notice, this list of conditions and the following disclaimer; 212292SN/A * redistributions in binary form must reproduce the above copyright 222292SN/A * notice, this list of conditions and the following disclaimer in the 232292SN/A * documentation and/or other materials provided with the distribution; 242292SN/A * neither the name of the copyright holders nor the names of its 252292SN/A * contributors may be used to endorse or promote products derived from 262292SN/A * this software without specific prior written permission. 272292SN/A * 282292SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292292SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302292SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312292SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322292SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332292SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342292SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 352292SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362292SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372292SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382292SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392689Sktlim@umich.edu * 402689Sktlim@umich.edu * Authors: Kevin Lim 412689Sktlim@umich.edu * Korey Sewell 422292SN/A */ 432292SN/A 448591Sgblack@eecs.umich.edu#include "arch/generic/debugfaults.hh" 453326Sktlim@umich.edu#include "arch/locked_mem.hh" 468229Snate@binkert.org#include "base/str.hh" 476658Snate@binkert.org#include "config/the_isa.hh" 488887Sgeoffrey.blake@arm.com#include "cpu/checker/cpu.hh" 492907Sktlim@umich.edu#include "cpu/o3/lsq.hh" 502292SN/A#include "cpu/o3/lsq_unit.hh" 518232Snate@binkert.org#include "debug/Activity.hh" 528232Snate@binkert.org#include "debug/IEW.hh" 538232Snate@binkert.org#include "debug/LSQUnit.hh" 542722Sktlim@umich.edu#include "mem/packet.hh" 552669Sktlim@umich.edu#include "mem/request.hh" 562292SN/A 572669Sktlim@umich.edutemplate<class Impl> 582678Sktlim@umich.eduLSQUnit<Impl>::WritebackEvent::WritebackEvent(DynInstPtr &_inst, PacketPtr _pkt, 592678Sktlim@umich.edu LSQUnit *lsq_ptr) 608581Ssteve.reinhardt@amd.com : Event(Default_Pri, AutoDelete), 618581Ssteve.reinhardt@amd.com inst(_inst), pkt(_pkt), lsqPtr(lsq_ptr) 622292SN/A{ 632292SN/A} 642292SN/A 652669Sktlim@umich.edutemplate<class Impl> 662292SN/Avoid 672678Sktlim@umich.eduLSQUnit<Impl>::WritebackEvent::process() 682292SN/A{ 692678Sktlim@umich.edu if (!lsqPtr->isSwitchedOut()) { 702678Sktlim@umich.edu lsqPtr->writeback(inst, pkt); 712678Sktlim@umich.edu } 724319Sktlim@umich.edu 734319Sktlim@umich.edu if (pkt->senderState) 744319Sktlim@umich.edu delete pkt->senderState; 754319Sktlim@umich.edu 764319Sktlim@umich.edu delete pkt->req; 772678Sktlim@umich.edu delete pkt; 782678Sktlim@umich.edu} 792292SN/A 802678Sktlim@umich.edutemplate<class Impl> 812678Sktlim@umich.educonst char * 825336Shines@cs.fsu.eduLSQUnit<Impl>::WritebackEvent::description() const 832678Sktlim@umich.edu{ 844873Sstever@eecs.umich.edu return "Store writeback"; 852678Sktlim@umich.edu} 862292SN/A 872678Sktlim@umich.edutemplate<class Impl> 882678Sktlim@umich.eduvoid 892678Sktlim@umich.eduLSQUnit<Impl>::completeDataAccess(PacketPtr pkt) 902678Sktlim@umich.edu{ 912678Sktlim@umich.edu LSQSenderState *state = dynamic_cast<LSQSenderState *>(pkt->senderState); 922678Sktlim@umich.edu DynInstPtr inst = state->inst; 937852SMatt.Horsnell@arm.com DPRINTF(IEW, "Writeback event [sn:%lli].\n", inst->seqNum); 947852SMatt.Horsnell@arm.com DPRINTF(Activity, "Activity: Writeback event [sn:%lli].\n", inst->seqNum); 952344SN/A 962678Sktlim@umich.edu //iewStage->ldstQueue.removeMSHR(inst->threadNumber,inst->seqNum); 972678Sktlim@umich.edu 986974Stjones1@inf.ed.ac.uk // If this is a split access, wait until all packets are received. 996974Stjones1@inf.ed.ac.uk if (TheISA::HasUnalignedMemAcc && !state->complete()) { 1006974Stjones1@inf.ed.ac.uk delete pkt->req; 1016974Stjones1@inf.ed.ac.uk delete pkt; 1026974Stjones1@inf.ed.ac.uk return; 1036974Stjones1@inf.ed.ac.uk } 1046974Stjones1@inf.ed.ac.uk 1052678Sktlim@umich.edu if (isSwitchedOut() || inst->isSquashed()) { 1062820Sktlim@umich.edu iewStage->decrWb(inst->seqNum); 1072678Sktlim@umich.edu } else { 1082678Sktlim@umich.edu if (!state->noWB) { 1096974Stjones1@inf.ed.ac.uk if (!TheISA::HasUnalignedMemAcc || !state->isSplit || 1106974Stjones1@inf.ed.ac.uk !state->isLoad) { 1116974Stjones1@inf.ed.ac.uk writeback(inst, pkt); 1126974Stjones1@inf.ed.ac.uk } else { 1136974Stjones1@inf.ed.ac.uk writeback(inst, state->mainPkt); 1146974Stjones1@inf.ed.ac.uk } 1152678Sktlim@umich.edu } 1162678Sktlim@umich.edu 1172678Sktlim@umich.edu if (inst->isStore()) { 1182678Sktlim@umich.edu completeStore(state->idx); 1192678Sktlim@umich.edu } 1202344SN/A } 1212307SN/A 1226974Stjones1@inf.ed.ac.uk if (TheISA::HasUnalignedMemAcc && state->isSplit && state->isLoad) { 1236974Stjones1@inf.ed.ac.uk delete state->mainPkt->req; 1246974Stjones1@inf.ed.ac.uk delete state->mainPkt; 1256974Stjones1@inf.ed.ac.uk } 1262678Sktlim@umich.edu delete state; 1274032Sktlim@umich.edu delete pkt->req; 1282678Sktlim@umich.edu delete pkt; 1292292SN/A} 1302292SN/A 1312292SN/Atemplate <class Impl> 1322292SN/ALSQUnit<Impl>::LSQUnit() 1338545Ssaidi@eecs.umich.edu : loads(0), stores(0), storesToWB(0), cacheBlockMask(0), stalled(false), 1342678Sktlim@umich.edu isStoreBlocked(false), isLoadBlocked(false), 1358727Snilay@cs.wisc.edu loadBlockedHandled(false), storeInFlight(false), hasPendingPkt(false) 1362292SN/A{ 1372292SN/A} 1382292SN/A 1392292SN/Atemplate<class Impl> 1402292SN/Avoid 1415529Snate@binkert.orgLSQUnit<Impl>::init(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params, 1425529Snate@binkert.org LSQ *lsq_ptr, unsigned maxLQEntries, unsigned maxSQEntries, 1435529Snate@binkert.org unsigned id) 1442292SN/A{ 1454329Sktlim@umich.edu cpu = cpu_ptr; 1464329Sktlim@umich.edu iewStage = iew_ptr; 1474329Sktlim@umich.edu 1484329Sktlim@umich.edu DPRINTF(LSQUnit, "Creating LSQUnit%i object.\n",id); 1492292SN/A 1502307SN/A switchedOut = false; 1512307SN/A 1528545Ssaidi@eecs.umich.edu cacheBlockMask = 0; 1538545Ssaidi@eecs.umich.edu 1542907Sktlim@umich.edu lsq = lsq_ptr; 1552907Sktlim@umich.edu 1562292SN/A lsqID = id; 1572292SN/A 1582329SN/A // Add 1 for the sentinel entry (they are circular queues). 1592329SN/A LQEntries = maxLQEntries + 1; 1602329SN/A SQEntries = maxSQEntries + 1; 1612292SN/A 1622292SN/A loadQueue.resize(LQEntries); 1632292SN/A storeQueue.resize(SQEntries); 1642292SN/A 1658199SAli.Saidi@ARM.com depCheckShift = params->LSQDepCheckShift; 1668199SAli.Saidi@ARM.com checkLoads = params->LSQCheckLoads; 1678199SAli.Saidi@ARM.com 1682292SN/A loadHead = loadTail = 0; 1692292SN/A 1702292SN/A storeHead = storeWBIdx = storeTail = 0; 1712292SN/A 1722292SN/A usedPorts = 0; 1732292SN/A cachePorts = params->cachePorts; 1742292SN/A 1753492Sktlim@umich.edu retryPkt = NULL; 1762329SN/A memDepViolator = NULL; 1772292SN/A 1782292SN/A blockedLoadSeqNum = 0; 1798727Snilay@cs.wisc.edu needsTSO = params->needsTSO; 1802292SN/A} 1812292SN/A 1822292SN/Atemplate<class Impl> 1832292SN/Astd::string 1842292SN/ALSQUnit<Impl>::name() const 1852292SN/A{ 1862292SN/A if (Impl::MaxThreads == 1) { 1872292SN/A return iewStage->name() + ".lsq"; 1882292SN/A } else { 1898247Snate@binkert.org return iewStage->name() + ".lsq.thread" + to_string(lsqID); 1902292SN/A } 1912292SN/A} 1922292SN/A 1932292SN/Atemplate<class Impl> 1942292SN/Avoid 1952727Sktlim@umich.eduLSQUnit<Impl>::regStats() 1962727Sktlim@umich.edu{ 1972727Sktlim@umich.edu lsqForwLoads 1982727Sktlim@umich.edu .name(name() + ".forwLoads") 1992727Sktlim@umich.edu .desc("Number of loads that had data forwarded from stores"); 2002727Sktlim@umich.edu 2012727Sktlim@umich.edu invAddrLoads 2022727Sktlim@umich.edu .name(name() + ".invAddrLoads") 2032727Sktlim@umich.edu .desc("Number of loads ignored due to an invalid address"); 2042727Sktlim@umich.edu 2052727Sktlim@umich.edu lsqSquashedLoads 2062727Sktlim@umich.edu .name(name() + ".squashedLoads") 2072727Sktlim@umich.edu .desc("Number of loads squashed"); 2082727Sktlim@umich.edu 2092727Sktlim@umich.edu lsqIgnoredResponses 2102727Sktlim@umich.edu .name(name() + ".ignoredResponses") 2112727Sktlim@umich.edu .desc("Number of memory responses ignored because the instruction is squashed"); 2122727Sktlim@umich.edu 2132361SN/A lsqMemOrderViolation 2142361SN/A .name(name() + ".memOrderViolation") 2152361SN/A .desc("Number of memory ordering violations"); 2162361SN/A 2172727Sktlim@umich.edu lsqSquashedStores 2182727Sktlim@umich.edu .name(name() + ".squashedStores") 2192727Sktlim@umich.edu .desc("Number of stores squashed"); 2202727Sktlim@umich.edu 2212727Sktlim@umich.edu invAddrSwpfs 2222727Sktlim@umich.edu .name(name() + ".invAddrSwpfs") 2232727Sktlim@umich.edu .desc("Number of software prefetches ignored due to an invalid address"); 2242727Sktlim@umich.edu 2252727Sktlim@umich.edu lsqBlockedLoads 2262727Sktlim@umich.edu .name(name() + ".blockedLoads") 2272727Sktlim@umich.edu .desc("Number of blocked loads due to partial load-store forwarding"); 2282727Sktlim@umich.edu 2292727Sktlim@umich.edu lsqRescheduledLoads 2302727Sktlim@umich.edu .name(name() + ".rescheduledLoads") 2312727Sktlim@umich.edu .desc("Number of loads that were rescheduled"); 2322727Sktlim@umich.edu 2332727Sktlim@umich.edu lsqCacheBlocked 2342727Sktlim@umich.edu .name(name() + ".cacheBlocked") 2352727Sktlim@umich.edu .desc("Number of times an access to memory failed due to the cache being blocked"); 2362727Sktlim@umich.edu} 2372727Sktlim@umich.edu 2382727Sktlim@umich.edutemplate<class Impl> 2392727Sktlim@umich.eduvoid 2408922Swilliam.wang@arm.comLSQUnit<Impl>::setDcachePort(MasterPort *dcache_port) 2414329Sktlim@umich.edu{ 2424329Sktlim@umich.edu dcachePort = dcache_port; 2434329Sktlim@umich.edu} 2444329Sktlim@umich.edu 2454329Sktlim@umich.edutemplate<class Impl> 2464329Sktlim@umich.eduvoid 2472292SN/ALSQUnit<Impl>::clearLQ() 2482292SN/A{ 2492292SN/A loadQueue.clear(); 2502292SN/A} 2512292SN/A 2522292SN/Atemplate<class Impl> 2532292SN/Avoid 2542292SN/ALSQUnit<Impl>::clearSQ() 2552292SN/A{ 2562292SN/A storeQueue.clear(); 2572292SN/A} 2582292SN/A 2592292SN/Atemplate<class Impl> 2602292SN/Avoid 2612307SN/ALSQUnit<Impl>::switchOut() 2622307SN/A{ 2632307SN/A switchedOut = true; 2642367SN/A for (int i = 0; i < loadQueue.size(); ++i) { 2652367SN/A assert(!loadQueue[i]); 2662307SN/A loadQueue[i] = NULL; 2672367SN/A } 2682307SN/A 2692329SN/A assert(storesToWB == 0); 2702307SN/A} 2712307SN/A 2722307SN/Atemplate<class Impl> 2732307SN/Avoid 2742307SN/ALSQUnit<Impl>::takeOverFrom() 2752307SN/A{ 2762307SN/A switchedOut = false; 2772307SN/A loads = stores = storesToWB = 0; 2782307SN/A 2792307SN/A loadHead = loadTail = 0; 2802307SN/A 2812307SN/A storeHead = storeWBIdx = storeTail = 0; 2822307SN/A 2832307SN/A usedPorts = 0; 2842307SN/A 2852329SN/A memDepViolator = NULL; 2862307SN/A 2872307SN/A blockedLoadSeqNum = 0; 2882307SN/A 2892307SN/A stalled = false; 2902307SN/A isLoadBlocked = false; 2912307SN/A loadBlockedHandled = false; 2928545Ssaidi@eecs.umich.edu 2938545Ssaidi@eecs.umich.edu // Just incase the memory system changed out from under us 2948545Ssaidi@eecs.umich.edu cacheBlockMask = 0; 2952307SN/A} 2962307SN/A 2972307SN/Atemplate<class Impl> 2982307SN/Avoid 2992292SN/ALSQUnit<Impl>::resizeLQ(unsigned size) 3002292SN/A{ 3012329SN/A unsigned size_plus_sentinel = size + 1; 3022329SN/A assert(size_plus_sentinel >= LQEntries); 3032292SN/A 3042329SN/A if (size_plus_sentinel > LQEntries) { 3052329SN/A while (size_plus_sentinel > loadQueue.size()) { 3062292SN/A DynInstPtr dummy; 3072292SN/A loadQueue.push_back(dummy); 3082292SN/A LQEntries++; 3092292SN/A } 3102292SN/A } else { 3112329SN/A LQEntries = size_plus_sentinel; 3122292SN/A } 3132292SN/A 3142292SN/A} 3152292SN/A 3162292SN/Atemplate<class Impl> 3172292SN/Avoid 3182292SN/ALSQUnit<Impl>::resizeSQ(unsigned size) 3192292SN/A{ 3202329SN/A unsigned size_plus_sentinel = size + 1; 3212329SN/A if (size_plus_sentinel > SQEntries) { 3222329SN/A while (size_plus_sentinel > storeQueue.size()) { 3232292SN/A SQEntry dummy; 3242292SN/A storeQueue.push_back(dummy); 3252292SN/A SQEntries++; 3262292SN/A } 3272292SN/A } else { 3282329SN/A SQEntries = size_plus_sentinel; 3292292SN/A } 3302292SN/A} 3312292SN/A 3322292SN/Atemplate <class Impl> 3332292SN/Avoid 3342292SN/ALSQUnit<Impl>::insert(DynInstPtr &inst) 3352292SN/A{ 3362292SN/A assert(inst->isMemRef()); 3372292SN/A 3382292SN/A assert(inst->isLoad() || inst->isStore()); 3392292SN/A 3402292SN/A if (inst->isLoad()) { 3412292SN/A insertLoad(inst); 3422292SN/A } else { 3432292SN/A insertStore(inst); 3442292SN/A } 3452292SN/A 3462292SN/A inst->setInLSQ(); 3472292SN/A} 3482292SN/A 3492292SN/Atemplate <class Impl> 3502292SN/Avoid 3512292SN/ALSQUnit<Impl>::insertLoad(DynInstPtr &load_inst) 3522292SN/A{ 3532329SN/A assert((loadTail + 1) % LQEntries != loadHead); 3542329SN/A assert(loads < LQEntries); 3552292SN/A 3567720Sgblack@eecs.umich.edu DPRINTF(LSQUnit, "Inserting load PC %s, idx:%i [sn:%lli]\n", 3577720Sgblack@eecs.umich.edu load_inst->pcState(), loadTail, load_inst->seqNum); 3582292SN/A 3592292SN/A load_inst->lqIdx = loadTail; 3602292SN/A 3612292SN/A if (stores == 0) { 3622292SN/A load_inst->sqIdx = -1; 3632292SN/A } else { 3642292SN/A load_inst->sqIdx = storeTail; 3652292SN/A } 3662292SN/A 3672292SN/A loadQueue[loadTail] = load_inst; 3682292SN/A 3692292SN/A incrLdIdx(loadTail); 3702292SN/A 3712292SN/A ++loads; 3722292SN/A} 3732292SN/A 3742292SN/Atemplate <class Impl> 3752292SN/Avoid 3762292SN/ALSQUnit<Impl>::insertStore(DynInstPtr &store_inst) 3772292SN/A{ 3782292SN/A // Make sure it is not full before inserting an instruction. 3792292SN/A assert((storeTail + 1) % SQEntries != storeHead); 3802292SN/A assert(stores < SQEntries); 3812292SN/A 3827720Sgblack@eecs.umich.edu DPRINTF(LSQUnit, "Inserting store PC %s, idx:%i [sn:%lli]\n", 3837720Sgblack@eecs.umich.edu store_inst->pcState(), storeTail, store_inst->seqNum); 3842292SN/A 3852292SN/A store_inst->sqIdx = storeTail; 3862292SN/A store_inst->lqIdx = loadTail; 3872292SN/A 3882292SN/A storeQueue[storeTail] = SQEntry(store_inst); 3892292SN/A 3902292SN/A incrStIdx(storeTail); 3912292SN/A 3922292SN/A ++stores; 3932292SN/A} 3942292SN/A 3952292SN/Atemplate <class Impl> 3962292SN/Atypename Impl::DynInstPtr 3972292SN/ALSQUnit<Impl>::getMemDepViolator() 3982292SN/A{ 3992292SN/A DynInstPtr temp = memDepViolator; 4002292SN/A 4012292SN/A memDepViolator = NULL; 4022292SN/A 4032292SN/A return temp; 4042292SN/A} 4052292SN/A 4062292SN/Atemplate <class Impl> 4072292SN/Aunsigned 4082292SN/ALSQUnit<Impl>::numFreeEntries() 4092292SN/A{ 4102292SN/A unsigned free_lq_entries = LQEntries - loads; 4112292SN/A unsigned free_sq_entries = SQEntries - stores; 4122292SN/A 4132292SN/A // Both the LQ and SQ entries have an extra dummy entry to differentiate 4142292SN/A // empty/full conditions. Subtract 1 from the free entries. 4152292SN/A if (free_lq_entries < free_sq_entries) { 4162292SN/A return free_lq_entries - 1; 4172292SN/A } else { 4182292SN/A return free_sq_entries - 1; 4192292SN/A } 4202292SN/A} 4212292SN/A 4222292SN/Atemplate <class Impl> 4238545Ssaidi@eecs.umich.eduvoid 4248545Ssaidi@eecs.umich.eduLSQUnit<Impl>::checkSnoop(PacketPtr pkt) 4258545Ssaidi@eecs.umich.edu{ 4268545Ssaidi@eecs.umich.edu int load_idx = loadHead; 4278545Ssaidi@eecs.umich.edu 4288545Ssaidi@eecs.umich.edu if (!cacheBlockMask) { 4298545Ssaidi@eecs.umich.edu assert(dcachePort); 4308545Ssaidi@eecs.umich.edu Addr bs = dcachePort->peerBlockSize(); 4318545Ssaidi@eecs.umich.edu 4328545Ssaidi@eecs.umich.edu // Make sure we actually got a size 4338545Ssaidi@eecs.umich.edu assert(bs != 0); 4348545Ssaidi@eecs.umich.edu 4358545Ssaidi@eecs.umich.edu cacheBlockMask = ~(bs - 1); 4368545Ssaidi@eecs.umich.edu } 4378545Ssaidi@eecs.umich.edu 4389383SAli.Saidi@ARM.com // Unlock the cpu-local monitor when the CPU sees a snoop to a locked 4399383SAli.Saidi@ARM.com // address. The CPU can speculatively execute a LL operation after a pending 4409383SAli.Saidi@ARM.com // SC operation in the pipeline and that can make the cache monitor the CPU 4419383SAli.Saidi@ARM.com // is connected to valid while it really shouldn't be. 4429383SAli.Saidi@ARM.com for (int x = 0; x < cpu->numActiveThreads(); x++) { 4439383SAli.Saidi@ARM.com ThreadContext *tc = cpu->getContext(x); 4449383SAli.Saidi@ARM.com bool no_squash = cpu->thread[x]->noSquashFromTC; 4459383SAli.Saidi@ARM.com cpu->thread[x]->noSquashFromTC = true; 4469383SAli.Saidi@ARM.com TheISA::handleLockedSnoop(tc, pkt, cacheBlockMask); 4479383SAli.Saidi@ARM.com cpu->thread[x]->noSquashFromTC = no_squash; 4489383SAli.Saidi@ARM.com } 4499383SAli.Saidi@ARM.com 4508545Ssaidi@eecs.umich.edu // If this is the only load in the LSQ we don't care 4518545Ssaidi@eecs.umich.edu if (load_idx == loadTail) 4528545Ssaidi@eecs.umich.edu return; 4538545Ssaidi@eecs.umich.edu incrLdIdx(load_idx); 4548545Ssaidi@eecs.umich.edu 4558545Ssaidi@eecs.umich.edu DPRINTF(LSQUnit, "Got snoop for address %#x\n", pkt->getAddr()); 4568545Ssaidi@eecs.umich.edu Addr invalidate_addr = pkt->getAddr() & cacheBlockMask; 4578545Ssaidi@eecs.umich.edu while (load_idx != loadTail) { 4588545Ssaidi@eecs.umich.edu DynInstPtr ld_inst = loadQueue[load_idx]; 4598545Ssaidi@eecs.umich.edu 4609046SAli.Saidi@ARM.com if (!ld_inst->effAddrValid() || ld_inst->uncacheable()) { 4618545Ssaidi@eecs.umich.edu incrLdIdx(load_idx); 4628545Ssaidi@eecs.umich.edu continue; 4638545Ssaidi@eecs.umich.edu } 4648545Ssaidi@eecs.umich.edu 4658545Ssaidi@eecs.umich.edu Addr load_addr = ld_inst->physEffAddr & cacheBlockMask; 4668545Ssaidi@eecs.umich.edu DPRINTF(LSQUnit, "-- inst [sn:%lli] load_addr: %#x to pktAddr:%#x\n", 4678545Ssaidi@eecs.umich.edu ld_inst->seqNum, load_addr, invalidate_addr); 4688545Ssaidi@eecs.umich.edu 4698545Ssaidi@eecs.umich.edu if (load_addr == invalidate_addr) { 4709046SAli.Saidi@ARM.com if (ld_inst->possibleLoadViolation()) { 4718545Ssaidi@eecs.umich.edu DPRINTF(LSQUnit, "Conflicting load at addr %#x [sn:%lli]\n", 4728545Ssaidi@eecs.umich.edu ld_inst->physEffAddr, pkt->getAddr(), ld_inst->seqNum); 4738545Ssaidi@eecs.umich.edu 4748545Ssaidi@eecs.umich.edu // Mark the load for re-execution 4758545Ssaidi@eecs.umich.edu ld_inst->fault = new ReExec; 4768545Ssaidi@eecs.umich.edu } else { 4778545Ssaidi@eecs.umich.edu // If a older load checks this and it's true 4788545Ssaidi@eecs.umich.edu // then we might have missed the snoop 4798545Ssaidi@eecs.umich.edu // in which case we need to invalidate to be sure 4809046SAli.Saidi@ARM.com ld_inst->hitExternalSnoop(true); 4818545Ssaidi@eecs.umich.edu } 4828545Ssaidi@eecs.umich.edu } 4838545Ssaidi@eecs.umich.edu incrLdIdx(load_idx); 4848545Ssaidi@eecs.umich.edu } 4858545Ssaidi@eecs.umich.edu return; 4868545Ssaidi@eecs.umich.edu} 4878545Ssaidi@eecs.umich.edu 4888545Ssaidi@eecs.umich.edutemplate <class Impl> 4892292SN/AFault 4908199SAli.Saidi@ARM.comLSQUnit<Impl>::checkViolations(int load_idx, DynInstPtr &inst) 4918199SAli.Saidi@ARM.com{ 4928199SAli.Saidi@ARM.com Addr inst_eff_addr1 = inst->effAddr >> depCheckShift; 4938199SAli.Saidi@ARM.com Addr inst_eff_addr2 = (inst->effAddr + inst->effSize - 1) >> depCheckShift; 4948199SAli.Saidi@ARM.com 4958199SAli.Saidi@ARM.com /** @todo in theory you only need to check an instruction that has executed 4968199SAli.Saidi@ARM.com * however, there isn't a good way in the pipeline at the moment to check 4978199SAli.Saidi@ARM.com * all instructions that will execute before the store writes back. Thus, 4988199SAli.Saidi@ARM.com * like the implementation that came before it, we're overly conservative. 4998199SAli.Saidi@ARM.com */ 5008199SAli.Saidi@ARM.com while (load_idx != loadTail) { 5018199SAli.Saidi@ARM.com DynInstPtr ld_inst = loadQueue[load_idx]; 5029046SAli.Saidi@ARM.com if (!ld_inst->effAddrValid() || ld_inst->uncacheable()) { 5038199SAli.Saidi@ARM.com incrLdIdx(load_idx); 5048199SAli.Saidi@ARM.com continue; 5058199SAli.Saidi@ARM.com } 5068199SAli.Saidi@ARM.com 5078199SAli.Saidi@ARM.com Addr ld_eff_addr1 = ld_inst->effAddr >> depCheckShift; 5088199SAli.Saidi@ARM.com Addr ld_eff_addr2 = 5098199SAli.Saidi@ARM.com (ld_inst->effAddr + ld_inst->effSize - 1) >> depCheckShift; 5108199SAli.Saidi@ARM.com 5118272SAli.Saidi@ARM.com if (inst_eff_addr2 >= ld_eff_addr1 && inst_eff_addr1 <= ld_eff_addr2) { 5128545Ssaidi@eecs.umich.edu if (inst->isLoad()) { 5138545Ssaidi@eecs.umich.edu // If this load is to the same block as an external snoop 5148545Ssaidi@eecs.umich.edu // invalidate that we've observed then the load needs to be 5158545Ssaidi@eecs.umich.edu // squashed as it could have newer data 5169046SAli.Saidi@ARM.com if (ld_inst->hitExternalSnoop()) { 5178545Ssaidi@eecs.umich.edu if (!memDepViolator || 5188545Ssaidi@eecs.umich.edu ld_inst->seqNum < memDepViolator->seqNum) { 5198545Ssaidi@eecs.umich.edu DPRINTF(LSQUnit, "Detected fault with inst [sn:%lli] " 5208592Sgblack@eecs.umich.edu "and [sn:%lli] at address %#x\n", 5218592Sgblack@eecs.umich.edu inst->seqNum, ld_inst->seqNum, ld_eff_addr1); 5228545Ssaidi@eecs.umich.edu memDepViolator = ld_inst; 5238199SAli.Saidi@ARM.com 5248545Ssaidi@eecs.umich.edu ++lsqMemOrderViolation; 5258199SAli.Saidi@ARM.com 5268591Sgblack@eecs.umich.edu return new GenericISA::M5PanicFault( 5278591Sgblack@eecs.umich.edu "Detected fault with inst [sn:%lli] and " 5288591Sgblack@eecs.umich.edu "[sn:%lli] at address %#x\n", 5298591Sgblack@eecs.umich.edu inst->seqNum, ld_inst->seqNum, ld_eff_addr1); 5308545Ssaidi@eecs.umich.edu } 5318545Ssaidi@eecs.umich.edu } 5328199SAli.Saidi@ARM.com 5338545Ssaidi@eecs.umich.edu // Otherwise, mark the load has a possible load violation 5348545Ssaidi@eecs.umich.edu // and if we see a snoop before it's commited, we need to squash 5359046SAli.Saidi@ARM.com ld_inst->possibleLoadViolation(true); 5368545Ssaidi@eecs.umich.edu DPRINTF(LSQUnit, "Found possible load violaiton at addr: %#x" 5378545Ssaidi@eecs.umich.edu " between instructions [sn:%lli] and [sn:%lli]\n", 5388545Ssaidi@eecs.umich.edu inst_eff_addr1, inst->seqNum, ld_inst->seqNum); 5398545Ssaidi@eecs.umich.edu } else { 5408545Ssaidi@eecs.umich.edu // A load/store incorrectly passed this store. 5418545Ssaidi@eecs.umich.edu // Check if we already have a violator, or if it's newer 5428545Ssaidi@eecs.umich.edu // squash and refetch. 5438545Ssaidi@eecs.umich.edu if (memDepViolator && ld_inst->seqNum > memDepViolator->seqNum) 5448545Ssaidi@eecs.umich.edu break; 5458545Ssaidi@eecs.umich.edu 5468592Sgblack@eecs.umich.edu DPRINTF(LSQUnit, "Detected fault with inst [sn:%lli] and " 5478592Sgblack@eecs.umich.edu "[sn:%lli] at address %#x\n", 5488592Sgblack@eecs.umich.edu inst->seqNum, ld_inst->seqNum, ld_eff_addr1); 5498545Ssaidi@eecs.umich.edu memDepViolator = ld_inst; 5508545Ssaidi@eecs.umich.edu 5518545Ssaidi@eecs.umich.edu ++lsqMemOrderViolation; 5528545Ssaidi@eecs.umich.edu 5538591Sgblack@eecs.umich.edu return new GenericISA::M5PanicFault("Detected fault with " 5548591Sgblack@eecs.umich.edu "inst [sn:%lli] and [sn:%lli] at address %#x\n", 5558591Sgblack@eecs.umich.edu inst->seqNum, ld_inst->seqNum, ld_eff_addr1); 5568545Ssaidi@eecs.umich.edu } 5578199SAli.Saidi@ARM.com } 5588199SAli.Saidi@ARM.com 5598199SAli.Saidi@ARM.com incrLdIdx(load_idx); 5608199SAli.Saidi@ARM.com } 5618199SAli.Saidi@ARM.com return NoFault; 5628199SAli.Saidi@ARM.com} 5638199SAli.Saidi@ARM.com 5648199SAli.Saidi@ARM.com 5658199SAli.Saidi@ARM.com 5668199SAli.Saidi@ARM.com 5678199SAli.Saidi@ARM.comtemplate <class Impl> 5688199SAli.Saidi@ARM.comFault 5692292SN/ALSQUnit<Impl>::executeLoad(DynInstPtr &inst) 5702292SN/A{ 5714032Sktlim@umich.edu using namespace TheISA; 5722292SN/A // Execute a specific load. 5732292SN/A Fault load_fault = NoFault; 5742292SN/A 5757720Sgblack@eecs.umich.edu DPRINTF(LSQUnit, "Executing load PC %s, [sn:%lli]\n", 5767944SGiacomo.Gabrielli@arm.com inst->pcState(), inst->seqNum); 5772292SN/A 5784032Sktlim@umich.edu assert(!inst->isSquashed()); 5794032Sktlim@umich.edu 5802669Sktlim@umich.edu load_fault = inst->initiateAcc(); 5812292SN/A 5827944SGiacomo.Gabrielli@arm.com if (inst->isTranslationDelayed() && 5837944SGiacomo.Gabrielli@arm.com load_fault == NoFault) 5847944SGiacomo.Gabrielli@arm.com return load_fault; 5857944SGiacomo.Gabrielli@arm.com 5867597Sminkyu.jeong@arm.com // If the instruction faulted or predicated false, then we need to send it 5877597Sminkyu.jeong@arm.com // along to commit without the instruction completing. 5887597Sminkyu.jeong@arm.com if (load_fault != NoFault || inst->readPredicate() == false) { 5892329SN/A // Send this instruction to commit, also make sure iew stage 5902329SN/A // realizes there is activity. 5912367SN/A // Mark it as executed unless it is an uncached load that 5922367SN/A // needs to hit the head of commit. 5937848SAli.Saidi@ARM.com if (inst->readPredicate() == false) 5947848SAli.Saidi@ARM.com inst->forwardOldRegs(); 5957600Sminkyu.jeong@arm.com DPRINTF(LSQUnit, "Load [sn:%lli] not executed from %s\n", 5967600Sminkyu.jeong@arm.com inst->seqNum, 5977600Sminkyu.jeong@arm.com (load_fault != NoFault ? "fault" : "predication")); 5984032Sktlim@umich.edu if (!(inst->hasRequest() && inst->uncacheable()) || 5993731Sktlim@umich.edu inst->isAtCommit()) { 6002367SN/A inst->setExecuted(); 6012367SN/A } 6022292SN/A iewStage->instToCommit(inst); 6032292SN/A iewStage->activityThisCycle(); 6044032Sktlim@umich.edu } else if (!loadBlocked()) { 6059046SAli.Saidi@ARM.com assert(inst->effAddrValid()); 6064032Sktlim@umich.edu int load_idx = inst->lqIdx; 6074032Sktlim@umich.edu incrLdIdx(load_idx); 6084032Sktlim@umich.edu 6098199SAli.Saidi@ARM.com if (checkLoads) 6108199SAli.Saidi@ARM.com return checkViolations(load_idx, inst); 6112292SN/A } 6122292SN/A 6132292SN/A return load_fault; 6142292SN/A} 6152292SN/A 6162292SN/Atemplate <class Impl> 6172292SN/AFault 6182292SN/ALSQUnit<Impl>::executeStore(DynInstPtr &store_inst) 6192292SN/A{ 6202292SN/A using namespace TheISA; 6212292SN/A // Make sure that a store exists. 6222292SN/A assert(stores != 0); 6232292SN/A 6242292SN/A int store_idx = store_inst->sqIdx; 6252292SN/A 6267720Sgblack@eecs.umich.edu DPRINTF(LSQUnit, "Executing store PC %s [sn:%lli]\n", 6277720Sgblack@eecs.umich.edu store_inst->pcState(), store_inst->seqNum); 6282292SN/A 6294032Sktlim@umich.edu assert(!store_inst->isSquashed()); 6304032Sktlim@umich.edu 6312292SN/A // Check the recently completed loads to see if any match this store's 6322292SN/A // address. If so, then we have a memory ordering violation. 6332292SN/A int load_idx = store_inst->lqIdx; 6342292SN/A 6352292SN/A Fault store_fault = store_inst->initiateAcc(); 6362292SN/A 6377944SGiacomo.Gabrielli@arm.com if (store_inst->isTranslationDelayed() && 6387944SGiacomo.Gabrielli@arm.com store_fault == NoFault) 6397944SGiacomo.Gabrielli@arm.com return store_fault; 6407944SGiacomo.Gabrielli@arm.com 6417848SAli.Saidi@ARM.com if (store_inst->readPredicate() == false) 6427848SAli.Saidi@ARM.com store_inst->forwardOldRegs(); 6437848SAli.Saidi@ARM.com 6442329SN/A if (storeQueue[store_idx].size == 0) { 6457782Sminkyu.jeong@arm.com DPRINTF(LSQUnit,"Fault on Store PC %s, [sn:%lli], Size = 0\n", 6467720Sgblack@eecs.umich.edu store_inst->pcState(), store_inst->seqNum); 6472292SN/A 6482292SN/A return store_fault; 6497782Sminkyu.jeong@arm.com } else if (store_inst->readPredicate() == false) { 6507782Sminkyu.jeong@arm.com DPRINTF(LSQUnit, "Store [sn:%lli] not executed from predication\n", 6517782Sminkyu.jeong@arm.com store_inst->seqNum); 6527782Sminkyu.jeong@arm.com return store_fault; 6532292SN/A } 6542292SN/A 6552292SN/A assert(store_fault == NoFault); 6562292SN/A 6572336SN/A if (store_inst->isStoreConditional()) { 6582336SN/A // Store conditionals need to set themselves as able to 6592336SN/A // writeback if we haven't had a fault by here. 6602329SN/A storeQueue[store_idx].canWB = true; 6612292SN/A 6622329SN/A ++storesToWB; 6632292SN/A } 6642292SN/A 6658199SAli.Saidi@ARM.com return checkViolations(load_idx, store_inst); 6662292SN/A 6672292SN/A} 6682292SN/A 6692292SN/Atemplate <class Impl> 6702292SN/Avoid 6712292SN/ALSQUnit<Impl>::commitLoad() 6722292SN/A{ 6732292SN/A assert(loadQueue[loadHead]); 6742292SN/A 6757720Sgblack@eecs.umich.edu DPRINTF(LSQUnit, "Committing head load instruction, PC %s\n", 6767720Sgblack@eecs.umich.edu loadQueue[loadHead]->pcState()); 6772292SN/A 6782292SN/A loadQueue[loadHead] = NULL; 6792292SN/A 6802292SN/A incrLdIdx(loadHead); 6812292SN/A 6822292SN/A --loads; 6832292SN/A} 6842292SN/A 6852292SN/Atemplate <class Impl> 6862292SN/Avoid 6872292SN/ALSQUnit<Impl>::commitLoads(InstSeqNum &youngest_inst) 6882292SN/A{ 6892292SN/A assert(loads == 0 || loadQueue[loadHead]); 6902292SN/A 6912292SN/A while (loads != 0 && loadQueue[loadHead]->seqNum <= youngest_inst) { 6922292SN/A commitLoad(); 6932292SN/A } 6942292SN/A} 6952292SN/A 6962292SN/Atemplate <class Impl> 6972292SN/Avoid 6982292SN/ALSQUnit<Impl>::commitStores(InstSeqNum &youngest_inst) 6992292SN/A{ 7002292SN/A assert(stores == 0 || storeQueue[storeHead].inst); 7012292SN/A 7022292SN/A int store_idx = storeHead; 7032292SN/A 7042292SN/A while (store_idx != storeTail) { 7052292SN/A assert(storeQueue[store_idx].inst); 7062329SN/A // Mark any stores that are now committed and have not yet 7072329SN/A // been marked as able to write back. 7082292SN/A if (!storeQueue[store_idx].canWB) { 7092292SN/A if (storeQueue[store_idx].inst->seqNum > youngest_inst) { 7102292SN/A break; 7112292SN/A } 7122292SN/A DPRINTF(LSQUnit, "Marking store as able to write back, PC " 7137720Sgblack@eecs.umich.edu "%s [sn:%lli]\n", 7147720Sgblack@eecs.umich.edu storeQueue[store_idx].inst->pcState(), 7152292SN/A storeQueue[store_idx].inst->seqNum); 7162292SN/A 7172292SN/A storeQueue[store_idx].canWB = true; 7182292SN/A 7192292SN/A ++storesToWB; 7202292SN/A } 7212292SN/A 7222292SN/A incrStIdx(store_idx); 7232292SN/A } 7242292SN/A} 7252292SN/A 7262292SN/Atemplate <class Impl> 7272292SN/Avoid 7286974Stjones1@inf.ed.ac.ukLSQUnit<Impl>::writebackPendingStore() 7296974Stjones1@inf.ed.ac.uk{ 7306974Stjones1@inf.ed.ac.uk if (hasPendingPkt) { 7316974Stjones1@inf.ed.ac.uk assert(pendingPkt != NULL); 7326974Stjones1@inf.ed.ac.uk 7336974Stjones1@inf.ed.ac.uk // If the cache is blocked, this will store the packet for retry. 7346974Stjones1@inf.ed.ac.uk if (sendStore(pendingPkt)) { 7356974Stjones1@inf.ed.ac.uk storePostSend(pendingPkt); 7366974Stjones1@inf.ed.ac.uk } 7376974Stjones1@inf.ed.ac.uk pendingPkt = NULL; 7386974Stjones1@inf.ed.ac.uk hasPendingPkt = false; 7396974Stjones1@inf.ed.ac.uk } 7406974Stjones1@inf.ed.ac.uk} 7416974Stjones1@inf.ed.ac.uk 7426974Stjones1@inf.ed.ac.uktemplate <class Impl> 7436974Stjones1@inf.ed.ac.ukvoid 7442292SN/ALSQUnit<Impl>::writebackStores() 7452292SN/A{ 7466974Stjones1@inf.ed.ac.uk // First writeback the second packet from any split store that didn't 7476974Stjones1@inf.ed.ac.uk // complete last cycle because there weren't enough cache ports available. 7486974Stjones1@inf.ed.ac.uk if (TheISA::HasUnalignedMemAcc) { 7496974Stjones1@inf.ed.ac.uk writebackPendingStore(); 7506974Stjones1@inf.ed.ac.uk } 7516974Stjones1@inf.ed.ac.uk 7522292SN/A while (storesToWB > 0 && 7532292SN/A storeWBIdx != storeTail && 7542292SN/A storeQueue[storeWBIdx].inst && 7552292SN/A storeQueue[storeWBIdx].canWB && 7568727Snilay@cs.wisc.edu ((!needsTSO) || (!storeInFlight)) && 7572292SN/A usedPorts < cachePorts) { 7582292SN/A 7592907Sktlim@umich.edu if (isStoreBlocked || lsq->cacheBlocked()) { 7602678Sktlim@umich.edu DPRINTF(LSQUnit, "Unable to write back any more stores, cache" 7612678Sktlim@umich.edu " is blocked!\n"); 7622678Sktlim@umich.edu break; 7632678Sktlim@umich.edu } 7642678Sktlim@umich.edu 7652329SN/A // Store didn't write any data so no need to write it back to 7662329SN/A // memory. 7672292SN/A if (storeQueue[storeWBIdx].size == 0) { 7682292SN/A completeStore(storeWBIdx); 7692292SN/A 7702292SN/A incrStIdx(storeWBIdx); 7712292SN/A 7722292SN/A continue; 7732292SN/A } 7742678Sktlim@umich.edu 7752292SN/A ++usedPorts; 7762292SN/A 7772292SN/A if (storeQueue[storeWBIdx].inst->isDataPrefetch()) { 7782292SN/A incrStIdx(storeWBIdx); 7792292SN/A 7802292SN/A continue; 7812292SN/A } 7822292SN/A 7832292SN/A assert(storeQueue[storeWBIdx].req); 7842292SN/A assert(!storeQueue[storeWBIdx].committed); 7852292SN/A 7866974Stjones1@inf.ed.ac.uk if (TheISA::HasUnalignedMemAcc && storeQueue[storeWBIdx].isSplit) { 7876974Stjones1@inf.ed.ac.uk assert(storeQueue[storeWBIdx].sreqLow); 7886974Stjones1@inf.ed.ac.uk assert(storeQueue[storeWBIdx].sreqHigh); 7896974Stjones1@inf.ed.ac.uk } 7906974Stjones1@inf.ed.ac.uk 7912669Sktlim@umich.edu DynInstPtr inst = storeQueue[storeWBIdx].inst; 7922669Sktlim@umich.edu 7932669Sktlim@umich.edu Request *req = storeQueue[storeWBIdx].req; 7948481Sgblack@eecs.umich.edu RequestPtr sreqLow = storeQueue[storeWBIdx].sreqLow; 7958481Sgblack@eecs.umich.edu RequestPtr sreqHigh = storeQueue[storeWBIdx].sreqHigh; 7968481Sgblack@eecs.umich.edu 7972292SN/A storeQueue[storeWBIdx].committed = true; 7982292SN/A 7992669Sktlim@umich.edu assert(!inst->memData); 8002669Sktlim@umich.edu inst->memData = new uint8_t[64]; 8013772Sgblack@eecs.umich.edu 8024326Sgblack@eecs.umich.edu memcpy(inst->memData, storeQueue[storeWBIdx].data, req->getSize()); 8032669Sktlim@umich.edu 8044878Sstever@eecs.umich.edu MemCmd command = 8054878Sstever@eecs.umich.edu req->isSwap() ? MemCmd::SwapReq : 8066102Sgblack@eecs.umich.edu (req->isLLSC() ? MemCmd::StoreCondReq : MemCmd::WriteReq); 8076974Stjones1@inf.ed.ac.uk PacketPtr data_pkt; 8086974Stjones1@inf.ed.ac.uk PacketPtr snd_data_pkt = NULL; 8092292SN/A 8102678Sktlim@umich.edu LSQSenderState *state = new LSQSenderState; 8112678Sktlim@umich.edu state->isLoad = false; 8122678Sktlim@umich.edu state->idx = storeWBIdx; 8132678Sktlim@umich.edu state->inst = inst; 8146974Stjones1@inf.ed.ac.uk 8156974Stjones1@inf.ed.ac.uk if (!TheISA::HasUnalignedMemAcc || !storeQueue[storeWBIdx].isSplit) { 8166974Stjones1@inf.ed.ac.uk 8176974Stjones1@inf.ed.ac.uk // Build a single data packet if the store isn't split. 8188949Sandreas.hansson@arm.com data_pkt = new Packet(req, command); 8196974Stjones1@inf.ed.ac.uk data_pkt->dataStatic(inst->memData); 8206974Stjones1@inf.ed.ac.uk data_pkt->senderState = state; 8216974Stjones1@inf.ed.ac.uk } else { 8226974Stjones1@inf.ed.ac.uk // Create two packets if the store is split in two. 8238949Sandreas.hansson@arm.com data_pkt = new Packet(sreqLow, command); 8248949Sandreas.hansson@arm.com snd_data_pkt = new Packet(sreqHigh, command); 8256974Stjones1@inf.ed.ac.uk 8266974Stjones1@inf.ed.ac.uk data_pkt->dataStatic(inst->memData); 8276974Stjones1@inf.ed.ac.uk snd_data_pkt->dataStatic(inst->memData + sreqLow->getSize()); 8286974Stjones1@inf.ed.ac.uk 8296974Stjones1@inf.ed.ac.uk data_pkt->senderState = state; 8306974Stjones1@inf.ed.ac.uk snd_data_pkt->senderState = state; 8316974Stjones1@inf.ed.ac.uk 8326974Stjones1@inf.ed.ac.uk state->isSplit = true; 8336974Stjones1@inf.ed.ac.uk state->outstanding = 2; 8346974Stjones1@inf.ed.ac.uk 8356974Stjones1@inf.ed.ac.uk // Can delete the main request now. 8366974Stjones1@inf.ed.ac.uk delete req; 8376974Stjones1@inf.ed.ac.uk req = sreqLow; 8386974Stjones1@inf.ed.ac.uk } 8392678Sktlim@umich.edu 8407720Sgblack@eecs.umich.edu DPRINTF(LSQUnit, "D-Cache: Writing back store idx:%i PC:%s " 8412292SN/A "to Addr:%#x, data:%#x [sn:%lli]\n", 8427720Sgblack@eecs.umich.edu storeWBIdx, inst->pcState(), 8433797Sgblack@eecs.umich.edu req->getPaddr(), (int)*(inst->memData), 8443221Sktlim@umich.edu inst->seqNum); 8452292SN/A 8462693Sktlim@umich.edu // @todo: Remove this SC hack once the memory system handles it. 8474350Sgblack@eecs.umich.edu if (inst->isStoreConditional()) { 8486974Stjones1@inf.ed.ac.uk assert(!storeQueue[storeWBIdx].isSplit); 8493326Sktlim@umich.edu // Disable recording the result temporarily. Writing to 8503326Sktlim@umich.edu // misc regs normally updates the result, but this is not 8513326Sktlim@umich.edu // the desired behavior when handling store conditionals. 8529046SAli.Saidi@ARM.com inst->recordResult(false); 8533326Sktlim@umich.edu bool success = TheISA::handleLockedWrite(inst.get(), req); 8549046SAli.Saidi@ARM.com inst->recordResult(true); 8553326Sktlim@umich.edu 8563326Sktlim@umich.edu if (!success) { 8573326Sktlim@umich.edu // Instantly complete this store. 8583326Sktlim@umich.edu DPRINTF(LSQUnit, "Store conditional [sn:%lli] failed. " 8593326Sktlim@umich.edu "Instantly completing it.\n", 8603326Sktlim@umich.edu inst->seqNum); 8613326Sktlim@umich.edu WritebackEvent *wb = new WritebackEvent(inst, data_pkt, this); 8627823Ssteve.reinhardt@amd.com cpu->schedule(wb, curTick() + 1); 8638887Sgeoffrey.blake@arm.com if (cpu->checker) { 8648887Sgeoffrey.blake@arm.com // Make sure to set the LLSC data for verification 8658887Sgeoffrey.blake@arm.com // if checker is loaded 8668887Sgeoffrey.blake@arm.com inst->reqToVerify->setExtraData(0); 8678887Sgeoffrey.blake@arm.com inst->completeAcc(data_pkt); 8688887Sgeoffrey.blake@arm.com } 8693326Sktlim@umich.edu completeStore(storeWBIdx); 8703326Sktlim@umich.edu incrStIdx(storeWBIdx); 8713326Sktlim@umich.edu continue; 8722693Sktlim@umich.edu } 8732693Sktlim@umich.edu } else { 8742693Sktlim@umich.edu // Non-store conditionals do not need a writeback. 8752693Sktlim@umich.edu state->noWB = true; 8762693Sktlim@umich.edu } 8772693Sktlim@umich.edu 8788481Sgblack@eecs.umich.edu bool split = 8798481Sgblack@eecs.umich.edu TheISA::HasUnalignedMemAcc && storeQueue[storeWBIdx].isSplit; 8808481Sgblack@eecs.umich.edu 8818481Sgblack@eecs.umich.edu ThreadContext *thread = cpu->tcBase(lsqID); 8828481Sgblack@eecs.umich.edu 8838481Sgblack@eecs.umich.edu if (req->isMmappedIpr()) { 8848481Sgblack@eecs.umich.edu assert(!inst->isStoreConditional()); 8858481Sgblack@eecs.umich.edu TheISA::handleIprWrite(thread, data_pkt); 8868481Sgblack@eecs.umich.edu delete data_pkt; 8878481Sgblack@eecs.umich.edu if (split) { 8888481Sgblack@eecs.umich.edu assert(snd_data_pkt->req->isMmappedIpr()); 8898481Sgblack@eecs.umich.edu TheISA::handleIprWrite(thread, snd_data_pkt); 8908481Sgblack@eecs.umich.edu delete snd_data_pkt; 8918481Sgblack@eecs.umich.edu delete sreqLow; 8928481Sgblack@eecs.umich.edu delete sreqHigh; 8938481Sgblack@eecs.umich.edu } 8948481Sgblack@eecs.umich.edu delete state; 8958481Sgblack@eecs.umich.edu delete req; 8968481Sgblack@eecs.umich.edu completeStore(storeWBIdx); 8978481Sgblack@eecs.umich.edu incrStIdx(storeWBIdx); 8988481Sgblack@eecs.umich.edu } else if (!sendStore(data_pkt)) { 8994032Sktlim@umich.edu DPRINTF(IEW, "D-Cache became blocked when writing [sn:%lli], will" 9003221Sktlim@umich.edu "retry later\n", 9013221Sktlim@umich.edu inst->seqNum); 9026974Stjones1@inf.ed.ac.uk 9036974Stjones1@inf.ed.ac.uk // Need to store the second packet, if split. 9048481Sgblack@eecs.umich.edu if (split) { 9056974Stjones1@inf.ed.ac.uk state->pktToSend = true; 9066974Stjones1@inf.ed.ac.uk state->pendingPacket = snd_data_pkt; 9076974Stjones1@inf.ed.ac.uk } 9082669Sktlim@umich.edu } else { 9096974Stjones1@inf.ed.ac.uk 9106974Stjones1@inf.ed.ac.uk // If split, try to send the second packet too 9118481Sgblack@eecs.umich.edu if (split) { 9126974Stjones1@inf.ed.ac.uk assert(snd_data_pkt); 9136974Stjones1@inf.ed.ac.uk 9146974Stjones1@inf.ed.ac.uk // Ensure there are enough ports to use. 9156974Stjones1@inf.ed.ac.uk if (usedPorts < cachePorts) { 9166974Stjones1@inf.ed.ac.uk ++usedPorts; 9176974Stjones1@inf.ed.ac.uk if (sendStore(snd_data_pkt)) { 9186974Stjones1@inf.ed.ac.uk storePostSend(snd_data_pkt); 9196974Stjones1@inf.ed.ac.uk } else { 9206974Stjones1@inf.ed.ac.uk DPRINTF(IEW, "D-Cache became blocked when writing" 9216974Stjones1@inf.ed.ac.uk " [sn:%lli] second packet, will retry later\n", 9226974Stjones1@inf.ed.ac.uk inst->seqNum); 9236974Stjones1@inf.ed.ac.uk } 9246974Stjones1@inf.ed.ac.uk } else { 9256974Stjones1@inf.ed.ac.uk 9266974Stjones1@inf.ed.ac.uk // Store the packet for when there's free ports. 9276974Stjones1@inf.ed.ac.uk assert(pendingPkt == NULL); 9286974Stjones1@inf.ed.ac.uk pendingPkt = snd_data_pkt; 9296974Stjones1@inf.ed.ac.uk hasPendingPkt = true; 9306974Stjones1@inf.ed.ac.uk } 9316974Stjones1@inf.ed.ac.uk } else { 9326974Stjones1@inf.ed.ac.uk 9336974Stjones1@inf.ed.ac.uk // Not a split store. 9346974Stjones1@inf.ed.ac.uk storePostSend(data_pkt); 9356974Stjones1@inf.ed.ac.uk } 9362292SN/A } 9372292SN/A } 9382292SN/A 9392292SN/A // Not sure this should set it to 0. 9402292SN/A usedPorts = 0; 9412292SN/A 9422292SN/A assert(stores >= 0 && storesToWB >= 0); 9432292SN/A} 9442292SN/A 9452292SN/A/*template <class Impl> 9462292SN/Avoid 9472292SN/ALSQUnit<Impl>::removeMSHR(InstSeqNum seqNum) 9482292SN/A{ 9492292SN/A list<InstSeqNum>::iterator mshr_it = find(mshrSeqNums.begin(), 9502292SN/A mshrSeqNums.end(), 9512292SN/A seqNum); 9522292SN/A 9532292SN/A if (mshr_it != mshrSeqNums.end()) { 9542292SN/A mshrSeqNums.erase(mshr_it); 9552292SN/A DPRINTF(LSQUnit, "Removing MSHR. count = %i\n",mshrSeqNums.size()); 9562292SN/A } 9572292SN/A}*/ 9582292SN/A 9592292SN/Atemplate <class Impl> 9602292SN/Avoid 9612292SN/ALSQUnit<Impl>::squash(const InstSeqNum &squashed_num) 9622292SN/A{ 9632292SN/A DPRINTF(LSQUnit, "Squashing until [sn:%lli]!" 9642329SN/A "(Loads:%i Stores:%i)\n", squashed_num, loads, stores); 9652292SN/A 9662292SN/A int load_idx = loadTail; 9672292SN/A decrLdIdx(load_idx); 9682292SN/A 9692292SN/A while (loads != 0 && loadQueue[load_idx]->seqNum > squashed_num) { 9707720Sgblack@eecs.umich.edu DPRINTF(LSQUnit,"Load Instruction PC %s squashed, " 9712292SN/A "[sn:%lli]\n", 9727720Sgblack@eecs.umich.edu loadQueue[load_idx]->pcState(), 9732292SN/A loadQueue[load_idx]->seqNum); 9742292SN/A 9752292SN/A if (isStalled() && load_idx == stallingLoadIdx) { 9762292SN/A stalled = false; 9772292SN/A stallingStoreIsn = 0; 9782292SN/A stallingLoadIdx = 0; 9792292SN/A } 9802292SN/A 9812329SN/A // Clear the smart pointer to make sure it is decremented. 9822731Sktlim@umich.edu loadQueue[load_idx]->setSquashed(); 9832292SN/A loadQueue[load_idx] = NULL; 9842292SN/A --loads; 9852292SN/A 9862292SN/A // Inefficient! 9872292SN/A loadTail = load_idx; 9882292SN/A 9892292SN/A decrLdIdx(load_idx); 9902727Sktlim@umich.edu ++lsqSquashedLoads; 9912292SN/A } 9922292SN/A 9932292SN/A if (isLoadBlocked) { 9942292SN/A if (squashed_num < blockedLoadSeqNum) { 9952292SN/A isLoadBlocked = false; 9962292SN/A loadBlockedHandled = false; 9972292SN/A blockedLoadSeqNum = 0; 9982292SN/A } 9992292SN/A } 10002292SN/A 10014032Sktlim@umich.edu if (memDepViolator && squashed_num < memDepViolator->seqNum) { 10024032Sktlim@umich.edu memDepViolator = NULL; 10034032Sktlim@umich.edu } 10044032Sktlim@umich.edu 10052292SN/A int store_idx = storeTail; 10062292SN/A decrStIdx(store_idx); 10072292SN/A 10082292SN/A while (stores != 0 && 10092292SN/A storeQueue[store_idx].inst->seqNum > squashed_num) { 10102329SN/A // Instructions marked as can WB are already committed. 10112292SN/A if (storeQueue[store_idx].canWB) { 10122292SN/A break; 10132292SN/A } 10142292SN/A 10157720Sgblack@eecs.umich.edu DPRINTF(LSQUnit,"Store Instruction PC %s squashed, " 10162292SN/A "idx:%i [sn:%lli]\n", 10177720Sgblack@eecs.umich.edu storeQueue[store_idx].inst->pcState(), 10182292SN/A store_idx, storeQueue[store_idx].inst->seqNum); 10192292SN/A 10202329SN/A // I don't think this can happen. It should have been cleared 10212329SN/A // by the stalling load. 10222292SN/A if (isStalled() && 10232292SN/A storeQueue[store_idx].inst->seqNum == stallingStoreIsn) { 10242292SN/A panic("Is stalled should have been cleared by stalling load!\n"); 10252292SN/A stalled = false; 10262292SN/A stallingStoreIsn = 0; 10272292SN/A } 10282292SN/A 10292329SN/A // Clear the smart pointer to make sure it is decremented. 10302731Sktlim@umich.edu storeQueue[store_idx].inst->setSquashed(); 10312292SN/A storeQueue[store_idx].inst = NULL; 10322292SN/A storeQueue[store_idx].canWB = 0; 10332292SN/A 10344032Sktlim@umich.edu // Must delete request now that it wasn't handed off to 10354032Sktlim@umich.edu // memory. This is quite ugly. @todo: Figure out the proper 10364032Sktlim@umich.edu // place to really handle request deletes. 10374032Sktlim@umich.edu delete storeQueue[store_idx].req; 10386974Stjones1@inf.ed.ac.uk if (TheISA::HasUnalignedMemAcc && storeQueue[store_idx].isSplit) { 10396974Stjones1@inf.ed.ac.uk delete storeQueue[store_idx].sreqLow; 10406974Stjones1@inf.ed.ac.uk delete storeQueue[store_idx].sreqHigh; 10416974Stjones1@inf.ed.ac.uk 10426974Stjones1@inf.ed.ac.uk storeQueue[store_idx].sreqLow = NULL; 10436974Stjones1@inf.ed.ac.uk storeQueue[store_idx].sreqHigh = NULL; 10446974Stjones1@inf.ed.ac.uk } 10454032Sktlim@umich.edu 10462292SN/A storeQueue[store_idx].req = NULL; 10472292SN/A --stores; 10482292SN/A 10492292SN/A // Inefficient! 10502292SN/A storeTail = store_idx; 10512292SN/A 10522292SN/A decrStIdx(store_idx); 10532727Sktlim@umich.edu ++lsqSquashedStores; 10542292SN/A } 10552292SN/A} 10562292SN/A 10572292SN/Atemplate <class Impl> 10582292SN/Avoid 10593349Sbinkertn@umich.eduLSQUnit<Impl>::storePostSend(PacketPtr pkt) 10602693Sktlim@umich.edu{ 10612693Sktlim@umich.edu if (isStalled() && 10622693Sktlim@umich.edu storeQueue[storeWBIdx].inst->seqNum == stallingStoreIsn) { 10632693Sktlim@umich.edu DPRINTF(LSQUnit, "Unstalling, stalling store [sn:%lli] " 10642693Sktlim@umich.edu "load idx:%i\n", 10652693Sktlim@umich.edu stallingStoreIsn, stallingLoadIdx); 10662693Sktlim@umich.edu stalled = false; 10672693Sktlim@umich.edu stallingStoreIsn = 0; 10682693Sktlim@umich.edu iewStage->replayMemInst(loadQueue[stallingLoadIdx]); 10692693Sktlim@umich.edu } 10702693Sktlim@umich.edu 10712693Sktlim@umich.edu if (!storeQueue[storeWBIdx].inst->isStoreConditional()) { 10722693Sktlim@umich.edu // The store is basically completed at this time. This 10732693Sktlim@umich.edu // only works so long as the checker doesn't try to 10742693Sktlim@umich.edu // verify the value in memory for stores. 10752693Sktlim@umich.edu storeQueue[storeWBIdx].inst->setCompleted(); 10768887Sgeoffrey.blake@arm.com 10772693Sktlim@umich.edu if (cpu->checker) { 10782732Sktlim@umich.edu cpu->checker->verify(storeQueue[storeWBIdx].inst); 10792693Sktlim@umich.edu } 10802693Sktlim@umich.edu } 10812693Sktlim@umich.edu 10828727Snilay@cs.wisc.edu if (needsTSO) { 10838727Snilay@cs.wisc.edu storeInFlight = true; 10848727Snilay@cs.wisc.edu } 10858727Snilay@cs.wisc.edu 10862693Sktlim@umich.edu incrStIdx(storeWBIdx); 10872693Sktlim@umich.edu} 10882693Sktlim@umich.edu 10892693Sktlim@umich.edutemplate <class Impl> 10902693Sktlim@umich.eduvoid 10912678Sktlim@umich.eduLSQUnit<Impl>::writeback(DynInstPtr &inst, PacketPtr pkt) 10922678Sktlim@umich.edu{ 10932678Sktlim@umich.edu iewStage->wakeCPU(); 10942678Sktlim@umich.edu 10952678Sktlim@umich.edu // Squashed instructions do not need to complete their access. 10962678Sktlim@umich.edu if (inst->isSquashed()) { 10972927Sktlim@umich.edu iewStage->decrWb(inst->seqNum); 10982678Sktlim@umich.edu assert(!inst->isStore()); 10992727Sktlim@umich.edu ++lsqIgnoredResponses; 11002678Sktlim@umich.edu return; 11012678Sktlim@umich.edu } 11022678Sktlim@umich.edu 11032678Sktlim@umich.edu if (!inst->isExecuted()) { 11042678Sktlim@umich.edu inst->setExecuted(); 11052678Sktlim@umich.edu 11062678Sktlim@umich.edu // Complete access to copy data to proper place. 11072678Sktlim@umich.edu inst->completeAcc(pkt); 11082678Sktlim@umich.edu } 11092678Sktlim@umich.edu 11102678Sktlim@umich.edu // Need to insert instruction into queue to commit 11112678Sktlim@umich.edu iewStage->instToCommit(inst); 11122678Sktlim@umich.edu 11132678Sktlim@umich.edu iewStage->activityThisCycle(); 11147598Sminkyu.jeong@arm.com 11157598Sminkyu.jeong@arm.com // see if this load changed the PC 11167598Sminkyu.jeong@arm.com iewStage->checkMisprediction(inst); 11172678Sktlim@umich.edu} 11182678Sktlim@umich.edu 11192678Sktlim@umich.edutemplate <class Impl> 11202678Sktlim@umich.eduvoid 11212292SN/ALSQUnit<Impl>::completeStore(int store_idx) 11222292SN/A{ 11232292SN/A assert(storeQueue[store_idx].inst); 11242292SN/A storeQueue[store_idx].completed = true; 11252292SN/A --storesToWB; 11262292SN/A // A bit conservative because a store completion may not free up entries, 11272292SN/A // but hopefully avoids two store completions in one cycle from making 11282292SN/A // the CPU tick twice. 11293126Sktlim@umich.edu cpu->wakeCPU(); 11302292SN/A cpu->activityThisCycle(); 11312292SN/A 11322292SN/A if (store_idx == storeHead) { 11332292SN/A do { 11342292SN/A incrStIdx(storeHead); 11352292SN/A 11362292SN/A --stores; 11372292SN/A } while (storeQueue[storeHead].completed && 11382292SN/A storeHead != storeTail); 11392292SN/A 11402292SN/A iewStage->updateLSQNextCycle = true; 11412292SN/A } 11422292SN/A 11432329SN/A DPRINTF(LSQUnit, "Completing store [sn:%lli], idx:%i, store head " 11442329SN/A "idx:%i\n", 11452329SN/A storeQueue[store_idx].inst->seqNum, store_idx, storeHead); 11462292SN/A 11472292SN/A if (isStalled() && 11482292SN/A storeQueue[store_idx].inst->seqNum == stallingStoreIsn) { 11492292SN/A DPRINTF(LSQUnit, "Unstalling, stalling store [sn:%lli] " 11502292SN/A "load idx:%i\n", 11512292SN/A stallingStoreIsn, stallingLoadIdx); 11522292SN/A stalled = false; 11532292SN/A stallingStoreIsn = 0; 11542292SN/A iewStage->replayMemInst(loadQueue[stallingLoadIdx]); 11552292SN/A } 11562316SN/A 11572316SN/A storeQueue[store_idx].inst->setCompleted(); 11582329SN/A 11598727Snilay@cs.wisc.edu if (needsTSO) { 11608727Snilay@cs.wisc.edu storeInFlight = false; 11618727Snilay@cs.wisc.edu } 11628727Snilay@cs.wisc.edu 11632329SN/A // Tell the checker we've completed this instruction. Some stores 11642329SN/A // may get reported twice to the checker, but the checker can 11652329SN/A // handle that case. 11662316SN/A if (cpu->checker) { 11672732Sktlim@umich.edu cpu->checker->verify(storeQueue[store_idx].inst); 11682316SN/A } 11692292SN/A} 11702292SN/A 11712292SN/Atemplate <class Impl> 11726974Stjones1@inf.ed.ac.ukbool 11736974Stjones1@inf.ed.ac.ukLSQUnit<Impl>::sendStore(PacketPtr data_pkt) 11746974Stjones1@inf.ed.ac.uk{ 11758975Sandreas.hansson@arm.com if (!dcachePort->sendTimingReq(data_pkt)) { 11766974Stjones1@inf.ed.ac.uk // Need to handle becoming blocked on a store. 11776974Stjones1@inf.ed.ac.uk isStoreBlocked = true; 11786974Stjones1@inf.ed.ac.uk ++lsqCacheBlocked; 11796974Stjones1@inf.ed.ac.uk assert(retryPkt == NULL); 11806974Stjones1@inf.ed.ac.uk retryPkt = data_pkt; 11816974Stjones1@inf.ed.ac.uk lsq->setRetryTid(lsqID); 11826974Stjones1@inf.ed.ac.uk return false; 11836974Stjones1@inf.ed.ac.uk } 11846974Stjones1@inf.ed.ac.uk return true; 11856974Stjones1@inf.ed.ac.uk} 11866974Stjones1@inf.ed.ac.uk 11876974Stjones1@inf.ed.ac.uktemplate <class Impl> 11882693Sktlim@umich.eduvoid 11892693Sktlim@umich.eduLSQUnit<Impl>::recvRetry() 11902693Sktlim@umich.edu{ 11912698Sktlim@umich.edu if (isStoreBlocked) { 11924985Sktlim@umich.edu DPRINTF(LSQUnit, "Receiving retry: store blocked\n"); 11932698Sktlim@umich.edu assert(retryPkt != NULL); 11942693Sktlim@umich.edu 11958587Snilay@cs.wisc.edu LSQSenderState *state = 11968587Snilay@cs.wisc.edu dynamic_cast<LSQSenderState *>(retryPkt->senderState); 11978587Snilay@cs.wisc.edu 11988975Sandreas.hansson@arm.com if (dcachePort->sendTimingReq(retryPkt)) { 11996974Stjones1@inf.ed.ac.uk // Don't finish the store unless this is the last packet. 12008133SAli.Saidi@ARM.com if (!TheISA::HasUnalignedMemAcc || !state->pktToSend || 12018133SAli.Saidi@ARM.com state->pendingPacket == retryPkt) { 12028133SAli.Saidi@ARM.com state->pktToSend = false; 12036974Stjones1@inf.ed.ac.uk storePostSend(retryPkt); 12046974Stjones1@inf.ed.ac.uk } 12052699Sktlim@umich.edu retryPkt = NULL; 12062693Sktlim@umich.edu isStoreBlocked = false; 12076221Snate@binkert.org lsq->setRetryTid(InvalidThreadID); 12086974Stjones1@inf.ed.ac.uk 12096974Stjones1@inf.ed.ac.uk // Send any outstanding packet. 12106974Stjones1@inf.ed.ac.uk if (TheISA::HasUnalignedMemAcc && state->pktToSend) { 12116974Stjones1@inf.ed.ac.uk assert(state->pendingPacket); 12126974Stjones1@inf.ed.ac.uk if (sendStore(state->pendingPacket)) { 12136974Stjones1@inf.ed.ac.uk storePostSend(state->pendingPacket); 12146974Stjones1@inf.ed.ac.uk } 12156974Stjones1@inf.ed.ac.uk } 12162693Sktlim@umich.edu } else { 12172693Sktlim@umich.edu // Still blocked! 12182727Sktlim@umich.edu ++lsqCacheBlocked; 12192907Sktlim@umich.edu lsq->setRetryTid(lsqID); 12202693Sktlim@umich.edu } 12212693Sktlim@umich.edu } else if (isLoadBlocked) { 12222693Sktlim@umich.edu DPRINTF(LSQUnit, "Loads squash themselves and all younger insts, " 12232693Sktlim@umich.edu "no need to resend packet.\n"); 12242693Sktlim@umich.edu } else { 12252693Sktlim@umich.edu DPRINTF(LSQUnit, "Retry received but LSQ is no longer blocked.\n"); 12262693Sktlim@umich.edu } 12272693Sktlim@umich.edu} 12282693Sktlim@umich.edu 12292693Sktlim@umich.edutemplate <class Impl> 12302292SN/Ainline void 12312292SN/ALSQUnit<Impl>::incrStIdx(int &store_idx) 12322292SN/A{ 12332292SN/A if (++store_idx >= SQEntries) 12342292SN/A store_idx = 0; 12352292SN/A} 12362292SN/A 12372292SN/Atemplate <class Impl> 12382292SN/Ainline void 12392292SN/ALSQUnit<Impl>::decrStIdx(int &store_idx) 12402292SN/A{ 12412292SN/A if (--store_idx < 0) 12422292SN/A store_idx += SQEntries; 12432292SN/A} 12442292SN/A 12452292SN/Atemplate <class Impl> 12462292SN/Ainline void 12472292SN/ALSQUnit<Impl>::incrLdIdx(int &load_idx) 12482292SN/A{ 12492292SN/A if (++load_idx >= LQEntries) 12502292SN/A load_idx = 0; 12512292SN/A} 12522292SN/A 12532292SN/Atemplate <class Impl> 12542292SN/Ainline void 12552292SN/ALSQUnit<Impl>::decrLdIdx(int &load_idx) 12562292SN/A{ 12572292SN/A if (--load_idx < 0) 12582292SN/A load_idx += LQEntries; 12592292SN/A} 12602329SN/A 12612329SN/Atemplate <class Impl> 12622329SN/Avoid 12632329SN/ALSQUnit<Impl>::dumpInsts() 12642329SN/A{ 12652329SN/A cprintf("Load store queue: Dumping instructions.\n"); 12662329SN/A cprintf("Load queue size: %i\n", loads); 12672329SN/A cprintf("Load queue: "); 12682329SN/A 12692329SN/A int load_idx = loadHead; 12702329SN/A 12712329SN/A while (load_idx != loadTail && loadQueue[load_idx]) { 12727720Sgblack@eecs.umich.edu cprintf("%s ", loadQueue[load_idx]->pcState()); 12732329SN/A 12742329SN/A incrLdIdx(load_idx); 12752329SN/A } 12762329SN/A 12772329SN/A cprintf("Store queue size: %i\n", stores); 12782329SN/A cprintf("Store queue: "); 12792329SN/A 12802329SN/A int store_idx = storeHead; 12812329SN/A 12822329SN/A while (store_idx != storeTail && storeQueue[store_idx].inst) { 12837720Sgblack@eecs.umich.edu cprintf("%s ", storeQueue[store_idx].inst->pcState()); 12842329SN/A 12852329SN/A incrStIdx(store_idx); 12862329SN/A } 12872329SN/A 12882329SN/A cprintf("\n"); 12892329SN/A} 1290