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

Generated on Fri Feb 28 2020 16:26:57 for gem5 by doxygen 1.8.13