pub const MetadataBlock = struct {
pub const id: BlockId = .METADATA;
pub const abbrevs = [_]type{
ModuleBlock.MetadataBlock.Strings,
ModuleBlock.MetadataBlock.File,
ModuleBlock.MetadataBlock.CompileUnit,
ModuleBlock.MetadataBlock.Subprogram,
ModuleBlock.MetadataBlock.LexicalBlock,
ModuleBlock.MetadataBlock.Location,
ModuleBlock.MetadataBlock.BasicType,
ModuleBlock.MetadataBlock.CompositeType,
ModuleBlock.MetadataBlock.DerivedType,
ModuleBlock.MetadataBlock.SubroutineType,
ModuleBlock.MetadataBlock.Enumerator,
ModuleBlock.MetadataBlock.Subrange,
ModuleBlock.MetadataBlock.Expression,
ModuleBlock.MetadataBlock.Node,
ModuleBlock.MetadataBlock.LocalVar,
ModuleBlock.MetadataBlock.Parameter,
ModuleBlock.MetadataBlock.GlobalVar,
ModuleBlock.MetadataBlock.GlobalVarExpression,
ModuleBlock.MetadataBlock.Constant,
ModuleBlock.MetadataBlock.Name,
ModuleBlock.MetadataBlock.NamedNode,
ModuleBlock.MetadataBlock.GlobalDeclAttachment,
};
pub const Code = enum(u6) {
/// MDSTRING: [values]
STRING_OLD = 1,
/// VALUE: [type num, value num]
VALUE = 2,
/// NODE: [n x md num]
NODE = 3,
/// STRING: [values]
NAME = 4,
/// DISTINCT_NODE: [n x md num]
DISTINCT_NODE = 5,
/// [n x [id, name]]
KIND = 6,
/// [distinct, line, col, scope, inlined-at?]
LOCATION = 7,
/// OLD_NODE: [n x (type num, value num)]
OLD_NODE = 8,
/// OLD_FN_NODE: [n x (type num, value num)]
OLD_FN_NODE = 9,
/// NAMED_NODE: [n x mdnodes]
NAMED_NODE = 10,
/// [m x [value, [n x [id, mdnode]]]
ATTACHMENT = 11,
/// [distinct, tag, vers, header, n x md num]
GENERIC_DEBUG = 12,
/// [distinct, count, lo]
SUBRANGE = 13,
/// [isUnsigned|distinct, value, name]
ENUMERATOR = 14,
/// [distinct, tag, name, size, align, enc]
BASIC_TYPE = 15,
/// [distinct, filename, directory, checksumkind, checksum]
FILE = 16,
/// [distinct, ...]
DERIVED_TYPE = 17,
/// [distinct, ...]
COMPOSITE_TYPE = 18,
/// [distinct, flags, types, cc]
SUBROUTINE_TYPE = 19,
/// [distinct, ...]
COMPILE_UNIT = 20,
/// [distinct, ...]
SUBPROGRAM = 21,
/// [distinct, scope, file, line, column]
LEXICAL_BLOCK = 22,
///[distinct, scope, file, discriminator]
LEXICAL_BLOCK_FILE = 23,
/// [distinct, scope, file, name, line, exportSymbols]
NAMESPACE = 24,
/// [distinct, scope, name, type, ...]
TEMPLATE_TYPE = 25,
/// [distinct, scope, name, type, value, ...]
TEMPLATE_VALUE = 26,
/// [distinct, ...]
GLOBAL_VAR = 27,
/// [distinct, ...]
LOCAL_VAR = 28,
/// [distinct, n x element]
EXPRESSION = 29,
/// [distinct, name, file, line, ...]
OBJC_PROPERTY = 30,
/// [distinct, tag, scope, entity, line, name]
IMPORTED_ENTITY = 31,
/// [distinct, scope, name, ...]
MODULE = 32,
/// [distinct, macinfo, line, name, value]
MACRO = 33,
/// [distinct, macinfo, line, file, ...]
MACRO_FILE = 34,
/// [count, offset] blob([lengths][chars])
STRINGS = 35,
/// [valueid, n x [id, mdnode]]
GLOBAL_DECL_ATTACHMENT = 36,
/// [distinct, var, expr]
GLOBAL_VAR_EXPR = 37,
/// [offset]
INDEX_OFFSET = 38,
/// [bitpos]
INDEX = 39,
/// [distinct, scope, name, file, line]
LABEL = 40,
/// [distinct, name, size, align,...]
STRING_TYPE = 41,
/// [distinct, scope, name, variable,...]
COMMON_BLOCK = 44,
/// [distinct, count, lo, up, stride]
GENERIC_SUBRANGE = 45,
/// [n x [type num, value num]]
ARG_LIST = 46,
/// [distinct, ...]
ASSIGN_ID = 47,
};
pub const Strings = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.STRINGS) },
.{ .vbr = 6 },
.{ .vbr = 6 },
.blob,
};
num_strings: u32,
strings_offset: u32,
blob: []const u8,
};
pub const File = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.FILE) },
.{ .literal = 0 }, // is distinct
MetadataAbbrev, // filename
MetadataAbbrev, // directory
.{ .literal = 0 }, // checksum
.{ .literal = 0 }, // checksum
};
filename: Builder.Metadata.String.Optional,
directory: Builder.Metadata.String.Optional,
};
pub const CompileUnit = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.COMPILE_UNIT) },
.{ .literal = 1 }, // is distinct
.{ .literal = std.dwarf.LANG.C99 }, // source language
MetadataAbbrev, // file
MetadataAbbrev, // producer
.{ .fixed = 1 }, // isOptimized
.{ .literal = 0 }, // raw flags
.{ .literal = 0 }, // runtime version
.{ .literal = 0 }, // split debug file name
.{ .literal = 1 }, // emission kind
MetadataAbbrev, // enums
.{ .literal = 0 }, // retained types
.{ .literal = 0 }, // subprograms
MetadataAbbrev, // globals
.{ .literal = 0 }, // imported entities
.{ .literal = 0 }, // DWO ID
.{ .literal = 0 }, // macros
.{ .literal = 0 }, // split debug inlining
.{ .literal = 0 }, // debug info profiling
.{ .literal = 0 }, // name table kind
.{ .literal = 0 }, // ranges base address
.{ .literal = 0 }, // raw sysroot
.{ .literal = 0 }, // raw SDK
};
file: Builder.Metadata.Optional,
producer: Builder.Metadata.String.Optional,
is_optimized: bool,
enums: Builder.Metadata.Optional,
globals: Builder.Metadata.Optional,
};
pub const Subprogram = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.SUBPROGRAM) },
.{ .literal = 0b111 }, // is distinct | has sp flags | has flags
MetadataAbbrev, // scope
MetadataAbbrev, // name
MetadataAbbrev, // linkage name
MetadataAbbrev, // file
LineAbbrev, // line
MetadataAbbrev, // type
LineAbbrev, // scope line
.{ .literal = 0 }, // containing type
.{ .fixed = 32 }, // sp flags
.{ .literal = 0 }, // virtual index
.{ .fixed = 32 }, // flags
MetadataAbbrev, // compile unit
.{ .literal = 0 }, // template params
.{ .literal = 0 }, // declaration
.{ .literal = 0 }, // retained nodes
.{ .literal = 0 }, // this adjustment
.{ .literal = 0 }, // thrown types
.{ .literal = 0 }, // annotations
.{ .literal = 0 }, // target function name
};
scope: Builder.Metadata.Optional,
name: Builder.Metadata.String.Optional,
linkage_name: Builder.Metadata.String.Optional,
file: Builder.Metadata.Optional,
line: u32,
ty: Builder.Metadata.Optional,
scope_line: u32,
sp_flags: Builder.Metadata.Subprogram.DISPFlags,
flags: Builder.Metadata.DIFlags,
compile_unit: Builder.Metadata.Optional,
};
pub const LexicalBlock = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.LEXICAL_BLOCK) },
.{ .literal = 0 }, // is distinct
MetadataAbbrev, // scope
MetadataAbbrev, // file
LineAbbrev, // line
ColumnAbbrev, // column
};
scope: Builder.Metadata.Optional,
file: Builder.Metadata.Optional,
line: u32,
column: u32,
};
pub const Location = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.LOCATION) },
.{ .literal = 0 }, // is distinct
LineAbbrev, // line
ColumnAbbrev, // column
MetadataAbbrev, // scope
MetadataAbbrev, // inlined at
.{ .literal = 0 }, // is implicit code
};
line: u32,
column: u32,
scope: Builder.Metadata,
inlined_at: Builder.Metadata.Optional,
};
pub const BasicType = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.BASIC_TYPE) },
.{ .literal = 0 }, // is distinct
.{ .literal = std.dwarf.TAG.base_type }, // tag
MetadataAbbrev, // name
.{ .vbr = 6 }, // size in bits
.{ .literal = 0 }, // align in bits
.{ .vbr = 8 }, // encoding
.{ .literal = 0 }, // flags
};
name: Builder.Metadata.String.Optional,
size_in_bits: u64,
encoding: u32,
};
pub const CompositeType = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.COMPOSITE_TYPE) },
.{ .literal = 0 | 0x2 }, // is distinct | is not used in old type ref
.{ .fixed = 32 }, // tag
MetadataAbbrev, // name
MetadataAbbrev, // file
LineAbbrev, // line
MetadataAbbrev, // scope
MetadataAbbrev, // underlying type
.{ .vbr = 6 }, // size in bits
.{ .vbr = 6 }, // align in bits
.{ .literal = 0 }, // offset in bits
.{ .fixed = 32 }, // flags
MetadataAbbrev, // elements
.{ .literal = 0 }, // runtime lang
.{ .literal = 0 }, // vtable holder
.{ .literal = 0 }, // template params
.{ .literal = 0 }, // raw id
.{ .literal = 0 }, // discriminator
.{ .literal = 0 }, // data location
.{ .literal = 0 }, // associated
.{ .literal = 0 }, // allocated
.{ .literal = 0 }, // rank
.{ .literal = 0 }, // annotations
};
tag: u32,
name: Builder.Metadata.String.Optional,
file: Builder.Metadata.Optional,
line: u32,
scope: Builder.Metadata.Optional,
underlying_type: Builder.Metadata.Optional,
size_in_bits: u64,
align_in_bits: u64,
flags: Builder.Metadata.DIFlags,
elements: Builder.Metadata.Optional,
};
pub const DerivedType = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.DERIVED_TYPE) },
.{ .literal = 0 }, // is distinct
.{ .fixed = 32 }, // tag
MetadataAbbrev, // name
MetadataAbbrev, // file
LineAbbrev, // line
MetadataAbbrev, // scope
MetadataAbbrev, // underlying type
.{ .vbr = 6 }, // size in bits
.{ .vbr = 6 }, // align in bits
.{ .vbr = 6 }, // offset in bits
.{ .literal = 0 }, // flags
.{ .literal = 0 }, // extra data
};
tag: u32,
name: Builder.Metadata.String.Optional,
file: Builder.Metadata.Optional,
line: u32,
scope: Builder.Metadata.Optional,
underlying_type: Builder.Metadata.Optional,
size_in_bits: u64,
align_in_bits: u64,
offset_in_bits: u64,
};
pub const SubroutineType = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.SUBROUTINE_TYPE) },
.{ .literal = 0 | 0x2 }, // is distinct | has no old type refs
.{ .literal = 0 }, // flags
MetadataAbbrev, // types
.{ .literal = 0 }, // cc
};
types: Builder.Metadata.Optional,
};
pub const Enumerator = struct {
pub const Flags = packed struct(u3) {
distinct: bool = false,
unsigned: bool,
bigint: bool = true,
};
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.ENUMERATOR) },
.{ .fixed = @bitSizeOf(Flags) }, // flags
.{ .vbr = 6 }, // bit width
MetadataAbbrev, // name
.{ .vbr = 16 }, // integer value
};
flags: Flags,
bit_width: u32,
name: Builder.Metadata.String.Optional,
value: u64,
};
pub const Subrange = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.SUBRANGE) },
.{ .literal = 0 | (2 << 1) }, // is distinct | version
MetadataAbbrev, // count
MetadataAbbrev, // lower bound
.{ .literal = 0 }, // upper bound
.{ .literal = 0 }, // stride
};
count: Builder.Metadata.Optional,
lower_bound: Builder.Metadata.Optional,
};
pub const Expression = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.EXPRESSION) },
.{ .literal = 0 | (3 << 1) }, // is distinct | version
MetadataArrayAbbrev, // elements
};
elements: []const u32,
};
pub const Node = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.NODE) },
MetadataArrayAbbrev, // elements
};
elements: []const Builder.Metadata.Optional,
};
pub const LocalVar = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.LOCAL_VAR) },
.{ .literal = 0b10 }, // is distinct | has alignment
MetadataAbbrev, // scope
MetadataAbbrev, // name
MetadataAbbrev, // file
LineAbbrev, // line
MetadataAbbrev, // type
.{ .literal = 0 }, // arg
.{ .literal = 0 }, // flags
.{ .literal = 0 }, // align bits
.{ .literal = 0 }, // annotations
};
scope: Builder.Metadata.Optional,
name: Builder.Metadata.String.Optional,
file: Builder.Metadata.Optional,
line: u32,
ty: Builder.Metadata.Optional,
};
pub const Parameter = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.LOCAL_VAR) },
.{ .literal = 0b10 }, // is distinct | has alignment
MetadataAbbrev, // scope
MetadataAbbrev, // name
MetadataAbbrev, // file
LineAbbrev, // line
MetadataAbbrev, // type
.{ .vbr = 4 }, // arg
.{ .literal = 0 }, // flags
.{ .literal = 0 }, // align bits
.{ .literal = 0 }, // annotations
};
scope: Builder.Metadata.Optional,
name: Builder.Metadata.String.Optional,
file: Builder.Metadata.Optional,
line: u32,
ty: Builder.Metadata.Optional,
arg: u32,
};
pub const GlobalVar = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.GLOBAL_VAR) },
.{ .literal = 0b101 }, // is distinct | version
MetadataAbbrev, // scope
MetadataAbbrev, // name
MetadataAbbrev, // linkage name
MetadataAbbrev, // file
LineAbbrev, // line
MetadataAbbrev, // type
.{ .fixed = 1 }, // local
.{ .literal = 1 }, // defined
.{ .literal = 0 }, // static data members declaration
.{ .literal = 0 }, // template params
.{ .literal = 0 }, // align in bits
.{ .literal = 0 }, // annotations
};
scope: Builder.Metadata.Optional,
name: Builder.Metadata.String.Optional,
linkage_name: Builder.Metadata.String.Optional,
file: Builder.Metadata.Optional,
line: u32,
ty: Builder.Metadata.Optional,
local: bool,
};
pub const GlobalVarExpression = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.GLOBAL_VAR_EXPR) },
.{ .literal = 0 }, // is distinct
MetadataAbbrev, // variable
MetadataAbbrev, // expression
};
variable: Builder.Metadata.Optional,
expression: Builder.Metadata.Optional,
};
pub const Constant = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.VALUE) },
MetadataAbbrev, // type
MetadataAbbrev, // value
};
ty: Builder.Type,
constant: Builder.Constant,
};
pub const Name = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.NAME) },
.{ .array_fixed = 8 }, // name
};
name: []const u8,
};
pub const NamedNode = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.NAMED_NODE) },
MetadataArrayAbbrev, // elements
};
elements: []const Builder.Metadata,
};
pub const GlobalDeclAttachment = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.GLOBAL_DECL_ATTACHMENT) },
ValueAbbrev, // value id
.{ .fixed = 1 }, // kind
MetadataAbbrev, // elements
};
value: Builder.Constant,
kind: FixedMetadataKind,
metadata: Builder.Metadata,
};
}