ROSE  0.11.2.0
DispatcherM68k.h
1 #ifndef ROSE_DispatcherM68k_H
2 #define ROSE_DispatcherM68k_H
3 #include <rosePublicConfig.h>
4 #ifdef ROSE_BUILD_BINARY_ANALYSIS_SUPPORT
5 
6 #include "BaseSemantics2.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:
23 
24 public:
34  // Floating-point condition code bits
36  // Floating-point status register exception bits
39  // Floating-point status register accrued exception bits
43 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
44 private:
45  friend class boost::serialization::access;
46 
47  template<class S>
48  void save(S &s, const unsigned /*version*/) const {
49  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
50  };
51 
52  template<class S>
53  void load(S &s, const unsigned /*version*/) {
54  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
55  regcache_init();
56  iproc_init();
57  memory_init();
58  }
59 
60  BOOST_SERIALIZATION_SPLIT_MEMBER();
61 #endif
62 
63 protected:
64  // prototypical constructor
65  DispatcherM68k(): BaseSemantics::Dispatcher(32, RegisterDictionary::dictionary_coldfire_emac()) {}
66 
67  DispatcherM68k(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth, const RegisterDictionary *regs)
68  : BaseSemantics::Dispatcher(ops, addrWidth, regs ? regs : RegisterDictionary::dictionary_coldfire_emac()) {
69  ASSERT_require(32==addrWidth);
70  regcache_init();
71  iproc_init();
72  memory_init();
73  }
74 
76  void iproc_init();
77 
79  void regcache_init();
80 
82  void memory_init();
83 
84 public:
87  static DispatcherM68kPtr instance() {
89  }
90 
92  static DispatcherM68kPtr instance(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth,
93  const RegisterDictionary *regs=NULL) {
94  return DispatcherM68kPtr(new DispatcherM68k(ops, addrWidth, regs));
95  }
96 
99  const RegisterDictionary *regs=NULL) const ROSE_OVERRIDE {
100  if (0==addrWidth)
101  addrWidth = addressWidth();
102  if (!regs)
103  regs = get_register_dictionary();
104  return instance(ops, addrWidth, regs);
105  }
106 
108  static DispatcherM68kPtr promote(const BaseSemantics::DispatcherPtr &d) {
109  DispatcherM68kPtr retval = boost::dynamic_pointer_cast<DispatcherM68k>(d);
110  ASSERT_not_null(retval);
111  return retval;
112  }
113 
114  virtual void set_register_dictionary(const RegisterDictionary *regdict) ROSE_OVERRIDE;
115 
116  virtual RegisterDescriptor instructionPointerRegister() const ROSE_OVERRIDE;
117  virtual RegisterDescriptor stackPointerRegister() const ROSE_OVERRIDE;
118  virtual RegisterDescriptor callReturnRegister() const ROSE_OVERRIDE;
119 
120  virtual int iproc_key(SgAsmInstruction *insn_) const ROSE_OVERRIDE {
121  SgAsmM68kInstruction *insn = isSgAsmM68kInstruction(insn_);
122  ASSERT_not_null(insn);
123  return insn->get_kind();
124  }
125 
126  virtual BaseSemantics::SValuePtr read(SgAsmExpression*, size_t value_nbits, size_t addr_nbits=0) ROSE_OVERRIDE;
127 
129  void updateFpsrExcInan(const BaseSemantics::SValuePtr &a, SgAsmType *aType,
130  const BaseSemantics::SValuePtr &b, SgAsmType *bType);
131 
133  void updateFpsrExcIde(const BaseSemantics::SValuePtr &a, SgAsmType *aType,
134  const BaseSemantics::SValuePtr &b, SgAsmType *bType);
135 
141  void updateFpsrExcOvfl(const BaseSemantics::SValuePtr &intermediate, SgAsmType *valueType,
142  SgAsmType *rounding, SgAsmType *dstType);
143 
151  void updateFpsrExcUnfl(const BaseSemantics::SValuePtr &intermediate, SgAsmType *valueType,
152  SgAsmType *rounding, SgAsmType *dstType);
153 
155  void updateFpsrExcInex();
156 
158  BaseSemantics::SValuePtr condition(M68kInstructionKind, BaseSemantics::RiscOperators*);
159 
161  void accumulateFpExceptions();
162 
164  void adjustFpConditionCodes(const BaseSemantics::SValuePtr &result, SgAsmFloatType*);
165 };
166 
167 } // namespace
168 } // namespace
169 } // namespace
170 
171 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
173 #endif
174 
175 #endif
176 #endif
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
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.
virtual const RegisterDictionary * get_register_dictionary() const
Access the register dictionary.
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.
Describes (part of) a physical CPU register.
size_t addressWidth() const
Property: Width of memory addresses.
static DispatcherM68kPtr promote(const BaseSemantics::DispatcherPtr &d)
Dynamic cast to DispatcherM68kPtr with assertion.
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.
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:38
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.
void updateFpsrExcIde(const BaseSemantics::SValuePtr &a, SgAsmType *aType, const BaseSemantics::SValuePtr &b, SgAsmType *bType)
Set or clear FPSR EXC IDE bit.
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...