ROSE  0.9.9.109
DispatcherM68k.h
1 #ifndef ROSE_DispatcherM68k_H
2 #define ROSE_DispatcherM68k_H
3 
4 #include "BaseSemantics2.h"
5 
6 #include <boost/serialization/access.hpp>
7 #include <boost/serialization/base_object.hpp>
8 #include <boost/serialization/export.hpp>
9 #include <boost/serialization/split_member.hpp>
10 
11 namespace Rose {
12 namespace BinaryAnalysis {
13 namespace InstructionSemantics2 {
14 
16 typedef boost::shared_ptr<class DispatcherM68k> DispatcherM68kPtr;
17 
19 public:
21 
22 public:
32  // Floating-point condition code bits
34  // Floating-point status register exception bits
37  // Floating-point status register accrued exception bits
41 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
42 private:
43  friend class boost::serialization::access;
44 
45  template<class S>
46  void save(S &s, const unsigned version) const {
47  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
48  };
49 
50  template<class S>
51  void load(S &s, const unsigned version) {
52  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
53  regcache_init();
54  iproc_init();
55  memory_init();
56  }
57 
58  BOOST_SERIALIZATION_SPLIT_MEMBER();
59 #endif
60 
61 protected:
62  // prototypical constructor
63  DispatcherM68k(): BaseSemantics::Dispatcher(32, RegisterDictionary::dictionary_coldfire_emac()) {}
64 
65  DispatcherM68k(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth, const RegisterDictionary *regs)
66  : BaseSemantics::Dispatcher(ops, addrWidth, regs ? regs : RegisterDictionary::dictionary_coldfire_emac()) {
67  ASSERT_require(32==addrWidth);
68  regcache_init();
69  iproc_init();
70  memory_init();
71  }
72 
74  void iproc_init();
75 
77  void regcache_init();
78 
80  void memory_init();
81 
82 public:
85  static DispatcherM68kPtr instance() {
87  }
88 
90  static DispatcherM68kPtr instance(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth,
91  const RegisterDictionary *regs=NULL) {
92  return DispatcherM68kPtr(new DispatcherM68k(ops, addrWidth, regs));
93  }
94 
97  const RegisterDictionary *regs=NULL) const ROSE_OVERRIDE {
98  if (0==addrWidth)
99  addrWidth = addressWidth();
100  if (!regs)
101  regs = get_register_dictionary();
102  return instance(ops, addrWidth, regs);
103  }
104 
106  static DispatcherM68kPtr promote(const BaseSemantics::DispatcherPtr &d) {
107  DispatcherM68kPtr retval = boost::dynamic_pointer_cast<DispatcherM68k>(d);
108  ASSERT_not_null(retval);
109  return retval;
110  }
111 
112  virtual void set_register_dictionary(const RegisterDictionary *regdict) ROSE_OVERRIDE;
113 
114  virtual RegisterDescriptor instructionPointerRegister() const ROSE_OVERRIDE;
115 
116  virtual RegisterDescriptor stackPointerRegister() const ROSE_OVERRIDE;
117 
118  virtual int iproc_key(SgAsmInstruction *insn_) const ROSE_OVERRIDE {
119  SgAsmM68kInstruction *insn = isSgAsmM68kInstruction(insn_);
120  ASSERT_not_null(insn);
121  return insn->get_kind();
122  }
123 
124  virtual BaseSemantics::SValuePtr read(SgAsmExpression*, size_t value_nbits, size_t addr_nbits=0) ROSE_OVERRIDE;
125 
127  BaseSemantics::SValuePtr condition(M68kInstructionKind, BaseSemantics::RiscOperators*);
128 
130  void accumulateFpExceptions();
131 
133  void adjustFpConditionCodes(const BaseSemantics::SValuePtr &result, SgAsmFloatType*);
134 };
135 
136 } // namespace
137 } // namespace
138 } // namespace
139 
140 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
142 #endif
143 
144 #endif
virtual RegisterDescriptor instructionPointerRegister() const ROSE_OVERRIDE
Returns the instruction pointer register.
boost::shared_ptr< class DispatcherM68k > DispatcherM68kPtr
Shared-ownership pointer to an M68k instruction dispatcher.
virtual BaseSemantics::DispatcherPtr create(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth=0, const RegisterDictionary *regs=NULL) const ROSE_OVERRIDE
Virtual constructor.
void memory_init()
Make sure memory is set up correctly.
Base class for machine instructions.
virtual RegisterDescriptor stackPointerRegister() const ROSE_OVERRIDE
Returns the stack pointer register.
void iproc_init()
Loads the iproc table with instruction processing functors.
Main namespace for the ROSE library.
Describes (part of) a physical CPU register.
virtual const RegisterDictionary * get_register_dictionary() const
Access the register dictionary.
boost::shared_ptr< class Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
Base classes for instruction semantics.
size_t addressWidth() const
Property: Width of memory addresses.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
static DispatcherM68kPtr promote(const BaseSemantics::DispatcherPtr &d)
Dynamic cast to DispatcherM68kPtr with assertion.
Defines registers available for a particular architecture.
Definition: Registers.h:32
static DispatcherM68kPtr instance(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth, const RegisterDictionary *regs=NULL)
Constructor.
const RegisterDictionary * regdict
See set_register_dictionary().
Base class for expressions.
void adjustFpConditionCodes(const BaseSemantics::SValuePtr &result, SgAsmFloatType *)
Set floating point condition codes according to result.
virtual BaseSemantics::SValuePtr read(SgAsmExpression *, size_t value_nbits, size_t addr_nbits=0) ROSE_OVERRIDE
Reads an R-value expression.
static DispatcherM68kPtr instance()
Construct a prototypical dispatcher.
BaseSemantics::SValuePtr condition(M68kInstructionKind, BaseSemantics::RiscOperators *)
Determines if an instruction should branch.
void accumulateFpExceptions()
Update accrued floating-point exceptions.
M68kInstructionKind get_kind() const
Property: Instruction kind.
Floating point types.
void regcache_init()
Load the cached register descriptors.
virtual void set_register_dictionary(const RegisterDictionary *regdict) ROSE_OVERRIDE
Access the register dictionary.
virtual int iproc_key(SgAsmInstruction *insn_) const ROSE_OVERRIDE
Given an instruction, return the InsnProcessor key that can be used as an index into the iproc_table...