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) {}
107 return (data_ >> 18) & 0x3ff;
123 if ((data_ & OFFSET_WIDTH_MASK) == EMPTY_PATTERN)
125 unsigned offsetField = (data_ >> 9) & 0x1ff;
126 unsigned widthField = data_ & 0x1ff;
127 if (offsetField + widthField == 512)
142 if ((data_ & OFFSET_WIDTH_MASK) == EMPTY_PATTERN)
144 unsigned offsetField = (data_ >> 9) & 0x1ff;
145 unsigned widthField = data_ & 0x1ff;
146 if (offsetField + widthField == 512)
148 return widthField + 1;
158 if (
const size_t n =
nBits()) {
203 void this_type_does_not_support_comparisons()
const {}
205 operator unspecified_bool()
const {
206 return isEmpty() ? 0 : &RegisterDescriptor::this_type_does_not_support_comparisons;
215 return data_ < other.data_;
223 return data_ == other.data_;
231 return data_ != other.data_;
265 unsigned get_major()
const {
268 bool is_valid()
const {
275 unsigned get_minor()
const {
282 unsigned get_offset()
const {
289 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.
bool operator==(RegisterDescriptor other) const
Check descriptors for equality.
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.
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.