gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 ArmISA
46 {
47 
48 void
49 MemoryReg::printOffset(std::ostream &os) const
50 {
51  if (!add)
52  os << "-";
54  if (shiftType != LSL || shiftAmt != 0) {
55  switch (shiftType) {
56  case LSL:
57  ccprintf(os, " LSL #%d", shiftAmt);
58  break;
59  case LSR:
60  ccprintf(os, " LSR #%d", (shiftAmt == 0) ? 32 : shiftAmt);
61  break;
62  case ASR:
63  ccprintf(os, " ASR #%d", (shiftAmt == 0) ? 32 : shiftAmt);
64  break;
65  case ROR:
66  if (shiftAmt == 0) {
67  ccprintf(os, " RRX");
68  } else {
69  ccprintf(os, " ROR #%d", shiftAmt);
70  }
71  break;
72  }
73  }
74 }
75 
76 std::string
78 {
79  std::stringstream ss;
80  switch (mode) {
81  case DecrementAfter:
82  printMnemonic(ss, "da");
83  break;
84  case DecrementBefore:
85  printMnemonic(ss, "db");
86  break;
87  case IncrementAfter:
88  printMnemonic(ss, "ia");
89  break;
90  case IncrementBefore:
91  printMnemonic(ss, "ib");
92  break;
93  }
95  if (wb) {
96  ss << "!";
97  }
98  return ss.str();
99 }
100 
101 std::string
103 {
104  std::stringstream ss;
105  switch (mode) {
106  case DecrementAfter:
107  printMnemonic(ss, "da");
108  break;
109  case DecrementBefore:
110  printMnemonic(ss, "db");
111  break;
112  case IncrementAfter:
113  printMnemonic(ss, "ia");
114  break;
115  case IncrementBefore:
116  printMnemonic(ss, "ib");
117  break;
118  }
120  if (wb) {
121  ss << "!";
122  }
123  ss << ", #";
124  switch (regMode) {
125  case MODE_USER:
126  ss << "user";
127  break;
128  case MODE_FIQ:
129  ss << "fiq";
130  break;
131  case MODE_IRQ:
132  ss << "irq";
133  break;
134  case MODE_SVC:
135  ss << "supervisor";
136  break;
137  case MODE_MON:
138  ss << "monitor";
139  break;
140  case MODE_ABORT:
141  ss << "abort";
142  break;
143  case MODE_HYP:
144  ss << "hyp";
145  break;
146  case MODE_UNDEFINED:
147  ss << "undefined";
148  break;
149  case MODE_SYSTEM:
150  ss << "system";
151  break;
152  default:
153  ss << "unrecognized";
154  break;
155  }
156  return ss.str();
157 }
158 
159 void
160 Memory::printInst(std::ostream &os, AddrMode addrMode) const
161 {
162  printMnemonic(os);
163  printDest(os);
164  os << ", [";
165  printIntReg(os, base);
166  if (addrMode != AddrMd_PostIndex) {
167  os << ", ";
168  printOffset(os);
169  os << "]";
170  if (addrMode == AddrMd_PreIndex) {
171  os << "!";
172  }
173  } else {
174  os << "] ";
175  printOffset(os);
176 
177  }
178 }
179 
180 }
ArmISA::RfeOp::mode
AddrMode mode
Definition: mem.hh:81
ArmISA::MODE_HYP
@ MODE_HYP
Definition: types.hh:642
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
ArmISA::SrsOp::mode
AddrMode mode
Definition: mem.hh:126
ArmISA::MODE_UNDEFINED
@ MODE_UNDEFINED
Definition: types.hh:643
ArmISA::SrsOp::IncrementAfter
@ IncrementAfter
Definition: mem.hh:121
ArmISA::SrsOp::regMode
uint32_t regMode
Definition: mem.hh:125
ArmISA::RfeOp::base
IntRegIndex base
Definition: mem.hh:80
ArmISA::MemoryReg::index
IntRegIndex index
Definition: mem.hh:296
Loader::SymbolTable
Definition: symtab.hh:58
ArmISA::MODE_SYSTEM
@ MODE_SYSTEM
Definition: types.hh:644
ArmISA::MemoryReg::printOffset
void printOffset(std::ostream &os) const
Definition: mem.cc:49
ArmISA::Memory::AddrMode
AddrMode
Definition: mem.hh:158
ArmISA::ArmStaticInst::printIntReg
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:296
ArmISA::Memory::add
bool add
Definition: mem.hh:168
ArmISA::RfeOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: mem.cc:77
ArmISA
Definition: ccregs.hh:41
ArmISA::INTREG_SP
@ INTREG_SP
Definition: intregs.hh:68
ArmISA::RfeOp::DecrementAfter
@ DecrementAfter
Definition: mem.hh:74
ArmISA::Memory::AddrMd_PreIndex
@ AddrMd_PreIndex
Definition: mem.hh:160
ArmISA::MemoryReg::shiftAmt
int32_t shiftAmt
Definition: mem.hh:294
ArmISA::SrsOp::DecrementBefore
@ DecrementBefore
Definition: mem.hh:120
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
ArmISA::SrsOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: mem.cc:102
ArmISA::ROR
@ ROR
Definition: types.hh:571
ArmISA::SrsOp::IncrementBefore
@ IncrementBefore
Definition: mem.hh:122
ArmISA::Memory::AddrMd_PostIndex
@ AddrMd_PostIndex
Definition: mem.hh:161
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
ArmISA::LSL
@ LSL
Definition: types.hh:568
ArmISA::SrsOp::DecrementAfter
@ DecrementAfter
Definition: mem.hh:119
ArmISA::RfeOp::IncrementBefore
@ IncrementBefore
Definition: mem.hh:77
ArmISA::MODE_SVC
@ MODE_SVC
Definition: types.hh:639
ArmISA::MODE_FIQ
@ MODE_FIQ
Definition: types.hh:637
ArmISA::Memory::base
IntRegIndex base
Definition: mem.hh:167
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
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
ArmISA::RfeOp::wb
bool wb
Definition: mem.hh:82
ArmISA::ArmStaticInst::printMnemonic
void printMnemonic(std::ostream &os, const std::string &suffix="", bool withPred=true, bool withCond64=false, ConditionCode cond64=COND_UC) const
Definition: static_inst.cc:374
ArmISA::Memory::printDest
virtual void printDest(std::ostream &os) const
Definition: mem.hh:197
ccprintf
void ccprintf(cp::Print &print)
Definition: cprintf.hh:127
ArmISA::MODE_MON
@ MODE_MON
Definition: types.hh:640
ArmISA::RfeOp::DecrementBefore
@ DecrementBefore
Definition: mem.hh:75
mem.hh
symtab.hh
ArmISA::ASR
@ ASR
Definition: types.hh:570
ArmISA::MODE_USER
@ MODE_USER
Definition: types.hh:636
ArmISA::SrsOp::wb
bool wb
Definition: mem.hh:127
ArmISA::RfeOp::IncrementAfter
@ IncrementAfter
Definition: mem.hh:76
ArmISA::Memory::printInst
void printInst(std::ostream &os, AddrMode addrMode) const
Definition: mem.cc:160
ArmISA::MemoryReg::shiftType
ArmShiftType shiftType
Definition: mem.hh:295
ArmISA::Memory::printOffset
virtual void printOffset(std::ostream &os) const
Definition: mem.hh:193

Generated on Tue Jun 22 2021 15:28:20 for gem5 by doxygen 1.8.17