ROSE 0.11.145.192
|
Describes (part of) a physical CPU register.
Some architectures have multiple names for physical registers. For example, amd64 has a 64-bit integer register, parts of which are referred to as "rax", "eax", "ax", "al", and "ah". The purpose of a RegisterDescriptor is to describe what physical register (major and minor) is being referenced, and the part (offset and nbits) that's being referenced.
The reason for having a major and minor number to specify a register is to allow for different types of registers. For instance, an i686 has a set of 64-bit integer registers and a set of 80-bit floating point registers (among others). Having major and minor numbers allows the physical register set (such as defined by an instruction semantics policy) to be implemented as an array of 64-bit integers and an array of 80-bit floating points (among others). The array is selected by the major number while the element of the array is selected by the minor number.
The RegisterDescriptor type is part of a SgAsmRegisterReferenceExpression and also appears in the register dictionaries (RegisterDictionary) used in various places including the disassembler. RegisterDescriptor objects are small and are intended to be passed by value. Although these objects are currently four bytes, we reserve the right to make them larger (but probably never more than eight bytes).
Definition at line 28 of file RegisterDescriptor.h.
#include <Rose/BinaryAnalysis/RegisterDescriptor.h>
Public Member Functions | |
RegisterDescriptor () | |
Create an empty register descriptor. | |
RegisterDescriptor (unsigned majr, unsigned minr, size_t offset, size_t width) | |
Construct a descriptor from its constituent parts. | |
Sawyer::Container::Interval< size_t > | bits () const |
Bit range. | |
void | setOffsetWidth (size_t offset, size_t nBits) |
Set offset and size at the same time. | |
bool | isEmpty () const |
Predicate returns true if the width is zero. | |
bool | isValid () const |
Predicate returns true if width is non-zero. | |
operator unspecified_bool () const | |
bool | operator< (RegisterDescriptor other) const |
Compare two descriptors. | |
bool | operator== (RegisterDescriptor other) const |
Check descriptors for equality. | |
bool | operator!= (RegisterDescriptor other) const |
Check descriptors for inequality. | |
RegisterDescriptor | operator& (RegisterDescriptor other) const |
Compute the intersection of two regiter descriptors. | |
bool | isSubsetOf (RegisterDescriptor other) const |
True if this descriptor is a subset of the specified descriptor. | |
unsigned | hash () const |
Hash value. | |
void | print (std::ostream &o) const |
Print all properties. | |
std::string | toString () const |
Show the properties as a string. | |
unsigned | get_major () const |
bool | is_valid () const |
RegisterDescriptor & | set_major (unsigned majr) |
unsigned | get_minor () const |
RegisterDescriptor & | set_minor (unsigned minr) |
unsigned | get_offset () const |
RegisterDescriptor & | set_offset (unsigned offset) |
unsigned | get_nbits () const |
RegisterDescriptor & | set_nbits (unsigned nbits) |
unsigned | majorNumber () const |
Property: Major number. | |
void | majorNumber (unsigned) |
Property: Major number. | |
unsigned | minorNumber () const |
Property: Minor number. | |
void | minorNumber (unsigned) |
Property: Minor number. | |
size_t | offset () const |
Property: Offset to least-significant bit. | |
void | offset (size_t) |
Property: Offset to least-significant bit. | |
size_t | nBits () const |
Property: Size in bits. | |
void | nBits (size_t) |
Property: Size in bits. | |
uint32_t | raw () const |
The raw value of the descriptor. | |
void | raw (uint32_t r) |
The raw value of the descriptor. | |
Static Public Member Functions | |
static RegisterDescriptor | fromRaw (uint32_t raw) |
Construct a descriptor from a raw value. | |
static unsigned | maxMajor () |
Maximum possible major number. | |
static unsigned | maxMinor () |
Maximum possible minor number. | |
static unsigned | maxOffset () |
Maximum possible bit offset. | |
static unsigned | maxNBits () |
Maximum possible size in bits. | |
|
inline |
Create an empty register descriptor.
A default constructed register descriptor has major number zero, minor number zero, offset zero, and size zero.
Definition at line 68 of file RegisterDescriptor.h.
|
inline |
Construct a descriptor from its constituent parts.
The major number, minor number, offset, and width must satisfy the requirements described for those various properties.
Definition at line 75 of file RegisterDescriptor.h.
References majorNumber(), minorNumber(), offset(), and setOffsetWidth().
|
inlinestatic |
Construct a descriptor from a raw value.
Definition at line 83 of file RegisterDescriptor.h.
References raw().
|
static |
Maximum possible size in bits.
Note that the offset and size cannot exceed the maximum size.
|
inline |
Property: Major number.
Each family of registers is identified by a major number. Major numbers are in the range 0 through 15, inclusive.
Definition at line 108 of file RegisterDescriptor.h.
Referenced by RegisterDescriptor(), Rose::BinaryAnalysis::RegisterDictionary::filterNonoverlapping(), and print().
void Rose::BinaryAnalysis::RegisterDescriptor::majorNumber | ( | unsigned | ) |
Property: Major number.
Each family of registers is identified by a major number. Major numbers are in the range 0 through 15, inclusive.
|
inline |
Property: Minor number.
Within a family of registers related by their majorNumber, the minorNumber
identifies individuals. Minor numbers are in the range 0 through 1023, inclusive.
Definition at line 120 of file RegisterDescriptor.h.
Referenced by RegisterDescriptor(), Rose::BinaryAnalysis::RegisterDictionary::filterNonoverlapping(), and print().
void Rose::BinaryAnalysis::RegisterDescriptor::minorNumber | ( | unsigned | ) |
Property: Minor number.
Within a family of registers related by their majorNumber, the minorNumber
identifies individuals. Minor numbers are in the range 0 through 1023, inclusive.
|
inline |
Property: Offset to least-significant bit.
Each member of a register family (member identified by major and minor number) is conceptually 512 bits wide. A RegisterDescriptor
has an offset and width (nBits property) to describe a contiguous region of that space. The sum of the offset and width cannot exceed 512. Decreasing the offset preserves the width; increasing the offset may truncate the width. The offset can be set and queried even for descriptors that are empty (width==0).
See also, setOffsetWidth which sets both offset and size at once.
Definition at line 136 of file RegisterDescriptor.h.
Referenced by RegisterDescriptor(), bits(), Rose::BinaryAnalysis::RegisterDictionary::filterNonoverlapping(), and print().
void Rose::BinaryAnalysis::RegisterDescriptor::offset | ( | size_t | ) |
Property: Offset to least-significant bit.
Each member of a register family (member identified by major and minor number) is conceptually 512 bits wide. A RegisterDescriptor
has an offset and width (nBits property) to describe a contiguous region of that space. The sum of the offset and width cannot exceed 512. Decreasing the offset preserves the width; increasing the offset may truncate the width. The offset can be set and queried even for descriptors that are empty (width==0).
See also, setOffsetWidth which sets both offset and size at once.
|
inline |
Property: Size in bits.
Each member of a register family (member identified by major and minor number) is conceptually 512 bits wide. A RegisterDescriptor
has an offset and this width-in-bits property to describe a contiguous region of that space. The sum of the offset and width cannot exceed 512 (the setOffsetWidth function sets both at once).
Definition at line 155 of file RegisterDescriptor.h.
Referenced by bits(), Rose::BinaryAnalysis::RegisterDictionary::filterNonoverlapping(), isEmpty(), isValid(), Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RiscOperators::peekRegister(), print(), and Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::RiscOperators::readRegister().
void Rose::BinaryAnalysis::RegisterDescriptor::nBits | ( | size_t | ) |
Property: Size in bits.
Each member of a register family (member identified by major and minor number) is conceptually 512 bits wide. A RegisterDescriptor
has an offset and this width-in-bits property to describe a contiguous region of that space. The sum of the offset and width cannot exceed 512 (the setOffsetWidth function sets both at once).
|
inline |
Bit range.
This is the range of bits to which this register descriptor refers. It is formed from the offset and nBits properties.
Definition at line 171 of file RegisterDescriptor.h.
References Sawyer::Container::Interval< T >::baseSize(), nBits(), and offset().
void Rose::BinaryAnalysis::RegisterDescriptor::setOffsetWidth | ( | size_t | offset, |
size_t | nBits | ||
) |
Set offset and size at the same time.
Adjusting the offset and width individually with the offset and nBits properties can be tricky because you need to always satisfy the invariant that offset + size <= 512. Setting the offset individually may change the width, and setting the width individually might cause an invariant to be violated. Therefore, the recommended way to adjust both is to use the setOffsetWidth
method.
The offset and width are set as indicated. Their sum must not exceed 512.
Referenced by RegisterDescriptor().
|
inline |
Predicate returns true if the width is zero.
Default-constructed register descriptors have an initial width of zero.
Definition at line 192 of file RegisterDescriptor.h.
References nBits().
|
inline |
Predicate returns true if width is non-zero.
Default-constructed register descriptors have an initial width of zero.
Definition at line 199 of file RegisterDescriptor.h.
References nBits().
|
inline |
The raw value of the descriptor.
Definition at line 206 of file RegisterDescriptor.h.
Referenced by fromRaw().
|
inline |
The raw value of the descriptor.
Definition at line 209 of file RegisterDescriptor.h.
|
inline |
Definition at line 219 of file RegisterDescriptor.h.
|
inline |
Compare two descriptors.
Descriptors are sorted by major and minor numbers. If two descriptors have the same major and minor numbers then this less-than operation satisfies the requirements of a strict weak ordering although the exact details are not specified (it is not a simple comparison of offset and width).
Definition at line 228 of file RegisterDescriptor.h.
|
inline |
Check descriptors for equality.
Two descriptors are equal if and only if they have the same major numbers, minor numbers, offsets, and width. Note that all properties are significant even if the width is zero or isEmpty returns true.
Definition at line 236 of file RegisterDescriptor.h.
|
inline |
Check descriptors for inequality.
Two descriptors are unequal if they differ in major numbers, minor numbers, offsets, or widths. Note that all properties are significant even if the width is zero or isEmpty returns true.
Definition at line 244 of file RegisterDescriptor.h.
RegisterDescriptor Rose::BinaryAnalysis::RegisterDescriptor::operator& | ( | RegisterDescriptor | other | ) | const |
Compute the intersection of two regiter descriptors.
If the registers have the same major numbers and the same minor numbers and the offset and size cause them to overlap, then the return value is a register descriptor with the same major and minor numbers and an offset and size that represents the overlapping portion. Otherwise the return value is a default constructed register descriptor.
|
inline |
Hash value.
Hash a descriptor. This is a perfect hash: every descriptor hashes to a distinct value.
Definition at line 261 of file RegisterDescriptor.h.
|
inline |
Print all properties.
Definition at line 266 of file RegisterDescriptor.h.
References majorNumber(), minorNumber(), nBits(), and offset().
|
inline |
Definition at line 279 of file RegisterDescriptor.h.
|
inline |
Definition at line 282 of file RegisterDescriptor.h.
|
inline |
Definition at line 285 of file RegisterDescriptor.h.
|
inline |
Definition at line 289 of file RegisterDescriptor.h.
|
inline |
Definition at line 292 of file RegisterDescriptor.h.
|
inline |
Definition at line 296 of file RegisterDescriptor.h.
|
inline |
Definition at line 299 of file RegisterDescriptor.h.
|
inline |
Definition at line 303 of file RegisterDescriptor.h.
|
inline |
Definition at line 306 of file RegisterDescriptor.h.