ROSE  0.11.51.0
MultiSemantics.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_MultiSemantics_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_MultiSemantics_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics.h>
7 
8 namespace Rose { // documented elsewhere
9 namespace BinaryAnalysis { // documented elsewhere
10 namespace InstructionSemantics2 { // documented elsewhere
11 
59 namespace MultiSemantics {
60 
63 public:
64  std::vector<std::string> subdomain_names;
65 };
66 
68 // Semantic values
70 
73 
84 public:
87 
89  using Ptr = SValuePtr;
90 
91 protected:
92  typedef std::vector<BaseSemantics::SValuePtr> Subvalues;
93  Subvalues subvalues;
94 
95 protected:
96  // Protected constructors
97  explicit SValue(size_t nbits)
98  : BaseSemantics::SValue(nbits) {}
99 
100  SValue(const SValue &other)
101  : BaseSemantics::SValue(other.nBits()) {
102  init(other);
103  }
104 
105  void init(const SValue &other);
106 
108  // Static allocating constructors
109 public:
111  static SValuePtr instance() {
112  return SValuePtr(new SValue(1));
113  }
114 
116  static SValuePtr promote(const BaseSemantics::SValuePtr &v) { // hot
117  SValuePtr retval = v.dynamicCast<SValue>();
118  ASSERT_not_null(retval);
119  return retval;
120  }
121 
123  // Virtual allocating constructors
124 public:
125 
126  virtual BaseSemantics::SValuePtr bottom_(size_t nbits) const ROSE_OVERRIDE;
127 
131  virtual BaseSemantics::SValuePtr undefined_(size_t nbits) const ROSE_OVERRIDE;
132 
136  virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) const ROSE_OVERRIDE;
137 
140  virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t number) const ROSE_OVERRIDE;
141 
144  virtual SValuePtr create_empty(size_t nbits) const {
145  return SValuePtr(new SValue(nbits));
146  }
147 
148  virtual BaseSemantics::SValuePtr copy(size_t new_width=0) const ROSE_OVERRIDE {
149  return BaseSemantics::SValuePtr(new SValue(*this));
150  }
151 
154  const SmtSolverPtr&) const ROSE_OVERRIDE;
155 
157  // Override virtual methods
158 public:
159  virtual bool isBottom() const ROSE_OVERRIDE;
160  virtual void print(std::ostream&, BaseSemantics::Formatter&) const ROSE_OVERRIDE;
161  virtual void hash(Combinatorics::Hasher&) const override;
162 
164  // Override legacy methods. Override these for now, but always call the camelCase names from the base class. Eventually
165  // these snake_case names will go away and the camelCase will become the virtual functions, so be sure to specify
166  // "override" in your own code so you get notified when that change occurs.
167 public:
170  virtual bool may_equal(const BaseSemantics::SValuePtr &other,
171  const SmtSolverPtr &solver = SmtSolverPtr()) const ROSE_OVERRIDE;
172 
176  virtual bool must_equal(const BaseSemantics::SValuePtr &other,
177  const SmtSolverPtr &solver = SmtSolverPtr()) const ROSE_OVERRIDE;
178 
179  virtual void set_width(size_t nbits) ROSE_OVERRIDE;
180 
184  virtual bool is_number() const ROSE_OVERRIDE;
185 
186  virtual uint64_t get_number() const ROSE_OVERRIDE;
187 
188 
190  // Additional methods first declared at this level of the class hierarchy
191 public:
194  virtual bool is_valid(size_t idx) const { // hot
195  return idx<subvalues.size() && subvalues[idx]!=NULL;
196  }
197 
200  virtual void invalidate(size_t idx);
201 
203  virtual BaseSemantics::SValuePtr get_subvalue(size_t idx) const { // hot
204  ASSERT_require(idx<subvalues.size() && subvalues[idx]!=NULL); // you should have called is_valid() first
205  return subvalues[idx];
206  }
207 
211  virtual void set_subvalue(size_t idx, const BaseSemantics::SValuePtr &value) { // hot
212  ASSERT_require(value==NULL || value->nBits()==nBits());
213  if (idx>=subvalues.size())
214  subvalues.resize(idx+1);
215  subvalues[idx] = value;
216  }
217 };
218 
219 
221 // Register states
223 
224 typedef void RegisterState;
225 
227 typedef boost::shared_ptr<void> RegisterStatePtr;
228 
230 // Memory states
232 
233 typedef void MemoryState;
234 
236 typedef boost::shared_ptr<void> MemoryStatePtr;
237 
239 // Complete state
241 
242 typedef void State;
243 
245 typedef boost::shared_ptr<void> StatePtr;
246 
248 // RISC operators
250 
252 typedef boost::shared_ptr<class RiscOperators> RiscOperatorsPtr;
253 
259 public:
262 
265 
266 protected:
267  typedef std::vector<BaseSemantics::RiscOperatorsPtr> Subdomains;
268  Subdomains subdomains;
269  std::vector<bool> active;
270  Formatter formatter; // contains names for the subdomains
271 
273  // Real constructors
274 protected:
276  : BaseSemantics::RiscOperators(protoval, solver) {
277  name("Multi");
278  (void) SValue::promote(protoval); // check that its dynamic type is a MultiSemantics::SValue
279  }
280 
281  explicit RiscOperators(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver = SmtSolverPtr())
282  : BaseSemantics::RiscOperators(state, solver) {
283  name("Multi");
284  (void) SValue::promote(state->protoval()); // dynamic type must be a MultiSemantics::SValue
285  }
286 
288  // Static allocating constructors
289 public:
293  static RiscOperatorsPtr instance(const RegisterDictionary *regdict) {
295  return RiscOperatorsPtr(new RiscOperators(protoval));
296  }
297 
298  static RiscOperatorsPtr instance(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver = SmtSolverPtr()) {
299  return RiscOperatorsPtr(new RiscOperators(protoval, solver));
300  }
301 
302  static RiscOperatorsPtr instance(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver = SmtSolverPtr()) {
303  return RiscOperatorsPtr(new RiscOperators(state, solver));
304  }
305 
307  // Virtual constructors
308 public:
310  const SmtSolverPtr &solver = SmtSolverPtr()) const ROSE_OVERRIDE {
311  return instance(protoval, solver);
312  }
313 
315  const SmtSolverPtr &solver = SmtSolverPtr()) const ROSE_OVERRIDE {
316  return instance(state, solver);
317  }
318 
320  // Dynamic pointer casts
321 public:
322  static RiscOperatorsPtr promote(const BaseSemantics::RiscOperatorsPtr &ops);
323 
325  // Methods first defined at this level of the class hiearchy
326 public:
332  virtual size_t add_subdomain(const BaseSemantics::RiscOperatorsPtr &subdomain, const std::string &name, bool activate=true);
333 
336  return formatter;
337  }
338 
340  virtual size_t nsubdomains() const {
341  return subdomains.size();
342  }
343 
345  virtual BaseSemantics::RiscOperatorsPtr get_subdomain(size_t idx) const;
346 
350  virtual bool is_active(size_t idx) const {
351  return idx<subdomains.size() && subdomains[idx]!=NULL && active[idx];
352  }
353 
356  virtual void clear_active(size_t idx) {
357  set_active(idx, false);
358  }
359 
363  virtual void set_active(size_t idx, bool status);
364 
367  virtual void before(size_t idx) {}
368 
371  virtual void after(size_t idx) {}
372 
374  virtual SValuePtr svalue_empty(size_t nbits) {
375  return SValue::promote(protoval())->create_empty(nbits);
376  }
377 
393  class Cursor {
394  public:
395  typedef std::vector<SValuePtr> Inputs;
396  protected:
397  RiscOperators *ops_;
398  Inputs inputs_;
399  size_t idx_;
400  public:
401  Cursor(RiscOperators *ops, const SValuePtr &arg1=SValuePtr(), const SValuePtr &arg2=SValuePtr(),
402  const SValuePtr &arg3=SValuePtr())
403  : ops_(ops), idx_(0) {
404  init(arg1, arg2, arg3);
405  }
406  Cursor(RiscOperators *ops, const Inputs &inputs)
407  : ops_(ops), inputs_(inputs), idx_(0) {
408  init();
409  }
410 
414  static Inputs inputs(const BaseSemantics::SValuePtr &arg1=BaseSemantics::SValuePtr(),
417 
418  bool at_end() const;
419  void next();
420  size_t idx() const;
426 
427  protected:
428  void init(const SValuePtr &arg1, const SValuePtr &arg2, const SValuePtr &arg3);
429  void init();
430  void skip_invalid();
431  bool inputs_are_valid() const;
432  };
433 
435  // RISC operations and other overrides
436 public:
437  virtual void print(std::ostream &o, BaseSemantics::Formatter&) const ROSE_OVERRIDE;
438  virtual void startInstruction(SgAsmInstruction *insn) ROSE_OVERRIDE;
439  virtual void finishInstruction(SgAsmInstruction *insn) ROSE_OVERRIDE;
440  virtual BaseSemantics::SValuePtr undefined_(size_t nbits) ROSE_OVERRIDE;
441  virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) ROSE_OVERRIDE;
442  virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) ROSE_OVERRIDE;
443  virtual BaseSemantics::SValuePtr boolean_(bool) ROSE_OVERRIDE;
444  virtual BaseSemantics::SValuePtr bottom_(size_t nbits) ROSE_OVERRIDE;
445  virtual BaseSemantics::SValuePtr filterCallTarget(const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
446  virtual BaseSemantics::SValuePtr filterReturnTarget(const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
447  virtual BaseSemantics::SValuePtr filterIndirectJumpTarget(const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
448  virtual BaseSemantics::SValuePtr and_(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
449  virtual BaseSemantics::SValuePtr or_(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
450  virtual BaseSemantics::SValuePtr xor_(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
451  virtual BaseSemantics::SValuePtr invert(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
452  virtual BaseSemantics::SValuePtr extract(const BaseSemantics::SValuePtr &a, size_t begin_bit, size_t end_bit) ROSE_OVERRIDE;
453  virtual BaseSemantics::SValuePtr concat(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
454  virtual BaseSemantics::SValuePtr leastSignificantSetBit(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
455  virtual BaseSemantics::SValuePtr mostSignificantSetBit(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
456  virtual BaseSemantics::SValuePtr rotateLeft(const BaseSemantics::SValuePtr &a,
457  const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE;
458  virtual BaseSemantics::SValuePtr rotateRight(const BaseSemantics::SValuePtr &a,
459  const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE;
460  virtual BaseSemantics::SValuePtr shiftLeft(const BaseSemantics::SValuePtr &a,
461  const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE;
462  virtual BaseSemantics::SValuePtr shiftRight(const BaseSemantics::SValuePtr &a,
463  const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE;
464  virtual BaseSemantics::SValuePtr shiftRightArithmetic(const BaseSemantics::SValuePtr &a,
465  const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE;
466  virtual BaseSemantics::SValuePtr equalToZero(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
467  virtual BaseSemantics::SValuePtr ite(const BaseSemantics::SValuePtr &cond, const BaseSemantics::SValuePtr &a,
468  const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
469  virtual BaseSemantics::SValuePtr unsignedExtend(const BaseSemantics::SValuePtr &a, size_t new_width) ROSE_OVERRIDE;
470  virtual BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a, size_t new_width) ROSE_OVERRIDE;
471  virtual BaseSemantics::SValuePtr add(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
472  virtual BaseSemantics::SValuePtr addWithCarries(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b,
473  const BaseSemantics::SValuePtr &c,
474  BaseSemantics::SValuePtr &carry_out/*output*/) ROSE_OVERRIDE;
475  virtual BaseSemantics::SValuePtr negate(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
476  virtual BaseSemantics::SValuePtr signedDivide(const BaseSemantics::SValuePtr &a,
477  const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
478  virtual BaseSemantics::SValuePtr signedModulo(const BaseSemantics::SValuePtr &a,
479  const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
480  virtual BaseSemantics::SValuePtr signedMultiply(const BaseSemantics::SValuePtr &a,
481  const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
482  virtual BaseSemantics::SValuePtr unsignedDivide(const BaseSemantics::SValuePtr &a,
483  const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
484  virtual BaseSemantics::SValuePtr unsignedModulo(const BaseSemantics::SValuePtr &a,
485  const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
486  virtual BaseSemantics::SValuePtr unsignedMultiply(const BaseSemantics::SValuePtr &a,
487  const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE;
488  virtual BaseSemantics::SValuePtr fpFromInteger(const BaseSemantics::SValuePtr&, SgAsmFloatType*) ROSE_OVERRIDE;
489  virtual BaseSemantics::SValuePtr fpToInteger(const BaseSemantics::SValuePtr&, SgAsmFloatType*,
490  const BaseSemantics::SValuePtr&) ROSE_OVERRIDE;
491  virtual BaseSemantics::SValuePtr fpConvert(const BaseSemantics::SValuePtr&, SgAsmFloatType*, SgAsmFloatType*) ROSE_OVERRIDE;
492  virtual BaseSemantics::SValuePtr fpIsNan(const BaseSemantics::SValuePtr&, SgAsmFloatType*) ROSE_OVERRIDE;
493  virtual BaseSemantics::SValuePtr fpIsDenormalized(const BaseSemantics::SValuePtr&, SgAsmFloatType*) ROSE_OVERRIDE;
494  virtual BaseSemantics::SValuePtr fpIsZero(const BaseSemantics::SValuePtr&, SgAsmFloatType*) ROSE_OVERRIDE;
495  virtual BaseSemantics::SValuePtr fpIsInfinity(const BaseSemantics::SValuePtr&, SgAsmFloatType*) ROSE_OVERRIDE;
496  virtual BaseSemantics::SValuePtr fpSign(const BaseSemantics::SValuePtr&, SgAsmFloatType*) ROSE_OVERRIDE;
497  virtual BaseSemantics::SValuePtr fpEffectiveExponent(const BaseSemantics::SValuePtr&, SgAsmFloatType*) ROSE_OVERRIDE;
498  virtual BaseSemantics::SValuePtr fpAdd(const BaseSemantics::SValuePtr&, const BaseSemantics::SValuePtr&,
499  SgAsmFloatType*) ROSE_OVERRIDE;
500  virtual BaseSemantics::SValuePtr fpSubtract(const BaseSemantics::SValuePtr&, const BaseSemantics::SValuePtr&,
501  SgAsmFloatType*) ROSE_OVERRIDE;
502  virtual BaseSemantics::SValuePtr fpMultiply(const BaseSemantics::SValuePtr&, const BaseSemantics::SValuePtr&,
503  SgAsmFloatType*) ROSE_OVERRIDE;
504  virtual BaseSemantics::SValuePtr fpDivide(const BaseSemantics::SValuePtr&, const BaseSemantics::SValuePtr&,
505  SgAsmFloatType*) ROSE_OVERRIDE;
506  virtual BaseSemantics::SValuePtr fpSquareRoot(const BaseSemantics::SValuePtr&, SgAsmFloatType*) ROSE_OVERRIDE;
507  virtual BaseSemantics::SValuePtr fpRoundTowardZero(const BaseSemantics::SValuePtr&, SgAsmFloatType*) ROSE_OVERRIDE;
508  virtual BaseSemantics::SValuePtr reinterpret(const BaseSemantics::SValuePtr&, SgAsmType*) ROSE_OVERRIDE;
509  virtual BaseSemantics::SValuePtr readRegister(RegisterDescriptor reg,
510  const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE;
511  virtual BaseSemantics::SValuePtr peekRegister(RegisterDescriptor reg,
512  const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE;
513  virtual void writeRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE;
514  virtual BaseSemantics::SValuePtr readMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr,
515  const BaseSemantics::SValuePtr &dflt,
516  const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE;
517  virtual BaseSemantics::SValuePtr peekMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr,
518  const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE;
519  virtual void writeMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr,
520  const BaseSemantics::SValuePtr &data, const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE;
521 };
522 
523 } // namespace
524 } // namespace
525 } // namespace
526 } // namespace
527 
528 #endif
529 #endif
virtual BaseSemantics::SValuePtr fpSign(const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Sign of floating-point value.
BaseSemantics::RiscOperatorsPtr operator->() const
Return the subdomain for the current cursor position.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
boost::shared_ptr< void > MemoryStatePtr
Shared-ownership pointer to a multi-semantics memory state.
virtual BaseSemantics::SValuePtr extract(const BaseSemantics::SValuePtr &a, size_t begin_bit, size_t end_bit) ROSE_OVERRIDE
Extracts bits from a value.
virtual BaseSemantics::SValuePtr bottom_(size_t nbits) ROSE_OVERRIDE
Returns a data-flow bottom value.
boost::shared_ptr< void > StatePtr
Shared-ownership pointer to a multi-semantics state.
virtual BaseSemantics::SValuePtr equalToZero(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE
Determines whether a value is equal to zero.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Virtual allocating constructor.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Virtual allocating constructor.
virtual BaseSemantics::SValuePtr or_(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Computes bit-wise OR of two values.
static SValuePtr instance()
Construct a prototypical value.
virtual SValuePtr svalue_empty(size_t nbits)
Convenience function for SValue::create_empty().
virtual BaseSemantics::SValuePtr fpIsZero(const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Whether a floating-point value is equal to zero.
virtual BaseSemantics::SValuePtr reinterpret(const BaseSemantics::SValuePtr &, SgAsmType *) ROSE_OVERRIDE
Reinterpret an expression as a different type.
virtual BaseSemantics::SValuePtr negate(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE
Two's complement.
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.
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 invert(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE
One's complement.
virtual bool isBottom() const ROSE_OVERRIDE
Determines whether a value is a data-flow bottom.
virtual Formatter & get_formatter()
Returns a formatter containing the names of the subdomains.
virtual bool may_equal(const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Determines if two multidomain values might be equal.
Base class for machine instructions.
virtual bool is_active(size_t idx) const
Returns true if a subdomain is active.
virtual void startInstruction(SgAsmInstruction *insn) ROSE_OVERRIDE
Called at the beginning of every instruction.
virtual BaseSemantics::SValuePtr fpIsInfinity(const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Whether a floating-point value is infinity.
virtual BaseSemantics::SValuePtr fpAdd(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Add two floating-point values.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
static RiscOperatorsPtr instance(const RegisterDictionary *regdict)
Static allocating constructor.
virtual BaseSemantics::SValuePtr filterIndirectJumpTarget(const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Invoked to filter indirect jumps.
virtual BaseSemantics::SValuePtr fpConvert(const BaseSemantics::SValuePtr &, SgAsmFloatType *, SgAsmFloatType *) ROSE_OVERRIDE
Convert from one floating-point type to another.
virtual BaseSemantics::SValuePtr fpIsDenormalized(const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Whether a floating-point value is denormalized.
STL namespace.
Holds a value or nothing.
Definition: Optional.h:49
virtual BaseSemantics::SValuePtr concat(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Concatenates the bits of two values.
virtual BaseSemantics::SValuePtr ite(const BaseSemantics::SValuePtr &cond, const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
If-then-else.
virtual BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a, size_t new_width) ROSE_OVERRIDE
Sign extends a value.
virtual SValuePtr protoval() const
Property: Prototypical semantic value.
Helps printing multidomain values by allowing the user to specify a name for each subdomain...
virtual bool is_number() const ROSE_OVERRIDE
Determines if the value is a concrete number.
Main namespace for the ROSE library.
virtual BaseSemantics::SValuePtr shiftRightArithmetic(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE
Returns arg shifted right arithmetically (with sign bit).
virtual BaseSemantics::SValuePtr fpToInteger(const BaseSemantics::SValuePtr &, SgAsmFloatType *, const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Construct an integer value from a floating-point value.
virtual bool must_equal(const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Determines if two multidomain values must be equal.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to multi-semantics RISC operators.
virtual BaseSemantics::SValuePtr fpSubtract(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Subtract one floating-point value from another.
virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) ROSE_OVERRIDE
Returns a new undefined value.
virtual BaseSemantics::SValuePtr readRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE
Reads a value from a register.
Defines RISC operators for the MultiSemantics domain.
virtual BaseSemantics::SValuePtr signedDivide(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Divides two signed values.
virtual BaseSemantics::SValuePtr peekMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE
Read memory without side effects.
virtual BaseSemantics::SValuePtr leastSignificantSetBit(const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE
Returns position of least significant set bit; zero when no bits are set.
Reference-counting intrusive smart pointer.
Definition: SharedPointer.h:68
virtual BaseSemantics::SValuePtr filterCallTarget(const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Invoked to filter call targets.
virtual void clear_active(size_t idx)
Makes a subdomain inactive.
virtual BaseSemantics::SValuePtr xor_(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Computes bit-wise XOR of two values.
virtual Sawyer::Optional< BaseSemantics::SValuePtr > createOptionalMerge(const BaseSemantics::SValuePtr &other, const BaseSemantics::MergerPtr &, const SmtSolverPtr &) const ROSE_OVERRIDE
Possibly create a new value by merging two existing values.
BaseSemantics::RiscOperatorsPtr operator*() const
Return the subdomain for the current cursor position.
virtual BaseSemantics::SValuePtr fpMultiply(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Multiply two floating-point values.
virtual void before(size_t idx)
Called before each subdomain RISC operation.
virtual BaseSemantics::SValuePtr shiftLeft(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE
Returns arg shifted left.
virtual uint64_t get_number() const ROSE_OVERRIDE
Virtual API.
Base classes for instruction semantics.
Definition: Dispatcher.h:18
static SValuePtr promote(const BaseSemantics::SValuePtr &v)
Promote a base value to a MultiSemantics value.
virtual void writeMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &data, const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE
Writes a value to memory.
virtual void set_active(size_t idx, bool status)
Makes a subdomain active or inactive.
virtual BaseSemantics::SValuePtr undefined_(size_t nbits) ROSE_OVERRIDE
Returns a new undefined value.
Describes (part of) a physical CPU register.
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 void set_subvalue(size_t idx, const BaseSemantics::SValuePtr &value)
Insert a subdomain value.
virtual BaseSemantics::SValuePtr filterReturnTarget(const BaseSemantics::SValuePtr &) ROSE_OVERRIDE
Invoked to filter return targets.
BaseSemantics::SValuePtr operator()(const BaseSemantics::SValuePtr &) const
Returns subdomain value of its multidomain argument.
virtual void finishInstruction(SgAsmInstruction *insn) ROSE_OVERRIDE
Called at the end of every instruction.
virtual bool is_valid(size_t idx) const
Returns true if a subdomain value is valid.
Sawyer::SharedPointer< class SValue > SValuePtr
Shared-ownership pointer to a multi-semantic value.
virtual void after(size_t idx)
Called after each subdomain RISC operation.
virtual BaseSemantics::SValuePtr peekRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE
Obtain a register value without side effects.
virtual size_t add_subdomain(const BaseSemantics::RiscOperatorsPtr &subdomain, const std::string &name, bool activate=true)
Add a subdomain to this MultiSemantics domain.
boost::shared_ptr< void > RegisterStatePtr
Shared-ownership pointer to a multi-semantics register state.
virtual void invalidate(size_t idx)
Removes a subdomain value and marks it as invalid.
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::RiscOperatorsPtr get_subdomain(size_t idx) const
Returns the RiscOperators for a subdomain.
virtual BaseSemantics::SValuePtr fpIsNan(const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Whether a floating-point value is a special not-a-number bit pattern.
virtual BaseSemantics::SValuePtr fpRoundTowardZero(const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Round toward zero.
virtual void writeRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &a) ROSE_OVERRIDE
Writes a value to a register.
SharedPointer< U > dynamicCast() const
Dynamic cast.
Base class for most instruction semantics RISC operators.
Definition: RiscOperators.h:48
virtual size_t nsubdomains() const
Returns the number of subdomains added to this MultiDomain.
virtual BaseSemantics::SValuePtr bottom_(size_t nbits) const ROSE_OVERRIDE
Data-flow bottom value.
virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) const ROSE_OVERRIDE
Create a new unspecified MultiSemantics value.
virtual BaseSemantics::SValuePtr add(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Adds two integers of equal size.
virtual BaseSemantics::SValuePtr unsignedDivide(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Divides two unsigned values.
virtual BaseSemantics::SValuePtr fpFromInteger(const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Construct a floating-point value from an integer value.
virtual BaseSemantics::SValuePtr rotateRight(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE
Rotate bits to the right.
static Inputs inputs(const BaseSemantics::SValuePtr &arg1=BaseSemantics::SValuePtr(), const BaseSemantics::SValuePtr &arg2=BaseSemantics::SValuePtr(), const BaseSemantics::SValuePtr &arg3=BaseSemantics::SValuePtr())
Class method to construct the array of inputs from a variable number of arguments.
virtual void set_width(size_t nbits) ROSE_OVERRIDE
Virtual API.
Base class for binary types.
virtual BaseSemantics::SValuePtr undefined_(size_t nbits) const ROSE_OVERRIDE
Create a new undefined MultiSemantics value.
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 BaseSemantics::SValuePtr boolean_(bool) ROSE_OVERRIDE
Returns a Boolean value.
virtual BaseSemantics::SValuePtr shiftRight(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE
Returns arg shifted right logically (no sign bit).
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
virtual BaseSemantics::SValuePtr rotateLeft(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &nbits) ROSE_OVERRIDE
Rotate bits to the left.
virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) ROSE_OVERRIDE
Returns a number of the specified bit width.
virtual void hash(Combinatorics::Hasher &) const override
Hash this semantic value.
Type of values manipulated by the MultiSemantics domain.
virtual BaseSemantics::SValuePtr get_subvalue(size_t idx) const
Return a subdomain value.
virtual BaseSemantics::SValuePtr signedModulo(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Calculates modulo with signed values.
virtual void print(std::ostream &o, BaseSemantics::Formatter &) const ROSE_OVERRIDE
Print multi-line output for this object.
Defines registers available for a particular architecture.
Definition: Registers.h:37
virtual SmtSolverPtr solver() const
Property: Satisfiability module theory (SMT) solver.
virtual BaseSemantics::SValuePtr unsignedMultiply(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Multiply two unsigned values.
virtual const std::string & name() const
Property: Name used for debugging.
virtual BaseSemantics::SValuePtr fpSquareRoot(const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Square root.
virtual BaseSemantics::SValuePtr fpEffectiveExponent(const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Exponent of floating-point value.
virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t number) const ROSE_OVERRIDE
Create a MultiSemantics value holding a concrete value.
virtual SValuePtr create_empty(size_t nbits) const
Create a new MultiSemantics value with no valid subvalues.
Floating point types.
virtual BaseSemantics::SValuePtr fpDivide(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &, SgAsmFloatType *) ROSE_OVERRIDE
Divide one floating-point value by another.
virtual BaseSemantics::SValuePtr signedMultiply(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Multiplies two signed values.
size_t idx() const
Return the subdomain index for the current cursor position.
bool at_end() const
Returns true when the cursor has gone past the last valid subdomain.
virtual BaseSemantics::SValuePtr unsignedModulo(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Calculates modulo with unsigned values.
std::shared_ptr< class SmtSolver > SmtSolverPtr
Reference-counting pointer for SMT solvers.
Definition: SmtSolver.h:25
virtual BaseSemantics::SValuePtr and_(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b) ROSE_OVERRIDE
Computes bit-wise AND of two values.
virtual void print(std::ostream &, BaseSemantics::Formatter &) const ROSE_OVERRIDE
Print a value to a stream using default format.