BuiltinFunction

public enum BuiltinFunction : Hashable, Sendable
extension BuiltinFunction: CustomStringConvertible

A function in the Builtin module, accessible only to the standard library.

Built-in functions implement the basis operations on built-in types such as Builtin.i64, and are implemented by a single IR instruction.

Only a few built-in functions, such as Builtin.address(of:), are truly generic. Others are parameterized by a bounded selection of types and flags, resulting in a family of related non-generic Hylo functions having the same base name. The full name of these functions is a concatenation of the base name with a representation of the value of each parameter, separated by underscores. For example, Builtin.add_i32 and Builtin.add_i64 represent integer addition for 32-bit and 64-bit integer values. Some flags have default values (e.g. OverflowBehavior.ignored), which are omitted from builtin function names. For example:

Hylo spelling Swift representation
Builtin.add_i64 .add(.ignored, .i(64))
Builtin.icmp_ne_i32 .icmp(.ne, .i(32))
Builtin.fmul_fast_float64 .fmul(.fast, .float64)

Most built-in functions have the same semantics an the LLVM instruction with the same base name; the other cases have documentation describing their semantics and Hylo signature. Supported LLVM operations include all arithmetic and comparison instructions on built-in integral and floating-point numbers as well as conversions from and to these types.

Functions unique to Hylo

  • Builtin.address<T>(of v: T) -> Builtin.ptr

    Returns a pointer to the storage of the argument.

    The resulting pointer is dereferenceable only for the lifetime of the argument; additional measures may be needed to keep the argument alive during the pointer’s use.

    Declaration

    Swift

    case addressOf
  • Builtin.mark_uninitialized<T>(_ v: sink T) -> Void

    Marks v as being uninitialized.

    Declaration

    Swift

    case markUninitialized

Functions with a counterpart LLVM instruction.

Parsing

  • An instance whose name—up to the open parenthesis—is n, or nil if no such built-in function exists.

    Declaration

    Swift

    public init?(_ n: String)
  • An atomic fence function whose name—up to the open parenthesis—is n, or nil if no such built-in function exists.

    Declaration

    Swift

    private init?(fence n: String)
  • An atomic non-fence function whose name—up to the open parenthesis—is n, or nil if no such built-in function exists.

    Declaration

    Swift

    private init?(atomic n: String)