ROSE  0.9.9.109
StaticSemantics2.h
1 // Turn instruction semantics into part of the AST
2 #ifndef Rose_StaticSemantics2_H
3 #define Rose_StaticSemantics2_H
4 
5 #include "Disassembler.h"
6 #include "NullSemantics2.h"
7 #include "sageBuilderAsm.h"
8 
9 namespace Rose {
10 namespace BinaryAnalysis { // documented elsewhere
11 namespace InstructionSemantics2 { // documented elsewhere
12 
37 namespace StaticSemantics {
38 
40 // Free functions
42 
58 // Value type
61 
64 
73 protected:
74  SgAsmExpression *ast_;
75 
76 protected:
78  static uint64_t nVars = 0;
79  ast_ = SageBuilderAsm::buildRiscOperation(op, SageBuilderAsm::buildValueU64(nVars++));
80  }
81 
82  SValue(size_t nbits, uint64_t number): BaseSemantics::SValue(nbits) {
83  SgAsmType *type = SgAsmType::registerOrDelete(new SgAsmIntegerType(ByteOrder::ORDER_LSB, nbits,
84  false /*unsigned*/));
85  ast_ = SageBuilderAsm::buildValueInteger(number, type);
86  }
87 
88  SValue(const SValue &other): BaseSemantics::SValue(other) {
89  SgTreeCopy deep;
90  SgNode *copied = ast_->copy(deep);
91  ASSERT_require(isSgAsmExpression(copied));
92  ast_ = isSgAsmExpression(copied);
93  }
94 
95 public:
99  static SValuePtr instance() {
100  return SValuePtr(new SValue(1, SgAsmRiscOperation::OP_undefined));
101  }
102 
104  static SValuePtr instance_bottom(size_t nbits) {
105  return SValuePtr(new SValue(nbits, SgAsmRiscOperation::OP_bottom));
106  }
107 
113  static SValuePtr instance_undefined(size_t nbits) {
114  return SValuePtr(new SValue(nbits, SgAsmRiscOperation::OP_undefined));
115  }
116 
122  static SValuePtr instance_unspecified(size_t nbits) {
123  return SValuePtr(new SValue(nbits, SgAsmRiscOperation::OP_unspecified));
124  }
125 
127  static SValuePtr instance_integer(size_t nbits, uint64_t value) {
128  return SValuePtr(new SValue(nbits, value));
129  }
130 
131 public:
132  virtual BaseSemantics::SValuePtr bottom_(size_t nbits) const ROSE_OVERRIDE {
133  return instance_bottom(nbits);
134  }
135  virtual BaseSemantics::SValuePtr undefined_(size_t nbits) const ROSE_OVERRIDE {
136  return instance_undefined(nbits);
137  }
138  virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) const ROSE_OVERRIDE {
139  return instance_unspecified(nbits);
140  }
141  virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) const ROSE_OVERRIDE {
142  return instance_integer(nbits, value);
143  }
144  virtual BaseSemantics::SValuePtr boolean_(bool value) const ROSE_OVERRIDE {
145  return instance_integer(1, value ? 1 : 0);
146  }
147  virtual BaseSemantics::SValuePtr copy(size_t new_width=0) const ROSE_OVERRIDE {
148  SValuePtr retval(new SValue(*this));
149  if (new_width!=0 && new_width!=retval->get_width())
150  retval->set_width(new_width);
151  return retval;
152  }
155  throw BaseSemantics::NotImplemented("StaticSemantics is not suitable for dataflow analysis", NULL);
156  }
157 
158 public:
160  static SValuePtr promote(const BaseSemantics::SValuePtr &v) { // hot
161  SValuePtr retval = v.dynamicCast<SValue>();
162  ASSERT_not_null(retval);
163  return retval;
164  }
165 
166 public:
167  // These are not needed since this domain never tries to compare semantic values.
168  virtual bool may_equal(const BaseSemantics::SValuePtr &other, SMTSolver *solver=NULL) const ROSE_OVERRIDE {
169  ASSERT_not_reachable("no implementation necessary");
170  }
171 
172  virtual bool must_equal(const BaseSemantics::SValuePtr &other, SMTSolver *solver=NULL) const ROSE_OVERRIDE {
173  ASSERT_not_reachable("no implementation necessary");
174  }
175 
176  virtual void set_width(size_t nbits) ROSE_OVERRIDE {
177  ASSERT_not_reachable("no implementation necessary");
178  }
179 
180  virtual bool isBottom() const ROSE_OVERRIDE {
181  return false;
182  }
183 
184  virtual bool is_number() const ROSE_OVERRIDE {
185  return false;
186  }
187 
188  virtual uint64_t get_number() const ROSE_OVERRIDE {
189  ASSERT_not_reachable("no implementation necessary");
190  }
191 
192  virtual void print(std::ostream&, BaseSemantics::Formatter&) const ROSE_OVERRIDE;
193 
194 public:
198  virtual SgAsmExpression* ast() {
199  return ast_;
200  }
201  virtual void ast(SgAsmExpression *x) {
202  ASSERT_not_null(x);
203  ASSERT_require(x->get_parent() == NULL);
204  ast_ = x;
205  }
207 };
208 
210 // State
212 
213 // No state necessary for this domain. All instruction side effects are immediately attached to the SgAsmInstruction node
214 // rather than being stored in some state.
215 
216 typedef NullSemantics::RegisterState RegisterState;
217 typedef NullSemantics::RegisterStatePtr RegisterStatePtr;
218 
219 typedef NullSemantics::MemoryState MemoryState;
220 typedef NullSemantics::MemoryStatePtr MemoryStatePtr;
221 
222 typedef NullSemantics::State State;
223 typedef NullSemantics::StatePtr StatePtr;
224 
225 
227 // RiscOperators
229 
231 typedef boost::shared_ptr<class RiscOperators> RiscOperatorsPtr;
232 
243 protected:
245  : BaseSemantics::RiscOperators(protoval, solver) {
246  name("StaticSemantics");
247  (void) SValue::promote(protoval); // make sure its dynamic type is a StaticSemantics::SValue
248  }
249 
250  RiscOperators(const BaseSemantics::StatePtr &state, SMTSolver *solver)
251  : BaseSemantics::RiscOperators(state, solver) {
252  name("StaticSemantics");
253  (void) SValue::promote(state->protoval()); // values must have StaticSemantics::SValue dynamic type
254  }
255 
256 public:
259  static RiscOperatorsPtr instance(const RegisterDictionary *regdict, SMTSolver *solver=NULL) {
261  BaseSemantics::RegisterStatePtr registers = RegisterState::instance(protoval, regdict);
262  BaseSemantics::MemoryStatePtr memory = MemoryState::instance(protoval, protoval);
263  BaseSemantics::StatePtr state = State::instance(registers, memory);
264  return RiscOperatorsPtr(new RiscOperators(state, solver));
265  }
266 
270  static RiscOperatorsPtr instance(const BaseSemantics::SValuePtr &protoval, SMTSolver *solver=NULL) {
271  return RiscOperatorsPtr(new RiscOperators(protoval, solver));
272  }
273 
276  static RiscOperatorsPtr instance(const BaseSemantics::StatePtr &state, SMTSolver *solver=NULL) {
277  return RiscOperatorsPtr(new RiscOperators(state, solver));
278  }
279 
281  // Virtual constructors
282 public:
284  SMTSolver *solver=NULL) const ROSE_OVERRIDE {
285  return instance(protoval, solver);
286  }
287 
289  SMTSolver *solver=NULL) const ROSE_OVERRIDE {
290  return instance(state, solver);
291  }
292 
294  // Dynamic pointer casts
295 public:
298  static RiscOperatorsPtr promote(const BaseSemantics::RiscOperatorsPtr &x) {
299  RiscOperatorsPtr retval = boost::dynamic_pointer_cast<RiscOperators>(x);
300  ASSERT_not_null(retval);
301  return retval;
302  }
303 
305  // Supporting functions
306 protected:
317  const BaseSemantics::SValuePtr &a);
319  const BaseSemantics::SValuePtr &a,
320  const BaseSemantics::SValuePtr &b);
322  const BaseSemantics::SValuePtr &a,
323  const BaseSemantics::SValuePtr &b,
324  const BaseSemantics::SValuePtr &c);
326  const BaseSemantics::SValuePtr &a,
327  const BaseSemantics::SValuePtr &b,
328  const BaseSemantics::SValuePtr &c,
329  const BaseSemantics::SValuePtr &d);
339 
341  // Override all operator methods from base class. These are the RISC operators that are invoked by a Dispatcher.
342 public:
343  virtual void startInstruction(SgAsmInstruction*) ROSE_OVERRIDE;
344  virtual BaseSemantics::SValuePtr filterCallTarget(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
345  virtual BaseSemantics::SValuePtr filterReturnTarget(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
346  virtual BaseSemantics::SValuePtr filterIndirectJumpTarget(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
347  virtual void hlt() ROSE_OVERRIDE;
348  virtual void cpuid() ROSE_OVERRIDE;
349  virtual BaseSemantics::SValuePtr rdtsc() ROSE_OVERRIDE;
350  virtual BaseSemantics::SValuePtr and_(const BaseSemantics::SValuePtr &a_,
351  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
352  virtual BaseSemantics::SValuePtr or_(const BaseSemantics::SValuePtr &a_,
353  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
354  virtual BaseSemantics::SValuePtr xor_(const BaseSemantics::SValuePtr &a_,
355  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
356  virtual BaseSemantics::SValuePtr invert(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE;
357  virtual BaseSemantics::SValuePtr extract(const BaseSemantics::SValuePtr &a_,
358  size_t begin_bit, size_t end_bit) ROSE_OVERRIDE;
359  virtual BaseSemantics::SValuePtr concat(const BaseSemantics::SValuePtr &a_,
360  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
361  virtual BaseSemantics::SValuePtr leastSignificantSetBit(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE;
362  virtual BaseSemantics::SValuePtr mostSignificantSetBit(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE;
363  virtual BaseSemantics::SValuePtr rotateLeft(const BaseSemantics::SValuePtr &a_,
364  const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE;
365  virtual BaseSemantics::SValuePtr rotateRight(const BaseSemantics::SValuePtr &a_,
366  const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE;
367  virtual BaseSemantics::SValuePtr shiftLeft(const BaseSemantics::SValuePtr &a_,
368  const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE;
369  virtual BaseSemantics::SValuePtr shiftRight(const BaseSemantics::SValuePtr &a_,
370  const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE;
371  virtual BaseSemantics::SValuePtr shiftRightArithmetic(const BaseSemantics::SValuePtr &a_,
372  const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE;
373  virtual BaseSemantics::SValuePtr equalToZero(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE;
374  virtual BaseSemantics::SValuePtr ite(const BaseSemantics::SValuePtr &sel_,
375  const BaseSemantics::SValuePtr &a_,
376  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
377  virtual BaseSemantics::SValuePtr isEqual(const BaseSemantics::SValuePtr&, const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
378  virtual BaseSemantics::SValuePtr isNotEqual(const BaseSemantics::SValuePtr&, const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
379  virtual BaseSemantics::SValuePtr isUnsignedLessThan(const BaseSemantics::SValuePtr&,
380  const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
381  virtual BaseSemantics::SValuePtr isUnsignedLessThanOrEqual(const BaseSemantics::SValuePtr&,
382  const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
383  virtual BaseSemantics::SValuePtr isUnsignedGreaterThan(const BaseSemantics::SValuePtr&,
384  const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
385  virtual BaseSemantics::SValuePtr isUnsignedGreaterThanOrEqual(const BaseSemantics::SValuePtr&,
386  const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
387  virtual BaseSemantics::SValuePtr isSignedLessThan(const BaseSemantics::SValuePtr&,
388  const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
389  virtual BaseSemantics::SValuePtr isSignedLessThanOrEqual(const BaseSemantics::SValuePtr&,
390  const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
391  virtual BaseSemantics::SValuePtr isSignedGreaterThan(const BaseSemantics::SValuePtr&,
392  const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
393  virtual BaseSemantics::SValuePtr isSignedGreaterThanOrEqual(const BaseSemantics::SValuePtr&,
394  const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
395  virtual BaseSemantics::SValuePtr unsignedExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) ROSE_OVERRIDE;
396  virtual BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) ROSE_OVERRIDE;
397  virtual BaseSemantics::SValuePtr add(const BaseSemantics::SValuePtr &a_,
398  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
399  virtual BaseSemantics::SValuePtr subtract(const BaseSemantics::SValuePtr &a_,
400  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
401  virtual BaseSemantics::SValuePtr addWithCarries(const BaseSemantics::SValuePtr &a_,
402  const BaseSemantics::SValuePtr &b_,
403  const BaseSemantics::SValuePtr &c_,
404  BaseSemantics::SValuePtr &carry_out/*out*/) ROSE_OVERRIDE;
405  virtual BaseSemantics::SValuePtr negate(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE;
406  virtual BaseSemantics::SValuePtr signedDivide(const BaseSemantics::SValuePtr &a_,
407  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
408  virtual BaseSemantics::SValuePtr signedModulo(const BaseSemantics::SValuePtr &a_,
409  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
410  virtual BaseSemantics::SValuePtr signedMultiply(const BaseSemantics::SValuePtr &a_,
411  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
412  virtual BaseSemantics::SValuePtr unsignedDivide(const BaseSemantics::SValuePtr &a_,
413  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
414  virtual BaseSemantics::SValuePtr unsignedModulo(const BaseSemantics::SValuePtr &a_,
415  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
416  virtual BaseSemantics::SValuePtr unsignedMultiply(const BaseSemantics::SValuePtr &a_,
417  const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE;
418  virtual void interrupt(int majr, int minr) ROSE_OVERRIDE;
419  virtual BaseSemantics::SValuePtr readRegister(RegisterDescriptor reg,
420  const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE;
421  virtual BaseSemantics::SValuePtr peekRegister(RegisterDescriptor reg,
422  const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE;
423  virtual void writeRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
424  virtual BaseSemantics::SValuePtr readMemory(RegisterDescriptor segreg,
425  const BaseSemantics::SValuePtr &addr,
426  const BaseSemantics::SValuePtr &dflt,
427  const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE;
428  virtual void writeMemory(RegisterDescriptor segreg,
429  const BaseSemantics::SValuePtr &addr,
430  const BaseSemantics::SValuePtr &data,
431  const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE;
432 };
433 
434 
435 } // namespace
436 } // namespace
437 } // namespace
438 } // namespace
439 
440 #endif
virtual BaseSemantics::SValuePtr isSignedGreaterThan(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Comparison for signed values.
virtual BaseSemantics::SValuePtr unsignedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Divides two unsigned values.
virtual BaseSemantics::SValuePtr shiftLeft(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE
Returns arg shifted left.
virtual void writeRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE
Writes a value to a register.
virtual BaseSemantics::SValuePtr leastSignificantSetBit(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE
Returns position of least significant set bit; zero when no bits are set.
virtual void cpuid() ROSE_OVERRIDE
Invoked for the x86 CPUID instruction.
virtual BaseSemantics::SValuePtr subtract(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Subtract one value from another.
virtual BaseSemantics::SValuePtr isSignedLessThan(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Comparison for signed values.
virtual bool is_number() const ROSE_OVERRIDE
Determines if the value is a concrete number.
virtual BaseSemantics::SValuePtr mostSignificantSetBit(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE
Returns position of most significant set bit; zero when no bits are set.
virtual BaseSemantics::SValuePtr filterCallTarget(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE
Invoked to filter call targets.
Base class for machine instructions.
static RiscOperatorsPtr instance(const BaseSemantics::SValuePtr &protoval, SMTSolver *solver=NULL)
Instantiates a new RiscOperators object with specified prototypical values.
static SValuePtr instance_undefined(size_t nbits)
Instantiate an undefined value.
RiscOperator
One enum per RISC operator.
virtual BaseSemantics::SValuePtr ite(const BaseSemantics::SValuePtr &sel_, const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
If-then-else.
virtual BaseSemantics::SValuePtr and_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Computes bit-wise AND of two values.
virtual BaseSemantics::SValuePtr extract(const BaseSemantics::SValuePtr &a_, size_t begin_bit, size_t end_bit) ROSE_OVERRIDE
Extracts bits from a value.
void attachInstructionSemantics(SgNode *ast, Disassembler *)
Build and attach static semantics to all instructions.
virtual void hlt() ROSE_OVERRIDE
Invoked for the x86 HLT instruction.
virtual BaseSemantics::SValuePtr isUnsignedLessThanOrEqual(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Comparison for unsigned values.
Holds a value or nothing.
Definition: Optional.h:49
virtual void interrupt(int majr, int minr) ROSE_OVERRIDE
Invoked for instructions that cause an interrupt.
virtual BaseSemantics::SValuePtr isUnsignedLessThan(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Comparison for unsigned values.
virtual SValuePtr protoval() const
Property: Prototypical semantic value.
boost::shared_ptr< class MemoryState > MemoryStatePtr
Shared-ownership pointer to null register state.
virtual BaseSemantics::SValuePtr negate(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE
Two's complement.
Main namespace for the ROSE library.
virtual BaseSemantics::SValuePtr unsignedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Calculates modulo with unsigned values.
Describes (part of) a physical CPU register.
virtual void ast(SgAsmExpression *x)
Property: Abstract syntax tree.
Semantic values for generating static semantic ASTs.
static SValuePtr promote(const BaseSemantics::SValuePtr &v)
Promote a base value to a static semantics value.
boost::shared_ptr< class RegisterState > RegisterStatePtr
Shared-ownership pointer to null register state.
virtual BaseSemantics::SValuePtr readRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE
Reads a value from a register.
virtual BaseSemantics::SValuePtr shiftRight(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE
Returns arg shifted right logically (no sign bit).
boost::shared_ptr< class RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
boost::shared_ptr< class State > StatePtr
Shared-ownership pointer to a semantic state.
boost::shared_ptr< class Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::StatePtr &state, SMTSolver *solver=NULL) const ROSE_OVERRIDE
Virtual allocating constructor.
virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) const ROSE_OVERRIDE
Create a new unspecified semantic value.
static Type * registerOrDelete(Type *toInsert)
Registers a type with the type system.
static SValuePtr instance_bottom(size_t nbits)
Instantiate a data-flow bottom value.
Base classes for instruction semantics.
virtual void startInstruction(SgAsmInstruction *) ROSE_OVERRIDE
Called at the beginning of every instruction.
virtual void set_width(size_t nbits) ROSE_OVERRIDE
Accessor for value width.
virtual BaseSemantics::SValuePtr rotateLeft(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE
Rotate bits to the left.
virtual BaseSemantics::SValuePtr or_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Computes bit-wise OR of two values.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:8322
virtual BaseSemantics::SValuePtr isSignedGreaterThanOrEqual(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Comparison for signed values.
virtual BaseSemantics::SValuePtr isEqual(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Equality comparison.
virtual BaseSemantics::SValuePtr boolean_(bool value) const ROSE_OVERRIDE
Create a new, Boolean value.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::SValuePtr &protoval, SMTSolver *solver=NULL) const ROSE_OVERRIDE
Virtual allocating constructor.
virtual BaseSemantics::SValuePtr invert(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE
One's complement.
Defines registers available for a particular architecture.
Definition: Registers.h:32
virtual bool must_equal(const BaseSemantics::SValuePtr &other, SMTSolver *solver=NULL) const ROSE_OVERRIDE
Returns true if two values must be equal.
virtual BaseSemantics::SValuePtr rotateRight(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE
Rotate bits to the right.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer for basic semantic operations.
virtual bool may_equal(const BaseSemantics::SValuePtr &other, SMTSolver *solver=NULL) const ROSE_OVERRIDE
Returns true if two values could be equal.
static RiscOperatorsPtr instance(const RegisterDictionary *regdict, SMTSolver *solver=NULL)
Instantiates a new RiscOperators object and configures it to use semantic values and states that are ...
SharedPointer< U > dynamicCast() const
Dynamic cast.
Base class for most instruction semantics RISC operators.
Base class for expressions.
virtual BaseSemantics::SValuePtr unsignedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Multiply two unsigned values.
virtual uint64_t get_number() const ROSE_OVERRIDE
Return the concrete number for this value.
static SValuePtr instance_unspecified(size_t nbits)
Instantiate an unspecified value.
virtual BaseSemantics::SValuePtr isUnsignedGreaterThan(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Comparison for unsigned values.
virtual Sawyer::Optional< BaseSemantics::SValuePtr > createOptionalMerge(const BaseSemantics::SValuePtr &, const BaseSemantics::MergerPtr &, SMTSolver *) const ROSE_OVERRIDE
Possibly create a new value by merging two existing values.
virtual bool isBottom() const ROSE_OVERRIDE
Determines whether a value is a data-flow bottom.
virtual void writeMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &data, const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE
Writes a value to memory.
static RiscOperatorsPtr instance(const BaseSemantics::StatePtr &state, SMTSolver *solver=NULL)
Instantiates a new RiscOperators object with specified state.
virtual SgNode * copy(SgCopyHelp &help) const
This function clones the current IR node object recursively or not, depending on the argument...
Supporting class for "Deep" copies of the AST.
Definition: Cxx_Grammar.h:8158
static StatePtr instance(const RegisterStatePtr &registers, const MemoryStatePtr &memory)
Instantiate a new state object with specified register and memory states.
Base class for binary types.
Sawyer::SharedPointer< class SValue > SValuePtr
Shared-ownership pointer for a static-semantics value.
boost::shared_ptr< class MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
virtual BaseSemantics::SValuePtr unsignedExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) ROSE_OVERRIDE
Extend (or shrink) operand a so it is nbits wide by adding or removing high-order bits...
virtual BaseSemantics::SValuePtr isNotEqual(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Equality comparison.
static RiscOperatorsPtr promote(const BaseSemantics::RiscOperatorsPtr &x)
Run-time promotion of a base RiscOperators pointer to static operators.
virtual BaseSemantics::SValuePtr addWithCarries(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_, const BaseSemantics::SValuePtr &c_, BaseSemantics::SValuePtr &carry_out) ROSE_OVERRIDE
Add two values of equal size and a carry bit.
SgNode * get_parent() const
Access function for parent node.
virtual BaseSemantics::SValuePtr signedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Calculates modulo with signed values.
virtual BaseSemantics::SValuePtr signedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Divides two signed values.
virtual BaseSemantics::SValuePtr equalToZero(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE
Determines whether a value is equal to zero.
virtual BaseSemantics::SValuePtr filterIndirectJumpTarget(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE
Invoked to filter indirect jumps.
virtual BaseSemantics::SValuePtr concat(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Concatenates the bits of two values.
virtual BaseSemantics::SValuePtr copy(size_t new_width=0) const ROSE_OVERRIDE
Create a new value from an existing value, changing the width if new_width is non-zero.
virtual BaseSemantics::SValuePtr peekRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE
Obtain a register value without side effects.
virtual BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) ROSE_OVERRIDE
Sign extends a value.
virtual BaseSemantics::SValuePtr rdtsc() ROSE_OVERRIDE
Invoked for the x86 RDTSC instruction.
virtual BaseSemantics::SValuePtr isSignedLessThanOrEqual(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Comparison for signed values.
static SValuePtr instance_integer(size_t nbits, uint64_t value)
Instantiate an integer constant.
virtual BaseSemantics::SValuePtr shiftRightArithmetic(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) ROSE_OVERRIDE
Returns arg shifted right arithmetically (with sign bit).
virtual BaseSemantics::SValuePtr xor_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Computes bit-wise XOR of two values.
virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) const ROSE_OVERRIDE
Create a new concrete semantic value.
virtual SMTSolver * solver() const
Property: Satisfiability module theory (SMT) solver.
virtual const std::string & name() const
Property: Name used for debugging.
Integer types.
virtual BaseSemantics::SValuePtr isUnsignedGreaterThanOrEqual(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Comparison for unsigned values.
virtual BaseSemantics::SValuePtr undefined_(size_t nbits) const ROSE_OVERRIDE
Create a new undefined semantic value.
static SValuePtr instance()
Instantiate a prototypical SValue.
virtual BaseSemantics::SValuePtr filterReturnTarget(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE
Invoked to filter return targets.
Virtual base class for instruction disassemblers.
Definition: Disassembler.h:41
virtual BaseSemantics::SValuePtr add(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Adds two integers of equal size.
virtual BaseSemantics::SValuePtr bottom_(size_t nbits) const ROSE_OVERRIDE
Data-flow bottom value.
BaseSemantics::SValuePtr makeSValue(size_t nbits, SgAsmExpression *)
Create a new SValue.
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.
Interface to Satisfiability Modulo Theory (SMT) solvers.
Definition: SMTSolver.h:19
virtual void print(std::ostream &, BaseSemantics::Formatter &) const ROSE_OVERRIDE
Print a value to a stream using default format.
virtual BaseSemantics::SValuePtr signedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Multiplies two signed values.
void saveSemanticEffect(const BaseSemantics::SValuePtr &)
Save instruction side effect.