gem5 v24.0.0.0
Loading...
Searching...
No Matches
integer.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006-2007 The Regents of The University of Michigan
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
31namespace gem5
32{
33
34namespace SparcISA
35{
36
38//
39// Integer operate instructions
40//
41
42bool
44 const loader::SymbolTable *symbab) const
45{
46 if (!std::strcmp(mnemonic, "or") && srcRegIdx(0).index() == 0) {
47 printMnemonic(os, "mov");
48 printSrcReg(os, 1);
49 ccprintf(os, ", ");
50 printDestReg(os, 0);
51 return true;
52 }
53 return false;
54}
55
56bool
58 const loader::SymbolTable *symbab) const
59{
60 if (!std::strcmp(mnemonic, "or")) {
61 if (_numSrcRegs > 0 && srcRegIdx(0).index() == 0) {
62 if (imm == 0) {
63 printMnemonic(os, "clr");
64 } else {
65 printMnemonic(os, "mov");
66 ccprintf(os, " %#x, ", imm);
67 }
68 printDestReg(os, 0);
69 return true;
70 } else if (imm == 0) {
71 printMnemonic(os, "mov");
72 printSrcReg(os, 0);
73 ccprintf(os, ", ");
74 printDestReg(os, 0);
75 return true;
76 }
77 }
78 return false;
79}
80
81std::string
83{
84 std::stringstream response;
85
86 if (printPseudoOps(response, pc, symtab))
87 return response.str();
88 printMnemonic(response, mnemonic);
89 printRegArray(response, &srcRegIdx(0), _numSrcRegs);
91 response << ", ";
92 printDestReg(response, 0);
93 return response.str();
94}
95
96std::string
98{
99 std::stringstream response;
100
101 if (printPseudoOps(response, pc, symtab))
102 return response.str();
103 printMnemonic(response, mnemonic);
104 printRegArray(response, &srcRegIdx(0), _numSrcRegs);
105 if (_numSrcRegs > 0)
106 response << ", ";
107 ccprintf(response, "%#x", imm);
108 if (_numDestRegs > 0)
109 response << ", ";
110 printDestReg(response, 0);
111 return response.str();
112}
113
114std::string
116{
117 std::stringstream response;
118
119 printMnemonic(response, mnemonic);
120 ccprintf(response, "%%hi(%#x), ", imm);
121 printDestReg(response, 0);
122 return response.str();
123}
124
125} // namespace SparcISA
126} // namespace gem5
bool printPseudoOps(std::ostream &os, Addr pc, const loader::SymbolTable *symtab) const override
Definition integer.cc:57
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition integer.cc:97
virtual bool printPseudoOps(std::ostream &os, Addr pc, const loader::SymbolTable *symtab) const
Definition integer.cc:43
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition integer.cc:82
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition integer.cc:115
void printRegArray(std::ostream &os, const RegId *indexArray, int num) const
static void printMnemonic(std::ostream &os, const char *mnemonic)
void printDestReg(std::ostream &os, int reg) const
void printSrcReg(std::ostream &os, int reg) const
uint8_t _numSrcRegs
See numSrcRegs().
uint8_t _numDestRegs
See numDestRegs().
const char * mnemonic
Base mnemonic (e.g., "add").
const RegId & srcRegIdx(int i) const
Return logical index (architectural reg num) of i'th source reg.
Bitfield< 4 > pc
Bitfield< 30, 0 > index
Bitfield< 17 > os
Definition misc.hh:838
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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 Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0