gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
branch.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: Gabe Black
29  * Steve Reinhardt
30  */
31 
33 
35 //
36 // Branch instructions
37 //
38 
39 namespace SparcISA
40 {
41 
42 template class BranchNBits<19>;
43 template class BranchNBits<22>;
44 template class BranchNBits<30>;
45 
46 std::string
48 {
49  std::stringstream response;
50 
51  printMnemonic(response, mnemonic);
54  response << ", ";
55  printDestReg(response, 0);
56 
57  return response.str();
58 }
59 
60 std::string
62 {
63  std::stringstream response;
64 
65  printMnemonic(response, mnemonic);
67  if (_numSrcRegs > 0)
68  response << ", ";
69  ccprintf(response, "0x%x", imm);
70  if (_numDestRegs > 0)
71  response << ", ";
72  printDestReg(response, 0);
73 
74  return response.str();
75 }
76 
77 std::string
79 {
80  std::stringstream response;
81  std::string symbol;
82  Addr symbol_addr;
83 
84  Addr target = disp + pc;
85 
86  printMnemonic(response, mnemonic);
87  ccprintf(response, "0x%x", target);
88 
89  if (symtab && symtab->findNearestSymbol(target, symbol, symbol_addr)) {
90  ccprintf(response, " <%s", symbol);
91  if (symbol_addr != target)
92  ccprintf(response, "+%d>", target - symbol_addr);
93  else
94  ccprintf(response, ">");
95  }
96 
97  return response.str();
98 }
99 
100 }
void ccprintf(cp::Print &print)
Definition: cprintf.hh:131
static void printMnemonic(std::ostream &os, const char *mnemonic)
Definition: static_inst.cc:58
int8_t _numSrcRegs
See numSrcRegs().
Definition: static_inst.hh:103
const char * mnemonic
Base mnemonic (e.g., "add").
Definition: static_inst.hh:244
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch.cc:61
Bitfield< 4 > pc
bool findNearestSymbol(Addr addr, std::string &symbol, Addr &symaddr, Addr &nextaddr) const
Find the nearest symbol equal to or less than the supplied address (e.g., the label for the enclosing...
Definition: symtab.hh:116
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
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch.cc:78
int8_t _numDestRegs
See numDestRegs().
Definition: static_inst.hh:106
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch.cc:47
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

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