union Data [src]

All instructions have an 8-byte payload, which is contained within this union. Tag determines which union field is active, as well as how to interpret the data within.

Fields

extended: Extended.InstDataUsed for Tag.extended. The extended opcode determines the meaning of the small and operand fields.
un_node: struct { /// Offset from Decl AST node index. src_node: Ast.Node.Offset, /// The meaning of this operand depends on the corresponding `Tag`. operand: Ref, }Used for unary operators, with an AST node source location.
un_tok: struct { /// Offset from Decl AST token index. src_tok: Ast.TokenOffset, /// The meaning of this operand depends on the corresponding `Tag`. operand: Ref, }Used for unary operators, with a token source location.
pl_node: struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: Ast.Node.Offset, /// index into extra. /// `Tag` determines what lives there. payload_index: u32, }
pl_tok: struct { /// Offset from Decl AST token index. src_tok: Ast.TokenOffset, /// index into extra. /// `Tag` determines what lives there. payload_index: u32, }
bin: Bin
str: struct { /// Offset into `string_bytes`. start: NullTerminatedString, /// Number of bytes in the string. len: u32, pub fn get(self: @This(), code: Zir) []const u8 { return code.string_bytes[@intFromEnum(self.start)..][0..self.len]; } }For strings which may contain null bytes.
str_tok: struct { /// Offset into `string_bytes`. Null-terminated. start: NullTerminatedString, /// Offset from Decl AST token index. src_tok: Ast.TokenOffset, pub fn get(self: @This(), code: Zir) [:0]const u8 { return code.nullTerminatedString(self.start); } }
tok: Ast.TokenOffsetOffset from Decl AST token index.
node: Ast.Node.OffsetOffset from Decl AST node index.
int: u64
float: f64
ptr_type: struct { flags: packed struct { is_allowzero: bool, is_mutable: bool, is_volatile: bool, has_sentinel: bool, has_align: bool, has_addrspace: bool, has_bit_range: bool, _: u1 = undefined, }, size: std.builtin.Type.Pointer.Size, /// Index into extra. See `PtrType`. payload_index: u32, }
int_type: struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: Ast.Node.Offset, signedness: std.builtin.Signedness, bit_count: u16, }
@"unreachable": struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: Ast.Node.Offset, }
@"break": struct { operand: Ref, /// Index of a `Break` payload. payload_index: u32, }
dbg_stmt: LineColumn
inst_node: struct { /// Offset from Decl AST node index. src_node: Ast.Node.Offset, /// The meaning of this operand depends on the corresponding `Tag`. inst: Index, }Used for unary operators which reference an inst, with an AST node source location.
str_op: struct { /// Offset into `string_bytes`. Null-terminated. str: NullTerminatedString, operand: Ref, pub fn getStr(self: @This(), zir: Zir) [:0]const u8 { return zir.nullTerminatedString(self.str); } }
@"defer": struct { index: u32, len: u32, }
defer_err_code: struct { err_code: Ref, payload_index: u32, }
save_err_ret_index: struct { operand: Ref, // If error type (or .none), save new trace index }
elem_val_imm: struct { /// The indexable value being accessed. operand: Ref, /// The index being accessed. idx: u32, }
declaration: struct { /// This node provides a new absolute baseline node for all instructions within this struct. src_node: Ast.Node.Index, /// index into extra to a `Declaration` payload. payload_index: u32, }

Members

Source

pub const Data = union { /// Used for `Tag.extended`. The extended opcode determines the meaning /// of the `small` and `operand` fields. extended: Extended.InstData, /// Used for unary operators, with an AST node source location. un_node: struct { /// Offset from Decl AST node index. src_node: Ast.Node.Offset, /// The meaning of this operand depends on the corresponding `Tag`. operand: Ref, }, /// Used for unary operators, with a token source location. un_tok: struct { /// Offset from Decl AST token index. src_tok: Ast.TokenOffset, /// The meaning of this operand depends on the corresponding `Tag`. operand: Ref, }, pl_node: struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: Ast.Node.Offset, /// index into extra. /// `Tag` determines what lives there. payload_index: u32, }, pl_tok: struct { /// Offset from Decl AST token index. src_tok: Ast.TokenOffset, /// index into extra. /// `Tag` determines what lives there. payload_index: u32, }, bin: Bin, /// For strings which may contain null bytes. str: struct { /// Offset into `string_bytes`. start: NullTerminatedString, /// Number of bytes in the string. len: u32, pub fn get(self: @This(), code: Zir) []const u8 { return code.string_bytes[@intFromEnum(self.start)..][0..self.len]; } }, str_tok: struct { /// Offset into `string_bytes`. Null-terminated. start: NullTerminatedString, /// Offset from Decl AST token index. src_tok: Ast.TokenOffset, pub fn get(self: @This(), code: Zir) [:0]const u8 { return code.nullTerminatedString(self.start); } }, /// Offset from Decl AST token index. tok: Ast.TokenOffset, /// Offset from Decl AST node index. node: Ast.Node.Offset, int: u64, float: f64, ptr_type: struct { flags: packed struct { is_allowzero: bool, is_mutable: bool, is_volatile: bool, has_sentinel: bool, has_align: bool, has_addrspace: bool, has_bit_range: bool, _: u1 = undefined, }, size: std.builtin.Type.Pointer.Size, /// Index into extra. See `PtrType`. payload_index: u32, }, int_type: struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: Ast.Node.Offset, signedness: std.builtin.Signedness, bit_count: u16, }, @"unreachable": struct { /// Offset from Decl AST node index. /// `Tag` determines which kind of AST node this points to. src_node: Ast.Node.Offset, }, @"break": struct { operand: Ref, /// Index of a `Break` payload. payload_index: u32, }, dbg_stmt: LineColumn, /// Used for unary operators which reference an inst, /// with an AST node source location. inst_node: struct { /// Offset from Decl AST node index. src_node: Ast.Node.Offset, /// The meaning of this operand depends on the corresponding `Tag`. inst: Index, }, str_op: struct { /// Offset into `string_bytes`. Null-terminated. str: NullTerminatedString, operand: Ref, pub fn getStr(self: @This(), zir: Zir) [:0]const u8 { return zir.nullTerminatedString(self.str); } }, @"defer": struct { index: u32, len: u32, }, defer_err_code: struct { err_code: Ref, payload_index: u32, }, save_err_ret_index: struct { operand: Ref, // If error type (or .none), save new trace index }, elem_val_imm: struct { /// The indexable value being accessed. operand: Ref, /// The index being accessed. idx: u32, }, declaration: struct { /// This node provides a new absolute baseline node for all instructions within this struct. src_node: Ast.Node.Index, /// index into extra to a `Declaration` payload. payload_index: u32, }, // Make sure we don't accidentally add a field to make this union // bigger than expected. Note that in Debug builds, Zig is allowed // to insert a secret field for safety checks. comptime { if (builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { assert(@sizeOf(Data) == 8); } } /// TODO this has to be kept in sync with `Data` which we want to be an untagged /// union. There is some kind of language awkwardness here and it has to do with /// deserializing an untagged union (in this case `Data`) from a file, and trying /// to preserve the hidden safety field. pub const FieldEnum = enum { extended, un_node, un_tok, pl_node, pl_tok, bin, str, str_tok, tok, node, int, float, ptr_type, int_type, @"unreachable", @"break", dbg_stmt, inst_node, str_op, @"defer", defer_err_code, save_err_ret_index, elem_val_imm, declaration, }; }