ROSE  0.9.9.139
DispatcherPowerpc.h
1 // Semantics for 32-bit Motorola-IBM PowerPC microprocessors using ROSE instruction semantics API2
2 // This code was derived from $ROSE/projects/assemblyToSourceAst/powerpcInstructionSemantics.h,
3 // which is mostly a copy of $ROSE/projects/SemanticSignatureVectors/powerpcInstructionSemantics.h
4 //
5 // The ROSE style guide indicates that PowerPC, when used as part of a symbol in ROSE source code,
6 // should be capitalized as "Powerpc" (e.g., "DispatcherPowerpc", the same rule that consistently
7 // capitializes x86 as "DispatcherX86").
8 
9 #ifndef ROSE_DispatcherPpc_H
10 #define ROSE_DispatcherPpc_H
11 
12 #include "BaseSemantics2.h"
13 
14 namespace Rose {
15 namespace BinaryAnalysis {
16 namespace InstructionSemantics2 {
17 
19 typedef boost::shared_ptr<class DispatcherPowerpc> DispatcherPowerpcPtr;
20 
22 protected:
23  // prototypical constructor
25 
26  DispatcherPowerpc(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth, const RegisterDictionary *regs)
27  : BaseSemantics::Dispatcher(ops, addrWidth, regs ? regs : RegisterDictionary::dictionary_powerpc()) {
28  ASSERT_require(32==addrWidth);
29  regcache_init();
30  iproc_init();
31  memory_init();
32  }
33 
35  void iproc_init();
36 
38  void regcache_init();
39 
41  void memory_init();
42 
43 public:
52  static DispatcherPowerpcPtr instance() {
54  }
55 
57  static DispatcherPowerpcPtr instance(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth,
58  const RegisterDictionary *regs=NULL) {
59  return DispatcherPowerpcPtr(new DispatcherPowerpc(ops, addrWidth, regs));
60  }
61 
64  const RegisterDictionary *regs=NULL) const ROSE_OVERRIDE {
65  if (0==addrWidth)
66  addrWidth = addressWidth();
67  if (!regs)
68  regs = get_register_dictionary();
69  return instance(ops, addrWidth, regs);
70  }
71 
73  static DispatcherPowerpcPtr promote(const BaseSemantics::DispatcherPtr &d) {
74  DispatcherPowerpcPtr retval = boost::dynamic_pointer_cast<DispatcherPowerpc>(d);
75  assert(retval!=NULL);
76  return retval;
77  }
78 
79  virtual void set_register_dictionary(const RegisterDictionary *regdict) ROSE_OVERRIDE;
80 
81  virtual RegisterDescriptor instructionPointerRegister() const ROSE_OVERRIDE;
82 
83  virtual RegisterDescriptor stackPointerRegister() const ROSE_OVERRIDE;
84 
85  virtual int iproc_key(SgAsmInstruction *insn_) const ROSE_OVERRIDE {
86  SgAsmPowerpcInstruction *insn = isSgAsmPowerpcInstruction(insn_);
87  assert(insn!=NULL);
88  return insn->get_kind();
89  }
90 
92  virtual void record(const BaseSemantics::SValuePtr &result);
93 };
94 
95 } // namespace
96 } // namespace
97 } // namespace
98 
99 #endif
virtual RegisterDescriptor stackPointerRegister() const ROSE_OVERRIDE
Returns the stack pointer register.
Base class for machine instructions.
Main namespace for the ROSE library.
Describes (part of) a physical CPU register.
void regcache_init()
Load the cached register descriptors.
virtual const RegisterDictionary * get_register_dictionary() const
Access the register dictionary.
void memory_init()
Make sure memory is set up correctly.
virtual void set_register_dictionary(const RegisterDictionary *regdict) ROSE_OVERRIDE
Access the register dictionary.
boost::shared_ptr< class Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
virtual RegisterDescriptor instructionPointerRegister() const ROSE_OVERRIDE
Returns the instruction pointer register.
virtual BaseSemantics::DispatcherPtr create(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth=0, const RegisterDictionary *regs=NULL) const ROSE_OVERRIDE
Virtual constructor.
size_t addressWidth() const
Property: Width of memory addresses.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
boost::shared_ptr< class DispatcherPowerpc > DispatcherPowerpcPtr
Shared-ownership pointer to a PowerPC instruction dispatcher.
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...
PowerpcInstructionKind get_kind() const
Property: Instruction kind.
Represents one PowerPC machine instruction.
static const RegisterDictionary * dictionary_powerpc()
PowerPC registers.
Defines registers available for a particular architecture.
Definition: Registers.h:32
void iproc_init()
Loads the iproc table with instruction processing functors.
const RegisterDictionary * regdict
See set_register_dictionary().
virtual void record(const BaseSemantics::SValuePtr &result)
Write status flags for result.
static DispatcherPowerpcPtr instance()
Construct a prototypical dispatcher.
static DispatcherPowerpcPtr instance(const BaseSemantics::RiscOperatorsPtr &ops, size_t addrWidth, const RegisterDictionary *regs=NULL)
Constructor.
static DispatcherPowerpcPtr promote(const BaseSemantics::DispatcherPtr &d)
Dynamic cast to a DispatcherPowerpcPtr with assertion.