Class CallingConventionUtil

java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.type.CallingConventionUtil

public class CallingConventionUtil extends Object
Utility routines for calling convention objects.
  • Method Details

    • getOrderedSingleInputRegisters

      public static Collection<Long> getOrderedSingleInputRegisters(ICallingConvention cc, Endianness endian)
      Get single-register input slots in declaration order.
      Parameters:
      cc - calling convention
      endian - endianness used for endian-dependent storage entries
      Returns:
      ordered native register identifiers
    • getOrderedSingleOutputRegisters

      public static Collection<Long> getOrderedSingleOutputRegisters(ICallingConvention cc, Endianness endian)
      Get single-register output slots in declaration order.
      Parameters:
      cc - calling convention
      endian - endianness used for endian-dependent storage entries
      Returns:
      ordered native register identifiers
    • getInputRegisters

      public static Set<Long> getInputRegisters(ICallingConvention cc, Endianness endian)
      Get input registers used by a calling convention.
      Parameters:
      cc - calling convention
      endian - endianness used for endian-dependent register pairs
      Returns:
      a set of native register ids
    • getOutputRegisters

      public static Set<Long> getOutputRegisters(ICallingConvention cc, Endianness endian)
      Get output registers used by a calling convention.
      Parameters:
      cc - calling convention
      endian - endianness used for endian-dependent register pairs
      Returns:
      a set of native register ids
    • getParameterRegisters

      public static Set<Long> getParameterRegisters(ICallingConventionManager ccManager, Endianness endian)
      Collect parameter registers from all defined calling conventions in the given manager.
      Parameters:
      ccManager - calling convention manager
      endian - endianness used for endian-dependent register pairs
      Returns:
      ids of the registers used as parameter in the known calling conventions
    • getSpoiledRegisters

      public static Set<Long> getSpoiledRegisters(ICallingConventionManager ccManager)
      Collect spoiled registers from all defined calling conventions in the given manager.
      Parameters:
      ccManager - calling convention manager
      Returns:
      ids of the registers used as parameter in the known calling conventions
    • getParameterIndexByArgumentStackOffset

      public static int getParameterIndexByArgumentStackOffset(ICallingConvention cc, IPrototypeItem proto, int stackOffset, int stackSlotSize)
      Given a calling convention and a stack offset, determine a method's parameter index (if the parameter is on the stack on of course).
      Parameters:
      cc - calling convention
      proto - prototype whose parameters are examined
      stackOffset - argument stack offset
      stackSlotSize - size of one stack slot, in bytes
      Returns:
      -1 if undetermined
    • parseAndBuild

      public static ICallingConvention parseAndBuild(String data, boolean build)
      Parse a calling convention definition and optionally build it.
      Parameters:
      data - calling convention definition, formatted as YAML data
      build - true to build the convention object
      Returns:
      parsed calling convention
    • parse

      public static CallingConventionBuilder parse(String data)
      Parse and create a new calling convention object.
      Parameters:
      data - definition of a calling convention, formatted as yaml data (see doc)
      Returns:
      a calling convention object (the method throws IllegalArgumentException on error)
    • isValidForProcessor

      public static boolean isValidForProcessor(ICallingConvention cc, List<ProcessorType> candidateProcessors)
      Determine whether a calling convention is compatible with one of the candidate processors.
      Parameters:
      cc - calling convention
      candidateProcessors - candidate processor types
      Returns:
      true if the convention has no processor restriction or matches a candidate processor