ROSE  0.11.23.0
DispatcherM68k.h
1 #ifndef ROSE_DispatcherM68k_H
2 #define ROSE_DispatcherM68k_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
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  initializeState(ops->currentState());
74  }
75 
77  void iproc_init();
78 
80  void regcache_init();
81 
83  void memory_init();
84 
85 public:
88  static DispatcherM68kPtr instance() {
90  }
91 
93  static DispatcherM68kPtr instance(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth,
94  const RegisterDictionary *regs=NULL) {
95  return DispatcherM68kPtr(new DispatcherM68k(ops, addrWidth, regs));
96  }
97 
100  const RegisterDictionary *regs=NULL) const ROSE_OVERRIDE {
101  if (0==addrWidth)
102  addrWidth = addressWidth();
103  if (!regs)
104  regs = get_register_dictionary();
105  return instance(ops, addrWidth, regs);
106  }
107 
109  static DispatcherM68kPtr promote(const BaseSemantics::DispatcherPtr &d) {
110  DispatcherM68kPtr retval = boost::dynamic_pointer_cast<DispatcherM68k>(d);
111  ASSERT_not_null(retval);
112  return retval;
113  }
114 
115  virtual void set_register_dictionary(const RegisterDictionary *regdict) ROSE_OVERRIDE;
116 
117  virtual RegisterDescriptor instructionPointerRegister() const ROSE_OVERRIDE;
118  virtual RegisterDescriptor stackPointerRegister() const ROSE_OVERRIDE;
119  virtual RegisterDescriptor callReturnRegister() const ROSE_OVERRIDE;
120 
121  virtual int iproc_key(SgAsmInstruction *insn_) const ROSE_OVERRIDE {
122  SgAsmM68kInstruction *insn = isSgAsmM68kInstruction(insn_);
123  ASSERT_not_null(insn);
124  return insn->get_kind();
125  }
126 
127  virtual BaseSemantics::SValuePtr read(SgAsmExpression*, size_t value_nbits, size_t addr_nbits=0) ROSE_OVERRIDE;
128 
130  void updateFpsrExcInan(const BaseSemantics::SValuePtr &a, SgAsmType *aType,
131  const BaseSemantics::SValuePtr &b, SgAsmType *bType);
132 
134  void updateFpsrExcIde(const BaseSemantics::SValuePtr &a, SgAsmType *aType,
135  const BaseSemantics::SValuePtr &b, SgAsmType *bType);
136 
142  void updateFpsrExcOvfl(const BaseSemantics::SValuePtr &intermediate, SgAsmType *valueType,
143  SgAsmType *rounding, SgAsmType *dstType);
144 
152  void updateFpsrExcUnfl(const BaseSemantics::SValuePtr &intermediate, SgAsmType *valueType,
153  SgAsmType *rounding, SgAsmType *dstType);
154 
156  void updateFpsrExcInex();
157 
159  BaseSemantics::SValuePtr condition(M68kInstructionKind, BaseSemantics::RiscOperators*);
160 
162  void accumulateFpExceptions();
163 
165  void adjustFpConditionCodes(const BaseSemantics::SValuePtr &result, SgAsmFloatType*);
166 };
167 
168 } // namespace
169 } // namespace
170 } // namespace
171 
172 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
174 #endif
175 
176 #endif
177 #endif
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.
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...