gem5  v20.1.0.0
priv.hh
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  * Copyright 2017 Google Inc.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef __ARCH_SPARC_INSTS_PRIV_HH__
31 #define __ARCH_SPARC_INSTS_PRIV_HH__
32 
34 
35 namespace SparcISA
36 {
37 
41 class Priv : public SparcStaticInst
42 {
43  protected:
44  using SparcStaticInst::SparcStaticInst;
45  std::string generateDisassembly(
46  Addr pc, const Loader::SymbolTable *symtab) const override;
47 };
48 
49 class PrivReg : public Priv
50 {
51  protected:
52  PrivReg(const char *mnem, ExtMachInst _machInst,
53  OpClass __opClass, char const * _regName) :
54  Priv(mnem, _machInst, __opClass), regName(_regName)
55  {}
56 
57  char const *regName;
58 };
59 
60 // This class is for instructions that explicitly read control
61 // registers. It provides a special generateDisassembly function.
62 class RdPriv : public PrivReg
63 {
64  protected:
65  using PrivReg::PrivReg;
66  std::string generateDisassembly(
67  Addr pc, const Loader::SymbolTable *symtab) const override;
68 };
69 
70 // This class is for instructions that explicitly write control
71 // registers. It provides a special generateDisassembly function.
72 class WrPriv : public PrivReg
73 {
74  protected:
75  using PrivReg::PrivReg;
76  std::string generateDisassembly(
77  Addr pc, const Loader::SymbolTable *symtab) const override;
78 };
79 
83 class PrivImm : public Priv
84 {
85  protected:
86  // Constructor
87  PrivImm(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
88  Priv(mnem, _machInst, __opClass), imm(bits(_machInst, 12, 0))
89  {}
90 
91  int32_t imm;
92 };
93 
94 // This class is for instructions that explicitly write control
95 // registers. It provides a special generateDisassembly function.
96 class WrPrivImm : public PrivImm
97 {
98  protected:
99  // Constructor
100  WrPrivImm(const char *mnem, ExtMachInst _machInst,
101  OpClass __opClass, char const *_regName) :
102  PrivImm(mnem, _machInst, __opClass), regName(_regName)
103  {}
104 
105  std::string generateDisassembly(
106  Addr pc, const Loader::SymbolTable *symtab) const override;
107 
108  char const *regName;
109 };
110 
111 }
112 
113 #endif //__ARCH_SPARC_INSTS_PRIV_HH__
SparcISA::WrPrivImm::WrPrivImm
WrPrivImm(const char *mnem, ExtMachInst _machInst, OpClass __opClass, char const *_regName)
Definition: priv.hh:100
SparcISA::PrivImm::imm
int32_t imm
Definition: priv.hh:91
SparcISA::Priv::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: priv.cc:36
SparcISA::WrPriv::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: priv.cc:59
Loader::SymbolTable
Definition: symtab.hh:59
SparcISA::RdPriv
Definition: priv.hh:62
SparcISA::PrivReg::PrivReg
PrivReg(const char *mnem, ExtMachInst _machInst, OpClass __opClass, char const *_regName)
Definition: priv.hh:52
SparcISA::PrivReg
Definition: priv.hh:49
SparcISA
Definition: asi.cc:31
SparcISA::PrivImm
Base class for privelege mode operations with immediates.
Definition: priv.hh:83
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
SparcISA::WrPrivImm
Definition: priv.hh:96
StaticInst::ExtMachInst
TheISA::ExtMachInst ExtMachInst
Binary extended machine instruction type.
Definition: static_inst.hh:89
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
SparcISA::WrPrivImm::regName
const char * regName
Definition: priv.hh:108
SparcISA::SparcStaticInst
Base class for all SPARC static instructions.
Definition: static_inst.hh:87
SparcISA::RdPriv::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: priv.cc:46
SparcISA::WrPrivImm::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: priv.cc:79
static_inst.hh
SparcISA::PrivReg::regName
const char * regName
Definition: priv.hh:57
SparcISA::PrivImm::PrivImm
PrivImm(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: priv.hh:87
SparcISA::WrPriv
Definition: priv.hh:72
SparcISA::Priv
Base class for privelege mode operations.
Definition: priv.hh:41
bits
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:75

Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17