gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Timothy M. Jones
29  */
30 
31 #ifndef __ARCH_POWER_INSTS_INTEGER_HH__
32 #define __ARCH_POWER_INSTS_INTEGER_HH__
33 
35 #include "base/bitfield.hh"
36 #include "base/cprintf.hh"
37 
38 namespace PowerISA
39 {
40 
51 class IntOp : public PowerStaticInst
52 {
53  protected:
54 
55  bool rcSet;
56  bool oeSet;
57 
58  // Needed for srawi only
59  uint32_t sh;
60 
62  IntOp(const char *mnem, MachInst _machInst, OpClass __opClass)
63  : PowerStaticInst(mnem, _machInst, __opClass),
64  rcSet(false), oeSet(false)
65  {
66  }
67 
68  /* Compute the CR (condition register) field using signed comparison */
69  inline uint32_t
70  makeCRField(int32_t a, int32_t b, uint32_t xerSO) const
71  {
72  uint32_t c = xerSO;
73 
74  /* We've pre-shifted the immediate values here */
75  if (a < b) { c += 0x8; }
76  else if (a > b) { c += 0x4; }
77  else { c += 0x2; }
78  return c;
79  }
80 
81  /* Compute the CR (condition register) field using unsigned comparison */
82  inline uint32_t
83  makeCRField(uint32_t a, uint32_t b, uint32_t xerSO) const
84  {
85  uint32_t c = xerSO;
86 
87  /* We've pre-shifted the immediate values here */
88  if (a < b) { c += 0x8; }
89  else if (a > b) { c += 0x4; }
90  else { c += 0x2; }
91  return c;
92  }
93 
94  std::string generateDisassembly(
95  Addr pc, const SymbolTable *symtab) const override;
96 };
97 
98 
102 class IntImmOp : public IntOp
103 {
104  protected:
105 
106  int32_t imm;
107  uint32_t uimm;
108 
110  IntImmOp(const char *mnem, MachInst _machInst, OpClass __opClass)
111  : IntOp(mnem, _machInst, __opClass),
112  imm(sext<16>(machInst.si)),
113  uimm(machInst.si)
114  {
115  }
116 
117  std::string generateDisassembly(
118  Addr pc, const SymbolTable *symtab) const override;
119 };
120 
121 
125 class IntShiftOp : public IntOp
126 {
127  protected:
128 
129  uint32_t sh;
130 
132  IntShiftOp(const char *mnem, MachInst _machInst, OpClass __opClass)
133  : IntOp(mnem, _machInst, __opClass),
134  sh(machInst.sh)
135  {
136  }
137 
138  std::string generateDisassembly(
139  Addr pc, const SymbolTable *symtab) const override;
140 };
141 
142 
146 class IntRotateOp : public IntShiftOp
147 {
148  protected:
149 
150  uint32_t mb;
151  uint32_t me;
152  uint32_t fullMask;
153 
155  IntRotateOp(const char *mnem, MachInst _machInst, OpClass __opClass)
156  : IntShiftOp(mnem, _machInst, __opClass),
157  mb(machInst.mb),
158  me(machInst.me)
159  {
160  if (me >= mb) {
161  fullMask = mask(31 - mb, 31 - me);
162  } else {
163  fullMask = ~mask(31 - (me + 1), 31 - (mb - 1));
164  }
165  }
166 
167  uint32_t
168  rotateValue(uint32_t rs, uint32_t shift) const
169  {
170  uint32_t n = shift & 31;
171  return (rs << n) | (rs >> (32 - n));
172  }
173 
174  std::string generateDisassembly(
175  Addr pc, const SymbolTable *symtab) const override;
176 };
177 
178 } // namespace PowerISA
179 
180 #endif //__ARCH_POWER_INSTS_INTEGER_HH__
uint32_t makeCRField(uint32_t a, uint32_t b, uint32_t xerSO) const
Definition: integer.hh:83
Bitfield< 8 > a
IntImmOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:110
Bitfield< 31 > n
Bitfield< 15, 0 > si
Definition: types.hh:55
Bitfield< 7 > b
const ExtMachInst machInst
The binary machine instruction.
Definition: static_inst.hh:229
Bitfield< 4 > pc
uint32_t MachInst
Definition: types.hh:41
Bitfield< 6, 5 > shift
Definition: types.hh:127
IntShiftOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:132
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
IntOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:62
We provide a base class for integer operations and then inherit for several other classes...
Definition: integer.hh:51
uint32_t rotateValue(uint32_t rs, uint32_t shift) const
Definition: integer.hh:168
Bitfield< 29 > c
Class for integer rotate operations.
Definition: integer.hh:146
uint32_t sh
Definition: integer.hh:59
Bitfield< 3, 0 > mask
Definition: types.hh:64
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: integer.cc:37
IntRotateOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:155
uint64_t sext(uint64_t val)
Sign-extend an N-bit value to 64 bits.
Definition: bitfield.hh:113
Class for integer immediate (signed and unsigned) operations.
Definition: integer.hh:102
uint32_t makeCRField(int32_t a, int32_t b, uint32_t xerSO) const
Definition: integer.hh:70
Class for integer operations with a shift.
Definition: integer.hh:125

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