ROSE  0.11.52.0
DispatcherM68k.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_DispatcherM68k_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_DispatcherM68k_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics.h>
7 
8 #include <boost/serialization/access.hpp>
9 #include <boost/serialization/base_object.hpp>
10 #include <boost/serialization/export.hpp>
11 #include <boost/serialization/split_member.hpp>
12 
13 namespace Rose {
14 namespace BinaryAnalysis {
15 namespace InstructionSemantics2 {
16 
18 typedef boost::shared_ptr<class DispatcherM68k> DispatcherM68kPtr;
19 
21 public:
24 
27 
28 public:
38  // Floating-point condition code bits
40  // Floating-point status register exception bits
43  // Floating-point status register accrued exception bits
47 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
48 private:
49  friend class boost::serialization::access;
50 
51  template<class S>
52  void save(S &s, const unsigned /*version*/) const {
53  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
54  };
55 
56  template<class S>
57  void load(S &s, const unsigned /*version*/) {
58  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
59  regcache_init();
60  iproc_init();
61  memory_init();
62  }
63 
64  BOOST_SERIALIZATION_SPLIT_MEMBER();
65 #endif
66 
67 protected:
68  // prototypical constructor
69  DispatcherM68k(): BaseSemantics::Dispatcher(32, RegisterDictionary::dictionary_coldfire_emac()) {}
70 
71  DispatcherM68k(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth, const RegisterDictionary *regs)
72  : BaseSemantics::Dispatcher(ops, addrWidth, regs ? regs : RegisterDictionary::dictionary_coldfire_emac()) {
73  ASSERT_require(32==addrWidth);
74  regcache_init();
75  iproc_init();
76  memory_init();
77  initializeState(ops->currentState());
78  }
79 
81  void iproc_init();
82 
86  void regcache_init();
87 
89  void memory_init();
90 
91 public:
94  static DispatcherM68kPtr instance() {
96  }
97 
99  static DispatcherM68kPtr instance(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth,
100  const RegisterDictionary *regs=NULL) {
101  return DispatcherM68kPtr(new DispatcherM68k(ops, addrWidth, regs));
102  }
103 
106  const RegisterDictionary *regs=NULL) const ROSE_OVERRIDE {
107  if (0==addrWidth)
108  addrWidth = addressWidth();
109  if (!regs)
110  regs = registerDictionary();
111  return instance(ops, addrWidth, regs);
112  }
113 
115  static DispatcherM68kPtr promote(const BaseSemantics::DispatcherPtr &d) {
116  DispatcherM68kPtr retval = boost::dynamic_pointer_cast<DispatcherM68k>(d);
117  ASSERT_not_null(retval);
118  return retval;
119  }
120 
121  virtual void set_register_dictionary(const RegisterDictionary *regdict) ROSE_OVERRIDE;
122 
123  virtual RegisterDescriptor instructionPointerRegister() const ROSE_OVERRIDE;
124  virtual RegisterDescriptor stackPointerRegister() const ROSE_OVERRIDE;
125  virtual RegisterDescriptor stackFrameRegister() const ROSE_OVERRIDE;
126  virtual RegisterDescriptor callReturnRegister() const ROSE_OVERRIDE;
127 
128  virtual int iprocKey(SgAsmInstruction *insn_) const ROSE_OVERRIDE {
129  SgAsmM68kInstruction *insn = isSgAsmM68kInstruction(insn_);
130  ASSERT_not_null(insn);
131  return insn->get_kind();
132  }
133 
134  virtual BaseSemantics::SValuePtr read(SgAsmExpression*, size_t value_nbits, size_t addr_nbits=0) ROSE_OVERRIDE;
135 
137  void updateFpsrExcInan(const BaseSemantics::SValuePtr &a, SgAsmType *aType,
138  const BaseSemantics::SValuePtr &b, SgAsmType *bType);
139 
141  void updateFpsrExcIde(const BaseSemantics::SValuePtr &a, SgAsmType *aType,
142  const BaseSemantics::SValuePtr &b, SgAsmType *bType);
143 
149  void updateFpsrExcOvfl(const BaseSemantics::SValuePtr &intermediate, SgAsmType *valueType,
150  SgAsmType *rounding, SgAsmType *dstType);
151 
159  void updateFpsrExcUnfl(const BaseSemantics::SValuePtr &intermediate, SgAsmType *valueType,
160  SgAsmType *rounding, SgAsmType *dstType);
161 
163  void updateFpsrExcInex();
164 
166  BaseSemantics::SValuePtr condition(M68kInstructionKind, BaseSemantics::RiscOperators*);
167 
169  void accumulateFpExceptions();
170 
172  void adjustFpConditionCodes(const BaseSemantics::SValuePtr &result, SgAsmFloatType*);
173 };
174 
175 } // namespace
176 } // namespace
177 } // namespace
178 
179 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
181 #endif
182 
183 #endif
184 #endif
virtual int iprocKey(SgAsmInstruction *insn_) const ROSE_OVERRIDE
Given an instruction, return the InsnProcessor key that can be used as an index into the iproc_table...
const RegisterDictionary * registerDictionary() const
Property: Register dictionary.
Definition: Dispatcher.h:195
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
virtual void initializeState(const StatePtr &)
Initialize the state.
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.
void updateFpsrExcUnfl(const BaseSemantics::SValuePtr &intermediate, SgAsmType *valueType, SgAsmType *rounding, SgAsmType *dstType)
Set or clear FPSR EXC UVFL bit.
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.
M68kInstructionKind
M68k instruction types.
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.
void updateFpsrExcInan(const BaseSemantics::SValuePtr &a, SgAsmType *aType, const BaseSemantics::SValuePtr &b, SgAsmType *bType)
Set or clear FPSR EXC INAN bit.
Main namespace for the ROSE library.
virtual RegisterDescriptor callReturnRegister() const ROSE_OVERRIDE
Returns the function call return address register.
void updateFpsrExcOvfl(const BaseSemantics::SValuePtr &intermediate, SgAsmType *valueType, SgAsmType *rounding, SgAsmType *dstType)
Set or clear FPSR EXC OVFL bit.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
void updateFpsrExcInex()
Set or clear FPSR EXC INEX bit.
Base classes for instruction semantics.
Definition: Dispatcher.h:18
DispatcherM68kPtr Ptr
Shared-ownership pointer.
Describes (part of) a physical CPU register.
size_t addressWidth() const
Property: Width of memory addresses.
Definition: Dispatcher.h:225
static DispatcherM68kPtr promote(const BaseSemantics::DispatcherPtr &d)
Dynamic cast to DispatcherM68kPtr with assertion.
virtual RegisterDescriptor stackFrameRegister() const ROSE_OVERRIDE
Returns the stack call frame register.
static DispatcherM68kPtr instance(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth, const RegisterDictionary *regs=NULL)
Constructor.
const RegisterDictionary * regdict
See registerDictionary property.
Definition: Dispatcher.h:53
Base class for expressions.
Dispatches instructions through the RISC layer.
Definition: Dispatcher.h:44
void adjustFpConditionCodes(const BaseSemantics::SValuePtr &result, SgAsmFloatType *)
Set floating point condition codes according to result.
Rose::BinaryAnalysis::M68kInstructionKind get_kind() const
Property: Instruction kind.
Base class for binary types.
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.
Defines registers available for a particular architecture.
Definition: Registers.h:37
Floating point types.
void regcache_init()
Load the cached register descriptors.
void updateFpsrExcIde(const BaseSemantics::SValuePtr &a, SgAsmType *aType, const BaseSemantics::SValuePtr &b, SgAsmType *bType)
Set or clear FPSR EXC IDE bit.