2 * Copyright (c) 2009 The Regents of The University of Michigan
3 * Copyright (c) 2009 The University of Edinburgh
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef __ARCH_POWER_ISA_HH__
31 #define __ARCH_POWER_ISA_HH__
33 #include "arch/generic/isa.hh"
34 #include "arch/power/registers.hh"
35 #include "arch/power/types.hh"
36 #include "base/logging.hh"
37 #include "cpu/reg_class.hh"
38 #include "debug/MiscRegs.hh"
39 #include "sim/sim_object.hh"
41 struct PowerISAParams;
49 class ISA : public BaseISA
53 RegVal miscRegs[NumMiscRegs];
56 typedef PowerISAParams Params;
62 readMiscRegNoEffect(int misc_reg) const
64 assert(misc_reg < NumMiscRegs);
65 int flatIndex = flattenMiscIndex(misc_reg);
66 auto val = miscRegs[flatIndex];
67 DPRINTF(MiscRegs, "Reading misc reg %d (%s) as %#x.\n", misc_reg,
68 miscRegName[flatIndex], val);
73 readMiscReg(int misc_reg)
75 return readMiscRegNoEffect(misc_reg);
79 setMiscRegNoEffect(int misc_reg, RegVal val)
81 assert(misc_reg < NumMiscRegs);
82 int flatIndex = flattenMiscIndex(misc_reg);
83 DPRINTF(MiscRegs, "Setting misc reg %d (%s) to %#x.\n", misc_reg,
84 miscRegName[flatIndex], val);
85 miscRegs[flatIndex] = val;
89 setMiscReg(int misc_reg, RegVal val)
91 return setMiscRegNoEffect(misc_reg, val);
95 flattenRegId(const RegId& regId) const
97 switch (regId.classValue()) {
99 return RegId(IntRegClass, flattenIntIndex(regId.index()));
101 return RegId(FloatRegClass, flattenFloatIndex(regId.index()));
103 return RegId(VecRegClass, flattenVecIndex(regId.index()));
105 return RegId(VecElemClass, flattenVecElemIndex(regId.index()),
107 case VecPredRegClass:
108 return RegId(VecPredRegClass,
109 flattenVecPredIndex(regId.index()));
111 return RegId(CCRegClass, flattenCCIndex(regId.index()));
113 return RegId(MiscRegClass, flattenMiscIndex(regId.index()));
120 flattenIntIndex(int reg) const
126 flattenFloatIndex(int reg) const
132 flattenVecIndex(int reg) const
138 flattenVecElemIndex(int reg) const
144 flattenVecPredIndex(int reg) const
151 flattenCCIndex(int reg) const
157 flattenMiscIndex(int reg) const
162 const Params ¶ms() const;
164 ISA(const Params &p);
167 } // namespace PowerISA
169 #endif // __ARCH_POWER_ISA_HH__