1 #ifndef ROSE_BinaryAnalysis_RegisterDescriptor_H
2 #define ROSE_BinaryAnalysis_RegisterDescriptor_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <boost/serialization/access.hpp>
9 namespace BinaryAnalysis {
50 static const uint32_t EMPTY_PATTERN = 0x000005ff;
51 static const uint32_t OFFSET_WIDTH_MASK = 0x0003ffff;
53 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
55 friend class boost::serialization::access;
58 void serialize(S &s,
const unsigned ) {
59 s & BOOST_SERIALIZATION_NVP(data_);
68 : data_(EMPTY_PATTERN) {}
106 return (data_ >> 18) & 0x3ff;
122 if ((data_ & OFFSET_WIDTH_MASK) == EMPTY_PATTERN)
124 unsigned offsetField = (data_ >> 9) & 0x1ff;
125 unsigned widthField = data_ & 0x1ff;
126 if (offsetField + widthField == 512)
141 if ((data_ & OFFSET_WIDTH_MASK) == EMPTY_PATTERN)
143 unsigned offsetField = (data_ >> 9) & 0x1ff;
144 unsigned widthField = data_ & 0x1ff;
145 if (offsetField + widthField == 512)
147 return widthField + 1;
157 if (
const size_t n =
nBits()) {
202 void this_type_does_not_support_comparisons()
const {}
204 operator unspecified_bool()
const {
205 return isEmpty() ? 0 : &RegisterDescriptor::this_type_does_not_support_comparisons;
214 return data_ < other.data_;
222 return data_ == other.data_;
230 return data_ != other.data_;
264 unsigned get_major()
const {
267 bool is_valid()
const {
274 unsigned get_minor()
const {
281 unsigned get_offset()
const {
288 unsigned get_nbits()
const {
void setOffsetWidth(size_t offset, size_t nBits)
Set offset and size at the same time.
unsigned majorNumber() const
Property: Major number.
size_t nBits() const
Property: Size in bits.
std::string toString() const
Show the properties as a string.
Sawyer::Container::Interval< size_t > bits() const
Bit range.
bool operator==(RegisterDescriptor other) const
Check descriptors for equality.
RegisterDescriptor operator&(RegisterDescriptor other) const
Compute the intersection of two regiter descriptors.
Main namespace for the ROSE library.
bool operator<(RegisterDescriptor other) const
Compare two descriptors.
void print(std::ostream &o) const
Print all properties.
RegisterDescriptor()
Create an empty register descriptor.
static Interval baseSize(T lo, T size)
Construct an interval from one endpoint and a size.
Describes (part of) a physical CPU register.
void raw(uint32_t r)
The raw value of the descriptor.
size_t offset() const
Property: Offset to least-significant bit.
unsigned hash() const
Hash value.
bool isValid() const
Predicate returns true if width is non-zero.
uint32_t raw() const
The raw value of the descriptor.
static RegisterDescriptor fromRaw(uint32_t raw)
Construct a descriptor from a raw value.
bool operator!=(RegisterDescriptor other) const
Check descriptors for inequality.
bool isSubsetOf(RegisterDescriptor other) const
True if this descriptor is a subset of the specified descriptor.
RegisterDescriptor(unsigned majr, unsigned minr, size_t offset, size_t width)
Construct a descriptor from its constituent parts.
unsigned minorNumber() const
Property: Minor number.
bool isEmpty() const
Predicate returns true if the width is zero.