2 * Copyright (c) 2013-2014 ARM Limited
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.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * Authors: Andrew Bardsley
40 #include "cpu/minor/pipe_data.hh"
46 operator <<(std::ostream
&os
, BranchData::Reason reason
)
50 case BranchData::NoBranch
:
53 case BranchData::UnpredictedBranch
:
54 os
<< "UnpredictedBranch";
56 case BranchData::BranchPrediction
:
57 os
<< "BranchPrediction";
59 case BranchData::CorrectlyPredictedBranch
:
60 os
<< "CorrectlyPredictedBranch";
62 case BranchData::BadlyPredictedBranch
:
63 os
<< "BadlyPredictedBranch";
65 case BranchData::BadlyPredictedBranchTarget
:
66 os
<< "BadlyPredictedBranchTarget";
68 case BranchData::Interrupt
:
71 case BranchData::SuspendThread
:
72 os
<< "SuspendThread";
74 case BranchData::HaltFetch
:
83 BranchData::isStreamChange(const BranchData::Reason reason
)
89 /* No change of stream (see the enum comment in pipe_data.hh) */
91 case CorrectlyPredictedBranch
:
95 /* Change of stream (Fetch1 should act on) */
96 case UnpredictedBranch
:
97 case BranchPrediction
:
98 case BadlyPredictedBranchTarget
:
99 case BadlyPredictedBranch
:
111 BranchData::isBranch(const BranchData::Reason reason
)
117 /* No change of stream (see the enum comment in pipe_data.hh) */
119 case CorrectlyPredictedBranch
:
126 /* Change of stream (Fetch1 should act on) */
127 case UnpredictedBranch
:
128 case BranchPrediction
:
129 case BadlyPredictedBranchTarget
:
130 case BadlyPredictedBranch
:
139 BranchData::reportData(std::ostream
&os
) const
145 << ';' << newStreamSeqNum
<< '.' << newPredictionSeqNum
146 << ";0x" << std::hex
<< target
.instAddr() << std::dec
148 inst
->reportData(os
);
153 operator <<(std::ostream
&os
, const BranchData
&branch
)
155 os
<< branch
.reason
<< " target: 0x"
156 << std::hex
<< branch
.target
.instAddr() << std::dec
157 << ' ' << *branch
.inst
158 << ' ' << branch
.newStreamSeqNum
<< "(stream)."
159 << branch
.newPredictionSeqNum
<< "(pred)";
165 ForwardLineData::setFault(Fault fault_
)
173 ForwardLineData::allocateLine(unsigned int width_
)
181 line
= new uint8_t[width_
];
185 ForwardLineData::adoptPacketData(Packet
*packet
)
187 this->packet
= packet
;
188 lineWidth
= packet
->req
->getSize();
194 line
= packet
->getPtr
<uint8_t>();
198 ForwardLineData::freeLine()
200 /* Only free lines in non-faulting, non-bubble lines */
201 if (!isFault() && !isBubble()) {
203 /* If packet is not NULL then the line must belong to the packet so
204 * we don't need to separately deallocate the line */
216 ForwardLineData::reportData(std::ostream
&os
) const
220 else if (fault
!= NoFault
)
226 ForwardInstData::ForwardInstData(unsigned int width
, ThreadID tid
) :
227 numInsts(width
), threadId(tid
)
232 ForwardInstData::ForwardInstData(const ForwardInstData
&src
)
238 ForwardInstData::operator =(const ForwardInstData
&src
)
240 numInsts
= src
.numInsts
;
242 for (unsigned int i
= 0; i
< src
.numInsts
; i
++)
243 insts
[i
] = src
.insts
[i
];
249 ForwardInstData::isBubble() const
251 return numInsts
== 0 || insts
[0]->isBubble();
255 ForwardInstData::bubbleFill()
257 for (unsigned int i
= 0; i
< numInsts
; i
++)
258 insts
[i
] = MinorDynInst::bubble();
262 ForwardInstData::resize(unsigned int width
)
264 assert(width
< MAX_FORWARD_INSTS
);
271 ForwardInstData::reportData(std::ostream
&os
) const
279 while (i
!= numInsts
) {
280 insts
[i
]->reportData(os
);