gem5  v22.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 namespace gem5
46 {
47 
48 namespace ArmISA
49 {
50 
51 void
52 MemoryReg::printOffset(std::ostream &os) const
53 {
54  if (!add)
55  os << "-";
57  if (shiftType != LSL || shiftAmt != 0) {
58  switch (shiftType) {
59  case LSL:
60  ccprintf(os, " LSL #%d", shiftAmt);
61  break;
62  case LSR:
63  ccprintf(os, " LSR #%d", (shiftAmt == 0) ? 32 : shiftAmt);
64  break;
65  case ASR:
66  ccprintf(os, " ASR #%d", (shiftAmt == 0) ? 32 : shiftAmt);
67  break;
68  case ROR:
69  if (shiftAmt == 0) {
70  ccprintf(os, " RRX");
71  } else {
72  ccprintf(os, " ROR #%d", shiftAmt);
73  }
74  break;
75  }
76  }
77 }
78 
79 std::string
81 {
82  std::stringstream ss;
83  switch (mode) {
84  case DecrementAfter:
85  printMnemonic(ss, "da");
86  break;
87  case DecrementBefore:
88  printMnemonic(ss, "db");
89  break;
90  case IncrementAfter:
91  printMnemonic(ss, "ia");
92  break;
93  case IncrementBefore:
94  printMnemonic(ss, "ib");
95  break;
96  }
98  if (wb) {
99  ss << "!";
100  }
101  return ss.str();
102 }
103 
104 std::string
106 {
107  std::stringstream ss;
108  switch (mode) {
109  case DecrementAfter:
110  printMnemonic(ss, "da");
111  break;
112  case DecrementBefore:
113  printMnemonic(ss, "db");
114  break;
115  case IncrementAfter:
116  printMnemonic(ss, "ia");
117  break;
118  case IncrementBefore:
119  printMnemonic(ss, "ib");
120  break;
121  }
123  if (wb) {
124  ss << "!";
125  }
126  ss << ", #";
127  switch (regMode) {
128  case MODE_USER:
129  ss << "user";
130  break;
131  case MODE_FIQ:
132  ss << "fiq";
133  break;
134  case MODE_IRQ:
135  ss << "irq";
136  break;
137  case MODE_SVC:
138  ss << "supervisor";
139  break;
140  case MODE_MON:
141  ss << "monitor";
142  break;
143  case MODE_ABORT:
144  ss << "abort";
145  break;
146  case MODE_HYP:
147  ss << "hyp";
148  break;
149  case MODE_UNDEFINED:
150  ss << "undefined";
151  break;
152  case MODE_SYSTEM:
153  ss << "system";
154  break;
155  default:
156  ss << "unrecognized";
157  break;
158  }
159  return ss.str();
160 }
161 
162 void
163 Memory::printInst(std::ostream &os, AddrMode addrMode) const
164 {
165  printMnemonic(os);
166  printDest(os);
167  os << ", [";
168  printIntReg(os, base);
169  if (addrMode != AddrMd_PostIndex) {
170  os << ", ";
171  printOffset(os);
172  os << "]";
173  if (addrMode == AddrMd_PreIndex) {
174  os << "!";
175  }
176  } else {
177  os << "] ";
178  printOffset(os);
179 
180  }
181 }
182 
183 } // namespace ArmISA
184 } // namespace gem5
void printMnemonic(std::ostream &os, const std::string &suffix="", bool withPred=true, bool withCond64=false, ConditionCode cond64=COND_UC) const
Definition: static_inst.cc:377
void printIntReg(std::ostream &os, RegIndex reg_idx, uint8_t opWidth=0) const
Print a register name for disassembly given the unique dependence tag number (FP or int).
Definition: static_inst.cc:299
ArmShiftType shiftType
Definition: mem.hh:318
void printOffset(std::ostream &os) const
Definition: mem.cc:52
void printInst(std::ostream &os, AddrMode addrMode) const
Definition: mem.cc:163
RegIndex base
Definition: mem.hh:190
virtual void printDest(std::ostream &os) const
Definition: mem.hh:220
virtual void printOffset(std::ostream &os) const
Definition: mem.hh:216
RegIndex base
Definition: mem.hh:101
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: mem.cc:80
AddrMode mode
Definition: mem.hh:102
AddrMode mode
Definition: mem.hh:148
uint32_t regMode
Definition: mem.hh:147
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: mem.cc:105
constexpr auto & Sp
Definition: int.hh:274
@ MODE_SYSTEM
Definition: types.hh:296
@ MODE_ABORT
Definition: types.hh:293
@ MODE_UNDEFINED
Definition: types.hh:295
Bitfield< 21 > ss
Definition: misc_types.hh:60
Bitfield< 4 > pc
Bitfield< 17 > os
Definition: misc.hh:810
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
void ccprintf(cp::Print &print)
Definition: cprintf.hh:130

Generated on Wed Dec 21 2022 10:22:25 for gem5 by doxygen 1.9.1