Package ghidra.program.model.lang
Class Register
- java.lang.Object
-
- ghidra.program.model.lang.Register
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Register>
- Direct Known Subclasses:
UnknownRegister
public class Register extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<Register>
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
TYPE_CONTEXT
static int
TYPE_DOES_NOT_FOLLOW_FLOW
static int
TYPE_FP
static int
TYPE_HIDDEN
static int
TYPE_NONE
static int
TYPE_PC
static int
TYPE_SP
static int
TYPE_VECTOR
Register can be used in SIMD operationsstatic int
TYPE_ZERO
-
Constructor Summary
Constructors Constructor Description Register(Register register)
Register(java.lang.String name, java.lang.String description, Address address, int numBytes, boolean bigEndian, int typeFlags)
Constructs a new Register object.Register(java.lang.String name, java.lang.String description, Address address, int numBytes, int leastSignificantBit, int bitLength, boolean bigEndian, int typeFlags)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Register other)
boolean
contains(Register reg)
Determines if reg is contained within this register.boolean
equals(java.lang.Object o)
boolean
followsFlow()
Returns true for a register whose context value should follow the disassembly flow.Address
getAddress()
Returns the address of the register.AddressSpace
getAddressSpace()
Returns the register address spacejava.lang.Iterable<java.lang.String>
getAliases()
Return register aliases.byte[]
getBaseMask()
Returns the mask that indicates which bits in the base register apply to this register.Register
getBaseRegister()
int
getBitLength()
Gets the total number of bits for this Register.java.util.List<Register>
getChildRegisters()
Returns list of children registers sorted by lest-significant bit-offset within this register.java.lang.String
getDescription()
Get the description of the Register.java.lang.String
getGroup()
int[]
getLaneSizes()
Returns the sorted array of lane sizes for this register, measured in bytes.int
getLeastSignificantBit()
Returns the bit offset from the register address for this register.int
getLeastSignificatBitInBaseRegister()
int
getMinimumByteSize()
Returns the minimum number of bytes required to store a value for this Register.java.lang.String
getName()
Gets the name of this Register.int
getOffset()
Returns the offset into the register space for this registerRegister
getParentRegister()
int
getTypeFlags()
boolean
hasChildren()
int
hashCode()
boolean
isBaseRegister()
boolean
isBigEndian()
boolean
isDefaultFramePointer()
Returns true if this is the default frame pointer registerboolean
isHidden()
Returns true if this is a hidden register.boolean
isProcessorContext()
Returns true if this is a processor state registerboolean
isProgramCounter()
Returns true if this is the program counter registerboolean
isValidLaneSize(int laneSizeInBytes)
Determines whetherlaneSizeInBytes
is a valid lane size for this register.boolean
isVectorRegister()
Returns true if this is a vector registerboolean
isZero()
Returns true for a register that is always zerojava.lang.String
toString()
-
-
-
Field Detail
-
TYPE_NONE
public static final int TYPE_NONE
- See Also:
- Constant Field Values
-
TYPE_FP
public static final int TYPE_FP
- See Also:
- Constant Field Values
-
TYPE_SP
public static final int TYPE_SP
- See Also:
- Constant Field Values
-
TYPE_PC
public static final int TYPE_PC
- See Also:
- Constant Field Values
-
TYPE_CONTEXT
public static final int TYPE_CONTEXT
- See Also:
- Constant Field Values
-
TYPE_ZERO
public static final int TYPE_ZERO
- See Also:
- Constant Field Values
-
TYPE_HIDDEN
public static final int TYPE_HIDDEN
- See Also:
- Constant Field Values
-
TYPE_DOES_NOT_FOLLOW_FLOW
public static final int TYPE_DOES_NOT_FOLLOW_FLOW
- See Also:
- Constant Field Values
-
TYPE_VECTOR
public static final int TYPE_VECTOR
Register can be used in SIMD operations- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Register
public Register(java.lang.String name, java.lang.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
public Register(Register register)
-
Register
public Register(java.lang.String name, java.lang.String description, Address address, int numBytes, int leastSignificantBit, int bitLength, boolean bigEndian, int typeFlags)
-
-
Method Detail
-
getAliases
public java.lang.Iterable<java.lang.String> getAliases()
Return register aliases. NOTE: This is generally only supported for context register fields.- Returns:
- register aliases or null
-
getName
public java.lang.String getName()
Gets the name of this Register.- Returns:
- the name of this Register.
-
getDescription
public java.lang.String 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.
-
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
getAddressSpace
public AddressSpace getAddressSpace()
Returns the register address space
-
compareTo
public int compareTo(Register other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Register>
- See Also:
Comparable.compareTo(java.lang.Object)
-
getAddress
public Address getAddress()
Returns the address of the register.
-
getParentRegister
public Register getParentRegister()
-
getChildRegisters
public java.util.List<Register> getChildRegisters()
Returns list of children registers sorted by lest-significant bit-offset within this register.
-
getBaseRegister
public Register getBaseRegister()
-
getLeastSignificatBitInBaseRegister
public int getLeastSignificatBitInBaseRegister()
-
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
public java.lang.String getGroup()
-
isBaseRegister
public boolean isBaseRegister()
-
contains
public boolean contains(Register reg)
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.
-
-