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: Ast.Node.Offset`.
this,
/// Implements the `@returnAddress` builtin.
/// `operand` is `src_node: Ast.Node.Offset`.
ret_addr,
/// Implements the `@src` builtin.
/// `operand` is payload index to `LineColumn`.
builtin_src,
/// Implements the `@errorReturnTrace` builtin.
/// `operand` is `src_node: Ast.Node.Offset`.
error_return_trace,
/// Implements the `@frame` builtin.
/// `operand` is `src_node: Ast.Node.Offset`.
frame,
/// Implements the `@frameAddress` builtin.
/// `operand` is `src_node: Ast.Node.Offset`.
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.
/// `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,
/// `@round`, `@floor`, `@ceil`, or `@trunc`, with a result type.
/// `operand` is payload index to `BinNode`.
/// `small` is a `RoundOp` representing the specific operation being performed.
round_op,
/// Returns the type for the operand of a rounding op.
/// `operand` is `UnNode`.
/// `small` is unused.
round_op_ty,
/// `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,
/// Implements `@breakpoint`.
/// `operand` is `src_node: Ast.Node.Offset`.
breakpoint,
/// Implement builtin `@disableInstrumentation`. `operand` is `src_node: Ast.Node.Offset`.
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,
/// Given a comptime-known operand of type `[]const A`, returns the type `*const [operand.len]B`.
/// The types `A` and `B` are determined from `ReifySliceArgInfo`.
/// This instruction is used to provide result types to arguments of `@Fn`, `@Struct`, etc.
/// `operand` is payload index to `UnNode`.
/// `small` is a bitcast `ReifySliceArgInfo`.
reify_slice_arg_ty,
/// Like `reify_slice_arg_ty` for the specific case of `[]const []const u8` to `[]const TagInt`,
/// as needed for `@Enum`.
/// `operand` is payload index to `BinNode`. lhs is the type `TagInt`. rhs is the `[]const []const u8` value.
/// `small` is unused.
reify_enum_value_slice_ty,
/// Given a comptime-known operand of type `type`, returns the type `?operand` if possible, otherwise `?noreturn`.
/// Used for the final arg of `@Pointer` to allow reifying pointers to opaque types.
/// `operand` is payload index to `UnNode`.
/// `small` is unused.
reify_pointer_sentinel_ty,
/// Implements builtin `@Tuple`.
/// `operand` is payload index to `UnNode`.
reify_tuple,
/// Implements builtin `@Pointer`.
/// `operand` is payload index to `ReifyPointer`.
reify_pointer,
/// Implements builtin `@Fn`.
/// `operand` is payload index to `ReifyFn`.
reify_fn,
/// Implements builtin `@Struct`.
/// `operand` is payload index to `ReifyStruct`.
/// `small` contains `NameStrategy`.
reify_struct,
/// Implements builtin `@Union`.
/// `operand` is payload index to `ReifyUnion`.
/// `small` contains `NameStrategy`.
reify_union,
/// Implements builtin `@Enum`.
/// `operand` is payload index to `ReifyEnum`.
/// `small` contains `NameStrategy`.
reify_enum,
/// Implements builtin `@SpirvType`.
/// `operand` is payload index to `ReifyFn`.
reify_spirv_type,
/// 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: Ast.Node.Offset`.
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: Ast.Node.Offset`.
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: Ast.Node.Offset`.
/// `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.lang`.
/// `operand` is `src_node: Ast.Node.Offset`.
/// `small` is an `Inst.StdLangValue`.
std_lang_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,
/// Given a type, strips away any error unions or optionals stacked
/// on top and returns the base type. That base type must be a float.
/// For example: Provided with `error{Foo}!?f64`, returns `f64`.
/// `operand` is payload index to `UnNode`.
float_op_result_ty,
pub const InstData = struct {
opcode: Extended,
small: u16,
operand: u32,
};
}
Rarer instructions are here; ones that do not fit in the 8-bit
Tagenum.noreturninstructions may not go here; they must be part of the mainTagenum.