gem5  v20.1.0.0
isa.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 The Regents of The University of Michigan
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 
29 #ifndef __ARCH_X86_ISA_HH__
30 #define __ARCH_X86_ISA_HH__
31 
32 #include <iostream>
33 #include <string>
34 
35 #include "arch/generic/isa.hh"
36 #include "arch/x86/registers.hh"
37 #include "arch/x86/regs/float.hh"
38 #include "arch/x86/regs/misc.hh"
39 #include "base/types.hh"
40 #include "cpu/reg_class.hh"
41 #include "sim/sim_object.hh"
42 
43 class Checkpoint;
44 class EventManager;
45 class ThreadContext;
46 struct X86ISAParams;
47 
48 namespace X86ISA
49 {
50  class ISA : public BaseISA
51  {
52  protected:
54  void updateHandyM5Reg(Efer efer, CR0 cr0,
55  SegAttr csAttr, SegAttr ssAttr, RFLAGS rflags);
56 
57  public:
58  void clear();
59 
60  typedef X86ISAParams Params;
61 
62  ISA(Params *p);
63  const Params *params() const;
64 
65  RegVal readMiscRegNoEffect(int miscReg) const;
66  RegVal readMiscReg(int miscReg);
67 
68  void setMiscRegNoEffect(int miscReg, RegVal val);
69  void setMiscReg(int miscReg, RegVal val);
70 
71  RegId
72  flattenRegId(const RegId& regId) const
73  {
74  switch (regId.classValue()) {
75  case IntRegClass:
76  return RegId(IntRegClass, flattenIntIndex(regId.index()));
77  case FloatRegClass:
78  return RegId(FloatRegClass, flattenFloatIndex(regId.index()));
79  case CCRegClass:
80  return RegId(CCRegClass, flattenCCIndex(regId.index()));
81  case MiscRegClass:
82  return RegId(MiscRegClass, flattenMiscIndex(regId.index()));
83  default:
84  break;
85  }
86  return regId;
87  }
88 
89  int flattenIntIndex(int reg) const { return reg & ~IntFoldBit; }
90 
91  int
93  {
94  if (reg >= NUM_FLOATREGS) {
97  }
98  return reg;
99  }
100 
101  int flattenVecIndex(int reg) const { return reg; }
102  int flattenVecElemIndex(int reg) const { return reg; }
103  int flattenVecPredIndex(int reg) const { return reg; }
104  int flattenCCIndex(int reg) const { return reg; }
105  int flattenMiscIndex(int reg) const { return reg; }
106 
107  void serialize(CheckpointOut &cp) const override;
108  void unserialize(CheckpointIn &cp) override;
109 
110  void setThreadContext(ThreadContext *_tc) override;
111  };
112 }
113 
114 #endif
X86ISA::IntFoldBit
static const IntRegIndex IntFoldBit
Definition: int.hh:151
X86ISA::ISA::setMiscRegNoEffect
void setMiscRegNoEffect(int miscReg, RegVal val)
Definition: isa.cc:178
X86ISA::ISA::flattenFloatIndex
int flattenFloatIndex(int reg) const
Definition: isa.hh:92
registers.hh
X86ISA::ISA::flattenCCIndex
int flattenCCIndex(int reg) const
Definition: isa.hh:104
X86ISA::MISCREG_X87_TOP
@ MISCREG_X87_TOP
Definition: misc.hh:377
X86ISA::ISA::readMiscReg
RegVal readMiscReg(int miscReg)
Definition: isa.cc:156
X86ISA::ISA::flattenMiscIndex
int flattenMiscIndex(int reg) const
Definition: isa.hh:105
X86ISA::ISA
Definition: isa.hh:50
X86ISA::ISA::clear
void clear()
Definition: isa.cc:103
X86ISA::ISA::updateHandyM5Reg
void updateHandyM5Reg(Efer efer, CR0 cr0, SegAttr csAttr, SegAttr ssAttr, RFLAGS rflags)
Definition: isa.cc:42
X86ISA::ISA::setMiscReg
void setMiscReg(int miscReg, RegVal val)
Definition: isa.cc:220
X86ISA::ISA::flattenIntIndex
int flattenIntIndex(int reg) const
Definition: isa.hh:89
X86ISA::ISA::flattenVecElemIndex
int flattenVecElemIndex(int reg) const
Definition: isa.hh:102
X86ISA::ISA::setThreadContext
void setThreadContext(ThreadContext *_tc) override
Definition: isa.cc:434
X86ISA::ISA::ISA
ISA(Params *p)
Definition: isa.cc:133
X86ISA::ISA::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: isa.cc:417
X86ISA::reg
Bitfield< 5, 3 > reg
Definition: types.hh:87
float.hh
RegId
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:75
cp
Definition: cprintf.cc:40
FloatRegClass
@ FloatRegClass
Floating-point register.
Definition: reg_class.hh:54
X86ISA::NUM_MISCREGS
@ NUM_MISCREGS
Definition: misc.hh:398
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
sim_object.hh
X86ISA::ISA::regVal
RegVal regVal[NUM_MISCREGS]
Definition: isa.hh:53
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
X86ISA::ISA::params
const Params * params() const
Definition: isa.cc:139
X86ISA
This is exposed globally, independent of the ISA.
Definition: acpi.hh:55
X86ISA::ISA::flattenRegId
RegId flattenRegId(const RegId &regId) const
Definition: isa.hh:72
X86ISA::ISA::Params
X86ISAParams Params
Definition: isa.hh:60
IntRegClass
@ IntRegClass
Integer register.
Definition: reg_class.hh:53
CCRegClass
@ CCRegClass
Condition-code register.
Definition: reg_class.hh:60
X86ISA::NUM_FLOATREGS
@ NUM_FLOATREGS
Definition: float.hh:113
isa.hh
X86ISA::ISA::readMiscRegNoEffect
RegVal readMiscRegNoEffect(int miscReg) const
Definition: isa.cc:145
MiscRegClass
@ MiscRegClass
Control (misc) register.
Definition: reg_class.hh:61
X86ISA::p
Bitfield< 0 > p
Definition: pagetable.hh:151
X86ISA::ISA::flattenVecPredIndex
int flattenVecPredIndex(int reg) const
Definition: isa.hh:103
types.hh
reg_class.hh
X86ISA::FLOATREG_STACK
static FloatRegIndex FLOATREG_STACK(int index, int top)
Definition: float.hh:147
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
EventManager
Definition: eventq.hh:973
RegId::index
const RegIndex & index() const
Index accessors.
Definition: reg_class.hh:173
X86ISA::ISA::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: isa.cc:423
CheckpointIn
Definition: serialize.hh:67
RegId::classValue
const RegClass & classValue() const
Class accessor.
Definition: reg_class.hh:200
misc.hh
BaseISA
Definition: isa.hh:47
RegVal
uint64_t RegVal
Definition: types.hh:168
X86ISA::ISA::flattenVecIndex
int flattenVecIndex(int reg) const
Definition: isa.hh:101

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17