gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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(Addr pc, const SymbolTable *symtab) const;
95 };
96 
97 
101 class IntImmOp : public IntOp
102 {
103  protected:
104 
105  int32_t imm;
106  uint32_t uimm;
107 
109  IntImmOp(const char *mnem, MachInst _machInst, OpClass __opClass)
110  : IntOp(mnem, _machInst, __opClass),
111  imm(sext<16>(machInst.si)),
112  uimm(machInst.si)
113  {
114  }
115 
116  std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
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(Addr pc, const SymbolTable *symtab) const;
137 };
138 
139 
143 class IntRotateOp : public IntShiftOp
144 {
145  protected:
146 
147  uint32_t mb;
148  uint32_t me;
149  uint32_t fullMask;
150 
152  IntRotateOp(const char *mnem, MachInst _machInst, OpClass __opClass)
153  : IntShiftOp(mnem, _machInst, __opClass),
154  mb(machInst.mb),
155  me(machInst.me)
156  {
157  if (me >= mb) {
158  fullMask = mask(31 - mb, 31 - me);
159  } else {
160  fullMask = ~mask(31 - (me + 1), 31 - (mb - 1));
161  }
162  }
163 
164  uint32_t
165  rotateValue(uint32_t rs, uint32_t shift) const
166  {
167  uint32_t n = shift & 31;
168  return (rs << n) | (rs >> (32 - n));
169  }
170 
171  std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
172 };
173 
174 } // namespace PowerISA
175 
176 #endif //__ARCH_POWER_INSTS_INTEGER_HH__
uint32_t makeCRField(uint32_t a, uint32_t b, uint32_t xerSO) const
Definition: integer.hh:83
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const
Internal function to generate disassembly string.
Definition: integer.cc:120
Bitfield< 8 > a
Definition: miscregs.hh:1377
IntImmOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:109
uint32_t rotateValue(uint32_t rs, uint32_t shift) const
Definition: integer.hh:165
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const
Internal function to generate disassembly string.
Definition: integer.cc:37
Bitfield< 31 > n
Definition: miscregs.hh:1636
Bitfield< 15, 0 > si
Definition: types.hh:55
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const
Internal function to generate disassembly string.
Definition: integer.cc:147
Bitfield< 7 > b
Definition: miscregs.hh:1564
const ExtMachInst machInst
The binary machine instruction.
Definition: static_inst.hh:218
uint32_t MachInst
Definition: types.hh:41
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const
Internal function to generate disassembly string.
Definition: integer.cc:84
Bitfield< 6, 5 > shift
Definition: types.hh:122
IntShiftOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:130
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
Bitfield< 29 > c
Definition: miscregs.hh:1365
uint32_t makeCRField(int32_t a, int32_t b, uint32_t xerSO) const
Definition: integer.hh:70
Class for integer rotate operations.
Definition: integer.hh:143
uint32_t sh
Definition: integer.hh:59
IntReg pc
Definition: remote_gdb.hh:91
Bitfield< 3, 0 > mask
Definition: types.hh:64
IntRotateOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: integer.hh:152
uint64_t sext(uint64_t val)
Sign-extend an N-bit value to 64 bits.
Definition: bitfield.hh:108
Class for integer immediate (signed and unsigned) operations.
Definition: integer.hh:101
Class for integer operations with a shift.
Definition: integer.hh:123

Generated on Fri Jun 9 2017 13:03:40 for gem5 by doxygen 1.8.6