Skip to documentation
SLOP

tiny.choir.bytecode

Reference tiny.choir bytecode

Defined in tiny.choir.

API (62)

Actions

Public operations.

Types and contracts

Public types and contracts.

Namespaces

Public namespaces.

Values and defaults

Public values and defaults.

No direct callersNo direct callstiny.choirbytecode
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/choir/src/bytecode/bytecode.zig:1917

zig
pub const AttrKind = enum(u8) {    dialect = 0,    integer = 1,    float_ = 2,    bool_ = 3,    string = 4,    type_list = 5,    string_list = 6,    symbol_ref = 7,    array = 8,};

Source: lib/choir/src/bytecode/bytecode.zig:1877

zig
pub const BuiltinScalarKind = enum(u8) {    index = 0,    bool_ = 1,    integer = 2,    float_ = 3,};

Source: lib/choir/src/bytecode/bytecode.zig:29

zig
pub const ContainerHeader = struct {    version: u32,    endianness: u8,    ptr_size: u8,    flags: u16,    section_table_offset: u64,    section_count: u64,    file_hash: u64,    pub fn compatibility(self: ContainerHeader) FormatCompatibility {        return classifyFormatVersion(self.version);    }};

Source: lib/choir/src/bytecode/bytecode.zig:122

zig
pub const DecodedModule = struct {    module: *ir.Operation,    tables: DecodedTables,    resources: []const Resource = &.{},    pub fn format(self: *const DecodedModule) FormatCompatibility {        return self.tables.format;    }    pub fn deinit(self: *DecodedModule) void {        freeResources(self.tables.allocator, self.resources);        self.tables.deinit();    }};

Source: lib/choir/src/bytecode/bytecode.zig:95

zig
pub const DecodedTables = struct {    allocator: std.mem.Allocator,    format: FormatCompatibility,    strings: []const []const u8,    dialects: []const DialectEntry,    types: []const ir.Type,    attrs: []const ir.Attribute,    locs: []const ir.Location,    loc_slices: std.ArrayList([]const ir.Location),    pub fn deinit(self: *DecodedTables) void {        for (self.loc_slices.items) |slice| {            self.allocator.free(@constCast(slice));        }        self.loc_slices.deinit(self.allocator);        for (self.strings) |str| {            self.allocator.free(@constCast(str));        }        self.allocator.free(self.strings);        self.allocator.free(self.dialects);        self.allocator.free(self.types);        self.allocator.free(self.attrs);        self.allocator.free(self.locs);    }};

Source: lib/choir/src/bytecode/bytecode.zig:78

zig
pub const DialectEntry = struct {    name: []const u8,    version: u32,    flags: u32,    pub fn usesDefaultVersion(self: DialectEntry) bool {        return self.version == default_dialect_version and self.flags == default_dialect_flags;    }};

Source: lib/choir/src/bytecode/bytecode.zig:137

zig
pub const FlatModuleDecoder = struct {    allocator: std.mem.Allocator,    tables: DecodedTables,    resources: []const Resource,    decoder: ModuleDecoder,    reader: SliceReader,    module_name: []const u8,    module_location: ir.Location,    operations_remaining: usize,    value_base: usize = 0,    current: ?*ir.Operation = null,    pub fn init(        allocator: std.mem.Allocator,        ctx: *ir.Context,        bytes: []const u8,    ) !FlatModuleDecoder {        const sections = try parseSections(bytes);        const module_bytes = sections.module orelse return error.MissingModule;        var tables = try decodeTablesFromSections(allocator, ctx, sections);        errdefer tables.deinit();        const resources = try decodeResourcesSection(allocator, sections.resources);        errdefer freeResources(allocator, resources);        var decoder = ModuleDecoder.init(allocator, ctx, &tables);        errdefer decoder.deinit();        var reader = SliceReader.init(module_bytes);        const envelope = try decodeFlatModuleEnvelope(&decoder, &reader);        return .{            .allocator = allocator,            .tables = tables,            .resources = resources,            .decoder = decoder,            .reader = reader,            .module_name = envelope.name,            .module_location = envelope.location,            .operations_remaining = envelope.operation_count,        };    }    pub fn deinit(self: *FlatModuleDecoder) void {        self.releaseCurrent();        self.decoder.deinit();        freeResources(self.allocator, self.resources);        self.tables.deinit();        self.* = undefined;    }    pub fn format(self: *const FlatModuleDecoder) FormatCompatibility {        return self.tables.format;    }    pub fn name(self: *const FlatModuleDecoder) []const u8 {        return self.module_name;    }    pub fn location(self: *const FlatModuleDecoder) ir.Location {        return self.module_location;    }    pub fn next(self: *FlatModuleDecoder) !?*ir.Operation {        self.releaseCurrent();        if (self.operations_remaining == 0) {            if (self.reader.offset != self.reader.bytes.len) {                return error.InvalidModule;            }            return null;        }        self.decoder.value_base = self.value_base;        const op = try decodeOperation(            &self.decoder,            &self.reader,            null,            null,        );        self.current = op;        self.operations_remaining -= 1;        return op;    }    fn releaseCurrent(self: *FlatModuleDecoder) void {        const op = self.current orelse return;        op.erase();        self.value_base = std.math.add(            usize,            self.value_base,            self.decoder.values.items.len,        ) catch unreachable;        self.decoder.values.clearRetainingCapacity();        self.current = null;    }};

Source: lib/choir/src/bytecode/bytecode.zig:18

zig
pub const FormatCompatibility = struct {    version: u32,    minimum_readable: u32 = minimum_readable_version,    maximum_readable: u32 = maximum_readable_version,    status: FormatVersionStatus,    pub fn readable(self: FormatCompatibility) bool {        return self.status == .readable;    }};

Source: lib/choir/src/bytecode/bytecode.zig:12

zig
pub const FormatVersionStatus = enum {    readable,    unsupported_older,    unsupported_newer,};

Source: lib/choir/src/bytecode/bytecode.zig:1929

zig
pub const LocationKind = enum(u8) {    unknown = 0,    file = 1,    name = 2,    fused = 3,    call_site = 4,    file_range = 5,};

Source: lib/choir/src/bytecode/bytecode.zig:693

zig
pub const ParsedSections = struct {    header: ContainerHeader,    strings: ?[]const u8,    dialects: ?[]const u8,    types: ?[]const u8,    attrs: ?[]const u8,    locs: ?[]const u8,    module: ?[]const u8,    resources: ?[]const u8,};

Source: lib/choir/src/bytecode/bytecode.zig:88

zig
pub const Resource = struct {    namespace: []const u8,    name: []const u8,    type_id: []const u8,    data: []const u8,};

Source: lib/choir/src/bytecode/bytecode.zig:55

zig
pub const SectionKind = enum(u32) {    strings = 1,    dialects = 2,    types = 3,    attributes = 4,    locations = 5,    module = 6,    resources = 7,};

Source: lib/choir/src/bytecode/bytecode.zig:2091

zig
pub const SliceReader = struct {    bytes: []const u8,    offset: usize,    pub fn init(bytes: []const u8) SliceReader {        return .{ .bytes = bytes, .offset = 0 };    }    pub fn readByte(self: *SliceReader) !u8 {        if (self.offset >= self.bytes.len) return error.EndOfStream;        const value = self.bytes[self.offset];        self.offset += 1;        return value;    }    pub fn readBytes(self: *SliceReader, len: usize) ![]const u8 {        if (len > self.bytes.len - self.offset) return error.EndOfStream;        const end = self.offset + len;        const slice = self.bytes[self.offset..end];        self.offset = end;        return slice;    }    pub fn readBytesWithLen(self: *SliceReader) ![]const u8 {        const len = try self.readULEBToUsize();        return self.readBytes(len);    }    pub fn readU16(self: *SliceReader) !u16 {        const slice = try self.readBytes(2);        var buf: [2]u8 = undefined;        std.mem.copyForwards(u8, buf[0..], slice);        return std.mem.readInt(u16, &buf, .little);    }    pub fn readU32(self: *SliceReader) !u32 {        const slice = try self.readBytes(4);        var buf: [4]u8 = undefined;        std.mem.copyForwards(u8, buf[0..], slice);        return std.mem.readInt(u32, &buf, .little);    }    pub fn readU64(self: *SliceReader) !u64 {        const slice = try self.readBytes(8);        var buf: [8]u8 = undefined;        std.mem.copyForwards(u8, buf[0..], slice);        return std.mem.readInt(u64, &buf, .little);    }    pub fn readULEB(self: *SliceReader) !u64 {        var result: u64 = 0;        var shift: u8 = 0;        while (true) {            const byte = try self.readByte();            const payload = byte & 0x7f;            if (shift == 63) {                if (payload > 1) return error.InvalidLEB128;                result |= @as(u64, payload) << 63;            } else {                const bit_shift: u6 = @intCast(shift);                result |= @as(u64, payload) << bit_shift;            }            if ((byte & 0x80) == 0) return result;            if (shift >= 63) return error.InvalidLEB128;            shift += 7;        }    }    pub fn readSLEB(self: *SliceReader) !i64 {        var result: u64 = 0;        var shift: u8 = 0;        while (true) {            const byte = try self.readByte();            const payload = byte & 0x7f;            if (shift == 63) {                if (payload == 0x7f) {                    result |= @as(u64, 1) << 63;                } else if (payload != 0) {                    return error.InvalidLEB128;                }            } else {                const bit_shift: u6 = @intCast(shift);                result |= @as(u64, payload) << bit_shift;            }            if ((byte & 0x80) == 0) {                const used = shift + 7;                if (used < 64 and (byte & 0x40) != 0) {                    const sign_shift: u6 = @intCast(used);                    result |= @as(u64, std.math.maxInt(u64)) << sign_shift;                }                return @bitCast(result);            }            if (shift >= 63) return error.InvalidLEB128;            shift += 7;        }    }    pub fn readULEBToU32(self: *SliceReader) !u32 {        const value = try self.readULEB();        if (value > std.math.maxInt(u32)) return error.InvalidTable;        return @intCast(value);    }    pub fn readULEBToUsize(self: *SliceReader) !usize {        const value = try self.readULEB();        if (value > std.math.maxInt(usize)) return error.InvalidTable;        return @intCast(value);    }    pub fn readTypeList(        self: *SliceReader,        allocator: std.mem.Allocator,        count: usize,        types: []const ir.Type,    ) ![]ir.Type {        const list = try allocator.alloc(ir.Type, count);        errdefer allocator.free(list);        var i: usize = 0;        while (i < count) : (i += 1) {            const type_id = try self.readULEBToUsize();            if (type_id >= types.len) return error.InvalidTable;            list[i] = types[type_id];        }        return list;    }};

Source: lib/choir/src/bytecode/bytecode.zig:315

zig
pub const TableBuilder = struct {    allocator: std.mem.Allocator,    strings: StringTable,    dialects: DialectTable,    types: std.ArrayList(ir.Type),    attrs: std.ArrayList(ir.Attribute),    locs: std.ArrayList(ir.Location),    pub fn init(allocator: std.mem.Allocator) TableBuilder {        return .{            .allocator = allocator,            .strings = StringTable.init(allocator),            .dialects = DialectTable.init(allocator),            .types = .empty,            .attrs = .empty,            .locs = .empty,        };    }    pub fn deinit(self: *TableBuilder) void {        self.locs.deinit(self.allocator);        self.attrs.deinit(self.allocator);        self.types.deinit(self.allocator);        self.dialects.deinit(self.allocator);        self.strings.deinit();    }    pub fn internString(self: *TableBuilder, value: []const u8) !u32 {        return self.strings.intern(value);    }    pub fn internDialect(self: *TableBuilder, name: []const u8) !u32 {        const name_id = try self.internString(name);        return self.dialects.intern(self.allocator, name_id);    }    pub fn internType(self: *TableBuilder, typ: ir.Type) !u32 {        if (findTypeIndex(self.types.items, typ)) |id| return id;        const storage = typ.getDialectStorage() orelse return error.UnsupportedType;        const dialect = dialectNamespace(storage.name);        if (dialect.len > 0) {            _ = try self.internDialect(dialect);            const type_name = dialectTypeName(storage.name);            _ = try self.internString(type_name);        } else {            _ = try self.internDialect(storage.name);        }        if (storage.param_key.len > 0) {            _ = try self.internString(storage.param_key);        }        try self.types.append(self.allocator, typ);        return @intCast(self.types.items.len - 1);    }    pub fn internAttribute(self: *TableBuilder, attr: ir.Attribute) !u32 {        if (findAttrIndex(self.attrs.items, attr)) |id| return id;        if (attr.abstract.name.len == 0) return error.UnsupportedAttribute;        const dialect = dialectNamespace(attr.abstract.name);        if (dialect.len > 0) {            _ = try self.internDialect(dialect);        }        const attr_name = dialectTypeName(attr.abstract.name);        _ = try self.internString(attr_name);        const is_typed = std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.integer) or            std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.float_) or            std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.bool_) or            std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.string) or            std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.symbol_ref) or            std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.string_list) or            std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.type_list) or            std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.array);        if (!is_typed) {            _ = attr.cast(ir.Attribute.DialectAttr) orelse return error.UnsupportedAttribute;        }        if (std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.type_list)) {            const type_list_attr = attr.cast(ir.Attribute.TypeListAttr) orelse return error.UnsupportedAttribute;            for (type_list_attr.values) |typ| {                _ = try self.internType(typ);            }        }        if (std.mem.eql(u8, attr.abstract.name, ir.builtin_attr_names.array)) {            const array_attr = attr.cast(ir.Attribute.ArrayAttr) orelse return error.UnsupportedAttribute;            for (array_attr.values) |child| {                _ = try self.internAttribute(child);            }        }        try self.attrs.append(self.allocator, attr);        return @intCast(self.attrs.items.len - 1);    }    pub fn internLocation(self: *TableBuilder, loc: ir.Location) !u32 {        if (findLocationIndex(self.locs.items, loc)) |id| return id;        switch (loc) {            .unknown => {},            .file => |file_loc| {                _ = try self.internString(file_loc.filename);            },            .file_range => |file_range| {                _ = try self.internString(file_range.filename);            },            .name => |name_loc| {                _ = try self.internString(name_loc.name);                if (name_loc.child) |child| {                    _ = try self.internLocation(child.*);                }            },            .fused => |fused| {                for (fused.locations) |child_loc| {                    _ = try self.internLocation(child_loc);                }            },            .call_site => |call_site| {                _ = try self.internLocation(call_site.callee.*);                _ = try self.internLocation(call_site.caller.*);            },        }        try self.locs.append(self.allocator, loc);        return @intCast(self.locs.items.len - 1);    }};

Source: lib/choir/src/bytecode/bytecode.zig:1871

zig
pub const TypeKind = enum(u8) {    dialect = 0,    builtin_scalar = 1,    dialect_only = 2,};
Called byCallsNo direct callersbytecodeclassifyFormatVersionbytecode.ContainerHeadercompatibility
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersbytecode.DecodedTablesdeinitprivate sourcelib.choir.src.bytecode.bytecodefreeResourcesbytecode.DecodedModuledeinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsbytecode.DecodedModuledeinitbytecode.FlatModuleDecoderdeinitbytecode.DecodedTablesdeinit
Static calls · unresolved targets: 0 · external targets: 2.
Called byCallstest sourcelib.choir.src.bytecode.bytecodetest: bytecode flat module decoder re...test sourcelib.choir.src.bytecode.bytecodetest: bytecode flat module decoder re...bytecode.DecodedTablesdeinitprivate sourcelib.choir.src.bytecode.bytecode.FlatModuleDec...releaseCurrentprivate sourcelib.choir.src.bytecode.bytecode.ModuleDecoderdeinitprivate sourcelib.choir.src.bytecode.bytecodefreeResourcesbytecode.FlatModuleDecoderdeinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.choir.src.bytecode.bytecodetest: bytecode flat module decoder re...test sourcelib.choir.src.bytecode.bytecodetest: bytecode flat module decoder re...private sourcelib.choir.src.bytecode.bytecode.ModuleDecoderdeinitprivate sourcelib.choir.src.bytecode.bytecode.ModuleDecoderinitbytecode.Readerinitprivate sourcelib.choir.src.bytecode.bytecodedecodeFlatModuleEnvelopeprivate sourcelib.choir.src.bytecode.bytecodedecodeResourcesSection+3 morebytecode.FlatModuleDecoderinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callstest sourcelib.choir.src.bytecode.bytecodetest: bytecode flat module decoder re...bytecode.FlatModuleDecodername
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.choir.src.bytecode.bytecodetest: bytecode flat module decoder re...test sourcelib.choir.src.bytecode.bytecodetest: bytecode flat module decoder re...private sourcelib.choir.src.bytecode.bytecode.FlatModuleDec...releaseCurrentprivate sourcelib.choir.src.bytecode.bytecodedecodeOperationbytecode.FlatModuleDecodernext
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsbytecode.FlatModuleDecoderinitprivate sourcelib.choir.src.bytecode.bytecodedecodeAttributesprivate sourcelib.choir.src.bytecode.bytecodedecodeDialectsprivate sourcelib.choir.src.bytecode.bytecodedecodeLocationsprivate sourcelib.choir.src.bytecode.bytecodedecodeModuleSection+6 morebytecode.Readerinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsbytecode.ReaderreadSLEBbytecode.ReaderreadULEBbytecode.ReaderreadByte
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsbytecode.ReaderreadBytesWithLenbytecode.ReaderreadU16bytecode.ReaderreadU32bytecode.ReaderreadU64test sourcelib.choir.src.bytecode.bytecodetest: bytecode reader rejects overflo...bytecode.ReaderreadBytes
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.choir.src.bytecode.bytecodedecodeResourcesSectionprivate sourcelib.choir.src.bytecode.bytecodedecodeStringsbytecode.ReaderreadBytesbytecode.ReaderreadULEBToUsizebytecode.ReaderreadBytesWithLen
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.choir.src.bytecode.bytecodetest: bytecode reader rejects overflo...bytecode.ReaderreadBytebytecode.ReaderreadSLEB
Static calls · unresolved targets: 1 · external targets: 0.
Called byCallsNo direct callersbytecode.ReaderreadULEBToUsizebytecode.ReaderreadTypeList
Static calls · unresolved targets: 0 · external targets: 2.
Called byCallsNo direct callersbytecode.ReaderreadBytesbytecode.ReaderreadU16
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsbytecodeinspectSectionsbytecode.ReaderreadBytesbytecode.ReaderreadU32
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsbytecodeinspectSectionsbytecode.ReaderreadBytesbytecode.ReaderreadU64
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsbytecode.ReaderreadULEBToU32bytecode.ReaderreadULEBToUsizetest sourcelib.choir.src.bytecode.bytecodetest: bytecode reader rejects overflo...bytecode.ReaderreadBytebytecode.ReaderreadULEB
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.choir.src.bytecode.bytecodedecodeDialectsbytecode.ReaderreadULEBbytecode.ReaderreadULEBToU32
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsbytecode.ReaderreadBytesWithLenbytecode.ReaderreadTypeListprivate sourcelib.choir.src.bytecode.bytecodedecodeAttributesprivate sourcelib.choir.src.bytecode.bytecodedecodeDialectsprivate sourcelib.choir.src.bytecode.bytecodedecodeLocations+3 morebytecode.ReaderreadULEBbytecode.ReaderreadULEBToUsize
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsbytecodeencodeModuleWithResourcestest sourcelib.choir.src.bytecode.bytecodetest: bytecode encoding is determinis...test sourcelib.choir.src.bytecode.bytecodetest: bytecode ignores unknown sectio...test sourcelib.choir.src.bytecode.bytecodetest: bytecode inspects and rejects u...test sourcelib.choir.src.bytecode.bytecodetest: bytecode rejects invalid magic+4 moreprivate sourcelib.choir.src.bytecode.bytecode.DialectTabledeinitprivate sourcelib.choir.src.bytecode.bytecode.StringTabledeinitbytecode.TableBuilderdeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsbytecodeencodeModuleWithResourcestest sourcelib.choir.src.bytecode.bytecodetest: bytecode encoding is determinis...test sourcelib.choir.src.bytecode.bytecodetest: bytecode ignores unknown sectio...test sourcelib.choir.src.bytecode.bytecodetest: bytecode inspects and rejects u...test sourcelib.choir.src.bytecode.bytecodetest: bytecode rejects invalid magic+4 moreprivate sourcelib.choir.src.bytecode.bytecode.DialectTableinitprivate sourcelib.choir.src.bytecode.bytecode.StringTableinitbytecode.TableBuilderinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.choir.src.bytecode.bytecodetest: bytecode encoding is determinis...test sourcelib.choir.src.bytecode.bytecodetest: bytecode tables round-tripbytecode.TableBuilderinternDialectbytecode.TableBuilderinternStringbytecode.TableBuilderinternTypeprivate sourcelib.choir.src.bytecode.bytecodedialectNamespaceprivate sourcelib.choir.src.bytecode.bytecodedialectTypeNameprivate sourcelib.choir.src.bytecode.bytecodefindAttrIndexbytecode.TableBuilderinternAttribute
Static calls · unresolved targets: 1 · external targets: 1.
Called byCallsbytecode.TableBuilderinternAttributebytecode.TableBuilderinternTypeprivate sourcelib.choir.src.bytecode.bytecode.DialectTableinternbytecode.TableBuilderinternStringbytecode.TableBuilderinternDialect
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsbytecodeencodeModuleWithResourcestest sourcelib.choir.src.bytecode.bytecodetest: bytecode encoding is determinis...test sourcelib.choir.src.bytecode.bytecodetest: bytecode ignores unknown sectio...test sourcelib.choir.src.bytecode.bytecodetest: bytecode tables round-tripbytecode.TableBuilderinternStringprivate sourcelib.choir.src.bytecode.bytecodefindLocationIndexbytecode.TableBuilderinternLocation
Static calls · unresolved targets: 1 · external targets: 0.
Called byCallsbytecode.TableBuilderinternAttributebytecode.TableBuilderinternDialectbytecode.TableBuilderinternLocationbytecode.TableBuilderinternTypeprivate sourcelib.choir.src.bytecode.bytecode.StringTableinternbytecode.TableBuilderinternString
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsbytecode.TableBuilderinternAttributetest sourcelib.choir.src.bytecode.bytecodetest: bytecode encoding is determinis...test sourcelib.choir.src.bytecode.bytecodetest: bytecode round-trips builtin sc...test sourcelib.choir.src.bytecode.bytecodetest: bytecode round-trips undotted d...test sourcelib.choir.src.bytecode.bytecodetest: bytecode tables round-tripbytecode.TableBuilderinternDialectbytecode.TableBuilderinternStringprivate sourcelib.choir.src.bytecode.bytecodedialectNamespaceprivate sourcelib.choir.src.bytecode.bytecodedialectTypeNameprivate sourcelib.choir.src.bytecode.bytecodefindTypeIndexbytecode.TableBuilderinternType
Static calls · unresolved targets: 1 · external targets: 1.

Source: lib/choir/src/bytecode/bytecode.zig:43

zig
pub fn classifyFormatVersion(version: u32) FormatCompatibility {    return .{        .version = version,        .status = if (version < minimum_readable_version)            .unsupported_older        else if (version > maximum_readable_version)            .unsupported_newer        else            .readable,    };}
Called byCallsNo direct callsbytecode.ContainerHeadercompatibilitytest sourcelib.choir.src.bytecode.bytecodetest: bytecode exposes format version...bytecodeclassifyFormatVersion
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/choir/src/bytecode/bytecode.zig:602

zig
pub fn decodeModule(allocator: std.mem.Allocator, ctx: *ir.Context, bytes: []const u8) !DecodedModule {    const sections = try parseSections(bytes);    const module_bytes = sections.module orelse return error.MissingModule;    var tables = try decodeTablesFromSections(allocator, ctx, sections);    errdefer tables.deinit();    const resources = try decodeResourcesSection(allocator, sections.resources);    errdefer freeResources(allocator, resources);    const module_op = try decodeModuleSection(allocator, ctx, module_bytes, &tables);    return .{        .module = module_op,        .tables = tables,        .resources = resources,    };}
Called byCallstest sourcelib.choir.src.backends.artifact.resourcetest: artifact bytecode resources rou...test sourcelib.choir.src.bytecode.bytecodetest: bytecode module round-triptest sourcelib.choir.src.bytecode.bytecodetest: bytecode module round-trips res...test sourcelib.choir.src.bytecode.bytecodetest: bytecode round-trips read-only ...test sourcelib.choir.src.bytecode.bytecodetest: bytecode table decoders reject ...+7 moreprivate sourcelib.choir.src.bytecode.bytecodedecodeModuleSectionprivate sourcelib.choir.src.bytecode.bytecodedecodeResourcesSectionprivate sourcelib.choir.src.bytecode.bytecodedecodeTablesFromSectionsprivate sourcelib.choir.src.bytecode.bytecodefreeResourcesbytecodeinspectSectionsbytecodedecodeModule
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/choir/src/bytecode/bytecode.zig:556

zig
pub fn decodeTables(allocator: std.mem.Allocator, ctx: *ir.Context, bytes: []const u8) !DecodedTables {    const sections = try parseSections(bytes);    return decodeTablesFromSections(allocator, ctx, sections);}
Called byCallsprivate sourcelib.choir.src.bytecode.bytecodetestTableAllocationFailuretest sourcelib.choir.src.bytecode.bytecodetest: bytecode ignores unknown sectio...test sourcelib.choir.src.bytecode.bytecodetest: bytecode inspects and rejects u...test sourcelib.choir.src.bytecode.bytecodetest: bytecode rejects invalid magictest sourcelib.choir.src.bytecode.bytecodetest: bytecode rejects overflowed sec...+5 moreprivate sourcelib.choir.src.bytecode.bytecodedecodeTablesFromSectionsbytecodeinspectSectionsbytecodedecodeTables
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/choir/src/bytecode/bytecode.zig:9

zig
pub const default_dialect_flags: u32 = 0;

Source: lib/choir/src/bytecode/bytecode.zig:8

zig
pub const default_dialect_version: u32 = 0;

Source: lib/choir/src/bytecode/bytecode.zig:469

zig
pub fn encodeModule(allocator: std.mem.Allocator, module: *ir.Operation) ![]u8 {    return encodeModuleWithResources(allocator, module, &.{});}
Called byCallstest sourcelib.choir.src.bytecode.bytecodetest: bytecode flat module decoder re...test sourcelib.choir.src.bytecode.bytecodetest: bytecode flat module decoder re...test sourcelib.choir.src.bytecode.bytecodetest: bytecode module round-triptest sourcelib.choir.src.bytecode.bytecodetest: bytecode round-trips read-only ...test sourcelib.choir.src.bytecode.qualificationtest: bytecode qualification refuses ...bytecodeencodeModuleWithResourcesbytecodeencodeModule
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/choir/src/bytecode/bytecode.zig:473

zig
pub fn encodeModuleWithResources(    allocator: std.mem.Allocator,    module: *ir.Operation,    resources: []const Resource,) ![]u8 {    var builder = TableBuilder.init(allocator);    defer builder.deinit();    _ = try builder.internLocation(ir.Location.getUnknown());    try collectOperationTables(&builder, module);    var sections: std.ArrayList(SectionData) = .empty;    defer {        for (sections.items) |section| {            allocator.free(@constCast(section.data));        }        sections.deinit(allocator);    }    try appendOwnedSection(        allocator,        &sections,        @backingInt(SectionKind.strings),        try encodeStringsSection(allocator, &builder),    );    try appendOwnedSection(        allocator,        &sections,        @backingInt(SectionKind.dialects),        try encodeDialectsSection(allocator, &builder),    );    try appendOwnedSection(        allocator,        &sections,        @backingInt(SectionKind.types),        try encodeTypesSection(allocator, &builder),    );    try appendOwnedSection(        allocator,        &sections,        @backingInt(SectionKind.attributes),        try encodeAttributesSection(allocator, &builder),    );    try appendOwnedSection(        allocator,        &sections,        @backingInt(SectionKind.locations),        try encodeLocationsSection(allocator, &builder),    );    try appendOwnedSection(        allocator,        &sections,        @backingInt(SectionKind.module),        try encodeModuleSection(allocator, &builder, module),    );    if (resources.len != 0) {        try appendOwnedSection(            allocator,            &sections,            @backingInt(SectionKind.resources),            try encodeResourcesSection(allocator, resources),        );    }    return try writeContainer(allocator, sections.items);}
Called byCallstest sourcelib.choir.src.backends.artifact.resourcetest: artifact bytecode resources rou...bytecodeencodeModuletest sourcelib.choir.src.bytecode.bytecodetest: bytecode module round-trips res...private sourcelib.choir.src.bytecode.imagetestBytesbytecode.qualificationencodebytecode.TableBuilderdeinitbytecode.TableBuilderinitbytecode.TableBuilderinternLocationprivate sourcelib.choir.src.bytecode.bytecodeappendOwnedSectionprivate sourcelib.choir.src.bytecode.bytecodecollectOperationTables+8 morebytecodeencodeModuleWithResources
Static calls · unresolved targets: 1 · external targets: 2.

Source: lib/choir/src/bytecode/bytecode.zig:442

zig
pub fn encodeTables(allocator: std.mem.Allocator, builder: *TableBuilder) ![]u8 {    var sections: std.ArrayList(SectionData) = .empty;    defer {        for (sections.items) |section| {            allocator.free(@constCast(section.data));        }        sections.deinit(allocator);    }    const strings_data = try encodeStringsSection(allocator, builder);    try sections.append(allocator, .{ .kind = @backingInt(SectionKind.strings), .flags = 0, .data = strings_data });    const dialects_data = try encodeDialectsSection(allocator, builder);    try sections.append(allocator, .{ .kind = @backingInt(SectionKind.dialects), .flags = 0, .data = dialects_data });    const types_data = try encodeTypesSection(allocator, builder);    try sections.append(allocator, .{ .kind = @backingInt(SectionKind.types), .flags = 0, .data = types_data });    const attrs_data = try encodeAttributesSection(allocator, builder);    try sections.append(allocator, .{ .kind = @backingInt(SectionKind.attributes), .flags = 0, .data = attrs_data });    const locs_data = try encodeLocationsSection(allocator, builder);    try sections.append(allocator, .{ .kind = @backingInt(SectionKind.locations), .flags = 0, .data = locs_data });    return try writeContainer(allocator, sections.items);}
Called byCallstest sourcelib.choir.src.bytecode.bytecodetest: bytecode encoding is determinis...test sourcelib.choir.src.bytecode.bytecodetest: bytecode inspects and rejects u...test sourcelib.choir.src.bytecode.bytecodetest: bytecode rejects invalid magictest sourcelib.choir.src.bytecode.bytecodetest: bytecode rejects overflowed sec...test sourcelib.choir.src.bytecode.bytecodetest: bytecode round-trips builtin sc...+2 moreprivate sourcelib.choir.src.bytecode.bytecodeencodeAttributesSectionprivate sourcelib.choir.src.bytecode.bytecodeencodeDialectsSectionprivate sourcelib.choir.src.bytecode.bytecodeencodeLocationsSectionprivate sourcelib.choir.src.bytecode.bytecodeencodeStringsSectionprivate sourcelib.choir.src.bytecode.bytecodeencodeTypesSectionprivate sourcelib.choir.src.bytecode.bytecodewriteContainerbytecodeencodeTables
Static calls · unresolved targets: 2 · external targets: 1.

Source: lib/choir/src/bytecode/bytecode.zig:5

zig
pub const format_version: u32 = 12;

Source: lib/choir/src/bytecode/bytecode.zig:673

zig
pub fn inspectHeader(bytes: []const u8) !ContainerHeader {    var reader = SliceReader.init(bytes);    return readHeader(&reader);}
Called byCallstest sourcelib.choir.src.backends.artifact.resourcetest: artifact bytecode resources rou...test sourcelib.choir.src.bytecode.bytecodetest: bytecode inspects and rejects u...bytecode.Readerinitprivate sourcelib.choir.src.bytecode.bytecodereadHeaderbytecodeinspectHeader
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/choir/src/bytecode/bytecode.zig:704

zig
pub fn parseSections(bytes: []const u8) !ParsedSections {    var header_reader = SliceReader.init(bytes);    const header = try readHeader(&header_reader);    if (!header.compatibility().readable()) return error.UnsupportedVersion;    if (header.endianness != current_endianness) return error.UnsupportedEndianness;    const bytes_len_u64: u64 = @intCast(bytes.len);    const section_table_size = std.math.mul(        u64,        header.section_count,        sectionEntrySize(),    ) catch return error.InvalidSectionTable;    const section_table_end = std.math.add(        u64,        header.section_table_offset,        section_table_size,    ) catch return error.InvalidSectionTable;    if (section_table_end > bytes_len_u64) return error.InvalidSectionTable;    var sections = ParsedSections{        .header = header,        .strings = null,        .dialects = null,        .types = null,        .attrs = null,        .locs = null,        .module = null,        .resources = null,    };    const table_offset: usize = @intCast(header.section_table_offset);    var table_reader = SliceReader.init(bytes[table_offset..]);    var i: u64 = 0;    while (i < header.section_count) : (i += 1) {        const kind_raw = try table_reader.readU32();        const flags = try table_reader.readU32();        const offset = try table_reader.readU64();        const size = try table_reader.readU64();        _ = flags;        const end_u64 = std.math.add(            u64,            offset,            size,        ) catch return error.InvalidSection;        if (end_u64 > bytes_len_u64) return error.InvalidSection;        const start: usize = @intCast(offset);        const end: usize = @intCast(end_u64);        const slice = bytes[start..end];        switch (kind_raw) {            @backingInt(SectionKind.strings) => {                if (sections.strings != null) return error.DuplicateSection;                sections.strings = slice;            },            @backingInt(SectionKind.dialects) => {                if (sections.dialects != null) return error.DuplicateSection;                sections.dialects = slice;            },            @backingInt(SectionKind.types) => {                if (sections.types != null) return error.DuplicateSection;                sections.types = slice;            },            @backingInt(SectionKind.attributes) => {                if (sections.attrs != null) return error.DuplicateSection;                sections.attrs = slice;            },            @backingInt(SectionKind.locations) => {                if (sections.locs != null) return error.DuplicateSection;                sections.locs = slice;            },            @backingInt(SectionKind.module) => {                if (sections.module != null) return error.DuplicateSection;                sections.module = slice;            },            @backingInt(SectionKind.resources) => {                if (sections.resources != null) return error.DuplicateSection;                sections.resources = slice;            },            else => {},        }    }    return sections;}
Called byCallsbytecode.FlatModuleDecoderinitbytecodedecodeModulebytecodedecodeTablesbytecode.Readerinitbytecode.ReaderreadU32bytecode.ReaderreadU64private sourcelib.choir.src.bytecode.bytecodereadHeaderprivate sourcelib.choir.src.bytecode.bytecodesectionEntrySizebytecodeinspectSections
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/choir/src/bytecode/root.zig

zig
const bytecode = @import("bytecode.zig");pub const qualification = @import("qualification.zig");pub const image = @import("image.zig");pub const Reader = bytecode.SliceReader;pub const ContainerSections = bytecode.ParsedSections;pub const inspectSections = bytecode.parseSections;pub const TypeKind = bytecode.TypeKind;pub const BuiltinScalarKind = bytecode.BuiltinScalarKind;pub const AttrKind = bytecode.AttrKind;pub const LocationKind = bytecode.LocationKind;pub const format_version = bytecode.format_version;pub const minimum_readable_version = bytecode.minimum_readable_version;pub const maximum_readable_version = bytecode.maximum_readable_version;pub const default_dialect_version = bytecode.default_dialect_version;pub const default_dialect_flags = bytecode.default_dialect_flags;pub const FormatVersionStatus = bytecode.FormatVersionStatus;pub const FormatCompatibility = bytecode.FormatCompatibility;pub const ContainerHeader = bytecode.ContainerHeader;pub const SectionKind = bytecode.SectionKind;pub const DialectEntry = bytecode.DialectEntry;pub const Resource = bytecode.Resource;pub const DecodedTables = bytecode.DecodedTables;pub const DecodedModule = bytecode.DecodedModule;pub const FlatModuleDecoder = bytecode.FlatModuleDecoder;pub const TableBuilder = bytecode.TableBuilder;pub const classifyFormatVersion = bytecode.classifyFormatVersion;pub const inspectHeader = bytecode.inspectHeader;pub const encodeTables = bytecode.encodeTables;pub const encodeModule = bytecode.encodeModule;pub const encodeModuleWithResources = bytecode.encodeModuleWithResources;pub const decodeTables = bytecode.decodeTables;pub const decodeModule = bytecode.decodeModule;

Source: lib/choir/src/root.zig:21

zig
pub const bytecode = @import("bytecode/root.zig");

Complete call list for bytecode.FlatModuleDecoder.init

8 direct calls.

Complete caller list for bytecode.Reader.init

11 direct callers.

Complete caller list for bytecode.Reader.readULEBToUsize

8 direct callers.

Complete caller list for bytecode.TableBuilder.deinit

9 direct callers.

Complete caller list for bytecode.TableBuilder.init

9 direct callers.

Complete caller list for bytecode.decodeModule

12 direct callers.

Complete caller list for bytecode.decodeTables

10 direct callers.

Complete call list for bytecode.encodeModuleWithResources

13 direct calls.

Complete caller list for bytecode.encodeTables

7 direct callers.

Audit

Definitions59
Public names61
Members87
Version26.7.0
Revisiondaab053ee433