ROSE  0.11.50.0
LlvmSemantics.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_LlvmSemantics_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_LlvmSemantics_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <Rose/BinaryAnalysis/InstructionSemantics2/SymbolicSemantics.h>
7 #include <Rose/BinaryAnalysis/InstructionSemantics2/DispatcherX86.h>
8 #include <Rose/CommandLine.h>
9 
10 namespace Rose {
11 namespace BinaryAnalysis {
12 namespace InstructionSemantics2 {
13 
15 namespace LlvmSemantics {
16 
17 typedef std::vector<RegisterDescriptor> RegisterDescriptors;
18 
24 typedef SymbolicExpr::Nodes TreeNodes;
25 
28 
29 typedef BaseSemantics::RegisterStateGenericPtr RegisterStatePtr;
31 
32 typedef SymbolicSemantics::MemoryStatePtr MemoryStatePtr;
34 
35 typedef BaseSemantics::StatePtr StatePtr;
36 typedef BaseSemantics::State State;
37 
39 typedef boost::shared_ptr<class RiscOperators> RiscOperatorsPtr;
40 
42 public:
45 
48 
49 private:
52 
53  Rewrites rewrites; // maps expressions to LLVM variables
54  Variables variables; // ROSE-to-LLVM variable map; name includes sigil
55  RegisterStatePtr prev_regstate; // most recently emitted register state
56  RegisterDescriptors important_registers; // registers that should be emitted to LLVM
57  TreeNodes mem_writes; // memory write operations (OP_WRITE expressions)
58  int indent_level; // level of indentation (might be negative, but prefix() clips to zero
59  std::string indent_string; // white space per indentation level
60  int llvmVersion_; // 1000000*major + 1000*minor + patch. e.g., 3005000 = llvm-3.5.0
61 
63  // Real constructors
64 protected:
66  : SymbolicSemantics::RiscOperators(protoval, solver), indent_level(0), indent_string(" "), llvmVersion_(0) {
67  name("Llvm");
68  }
69 
70  explicit RiscOperators(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver = SmtSolverPtr())
71  : SymbolicSemantics::RiscOperators(state, solver), indent_level(0), indent_string(" "), llvmVersion_(0) {
72  name("Llvm");
73  }
74 
76  // Static allocating constructors
77 public:
80  static RiscOperatorsPtr instance(const RegisterDictionary *regdict, const SmtSolverPtr &solver = SmtSolverPtr()) {
82  BaseSemantics::RegisterStatePtr registers = RegisterState::instance(protoval, regdict);
83  BaseSemantics::MemoryStatePtr memory = MemoryState::instance(protoval, protoval);
84  BaseSemantics::StatePtr state = State::instance(registers, memory);
85  return RiscOperatorsPtr(new RiscOperators(state, solver));
86  }
87 
89  static RiscOperatorsPtr instance(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver = SmtSolverPtr()) {
90  return RiscOperatorsPtr(new RiscOperators(protoval, solver));
91  }
92 
94  static RiscOperatorsPtr instance(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver = SmtSolverPtr()) {
95  return RiscOperatorsPtr(new RiscOperators(state, solver));
96  }
97 
99  // Virtual constructors
100 public:
102  const SmtSolverPtr &solver = SmtSolverPtr()) const ROSE_OVERRIDE {
103  return instance(protoval, solver);
104  }
105 
107  const SmtSolverPtr &solver = SmtSolverPtr()) const ROSE_OVERRIDE {
108  return instance(state, solver);
109  }
110 
112  // Dynamic pointer cases
113 public:
116  static RiscOperatorsPtr promote(const BaseSemantics::RiscOperatorsPtr &x) {
117  RiscOperatorsPtr retval = boost::dynamic_pointer_cast<RiscOperators>(x);
118  assert(retval!=NULL);
119  return retval;
120  }
121 
123  // Properties
124 public:
132  int llvmVersion() const { return llvmVersion_; }
133  void llvmVersion(int v) { llvmVersion_ = v; }
136  // Methods we override from the super class
138 public:
140  const BaseSemantics::SValuePtr &dflt,
141  const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE;
142  virtual void writeMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr,
143  const BaseSemantics::SValuePtr &data, const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE;
144 
146  // Methods to control indentation of LLVM output
147 public:
151  int indent(int nlevels=1) { indent_level += nlevels; return nlevels; }
152 
154  std::string prefix() const;
155 
157  struct Indent {
158  RiscOperators *ops;
159  RiscOperatorsPtr ops_ptr;
160  int nlevels;
161  explicit Indent(const RiscOperatorsPtr &ops_ptr, int nlevels=1): ops_ptr(ops_ptr), nlevels(nlevels) {
162  ops = ops_ptr.get();
163  ops->indent(nlevels);
164  }
165  explicit Indent(RiscOperators *ops, int nlevels=1): ops(ops), nlevels(nlevels) {
166  ops->indent(nlevels);
167  }
168  ~Indent() {
169  ops->indent(-nlevels);
170  }
171  };
172 
174  // New methods to control/query the machine state
175 public:
177  virtual void reset();
178 
181  virtual const RegisterDescriptors& get_important_registers();
182 
185  virtual RegisterDescriptors get_stored_registers();
186 
188  virtual RegisterDescriptors get_modified_registers();
189 
192 
194  virtual SValuePtr get_instruction_pointer();
195 
199  virtual const TreeNodes& get_memory_writes() { return mem_writes; }
200 
202  virtual void make_current();
203 
205  virtual void add_rewrite(const ExpressionPtr &from, const LeafPtr &to);
206 
209  virtual std::string add_variable(const LeafPtr&);
210 
213  virtual std::string get_variable(const LeafPtr&);
214 
216  // New methods to emit the machine state
217 public:
219  virtual void emit_register_declarations(std::ostream&, const RegisterDescriptors&);
220 
222  virtual void emit_register_definitions(std::ostream&, const RegisterDescriptors&);
223 
250  virtual void emit_prerequisites(std::ostream&, const RegisterDescriptors&, const RegisterDictionary*);
251 
254  virtual void emit_next_eip(std::ostream&, SgAsmInstruction *latest_insn);
255 
257  virtual void emit_memory_writes(std::ostream&);
258 
260  virtual void emit_changed_state(std::ostream&);
261 
263  // New methods to return snippets of LLVM as strings or expressions
264 public:
266  virtual std::string llvm_integer_type(size_t nbits);
267 
269  virtual std::string llvm_term(const ExpressionPtr&);
270 
273  virtual std::string llvm_lvalue(const LeafPtr&);
274 
276  virtual LeafPtr next_temporary(size_t nbits);
277 
279  virtual std::string next_label();
280 
282  virtual std::string addr_label(rose_addr_t);
283 
285  virtual std::string function_label(SgAsmFunction*);
286 
288  // New methods to emit LLVM code for an expression.
289 public:
307  virtual LeafPtr emit_expression(std::ostream&, const SValuePtr&);
308  virtual LeafPtr emit_expression(std::ostream&, const ExpressionPtr&);
309  virtual LeafPtr emit_expression(std::ostream&, const LeafPtr&);
312 protected:
316  virtual LeafPtr emit_assignment(std::ostream&, const ExpressionPtr &rhs);
317 
324  virtual ExpressionPtr emit_zero_extend(std::ostream&, const ExpressionPtr &value, size_t nbits);
325  virtual ExpressionPtr emit_sign_extend(std::ostream&, const ExpressionPtr &value, size_t nbits);
326  virtual ExpressionPtr emit_truncate(std::ostream&, const ExpressionPtr &value, size_t nbits);
327  virtual ExpressionPtr emit_unsigned_resize(std::ostream&, const ExpressionPtr &value, size_t nbits);
328  virtual ExpressionPtr emit_binary(std::ostream&, const std::string &llvm_op, const ExpressionPtr&, const ExpressionPtr&);
329  virtual ExpressionPtr emit_signed_binary(std::ostream&, const std::string &llvm_op, const ExpressionPtr&, const ExpressionPtr&);
330  virtual ExpressionPtr emit_unsigned_binary(std::ostream&, const std::string &llvm_op, const ExpressionPtr&, const ExpressionPtr&);
331  virtual ExpressionPtr emit_logical_right_shift(std::ostream&, const ExpressionPtr &value, const ExpressionPtr &amount);
332  virtual ExpressionPtr emit_logical_right_shift_ones(std::ostream&, const ExpressionPtr &value, const ExpressionPtr &amount);
333  virtual ExpressionPtr emit_arithmetic_right_shift(std::ostream&, const ExpressionPtr &value, const ExpressionPtr &amount);
334  virtual ExpressionPtr emit_left_shift(std::ostream&, const ExpressionPtr &value, const ExpressionPtr &amount);
335  virtual ExpressionPtr emit_left_shift_ones(std::ostream&, const ExpressionPtr &value, const ExpressionPtr &amount);
336  virtual ExpressionPtr emit_lssb(std::ostream&, const ExpressionPtr&);
337  virtual ExpressionPtr emit_mssb(std::ostream&, const ExpressionPtr&);
338  virtual ExpressionPtr emit_extract(std::ostream&, const ExpressionPtr &value, const ExpressionPtr &from, size_t result_nbits);
339  virtual ExpressionPtr emit_invert(std::ostream&, const ExpressionPtr &value);
340  virtual ExpressionPtr emit_left_associative(std::ostream&, const std::string &llvm_op, const TreeNodes &operands);
341  virtual ExpressionPtr emit_concat(std::ostream&, TreeNodes operands);
342  virtual ExpressionPtr emit_signed_divide(std::ostream&, const ExpressionPtr &numerator, const ExpressionPtr &denominator);
343  virtual ExpressionPtr emit_unsigned_divide(std::ostream&, const ExpressionPtr &numerator, const ExpressionPtr &denominator);
344  virtual ExpressionPtr emit_signed_modulo(std::ostream&, const ExpressionPtr &numerator, const ExpressionPtr &denominator);
345  virtual ExpressionPtr emit_unsigned_modulo(std::ostream&, const ExpressionPtr &numerator, const ExpressionPtr &denominator);
346  virtual ExpressionPtr emit_signed_multiply(std::ostream&, const TreeNodes &operands);
347  virtual ExpressionPtr emit_unsigned_multiply(std::ostream&, const TreeNodes &operands);
348  virtual ExpressionPtr emit_rotate_left(std::ostream&, const ExpressionPtr &value, const ExpressionPtr &amount);
349  virtual ExpressionPtr emit_rotate_right(std::ostream&, const ExpressionPtr &value, const ExpressionPtr &amount);
350  virtual ExpressionPtr emit_compare(std::ostream&, const std::string &llvm_op, const ExpressionPtr&, const ExpressionPtr&);
351  virtual ExpressionPtr emit_ite(std::ostream&, const ExpressionPtr &cond, const ExpressionPtr&, const ExpressionPtr&);
352  virtual ExpressionPtr emit_memory_read(std::ostream&, const ExpressionPtr &address, size_t nbits);
353  virtual ExpressionPtr emit_global_read(std::ostream&, const std::string &varname, size_t nbits);
354  virtual void emit_memory_write(std::ostream&, const ExpressionPtr &address, const ExpressionPtr &value);
356 };
357 
359 typedef boost::shared_ptr<class Transcoder> TranscoderPtr;
360 
362 class Transcoder {
363 private:
364  RiscOperatorsPtr operators;
365  BaseSemantics::DispatcherPtr dispatcher;
366  bool emit_funcfrags; // emit BBs that aren't part of the CFG?
367  bool quiet_errors; // catch exceptions and emit an LLVM comment instead?
368 
369 protected:
370  explicit Transcoder(const BaseSemantics::DispatcherPtr &dispatcher)
371  : dispatcher(dispatcher), emit_funcfrags(false), quiet_errors(false) {
372  operators = RiscOperators::promote(dispatcher->operators());
373  }
374 
375 public:
378  static TranscoderPtr instance(const BaseSemantics::DispatcherPtr &dispatcher) {
379  return TranscoderPtr(new Transcoder(dispatcher));
380  }
381 
383  static TranscoderPtr instanceX86() {
386  RiscOperatorsPtr ops = RiscOperators::instance(regdict, solver);
388  return instance(dispatcher);
389  }
390 
399  int llvmVersion() const;
400  void llvmVersion(int version);
408  bool emitFunctionFragements() const { return emit_funcfrags; }
409  void emitFunctionFragements(bool b) { emit_funcfrags = b; }
416  bool quietErrors() const { return quiet_errors; }
417  void quietErrors(bool b) { quiet_errors = b; }
422  void emitFilePrologue(std::ostream&);
423  std::string emitFilePrologue();
428  void emitFunctionDeclarations(SgNode *ast, std::ostream&);
429  std::string emitFunctionDeclarations(SgNode *ast);
435  void transcodeInstruction(SgAsmInstruction*, std::ostream&);
442  size_t transcodeBasicBlock(SgAsmBlock*, std::ostream&);
443  std::string transcodeBasicBlock(SgAsmBlock*);
449  size_t transcodeFunction(SgAsmFunction*, std::ostream&);
450  std::string transcodeFunction(SgAsmFunction*);
456  void transcodeInterpretation(SgAsmInterpretation*, std::ostream&);
459 };
460 
461 } // namespace
462 } // namespace
463 } // namespace
464 } // namespace
465 
466 #endif
467 #endif
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Virtual allocating constructor.
virtual RegisterDescriptor get_insn_pointer_register()
Return the descriptor for the instruction pointer register.
size_t transcodeBasicBlock(SgAsmBlock *, std::ostream &)
Transcode a basic block of machine instructions to LLVM instructions.
static RegisterStateGenericPtr instance(const SValuePtr &protoval, const RegisterDictionary *regdict)
Instantiate a new register state.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
static TranscoderPtr instance(const BaseSemantics::DispatcherPtr &dispatcher)
Factory method to create a new transcoder for an arbitrary machine architecture.
virtual void make_current()
Mark the current state as having been emitted.
virtual BaseSemantics::SValuePtr readMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt, const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE
Reads a value from memory.
virtual ExpressionPtr emit_unsigned_modulo(std::ostream &, const ExpressionPtr &numerator, const ExpressionPtr &denominator)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_invert(std::ostream &, const ExpressionPtr &value)
Emit an operation as LLVM instructions.
static RiscOperatorsPtr promote(const BaseSemantics::RiscOperatorsPtr &x)
Run-time promotion of a base RiscOperators pointer to Llvm operators.
Leaf node of an expression tree for instruction semantics.
Defines RISC operators for the SymbolicSemantics domain.
virtual const TreeNodes & get_memory_writes()
Return the list of memory writes that have occured since the last call to make_current().
boost::shared_ptr< class RegisterStateGeneric > RegisterStateGenericPtr
Shared-ownership pointer to generic register states.
virtual const RegisterDescriptors & get_important_registers()
Return the list of registers that needs to be emitted to LLVM.
virtual std::string llvm_integer_type(size_t nbits)
Obtain the LLVM type name for an integer.
Instruction basic block.
Interior node of an expression tree for instruction semantics.
Base class for machine instructions.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
std::string prefix() const
Return indentation string.
boost::shared_ptr< class Transcoder > TranscoderPtr
Shared-ownership pointer to an LLVM transcoder.
virtual ExpressionPtr emit_sign_extend(std::ostream &, const ExpressionPtr &value, size_t nbits)
Emit an operation as LLVM instructions.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
virtual ExpressionPtr emit_global_read(std::ostream &, const std::string &varname, size_t nbits)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_unsigned_binary(std::ostream &, const std::string &llvm_op, const ExpressionPtr &, const ExpressionPtr &)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_unsigned_resize(std::ostream &, const ExpressionPtr &value, size_t nbits)
Emit an operation as LLVM instructions.
virtual void emit_register_definitions(std::ostream &, const RegisterDescriptors &)
Output LLVM global register definitions for the specified registers.
virtual void writeMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &data, const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE
Writes a value to memory.
bool emitFunctionFragements() const
Property to determine whether function fragments should be emitted.
virtual ExpressionPtr emit_signed_multiply(std::ostream &, const TreeNodes &operands)
Emit an operation as LLVM instructions.
static RiscOperatorsPtr instance(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr())
Instantiates a new RiscOperators object with specified prototypical values.
Definition: LlvmSemantics.h:89
static const RegisterDictionary * dictionary_pentium4()
Intel Pentium 4 registers.
Represents a synthesized function.
void transcodeInstruction(SgAsmInstruction *, std::ostream &)
Translate a single machine instruction to LLVM instructions.
virtual RegisterDescriptors get_modified_registers()
Return the list of important registers that have been modified since the last call to make_current()...
size_t transcodeFunction(SgAsmFunction *, std::ostream &)
Transcode an entire function to LLVM instructions.
virtual void add_rewrite(const ExpressionPtr &from, const LeafPtr &to)
Register a rewrite.
virtual void emit_register_declarations(std::ostream &, const RegisterDescriptors &)
Output LLVM global register declarations for the specified registers.
virtual SValuePtr protoval() const
Property: Prototypical semantic value.
Main namespace for the ROSE library.
virtual std::string next_label()
Obtain the name for an LLVM label, excluding the "%" sigil.
virtual ExpressionPtr emit_logical_right_shift(std::ostream &, const ExpressionPtr &value, const ExpressionPtr &amount)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_rotate_left(std::ostream &, const ExpressionPtr &value, const ExpressionPtr &amount)
Emit an operation as LLVM instructions.
static MemoryListStatePtr instance(const BaseSemantics::MemoryCellPtr &protocell)
Instantiates a new memory state having specified prototypical cells and value.
virtual ExpressionPtr emit_truncate(std::ostream &, const ExpressionPtr &value, size_t nbits)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_binary(std::ostream &, const std::string &llvm_op, const ExpressionPtr &, const ExpressionPtr &)
Emit an operation as LLVM instructions.
Reference-counting intrusive smart pointer.
Definition: SharedPointer.h:68
virtual ExpressionPtr emit_unsigned_divide(std::ostream &, const ExpressionPtr &numerator, const ExpressionPtr &denominator)
Emit an operation as LLVM instructions.
virtual std::string llvm_term(const ExpressionPtr &)
Convert a ROSE variable or integer to an LLVM term.
virtual LeafPtr emit_assignment(std::ostream &, const ExpressionPtr &rhs)
Emit an assignment and add a rewrite rule.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
virtual std::string add_variable(const LeafPtr &)
Register an LLVM variable.
void quietErrors(bool b)
Property to control what happens when a translation exception occurs.
virtual ExpressionPtr emit_signed_divide(std::ostream &, const ExpressionPtr &numerator, const ExpressionPtr &denominator)
Emit an operation as LLVM instructions.
virtual LeafPtr next_temporary(size_t nbits)
Create a temporary variable.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to LLVM RISC operations.
Definition: LlvmSemantics.h:39
virtual std::string function_label(SgAsmFunction *)
Obtain a label for a function.
virtual void emit_memory_writes(std::ostream &)
Output changed memory state.
static Ptr instance(const std::string &name)
Allocate a new solver by name.
Describes (part of) a physical CPU register.
void emitFunctionFragements(bool b)
Property to determine whether function fragments should be emitted.
virtual ExpressionPtr emit_rotate_right(std::ostream &, const ExpressionPtr &value, const ExpressionPtr &amount)
Emit an operation as LLVM instructions.
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:9555
virtual ExpressionPtr emit_extract(std::ostream &, const ExpressionPtr &value, const ExpressionPtr &from, size_t result_nbits)
Emit an operation as LLVM instructions.
static SValuePtr instance()
Instantiate a new prototypical value.
virtual RegisterDescriptors get_stored_registers()
Return the list of important registers that are stored.
virtual ExpressionPtr emit_left_shift_ones(std::ostream &, const ExpressionPtr &value, const ExpressionPtr &amount)
Emit an operation as LLVM instructions.
virtual LeafPtr emit_expression(std::ostream &, const SValuePtr &)
Emit LLVM statements for an expression.
virtual void emit_changed_state(std::ostream &)
Output LLVM to bring the LLVM state up to date with respect to the ROSE state.
virtual void emit_next_eip(std::ostream &, SgAsmInstruction *latest_insn)
Output an LLVM branch instruction.
virtual ExpressionPtr emit_logical_right_shift_ones(std::ostream &, const ExpressionPtr &value, const ExpressionPtr &amount)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_signed_binary(std::ostream &, const std::string &llvm_op, const ExpressionPtr &, const ExpressionPtr &)
Emit an operation as LLVM instructions.
bool quietErrors() const
Property to control what happens when a translation exception occurs.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Virtual allocating constructor.
virtual ExpressionPtr emit_left_associative(std::ostream &, const std::string &llvm_op, const TreeNodes &operands)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_arithmetic_right_shift(std::ostream &, const ExpressionPtr &value, const ExpressionPtr &amount)
Emit an operation as LLVM instructions.
virtual void emit_memory_write(std::ostream &, const ExpressionPtr &address, const ExpressionPtr &value)
Emit an operation as LLVM instructions.
Type of values manipulated by the SymbolicSemantics domain.
virtual std::string llvm_lvalue(const LeafPtr &)
Convert a ROSE variable to an LLVM lvalue.
void emitFunctionDeclarations(SgNode *ast, std::ostream &)
Emit function declarations.
virtual SValuePtr get_instruction_pointer()
Return the value of the instruction pointer.
static RiscOperatorsPtr instance(const RegisterDictionary *regdict, const SmtSolverPtr &solver=SmtSolverPtr())
Instantiates a new RiscOperators object and configures it to use semantic values and states that are ...
Definition: LlvmSemantics.h:80
virtual ExpressionPtr emit_memory_read(std::ostream &, const ExpressionPtr &address, size_t nbits)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_ite(std::ostream &, const ExpressionPtr &cond, const ExpressionPtr &, const ExpressionPtr &)
Emit an operation as LLVM instructions.
static DispatcherX86Ptr instance()
Construct a prototypical dispatcher.
void transcodeInterpretation(SgAsmInterpretation *, std::ostream &)
Transcode an entire binary interpretation.
virtual ExpressionPtr emit_mssb(std::ostream &, const ExpressionPtr &)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_compare(std::ostream &, const std::string &llvm_op, const ExpressionPtr &, const ExpressionPtr &)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_left_shift(std::ostream &, const ExpressionPtr &value, const ExpressionPtr &amount)
Emit an operation as LLVM instructions.
Defines registers available for a particular architecture.
Definition: Registers.h:37
virtual SmtSolverPtr solver() const
Property: Satisfiability module theory (SMT) solver.
virtual ExpressionPtr emit_unsigned_multiply(std::ostream &, const TreeNodes &operands)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_concat(std::ostream &, TreeNodes operands)
Emit an operation as LLVM instructions.
virtual ExpressionPtr emit_signed_modulo(std::ostream &, const ExpressionPtr &numerator, const ExpressionPtr &denominator)
Emit an operation as LLVM instructions.
virtual const std::string & name() const
Property: Name used for debugging.
virtual void emit_prerequisites(std::ostream &, const RegisterDescriptors &, const RegisterDictionary *)
Output LLVM global variable reads that are needed to define the specified registers and pending memor...
int indent(int nlevels=1)
Increase indentation by nlevels levels.
Represents an interpretation of a binary container.
ROSE_DLL_API GenericSwitchArgs genericSwitchArgs
Global location for parsed generic command-line switches.
virtual ExpressionPtr emit_lssb(std::ostream &, const ExpressionPtr &)
Emit an operation as LLVM instructions.
virtual std::string get_variable(const LeafPtr &)
Returns the LLVM name for a variable, including the sigil.
virtual std::string addr_label(rose_addr_t)
Obtain a label for a virtual address.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
std::shared_ptr< class SmtSolver > SmtSolverPtr
Reference-counting pointer for SMT solvers.
Definition: SmtSolver.h:25
static RiscOperatorsPtr instance(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver=SmtSolverPtr())
Instantiates a new RiscOperators object with specified state.
Definition: LlvmSemantics.h:94
static TranscoderPtr instanceX86()
Factory method to create a new transcoder for 32-bit X86 instructions.
virtual ExpressionPtr emit_zero_extend(std::ostream &, const ExpressionPtr &value, size_t nbits)
Emit an operation as LLVM instructions.