gem5  v21.0.1.0
integer.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 The University of Edinburgh
3  * All rights reserved.
4  *
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.
15  *
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.
27  */
28 
30 
31 using namespace PowerISA;
32 
33 std::string
35 {
36  std::stringstream ss;
37  bool printDest = true;
38  bool printSrcs = true;
39  bool printSecondSrc = true;
40 
41  // Generate the correct mnemonic
42  std::string myMnemonic(mnemonic);
43 
44  // Special cases
45  if (!myMnemonic.compare("or") && srcRegIdx(0) == srcRegIdx(1)) {
46  myMnemonic = "mr";
47  printSecondSrc = false;
48  } else if (!myMnemonic.compare("mtlr") || !myMnemonic.compare("cmpi")) {
49  printDest = false;
50  } else if (!myMnemonic.compare("mflr")) {
51  printSrcs = false;
52  }
53 
54  // Additional characters depending on isa bits being set
55  if (oeSet) myMnemonic = myMnemonic + "o";
56  if (rcSet) myMnemonic = myMnemonic + ".";
57  ccprintf(ss, "%-10s ", myMnemonic);
58 
59  // Print the first destination only
60  if (_numDestRegs > 0 && printDest) {
61  printReg(ss, destRegIdx(0));
62  }
63 
64  // Print the (possibly) two source registers
65  if (_numSrcRegs > 0 && printSrcs) {
66  if (_numDestRegs > 0 && printDest) {
67  ss << ", ";
68  }
69  printReg(ss, srcRegIdx(0));
70  if (_numSrcRegs > 1 && printSecondSrc) {
71  ss << ", ";
72  printReg(ss, srcRegIdx(1));
73  }
74  }
75 
76  return ss.str();
77 }
78 
79 
80 std::string
82 {
83  std::stringstream ss;
84 
85  // Generate the correct mnemonic
86  std::string myMnemonic(mnemonic);
87 
88  // Special cases
89  if (!myMnemonic.compare("addi") && _numSrcRegs == 0) {
90  myMnemonic = "li";
91  } else if (!myMnemonic.compare("addis") && _numSrcRegs == 0) {
92  myMnemonic = "lis";
93  }
94  ccprintf(ss, "%-10s ", myMnemonic);
95 
96  // Print the first destination only
97  if (_numDestRegs > 0) {
98  printReg(ss, destRegIdx(0));
99  }
100 
101  // Print the source register
102  if (_numSrcRegs > 0) {
103  if (_numDestRegs > 0) {
104  ss << ", ";
105  }
106  printReg(ss, srcRegIdx(0));
107  }
108 
109  // Print the immediate value last
110  ss << ", " << (int32_t)imm;
111 
112  return ss.str();
113 }
114 
115 
116 std::string
118  Addr pc, const Loader::SymbolTable *symtab) const
119 {
120  std::stringstream ss;
121 
122  ccprintf(ss, "%-10s ", mnemonic);
123 
124  // Print the first destination only
125  if (_numDestRegs > 0) {
126  printReg(ss, destRegIdx(0));
127  }
128 
129  // Print the first source register
130  if (_numSrcRegs > 0) {
131  if (_numDestRegs > 0) {
132  ss << ", ";
133  }
134  printReg(ss, srcRegIdx(0));
135  }
136 
137  // Print the shift
138  ss << ", " << sh;
139 
140  return ss.str();
141 }
142 
143 
144 std::string
146  Addr pc, const Loader::SymbolTable *symtab) const
147 {
148  std::stringstream ss;
149 
150  ccprintf(ss, "%-10s ", mnemonic);
151 
152  // Print the first destination only
153  if (_numDestRegs > 0) {
154  printReg(ss, destRegIdx(0));
155  }
156 
157  // Print the first source register
158  if (_numSrcRegs > 0) {
159  if (_numDestRegs > 0) {
160  ss << ", ";
161  }
162  printReg(ss, srcRegIdx(0));
163  }
164 
165  // Print the shift, mask begin and mask end
166  ss << ", " << sh << ", " << mb << ", " << me;
167 
168  return ss.str();
169 }
PowerISA::IntShiftOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:117
StaticInst::destRegIdx
const RegId & destRegIdx(int i) const
Return logical index (architectural reg num) of i'th destination reg.
Definition: static_inst.hh:234
PowerISA::IntRotateOp::me
uint32_t me
Definition: integer.hh:149
PowerISA::IntOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:34
Loader::SymbolTable
Definition: symtab.hh:58
integer.hh
PowerISA::IntOp::rcSet
bool rcSet
Definition: integer.hh:53
PowerISA::IntImmOp::imm
int32_t imm
Definition: integer.hh:104
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
PowerISA
Definition: decoder.cc:31
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
PowerISA::PowerStaticInst::printReg
void printReg(std::ostream &os, RegId reg) const
Print a register name for disassembly given the unique dependence tag number (FP or int).
Definition: static_inst.cc:37
PowerISA::IntRotateOp::mb
uint32_t mb
Definition: integer.hh:148
StaticInst::mnemonic
const char * mnemonic
Base mnemonic (e.g., "add").
Definition: static_inst.hh:284
PowerISA::IntShiftOp::sh
uint32_t sh
Definition: integer.hh:127
PowerISA::IntImmOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:81
StaticInst::srcRegIdx
const RegId & srcRegIdx(int i) const
Return logical index (architectural reg num) of i'th source reg.
Definition: static_inst.hh:244
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
PowerISA::IntOp::oeSet
bool oeSet
Definition: integer.hh:54
PowerISA::IntRotateOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:145
ccprintf
void ccprintf(cp::Print &print)
Definition: cprintf.hh:127
StaticInst::_numSrcRegs
int8_t _numSrcRegs
See numSrcRegs().
Definition: static_inst.hh:106
StaticInst::_numDestRegs
int8_t _numDestRegs
See numDestRegs().
Definition: static_inst.hh:109

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