gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
31 namespace SparcISA
32 {
33 
35 //
36 // Integer operate instructions
37 //
38 
39 bool
41  const Loader::SymbolTable *symbab) const
42 {
43  if (!std::strcmp(mnemonic, "or") && _srcRegIdx[0].index() == 0) {
44  printMnemonic(os, "mov");
45  printSrcReg(os, 1);
46  ccprintf(os, ", ");
47  printDestReg(os, 0);
48  return true;
49  }
50  return false;
51 }
52 
53 bool
55  const Loader::SymbolTable *symbab) const
56 {
57  if (!std::strcmp(mnemonic, "or")) {
58  if (_numSrcRegs > 0 && _srcRegIdx[0].index() == 0) {
59  if (imm == 0) {
60  printMnemonic(os, "clr");
61  } else {
62  printMnemonic(os, "mov");
63  ccprintf(os, " %#x, ", imm);
64  }
65  printDestReg(os, 0);
66  return true;
67  } else if (imm == 0) {
68  printMnemonic(os, "mov");
69  printSrcReg(os, 0);
70  ccprintf(os, ", ");
71  printDestReg(os, 0);
72  return true;
73  }
74  }
75  return false;
76 }
77 
78 std::string
80 {
81  std::stringstream response;
82 
83  if (printPseudoOps(response, pc, symtab))
84  return response.str();
85  printMnemonic(response, mnemonic);
88  response << ", ";
89  printDestReg(response, 0);
90  return response.str();
91 }
92 
93 std::string
95 {
96  std::stringstream response;
97 
98  if (printPseudoOps(response, pc, symtab))
99  return response.str();
100  printMnemonic(response, mnemonic);
102  if (_numSrcRegs > 0)
103  response << ", ";
104  ccprintf(response, "%#x", imm);
105  if (_numDestRegs > 0)
106  response << ", ";
107  printDestReg(response, 0);
108  return response.str();
109 }
110 
111 std::string
113 {
114  std::stringstream response;
115 
116  printMnemonic(response, mnemonic);
117  ccprintf(response, "%%hi(%#x), ", imm);
118  printDestReg(response, 0);
119  return response.str();
120 }
121 
122 }
void ccprintf(cp::Print &print)
Definition: cprintf.hh:127
static void printMnemonic(std::ostream &os, const char *mnemonic)
Definition: static_inst.cc:56
Bitfield< 30, 0 > index
int8_t _numSrcRegs
See numSrcRegs().
Definition: static_inst.hh:105
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:79
const char * mnemonic
Base mnemonic (e.g., "add").
Definition: static_inst.hh:246
Bitfield< 17 > os
Definition: misc.hh:803
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:112
Bitfield< 4 > pc
void printSrcReg(std::ostream &os, int reg) const
Definition: static_inst.cc:81
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Bitfield< 7, 0 > imm
Definition: types.hh:140
void printDestReg(std::ostream &os, int reg) const
Definition: static_inst.cc:88
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:94
int8_t _numDestRegs
See numDestRegs().
Definition: static_inst.hh:108
Definition: asi.cc:31
RegId _srcRegIdx[MaxInstSrcRegs]
See srcRegIdx().
Definition: static_inst.hh:238
void printRegArray(std::ostream &os, const RegId indexArray[], int num) const
Definition: static_inst.cc:62
virtual bool printPseudoOps(std::ostream &os, Addr pc, const Loader::SymbolTable *symtab) const
Definition: integer.cc:40
bool printPseudoOps(std::ostream &os, Addr pc, const Loader::SymbolTable *symtab) const override
Definition: integer.cc:54

Generated on Mon Jun 8 2020 15:45:06 for gem5 by doxygen 1.8.13