gem5  v20.1.0.0
integer.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 The University of Edinburgh
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_POWER_INSTS_INTEGER_HH__
30 #define __ARCH_POWER_INSTS_INTEGER_HH__
31 
33 #include "base/bitfield.hh"
34 #include "base/cprintf.hh"
35 
36 namespace PowerISA
37 {
38 
49 class IntOp : public PowerStaticInst
50 {
51  protected:
52 
53  bool rcSet;
54  bool oeSet;
55 
56  // Needed for srawi only
57  uint32_t sh;
58 
60  IntOp(const char *mnem, MachInst _machInst, OpClass __opClass)
61  : PowerStaticInst(mnem, _machInst, __opClass),
62  rcSet(false), oeSet(false)
63  {
64  }
65 
66  /* Compute the CR (condition register) field using signed comparison */
67  inline uint32_t
68  makeCRField(int32_t a, int32_t b, uint32_t xerSO) const
69  {
70  uint32_t c = xerSO;
71 
72  /* We've pre-shifted the immediate values here */
73  if (a < b) { c += 0x8; }
74  else if (a > b) { c += 0x4; }
75  else { c += 0x2; }
76  return c;
77  }
78 
79  /* Compute the CR (condition register) field using unsigned comparison */
80  inline uint32_t
81  makeCRField(uint32_t a, uint32_t b, uint32_t xerSO) const
82  {
83  uint32_t c = xerSO;
84 
85  /* We've pre-shifted the immediate values here */
86  if (a < b) { c += 0x8; }
87  else if (a > b) { c += 0x4; }
88  else { c += 0x2; }
89  return c;
90  }
91 
92  std::string generateDisassembly(
93  Addr pc, const Loader::SymbolTable *symtab) const override;
94 };
95 
96 
100 class IntImmOp : public IntOp
101 {
102  protected:
103 
104  int32_t imm;
105  uint32_t uimm;
106 
108  IntImmOp(const char *mnem, MachInst _machInst, OpClass __opClass)
109  : IntOp(mnem, _machInst, __opClass),
110  imm(sext<16>(machInst.si)),
111  uimm(machInst.si)
112  {
113  }
114 
115  std::string generateDisassembly(
116  Addr pc, const Loader::SymbolTable *symtab) const override;
117 };
118 
119 
123 class IntShiftOp : public IntOp
124 {
125  protected:
126 
127  uint32_t sh;
128 
130  IntShiftOp(const char *mnem, MachInst _machInst, OpClass __opClass)
131  : IntOp(mnem, _machInst, __opClass),
132  sh(machInst.sh)
133  {
134  }
135 
136  std::string generateDisassembly(
137  Addr pc, const Loader::SymbolTable *symtab) const override;
138 };
139 
140 
144 class IntRotateOp : public IntShiftOp
145 {
146  protected:
147 
148  uint32_t mb;
149  uint32_t me;
150  uint32_t fullMask;
151 
153  IntRotateOp(const char *mnem, MachInst _machInst, OpClass __opClass)
154  : IntShiftOp(mnem, _machInst, __opClass),
155  mb(machInst.mb),
156  me(machInst.me)
157  {
158  if (me >= mb) {
159  fullMask = mask(31 - mb, 31 - me);
160  } else {
161  fullMask = ~mask(31 - (me + 1), 31 - (mb - 1));
162  }
163  }
164 
165  uint32_t
166  rotateValue(uint32_t rs, uint32_t shift) const
167  {
168  uint32_t n = shift & 31;
169  return (rs << n) | (rs >> (32 - n));
170  }
171 
172  std::string generateDisassembly(
173  Addr pc, const Loader::SymbolTable *symtab) const override;
174 };
175 
176 } // namespace PowerISA
177 
178 #endif //__ARCH_POWER_INSTS_INTEGER_HH__
PowerISA::IntImmOp::uimm
uint32_t uimm
Definition: integer.hh:105
PowerISA::IntRotateOp::me
uint32_t me
Definition: integer.hh:149
PowerISA::si
Bitfield< 15, 0 > si
Definition: types.hh:53
PowerISA::IntRotateOp::fullMask
uint32_t fullMask
Definition: integer.hh:150
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
PowerISA::IntOp::rcSet
bool rcSet
Definition: integer.hh:53
PowerISA::IntRotateOp
Class for integer rotate operations.
Definition: integer.hh:144
PowerISA::IntImmOp::IntImmOp
IntImmOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:108
PowerISA::rs
rs
Definition: types.hh:44
PowerISA::MachInst
uint32_t MachInst
Definition: types.hh:39
PowerISA::IntImmOp::imm
int32_t imm
Definition: integer.hh:104
ArmISA::n
Bitfield< 31 > n
Definition: miscregs_types.hh:450
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
PowerISA
Definition: decoder.cc:31
PowerISA::IntRotateOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:146
bitfield.hh
PowerISA::IntOp::IntOp
IntOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:60
ArmISA::shift
Bitfield< 6, 5 > shift
Definition: types.hh:126
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
PowerISA::IntImmOp
Class for integer immediate (signed and unsigned) operations.
Definition: integer.hh:100
PowerISA::IntRotateOp::mb
uint32_t mb
Definition: integer.hh:148
cprintf.hh
PowerISA::IntShiftOp::sh
uint32_t sh
Definition: integer.hh:127
PowerISA::IntImmOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:82
PowerISA::IntShiftOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:118
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
PowerISA::IntRotateOp::rotateValue
uint32_t rotateValue(uint32_t rs, uint32_t shift) const
Definition: integer.hh:166
PowerISA::IntOp::oeSet
bool oeSet
Definition: integer.hh:54
ArmISA::b
Bitfield< 7 > b
Definition: miscregs_types.hh:376
StaticInst::machInst
const ExtMachInst machInst
The binary machine instruction.
Definition: static_inst.hh:243
PowerISA::IntShiftOp
Class for integer operations with a shift.
Definition: integer.hh:123
PowerISA::IntOp::sh
uint32_t sh
Definition: integer.hh:57
ArmISA::c
Bitfield< 29 > c
Definition: miscregs_types.hh:50
PowerISA::IntOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:35
PowerISA::IntShiftOp::IntShiftOp
IntShiftOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:130
PowerISA::IntOp::makeCRField
uint32_t makeCRField(uint32_t a, uint32_t b, uint32_t xerSO) const
Definition: integer.hh:81
PowerISA::IntOp::makeCRField
uint32_t makeCRField(int32_t a, int32_t b, uint32_t xerSO) const
Definition: integer.hh:68
PowerISA::PowerStaticInst
Definition: static_inst.hh:38
static_inst.hh
PowerISA::IntOp
We provide a base class for integer operations and then inherit for several other classes.
Definition: integer.hh:49
PowerISA::IntRotateOp::IntRotateOp
IntRotateOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:153
ArmISA::mask
Bitfield< 28, 24 > mask
Definition: miscregs_types.hh:711

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