gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pseudo.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014,2016-2018 ARM Limited
3  * All rights reserved
4  *
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.
13  *
14  * Copyright (c) 2007-2008 The Florida State University
15  * All rights reserved.
16  *
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.
27  *
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.
39  *
40  * Authors: Andreas Sandberg
41  * Stephen Hines
42  */
43 
44 #include "arch/arm/insts/pseudo.hh"
45 
46 #include "cpu/exec_context.hh"
47 
49  : ArmStaticInst("gem5decoderFault", _machInst, No_OpClass),
50  faultId(static_cast<DecoderFault>(
51  static_cast<uint8_t>(_machInst.decoderFault)))
52 {
53  // Don't call execute() if we're on a speculative path and the
54  // fault is an internal panic fault.
55  flags[IsNonSpeculative] = (faultId == DecoderFault::PANIC);
56 }
57 
58 Fault
60 {
61  const PCState pc_state(xc->pcState());
62  const Addr pc(pc_state.instAddr());
63 
64  switch (faultId) {
66  if (machInst.aarch64) {
67  return std::make_shared<PCAlignmentFault>(pc);
68  } else {
69  // TODO: We should check if we the receiving end is in
70  // aarch64 mode and raise a PCAlignment fault instead.
71  return std::make_shared<PrefetchAbort>(
72  pc, ArmFault::AlignmentFault);
73  }
74 
76  panic("Internal error in instruction decoder\n");
77 
78  case DecoderFault::OK:
79  panic("Decoder fault instruction without decoder fault.\n");
80  }
81 
82  panic("Unhandled fault type");
83 }
84 
85 const char *
87 {
88  switch (faultId) {
89  case DecoderFault::OK:
90  return "OK";
91 
93  return "UnalignedInstruction";
94 
96  return "DecoderPanic";
97  }
98 
99  panic("Unhandled fault type");
100 }
101 
102 std::string
104 {
105  return csprintf("gem5fault %s", faultName());
106 }
107 
108 
109 
111  ExtMachInst _machInst)
112  : ArmStaticInst(_mnemonic, _machInst, No_OpClass)
113 {
114  // don't call execute() (which panics) if we're on a
115  // speculative path
116  flags[IsNonSpeculative] = true;
117 }
118 
120  ExtMachInst _machInst,
121  const std::string& _fullMnemonic)
122  : ArmStaticInst(_mnemonic, _machInst, No_OpClass),
123  fullMnemonic(_fullMnemonic)
124 {
125  // don't call execute() (which panics) if we're on a
126  // speculative path
127  flags[IsNonSpeculative] = true;
128 }
129 
130 Fault
132 {
133  return std::make_shared<UndefinedInstruction>(machInst, false, mnemonic);
134 }
135 
136 std::string
138 {
139  return csprintf("%-10s (unimplemented)",
140  fullMnemonic.size() ? fullMnemonic.c_str() : mnemonic);
141 }
142 
143 
144 
146  ExtMachInst _machInst)
147  : ArmStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
148 {
149  // don't call execute() (which panics) if we're on a
150  // speculative path
151  flags[IsNonSpeculative] = true;
152 }
153 
155  ExtMachInst _machInst,
156  const std::string& _fullMnemonic)
157  : ArmStaticInst(_mnemonic, _machInst, No_OpClass), warned(false),
158  fullMnemonic(_fullMnemonic)
159 {
160  // don't call execute() (which panics) if we're on a
161  // speculative path
162  flags[IsNonSpeculative] = true;
163 }
164 
165 Fault
167 {
168  if (!warned) {
169  warn("\tinstruction '%s' unimplemented\n",
170  fullMnemonic.size() ? fullMnemonic.c_str() : mnemonic);
171  warned = true;
172  }
173 
174  return NoFault;
175 }
176 
177 std::string
179 {
180  return csprintf("%-10s (unimplemented)",
181  fullMnemonic.size() ? fullMnemonic.c_str() : mnemonic);
182 }
183 
185  : ArmStaticInst("Illegal Execution", _machInst, No_OpClass)
186 {}
187 
188 Fault
190 {
191  return std::make_shared<IllegalInstSetStateFault>();
192 }
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
DecoderFault faultId
Definition: pseudo.hh:52
decltype(nullptr) constexpr NoFault
Definition: types.hh:245
IllegalExecInst(ExtMachInst _machInst)
Definition: pseudo.cc:184
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: pseudo.cc:103
Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const override
Definition: pseudo.cc:131
WarnUnimplemented(const char *_mnemonic, ExtMachInst _machInst)
Definition: pseudo.cc:145
const char * mnemonic
Base mnemonic (e.g., "add").
Definition: static_inst.hh:244
virtual PCState pcState() const =0
Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const override
Definition: pseudo.cc:59
FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst)
Definition: pseudo.cc:110
No fault.
Definition: types.hh:658
Internal gem5 error.
Definition: types.hh:661
bool warned
Have we warned on this instruction yet?
Definition: pseudo.hh:105
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
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:162
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: pseudo.cc:178
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
std::string fullMnemonic
Full mnemonic for MRC and MCR instructions including the coproc.
Definition: pseudo.hh:108
DecoderFaultInst(ExtMachInst _machInst)
Definition: pseudo.cc:48
const char * faultName() const
Definition: pseudo.cc:86
decoderFault
Definition: types.hh:72
Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const
Definition: pseudo.cc:189
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: pseudo.cc:137
std::string fullMnemonic
Full mnemonic for MRC and MCR instructions including the coproc.
Definition: pseudo.hh:78
TheISA::ExtMachInst ExtMachInst
Binary extended machine instruction type.
Definition: static_inst.hh:87
#define warn(...)
Definition: logging.hh:212
Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const override
Definition: pseudo.cc:166
Unaligned instruction fault.
Definition: types.hh:659
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
DecoderFault
Instruction decoder fault codes in ExtMachInst.
Definition: types.hh:657

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