gem5  v22.0.0.1
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_SPARC_DECODER_HH__
30 #define __ARCH_SPARC_DECODER_HH__
31 
33 #include "arch/generic/decoder.hh"
34 #include "arch/sparc/types.hh"
35 #include "cpu/static_inst.hh"
36 #include "debug/Decode.hh"
37 #include "params/SparcDecoder.hh"
38 
39 namespace gem5
40 {
41 
42 namespace SparcISA
43 {
44 
45 class ISA;
46 class Decoder : public InstDecoder
47 {
48  protected:
49  // The extended machine instruction being generated
51  uint32_t machInst;
53 
54  public:
55  Decoder(const SparcDecoderParams &p) : InstDecoder(p, &machInst), asi(0)
56  {}
57 
58  // Use this to give data to the predecoder. This should be used
59  // when there is control flow.
60  void
61  moreBytes(const PCStateBase &pc, Addr fetchPC) override
62  {
63  emi = betoh(machInst);
64  // The I bit, bit 13, is used to figure out where the ASI
65  // should come from. Use that in the ExtMachInst. This is
66  // slightly redundant, but it removes the need to put a condition
67  // into all the execute functions
68  if (emi & (1 << 13)) {
69  emi |= (static_cast<ExtMachInst>(
70  asi << (sizeof(machInst) * 8)));
71  } else {
72  emi |= (static_cast<ExtMachInst>(bits(emi, 12, 5))
73  << (sizeof(machInst) * 8));
74  }
75  instDone = true;
76  }
77 
78  void
80  {
81  asi = _asi;
82  }
83 
84  protected:
88 
90 
96  {
97  StaticInstPtr si = defaultCache.decode(this, mach_inst, addr);
98  DPRINTF(Decode, "Decode: Decoded %s instruction: %#x\n",
99  si->getName(), mach_inst);
100  return si;
101  }
102 
103  public:
105  decode(PCStateBase &next_pc) override
106  {
107  if (!instDone)
108  return NULL;
109  instDone = false;
110  return decode(emi, next_pc.instAddr());
111  }
112 };
113 
114 } // namespace SparcISA
115 } // namespace gem5
116 
117 #endif // __ARCH_SPARC_DECODER_HH__
gem5::SparcISA::Decoder
Definition: decoder.hh:46
gem5::PCStateBase::instAddr
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
Definition: pcstate.hh:107
gem5::RegVal
uint64_t RegVal
Definition: types.hh:173
gem5::SparcISA::ExtMachInst
uint64_t ExtMachInst
Definition: types.hh:42
gem5::SparcISA::Decoder::asi
RegVal asi
Definition: decoder.hh:52
decode_cache.hh
gem5::betoh
T betoh(T value)
Definition: byteswap.hh:175
gem5::SparcISA::Decoder::Decoder
Decoder(const SparcDecoderParams &p)
Definition: decoder.hh:55
gem5::GenericISA::BasicDecodeCache
Definition: decode_cache.hh:43
gem5::SparcISA::Decoder::decode
StaticInstPtr decode(PCStateBase &next_pc) override
Decode an instruction or fetch it from the code cache.
Definition: decoder.hh:105
gem5::SparcISA::Decoder::defaultCache
static GenericISA::BasicDecodeCache< Decoder, ExtMachInst > defaultCache
A cache of decoded instruction objects.
Definition: decoder.hh:86
gem5::RefCountingPtr< StaticInst >
gem5::SparcISA::Decoder::decodeInst
StaticInstPtr decodeInst(ExtMachInst mach_inst)
gem5::SparcISA::Decoder::emi
ExtMachInst emi
Definition: decoder.hh:50
decoder.hh
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::InstDecoder
Definition: decoder.hh:42
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::bits
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:76
static_inst.hh
types.hh
gem5::ArmISA::si
Bitfield< 6 > si
Definition: misc_types.hh:825
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::SparcISA::Decoder::machInst
uint32_t machInst
Definition: decoder.hh:51
gem5::InstDecoder::instDone
bool instDone
Definition: decoder.hh:49
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::SparcISA::Decoder::setContext
void setContext(RegVal _asi)
Definition: decoder.hh:79
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::SparcISA::Decoder::moreBytes
void moreBytes(const PCStateBase &pc, Addr fetchPC) override
Feed data to the decoder.
Definition: decoder.hh:61
gem5::SparcISA::Decoder::decode
StaticInstPtr decode(ExtMachInst mach_inst, Addr addr)
Decode a machine instruction.
Definition: decoder.hh:95
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Sat Jun 18 2022 08:12:13 for gem5 by doxygen 1.8.17