Class StorageEntry
java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.type.StorageEntry
Representation of an immutable storage entry (input/output) for sub-routine calls. Used to define
ICallingConvention objects.
Types of storage entries:
- stack entries (any slot count)
- platform register (single slot)
- pair of platform registers (double slot)
- double-pair of platform registers (quad slot)
- a mixed entry, made up of registers and stack slots (any slot count)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTransformation rules for multi-slot storages.static enumType of storage requirements (on the stack, in registers, etc.). -
Method Summary
Modifier and TypeMethodDescriptionvoidcollectRegisters(Set<Long> sink) Add all referenced registers to a sink.static StorageEntrycreateMixed(StorageEntry... items) Create a mixed storage entry.static StorageEntrycreateMixed(Collection<StorageEntry> items) Create a mixed storage entry.static StorageEntrycreateRegister(long regId) Create a single-register storage entry.static StorageEntrycreateRegisterPair(long regId1, long regId2) Create a double-register storage entry.static StorageEntrycreateRegisterPairEndianDep(long regId1, long regId2) Create a double-register storage entry.static StorageEntrycreateRegisterQuad(long regId1, long regId2, long regId3, long regId4) Create a quad-register storage entry.static StorageEntrycreateRegisterQuadEndianDep(long regId1, long regId2, long regId3, long regId4) Create an endian-dependent quad-register storage entry.static StorageEntrycreateStackEntry(long slotIndex, int slotCount) Create a stack storage entry.static StorageEntrycreateStackSlot(long slotIndex) Create a single-slot stack storage entry.booleanformatLong(IRegisterBank rbl) Format this storage entry using register names.Format this storage entry in a parseable form.getMixedItem(int index) Retrieve an item of a mixed storage entry.Retrieve the items of a mixed storage entry.Retrieve all registers referenced by this storage entry.intRetrieve the number of storage slots used by this entry.getType()Retrieve the storage entry type.longgetValue()Get the slot index or native register id, depending on the type of this object.longgetValue(Endianness endian) Get the slot index or native register id, depending on the type of this object.longFor register pairs, retrieve the native register id of the second register of the pair.longgetValue2(Endianness endian) For register pairs, retrieve the native register id of the second register of the pair.longFor register quads, retrieve the native register id of the third register.longFor register quads, retrieve the native register id of the fourth register.intRetrieve this stack entry's slot index.inthashCode()booleanDetermine whether this storage entry uses register storage.booleanDetermine whether this storage entry uses stack storage.intnextSlotIndex(int currentSlotIndex, int requestedSlotCount) Calculate the next slot index given the slot index of the current storage entry.nextStackEntry(int slotcount) Create the next stack entry after this entry.nextStackEntry(int slotcount, int slotalign) Create the next aligned stack entry after this entry.toString()withCount(int count) Duplicate this STACK entry, and set a custom slot count.
-
Method Details
-
createStackSlot
Create a single-slot stack storage entry. Stack entries are relative to the stack pointer at the called routine entry-point.- Parameters:
slotIndex- stack slot index- Returns:
- stack storage entry
-
createStackEntry
Create a stack storage entry. Stack entries are relative to the stack pointer at the called routine entry-point.- Parameters:
slotIndex- stack slot indexslotCount- number of stack slots- Returns:
- stack storage entry
-
createRegister
Create a single-register storage entry.- Parameters:
regId- register id (refer to register banks)- Returns:
- register storage entry
-
createRegisterPair
Create a double-register storage entry.- Parameters:
regId1- low register id (refer to register banks)regId2- high register id (refer to register banks)- Returns:
- register-pair storage entry
-
createRegisterPairEndianDep
Create a double-register storage entry. Register order (which one stores the LSB, which one stores the MSB) depends on external parameters.- Parameters:
regId1- first register id (refer to register banks)regId2- second register id (refer to register banks)- Returns:
- endian-dependent register-pair storage entry
-
createRegisterQuad
Create a quad-register storage entry.- Parameters:
regId1- first register idregId2- second register idregId3- third register idregId4- fourth register id- Returns:
- quad-register storage entry
-
createRegisterQuadEndianDep
public static StorageEntry createRegisterQuadEndianDep(long regId1, long regId2, long regId3, long regId4) Create an endian-dependent quad-register storage entry.- Parameters:
regId1- first register idregId2- second register idregId3- third register idregId4- fourth register id- Returns:
- endian-dependent quad-register storage entry
-
createMixed
Create a mixed storage entry.- Parameters:
items- a 2+ items list of one or moreStorageEntry.Type.REGISTERentries, followed by an optionalStorageEntry.Type.STACKentry.- Returns:
- mixed storage entry
-
createMixed
Create a mixed storage entry.- Parameters:
items- a 2+ items list of one or moreStorageEntry.Type.REGISTERentries, followed by an optionalStorageEntry.Type.STACKentry.- Returns:
- mixed storage entry
-
withCount
Duplicate this STACK entry, and set a custom slot count.- Parameters:
count- slot count- Returns:
- duplicated stack entry
-
hashCode
public int hashCode() -
equals
-
getType
Retrieve the storage entry type.- Returns:
- storage entry type
-
getValueAsStackIndex
public int getValueAsStackIndex()Retrieve this stack entry's slot index.- Returns:
- stack slot index
-
getRegisters
Retrieve all registers referenced by this storage entry.- Returns:
- register ids
-
collectRegisters
Add all referenced registers to a sink.- Parameters:
sink- register-id sink
-
getValue
public long getValue()Get the slot index or native register id, depending on the type of this object.- Returns:
- slot index or register id
-
getValue
Get the slot index or native register id, depending on the type of this object. To be used forStorageEntry.Type.REGISTER_PAIRovergetValue()which may return the wrong slot index.- Parameters:
endian- byte order used for endian-dependent register pairs- Returns:
- slot index or register id
-
getValue2
public long getValue2()For register pairs, retrieve the native register id of the second register of the pair.- Returns:
- second register id
-
getValue2
For register pairs, retrieve the native register id of the second register of the pair.- Parameters:
endian- byte order used for endian-dependent register pairs- Returns:
- second register id
-
getValue3
public long getValue3()For register quads, retrieve the native register id of the third register.- Returns:
- third register id
-
getValue4
public long getValue4()For register quads, retrieve the native register id of the fourth register.- Returns:
- fourth register id
-
getMixedItems
Retrieve the items of a mixed storage entry.- Returns:
- mixed storage items
-
getMixedItem
Retrieve an item of a mixed storage entry.- Parameters:
index- item index- Returns:
- mixed storage item
-
nextSlotIndex
public int nextSlotIndex(int currentSlotIndex, int requestedSlotCount) Calculate the next slot index given the slot index of the current storage entry.- Parameters:
currentSlotIndex- slot index of this storage entryrequestedSlotCount- the amount of slots used to accommodate this entry, unless it was a register-based entry- Returns:
- the next available slot for storage
-
isStackBased
public boolean isStackBased()Determine whether this storage entry uses stack storage.- Returns:
- true if stack-based
-
isRegisterBased
public boolean isRegisterBased()Determine whether this storage entry uses register storage.- Returns:
- true if register-based
-
nextStackEntry
Create the next stack entry after this entry.- Parameters:
slotcount- number of slots in the next entry- Returns:
- next stack entry
-
nextStackEntry
Create the next aligned stack entry after this entry.- Parameters:
slotcount- number of slots in the next entryslotalign- stack slot alignment- Returns:
- next stack entry
-
getSlotCount
public int getSlotCount()Retrieve the number of storage slots used by this entry.- Returns:
- slot count
-
toString
-
formatLong
Format this storage entry using register names.- Parameters:
rbl- register bank layout- Returns:
- formatted storage entry
-
formatParseable
Format this storage entry in a parseable form.- Parameters:
rbl- register bank layout- Returns:
- parseable storage entry
-