Deleted Added
sdiff udiff text old ( 6253:988a001820f8 ) new ( 6264:588457e03a81 )
full compact
1/* Copyright (c) 2007-2008 The Florida State University
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Stephen Hines
28 */
29#ifndef __ARCH_ARM_INSTS_PREDINST_HH__
30#define __ARCH_ARM_INSTS_PREDINST_HH__
31
32#include "arch/arm/insts/static_inst.hh"
33#include "base/trace.hh"
34
35namespace ArmISA
36{
37static inline uint32_t
38rotate_imm(uint32_t immValue, int rotateValue)
39{
40 return ((immValue >> (rotateValue & 31)) |
41 (immValue << (32 - (rotateValue & 31))));
42}
43
44/**
45 * Base class for predicated integer operations.
46 */
47class PredOp : public ArmStaticInst
48{
49 protected:
50
51 ConditionCode condCode;
52
53 /// Constructor
54 PredOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
55 ArmStaticInst(mnem, _machInst, __opClass),
56 condCode((ConditionCode)(unsigned)machInst.condCode)
57 {
58 }
59
60 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
61};
62
63/**
64 * Base class for predicated immediate operations.
65 */
66class PredImmOp : public PredOp
67{
68 protected:
69
70 uint32_t imm;
71 uint32_t rotate;
72 uint32_t rotated_imm;
73 uint32_t rotated_carry;
74
75 /// Constructor
76 PredImmOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
77 PredOp(mnem, _machInst, __opClass),
78 imm(machInst.imm), rotate(machInst.rotate << 1),
79 rotated_imm(0), rotated_carry(0)
80 {
81 rotated_imm = rotate_imm(imm, rotate);
82 if (rotate != 0)
83 rotated_carry = (rotated_imm >> 31) & 1;
84 }
85
86 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
87};
88
89/**
90 * Base class for predicated integer operations.
91 */
92class PredIntOp : public PredOp
93{
94 protected:
95
96 uint32_t shift_size;
97 uint32_t shift;
98
99 /// Constructor
100 PredIntOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
101 PredOp(mnem, _machInst, __opClass),
102 shift_size(machInst.shiftSize), shift(machInst.shift)
103 {
104 }
105
106 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
107};
108
109/**
110 * Base class for predicated macro-operations.
111 */
112class PredMacroOp : public PredOp
113{
114 protected:
115
116 uint32_t numMicroops;
117 StaticInstPtr * microOps;
118
119 /// Constructor
120 PredMacroOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
121 PredOp(mnem, _machInst, __opClass),
122 numMicroops(0)
123 {
124 // We rely on the subclasses of this object to handle the
125 // initialization of the micro-operations, since they are
126 // all of variable length
127 flags[IsMacroop] = true;
128 }
129
130 ~PredMacroOp()
131 {
132 if (numMicroops)
133 delete [] microOps;
134 }
135
136 StaticInstPtr
137 fetchMicroop(MicroPC microPC)
138 {
139 assert(microPC < numMicroops);
140 return microOps[microPC];
141 }
142
143 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
144};
145
146/**
147 * Base class for predicated micro-operations.
148 */
149class PredMicroop : public PredOp
150{
151 /// Constructor
152 PredMicroop(const char *mnem, MachInst _machInst, OpClass __opClass) :
153 PredOp(mnem, _machInst, __opClass)
154 {
155 flags[IsMicroop] = true;
156 }
157};
158}
159
160#endif //__ARCH_ARM_INSTS_PREDINST_HH__