2 * Copyright (c) 2010 ARM Limited
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
14 * Copyright (c) 2007-2008 The Florida State University
15 * All rights reserved.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 * Authors: Stephen Hines
42 #ifndef __ARCH_ARM_INSTS_PREDINST_HH__
43 #define __ARCH_ARM_INSTS_PREDINST_HH__
45 #include "arch/arm/insts/static_inst.hh"
46 #include "base/trace.hh"
50 static inline uint32_t
51 rotate_imm(uint32_t immValue, int rotateValue)
53 return ((immValue >> (rotateValue & 31)) |
54 (immValue << (32 - (rotateValue & 31))));
57 static inline uint32_t
58 modified_imm(uint8_t ctrlImm, uint8_t dataImm)
60 uint32_t bigData = dataImm;
61 uint32_t bigCtrl = ctrlImm;
67 return bigData | (bigData << 16);
69 return (bigData << 8) | (bigData << 24);
71 return (bigData << 0) | (bigData << 8) |
72 (bigData << 16) | (bigData << 24);
75 bigCtrl = (bigCtrl << 1) | ((bigData >> 7) & 0x1);
77 return bigData << (32 - bigCtrl);
82 * Base class for predicated integer operations.
84 class PredOp : public ArmStaticInst
88 ConditionCode condCode;
91 PredOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
92 ArmStaticInst(mnem, _machInst, __opClass),
93 condCode((ConditionCode)(unsigned)machInst.condCode)
99 * Base class for predicated immediate operations.
101 class PredImmOp : public PredOp
106 uint32_t rotated_imm;
107 uint32_t rotated_carry;
111 PredImmOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
112 PredOp(mnem, _machInst, __opClass),
113 imm(machInst.imm), rotated_imm(0), rotated_carry(0),
114 rotate(machInst.rotate << 1)
116 rotated_imm = rotate_imm(imm, rotate);
118 rotated_carry = bits(rotated_imm, 31);
121 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
125 * Base class for predicated integer operations.
127 class PredIntOp : public PredOp
135 PredIntOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
136 PredOp(mnem, _machInst, __opClass),
137 shift_size(machInst.shiftSize), shift(machInst.shift)
141 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
144 class DataImmOp : public PredOp
147 IntRegIndex dest, op1;
149 // Whether the carry flag should be modified if that's an option for
153 DataImmOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
154 IntRegIndex _dest, IntRegIndex _op1, uint32_t _imm, bool _rotC) :
155 PredOp(mnem, _machInst, __opClass),
156 dest(_dest), op1(_op1), imm(_imm), rotC(_rotC)
159 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
162 class DataRegOp : public PredOp
165 IntRegIndex dest, op1, op2;
167 ArmShiftType shiftType;
169 DataRegOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
170 IntRegIndex _dest, IntRegIndex _op1, IntRegIndex _op2,
171 int32_t _shiftAmt, ArmShiftType _shiftType) :
172 PredOp(mnem, _machInst, __opClass),
173 dest(_dest), op1(_op1), op2(_op2),
174 shiftAmt(_shiftAmt), shiftType(_shiftType)
177 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
180 class DataRegRegOp : public PredOp
183 IntRegIndex dest, op1, op2, shift;
184 ArmShiftType shiftType;
186 DataRegRegOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
187 IntRegIndex _dest, IntRegIndex _op1, IntRegIndex _op2,
188 IntRegIndex _shift, ArmShiftType _shiftType) :
189 PredOp(mnem, _machInst, __opClass),
190 dest(_dest), op1(_op1), op2(_op2), shift(_shift),
191 shiftType(_shiftType)
194 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
198 * Base class for predicated macro-operations.
200 class PredMacroOp : public PredOp
204 uint32_t numMicroops;
205 StaticInstPtr * microOps;
208 PredMacroOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
209 PredOp(mnem, _machInst, __opClass),
212 // We rely on the subclasses of this object to handle the
213 // initialization of the micro-operations, since they are
214 // all of variable length
215 flags[IsMacroop] = true;
225 fetchMicroop(MicroPC microPC)
227 assert(microPC < numMicroops);
228 return microOps[microPC];
231 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
235 * Base class for predicated micro-operations.
237 class PredMicroop : public PredOp
240 PredMicroop(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
241 PredOp(mnem, _machInst, __opClass)
243 flags[IsMicroop] = true;
248 #endif //__ARCH_ARM_INSTS_PREDINST_HH__