1/*
2 * Copyright (c) 2012, 2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder.  You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2004-2006 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Authors: Kevin Lim
41 */
42
43#ifndef __CPU_O3_DECODE_IMPL_HH__
44#define __CPU_O3_DECODE_IMPL_HH__
45
46#include "arch/types.hh"
47#include "base/trace.hh"
48#include "config/the_isa.hh"
49#include "cpu/o3/decode.hh"
50#include "cpu/inst_seq.hh"
51#include "debug/Activity.hh"
52#include "debug/Decode.hh"
53#include "debug/O3PipeView.hh"
54#include "params/DerivO3CPU.hh"
55#include "sim/full_system.hh"
56
57// clang complains about std::set being overloaded with Packet::set if
58// we open up the entire namespace std
59using std::list;
60
61template<class Impl>
62DefaultDecode<Impl>::DefaultDecode(O3CPU *_cpu, DerivO3CPUParams *params)
63    : cpu(_cpu),
64      renameToDecodeDelay(params->renameToDecodeDelay),
65      iewToDecodeDelay(params->iewToDecodeDelay),
66      commitToDecodeDelay(params->commitToDecodeDelay),
67      fetchToDecodeDelay(params->fetchToDecodeDelay),
68      decodeWidth(params->decodeWidth),
69      numThreads(params->numThreads)
70{
71    if (decodeWidth > Impl::MaxWidth)
72        fatal("decodeWidth (%d) is larger than compiled limit (%d),\n"
73             "\tincrease MaxWidth in src/cpu/o3/impl.hh\n",
74             decodeWidth, static_cast<int>(Impl::MaxWidth));
75
76    // @todo: Make into a parameter
77    skidBufferMax = (fetchToDecodeDelay + 1) *  params->fetchWidth;
78    for (int tid = 0; tid < Impl::MaxThreads; tid++) {
79        stalls[tid] = {false};
80        decodeStatus[tid] = Idle;
81        bdelayDoneSeqNum[tid] = 0;
82        squashInst[tid] = nullptr;
83        squashAfterDelaySlot[tid] = 0;
84    }
85}
86
87template<class Impl>
88void
89DefaultDecode<Impl>::startupStage()
90{
91    resetStage();
92}
93
94template<class Impl>
95void
96DefaultDecode<Impl>::clearStates(ThreadID tid)
97{
98    decodeStatus[tid] = Idle;
99    stalls[tid].rename = false;
100}
101
102template<class Impl>
103void
104DefaultDecode<Impl>::resetStage()
105{
106    _status = Inactive;
107
108    // Setup status, make sure stall signals are clear.
109    for (ThreadID tid = 0; tid < numThreads; ++tid) {
110        decodeStatus[tid] = Idle;
111
112        stalls[tid].rename = false;
113    }
114}
115
116template <class Impl>
117std::string
118DefaultDecode<Impl>::name() const
119{
120    return cpu->name() + ".decode";
121}
122
123template <class Impl>
124void
125DefaultDecode<Impl>::regStats()
126{
127    decodeIdleCycles
128        .name(name() + ".IdleCycles")
129        .desc("Number of cycles decode is idle")
130        .prereq(decodeIdleCycles);
131    decodeBlockedCycles
132        .name(name() + ".BlockedCycles")
133        .desc("Number of cycles decode is blocked")
134        .prereq(decodeBlockedCycles);
135    decodeRunCycles
136        .name(name() + ".RunCycles")
137        .desc("Number of cycles decode is running")
138        .prereq(decodeRunCycles);
139    decodeUnblockCycles
140        .name(name() + ".UnblockCycles")
141        .desc("Number of cycles decode is unblocking")
142        .prereq(decodeUnblockCycles);
143    decodeSquashCycles
144        .name(name() + ".SquashCycles")
145        .desc("Number of cycles decode is squashing")
146        .prereq(decodeSquashCycles);
147    decodeBranchResolved
148        .name(name() + ".BranchResolved")
149        .desc("Number of times decode resolved a branch")
150        .prereq(decodeBranchResolved);
151    decodeBranchMispred
152        .name(name() + ".BranchMispred")
153        .desc("Number of times decode detected a branch misprediction")
154        .prereq(decodeBranchMispred);
155    decodeControlMispred
156        .name(name() + ".ControlMispred")
157        .desc("Number of times decode detected an instruction incorrectly"
158              " predicted as a control")
159        .prereq(decodeControlMispred);
160    decodeDecodedInsts
161        .name(name() + ".DecodedInsts")
162        .desc("Number of instructions handled by decode")
163        .prereq(decodeDecodedInsts);
164    decodeSquashedInsts
165        .name(name() + ".SquashedInsts")
166        .desc("Number of squashed instructions handled by decode")
167        .prereq(decodeSquashedInsts);
168}
169
170template<class Impl>
171void
172DefaultDecode<Impl>::setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr)
173{
174    timeBuffer = tb_ptr;
175
176    // Setup wire to write information back to fetch.
177    toFetch = timeBuffer->getWire(0);
178
179    // Create wires to get information from proper places in time buffer.
180    fromRename = timeBuffer->getWire(-renameToDecodeDelay);
181    fromIEW = timeBuffer->getWire(-iewToDecodeDelay);
182    fromCommit = timeBuffer->getWire(-commitToDecodeDelay);
183}
184
185template<class Impl>
186void
187DefaultDecode<Impl>::setDecodeQueue(TimeBuffer<DecodeStruct> *dq_ptr)
188{
189    decodeQueue = dq_ptr;
190
191    // Setup wire to write information to proper place in decode queue.
192    toRename = decodeQueue->getWire(0);
193}
194
195template<class Impl>
196void
197DefaultDecode<Impl>::setFetchQueue(TimeBuffer<FetchStruct> *fq_ptr)
198{
199    fetchQueue = fq_ptr;
200
201    // Setup wire to read information from fetch queue.
202    fromFetch = fetchQueue->getWire(-fetchToDecodeDelay);
203}
204
205template<class Impl>
206void
207DefaultDecode<Impl>::setActiveThreads(std::list<ThreadID> *at_ptr)
208{
209    activeThreads = at_ptr;
210}
211
212template <class Impl>
213void
214DefaultDecode<Impl>::drainSanityCheck() const
215{
216    for (ThreadID tid = 0; tid < numThreads; ++tid) {
217        assert(insts[tid].empty());
218        assert(skidBuffer[tid].empty());
219    }
220}
221
222template <class Impl>
223bool
224DefaultDecode<Impl>::isDrained() const
225{
226    for (ThreadID tid = 0; tid < numThreads; ++tid) {
227        if (!insts[tid].empty() || !skidBuffer[tid].empty() ||
228                (decodeStatus[tid] != Running && decodeStatus[tid] != Idle))
229            return false;
230    }
231    return true;
232}
233
234template<class Impl>
235bool
236DefaultDecode<Impl>::checkStall(ThreadID tid) const
237{
238    bool ret_val = false;
239
240    if (stalls[tid].rename) {
241        DPRINTF(Decode,"[tid:%i] Stall fom Rename stage detected.\n", tid);
242        ret_val = true;
243    }
244
245    return ret_val;
246}
247
248template<class Impl>
249inline bool
250DefaultDecode<Impl>::fetchInstsValid()
251{
252    return fromFetch->size > 0;
253}
254
255template<class Impl>
256bool
257DefaultDecode<Impl>::block(ThreadID tid)
258{
259    DPRINTF(Decode, "[tid:%i] Blocking.\n", tid);
260
261    // Add the current inputs to the skid buffer so they can be
262    // reprocessed when this stage unblocks.
263    skidInsert(tid);
264
265    // If the decode status is blocked or unblocking then decode has not yet
266    // signalled fetch to unblock. In that case, there is no need to tell
267    // fetch to block.
268    if (decodeStatus[tid] != Blocked) {
269        // Set the status to Blocked.
270        decodeStatus[tid] = Blocked;
271
272        if (toFetch->decodeUnblock[tid]) {
273            toFetch->decodeUnblock[tid] = false;
274        } else {
275            toFetch->decodeBlock[tid] = true;
276            wroteToTimeBuffer = true;
277        }
278
279        return true;
280    }
281
282    return false;
283}
284
285template<class Impl>
286bool
287DefaultDecode<Impl>::unblock(ThreadID tid)
288{
289    // Decode is done unblocking only if the skid buffer is empty.
290    if (skidBuffer[tid].empty()) {
291        DPRINTF(Decode, "[tid:%i] Done unblocking.\n", tid);
292        toFetch->decodeUnblock[tid] = true;
293        wroteToTimeBuffer = true;
294
295        decodeStatus[tid] = Running;
296        return true;
297    }
298
299    DPRINTF(Decode, "[tid:%i] Currently unblocking.\n", tid);
300
301    return false;
302}
303
304template<class Impl>
305void
306DefaultDecode<Impl>::squash(const DynInstPtr &inst, ThreadID tid)
307{
308    DPRINTF(Decode, "[tid:%i] [sn:%llu] Squashing due to incorrect branch "
309            "prediction detected at decode.\n", tid, inst->seqNum);
310
311    // Send back mispredict information.
312    toFetch->decodeInfo[tid].branchMispredict = true;
313    toFetch->decodeInfo[tid].predIncorrect = true;
314    toFetch->decodeInfo[tid].mispredictInst = inst;
315    toFetch->decodeInfo[tid].squash = true;
316    toFetch->decodeInfo[tid].doneSeqNum = inst->seqNum;
317    toFetch->decodeInfo[tid].nextPC = inst->branchTarget();
318    toFetch->decodeInfo[tid].branchTaken = inst->pcState().branching();
319    toFetch->decodeInfo[tid].squashInst = inst;
320    if (toFetch->decodeInfo[tid].mispredictInst->isUncondCtrl()) {
321            toFetch->decodeInfo[tid].branchTaken = true;
322    }
323
324    InstSeqNum squash_seq_num = inst->seqNum;
325
326    // Might have to tell fetch to unblock.
327    if (decodeStatus[tid] == Blocked ||
328        decodeStatus[tid] == Unblocking) {
329        toFetch->decodeUnblock[tid] = 1;
330    }
331
332    // Set status to squashing.
333    decodeStatus[tid] = Squashing;
334
335    for (int i=0; i<fromFetch->size; i++) {
336        if (fromFetch->insts[i]->threadNumber == tid &&
337            fromFetch->insts[i]->seqNum > squash_seq_num) {
338            fromFetch->insts[i]->setSquashed();
339        }
340    }
341
342    // Clear the instruction list and skid buffer in case they have any
343    // insts in them.
344    while (!insts[tid].empty()) {
345        insts[tid].pop();
346    }
347
348    while (!skidBuffer[tid].empty()) {
349        skidBuffer[tid].pop();
350    }
351
352    // Squash instructions up until this one
353    cpu->removeInstsUntil(squash_seq_num, tid);
354}
355
356template<class Impl>
357unsigned
358DefaultDecode<Impl>::squash(ThreadID tid)
359{
360    DPRINTF(Decode, "[tid:%i] Squashing.\n",tid);
361
362    if (decodeStatus[tid] == Blocked ||
363        decodeStatus[tid] == Unblocking) {
364        if (FullSystem) {
365            toFetch->decodeUnblock[tid] = 1;
366        } else {
367            // In syscall emulation, we can have both a block and a squash due
368            // to a syscall in the same cycle.  This would cause both signals
369            // to be high.  This shouldn't happen in full system.
370            // @todo: Determine if this still happens.
371            if (toFetch->decodeBlock[tid])
372                toFetch->decodeBlock[tid] = 0;
373            else
374                toFetch->decodeUnblock[tid] = 1;
375        }
376    }
377
378    // Set status to squashing.
379    decodeStatus[tid] = Squashing;
380
381    // Go through incoming instructions from fetch and squash them.
382    unsigned squash_count = 0;
383
384    for (int i=0; i<fromFetch->size; i++) {
385        if (fromFetch->insts[i]->threadNumber == tid) {
386            fromFetch->insts[i]->setSquashed();
387            squash_count++;
388        }
389    }
390
391    // Clear the instruction list and skid buffer in case they have any
392    // insts in them.
393    while (!insts[tid].empty()) {
394        insts[tid].pop();
395    }
396
397    while (!skidBuffer[tid].empty()) {
398        skidBuffer[tid].pop();
399    }
400
401    return squash_count;
402}
403
404template<class Impl>
405void
406DefaultDecode<Impl>::skidInsert(ThreadID tid)
407{
408    DynInstPtr inst = NULL;
409
410    while (!insts[tid].empty()) {
411        inst = insts[tid].front();
412
413        insts[tid].pop();
414
415        assert(tid == inst->threadNumber);
416
417        skidBuffer[tid].push(inst);
418
419        DPRINTF(Decode,"Inserting [tid:%d][sn:%lli] PC: %s into decode skidBuffer %i\n",
420                inst->threadNumber, inst->seqNum, inst->pcState(), skidBuffer[tid].size());
421    }
422
423    // @todo: Eventually need to enforce this by not letting a thread
424    // fetch past its skidbuffer
425    assert(skidBuffer[tid].size() <= skidBufferMax);
426}
427
428template<class Impl>
429bool
430DefaultDecode<Impl>::skidsEmpty()
431{
432    list<ThreadID>::iterator threads = activeThreads->begin();
433    list<ThreadID>::iterator end = activeThreads->end();
434
435    while (threads != end) {
436        ThreadID tid = *threads++;
437        if (!skidBuffer[tid].empty())
438            return false;
439    }
440
441    return true;
442}
443
444template<class Impl>
445void
446DefaultDecode<Impl>::updateStatus()
447{
448    bool any_unblocking = false;
449
450    list<ThreadID>::iterator threads = activeThreads->begin();
451    list<ThreadID>::iterator end = activeThreads->end();
452
453    while (threads != end) {
454        ThreadID tid = *threads++;
455
456        if (decodeStatus[tid] == Unblocking) {
457            any_unblocking = true;
458            break;
459        }
460    }
461
462    // Decode will have activity if it's unblocking.
463    if (any_unblocking) {
464        if (_status == Inactive) {
465            _status = Active;
466
467            DPRINTF(Activity, "Activating stage.\n");
468
469            cpu->activateStage(O3CPU::DecodeIdx);
470        }
471    } else {
472        // If it's not unblocking, then decode will not have any internal
473        // activity.  Switch it to inactive.
474        if (_status == Active) {
475            _status = Inactive;
476            DPRINTF(Activity, "Deactivating stage.\n");
477
478            cpu->deactivateStage(O3CPU::DecodeIdx);
479        }
480    }
481}
482
483template <class Impl>
484void
485DefaultDecode<Impl>::sortInsts()
486{
487    int insts_from_fetch = fromFetch->size;
488    for (int i = 0; i < insts_from_fetch; ++i) {
489        insts[fromFetch->insts[i]->threadNumber].push(fromFetch->insts[i]);
490    }
491}
492
493template<class Impl>
494void
495DefaultDecode<Impl>::readStallSignals(ThreadID tid)
496{
497    if (fromRename->renameBlock[tid]) {
498        stalls[tid].rename = true;
499    }
500
501    if (fromRename->renameUnblock[tid]) {
502        assert(stalls[tid].rename);
503        stalls[tid].rename = false;
504    }
505}
506
507template <class Impl>
508bool
509DefaultDecode<Impl>::checkSignalsAndUpdate(ThreadID tid)
510{
511    // Check if there's a squash signal, squash if there is.
512    // Check stall signals, block if necessary.
513    // If status was blocked
514    //     Check if stall conditions have passed
515    //         if so then go to unblocking
516    // If status was Squashing
517    //     check if squashing is not high.  Switch to running this cycle.
518
519    // Update the per thread stall statuses.
520    readStallSignals(tid);
521
522    // Check squash signals from commit.
523    if (fromCommit->commitInfo[tid].squash) {
524
525        DPRINTF(Decode, "[tid:%i] Squashing instructions due to squash "
526                "from commit.\n", tid);
527
528        squash(tid);
529
530        return true;
531    }
532
533    if (checkStall(tid)) {
534        return block(tid);
535    }
536
537    if (decodeStatus[tid] == Blocked) {
538        DPRINTF(Decode, "[tid:%i] Done blocking, switching to unblocking.\n",
539                tid);
540
541        decodeStatus[tid] = Unblocking;
542
543        unblock(tid);
544
545        return true;
546    }
547
548    if (decodeStatus[tid] == Squashing) {
549        // Switch status to running if decode isn't being told to block or
550        // squash this cycle.
551        DPRINTF(Decode, "[tid:%i] Done squashing, switching to running.\n",
552                tid);
553
554        decodeStatus[tid] = Running;
555
556        return false;
557    }
558
559    // If we've reached this point, we have not gotten any signals that
560    // cause decode to change its status.  Decode remains the same as before.
561    return false;
562}
563
564template<class Impl>
565void
566DefaultDecode<Impl>::tick()
567{
568    wroteToTimeBuffer = false;
569
570    bool status_change = false;
571
572    toRenameIndex = 0;
573
574    list<ThreadID>::iterator threads = activeThreads->begin();
575    list<ThreadID>::iterator end = activeThreads->end();
576
577    sortInsts();
578
579    //Check stall and squash signals.
580    while (threads != end) {
581        ThreadID tid = *threads++;
582
583        DPRINTF(Decode,"Processing [tid:%i]\n",tid);
584        status_change =  checkSignalsAndUpdate(tid) || status_change;
585
586        decode(status_change, tid);
587    }
588
589    if (status_change) {
590        updateStatus();
591    }
592
593    if (wroteToTimeBuffer) {
594        DPRINTF(Activity, "Activity this cycle.\n");
595
596        cpu->activityThisCycle();
597    }
598}
599
600template<class Impl>
601void
602DefaultDecode<Impl>::decode(bool &status_change, ThreadID tid)
603{
604    // If status is Running or idle,
605    //     call decodeInsts()
606    // If status is Unblocking,
607    //     buffer any instructions coming from fetch
608    //     continue trying to empty skid buffer
609    //     check if stall conditions have passed
610
611    if (decodeStatus[tid] == Blocked) {
612        ++decodeBlockedCycles;
613    } else if (decodeStatus[tid] == Squashing) {
614        ++decodeSquashCycles;
615    }
616
617    // Decode should try to decode as many instructions as its bandwidth
618    // will allow, as long as it is not currently blocked.
619    if (decodeStatus[tid] == Running ||
620        decodeStatus[tid] == Idle) {
621        DPRINTF(Decode, "[tid:%i] Not blocked, so attempting to run "
622                "stage.\n",tid);
623
624        decodeInsts(tid);
625    } else if (decodeStatus[tid] == Unblocking) {
626        // Make sure that the skid buffer has something in it if the
627        // status is unblocking.
628        assert(!skidsEmpty());
629
630        // If the status was unblocking, then instructions from the skid
631        // buffer were used.  Remove those instructions and handle
632        // the rest of unblocking.
633        decodeInsts(tid);
634
635        if (fetchInstsValid()) {
636            // Add the current inputs to the skid buffer so they can be
637            // reprocessed when this stage unblocks.
638            skidInsert(tid);
639        }
640
641        status_change = unblock(tid) || status_change;
642    }
643}
644
645template <class Impl>
646void
647DefaultDecode<Impl>::decodeInsts(ThreadID tid)
648{
649    // Instructions can come either from the skid buffer or the list of
650    // instructions coming from fetch, depending on decode's status.
651    int insts_available = decodeStatus[tid] == Unblocking ?
652        skidBuffer[tid].size() : insts[tid].size();
653
654    if (insts_available == 0) {
655        DPRINTF(Decode, "[tid:%i] Nothing to do, breaking out"
656                " early.\n",tid);
657        // Should I change the status to idle?
658        ++decodeIdleCycles;
659        return;
660    } else if (decodeStatus[tid] == Unblocking) {
661        DPRINTF(Decode, "[tid:%i] Unblocking, removing insts from skid "
662                "buffer.\n",tid);
663        ++decodeUnblockCycles;
664    } else if (decodeStatus[tid] == Running) {
665        ++decodeRunCycles;
666    }
667
668    std::queue<DynInstPtr>
669        &insts_to_decode = decodeStatus[tid] == Unblocking ?
670        skidBuffer[tid] : insts[tid];
671
672    DPRINTF(Decode, "[tid:%i] Sending instruction to rename.\n",tid);
673
674    while (insts_available > 0 && toRenameIndex < decodeWidth) {
675        assert(!insts_to_decode.empty());
676
677        DynInstPtr inst = std::move(insts_to_decode.front());
678
679        insts_to_decode.pop();
680
681        DPRINTF(Decode, "[tid:%i] Processing instruction [sn:%lli] with "
682                "PC %s\n", tid, inst->seqNum, inst->pcState());
683
684        if (inst->isSquashed()) {
685            DPRINTF(Decode, "[tid:%i] Instruction %i with PC %s is "
686                    "squashed, skipping.\n",
687                    tid, inst->seqNum, inst->pcState());
688
689            ++decodeSquashedInsts;
690
691            --insts_available;
692
693            continue;
694        }
695
696        // Also check if instructions have no source registers.  Mark
697        // them as ready to issue at any time.  Not sure if this check
698        // should exist here or at a later stage; however it doesn't matter
699        // too much for function correctness.
700        if (inst->numSrcRegs() == 0) {
701            inst->setCanIssue();
702        }
703
704        // This current instruction is valid, so add it into the decode
705        // queue.  The next instruction may not be valid, so check to
706        // see if branches were predicted correctly.
707        toRename->insts[toRenameIndex] = inst;
708
709        ++(toRename->size);
710        ++toRenameIndex;
711        ++decodeDecodedInsts;
712        --insts_available;
713
714#if TRACING_ON
715        if (DTRACE(O3PipeView)) {
716            inst->decodeTick = curTick() - inst->fetchTick;
717        }
718#endif
719
720        // Ensure that if it was predicted as a branch, it really is a
721        // branch.
722        if (inst->readPredTaken() && !inst->isControl()) {
723            panic("Instruction predicted as a branch!");
724
725            ++decodeControlMispred;
726
727            // Might want to set some sort of boolean and just do
728            // a check at the end
729            squash(inst, inst->threadNumber);
730
731            break;
732        }
733
734        // Go ahead and compute any PC-relative branches.
735        // This includes direct unconditional control and
736        // direct conditional control that is predicted taken.
737        if (inst->isDirectCtrl() &&
738           (inst->isUncondCtrl() || inst->readPredTaken()))
739        {
740            ++decodeBranchResolved;
741
742            if (!(inst->branchTarget() == inst->readPredTarg())) {
743                ++decodeBranchMispred;
744
745                // Might want to set some sort of boolean and just do
746                // a check at the end
747                squash(inst, inst->threadNumber);
748                TheISA::PCState target = inst->branchTarget();
749
750                DPRINTF(Decode,
751                        "[tid:%i] [sn:%llu] "
752                        "Updating predictions: PredPC: %s\n",
753                        tid, inst->seqNum, target);
754                //The micro pc after an instruction level branch should be 0
755                inst->setPredTarg(target);
756                break;
757            }
758        }
759    }
760
761    // If we didn't process all instructions, then we will need to block
762    // and put all those instructions into the skid buffer.
763    if (!insts_to_decode.empty()) {
764        block(tid);
765    }
766
767    // Record that decode has written to the time buffer for activity
768    // tracking.
769    if (toRenameIndex) {
770        wroteToTimeBuffer = true;
771    }
772}
773
774#endif//__CPU_O3_DECODE_IMPL_HH__
775