gem5  v20.1.0.0
decoder.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Google
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_MIPS_DECODER_HH__
30 #define __ARCH_MIPS_DECODER_HH__
31 
33 #include "arch/generic/decoder.hh"
34 #include "arch/mips/types.hh"
35 #include "base/logging.hh"
36 #include "base/types.hh"
37 #include "cpu/static_inst.hh"
38 
39 namespace MipsISA
40 {
41 
42 class ISA;
43 class Decoder : public InstDecoder
44 {
45  protected:
46  //The extended machine instruction being generated
48  bool instDone;
49 
50  public:
51  Decoder(ISA* isa = nullptr) : instDone(false)
52  {}
53 
54  void
56  {
57  }
58 
59  void
61  {
62  instDone = false;
63  }
64 
65  //Use this to give data to the decoder. This should be used
66  //when there is control flow.
67  void
68  moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
69  {
70  emi = letoh(inst);
71  instDone = true;
72  }
73 
74  bool
76  {
77  return true;
78  }
79 
80  bool
82  {
83  return instDone;
84  }
85 
86  void takeOverFrom(Decoder *old) {}
87 
88  protected:
91 
92  public:
94 
100  {
101  return defaultCache.decode(this, mach_inst, addr);
102  }
103 
106  {
107  if (!instDone)
108  return NULL;
109  instDone = false;
110  return decode(emi, nextPC.instAddr());
111  }
112 };
113 
114 } // namespace MipsISA
115 
116 #endif // __ARCH_MIPS_DECODER_HH__
MipsISA::ISA
Definition: isa.hh:51
GenericISA::BasicDecodeCache::decode
StaticInstPtr decode(TheISA::Decoder *const decoder, TheISA::ExtMachInst mach_inst, Addr addr)
Decode a machine instruction.
Definition: decode_cache.cc:40
MipsISA::Decoder::decode
StaticInstPtr decode(MipsISA::PCState &nextPC)
Definition: decoder.hh:105
MipsISA::Decoder::needMoreBytes
bool needMoreBytes()
Definition: decoder.hh:75
MipsISA::Decoder::process
void process()
Definition: decoder.hh:55
types.hh
decode_cache.hh
MipsISA::Decoder::reset
void reset()
Definition: decoder.hh:60
MipsISA::Decoder::defaultCache
static GenericISA::BasicDecodeCache defaultCache
A cache of decoded instruction objects.
Definition: decoder.hh:90
MipsISA::Decoder::instDone
bool instDone
Definition: decoder.hh:48
GenericISA::BasicDecodeCache
Definition: decode_cache.hh:45
MipsISA::Decoder
Definition: decoder.hh:43
MipsISA
Definition: decoder.cc:31
MipsISA::Decoder::decodeInst
StaticInstPtr decodeInst(ExtMachInst mach_inst)
letoh
T letoh(T value)
Definition: byteswap.hh:141
decoder.hh
MipsISA::MachInst
uint32_t MachInst
Definition: types.hh:38
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
MipsISA::Decoder::moreBytes
void moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
Definition: decoder.hh:68
MipsISA::Decoder::takeOverFrom
void takeOverFrom(Decoder *old)
Definition: decoder.hh:86
static_inst.hh
GenericISA::PCStateBase::instAddr
Addr instAddr() const
Returns the memory address the bytes of this instruction came from.
Definition: types.hh:80
GenericISA::DelaySlotPCState
Definition: types.hh:312
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
MipsISA::Decoder::instReady
bool instReady()
Definition: decoder.hh:81
MipsISA::Decoder::Decoder
Decoder(ISA *isa=nullptr)
Definition: decoder.hh:51
types.hh
addr
ip6_addr_t addr
Definition: inet.hh:423
logging.hh
InstDecoder
Definition: decoder.hh:34
RefCountingPtr< StaticInst >
MipsISA::Decoder::decode
StaticInstPtr decode(ExtMachInst mach_inst, Addr addr)
Decode a machine instruction.
Definition: decoder.hh:99
MipsISA::Decoder::emi
ExtMachInst emi
Definition: decoder.hh:47
MipsISA::ExtMachInst
uint64_t ExtMachInst
Definition: types.hh:39

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