Class CallingConvention

java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.type.CallingConvention
All Implemented Interfaces:
ICallingConvention

@Ser public class CallingConvention extends Object implements ICallingConvention
Standard implementation of a calling convention object. It can be sub-classed to generate custom input/output layout.
  • Constructor Details

    • CallingConvention

      public CallingConvention()
      Reserved.
  • Method Details

    • clone

      public CallingConvention clone()
      Overrides:
      clone in class Object
    • getIdentifierKey

      public long getIdentifierKey()
      Description copied from interface: ICallingConvention
      Get an internally-generated identifier for this calling convention object. The id is generated using:
      • the same names
      • same flags
      • same processor targets
      • same subsystem targets
      • same compiler targets
      Specified by:
      getIdentifierKey in interface ICallingConvention
      Returns:
      the key for this calling convention
    • getNotes

      public String getNotes()
      Description copied from interface: ICallingConvention
      Retrieve implementation notes.
      Specified by:
      getNotes in interface ICallingConvention
      Returns:
      notes, or null
    • getFlags

      public int getFlags()
      Description copied from interface: ICallingConvention
      Retrieve convention flags.
      Specified by:
      getFlags in interface ICallingConvention
      Returns:
      flags
    • hasFlag

      public boolean hasFlag(int f)
      Description copied from interface: ICallingConvention
      Determine whether a flag is set.
      Specified by:
      hasFlag in interface ICallingConvention
      Parameters:
      f - flag to test
      Returns:
      true if the flag is set
    • isUnknown

      public boolean isUnknown()
      Description copied from interface: ICallingConvention
      Determine whether this is the unknown calling convention.
      Specified by:
      isUnknown in interface ICallingConvention
      Returns:
      true if this convention is unknown
    • getName

      public String getName()
      Description copied from interface: ICallingConvention
      Get the common name of this calling convention.
      Specified by:
      getName in interface ICallingConvention
      Returns:
      principal name
    • getAlternateNames

      public List<String> getAlternateNames()
      Description copied from interface: ICallingConvention
      Get a list of alternate names for this calling convention.
      Specified by:
      getAlternateNames in interface ICallingConvention
      Returns:
      alternate names
    • getNames

      public List<String> getNames()
      Description copied from interface: ICallingConvention
      Retrieve all names for this calling convention (principal and alternates).
      Specified by:
      getNames in interface ICallingConvention
      Returns:
      principal and alternate names
    • getPrimaryProcessorType

      public ProcessorType getPrimaryProcessorType()
      Get the first processor type associated with this convention.
      Returns:
      primary processor type, or null if none is defined
    • getProcessorTypes

      public List<ProcessorType> getProcessorTypes()
      Description copied from interface: ICallingConvention
      Get the list of processor types this calling convention may work with.
      Specified by:
      getProcessorTypes in interface ICallingConvention
      Returns:
      processor type list
    • getSubsystemTypes

      public List<SubsystemType> getSubsystemTypes()
      Description copied from interface: ICallingConvention
      Get the list of subsystem types this calling convention may work with.
      Specified by:
      getSubsystemTypes in interface ICallingConvention
      Returns:
      subsystem type list
    • getCompilerTypes

      public List<CompilerType> getCompilerTypes()
      Description copied from interface: ICallingConvention
      Get the list of compiler types this calling convention may work with.
      Specified by:
      getCompilerTypes in interface ICallingConvention
      Returns:
      compiler type list
    • isCompatibleWith

      public boolean isCompatibleWith(ProcessorType wantedProcessor, SubsystemType wantedSubsystem, CompilerType wantedCompiler)
      Description copied from interface: ICallingConvention
      Determine whether this calling convention is compatible with the provided triple (processor, subsystem, compiler).
      Specified by:
      isCompatibleWith in interface ICallingConvention
      Parameters:
      wantedProcessor - mandatory (pass UNKNOWN if not known)
      wantedSubsystem - mandatory (pass UNKNOWN if not known)
      wantedCompiler - mandatory (pass UNKNOWN if not known)
      Returns:
      true if this convention is compatible
    • getSpoiledRegisters

      public Collection<Long> getSpoiledRegisters()
      Description copied from interface: ICallingConvention
      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.
      Specified by:
      getSpoiledRegisters in interface ICallingConvention
      Returns:
      spoiled register ids
    • getPureSpoiledRegisters

      public Collection<Long> getPureSpoiledRegisters()
      Description copied from interface: ICallingConvention
      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.
      Specified by:
      getPureSpoiledRegisters in interface ICallingConvention
      Returns:
      pure spoiled register ids
    • getReturnAddressSlot

      public StorageEntry getReturnAddressSlot()
      Description copied from interface: ICallingConvention
      Retrieve the return-address storage slot.
      Specified by:
      getReturnAddressSlot in interface ICallingConvention
      Returns:
      return-address storage slot
    • getReturnAddressSlot

      public StorageEntry getReturnAddressSlot(Integer inputStackSlotCount)
      Description copied from interface: ICallingConvention
      Retrieve the return-address storage slot.
      Specified by:
      getReturnAddressSlot in interface ICallingConvention
      Parameters:
      inputStackSlotCount - input stack slot count
      Returns:
      return-address storage slot
    • getOutput

      public StorageEntry getOutput(TypeLayoutInfo ti, int inputStackSlotCount)
      Description copied from interface: ICallingConvention
      Convenience method to retrieve the storage location of the single return value for this calling convention. Most calling conventions allow the return of a single value.
      Specified by:
      getOutput in interface ICallingConvention
      Parameters:
      ti - storage type
      inputStackSlotCount - the number of stack slots used to provide input parameters (some calling conventions require that to calculate proper positioning for output values)
      Returns:
      output storage entry, or null
    • getInputSlotCountHint

      public int getInputSlotCountHint()
      Description copied from interface: ICallingConvention
      Return the number of slots that are reserved for parameters. Note that this is just a hint on how many parameters are used.
      Specified by:
      getInputSlotCountHint in interface ICallingConvention
      Returns:
      input slot count hint
    • getOutputSlotCountHint

      public int getOutputSlotCountHint()
      Description copied from interface: ICallingConvention
      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.
      Specified by:
      getOutputSlotCountHint in interface ICallingConvention
      Returns:
      output slot count hint
    • getSlotcountAlignmentMap

      public Map<Integer,Integer> getSlotcountAlignmentMap()
      Description copied from interface: ICallingConvention
      Alignment specifications for non-composite types.
      Specified by:
      getSlotcountAlignmentMap in interface ICallingConvention
      Returns:
      slot-count alignment map
    • determineSlotcountAlignment

      public int determineSlotcountAlignment(int requestedSlotcount)
      Description copied from interface: ICallingConvention
      Determine the slotcount alignment requirement of a non-composite type.
      Specified by:
      determineSlotcountAlignment in interface ICallingConvention
      Parameters:
      requestedSlotcount - requested slot count
      Returns:
      aligned slot count
    • getIPRDMinimumSlotCount

      public int getIPRDMinimumSlotCount()
      Description copied from interface: ICallingConvention
      Retrieve the minimum slot count for implicit pointer-to-return-data handling.
      Specified by:
      getIPRDMinimumSlotCount in interface ICallingConvention
      Returns:
      minimum slot count
    • getIPRDInputPtrEntry

      public StorageEntry getIPRDInputPtrEntry()
      Description copied from interface: ICallingConvention
      Retrieve the implicit input pointer storage entry.
      Specified by:
      getIPRDInputPtrEntry in interface ICallingConvention
      Returns:
      input pointer storage entry
    • getIPRDOutputPtrEntry

      public StorageEntry getIPRDOutputPtrEntry()
      Description copied from interface: ICallingConvention
      Retrieve the implicit output pointer storage entry.
      Specified by:
      getIPRDOutputPtrEntry in interface ICallingConvention
      Returns:
      output pointer storage entry
    • getIPRDConvention

      public ICallingConvention getIPRDConvention()
      Description copied from interface: ICallingConvention
      Retrieve the optional calling convention, derived from this convention, used to return large composite prototypes. This only applies if the flag ICallingConvention.FLAG_IPRD was set.
      Specified by:
      getIPRDConvention in interface ICallingConvention
      Returns:
      a linked IPRD (Implicit Pointer to Return Data) convention, or null
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • format

      public String format(int type)
      Description copied from interface: ICallingConvention
      Format this calling convention.
      Specified by:
      format in interface ICallingConvention
      Parameters:
      type - 0: short-form (i.e., toString()), 1: user-friendly long-form, 2: parseable yaml form
      Returns:
      formatted convention
    • formatParseable

      public String formatParseable()
      Format this calling convention as parseable text.
      Returns:
      parseable calling convention definition
    • formatUser

      public String formatUser()
      Format this calling convention for user display.
      Returns:
      user-facing calling convention description
    • getInputsGenerator

      public CallingConvention.ArgLocationGenerator getInputsGenerator()
      Description copied from interface: ICallingConvention
      Create a storage-location generator for the inputs provided to a routine using this calling convention. convention.
      Specified by:
      getInputsGenerator in interface ICallingConvention
      Returns:
      a generator
    • getOutputsGenerator

      public CallingConvention.RetLocationGenerator getOutputsGenerator(int inputStackSlotCount)
      Description copied from interface: ICallingConvention
      Create a storage-location generator for the outputs provided to a routine using this calling convention.
      Specified by:
      getOutputsGenerator in interface ICallingConvention
      Parameters:
      inputStackSlotCount - optional value indicating how many stack slots were used to provide parameters (this value is the calling convention has the flags ICallingConvention.FLAG_OUTPUT_AFTER_INPUT or ICallingConvention.FLAG_OUTPUT_PUSHED)
      Returns:
      a generator