ROSE  0.11.101.0
RiscOperators.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_RiscOperators_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_RiscOperators_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/Types.h>
7 #include <Rose/BinaryAnalysis/InstructionSemantics/Utility.h>
8 #include <Rose/BinaryAnalysis/HotPatch.h>
9 #include <Rose/BinaryAnalysis/SmtSolver.h>
10 #include <Combinatorics.h>
11 
12 #include <boost/enable_shared_from_this.hpp>
13 #include <boost/serialization/access.hpp>
14 #include <boost/serialization/export.hpp>
15 #include <boost/serialization/nvp.hpp>
16 #include <boost/serialization/shared_ptr.hpp>
17 #include <boost/serialization/version.hpp>
18 
19 namespace Rose {
20 namespace BinaryAnalysis {
21 namespace InstructionSemantics {
22 namespace BaseSemantics {
23 
25 // RISC Operators
27 
48 class RiscOperators: public boost::enable_shared_from_this<RiscOperators> {
49 public:
52 
53 private:
54  SValuePtr protoval_; // Prototypical value used for its virtual constructors
55  StatePtr currentState_; // State upon which RISC operators operate
56  StatePtr initialState_; // Lazily updated initial state; see readMemory
57  SmtSolverPtr solver_; // Optional SMT solver
58  SgAsmInstruction *currentInsn_ = nullptr; // Current instruction, as set by latest startInstruction call
59  size_t nInsns_ = 0; // Number of instructions processed
60  std::string name_; // Name to use for debugging
61  HotPatch hotPatch_; // Adjustments to the semantic state after each instruction.
62  bool isNoopRead_ = false; // Read is part of a possible no-op read-then-write sequence
63 
65  // Serialization
66 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
67 private:
68  friend class boost::serialization::access;
69 
70  template<class S>
71  void serialize(S &s, const unsigned version) {
72  s & BOOST_SERIALIZATION_NVP(protoval_);
73  s & BOOST_SERIALIZATION_NVP(currentState_);
74  s & BOOST_SERIALIZATION_NVP(initialState_);
75  s & BOOST_SERIALIZATION_NVP(solver_);
76  s & BOOST_SERIALIZATION_NVP(currentInsn_);
77  s & BOOST_SERIALIZATION_NVP(nInsns_);
78  s & BOOST_SERIALIZATION_NVP(name_);
79  if (version >= 1)
80  s & BOOST_SERIALIZATION_NVP(hotPatch_);
81  if (version >= 2)
82  s & BOOST_SERIALIZATION_NVP(isNoopRead_);
83  }
84 #endif
85 
87  // Real constructors
88 protected:
89  // for serialization
90  RiscOperators();
91 
92  explicit RiscOperators(const SValuePtr &protoval, const SmtSolverPtr &solver = SmtSolverPtr());
93  explicit RiscOperators(const StatePtr &state, const SmtSolverPtr &solver = SmtSolverPtr());
94 
95 public:
96  virtual ~RiscOperators();
97 
99  // Static allocating constructors. None needed since this class is abstract.
100 
101 
103  // Virtual constructors.
104 public:
108  virtual RiscOperatorsPtr create(const SValuePtr &protoval, const SmtSolverPtr &solver = SmtSolverPtr()) const = 0;
109 
114  virtual RiscOperatorsPtr create(const StatePtr &state, const SmtSolverPtr &solver = SmtSolverPtr()) const = 0;
115 
117  // Dynamic pointer casts. No-op since this is the base class.
118 public:
119  static RiscOperatorsPtr promote(const RiscOperatorsPtr &x) {
120  ASSERT_not_null(x);
121  return x;
122  }
123 
125  // Other methods part of our API
126 public:
130  virtual SValuePtr protoval() const { return protoval_; }
131 
140  virtual SmtSolverPtr solver() const { return solver_; }
141  virtual void solver(const SmtSolverPtr &s) { solver_ = s; }
150  const HotPatch& hotPatch() const { return hotPatch_; }
151  HotPatch& hotPatch() { return hotPatch_; }
152  void hotPatch(const HotPatch &hp) { hotPatch_ = hp; }
166  virtual StatePtr currentState() const { return currentState_; }
167  virtual void currentState(const StatePtr &s) { currentState_ = s; }
207  virtual StatePtr initialState() const { return initialState_; }
208  virtual void initialState(const StatePtr &s) { initialState_ = s; }
216  virtual const std::string& name() const { return name_; }
217  virtual void name(const std::string &s) { name_ = s; }
223  virtual void hash(Combinatorics::Hasher&);
224 
227  void print(std::ostream &stream, const std::string prefix="") const;
228  virtual void print(std::ostream &stream, Formatter &fmt) const;
233  RiscOperatorsPtr obj;
234  Formatter &fmt;
235  public:
236  WithFormatter(const RiscOperatorsPtr &obj, Formatter &fmt): obj(obj), fmt(fmt) {}
237  void print(std::ostream &stream) const { obj->print(stream, fmt); }
238  };
239 
255  WithFormatter with_format(Formatter &fmt) { return WithFormatter(shared_from_this(), fmt); }
257  WithFormatter operator+(const std::string &linePrefix);
265  virtual size_t nInsns() const { return nInsns_; }
266  virtual void nInsns(size_t n) { nInsns_ = n; }
276  return currentInsn_;
277  }
278  virtual void currentInstruction(SgAsmInstruction *insn) {
279  currentInsn_ = insn;
280  }
296  virtual bool isNoopRead() const { return isNoopRead_; }
297  virtual void isNoopRead(bool b) { isNoopRead_ = b; }
302  virtual void startInstruction(SgAsmInstruction *insn);
303 
306  virtual void finishInstruction(SgAsmInstruction *insn);
307 
311  virtual void comment(const std::string&);
312 
313 
315  // Value Construction Operations
317  // The trailing underscores are necessary for for undefined_() on some machines, so we just add one to the end of all the
318  // virtual constructors for consistency.
319 
323  virtual SValuePtr undefined_(size_t nbits);
324  virtual SValuePtr unspecified_(size_t nbits);
328  virtual SValuePtr number_(size_t nbits, uint64_t value);
329 
331  virtual SValuePtr boolean_(bool value);
332 
334  virtual SValuePtr bottom_(size_t nbits);
335 
336 
338  // x86-specific Operations (FIXME)
340 
343  virtual SValuePtr filterCallTarget(const SValuePtr &a);
344 
348  virtual SValuePtr filterReturnTarget(const SValuePtr &a);
349 
353  virtual SValuePtr filterIndirectJumpTarget(const SValuePtr &a);
354 
356  virtual void hlt() {}
357 
359  virtual void cpuid() {}
360 
362  virtual SValuePtr rdtsc() { return unspecified_(64); }
363 
364 
366  // Boolean Operations
368 
371  virtual SValuePtr and_(const SValuePtr &a, const SValuePtr &b) = 0;
372 
375  virtual SValuePtr or_(const SValuePtr &a, const SValuePtr &b) = 0;
376 
379  virtual SValuePtr xor_(const SValuePtr &a, const SValuePtr &b) = 0;
380 
382  virtual SValuePtr invert(const SValuePtr &a) = 0;
383 
387  virtual SValuePtr extract(const SValuePtr &a, size_t begin_bit, size_t end_bit) = 0;
388 
395  virtual SValuePtr concat(const SValuePtr &lowBits, const SValuePtr &highBits) = 0;
396 
404  virtual SValuePtr concatLoHi(const SValuePtr &lowBits, const SValuePtr &highBits) {
405  return concat(lowBits, highBits);
406  }
407  virtual SValuePtr concatHiLo(const SValuePtr &highBits, const SValuePtr &lowBits) {
408  return concat(lowBits, highBits);
409  }
417  virtual std::pair<SValuePtr /*low*/, SValuePtr /*high*/> split(const SValuePtr &a, size_t splitPoint);
418 
421  virtual SValuePtr leastSignificantSetBit(const SValuePtr &a) = 0;
422 
425  virtual SValuePtr mostSignificantSetBit(const SValuePtr &a) = 0;
426 
431  virtual SValuePtr countLeadingZeros(const SValuePtr &a);
432 
437  virtual SValuePtr countLeadingOnes(const SValuePtr &a);
438 
442  virtual SValuePtr rotateLeft(const SValuePtr &a, const SValuePtr &nbits) = 0;
443 
447  virtual SValuePtr rotateRight(const SValuePtr &a, const SValuePtr &nbits) = 0;
448 
452  virtual SValuePtr shiftLeft(const SValuePtr &a, const SValuePtr &nbits) = 0;
453 
457  virtual SValuePtr shiftRight(const SValuePtr &a, const SValuePtr &nbits) = 0;
458 
463  virtual SValuePtr shiftRightArithmetic(const SValuePtr &a, const SValuePtr &nbits) = 0;
464 
470  virtual SValuePtr reverseElmts(const SValuePtr &a, size_t elmtNBits);
471 
472 
474  // Comparison Operations
476 
479  virtual SValuePtr equalToZero(const SValuePtr &a) = 0;
480 
482  enum class IteStatus {
483  NEITHER,
484  A,
485  B,
486  BOTH
487  };
488 
496  virtual SValuePtr iteWithStatus(const SValuePtr &cond, const SValuePtr &a, const SValuePtr &b, IteStatus &status /*out*/) = 0;
497 
506  virtual SValuePtr ite(const SValuePtr &cond, const SValuePtr &a, const SValuePtr &b) final {
507  IteStatus status = IteStatus::NEITHER;
508  return iteWithStatus(cond, a, b, status);
509  }
510 
517  virtual SValuePtr isEqual(const SValuePtr &a, const SValuePtr &b);
518  virtual SValuePtr isNotEqual(const SValuePtr &a, const SValuePtr &b);
528  virtual SValuePtr isUnsignedLessThan(const SValuePtr &a, const SValuePtr &b);
529  virtual SValuePtr isUnsignedLessThanOrEqual(const SValuePtr &a, const SValuePtr &b);
530  virtual SValuePtr isUnsignedGreaterThan(const SValuePtr &a, const SValuePtr &b);
531  virtual SValuePtr isUnsignedGreaterThanOrEqual(const SValuePtr &a, const SValuePtr &b);
541  virtual SValuePtr isSignedLessThan(const SValuePtr &a, const SValuePtr &b);
542  virtual SValuePtr isSignedLessThanOrEqual(const SValuePtr &a, const SValuePtr &b);
543  virtual SValuePtr isSignedGreaterThan(const SValuePtr &a, const SValuePtr &b);
544  virtual SValuePtr isSignedGreaterThanOrEqual(const SValuePtr &a, const SValuePtr &b);
547  // Integer Arithmetic Operations
550 
553  virtual SValuePtr unsignedExtend(const SValuePtr &a, size_t new_width);
554 
557  virtual SValuePtr signExtend(const SValuePtr &a, size_t new_width) = 0;
558 
561  virtual SValuePtr add(const SValuePtr &a, const SValuePtr &b) = 0;
562 
567  virtual SValuePtr addCarry(const SValuePtr &a, const SValuePtr &b,
568  SValuePtr &carryOut /*out*/, SValuePtr &overflowed /*out*/);
569 
575  virtual SValuePtr subtract(const SValuePtr &minuend, const SValuePtr &subtrahend);
576 
585  virtual SValuePtr subtractCarry(const SValuePtr &minuend, const SValuePtr &subtrahend,
586  SValuePtr &carryOut /*out*/, SValuePtr &overflowed /*out*/);
587 
604  virtual SValuePtr addWithCarries(const SValuePtr &a, const SValuePtr &b, const SValuePtr &c,
605  SValuePtr &carry_out/*output*/) = 0;
606 
608  virtual SValuePtr negate(const SValuePtr &a) = 0;
609 
611  virtual SValuePtr signedDivide(const SValuePtr &dividend, const SValuePtr &divisor) = 0;
612 
614  virtual SValuePtr signedModulo(const SValuePtr &a, const SValuePtr &b) = 0;
615 
617  virtual SValuePtr signedMultiply(const SValuePtr &a, const SValuePtr &b) = 0;
618 
620  virtual SValuePtr unsignedDivide(const SValuePtr &dividend, const SValuePtr &divisor) = 0;
621 
623  virtual SValuePtr unsignedModulo(const SValuePtr &a, const SValuePtr &b) = 0;
624 
626  virtual SValuePtr unsignedMultiply(const SValuePtr &a, const SValuePtr &b) = 0;
627 
628 
630  // Interrupt and system calls
632 
639  virtual void interrupt(int majr, int minr) {}
640 
646  virtual void interrupt(const SValuePtr &majr, const SValuePtr &minr, const SValuePtr &enabled);
647 
648 
650  // Floating-point operations
651  //
652  // For now these all have default implementations that throw NotImplemented, but we might change them to pure virtual
653  // sometime in the future so they're consistent with most other RISC operators. [Robb P. Matzke 2015-08-03]
655 
657  virtual SValuePtr fpFromInteger(const SValuePtr &intValue, SgAsmFloatType *fpType);
658 
664  virtual SValuePtr fpToInteger(const SValuePtr &fpValue, SgAsmFloatType *fpType, const SValuePtr &dflt);
665 
669  virtual SValuePtr fpConvert(const SValuePtr &a, SgAsmFloatType *aType, SgAsmFloatType *retType);
670 
672  virtual SValuePtr fpIsNan(const SValuePtr &fpValue, SgAsmFloatType *fpType);
673 
675  virtual SValuePtr fpIsDenormalized(const SValuePtr &fpValue, SgAsmFloatType *fpType);
676 
678  virtual SValuePtr fpIsZero(const SValuePtr &fpValue, SgAsmFloatType *fpType);
679 
684  virtual SValuePtr fpIsInfinity(const SValuePtr &fpValue, SgAsmFloatType *fpType);
685 
689  virtual SValuePtr fpSign(const SValuePtr &fpValue, SgAsmFloatType *fpType);
690 
696  virtual SValuePtr fpEffectiveExponent(const SValuePtr &fpValue, SgAsmFloatType *fpType);
697 
701  virtual SValuePtr fpAdd(const SValuePtr &a, const SValuePtr &b, SgAsmFloatType *fpType);
702 
707  virtual SValuePtr fpSubtract(const SValuePtr &a, const SValuePtr &b, SgAsmFloatType *fpType);
708 
712  virtual SValuePtr fpMultiply(const SValuePtr &a, const SValuePtr &b, SgAsmFloatType *fpType);
713 
717  virtual SValuePtr fpDivide(const SValuePtr &a, const SValuePtr &b, SgAsmFloatType *fpType);
718 
722  virtual SValuePtr fpSquareRoot(const SValuePtr &a, SgAsmFloatType *fpType);
723 
727  virtual SValuePtr fpRoundTowardZero(const SValuePtr &a, SgAsmFloatType *fpType);
728 
730  // Conversion operations
732 
738  virtual SValuePtr reinterpret(const SValuePtr &a, SgAsmType *retType);
739 
750  virtual SValuePtr convert(const SValuePtr &a, SgAsmType *srcType, SgAsmType *dstType);
751 
752 
754  // State Accessing Operations
756 
781  virtual SValuePtr readRegister(RegisterDescriptor reg) { // old subclasses can still override this if they want,
782  return readRegister(reg, undefined_(reg.nBits())); // but new subclasses should not override this method.
783  }
784  virtual SValuePtr readRegister(RegisterDescriptor reg, const SValuePtr &dflt); // new subclasses override this
796  virtual void writeRegister(RegisterDescriptor reg, const SValuePtr &a);
797 
805  virtual SValuePtr peekRegister(RegisterDescriptor, const SValuePtr &dflt);
807  return peekRegister(reg, undefined_(reg.nBits()));
808  }
832  virtual SValuePtr readMemory(RegisterDescriptor segreg, const SValuePtr &addr, const SValuePtr &dflt,
833  const SValuePtr &cond) = 0;
834 
845  virtual void writeMemory(RegisterDescriptor segreg, const SValuePtr &addr, const SValuePtr &data,
846  const SValuePtr &cond) = 0;
847 
852  virtual SValuePtr peekMemory(RegisterDescriptor segreg, const SValuePtr &addr, const SValuePtr &dflt) = 0;
853 };
854 
855 std::ostream& operator<<(std::ostream&, const RiscOperators&);
856 std::ostream& operator<<(std::ostream&, const RiscOperators::WithFormatter&);
857 
858 } // namespace
859 } // namespace
860 } // namespace
861 } // namespace
862 
865 
866 #endif
867 #endif
virtual SValuePtr shiftRight(const SValuePtr &a, const SValuePtr &nbits)=0
Returns arg shifted right logically (no sign bit).
Base classes for instruction semantics.
Definition: Dispatcher.h:18
virtual SValuePtr negate(const SValuePtr &a)=0
Two's complement.
virtual SValuePtr readMemory(RegisterDescriptor segreg, const SValuePtr &addr, const SValuePtr &dflt, const SValuePtr &cond)=0
Reads a value from memory.
virtual SValuePtr shiftRightArithmetic(const SValuePtr &a, const SValuePtr &nbits)=0
Returns arg shifted right arithmetically (with sign bit).
virtual SValuePtr peekRegister(RegisterDescriptor, const SValuePtr &dflt)
Obtain a register value without side effects.
size_t nBits() const
Property: Size in bits.
virtual SValuePtr fpIsNan(const SValuePtr &fpValue, SgAsmFloatType *fpType)
Whether a floating-point value is a special not-a-number bit pattern.
virtual SValuePtr countLeadingOnes(const SValuePtr &a)
Count leading one bits.
virtual SValuePtr filterIndirectJumpTarget(const SValuePtr &a)
Invoked to filter indirect jumps.
virtual const std::string & name() const
Property: Name used for debugging.
virtual SValuePtr isUnsignedLessThanOrEqual(const SValuePtr &a, const SValuePtr &b)
Comparison for unsigned values.
virtual SValuePtr fpSubtract(const SValuePtr &a, const SValuePtr &b, SgAsmFloatType *fpType)
Subtract one floating-point value from another.
Describes how to modify machine state after each instruction.
Definition: HotPatch.h:22
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
Base class for machine instructions.
virtual SValuePtr concat(const SValuePtr &lowBits, const SValuePtr &highBits)=0
Concatenates the bits of two values.
virtual void initialState(const StatePtr &s)
Property: Optional lazily updated initial state.
virtual SValuePtr fpMultiply(const SValuePtr &a, const SValuePtr &b, SgAsmFloatType *fpType)
Multiply two floating-point values.
virtual SValuePtr fpDivide(const SValuePtr &a, const SValuePtr &b, SgAsmFloatType *fpType)
Divide one floating-point value by another.
virtual void cpuid()
Invoked for the x86 CPUID instruction.
virtual void startInstruction(SgAsmInstruction *insn)
Called at the beginning of every instruction.
virtual std::pair< SValuePtr, SValuePtr > split(const SValuePtr &a, size_t splitPoint)
Split a value into two narrower values.
virtual SValuePtr rotateRight(const SValuePtr &a, const SValuePtr &nbits)=0
Rotate bits to the right.
void hotPatch(const HotPatch &hp)
Property: Post-instruction hot patches.
virtual SValuePtr fpConvert(const SValuePtr &a, SgAsmFloatType *aType, SgAsmFloatType *retType)
Convert from one floating-point type to another.
virtual SValuePtr equalToZero(const SValuePtr &a)=0
Determines whether a value is equal to zero.
virtual SValuePtr subtractCarry(const SValuePtr &minuend, const SValuePtr &subtrahend, SValuePtr &carryOut, SValuePtr &overflowed)
Subtract one value from another and carry.
virtual SValuePtr undefined_(size_t nbits)
Returns a new undefined value.
const HotPatch & hotPatch() const
Property: Post-instruction hot patches.
virtual StatePtr initialState() const
Property: Optional lazily updated initial state.
virtual SValuePtr unsignedDivide(const SValuePtr &dividend, const SValuePtr &divisor)=0
Divides two unsigned values.
virtual SValuePtr fpFromInteger(const SValuePtr &intValue, SgAsmFloatType *fpType)
Construct a floating-point value from an integer value.
virtual SValuePtr bottom_(size_t nbits)
Returns a data-flow bottom value.
virtual SValuePtr xor_(const SValuePtr &a, const SValuePtr &b)=0
Computes bit-wise XOR of two values.
virtual SValuePtr and_(const SValuePtr &a, const SValuePtr &b)=0
Computes bit-wise AND of two values.
Main namespace for the ROSE library.
virtual SValuePtr invert(const SValuePtr &a)=0
One's complement.
virtual SValuePtr isSignedLessThanOrEqual(const SValuePtr &a, const SValuePtr &b)
Comparison for signed values.
virtual SValuePtr number_(size_t nbits, uint64_t value)
Returns a number of the specified bit width.
virtual SValuePtr signExtend(const SValuePtr &a, size_t new_width)=0
Sign extends a value.
virtual void name(const std::string &s)
Property: Name used for debugging.
virtual SValuePtr isNotEqual(const SValuePtr &a, const SValuePtr &b)
Equality comparison.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
virtual void comment(const std::string &)
Inject a line comment into debugging streams.
virtual SValuePtr iteWithStatus(const SValuePtr &cond, const SValuePtr &a, const SValuePtr &b, IteStatus &status)=0
If-then-else with status.
virtual SValuePtr fpRoundTowardZero(const SValuePtr &a, SgAsmFloatType *fpType)
Round toward zero.
virtual SValuePtr shiftLeft(const SValuePtr &a, const SValuePtr &nbits)=0
Returns arg shifted left.
virtual void writeRegister(RegisterDescriptor reg, const SValuePtr &a)
Writes a value to a register.
virtual void interrupt(int majr, int minr)
Invoked for instructions that cause an interrupt.
WithFormatter with_format(Formatter &fmt)
Used for printing RISC operators with formatting.
virtual SValuePtr extract(const SValuePtr &a, size_t begin_bit, size_t end_bit)=0
Extracts bits from a value.
virtual SValuePtr filterReturnTarget(const SValuePtr &a)
Invoked to filter return targets.
virtual SValuePtr unspecified_(size_t nbits)
Returns a new undefined value.
virtual SValuePtr filterCallTarget(const SValuePtr &a)
Invoked to filter call targets.
virtual SValuePtr signedMultiply(const SValuePtr &a, const SValuePtr &b)=0
Multiplies two signed values.
virtual SValuePtr reverseElmts(const SValuePtr &a, size_t elmtNBits)
Reverse parts of a value.
virtual RiscOperatorsPtr create(const SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr()) const =0
Virtual allocating constructor.
virtual SValuePtr fpIsInfinity(const SValuePtr &fpValue, SgAsmFloatType *fpType)
Whether a floating-point value is infinity.
HotPatch & hotPatch()
Property: Post-instruction hot patches.
virtual SValuePtr isUnsignedGreaterThanOrEqual(const SValuePtr &a, const SValuePtr &b)
Comparison for unsigned values.
virtual SValuePtr or_(const SValuePtr &a, const SValuePtr &b)=0
Computes bit-wise OR of two values.
virtual SValuePtr fpToInteger(const SValuePtr &fpValue, SgAsmFloatType *fpType, const SValuePtr &dflt)
Construct an integer value from a floating-point value.
virtual SValuePtr fpIsDenormalized(const SValuePtr &fpValue, SgAsmFloatType *fpType)
Whether a floating-point value is denormalized.
Describes (part of) a physical CPU register.
SValuePtr peekRegister(RegisterDescriptor reg)
Obtain a register value without side effects.
virtual SValuePtr isSignedGreaterThanOrEqual(const SValuePtr &a, const SValuePtr &b)
Comparison for signed values.
virtual SValuePtr reinterpret(const SValuePtr &a, SgAsmType *retType)
Reinterpret an expression as a different type.
virtual void currentInstruction(SgAsmInstruction *insn)
Property: Current instruction.
virtual void hlt()
Invoked for the x86 HLT instruction.
virtual SValuePtr signedModulo(const SValuePtr &a, const SValuePtr &b)=0
Calculates modulo with signed values.
RiscOperatorsPtr Ptr
Shared-ownership pointer for a RiscOperators object.
Definition: RiscOperators.h:51
virtual SValuePtr subtract(const SValuePtr &minuend, const SValuePtr &subtrahend)
Subtract one value from another.
virtual size_t nInsns() const
Property: Number of instructions processed.
virtual SValuePtr ite(const SValuePtr &cond, const SValuePtr &a, const SValuePtr &b) final
If-then-else.
virtual SValuePtr fpAdd(const SValuePtr &a, const SValuePtr &b, SgAsmFloatType *fpType)
Add two floating-point values.
virtual SValuePtr signedDivide(const SValuePtr &dividend, const SValuePtr &divisor)=0
Divides two signed values.
virtual SValuePtr convert(const SValuePtr &a, SgAsmType *srcType, SgAsmType *dstType)
Convert value from one type to another.
virtual SValuePtr readRegister(RegisterDescriptor reg)
Reads a value from a register.
virtual void nInsns(size_t n)
Property: Number of instructions processed.
Binary analysis.
virtual SValuePtr add(const SValuePtr &a, const SValuePtr &b)=0
Adds two integers of equal size.
virtual SValuePtr concatLoHi(const SValuePtr &lowBits, const SValuePtr &highBits)
Aliases for concatenation.
virtual SValuePtr peekMemory(RegisterDescriptor segreg, const SValuePtr &addr, const SValuePtr &dflt)=0
Read memory without side effects.
virtual void solver(const SmtSolverPtr &s)
Property: Satisfiability module theory (SMT) solver.
virtual void writeMemory(RegisterDescriptor segreg, const SValuePtr &addr, const SValuePtr &data, const SValuePtr &cond)=0
Writes a value to memory.
virtual SValuePtr concatHiLo(const SValuePtr &highBits, const SValuePtr &lowBits)
Aliases for concatenation.
virtual StatePtr currentState() const
Property: Current semantic state.
virtual SgAsmInstruction * currentInstruction() const
Property: Current instruction.
virtual SValuePtr fpSquareRoot(const SValuePtr &a, SgAsmFloatType *fpType)
Square root.
Base class for binary types.
virtual void finishInstruction(SgAsmInstruction *insn)
Called at the end of every instruction.
virtual SValuePtr boolean_(bool value)
Returns a Boolean value.
virtual SValuePtr isSignedLessThan(const SValuePtr &a, const SValuePtr &b)
Comparison for signed values.
virtual SValuePtr addWithCarries(const SValuePtr &a, const SValuePtr &b, const SValuePtr &c, SValuePtr &carry_out)=0
Add two values of equal size and a carry bit.
virtual SValuePtr countLeadingZeros(const SValuePtr &a)
Count leading zero bits.
virtual SmtSolverPtr solver() const
Property: Satisfiability module theory (SMT) solver.
virtual SValuePtr leastSignificantSetBit(const SValuePtr &a)=0
Returns position of least significant set bit; zero when no bits are set.
virtual SValuePtr rotateLeft(const SValuePtr &a, const SValuePtr &nbits)=0
Rotate bits to the left.
virtual void currentState(const StatePtr &s)
Property: Current semantic state.
virtual SValuePtr addCarry(const SValuePtr &a, const SValuePtr &b, SValuePtr &carryOut, SValuePtr &overflowed)
Adds two integers of equal size and carry.
WithFormatter operator+(Formatter &fmt)
Used for printing RISC operators with formatting.
virtual SValuePtr isSignedGreaterThan(const SValuePtr &a, const SValuePtr &b)
Comparison for signed values.
virtual SValuePtr isEqual(const SValuePtr &a, const SValuePtr &b)
Equality comparison.
virtual SValuePtr fpIsZero(const SValuePtr &fpValue, SgAsmFloatType *fpType)
Whether a floating-point value is equal to zero.
virtual SValuePtr protoval() const
Property: Prototypical semantic value.
virtual SValuePtr unsignedModulo(const SValuePtr &a, const SValuePtr &b)=0
Calculates modulo with unsigned values.
Base class for most instruction semantics RISC operators.
Definition: RiscOperators.h:48
virtual SValuePtr fpSign(const SValuePtr &fpValue, SgAsmFloatType *fpType)
Sign of floating-point value.
virtual SValuePtr fpEffectiveExponent(const SValuePtr &fpValue, SgAsmFloatType *fpType)
Exponent of floating-point value.
virtual SValuePtr unsignedExtend(const SValuePtr &a, size_t new_width)
Extend (or shrink) operand a so it is nbits wide by adding or removing high-order bits...
virtual SValuePtr rdtsc()
Invoked for the x86 RDTSC instruction.
virtual SValuePtr isUnsignedGreaterThan(const SValuePtr &a, const SValuePtr &b)
Comparison for unsigned values.
virtual SValuePtr mostSignificantSetBit(const SValuePtr &a)=0
Returns position of most significant set bit; zero when no bits are set.
Floating point types.
void print(std::ostream &stream, const std::string prefix="") const
Print multi-line output for this object.
virtual void hash(Combinatorics::Hasher &)
Compute hash of current state.
virtual SValuePtr unsignedMultiply(const SValuePtr &a, const SValuePtr &b)=0
Multiply two unsigned values.
virtual SValuePtr isUnsignedLessThan(const SValuePtr &a, const SValuePtr &b)
Comparison for unsigned values.