gem5  v20.1.0.0
integer.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  *
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 
29 #ifndef __ARCH_SPARC_INSTS_INTEGER_HH__
30 #define __ARCH_SPARC_INSTS_INTEGER_HH__
31 
33 
34 namespace SparcISA
35 {
36 
38 //
39 // Integer operate instructions
40 //
41 
45 class IntOp : public SparcStaticInst
46 {
47  protected:
48  using SparcStaticInst::SparcStaticInst;
49 
50  std::string generateDisassembly(
51  Addr pc, const Loader::SymbolTable *symtab) const override;
52 
53  virtual bool printPseudoOps(std::ostream &os, Addr pc,
54  const Loader::SymbolTable *symtab) const;
55 };
56 
60 class IntOpImm : public IntOp
61 {
62  protected:
63  // Constructor
64  IntOpImm(const char *mnem, ExtMachInst _machInst,
65  OpClass __opClass, int64_t _imm) :
66  IntOp(mnem, _machInst, __opClass), imm(_imm)
67  {}
68 
69  int64_t imm;
70 
71  std::string generateDisassembly(
72  Addr pc, const Loader::SymbolTable *symtab) const override;
73 
74  bool printPseudoOps(std::ostream &os, Addr pc,
75  const Loader::SymbolTable *symtab) const override;
76 };
77 
81 class IntOpImm10 : public IntOpImm
82 {
83  protected:
84  // Constructor
85  IntOpImm10(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
86  IntOpImm(mnem, _machInst, __opClass, sext<10>(bits(_machInst, 9, 0)))
87  {}
88 };
89 
93 class IntOpImm11 : public IntOpImm
94 {
95  protected:
96  IntOpImm11(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
97  IntOpImm(mnem, _machInst, __opClass, sext<10>(bits(_machInst, 10, 0)))
98  {}
99 };
100 
104 class IntOpImm13 : public IntOpImm
105 {
106  protected:
107  IntOpImm13(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
108  IntOpImm(mnem, _machInst, __opClass, sext<13>(bits(_machInst, 12, 0)))
109  {}
110 };
111 
115 class SetHi : public IntOpImm
116 {
117  protected:
118  // Constructor
119  SetHi(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
120  IntOpImm(mnem, _machInst, __opClass, bits(_machInst, 21, 0) << 10)
121  {}
122 
123  std::string generateDisassembly(
124  Addr pc, const Loader::SymbolTable *symtab) const override;
125 };
126 
127 }
128 
129 #endif // __ARCH_SPARCH_INSTS_INTEGER_HH__
SparcISA::IntOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:79
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
Loader::SymbolTable
Definition: symtab.hh:59
sext
uint64_t sext(uint64_t val)
Sign-extend an N-bit value to 64 bits.
Definition: bitfield.hh:126
SparcISA::IntOpImm::printPseudoOps
bool printPseudoOps(std::ostream &os, Addr pc, const Loader::SymbolTable *symtab) const override
Definition: integer.cc:54
SparcISA::IntOpImm13
Base class for 13 bit immediate integer operations.
Definition: integer.hh:104
SparcISA::IntOpImm::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:94
SparcISA::IntOpImm10
Base class for 10 bit immediate integer operations.
Definition: integer.hh:81
SparcISA
Definition: asi.cc:31
SparcISA::IntOpImm10::IntOpImm10
IntOpImm10(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: integer.hh:85
SparcISA::SetHi
Base class for sethi.
Definition: integer.hh:115
SparcISA::IntOpImm::IntOpImm
IntOpImm(const char *mnem, ExtMachInst _machInst, OpClass __opClass, int64_t _imm)
Definition: integer.hh:64
SparcISA::IntOpImm11::IntOpImm11
IntOpImm11(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: integer.hh:96
SparcISA::IntOpImm
Base class for immediate integer operations.
Definition: integer.hh:60
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
SparcISA::SetHi::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:112
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::SparcStaticInst
Base class for all SPARC static instructions.
Definition: static_inst.hh:87
SparcISA::IntOpImm11
Base class for 11 bit immediate integer operations.
Definition: integer.hh:93
SparcISA::IntOp::printPseudoOps
virtual bool printPseudoOps(std::ostream &os, Addr pc, const Loader::SymbolTable *symtab) const
Definition: integer.cc:40
static_inst.hh
SparcISA::IntOpImm::imm
int64_t imm
Definition: integer.hh:69
SparcISA::IntOpImm13::IntOpImm13
IntOpImm13(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: integer.hh:107
SparcISA::SetHi::SetHi
SetHi(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: integer.hh:119
SparcISA::IntOp
Base class for integer operations.
Definition: integer.hh:45
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