ROSE  0.9.9.139
AbstractLocation.h
1 #ifndef Rose_BinaryAnalysis_AbstractLocation_H
2 #define Rose_BinaryAnalysis_AbstractLocation_H
3 
4 #include "BaseSemantics2.h"
5 
6 namespace Rose {
7 namespace BinaryAnalysis {
8 
24 public:
27 private:
28  RegisterDescriptor reg_;
29  Address addr_;
30  size_t nBytes_; // size of memory location, or zero if unknown
31  const RegisterDictionary *regdict_;
32 
33 public:
38  AbstractLocation(): nBytes_(0), regdict_(NULL) {}
39 
42  : reg_(other.reg_), addr_(other.addr_), nBytes_(other.nBytes_), regdict_(other.regdict_) {}
43 
47  explicit AbstractLocation(RegisterDescriptor reg, const RegisterDictionary *regdict=NULL)
48  : reg_(reg), nBytes_(0), regdict_(regdict) {}
49 
53  explicit AbstractLocation(const Address &addr, size_t nBytes=0): addr_(addr), nBytes_(nBytes), regdict_(NULL) {}
54 
57  reg_ = other.reg_;
58  addr_ = other.addr_;
59  nBytes_ = other.nBytes_;
60  regdict_ = other.regdict_;
61  return *this;
62  }
63 
68  bool isValid() const { return isRegister() || isAddress(); }
69 
74  bool isRegister() const { return reg_.is_valid(); }
75 
80  bool isAddress() const { return addr_!=NULL; }
81 
87  RegisterDescriptor getRegister() const { return reg_; }
88 
93  const Address getAddress() const { return addr_; }
94 
99  size_t nBytes() const { ASSERT_require(isAddress()); return nBytes_; }
100 
110  bool mayAlias(const AbstractLocation &other, SmtSolver *solver=NULL) const;
111 
121  bool mustAlias(const AbstractLocation &other, SmtSolver *solver=NULL) const;
122 
129  void print(std::ostream &out, const RegisterDictionary *regdict=NULL) const {
131  print(out, regdict, fmt);
132  }
133  void print(std::ostream &out, InstructionSemantics2::BaseSemantics::Formatter &fmt) const {
134  print(out, NULL, fmt);
135  }
136  void print(std::ostream &out, const RegisterDictionary *regdict, InstructionSemantics2::BaseSemantics::Formatter &fmt) const;
138 };
139 
140 std::ostream& operator<<(std::ostream&, const AbstractLocation&);
141 
142 } // namespace
143 } // namespace
144 
145 #endif
AbstractLocation(const AbstractLocation &other)
Copy constructor.
bool isValid() const
Validity checker.
size_t nBytes() const
Returns size of memory location in bytes.
void print(std::ostream &out, InstructionSemantics2::BaseSemantics::Formatter &fmt) const
Print an abstract location.
Main namespace for the ROSE library.
Describes (part of) a physical CPU register.
bool mustAlias(const AbstractLocation &other, SmtSolver *solver=NULL) const
True if two abstract locations are certainly aliases.
bool mayAlias(const AbstractLocation &other, SmtSolver *solver=NULL) const
True if two abstract locations could be aliases.
RegisterDescriptor getRegister() const
Returns register.
const Address getAddress() const
Returns memory address.
void print(std::ostream &out, const RegisterDictionary *regdict=NULL) const
Print an abstract location.
AbstractLocation & operator=(const AbstractLocation &other)
Assignment operator.
Defines registers available for a particular architecture.
Definition: Registers.h:32
bool isAddress() const
Checks memory reference.
AbstractLocation(RegisterDescriptor reg, const RegisterDictionary *regdict=NULL)
Register referent.
InstructionSemantics2::BaseSemantics::SValuePtr Address
Type of memory address.
Interface to Satisfiability Modulo Theory (SMT) solvers.
bool isRegister() const
Checks register reference.
AbstractLocation(const Address &addr, size_t nBytes=0)
Memory referent.