gem5  v19.0.0.0
static_inst.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 RISC-V Foundation
3  * Copyright (c) 2016 The University of Virginia
4  * All rights reserved.
5  *
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.
16  *
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.
28  *
29  * Authors: Maxwell Walter
30  * Alec Roelke
31  */
32 
33 #ifndef __ARCH_RISCV_STATIC_INST_HH__
34 #define __ARCH_RISCV_STATIC_INST_HH__
35 
36 #include <string>
37 
38 #include "arch/riscv/types.hh"
39 #include "cpu/exec_context.hh"
40 #include "cpu/static_inst.hh"
41 #include "mem/packet.hh"
42 
43 namespace RiscvISA
44 {
45 
50 {
51  protected:
53 
54  public:
55  void advancePC(PCState &pc) const override { pc.advance(); }
56 
57  size_t
58  asBytes(void *buf, size_t size) override
59  {
60  return simpleAsBytes(buf, size, machInst);
61  }
62 };
63 
68 {
69  protected:
71 
72  RiscvMacroInst(const char *mnem, ExtMachInst _machInst,
73  OpClass __opClass) :
74  RiscvStaticInst(mnem, _machInst, __opClass)
75  {
76  flags[IsMacroop] = true;
77  }
78 
79  ~RiscvMacroInst() { microops.clear(); }
80 
82  fetchMicroop(MicroPC upc) const override
83  {
84  return microops[upc];
85  }
86 
87  Fault
88  initiateAcc(ExecContext *xc, Trace::InstRecord *traceData) const override
89  {
90  panic("Tried to execute a macroop directly!\n");
91  }
92 
93  Fault
95  Trace::InstRecord *traceData) const override
96  {
97  panic("Tried to execute a macroop directly!\n");
98  }
99 
100  Fault
101  execute(ExecContext *xc, Trace::InstRecord *traceData) const override
102  {
103  panic("Tried to execute a macroop directly!\n");
104  }
105 };
106 
111 {
112  protected:
113  RiscvMicroInst(const char *mnem, ExtMachInst _machInst,
114  OpClass __opClass) :
115  RiscvStaticInst(mnem, _machInst, __opClass)
116  {
117  flags[IsMicroop] = true;
118  }
119 
120  void advancePC(PCState &pcState) const override;
121 };
122 
123 }
124 
125 #endif // __ARCH_RISCV_STATIC_INST_HH__
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
StaticInstPtr fetchMicroop(MicroPC upc) const override
Return the microop that goes with a particular micropc.
Definition: static_inst.hh:82
Base class for all RISC-V Microops.
Definition: static_inst.hh:110
Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const override
Definition: static_inst.hh:101
RiscvMicroInst(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: static_inst.hh:113
Fault initiateAcc(ExecContext *xc, Trace::InstRecord *traceData) const override
Definition: static_inst.hh:88
STL vector class.
Definition: stl.hh:40
const ExtMachInst machInst
The binary machine instruction.
Definition: static_inst.hh:229
std::bitset< Num_Flags > flags
Flag values for this instruction.
Definition: static_inst.hh:97
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition: exec_context.hh:73
Bitfield< 4 > pc
Fault completeAcc(PacketPtr pkt, ExecContext *xc, Trace::InstRecord *traceData) const override
Definition: static_inst.hh:94
Base class for all RISC-V Macroops.
Definition: static_inst.hh:67
uint16_t MicroPC
Definition: types.hh:144
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
size_t asBytes(void *buf, size_t size) override
Instruction classes can override this function to return a a representation of themselves as a blob o...
Definition: static_inst.hh:58
Declaration of the Packet class.
std::vector< StaticInstPtr > microops
Definition: static_inst.hh:70
Base, ISA-independent static instruction class.
Definition: static_inst.hh:83
StaticInst(const char *_mnemonic, ExtMachInst _machInst, OpClass __opClass)
Constructor.
Definition: static_inst.hh:263
TheISA::ExtMachInst ExtMachInst
Binary extended machine instruction type.
Definition: static_inst.hh:87
Base class for all RISC-V static instructions.
Definition: static_inst.hh:49
void advancePC(PCState &pc) const override
Definition: static_inst.hh:55
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
RiscvMacroInst(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: static_inst.hh:72
size_t simpleAsBytes(void *buf, size_t max_size, const T &t)
Definition: static_inst.hh:341

Generated on Fri Feb 28 2020 16:26:57 for gem5 by doxygen 1.8.13