enumstd.zig.Zir.Inst.Extended[src]

Rarer instructions are here; ones that do not fit in the 8-bit Tag enum. noreturn instructions may not go here; they must be part of the main Tag enum.

Fields

struct_decl

A struct type definition. Contains references to ZIR instructions for the field types, defaults, and alignments. operand is payload index to StructDecl. small is StructDecl.Small.

enum_decl

An enum type definition. Contains references to ZIR instructions for the field value expressions and optional type tag expression. operand is payload index to EnumDecl. small is EnumDecl.Small.

union_decl

A union type definition. Contains references to ZIR instructions for the field types and optional type tag expression. operand is payload index to UnionDecl. small is UnionDecl.Small.

opaque_decl

An opaque type definition. Contains references to decls and captures. operand is payload index to OpaqueDecl. small is OpaqueDecl.Small.

tuple_decl

A tuple type. Note that tuples are not namespace/container types. operand is payload index to TupleDecl. small is fields_len: u16.

this

Implements the @This builtin. operand is src_node: i32.

ret_addr

Implements the @returnAddress builtin. operand is src_node: i32.

builtin_src

Implements the @src builtin. operand is payload index to LineColumn.

error_return_trace

Implements the @errorReturnTrace builtin. operand is src_node: i32.

frame

Implements the @frame builtin. operand is src_node: i32.

frame_address

Implements the @frameAddress builtin. operand is src_node: i32.

alloc

Same as alloc from Tag but may contain an alignment instruction. operand is payload index to AllocExtended. small:

  • 0b000X - has type
  • 0b00X0 - has alignment
  • 0b0X00 - 1=const, 0=var
  • 0bX000 - is comptime
builtin_extern

The @extern builtin. operand is payload index to BinNode.

@"asm"

Inline assembly. small:

  • 0b00000000_000XXXXX - outputs_len.
  • 0b000000XX_XXX00000 - inputs_len.
  • 0b0XXXXX00_00000000 - clobbers_len.
  • 0bX0000000_00000000 - is volatile operand is payload index to Asm.
asm_expr

Same as asm except the assembly template is not a string literal but a comptime expression. The asm_source field of the Asm is not a null-terminated string but instead a Ref.

compile_log

Log compile time variables and emit an error message. operand is payload index to NodeMultiOp. small is operands_len. The AST node is the compile log builtin call.

typeof_peer

The builtin @TypeOf which returns the type after Peer Type Resolution of one or more params. operand is payload index to TypeOfPeer. small is operands_len. The AST node is the builtin call.

min_multi

Implements the @min builtin for more than 2 args. operand is payload index to NodeMultiOp. small is operands_len. The AST node is the builtin call.

max_multi

Implements the @max builtin for more than 2 args. operand is payload index to NodeMultiOp. small is operands_len. The AST node is the builtin call.

add_with_overflow

Implements the @addWithOverflow builtin. operand is payload index to BinNode. small is unused.

sub_with_overflow

Implements the @subWithOverflow builtin. operand is payload index to BinNode. small is unused.

mul_with_overflow

Implements the @mulWithOverflow builtin. operand is payload index to BinNode. small is unused.

shl_with_overflow

Implements the @shlWithOverflow builtin. operand is payload index to BinNode. small is unused.

c_undef

operand is payload index to UnNode.

c_include

operand is payload index to UnNode.

c_define

operand is payload index to BinNode.

wasm_memory_size

operand is payload index to UnNode.

wasm_memory_grow

operand is payload index to BinNode.

prefetch

The @prefetch builtin. operand is payload index to BinNode.

set_float_mode

Implement builtin @setFloatMode. operand is payload index to UnNode.

error_cast

Implements the @errorCast builtin. operand is payload index to BinNode. lhs is dest type, rhs is operand.

await_nosuspend

operand is payload index to UnNode.

breakpoint

Implements @breakpoint. operand is src_node: i32.

disable_instrumentation

Implement builtin @disableInstrumentation. operand is src_node: i32.

disable_intrinsics

Implement builtin @disableIntrinsics. operand is src_node: i32.

select

Implements the @select builtin. operand is payload index to Select.

int_from_error

Implement builtin @errToInt. operand is payload index to UnNode.

error_from_int

Implement builtin @errorFromInt. operand is payload index to UnNode.

reify

Implement builtin @Type. operand is payload index to Reify. small contains NameStrategy.

builtin_async_call

Implements the @asyncCall builtin. operand is payload index to AsyncCall.

cmpxchg

Implements the @cmpxchgStrong and @cmpxchgWeak builtins. small 0=>weak 1=>strong operand is payload index to Cmpxchg.

c_va_arg

Implement builtin @cVaArg. operand is payload index to BinNode.

c_va_copy

Implement builtin @cVaCopy. operand is payload index to UnNode.

c_va_end

Implement builtin @cVaEnd. operand is payload index to UnNode.

c_va_start

Implement builtin @cVaStart. operand is src_node: i32.

ptr_cast_full

Implements the following builtins: @ptrCast, @alignCast, @addrSpaceCast, @constCast, @volatileCast. Represents an arbitrary nesting of the above builtins. Such a nesting is treated as a single operation which can modify multiple components of a pointer type. operand is payload index to BinNode. small contains FullPtrCastFlags. AST node is the root of the nested casts. lhs is dest type, rhs is operand.

ptr_cast_no_dest

operand is payload index to UnNode. small contains FullPtrCastFlags. Guaranteed to only have flags where no explicit destination type is required (const_cast and volatile_cast). AST node is the root of the nested casts.

work_item_id

Implements the @workItemId builtin. operand is payload index to UnNode.

work_group_size

Implements the @workGroupSize builtin. operand is payload index to UnNode.

work_group_id

Implements the @workGroupId builtin. operand is payload index to UnNode.

in_comptime

Implements the @inComptime builtin. operand is src_node: i32.

restore_err_ret_index

Restores the error return index to its last saved state in a given block. If the block is .none, restores to the state from the point of function entry. If the operand is not .none, the restore is conditional on the operand value not being an error. operand is payload index to RestoreErrRetIndex. small is undefined.

closure_get

Retrieves a value from the current type declaration scope's closure. operand is src_node: i32. small is closure index.

value_placeholder

Used as a placeholder instruction which is just a dummy index for Sema to replace with a specific value. For instance, this is used for the capture of an errdefer. This should never appear in a body.

field_parent_ptr

Implements the @fieldParentPtr builtin. operand is payload index to FieldParentPtr. small contains FullPtrCastFlags. Guaranteed to not have the ptr_cast flag. Uses the pl_node union field with payload FieldParentPtr.

builtin_value

Get a type or value from std.builtin. operand is src_node: i32. small is an Inst.BuiltinValue.

branch_hint

Provide a @branchHint for the current block. operand is payload index to UnNode. small is unused.

inplace_arith_result_ty

Compute the result type for in-place arithmetic, e.g. +=. operand is Zir.Inst.Ref of the loaded LHS (not its type). small is an Inst.InplaceOp.

dbg_empty_stmt

Marks a statement that can be stepped to but produces no code. operand and small are ignored.

astgen_error

At this point, AstGen encountered a fatal error which terminated ZIR lowering for this body. A file-level error has been reported. Sema should terminate semantic analysis. operand and small are ignored. This instruction is always noreturn, however, it is not considered as such by ZIR-level queries. This allows AstGen to assume that any code may have gone here, avoiding false-positive "unreachable code" errors.

Source Code

Source code
pub const Extended = enum(u16) {
    /// A struct type definition. Contains references to ZIR instructions for
    /// the field types, defaults, and alignments.
    /// `operand` is payload index to `StructDecl`.
    /// `small` is `StructDecl.Small`.
    struct_decl,
    /// An enum type definition. Contains references to ZIR instructions for
    /// the field value expressions and optional type tag expression.
    /// `operand` is payload index to `EnumDecl`.
    /// `small` is `EnumDecl.Small`.
    enum_decl,
    /// A union type definition. Contains references to ZIR instructions for
    /// the field types and optional type tag expression.
    /// `operand` is payload index to `UnionDecl`.
    /// `small` is `UnionDecl.Small`.
    union_decl,
    /// An opaque type definition. Contains references to decls and captures.
    /// `operand` is payload index to `OpaqueDecl`.
    /// `small` is `OpaqueDecl.Small`.
    opaque_decl,
    /// A tuple type. Note that tuples are not namespace/container types.
    /// `operand` is payload index to `TupleDecl`.
    /// `small` is `fields_len: u16`.
    tuple_decl,
    /// Implements the `@This` builtin.
    /// `operand` is `src_node: i32`.
    this,
    /// Implements the `@returnAddress` builtin.
    /// `operand` is `src_node: i32`.
    ret_addr,
    /// Implements the `@src` builtin.
    /// `operand` is payload index to `LineColumn`.
    builtin_src,
    /// Implements the `@errorReturnTrace` builtin.
    /// `operand` is `src_node: i32`.
    error_return_trace,
    /// Implements the `@frame` builtin.
    /// `operand` is `src_node: i32`.
    frame,
    /// Implements the `@frameAddress` builtin.
    /// `operand` is `src_node: i32`.
    frame_address,
    /// Same as `alloc` from `Tag` but may contain an alignment instruction.
    /// `operand` is payload index to `AllocExtended`.
    /// `small`:
    ///  * 0b000X - has type
    ///  * 0b00X0 - has alignment
    ///  * 0b0X00 - 1=const, 0=var
    ///  * 0bX000 - is comptime
    alloc,
    /// The `@extern` builtin.
    /// `operand` is payload index to `BinNode`.
    builtin_extern,
    /// Inline assembly.
    /// `small`:
    ///  * 0b00000000_000XXXXX - `outputs_len`.
    ///  * 0b000000XX_XXX00000 - `inputs_len`.
    ///  * 0b0XXXXX00_00000000 - `clobbers_len`.
    ///  * 0bX0000000_00000000 - is volatile
    /// `operand` is payload index to `Asm`.
    @"asm",
    /// Same as `asm` except the assembly template is not a string literal but a comptime
    /// expression.
    /// The `asm_source` field of the Asm is not a null-terminated string
    /// but instead a Ref.
    asm_expr,
    /// Log compile time variables and emit an error message.
    /// `operand` is payload index to `NodeMultiOp`.
    /// `small` is `operands_len`.
    /// The AST node is the compile log builtin call.
    compile_log,
    /// The builtin `@TypeOf` which returns the type after Peer Type Resolution
    /// of one or more params.
    /// `operand` is payload index to `TypeOfPeer`.
    /// `small` is `operands_len`.
    /// The AST node is the builtin call.
    typeof_peer,
    /// Implements the `@min` builtin for more than 2 args.
    /// `operand` is payload index to `NodeMultiOp`.
    /// `small` is `operands_len`.
    /// The AST node is the builtin call.
    min_multi,
    /// Implements the `@max` builtin for more than 2 args.
    /// `operand` is payload index to `NodeMultiOp`.
    /// `small` is `operands_len`.
    /// The AST node is the builtin call.
    max_multi,
    /// Implements the `@addWithOverflow` builtin.
    /// `operand` is payload index to `BinNode`.
    /// `small` is unused.
    add_with_overflow,
    /// Implements the `@subWithOverflow` builtin.
    /// `operand` is payload index to `BinNode`.
    /// `small` is unused.
    sub_with_overflow,
    /// Implements the `@mulWithOverflow` builtin.
    /// `operand` is payload index to `BinNode`.
    /// `small` is unused.
    mul_with_overflow,
    /// Implements the `@shlWithOverflow` builtin.
    /// `operand` is payload index to `BinNode`.
    /// `small` is unused.
    shl_with_overflow,
    /// `operand` is payload index to `UnNode`.
    c_undef,
    /// `operand` is payload index to `UnNode`.
    c_include,
    /// `operand` is payload index to `BinNode`.
    c_define,
    /// `operand` is payload index to `UnNode`.
    wasm_memory_size,
    /// `operand` is payload index to `BinNode`.
    wasm_memory_grow,
    /// The `@prefetch` builtin.
    /// `operand` is payload index to `BinNode`.
    prefetch,
    /// Implement builtin `@setFloatMode`.
    /// `operand` is payload index to `UnNode`.
    set_float_mode,
    /// Implements the `@errorCast` builtin.
    /// `operand` is payload index to `BinNode`. `lhs` is dest type, `rhs` is operand.
    error_cast,
    /// `operand` is payload index to `UnNode`.
    await_nosuspend,
    /// Implements `@breakpoint`.
    /// `operand` is `src_node: i32`.
    breakpoint,
    /// Implement builtin `@disableInstrumentation`. `operand` is `src_node: i32`.
    disable_instrumentation,
    /// Implement builtin `@disableIntrinsics`. `operand` is `src_node: i32`.
    disable_intrinsics,
    /// Implements the `@select` builtin.
    /// `operand` is payload index to `Select`.
    select,
    /// Implement builtin `@errToInt`.
    /// `operand` is payload index to `UnNode`.
    int_from_error,
    /// Implement builtin `@errorFromInt`.
    /// `operand` is payload index to `UnNode`.
    error_from_int,
    /// Implement builtin `@Type`.
    /// `operand` is payload index to `Reify`.
    /// `small` contains `NameStrategy`.
    reify,
    /// Implements the `@asyncCall` builtin.
    /// `operand` is payload index to `AsyncCall`.
    builtin_async_call,
    /// Implements the `@cmpxchgStrong` and `@cmpxchgWeak` builtins.
    /// `small` 0=>weak 1=>strong
    /// `operand` is payload index to `Cmpxchg`.
    cmpxchg,
    /// Implement builtin `@cVaArg`.
    /// `operand` is payload index to `BinNode`.
    c_va_arg,
    /// Implement builtin `@cVaCopy`.
    /// `operand` is payload index to `UnNode`.
    c_va_copy,
    /// Implement builtin `@cVaEnd`.
    /// `operand` is payload index to `UnNode`.
    c_va_end,
    /// Implement builtin `@cVaStart`.
    /// `operand` is `src_node: i32`.
    c_va_start,
    /// Implements the following builtins:
    /// `@ptrCast`, `@alignCast`, `@addrSpaceCast`, `@constCast`, `@volatileCast`.
    /// Represents an arbitrary nesting of the above builtins. Such a nesting is treated as a
    /// single operation which can modify multiple components of a pointer type.
    /// `operand` is payload index to `BinNode`.
    /// `small` contains `FullPtrCastFlags`.
    /// AST node is the root of the nested casts.
    /// `lhs` is dest type, `rhs` is operand.
    ptr_cast_full,
    /// `operand` is payload index to `UnNode`.
    /// `small` contains `FullPtrCastFlags`.
    /// Guaranteed to only have flags where no explicit destination type is
    /// required (const_cast and volatile_cast).
    /// AST node is the root of the nested casts.
    ptr_cast_no_dest,
    /// Implements the `@workItemId` builtin.
    /// `operand` is payload index to `UnNode`.
    work_item_id,
    /// Implements the `@workGroupSize` builtin.
    /// `operand` is payload index to `UnNode`.
    work_group_size,
    /// Implements the `@workGroupId` builtin.
    /// `operand` is payload index to `UnNode`.
    work_group_id,
    /// Implements the `@inComptime` builtin.
    /// `operand` is `src_node: i32`.
    in_comptime,
    /// Restores the error return index to its last saved state in a given
    /// block. If the block is `.none`, restores to the state from the point
    /// of function entry. If the operand is not `.none`, the restore is
    /// conditional on the operand value not being an error.
    /// `operand` is payload index to `RestoreErrRetIndex`.
    /// `small` is undefined.
    restore_err_ret_index,
    /// Retrieves a value from the current type declaration scope's closure.
    /// `operand` is `src_node: i32`.
    /// `small` is closure index.
    closure_get,
    /// Used as a placeholder instruction which is just a dummy index for Sema to replace
    /// with a specific value. For instance, this is used for the capture of an `errdefer`.
    /// This should never appear in a body.
    value_placeholder,
    /// Implements the `@fieldParentPtr` builtin.
    /// `operand` is payload index to `FieldParentPtr`.
    /// `small` contains `FullPtrCastFlags`.
    /// Guaranteed to not have the `ptr_cast` flag.
    /// Uses the `pl_node` union field with payload `FieldParentPtr`.
    field_parent_ptr,
    /// Get a type or value from `std.builtin`.
    /// `operand` is `src_node: i32`.
    /// `small` is an `Inst.BuiltinValue`.
    builtin_value,
    /// Provide a `@branchHint` for the current block.
    /// `operand` is payload index to `UnNode`.
    /// `small` is unused.
    branch_hint,
    /// Compute the result type for in-place arithmetic, e.g. `+=`.
    /// `operand` is `Zir.Inst.Ref` of the loaded LHS (*not* its type).
    /// `small` is an `Inst.InplaceOp`.
    inplace_arith_result_ty,
    /// Marks a statement that can be stepped to but produces no code.
    /// `operand` and `small` are ignored.
    dbg_empty_stmt,
    /// At this point, AstGen encountered a fatal error which terminated ZIR lowering for this body.
    /// A file-level error has been reported. Sema should terminate semantic analysis.
    /// `operand` and `small` are ignored.
    /// This instruction is always `noreturn`, however, it is not considered as such by ZIR-level queries. This allows AstGen to assume that
    /// any code may have gone here, avoiding false-positive "unreachable code" errors.
    astgen_error,

    pub const InstData = struct {
        opcode: Extended,
        small: u16,
        operand: u32,
    };
}