gem5  v22.1.0.0
static_inst.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006-2007 The Regents of The University of Michigan
3  * All rights reserved.
4  * Copyright 2017 Google Inc.
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 
30 #ifndef __ARCH_SPARC_INSTS_STATIC_INST_HH__
31 #define __ARCH_SPARC_INSTS_STATIC_INST_HH__
32 
33 #include <cstdint>
34 
35 #include "arch/sparc/pcstate.hh"
36 #include "arch/sparc/types.hh"
37 #include "base/trace.hh"
38 #include "cpu/exec_context.hh"
39 #include "cpu/static_inst.hh"
40 #include "cpu/thread_context.hh"
41 
42 namespace gem5
43 {
44 
45 namespace SparcISA
46 {
47 
49 {
50  Always=0x8,
51  Never=0x0,
52  NotEqual=0x9,
53  Equal=0x1,
54  Greater=0xA,
57  Less=0x3,
61  CarrySet=0x5,
62  Positive=0xE,
63  Negative=0x6,
65  OverflowSet=0x7
66 };
67 
68 extern const char *CondTestAbbrev[];
69 
71 {
72  FAlways=0x8,
73  FNever=0x0,
75  FGreater=0x6,
77  FLess=0x4,
80  FNotEqual=0x1,
81  FEqual=0x9,
87  FOrdered=0xF
88 };
89 
94 {
95  protected:
97 
98  SparcStaticInst(const char *_mnemonic, ExtMachInst _machInst,
99  OpClass __opClass) :
100  StaticInst(_mnemonic, __opClass), machInst(_machInst)
101  {}
102 
103  std::string generateDisassembly(
104  Addr pc, const loader::SymbolTable *symtab) const override;
105 
106  static void printMnemonic(std::ostream &os, const char *mnemonic);
107  static void printReg(std::ostream &os, RegId reg);
108 
109  void printSrcReg(std::ostream &os, int reg) const;
110  void printDestReg(std::ostream &os, int reg) const;
111 
112  void printRegArray(std::ostream &os,
113  const RegId *indexArray, int num) const;
114 
115  void advancePC(PCStateBase &pcState) const override;
116  void advancePC(ThreadContext *tc) const override;
117 
118  static bool passesFpCondition(uint32_t fcc, uint32_t condition);
119  static bool passesCondition(uint32_t codes, uint32_t condition);
120 
121  size_t
122  asBytes(void *buf, size_t size) override
123  {
124  return simpleAsBytes(buf, size, machInst);
125  }
126 
127  std::unique_ptr<PCStateBase>
128  buildRetPC(const PCStateBase &cur_pc,
129  const PCStateBase &call_pc) const override
130  {
131  PCStateBase *ret_ptr = call_pc.clone();
132  auto &ret = ret_ptr->as<PCState>();
133  ret.uEnd();
134  ret.pc(cur_pc.as<PCState>().npc());
135  return std::unique_ptr<PCStateBase>{ret_ptr};
136  }
137 };
138 
139 } // namespace SparcISA
140 } // namespace gem5
141 
142 #endif //__ARCH_SPARC_INSTS_STATIC_INST_HH__
Target & as()
Definition: pcstate.hh:72
virtual PCStateBase * clone() const =0
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:91
Base class for all SPARC static instructions.
Definition: static_inst.hh:94
void printRegArray(std::ostream &os, const RegId *indexArray, int num) const
Definition: static_inst.cc:70
std::unique_ptr< PCStateBase > buildRetPC(const PCStateBase &cur_pc, const PCStateBase &call_pc) const override
Definition: static_inst.hh:128
static bool passesCondition(uint32_t codes, uint32_t condition)
Definition: static_inst.cc:339
SparcStaticInst(const char *_mnemonic, ExtMachInst _machInst, OpClass __opClass)
Definition: static_inst.hh:98
static void printReg(std::ostream &os, RegId reg)
Definition: static_inst.cc:111
static void printMnemonic(std::ostream &os, const char *mnemonic)
Definition: static_inst.cc:64
void advancePC(PCStateBase &pcState) const override
Definition: static_inst.cc:83
void printDestReg(std::ostream &os, int reg) const
Definition: static_inst.cc:104
static bool passesFpCondition(uint32_t fcc, uint32_t condition)
Definition: static_inst.cc:294
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: static_inst.cc:265
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:122
void printSrcReg(std::ostream &os, int reg) const
Definition: static_inst.cc:97
Base, ISA-independent static instruction class.
Definition: static_inst.hh:89
size_t simpleAsBytes(void *buf, size_t max_size, const T &t)
Definition: static_inst.hh:356
const char * mnemonic
Base mnemonic (e.g., "add").
Definition: static_inst.hh:259
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Bitfield< 4 > pc
uint64_t ExtMachInst
Definition: types.hh:42
@ FUnorderedOrGreaterOrEqual
Definition: static_inst.hh:84
const char * CondTestAbbrev[]
Definition: static_inst.cc:43
Bitfield< 5, 3 > reg
Definition: types.hh:92
Bitfield< 17 > os
Definition: misc.hh:810
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147

Generated on Wed Dec 21 2022 10:22:26 for gem5 by doxygen 1.9.1