2 * Copyright (c) 2009 The University of Edinburgh
3 * Copyright (c) 2021 IBM Corporation
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "arch/power/insts/mem.hh"
32 #include "base/loader/symtab.hh"
34 using namespace PowerISA
;
37 MemOp::generateDisassembly(Addr pc
, const Loader::SymbolTable
*symtab
) const
39 return csprintf("%-10s", mnemonic
);
44 MemDispOp::generateDisassembly(
45 Addr pc
, const Loader::SymbolTable
*symtab
) const
49 ccprintf(ss
, "%-10s ", mnemonic
);
51 // Print the destination only for a load
52 if (!flags
[IsStore
]) {
53 if (_numDestRegs
> 0) {
55 // If the instruction updates the source register with the
56 // EA, then this source register is placed in position 0,
57 // therefore we print the last destination register.
58 printReg(ss
, destRegIdx(_numDestRegs
-1));
62 // Print the data register for a store
64 if (_numSrcRegs
> 0) {
65 printReg(ss
, srcRegIdx(0));
69 // Print the displacement
73 // Print the address register for a load
74 if (!flags
[IsStore
]) {
75 if (_numSrcRegs
> 0) {
76 printReg(ss
, srcRegIdx(0));
79 // The address register is skipped if it is R0
85 // Print the address register for a store
87 if (_numSrcRegs
> 1) {
88 printReg(ss
, srcRegIdx(1));
91 // The address register is skipped if it is R0
104 MemDispShiftOp::generateDisassembly(
105 Addr pc
, const Loader::SymbolTable
*symtab
) const
107 std::stringstream ss
;
109 ccprintf(ss
, "%-10s ", mnemonic
);
111 // Print the destination only for a load
112 if (!flags
[IsStore
]) {
113 if (_numDestRegs
> 0) {
115 // If the instruction updates the source register with the
116 // EA, then this source register is placed in position 0,
117 // therefore we print the last destination register.
118 printReg(ss
, destRegIdx(_numDestRegs
-1));
122 // Print the data register for a store
124 if (_numSrcRegs
> 0) {
125 printReg(ss
, srcRegIdx(0));
129 // Print the displacement
130 ss
<< ", " << (disp
<< 2);
133 // Print the address register for a load
134 if (!flags
[IsStore
]) {
135 if (_numSrcRegs
> 0) {
136 printReg(ss
, srcRegIdx(0));
139 // The address register is skipped if it is R0
145 // Print the address register for a store
147 if (_numSrcRegs
> 1) {
148 printReg(ss
, srcRegIdx(1));
151 // The address register is skipped if it is R0
164 MemIndexOp::generateDisassembly(
165 Addr pc
, const Loader::SymbolTable
*symtab
) const
167 std::stringstream ss
;
169 ccprintf(ss
, "%-10s ", mnemonic
);
171 // Print the destination only for a load
172 if (!flags
[IsStore
]) {
173 if (_numDestRegs
> 0) {
175 // If the instruction updates the source register with the
176 // EA, then this source register is placed in position 0,
177 // therefore we print the last destination register.
178 printReg(ss
, destRegIdx(_numDestRegs
-1));
182 // Print the data register for a store
184 if (_numSrcRegs
> 0) {
185 printReg(ss
, srcRegIdx(0));
191 // Print the address registers for a load
192 if (!flags
[IsStore
]) {
193 if (_numSrcRegs
> 1) {
194 printReg(ss
, srcRegIdx(0));
196 printReg(ss
, srcRegIdx(1));
199 // The first address register is skipped if it is R0
200 else if (_numSrcRegs
> 0) {
202 printReg(ss
, srcRegIdx(0));
206 // Print the address registers for a store
208 if (_numSrcRegs
> 2) {
209 printReg(ss
, srcRegIdx(1));
211 printReg(ss
, srcRegIdx(2));
214 // The first address register is skipped if it is R0
215 else if (_numSrcRegs
> 1) {
217 printReg(ss
, srcRegIdx(1));