Module

extension SwiftyLLVM.Module
  • Returns the LLVM type of a machine word.

    Declaration

    Swift

    mutating func word() -> SwiftyLLVM.IntegerType
  • Creates the LLVM transpilation of the Hylo IR module m in ir.

    Declaration

    Swift

    init(transpiling m: ModuleDecl.ID, in context: inout CodeGenerationContext)
  • Transpiles and incorporates f, which is a function or subscript of m in ir.

    Declaration

    Swift

    mutating func incorporate(_ f: IR.Function.ID, in context: inout CodeGenerationContext)
  • Transpiles and incorates s, which is a static allocation of m in ir.

    The storage is allocated along with a flag keeping track of its initialization state. Access is provided by an addressor that initializes the storage the first time it is called using s.initializer.

    Declaration

    Swift

    private mutating func incorporate(_ s: StaticStorage, in context: inout CodeGenerationContext)
  • Defines a “main” function calling the function f, which represents the entry point of the entry module m of the program ir.

    This method creates a LLVM entry point calling f, which is the lowered form of a public function named “main”, taking no parameter and returning either Void or Int32. f will be linked privately in m.

    Declaration

    Swift

    private mutating func defineMain(
      calling f: IR.Function.ID, in context: inout CodeGenerationContext
    )
  • Returns the LLVM type of a metatype instance.

    Declaration

    Swift

    private mutating func metatypeType() -> SwiftyLLVM.StructType
  • Returns the LLVM type of an existential container.

    Declaration

    Swift

    private mutating func containerType() -> SwiftyLLVM.StructType
  • Returns the prototype of subscript slides.

    Declaration

    Swift

    private mutating func slidePrototype() -> SwiftyLLVM.Function
  • Returns the declaration of malloc.

    Declaration

    Swift

    private mutating func mallocPrototype() -> SwiftyLLVM.Function
  • Returns the declaration of free.

    Declaration

    Swift

    private mutating func freePrototype() -> SwiftyLLVM.Function
  • Returns the type of a transpiled function whose type in Hylo is t.

    Note

    the type of a function in Hylo IR typically doesn’t match the type of its transpiled form 1-to-1, as return values are often passed by references.

    Declaration

    Swift

    private mutating func transpiledType(_ t: ArrowType) -> SwiftyLLVM.FunctionType
  • Returns the LLVM IR value corresponding to the Hylo IR constant c when used in m in ir.

    Declaration

    Swift

    private mutating func transpiledConstant(
      _ c: any IR.Constant, in context: inout CodeGenerationContext
    ) -> SwiftyLLVM.IRValue
  • Returns the LLVM IR value corresponding to the Hylo IR constant c when used in m in ir.

    Declaration

    Swift

    private mutating func transpiledConstant(
      _ c: IR.WordConstant, in context: inout CodeGenerationContext
    ) -> SwiftyLLVM.IRValue
  • Returns the LLVM IR value corresponding to the Hylo IR constant c when used in m in ir.

    Declaration

    Swift

    private mutating func transpiledConstant(
      _ c: IR.IntegerConstant, in context: inout CodeGenerationContext
    ) -> SwiftyLLVM.IRValue
  • Returns the LLVM IR value corresponding to the Hylo IR constant c when used in m in ir.

    Declaration

    Swift

    private mutating func transpiledConstant(
      _ c: IR.FloatingPointConstant, in context: inout CodeGenerationContext
    ) -> SwiftyLLVM.IRValue
  • Returns the LLVM IR value of the witness table t used in m in ir.

    Declaration

    Swift

    private mutating func transpiledWitnessTable(
      _ t: WitnessTable, in context: inout CodeGenerationContext
    ) -> SwiftyLLVM.IRValue
  • Returns the LLVM IR value of the requirement implementation i, which is in ir.

    Declaration

    Swift

    private mutating func transpiledRequirementImplementation(
      _ i: IR.Conformance.Implementation, from ir: IR.Program
    ) -> SwiftyLLVM.Function
  • Returns the LLVM IR value of the metatype t used in m in ir.

    Declaration

    Swift

    private mutating func demandMetatype(
      of t: AnyType, in context: inout CodeGenerationContext
    ) -> SwiftyLLVM.GlobalVariable
  • Initializes instance with the value of the metatype of t used in m in ir.

    Declaration

    Swift

    private mutating func initializeTranspiledMetatype<T: TypeProtocol>(
      _ instance: SwiftyLLVM.GlobalVariable,
      of t: T, in context: inout CodeGenerationContext
    )
  • Initializes instance with the value of the metatype of t used in m in ir.

    Declaration

    Swift

    private mutating func initializeTranspiledProductTypeMetatype(
      _ instance: SwiftyLLVM.GlobalVariable,
      of t: ProductType, in context: inout CodeGenerationContext
    )
  • Returns the LLVM IR value of t used in m in ir, calling initializeInstance to initialize it.

    Declaration

    Swift

    private mutating func demandMetatype<T: TypeProtocol>(
      of t: T, in context: inout CodeGenerationContext,
      initializedWith initializeInstance: (
        inout Self, inout CodeGenerationContext, SwiftyLLVM.GlobalVariable
      ) -> Void
    ) -> SwiftyLLVM.GlobalVariable
  • Returns the LLVM IR value of t used in m in ir.

    Declaration

    Swift

    private mutating func demandTrait(
      _ t: TraitType, in context: inout CodeGenerationContext
    ) -> SwiftyLLVM.GlobalVariable
  • Inserts and returns the transpiled declaration of ref, which is in ir.

    Declaration

    Swift

    private mutating func declare(
      _ ref: IR.FunctionReference, from ir: IR.Program
    ) -> SwiftyLLVM.Function
  • Inserts and returns the transpiled declaration of f, which is a function of m in ir.

    Declaration

    Swift

    private mutating func declareFunction(
      transpiledFrom f: IR.Function.ID, in context: inout CodeGenerationContext
    ) -> (inserted: Bool, function: SwiftyLLVM.Function)
  • Inserts and returns the transpiled declaration of f, which is a subscript of m in ir.

    Declaration

    Swift

    private mutating func declareSubscript(
      transpiledFrom f: IR.Function.ID, in context: inout CodeGenerationContext
    ) -> (inserted: Bool, function: SwiftyLLVM.Function)
  • Adds to llvmFunction the attributes implied by its IR form f, which is in m.

    Declaration

    Swift

    private mutating func configureAttributes(
      _ llvmFunction: SwiftyLLVM.Function, transpiledFrom f: IR.Function.ID, of m: IR.Module
    )
  • Adds to each parameter in llvmParameters the attributes implied by its corresponding IR form in m[f].inputs.

    Declaration

    Swift

    private mutating func configureInputAttributes(
      _ llvmParameters: SwiftyLLVM.Function.Parameters.SubSequence,
      transpiledFrom f: IR.Function.ID, in m: IR.Module
    )
  • Adds to llvmParameter the attributes implied by its IR form in m[f].inputs[p].

    Declaration

    Swift

    private mutating func configureInputAttributes(
      _ llvmParameter: SwiftyLLVM.Parameter,
      transpiledFrom p: Int, in f: IR.Function.ID, in m: IR.Module
    )
  • Inserts into transpilationthe transpiled contents of f, which is a function or subscript of m in ir.

    Requires

    transpilation contains no instruction.
    See more

    Declaration

    Swift

    private mutating func transpile(
      contentsOf f: IR.Function.ID,
      into transpilation: SwiftyLLVM.Function,
      inContext context: inout CodeGenerationContext
    )
  • Inserts the prologue of the subscript transpilation at the end of its entry and returns a pointer to its stack frame.

    Declaration

    Swift

    fileprivate mutating func insertSubscriptPrologue(
      into transpilation: SwiftyLLVM.Function
    ) -> IRValue