Package ghidra.program.model.lang
Class Register
java.lang.Object
ghidra.program.model.lang.Register
- All Implemented Interfaces:
Serializable
,Comparable<Register>
- Direct Known Subclasses:
UnknownRegister
Class to represent a processor register. To sort of handle bit registers, a special addressing
convention is used. First the upper bit is set. Second, the next 3 bits are used to specify what
bit position within a byte that this register bit exists at. Finally, the rest of the address is
the address of the byte where the register bit lives.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Register
Register used to denote NO defined context for a languagestatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Register can be used in SIMD operationsstatic final int
-
Constructor Summary
ConstructorDescriptionRegister
(String name, String description, Address address, int numBytes, boolean bigEndian, int typeFlags) Constructs a new Register object.Register
(String name, String description, Address address, int numBytes, int leastSignificantBit, int bitLength, boolean bigEndian, int typeFlags) -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Determines if reg is contained within this register.boolean
boolean
Returns true for a register whose context value should follow the disassembly flow.Returns the address of the register.Returns the register address spaceReturn register aliases.byte[]
Returns the mask that indicates which bits in the base register apply to this register.int
Gets the total number of bits for this Register.Returns list of children registers sorted by lest-significant bit-offset within this register.Get the description of the Register.getGroup()
int[]
Returns the sorted array of lane sizes for this register, measured in bytes.int
Returns the bit offset from the register address for this register.int
int
Returns the minimum number of bytes required to store a value for this Register.getName()
Gets the name of this Register.int
Returns the number of bytes spanned by this Register.int
Returns the offset into the register space for this registerint
boolean
int
hashCode()
boolean
boolean
boolean
Returns true if this is the default frame pointer registerboolean
isHidden()
Returns true if this is a hidden register.boolean
Returns true if this is a processor state registerboolean
Returns true if this is the program counter registerboolean
isValidLaneSize
(int laneSizeInBytes) Determines whetherlaneSizeInBytes
is a valid lane size for this register.boolean
Returns true if this is a vector registerboolean
isZero()
Returns true for a register that is always zerotoString()
-
Field Details
-
TYPE_NONE
public static final int TYPE_NONE- See Also:
-
TYPE_FP
public static final int TYPE_FP- See Also:
-
TYPE_SP
public static final int TYPE_SP- See Also:
-
TYPE_PC
public static final int TYPE_PC- See Also:
-
TYPE_CONTEXT
public static final int TYPE_CONTEXT- See Also:
-
TYPE_ZERO
public static final int TYPE_ZERO- See Also:
-
TYPE_HIDDEN
public static final int TYPE_HIDDEN- See Also:
-
TYPE_DOES_NOT_FOLLOW_FLOW
public static final int TYPE_DOES_NOT_FOLLOW_FLOW- See Also:
-
TYPE_VECTOR
public static final int TYPE_VECTORRegister can be used in SIMD operations- See Also:
-
NO_CONTEXT
Register used to denote NO defined context for a language
-
-
Constructor Details
-
Register
public Register(String name, String description, Address address, int numBytes, boolean bigEndian, int typeFlags) Constructs a new Register object.- Parameters:
name
- the name of this Register.description
- the description of this Registeraddress
- the address in register space of this registernumBytes
- the size (in bytes) of this registerbigEndian
- true if the most significant bytes are associated with the lowest register addresses, and false if the least significant bytes are associated with the lowest register addresses.typeFlags
- the type(s) of this Register (TYPE_NONE, TYPE_FP, TYPE_SP, TYPE_PC, TYPE_CONTEXT, TYPE_ZERO);)
-
Register
-
Register
-
-
Method Details
-
getAliases
Return register aliases. NOTE: This is generally only supported for context register fields.- Returns:
- register aliases or null
-
getName
Gets the name of this Register.- Returns:
- the name of this Register.
-
getDescription
Get the description of the Register.- Returns:
- the description of the register
-
isBigEndian
public boolean isBigEndian() -
getBitLength
public int getBitLength()Gets the total number of bits for this Register.- Returns:
- the total number of bits for this Register.
-
getMinimumByteSize
public int getMinimumByteSize()Returns the minimum number of bytes required to store a value for this Register. -
getNumBytes
public int getNumBytes()Returns the number of bytes spanned by this Register.Compare to
getMinimumByteSize()
: Suppose a 5-bit register spans 2 bytes: 1 bit in the first byte, and the remaining 4 in the following byte. Its value can still be stored in 1 byte, which is whatgetMinimumByteSize()
returns; however, its storage still spans 2 bytes of the base register, which is what this method returns. -
getOffset
public int getOffset()Returns the offset into the register space for this register -
getLeastSignificantBit
public int getLeastSignificantBit()Returns the bit offset from the register address for this register.- Returns:
- the bit offset from the register address for this register.
-
isDefaultFramePointer
public boolean isDefaultFramePointer()Returns true if this is the default frame pointer register -
followsFlow
public boolean followsFlow()Returns true for a register whose context value should follow the disassembly flow. -
isHidden
public boolean isHidden()Returns true if this is a hidden register. -
isProgramCounter
public boolean isProgramCounter()Returns true if this is the program counter register -
isProcessorContext
public boolean isProcessorContext()Returns true if this is a processor state register -
isZero
public boolean isZero()Returns true for a register that is always zero -
toString
-
equals
-
hashCode
public int hashCode() -
getAddressSpace
Returns the register address space -
compareTo
- Specified by:
compareTo
in interfaceComparable<Register>
- See Also:
-
getAddress
Returns the address of the register. -
getParentRegister
-
getChildRegisters
Returns list of children registers sorted by lest-significant bit-offset within this register. -
getBaseRegister
-
getLeastSignificantBitInBaseRegister
public int getLeastSignificantBitInBaseRegister() -
getTypeFlags
public int getTypeFlags() -
getBaseMask
public byte[] getBaseMask()Returns the mask that indicates which bits in the base register apply to this register.- Returns:
- the mask that indicates which bits in the base register apply to this register
-
hasChildren
public boolean hasChildren() -
getGroup
-
isBaseRegister
public boolean isBaseRegister() -
contains
Determines if reg is contained within this register. Method does not work for bit registers (e.g., context-bits)- Parameters:
reg
- another register- Returns:
- true if reg equals this register or is contained within it.
-
isVectorRegister
public boolean isVectorRegister()Returns true if this is a vector register- Returns:
- true precisely when
this
is a full vector register (i.e., a register that can be used as input or output for a SIMD operation).
-
isValidLaneSize
public boolean isValidLaneSize(int laneSizeInBytes) Determines whetherlaneSizeInBytes
is a valid lane size for this register.- Parameters:
laneSizeInBytes
- lane size to check, measured in bytes- Returns:
- true precisely when
this
is a vector register andlaneSizeInBytes
is a valid lane size.
-
getLaneSizes
public int[] getLaneSizes()Returns the sorted array of lane sizes for this register, measured in bytes.- Returns:
- array of lane sizes, or
null
ifthis
is not a vector register or no lane sizes have been set.
-