1#ifndef ROSE_BinaryAnalysis_RegisterDescriptor_H
2#define ROSE_BinaryAnalysis_RegisterDescriptor_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6#include <Sawyer/Interval.h>
7#include <boost/serialization/access.hpp>
10namespace BinaryAnalysis {
51 static const uint32_t EMPTY_PATTERN = 0x000005ff;
52 static const uint32_t OFFSET_WIDTH_MASK = 0x0003ffff;
54#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
56 friend class boost::serialization::access;
59 void serialize(S &s,
const unsigned ) {
60 s & BOOST_SERIALIZATION_NVP(data_);
69 : data_(EMPTY_PATTERN) {}
121 return (data_ >> 18) & 0x3ff;
137 if ((data_ & OFFSET_WIDTH_MASK) == EMPTY_PATTERN)
139 unsigned offsetField = (data_ >> 9) & 0x1ff;
140 unsigned widthField = data_ & 0x1ff;
141 if (offsetField + widthField == 512)
156 if ((data_ & OFFSET_WIDTH_MASK) == EMPTY_PATTERN)
158 unsigned offsetField = (data_ >> 9) & 0x1ff;
159 unsigned widthField = data_ & 0x1ff;
160 if (offsetField + widthField == 512)
162 return widthField + 1;
172 if (
const size_t n =
nBits()) {
217 void this_type_does_not_support_comparisons()
const {}
219 operator unspecified_bool()
const {
220 return isEmpty() ? 0 : &RegisterDescriptor::this_type_does_not_support_comparisons;
229 return data_ < other.data_;
237 return data_ == other.data_;
245 return data_ != other.data_;
279 unsigned get_major()
const {
282 bool is_valid()
const {
289 unsigned get_minor()
const {
296 unsigned get_offset()
const {
303 unsigned get_nbits()
const {
Describes (part of) a physical CPU register.
bool operator<(RegisterDescriptor other) const
Compare two descriptors.
void raw(uint32_t r)
The raw value of the descriptor.
static RegisterDescriptor fromRaw(uint32_t raw)
Construct a descriptor from a raw value.
void offset(size_t)
Property: Offset to least-significant bit.
static unsigned maxMajor()
Maximum possible major number.
bool operator==(RegisterDescriptor other) const
Check descriptors for equality.
static unsigned maxMinor()
Maximum possible minor number.
static unsigned maxOffset()
Maximum possible bit offset.
void nBits(size_t)
Property: Size in bits.
void majorNumber(unsigned)
Property: Major number.
bool operator!=(RegisterDescriptor other) const
Check descriptors for inequality.
RegisterDescriptor(unsigned majr, unsigned minr, size_t offset, size_t width)
Construct a descriptor from its constituent parts.
RegisterDescriptor()
Create an empty register descriptor.
RegisterDescriptor operator&(RegisterDescriptor other) const
Compute the intersection of two regiter descriptors.
std::string toString() const
Show the properties as a string.
size_t offset() const
Property: Offset to least-significant bit.
void print(std::ostream &o) const
Print all properties.
bool isSubsetOf(RegisterDescriptor other) const
True if this descriptor is a subset of the specified descriptor.
void setOffsetWidth(size_t offset, size_t nBits)
Set offset and size at the same time.
unsigned minorNumber() const
Property: Minor number.
uint32_t raw() const
The raw value of the descriptor.
Sawyer::Container::Interval< size_t > bits() const
Bit range.
bool isEmpty() const
Predicate returns true if the width is zero.
static unsigned maxNBits()
Maximum possible size in bits.
bool isValid() const
Predicate returns true if width is non-zero.
void minorNumber(unsigned)
Property: Minor number.
unsigned majorNumber() const
Property: Major number.
unsigned hash() const
Hash value.
size_t nBits() const
Property: Size in bits.
Range of values delimited by endpoints.
static Interval baseSize(T lo, T size)
Construct an interval from one endpoint and a size.