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
43 #include "arch/isa.hh"
44 #include "arch/registers.hh"
45 #include "cpu/minor/dyn_inst.hh"
46 #include "cpu/minor/trace.hh"
47 #include "cpu/base.hh"
48 #include "cpu/reg_class.hh"
49 #include "debug/MinorExecute.hh"
50 #include "enums/OpClass.hh"
56 operator <<(std::ostream
&os
, const InstId
&id
)
58 os
<< id
.threadId
<< '/' << id
.streamSeqNum
<< '.'
59 << id
.predictionSeqNum
<< '/' << id
.lineSeqNum
;
61 /* Not all structures have fetch and exec sequence numbers */
62 if (id
.fetchSeqNum
!= 0) {
63 os
<< '/' << id
.fetchSeqNum
;
64 if (id
.execSeqNum
!= 0)
65 os
<< '.' << id
.execSeqNum
;
71 MinorDynInstPtr
MinorDynInst::bubbleInst
= NULL
;
77 bubbleInst
= new MinorDynInst();
78 assert(bubbleInst
->isBubble());
79 /* Make bubbleInst immortal */
85 MinorDynInst::isLastOpInInst() const
88 return !(staticInst
->isMicroop() && !staticInst
->isLastMicroop());
92 MinorDynInst::isNoCostInst() const
94 return isInst() && staticInst
->opClass() == No_OpClass
;
98 MinorDynInst::reportData(std::ostream
&os
) const
109 operator <<(std::ostream
&os
, const MinorDynInst
&inst
)
111 os
<< inst
.id
<< " pc: 0x"
112 << std::hex
<< inst
.pc
.instAddr() << std::dec
<< " (";
115 os
<< "fault: \"" << inst
.fault
->name() << '"';
116 else if (inst
.staticInst
)
117 os
<< inst
.staticInst
->getName();
126 /** Print a register in the form r<n>, f<n>, m<n>(<name>), z for integer,
127 * float, misc and zero registers given an 'architectural register number' */
129 printRegName(std::ostream
&os
, TheISA::RegIndex reg
)
131 RegClass reg_class
= regIdxToClass(reg
);
137 TheISA::RegIndex misc_reg
= reg
- TheISA::Misc_Reg_Base
;
139 /* This is an ugly test because not all archs. have miscRegName */
140 #if THE_ISA == ARM_ISA
141 os
<< 'm' << misc_reg
<< '(' << TheISA::miscRegName
[misc_reg
] <<
144 os
<< 'n' << misc_reg
;
149 os
<< 'f' << static_cast<unsigned int>(reg
- TheISA::FP_Reg_Base
);
152 if (reg
== TheISA::ZeroReg
) {
155 os
<< 'r' << static_cast<unsigned int>(reg
);
159 os
<< 'c' << static_cast<unsigned int>(reg
- TheISA::CC_Reg_Base
);
164 MinorDynInst::minorTraceInst(const Named
&named_object
) const
167 MINORINST(&named_object
, "id=F;%s addr=0x%x fault=\"%s\"\n",
168 id
, pc
.instAddr(), fault
->name());
170 unsigned int num_src_regs
= staticInst
->numSrcRegs();
171 unsigned int num_dest_regs
= staticInst
->numDestRegs();
173 std::ostringstream regs_str
;
175 /* Format lists of src and dest registers for microops and
176 * 'full' instructions */
177 if (!staticInst
->isMacroop()) {
178 regs_str
<< " srcRegs=";
180 unsigned int src_reg
= 0;
181 while (src_reg
< num_src_regs
) {
182 printRegName(regs_str
, staticInst
->srcRegIdx(src_reg
));
185 if (src_reg
!= num_src_regs
)
189 regs_str
<< " destRegs=";
191 unsigned int dest_reg
= 0;
192 while (dest_reg
< num_dest_regs
) {
193 printRegName(regs_str
, staticInst
->destRegIdx(dest_reg
));
196 if (dest_reg
!= num_dest_regs
)
200 #if THE_ISA == ARM_ISA
201 regs_str
<< " extMachInst=" << std::hex
<< std::setw(16)
202 << std::setfill('0') << staticInst
->machInst
<< std::dec
;
206 std::ostringstream flags
;
207 staticInst
->printFlags(flags
, " ");
209 MINORINST(&named_object
, "id=%s addr=0x%x inst=\"%s\" class=%s"
210 " flags=\"%s\"%s%s\n",
212 (staticInst
->opClass() == No_OpClass
?
213 "(invalid)" : staticInst
->disassemble(0,NULL
)),
214 Enums::OpClassStrings
[staticInst
->opClass()],
217 (predictedTaken
? " predictedTaken" : ""));
221 MinorDynInst::~MinorDynInst()