Function

public struct Function : Sendable

A collection of basic blocks representing a lowered function.

  • A collection of blocks with stable identities.

    Declaration

    Swift

    public typealias Blocks = DoublyLinkedList<Block>
  • true iff the function implements a subscript.

    Declaration

    Swift

    public let isSubscript: Bool
  • The site in the source code to which the function corresponds..

    Declaration

    Swift

    public let site: SourceRange
  • The linkage of the function.

    Declaration

    Swift

    public let linkage: Linkage
  • The generic (a.k.a., compile-time) parameters of the function.

    Declaration

    Swift

    public let genericParameters: [GenericParameterDecl.ID]
  • The run-time parameters of the function.

    Declaration

    Swift

    public let inputs: [Parameter]
  • The type of the function’s output.

    Declaration

    Swift

    public let output: AnyType
  • The blocks in the function.

    Declaration

    Swift

    public private(set) var blocks: Blocks { get }
  • The entry of the function.

    Declaration

    Swift

    public var entry: Blocks.Address? { get }
  • Accesses the basic block at address.

    Requires

    address must be a valid address in self.

    Declaration

    Swift

    public subscript(address: Blocks.Address) -> Block { get set }
  • true iff the function takes generic parameters.

    Declaration

    Swift

    public var isGeneric: Bool { get }
  • Appends to self a basic block in scope that accepts parameters, returning its address.

    The new block will become the function’s entry if self contains no block before appendBlock is called.

    Declaration

    Swift

    mutating func appendBlock<T: ScopeID>(
      in scope: T, taking parameters: [IR.`Type`]
    ) -> Blocks.Address
  • Removes the block at address.

    Declaration

    Swift

    @discardableResult
    mutating func removeBlock(_ address: Blocks.Address) -> Block
  • Returns the control flow graph of self.

    Declaration

    Swift

    func cfg() -> ControlFlowGraph
  • ID

    The global identity of an IR function.

    See more

    Declaration

    Swift

    public struct ID : Hashable, Sendable
    extension Function.ID: CustomStringConvertible