com.pnfsoftware.jeb.core.units.code.asm.type.ICallingConvention |
![]() |
A calling convention object. Calling convention objects are immutable.
Notes:
- several (potentially as many as necessary) input slots
- a single output slot
- input slots can be registers, register pairs, or stack slots
- the output slot can be a register or a register pair
- the "routine return address" slot is a single slot, either register or stack
- register ids are well-defined in corresponding IRegisterBank
implementations
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | FLAG_COMPLEX_VALUE_RETURNED_VIA_IMPLICIT_FIRST_PARAMETER_POINTER | The flag indicates that the calling convention uses an implicit pointer as first parameter when the function prototype specifies that a "complex" data type (some fundamental types, all aggregate types) is to be returned. | |||||||||
int | FLAG_FIRST_ARG_IS_THIS_POINTER | The first argument must be a pointer to the object. | |||||||||
int | FLAG_FLOAT_INPUT_ON_STACK | The flag indicates that all float arguments must go on the stack, regardless of registers declared to be holding storage items, if any. | |||||||||
int | FLAG_LINK_AFTER_INPUT | This flag indicates that the return-address value is located after the input argument on the stack. | |||||||||
int | FLAG_OUTPUT_AFTER_INPUT | The flag indicates that output values are located on the pre-allocated stack slots located after the input values (whose count may not be known). | |||||||||
int | FLAG_OUTPUT_PUSHED | This flag indicates that the return values are to be pushed on the stack after return. | |||||||||
int | FLAG_PARALLEL_INPUT_REGISTER_STACKS | The indices in the lists of registers used to pass integral arguments and floating-point arguments grow together, in a parallel fashion. | |||||||||
int | FLAG_STACK_CLEANED_BY_CALLEE | The flag indicates that the stack is cleaned by the callee (which is not the norm; if the flag is not set, it should be assumed the stack is cleaned by the caller). |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract int |
determineSlotcountAlignment(int requestedSlotcount)
Determine the slotcount alignment requirement of a non-
composite type. | ||||||||||
abstract String | format(int type) | ||||||||||
abstract List<String> |
getAlternateNames()
Get a list of alternate names for this calling convention.
| ||||||||||
abstract CallingConvention.ArgLocationGenerator |
getArgLocationGenerator()
Create a storage-location generator for the inputs provided to a routine using this calling
convention.
| ||||||||||
abstract List<CompilerType> |
getCompilerTypes()
Get the list of compiler types this calling convention may work with.
| ||||||||||
abstract int | getFlags() | ||||||||||
abstract long |
getIdentifierKey()
Get an internally-generated identifier for this calling convention object.
| ||||||||||
abstract StorageEntry |
getInput(StorageEntry previousStorageEntry, TypeLayoutInfo ti)
This method is deprecated.
This method cannot always retrieve proper storage locations for conventions not
specifying the
FLAG_PARALLEL_INPUT_REGISTER_STACKS . It is recommended to
use getArgLocationGenerator() instead of this method
| ||||||||||
abstract int |
getInputSlotCountHint()
Return the number of slots that are reserved for parameters.
| ||||||||||
abstract String |
getName()
Get the common name of this calling convention.
| ||||||||||
abstract List<String> |
getNames()
Retrieve all names for this calling convention (principal and alternates).
| ||||||||||
abstract String | getNotes() | ||||||||||
abstract StorageEntry |
getOutput(int index, int requestedSlotCount, boolean isFloat, Integer inputStackSlotCount)
Determine the storage item assigned to a method return value.
| ||||||||||
abstract StorageEntry |
getOutput(int index, int requestedSlotCount, boolean isFloat)
Determine the storage item assigned to a method return value.
| ||||||||||
abstract int |
getOutputSlotCountHint()
Return the number of slots that are reserved for return values.
| ||||||||||
abstract List<ProcessorType> |
getProcessorTypes()
Get the list of processor types this calling convention may work with.
| ||||||||||
abstract Collection<Long> |
getPureSpoiledRegisters()
Get the list of registers that are spoiled by a callee, in the strictest sense, i.e.
| ||||||||||
abstract StorageEntry | getReturnAddressSlot(Integer inputStackSlotCount) | ||||||||||
abstract StorageEntry | getReturnAddressSlot() | ||||||||||
abstract Map<Integer, Integer> |
getSlotcountAlignmentMap()
Alignment specifications for non-
composite types. | ||||||||||
abstract Collection<Long> |
getSpoiledRegisters()
Get the list of all registers that may be modified and/or spoiled by a callee, in the most
general sense.
| ||||||||||
abstract List<SubsystemType> |
getSubsystemTypes()
Get the list of subsystem types this calling convention may work with.
| ||||||||||
abstract boolean | isFloatInputOnStack() | ||||||||||
abstract boolean | isLinkAfterInput() | ||||||||||
abstract boolean | isOutputAfterInput() | ||||||||||
abstract boolean | isOutputPushed() | ||||||||||
abstract boolean |
isStackCleanedByCallee()
Determine whether routine parameters pushed on stack before a routine call are cleaned by the
callee.
| ||||||||||
abstract boolean |
isStackCleanedByCaller()
Determine whether routine parameters pushed on stack before a routine call are cleaned by the
caller.
| ||||||||||
abstract boolean | isUnknown() |
The flag indicates that the calling convention uses an implicit pointer as first parameter when the function prototype specifies that a "complex" data type (some fundamental types, all aggregate types) is to be returned.
The first argument must be a pointer to the object. Typically, this flag is used by MSVC's
__thiscall
convention. Generally, it enforces the fact that the first parameter of a
prototype must be a single-slot element (and more specifically, a pointer
-type element.
The flag indicates that all float arguments must go on the stack, regardless of registers declared to be holding storage items, if any. (I.e., input registers will be used for integral types, at least, not FP types.)
This flag indicates that the return-address value is located after the input argument on the stack.
Example:
| ... | return addr | argN | (...) v arg1 +----------- <---- SP at routine entryIMPORTANT: this flag requires that all calling convention elements (inputs, outputs, return address) be located on the stack.
The flag indicates that output values are located on the pre-allocated stack slots located after the input values (whose count may not be known).
Example, when calling a function (int,int)->(int)
v ... +----------- (SP1) | ? retval1 (slot) | arg2 | arg1 v return addr +----------- <---- SP at routine entryIf
FLAG_STACK_CLEANED_BY_CALLEE
is also set, the input values as well as the output
values are 'cleared', i.e. the stack pointer would be expected to have the value SP1 when
execution resumes to the return address.
IMPORTANT: this flag requires that all calling convention elements (inputs, outputs, return address) be located on the stack.
This flag indicates that the return values are to be pushed on the stack after return. If it
is combined with FLAG_STACK_CLEANED_BY_CALLEE
, the input arguments are assumed to be
cleaned before pushing the output.
Example, when calling a function (int,int)->(int):
v ... +----------- (SP1) | retaddr | arg2 v arg1 +----------- <---- SP at routine entryAfter execution:
v ... +----------- (SP1) | retval +----------- <---- SP at return PCIMPORTANT: this flag requires that all calling convention elements (inputs, outputs, return address) be located on the stack.
The indices in the lists of registers used to pass integral arguments and floating-point arguments grow together, in a parallel fashion.
Example when calling a method: void f(int a, float b, int c, float d)
With the standard x86_64 Windows calling convention, arguments...
- a would go in rcx - b would go in xmm1 (FP reg at index 1) - c would go in r8 (GP reg at index 2) - d would go in xmm3 (GP reg at index 3)
Here is an example of what happens when the general and FP register stacks used for arguments passing grow separately, as is the case for Linux x64, with the standard amd64 System V convention:
- a would go in rdi - b would go in xmm0 (NOT xmm1) - c would go in rsi (NOT rdx) - d would go in xmm1 (NOT xmm3)
The flag indicates that the stack is cleaned by the callee (which is not the norm; if the flag is not set, it should be assumed the stack is cleaned by the caller).
Note that a return-address value located on the stack is always pop'ed, regardless of the presence of this flag.
Determine the slotcount alignment requirement of a non-composite
type.
type | 0: short-form (i.e., #toString()), 1: user-friendly long-form, 2: parseable yaml form |
---|
Get a list of alternate names for this calling convention.
Create a storage-location generator for the inputs provided to a routine using this calling convention.
Get the list of compiler types this calling convention may work with.
Get an internally-generated identifier for this calling convention object. Two calling
conventions using:
- the same names
- same flags
- same processor targets
- same subsystem targets
- same compiler targets
will have the same UUID.
This method is deprecated.
This method cannot always retrieve proper storage locations for conventions not
specifying the FLAG_PARALLEL_INPUT_REGISTER_STACKS
. It is recommended to
use getArgLocationGenerator()
instead of this method
Determine the storage item assigned to a method invocation parameter.
previousStorageEntry | the previous entry, null if this input entry is the first one |
---|---|
ti | type information of the input parameter |
Return the number of slots that are reserved for parameters. Note that this is just a hint on how many parameters are used.
Get the common name of this calling convention.
Retrieve all names for this calling convention (principal and alternates).
Determine the storage item assigned to a method return value.
index | first slot index (not an output value index) for the output value |
---|---|
requestedSlotCount | number of slots required to accommodate the output value |
isFloat | the output value is an ieee754 float |
inputStackSlotCount | for calling conventions marked isOutputAfterInput() , this
value is mandatory in order to calculate an accurate output slot |
Determine the storage item assigned to a method return value.
index | first slot index (not an output value index) for the output value |
---|---|
requestedSlotCount | number of slots required to accommodate the output value |
isFloat | the output value is an ieee754 float |
Return the number of slots that are reserved for return values. Note that this is just a hint on how many return values are defined.
Get the list of processor types this calling convention may work with.
Get the list of registers that are spoiled by a callee, in the strictest sense, i.e. their value may or may not be modified, but it is meaningless and should not be interpreted by the caller upon return. That set would NOT include return registers.
Alignment specifications for non-composite
types.
Get the list of all registers that may be modified and/or spoiled by a callee, in the most general sense. That set would include any type of return registers.
Get the list of subsystem types this calling convention may work with.
Determine whether routine parameters pushed on stack before a routine call are cleaned by the callee.
Determine whether routine parameters pushed on stack before a routine call are cleaned by the caller.