gem5  v20.1.0.0
mem.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, 2012 ARM Limited
3  * All rights reserved
4  *
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.
13  *
14  * Copyright (c) 2007-2008 The Florida State University
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #include "arch/arm/insts/mem.hh"
42 
43 #include "base/loader/symtab.hh"
44 
45 using namespace std;
46 
47 namespace ArmISA
48 {
49 
50 void
51 MemoryReg::printOffset(std::ostream &os) const
52 {
53  if (!add)
54  os << "-";
55  printIntReg(os, index);
56  if (shiftType != LSL || shiftAmt != 0) {
57  switch (shiftType) {
58  case LSL:
59  ccprintf(os, " LSL #%d", shiftAmt);
60  break;
61  case LSR:
62  ccprintf(os, " LSR #%d", (shiftAmt == 0) ? 32 : shiftAmt);
63  break;
64  case ASR:
65  ccprintf(os, " ASR #%d", (shiftAmt == 0) ? 32 : shiftAmt);
66  break;
67  case ROR:
68  if (shiftAmt == 0) {
69  ccprintf(os, " RRX");
70  } else {
71  ccprintf(os, " ROR #%d", shiftAmt);
72  }
73  break;
74  }
75  }
76 }
77 
78 string
79 RfeOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const
80 {
81  stringstream ss;
82  switch (mode) {
83  case DecrementAfter:
84  printMnemonic(ss, "da");
85  break;
86  case DecrementBefore:
87  printMnemonic(ss, "db");
88  break;
89  case IncrementAfter:
90  printMnemonic(ss, "ia");
91  break;
92  case IncrementBefore:
93  printMnemonic(ss, "ib");
94  break;
95  }
96  printIntReg(ss, base);
97  if (wb) {
98  ss << "!";
99  }
100  return ss.str();
101 }
102 
103 string
104 SrsOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const
105 {
106  stringstream ss;
107  switch (mode) {
108  case DecrementAfter:
109  printMnemonic(ss, "da");
110  break;
111  case DecrementBefore:
112  printMnemonic(ss, "db");
113  break;
114  case IncrementAfter:
115  printMnemonic(ss, "ia");
116  break;
117  case IncrementBefore:
118  printMnemonic(ss, "ib");
119  break;
120  }
121  printIntReg(ss, INTREG_SP);
122  if (wb) {
123  ss << "!";
124  }
125  ss << ", #";
126  switch (regMode) {
127  case MODE_USER:
128  ss << "user";
129  break;
130  case MODE_FIQ:
131  ss << "fiq";
132  break;
133  case MODE_IRQ:
134  ss << "irq";
135  break;
136  case MODE_SVC:
137  ss << "supervisor";
138  break;
139  case MODE_MON:
140  ss << "monitor";
141  break;
142  case MODE_ABORT:
143  ss << "abort";
144  break;
145  case MODE_HYP:
146  ss << "hyp";
147  break;
148  case MODE_UNDEFINED:
149  ss << "undefined";
150  break;
151  case MODE_SYSTEM:
152  ss << "system";
153  break;
154  default:
155  ss << "unrecognized";
156  break;
157  }
158  return ss.str();
159 }
160 
161 void
162 Memory::printInst(std::ostream &os, AddrMode addrMode) const
163 {
164  printMnemonic(os);
165  printDest(os);
166  os << ", [";
167  printIntReg(os, base);
168  if (addrMode != AddrMd_PostIndex) {
169  os << ", ";
170  printOffset(os);
171  os << "]";
172  if (addrMode == AddrMd_PreIndex) {
173  os << "!";
174  }
175  } else {
176  os << "] ";
177  printOffset(os);
178 
179  }
180 }
181 
182 }
ArmISA::MODE_HYP
@ MODE_HYP
Definition: types.hh:642
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
ArmISA::MODE_UNDEFINED
@ MODE_UNDEFINED
Definition: types.hh:643
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
Loader::SymbolTable
Definition: symtab.hh:59
ArmISA::MODE_SYSTEM
@ MODE_SYSTEM
Definition: types.hh:644
X86ISA::base
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
ArmISA::Memory::AddrMode
AddrMode
Definition: mem.hh:158
ArmISA
Definition: ccregs.hh:41
ArmISA::INTREG_SP
@ INTREG_SP
Definition: intregs.hh:68
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
ArmISA::ROR
@ ROR
Definition: types.hh:571
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
ArmISA::mode
Bitfield< 4, 0 > mode
Definition: miscregs_types.hh:70
ArmISA::LSL
@ LSL
Definition: types.hh:568
ArmISA::MODE_SVC
@ MODE_SVC
Definition: types.hh:639
ArmISA::MODE_FIQ
@ MODE_FIQ
Definition: types.hh:637
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ArmISA::LSR
@ LSR
Definition: types.hh:569
ArmISA::MODE_IRQ
@ MODE_IRQ
Definition: types.hh:638
ArmISA::MODE_ABORT
@ MODE_ABORT
Definition: types.hh:641
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
ccprintf
void ccprintf(cp::Print &print)
Definition: cprintf.hh:127
ArmISA::MODE_MON
@ MODE_MON
Definition: types.hh:640
mem.hh
symtab.hh
ArmISA::ASR
@ ASR
Definition: types.hh:570
ArmISA::MODE_USER
@ MODE_USER
Definition: types.hh:636

Generated on Wed Sep 30 2020 14:02:00 for gem5 by doxygen 1.8.17