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 intTYPE_CONTEXTstatic intTYPE_DOES_NOT_FOLLOW_FLOWstatic intTYPE_FPstatic intTYPE_HIDDENstatic intTYPE_NONEstatic intTYPE_PCstatic intTYPE_SPstatic intTYPE_VECTORRegister can be used in SIMD operationsstatic intTYPE_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 intcompareTo(Register other)booleancontains(Register reg)Determines if reg is contained within this register.booleanequals(java.lang.Object o)booleanfollowsFlow()Returns true for a register whose context value should follow the disassembly flow.AddressgetAddress()Returns the address of the register.AddressSpacegetAddressSpace()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.RegistergetBaseRegister()intgetBitLength()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.StringgetDescription()Get the description of the Register.java.lang.StringgetGroup()int[]getLaneSizes()Returns the sorted array of lane sizes for this register, measured in bytes.intgetLeastSignificantBit()Returns the bit offset from the register address for this register.intgetLeastSignificatBitInBaseRegister()intgetMinimumByteSize()Returns the minimum number of bytes required to store a value for this Register.java.lang.StringgetName()Gets the name of this Register.intgetOffset()Returns the offset into the register space for this registerRegistergetParentRegister()intgetTypeFlags()booleanhasChildren()inthashCode()booleanisBaseRegister()booleanisBigEndian()booleanisDefaultFramePointer()Returns true if this is the default frame pointer registerbooleanisHidden()Returns true if this is a hidden register.booleanisProcessorContext()Returns true if this is a processor state registerbooleanisProgramCounter()Returns true if this is the program counter registerbooleanisValidLaneSize(int laneSizeInBytes)Determines whetherlaneSizeInBytesis a valid lane size for this register.booleanisVectorRegister()Returns true if this is a vector registerbooleanisZero()Returns true for a register that is always zerojava.lang.StringtoString()
-
-
-
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:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
getAddressSpace
public AddressSpace getAddressSpace()
Returns the register address space
-
compareTo
public int compareTo(Register other)
- Specified by:
compareToin 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
thisis 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 whetherlaneSizeInBytesis a valid lane size for this register.- Parameters:
laneSizeInBytes- lane size to check, measured in bytes- Returns:
- true precisely when
thisis a vector register andlaneSizeInBytesis 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
nullifthisis not a vector register or no lane sizes have been set.
-
-