087b718d36ce0836fc999d0955573fec946d7d11
2 * Copyright (c) 2013-2014, 2016,2018 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/dyn_inst.hh"
45 #include "arch/isa.hh"
46 #include "arch/registers.hh"
47 #include "cpu/base.hh"
48 #include "cpu/minor/trace.hh"
49 #include "cpu/reg_class.hh"
50 #include "debug/MinorExecute.hh"
51 #include "enums/OpClass.hh"
56 const InstSeqNum
InstId::firstStreamSeqNum
;
57 const InstSeqNum
InstId::firstPredictionSeqNum
;
58 const InstSeqNum
InstId::firstLineSeqNum
;
59 const InstSeqNum
InstId::firstFetchSeqNum
;
60 const InstSeqNum
InstId::firstExecSeqNum
;
63 operator <<(std::ostream
&os
, const InstId
&id
)
65 os
<< id
.threadId
<< '/' << id
.streamSeqNum
<< '.'
66 << id
.predictionSeqNum
<< '/' << id
.lineSeqNum
;
68 /* Not all structures have fetch and exec sequence numbers */
69 if (id
.fetchSeqNum
!= 0) {
70 os
<< '/' << id
.fetchSeqNum
;
71 if (id
.execSeqNum
!= 0)
72 os
<< '.' << id
.execSeqNum
;
78 MinorDynInstPtr
MinorDynInst::bubbleInst
= NULL
;
84 bubbleInst
= new MinorDynInst();
85 assert(bubbleInst
->isBubble());
86 /* Make bubbleInst immortal */
92 MinorDynInst::isLastOpInInst() const
95 return !(staticInst
->isMicroop() && !staticInst
->isLastMicroop());
99 MinorDynInst::isNoCostInst() const
101 return isInst() && staticInst
->opClass() == No_OpClass
;
105 MinorDynInst::reportData(std::ostream
&os
) const
111 else if (translationFault
!= NoFault
)
118 operator <<(std::ostream
&os
, const MinorDynInst
&inst
)
120 os
<< inst
.id
<< " pc: 0x"
121 << std::hex
<< inst
.pc
.instAddr() << std::dec
<< " (";
124 os
<< "fault: \"" << inst
.fault
->name() << '"';
125 else if (inst
.translationFault
!= NoFault
)
126 os
<< "translation fault: \"" << inst
.translationFault
->name() << '"';
127 else if (inst
.staticInst
)
128 os
<< inst
.staticInst
->getName();
137 /** Print a register in the form r<n>, f<n>, m<n>(<name>), z for integer,
138 * float, misc and zero registers given an 'architectural register number' */
140 printRegName(std::ostream
&os
, const RegId
& reg
)
142 switch (reg
.classValue())
146 RegIndex misc_reg
= reg
.index();
148 /* This is an ugly test because not all archs. have miscRegName */
149 #if THE_ISA == ARM_ISA
150 os
<< 'm' << misc_reg
<< '(' << TheISA::miscRegName
[misc_reg
] <<
153 os
<< 'n' << misc_reg
;
158 os
<< 'f' << static_cast<unsigned int>(reg
.index());
161 os
<< 'v' << static_cast<unsigned int>(reg
.index());
164 os
<< 'v' << static_cast<unsigned int>(reg
.index()) << '[' <<
165 static_cast<unsigned int>(reg
.elemIndex()) << ']';
168 if (reg
.isZeroReg()) {
171 os
<< 'r' << static_cast<unsigned int>(reg
.index());
175 os
<< 'c' << static_cast<unsigned int>(reg
.index());
178 panic("Unknown register class: %d", (int)reg
.classValue());
183 MinorDynInst::minorTraceInst(const Named
&named_object
) const
186 MINORINST(&named_object
, "id=F;%s addr=0x%x fault=\"%s\"\n",
187 id
, pc
.instAddr(), fault
->name());
189 unsigned int num_src_regs
= staticInst
->numSrcRegs();
190 unsigned int num_dest_regs
= staticInst
->numDestRegs();
192 std::ostringstream regs_str
;
194 /* Format lists of src and dest registers for microops and
195 * 'full' instructions */
196 if (!staticInst
->isMacroop()) {
197 regs_str
<< " srcRegs=";
199 unsigned int src_reg
= 0;
200 while (src_reg
< num_src_regs
) {
201 printRegName(regs_str
, staticInst
->srcRegIdx(src_reg
));
204 if (src_reg
!= num_src_regs
)
208 regs_str
<< " destRegs=";
210 unsigned int dest_reg
= 0;
211 while (dest_reg
< num_dest_regs
) {
212 printRegName(regs_str
, staticInst
->destRegIdx(dest_reg
));
215 if (dest_reg
!= num_dest_regs
)
219 #if THE_ISA == ARM_ISA
220 regs_str
<< " extMachInst=" << std::hex
<< std::setw(16)
221 << std::setfill('0') << staticInst
->machInst
<< std::dec
;
225 std::ostringstream flags
;
226 staticInst
->printFlags(flags
, " ");
228 MINORINST(&named_object
, "id=%s addr=0x%x inst=\"%s\" class=%s"
229 " flags=\"%s\"%s%s\n",
231 (staticInst
->opClass() == No_OpClass
?
232 "(invalid)" : staticInst
->disassemble(0,NULL
)),
233 Enums::OpClassStrings
[staticInst
->opClass()],
236 (predictedTaken
? " predictedTaken" : ""));
240 MinorDynInst::~MinorDynInst()