2 * Copyright (c) 2009 The University of Edinburgh
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Timothy M. Jones
31 #include "arch/power/insts/integer.hh"
34 using namespace PowerISA
;
37 IntOp::generateDisassembly(Addr pc
, const SymbolTable
*symtab
) const
40 bool printDest
= true;
41 bool printSrcs
= true;
42 bool printSecondSrc
= true;
44 // Generate the correct mnemonic
45 string
myMnemonic(mnemonic
);
48 if (!myMnemonic
.compare("or") && _srcRegIdx
[0] == _srcRegIdx
[1]) {
50 printSecondSrc
= false;
51 } else if (!myMnemonic
.compare("mtlr") || !myMnemonic
.compare("cmpi")) {
53 } else if (!myMnemonic
.compare("mflr")) {
57 // Additional characters depending on isa bits being set
58 if (oeSet
) myMnemonic
= myMnemonic
+ "o";
59 if (rcSet
) myMnemonic
= myMnemonic
+ ".";
60 ccprintf(ss
, "%-10s ", myMnemonic
);
62 // Print the first destination only
63 if (_numDestRegs
> 0 && printDest
) {
64 printReg(ss
, _destRegIdx
[0]);
67 // Print the (possibly) two source registers
68 if (_numSrcRegs
> 0 && printSrcs
) {
69 if (_numDestRegs
> 0 && printDest
) {
72 printReg(ss
, _srcRegIdx
[0]);
73 if (_numSrcRegs
> 1 && printSecondSrc
) {
75 printReg(ss
, _srcRegIdx
[1]);
84 IntImmOp::generateDisassembly(Addr pc
, const SymbolTable
*symtab
) const
88 // Generate the correct mnemonic
89 string
myMnemonic(mnemonic
);
92 if (!myMnemonic
.compare("addi") && _numSrcRegs
== 0) {
94 } else if (!myMnemonic
.compare("addis") && _numSrcRegs
== 0) {
97 ccprintf(ss
, "%-10s ", myMnemonic
);
99 // Print the first destination only
100 if (_numDestRegs
> 0) {
101 printReg(ss
, _destRegIdx
[0]);
104 // Print the source register
105 if (_numSrcRegs
> 0) {
106 if (_numDestRegs
> 0) {
109 printReg(ss
, _srcRegIdx
[0]);
112 // Print the immediate value last
113 ss
<< ", " << (int32_t)imm
;
120 IntShiftOp::generateDisassembly(Addr pc
, const SymbolTable
*symtab
) const
124 ccprintf(ss
, "%-10s ", mnemonic
);
126 // Print the first destination only
127 if (_numDestRegs
> 0) {
128 printReg(ss
, _destRegIdx
[0]);
131 // Print the first source register
132 if (_numSrcRegs
> 0) {
133 if (_numDestRegs
> 0) {
136 printReg(ss
, _srcRegIdx
[0]);
147 IntRotateOp::generateDisassembly(Addr pc
, const SymbolTable
*symtab
) const
151 ccprintf(ss
, "%-10s ", mnemonic
);
153 // Print the first destination only
154 if (_numDestRegs
> 0) {
155 printReg(ss
, _destRegIdx
[0]);
158 // Print the first source register
159 if (_numSrcRegs
> 0) {
160 if (_numDestRegs
> 0) {
163 printReg(ss
, _srcRegIdx
[0]);
166 // Print the shift, mask begin and mask end
167 ss
<< ", " << sh
<< ", " << mb
<< ", " << me
;