feature. See also
. The project being documented here (as the example) is the Zig library itself.
File
Code
const std = @import("../../std.zig");
const Builder = @import("Builder.zig");
const bitcode_writer = @import("bitcode_writer.zig");
const AbbrevOp = bitcode_writer.AbbrevOp;
pub const MAGIC: u32 = 0xdec04342;
const ValueAbbrev = AbbrevOp{ .vbr = 6 };
const ValueArrayAbbrev = AbbrevOp{ .array_vbr = 6 };
const ConstantAbbrev = AbbrevOp{ .vbr = 6 };
const ConstantArrayAbbrev = AbbrevOp{ .array_vbr = 6 };
const MetadataAbbrev = AbbrevOp{ .vbr = 16 };
const MetadataArrayAbbrev = AbbrevOp{ .array_vbr = 16 };
const LineAbbrev = AbbrevOp{ .vbr = 8 };
const ColumnAbbrev = AbbrevOp{ .vbr = 8 };
const BlockAbbrev = AbbrevOp{ .vbr = 6 };
const BlockArrayAbbrev = AbbrevOp{ .array_vbr = 6 };
pub const BlockId = enum(u5) {
BLOCKINFO = 0,
MODULE = FIRST_APPLICATION,
PARAMATTR,
PARAMATTR_GROUP,
CONSTANTS,
FUNCTION,
IDENTIFICATION,
VALUE_SYMTAB,
METADATA,
METADATA_ATTACHMENT,
TYPE,
USELIST,
MODULE_STRTAB,
GLOBALVAL_SUMMARY,
OPERAND_BUNDLE_TAGS,
METADATA_KIND,
STRTAB,
FULL_LTO_GLOBALVAL_SUMMARY,
SYMTAB,
SYNC_SCOPE_NAMES,
pub const FIRST_APPLICATION = 8;
};
pub const FixedMetadataKind = enum(u6) {
dbg = 0,
prof = 2,
//range = 4,
//@"tbaa.struct" = 5,
//@"invariant.load" = 6,
//@"alias.scope" = 7,
//@"noalias" = 8,
//nontemporal = 9,
//@"llvm.mem.parallel_loop_access" = 10,
//nonnull = 11,
//dereferenceable = 12,
//dereferenceable_or_null = 13,
//@"make.implicit" = 14,
unpredictable = 15,
//@"align" = 17,
//@"llvm.loop" = 18,
//type = 19,
//section_prefix = 20,
//absolute_symbol = 21,
//associated = 22,
//callees = 23,
//irr_loop = 24,
//@"llvm.access.group" = 25,
//callback = 26,
//@"llvm.preserve.access.index" = 27,
//vcall_visibility = 28,
//noundef = 29,
//annotation = 30,
//nosanitize = 31,
//func_sanitize = 32,
//exclude = 33,
//memprof = 34,
//callsite = 35,
//kcfi_type = 36,
//pcsections = 37,
//DIAssignID = 38,
//@"coro.outside.frame" = 39,
};
pub const BlockInfoBlock = struct {
pub const id: BlockId = .BLOCKINFO;
pub const set_block_id = 1;
pub const abbrevs = [_]type{};
};
pub const ModuleBlock = struct {
pub const id: BlockId = .MODULE;
pub const abbrevs = [_]type{
ModuleBlock.Version,
ModuleBlock.String,
ModuleBlock.Variable,
ModuleBlock.Function,
ModuleBlock.Alias,
};
pub const Code = enum(u5) {
VERSION = 1,
TRIPLE = 2,
DATALAYOUT = 3,
ASM = 4,
SECTIONNAME = 5,
DEPLIB = 6,
GLOBALVAR = 7,
FUNCTION = 8,
ALIAS_OLD = 9,
GCNAME = 11,
COMDAT = 12,
VSTOFFSET = 13,
ALIAS = 14,
METADATA_VALUES_UNUSED = 15,
SOURCE_FILENAME = 16,
HASH = 17,
IFUNC = 18,
};
pub const Version = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.Code.VERSION) },
.{ .literal = 2 },
};
};
pub const String = struct {
pub const ops = [_]AbbrevOp{
.{ .vbr = 4 },
.{ .array_fixed = 8 },
};
code: u16,
string: []const u8,
};
pub const Variable = struct {
const AddrSpaceAndIsConst = packed struct {
is_const: bool,
one: u1 = 1,
addr_space: Builder.AddrSpace,
};
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.Code.GLOBALVAR) },
.{ .vbr = 16 },
.{ .vbr = 16 },
.{ .fixed_runtime = Builder.Type },
.{ .fixed = @bitSizeOf(AddrSpaceAndIsConst) },
ConstantAbbrev,
.{ .fixed = @bitSizeOf(Builder.Linkage) },
.{ .fixed = @bitSizeOf(Builder.Alignment) },
.{ .vbr = 16 },
.{ .fixed = @bitSizeOf(Builder.Visibility) },
.{ .fixed = @bitSizeOf(Builder.ThreadLocal) },
.{ .fixed = @bitSizeOf(Builder.UnnamedAddr) },
.{ .fixed = @bitSizeOf(Builder.ExternallyInitialized) },
.{ .fixed = @bitSizeOf(Builder.DllStorageClass) },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .fixed = @bitSizeOf(Builder.Preemption) },
};
strtab_offset: usize,
strtab_size: usize,
type_index: Builder.Type,
is_const: AddrSpaceAndIsConst,
initid: u32,
linkage: Builder.Linkage,
alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)),
section: usize,
visibility: Builder.Visibility,
thread_local: Builder.ThreadLocal,
unnamed_addr: Builder.UnnamedAddr,
externally_initialized: Builder.ExternallyInitialized,
dllstorageclass: Builder.DllStorageClass,
preemption: Builder.Preemption,
};
pub const Function = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.Code.FUNCTION) },
.{ .vbr = 16 },
.{ .vbr = 16 },
.{ .fixed_runtime = Builder.Type },
.{ .fixed = @bitSizeOf(Builder.CallConv) },
.{ .fixed = 1 },
.{ .fixed = @bitSizeOf(Builder.Linkage) },
.{ .vbr = 16 },
.{ .fixed = @bitSizeOf(Builder.Alignment) },
.{ .vbr = 16 },
.{ .fixed = @bitSizeOf(Builder.Visibility) },
.{ .literal = 0 },
.{ .fixed = @bitSizeOf(Builder.UnnamedAddr) },
.{ .literal = 0 },
.{ .fixed = @bitSizeOf(Builder.DllStorageClass) },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .fixed = @bitSizeOf(Builder.Preemption) },
.{ .fixed = @bitSizeOf(Builder.AddrSpace) },
};
strtab_offset: usize,
strtab_size: usize,
type_index: Builder.Type,
call_conv: Builder.CallConv,
is_proto: bool,
linkage: Builder.Linkage,
paramattr: usize,
alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)),
section: usize,
visibility: Builder.Visibility,
unnamed_addr: Builder.UnnamedAddr,
dllstorageclass: Builder.DllStorageClass,
preemption: Builder.Preemption,
addr_space: Builder.AddrSpace,
};
pub const Alias = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.Code.ALIAS) },
.{ .vbr = 16 },
.{ .vbr = 16 },
.{ .fixed_runtime = Builder.Type },
.{ .fixed = @bitSizeOf(Builder.AddrSpace) },
ConstantAbbrev,
.{ .fixed = @bitSizeOf(Builder.Linkage) },
.{ .fixed = @bitSizeOf(Builder.Visibility) },
.{ .fixed = @bitSizeOf(Builder.DllStorageClass) },
.{ .fixed = @bitSizeOf(Builder.ThreadLocal) },
.{ .fixed = @bitSizeOf(Builder.UnnamedAddr) },
.{ .fixed = @bitSizeOf(Builder.Preemption) },
};
strtab_offset: usize,
strtab_size: usize,
type_index: Builder.Type,
addr_space: Builder.AddrSpace,
aliasee: u32,
linkage: Builder.Linkage,
visibility: Builder.Visibility,
dllstorageclass: Builder.DllStorageClass,
thread_local: Builder.ThreadLocal,
unnamed_addr: Builder.UnnamedAddr,
preemption: Builder.Preemption,
};
pub const ParamattrBlock = struct {
pub const id: BlockId = .PARAMATTR;
pub const abbrevs = [_]type{
ModuleBlock.ParamattrBlock.Entry,
};
pub const Code = enum(u2) {
ENTRY_OLD = 1,
ENTRY = 2,
};
pub const Entry = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ParamattrBlock.Code.ENTRY) },
.{ .array_vbr = 8 },
};
group_indices: []const u64,
};
};
pub const ParamattrGroupBlock = struct {
pub const id: BlockId = .PARAMATTR_GROUP;
pub const abbrevs = [_]type{};
pub const Code = enum(u2) {
CODE_ENTRY = 3,
};
};
pub const ConstantsBlock = struct {
pub const id: BlockId = .CONSTANTS;
pub const abbrevs = [_]type{
ModuleBlock.ConstantsBlock.SetType,
ModuleBlock.ConstantsBlock.Null,
ModuleBlock.ConstantsBlock.Undef,
ModuleBlock.ConstantsBlock.Poison,
ModuleBlock.ConstantsBlock.Integer,
ModuleBlock.ConstantsBlock.Half,
ModuleBlock.ConstantsBlock.Float,
ModuleBlock.ConstantsBlock.Double,
ModuleBlock.ConstantsBlock.Fp80,
ModuleBlock.ConstantsBlock.Fp128,
ModuleBlock.ConstantsBlock.Aggregate,
ModuleBlock.ConstantsBlock.String,
ModuleBlock.ConstantsBlock.CString,
ModuleBlock.ConstantsBlock.Cast,
ModuleBlock.ConstantsBlock.Binary,
ModuleBlock.ConstantsBlock.Cmp,
ModuleBlock.ConstantsBlock.ExtractElement,
ModuleBlock.ConstantsBlock.InsertElement,
ModuleBlock.ConstantsBlock.ShuffleVector,
ModuleBlock.ConstantsBlock.ShuffleVectorEx,
ModuleBlock.ConstantsBlock.BlockAddress,
ModuleBlock.ConstantsBlock.DsoLocalEquivalentOrNoCfi,
};
pub const Code = enum(u6) {
SETTYPE = 1,
NULL = 2,
UNDEF = 3,
INTEGER = 4,
WIDE_INTEGER = 5,
FLOAT = 6,
AGGREGATE = 7,
STRING = 8,
CSTRING = 9,
CE_BINOP = 10,
CE_CAST = 11,
CE_GEP_OLD = 12,
CE_SELECT = 13,
CE_EXTRACTELT = 14,
CE_INSERTELT = 15,
CE_SHUFFLEVEC = 16,
CE_CMP = 17,
INLINEASM_OLD = 18,
CE_SHUFVEC_EX = 19,
CE_INBOUNDS_GEP = 20,
BLOCKADDRESS = 21,
DATA = 22,
INLINEASM_OLD2 = 23,
CE_GEP_WITH_INRANGE_INDEX_OLD = 24,
CE_UNOP = 25,
POISON = 26,
DSO_LOCAL_EQUIVALENT = 27,
INLINEASM_OLD3 = 28,
NO_CFI_VALUE = 29,
INLINEASM = 30,
CE_GEP_WITH_INRANGE = 31,
CE_GEP = 32,
PTRAUTH = 33,
};
pub const SetType = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.SETTYPE) },
.{ .fixed_runtime = Builder.Type },
};
type_id: Builder.Type,
};
pub const Null = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.NULL) },
};
};
pub const Undef = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.UNDEF) },
};
};
pub const Poison = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.POISON) },
};
};
pub const Integer = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.INTEGER) },
.{ .vbr = 16 },
};
value: u64,
};
pub const Half = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.FLOAT) },
.{ .fixed = 16 },
};
value: u16,
};
pub const Float = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.FLOAT) },
.{ .fixed = 32 },
};
value: u32,
};
pub const Double = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.FLOAT) },
.{ .vbr = 6 },
};
value: u64,
};
pub const Fp80 = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.FLOAT) },
.{ .vbr = 6 },
.{ .vbr = 6 },
};
hi: u64,
lo: u16,
};
pub const Fp128 = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.FLOAT) },
.{ .vbr = 6 },
.{ .vbr = 6 },
};
lo: u64,
hi: u64,
};
pub const Aggregate = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.AGGREGATE) },
.{ .array_fixed = 32 },
};
values: []const Builder.Constant,
};
pub const String = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.STRING) },
.{ .array_fixed = 8 },
};
string: []const u8,
};
pub const CString = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.CSTRING) },
.{ .array_fixed = 8 },
};
string: []const u8,
};
pub const Cast = struct {
const CastOpcode = Builder.CastOpcode;
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.CE_CAST) },
.{ .fixed = @bitSizeOf(CastOpcode) },
.{ .fixed_runtime = Builder.Type },
ConstantAbbrev,
};
opcode: CastOpcode,
type_index: Builder.Type,
val: Builder.Constant,
};
pub const Binary = struct {
const BinaryOpcode = Builder.BinaryOpcode;
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.CE_BINOP) },
.{ .fixed = @bitSizeOf(BinaryOpcode) },
ConstantAbbrev,
ConstantAbbrev,
};
opcode: BinaryOpcode,
lhs: Builder.Constant,
rhs: Builder.Constant,
};
pub const Cmp = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.CE_CMP) },
.{ .fixed_runtime = Builder.Type },
ConstantAbbrev,
ConstantAbbrev,
.{ .vbr = 6 },
};
ty: Builder.Type,
lhs: Builder.Constant,
rhs: Builder.Constant,
pred: u32,
};
pub const ExtractElement = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.CE_EXTRACTELT) },
.{ .fixed_runtime = Builder.Type },
ConstantAbbrev,
.{ .fixed_runtime = Builder.Type },
ConstantAbbrev,
};
val_type: Builder.Type,
val: Builder.Constant,
index_type: Builder.Type,
index: Builder.Constant,
};
pub const InsertElement = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.CE_INSERTELT) },
ConstantAbbrev,
ConstantAbbrev,
.{ .fixed_runtime = Builder.Type },
ConstantAbbrev,
};
val: Builder.Constant,
elem: Builder.Constant,
index_type: Builder.Type,
index: Builder.Constant,
};
pub const ShuffleVector = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.CE_SHUFFLEVEC) },
ValueAbbrev,
ValueAbbrev,
ValueAbbrev,
};
lhs: Builder.Constant,
rhs: Builder.Constant,
mask: Builder.Constant,
};
pub const ShuffleVectorEx = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.CE_SHUFVEC_EX) },
.{ .fixed_runtime = Builder.Type },
ValueAbbrev,
ValueAbbrev,
ValueAbbrev,
};
ty: Builder.Type,
lhs: Builder.Constant,
rhs: Builder.Constant,
mask: Builder.Constant,
};
pub const BlockAddress = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.ConstantsBlock.Code.BLOCKADDRESS) },
.{ .fixed_runtime = Builder.Type },
ConstantAbbrev,
BlockAbbrev,
};
type_id: Builder.Type,
function: u32,
block: u32,
};
pub const DsoLocalEquivalentOrNoCfi = struct {
pub const ops = [_]AbbrevOp{
.{ .fixed = 5 },
.{ .fixed_runtime = Builder.Type },
ConstantAbbrev,
};
code: ModuleBlock.ConstantsBlock.Code,
type_id: Builder.Type,
function: u32,
};
};
pub const FunctionBlock = struct {
pub const id: BlockId = .FUNCTION;
pub const abbrevs = [_]type{
ModuleBlock.FunctionBlock.DeclareBlocks,
ModuleBlock.FunctionBlock.Call,
ModuleBlock.FunctionBlock.CallFast,
ModuleBlock.FunctionBlock.FNeg,
ModuleBlock.FunctionBlock.FNegFast,
ModuleBlock.FunctionBlock.Binary,
ModuleBlock.FunctionBlock.BinaryNoWrap,
ModuleBlock.FunctionBlock.BinaryExact,
ModuleBlock.FunctionBlock.BinaryFast,
ModuleBlock.FunctionBlock.Cmp,
ModuleBlock.FunctionBlock.CmpFast,
ModuleBlock.FunctionBlock.Select,
ModuleBlock.FunctionBlock.SelectFast,
ModuleBlock.FunctionBlock.Cast,
ModuleBlock.FunctionBlock.TruncNoWrap,
ModuleBlock.FunctionBlock.Alloca,
ModuleBlock.FunctionBlock.GetElementPtr,
ModuleBlock.FunctionBlock.ExtractValue,
ModuleBlock.FunctionBlock.InsertValue,
ModuleBlock.FunctionBlock.ExtractElement,
ModuleBlock.FunctionBlock.InsertElement,
ModuleBlock.FunctionBlock.ShuffleVector,
ModuleBlock.FunctionBlock.RetVoid,
ModuleBlock.FunctionBlock.Ret,
ModuleBlock.FunctionBlock.Unreachable,
ModuleBlock.FunctionBlock.Load,
ModuleBlock.FunctionBlock.LoadAtomic,
ModuleBlock.FunctionBlock.Store,
ModuleBlock.FunctionBlock.StoreAtomic,
ModuleBlock.FunctionBlock.BrUnconditional,
ModuleBlock.FunctionBlock.BrConditional,
ModuleBlock.FunctionBlock.VaArg,
ModuleBlock.FunctionBlock.AtomicRmw,
ModuleBlock.FunctionBlock.CmpXchg,
ModuleBlock.FunctionBlock.Fence,
ModuleBlock.FunctionBlock.DebugLoc,
ModuleBlock.FunctionBlock.DebugLocAgain,
ModuleBlock.FunctionBlock.ColdOperandBundle,
ModuleBlock.FunctionBlock.IndirectBr,
};
pub const Code = enum(u7) {
DECLAREBLOCKS = 1,
INST_BINOP = 2,
INST_CAST = 3,
INST_GEP_OLD = 4,
INST_SELECT = 5,
INST_EXTRACTELT = 6,
INST_INSERTELT = 7,
INST_SHUFFLEVEC = 8,
INST_CMP = 9,
INST_RET = 10,
INST_BR = 11,
INST_SWITCH = 12,
INST_INVOKE = 13,
INST_UNREACHABLE = 15,
INST_PHI = 16,
INST_ALLOCA = 19,
INST_LOAD = 20,
INST_VAARG = 23,
INST_STORE_OLD = 24,
INST_EXTRACTVAL = 26,
INST_INSERTVAL = 27,
INST_CMP2 = 28,
INST_VSELECT = 29,
INST_INBOUNDS_GEP_OLD = 30,
INST_INDIRECTBR = 31,
DEBUG_LOC_AGAIN = 33,
INST_CALL = 34,
DEBUG_LOC = 35,
INST_FENCE = 36,
INST_CMPXCHG_OLD = 37,
INST_ATOMICRMW_OLD = 38,
INST_RESUME = 39,
INST_LANDINGPAD_OLD = 40,
INST_LOADATOMIC = 41,
INST_STOREATOMIC_OLD = 42,
INST_GEP = 43,
INST_STORE = 44,
INST_STOREATOMIC = 45,
INST_CMPXCHG = 46,
INST_LANDINGPAD = 47,
INST_CLEANUPRET = 48,
INST_CATCHRET = 49,
INST_CATCHPAD = 50,
INST_CLEANUPPAD = 51,
INST_CATCHSWITCH = 52,
OPERAND_BUNDLE = 55,
INST_UNOP = 56,
INST_CALLBR = 57,
INST_FREEZE = 58,
INST_ATOMICRMW = 59,
BLOCKADDR_USERS = 60,
DEBUG_RECORD_VALUE = 61,
DEBUG_RECORD_DECLARE = 62,
DEBUG_RECORD_ASSIGN = 63,
DEBUG_RECORD_VALUE_SIMPLE = 64,
DEBUG_RECORD_LABEL = 65,
};
pub const DeclareBlocks = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.DECLAREBLOCKS) },
.{ .vbr = 8 },
};
num_blocks: usize,
};
pub const Call = struct {
pub const CallType = packed struct(u17) {
tail: bool = false,
call_conv: Builder.CallConv,
reserved: u3 = 0,
must_tail: bool = false,
explicit_type: bool = true,
no_tail: bool = false,
};
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_CALL) },
.{ .fixed_runtime = Builder.FunctionAttributes },
.{ .fixed = @bitSizeOf(CallType) },
.{ .fixed_runtime = Builder.Type },
ValueAbbrev,
ValueArrayAbbrev,
};
attributes: Builder.FunctionAttributes,
call_type: CallType,
type_id: Builder.Type,
callee: Builder.Value,
args: []const Builder.Value,
};
pub const CallFast = struct {
const CallType = packed struct(u18) {
tail: bool = false,
call_conv: Builder.CallConv,
reserved: u3 = 0,
must_tail: bool = false,
explicit_type: bool = true,
no_tail: bool = false,
fast: bool = true,
};
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_CALL) },
.{ .fixed_runtime = Builder.FunctionAttributes },
.{ .fixed = @bitSizeOf(CallType) },
.{ .fixed = @bitSizeOf(Builder.FastMath) },
.{ .fixed_runtime = Builder.Type },
ValueAbbrev,
ValueArrayAbbrev,
};
attributes: Builder.FunctionAttributes,
call_type: CallType,
fast_math: Builder.FastMath,
type_id: Builder.Type,
callee: Builder.Value,
args: []const Builder.Value,
};
pub const FNeg = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_UNOP) },
ValueAbbrev,
.{ .literal = 0 },
};
val: u32,
};
pub const FNegFast = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_UNOP) },
ValueAbbrev,
.{ .literal = 0 },
.{ .fixed = @bitSizeOf(Builder.FastMath) },
};
val: u32,
fast_math: Builder.FastMath,
};
pub const Binary = struct {
const BinaryOpcode = Builder.BinaryOpcode;
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_BINOP) },
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(BinaryOpcode) },
};
lhs: u32,
rhs: u32,
opcode: BinaryOpcode,
};
pub const BinaryNoWrap = struct {
const BinaryOpcode = Builder.BinaryOpcode;
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_BINOP) },
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(BinaryOpcode) },
.{ .fixed = 2 },
};
lhs: u32,
rhs: u32,
opcode: BinaryOpcode,
flags: packed struct(u2) {
no_unsigned_wrap: bool,
no_signed_wrap: bool,
},
};
pub const BinaryExact = struct {
const BinaryOpcode = Builder.BinaryOpcode;
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_BINOP) },
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(BinaryOpcode) },
.{ .literal = 1 },
};
lhs: u32,
rhs: u32,
opcode: BinaryOpcode,
};
pub const BinaryFast = struct {
const BinaryOpcode = Builder.BinaryOpcode;
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_BINOP) },
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(BinaryOpcode) },
.{ .fixed = @bitSizeOf(Builder.FastMath) },
};
lhs: u32,
rhs: u32,
opcode: BinaryOpcode,
fast_math: Builder.FastMath,
};
pub const Cmp = struct {
const CmpPredicate = Builder.CmpPredicate;
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_CMP2) },
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(CmpPredicate) },
};
lhs: u32,
rhs: u32,
pred: CmpPredicate,
};
pub const CmpFast = struct {
const CmpPredicate = Builder.CmpPredicate;
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_CMP2) },
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(CmpPredicate) },
.{ .fixed = @bitSizeOf(Builder.FastMath) },
};
lhs: u32,
rhs: u32,
pred: CmpPredicate,
fast_math: Builder.FastMath,
};
pub const Select = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_VSELECT) },
ValueAbbrev,
ValueAbbrev,
ValueAbbrev,
};
lhs: u32,
rhs: u32,
cond: u32,
};
pub const SelectFast = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_VSELECT) },
ValueAbbrev,
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(Builder.FastMath) },
};
lhs: u32,
rhs: u32,
cond: u32,
fast_math: Builder.FastMath,
};
pub const Cast = struct {
const CastOpcode = Builder.CastOpcode;
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_CAST) },
ValueAbbrev,
.{ .fixed_runtime = Builder.Type },
.{ .fixed = @bitSizeOf(CastOpcode) },
};
val: u32,
type_index: Builder.Type,
opcode: CastOpcode,
};
pub const TruncNoWrap = struct {
pub const Flags = packed struct(u2) {
no_unsigned_wrap: bool,
no_signed_wrap: bool,
};
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_CAST) },
ValueAbbrev,
.{ .fixed_runtime = Builder.Type },
.{ .literal = @backingInt(Builder.CastOpcode.trunc) },
.{ .fixed = @bitSizeOf(Flags) },
};
val: u32,
type_index: Builder.Type,
flags: Flags,
};
pub const Alloca = struct {
pub const Flags = packed struct(u11) {
align_lower: u5,
inalloca: bool,
explicit_type: bool,
swift_error: bool,
align_upper: u3,
};
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_ALLOCA) },
.{ .fixed_runtime = Builder.Type },
.{ .fixed_runtime = Builder.Type },
ValueAbbrev,
.{ .fixed = @bitSizeOf(Flags) },
};
inst_type: Builder.Type,
len_type: Builder.Type,
len_value: u32,
flags: Flags,
};
pub const RetVoid = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_RET) },
};
};
pub const Ret = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_RET) },
ValueAbbrev,
};
val: u32,
};
pub const GetElementPtr = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_GEP) },
.{ .fixed = 1 },
.{ .fixed_runtime = Builder.Type },
ValueAbbrev,
ValueArrayAbbrev,
};
is_inbounds: bool,
type_index: Builder.Type,
base: Builder.Value,
indices: []const Builder.Value,
};
pub const ExtractValue = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_EXTRACTVAL) },
ValueAbbrev,
ValueArrayAbbrev,
};
val: u32,
indices: []const u32,
};
pub const InsertValue = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_INSERTVAL) },
ValueAbbrev,
ValueAbbrev,
ValueArrayAbbrev,
};
val: u32,
elem: u32,
indices: []const u32,
};
pub const ExtractElement = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_EXTRACTELT) },
ValueAbbrev,
ValueAbbrev,
};
val: u32,
index: u32,
};
pub const InsertElement = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_INSERTELT) },
ValueAbbrev,
ValueAbbrev,
ValueAbbrev,
};
val: u32,
elem: u32,
index: u32,
};
pub const ShuffleVector = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_SHUFFLEVEC) },
ValueAbbrev,
ValueAbbrev,
ValueAbbrev,
};
lhs: u32,
rhs: u32,
mask: u32,
};
pub const Unreachable = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_UNREACHABLE) },
};
};
pub const Load = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_LOAD) },
ValueAbbrev,
.{ .fixed_runtime = Builder.Type },
.{ .fixed = @bitSizeOf(Builder.Alignment) },
.{ .fixed = 1 },
};
ptr: u32,
ty: Builder.Type,
alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)),
is_volatile: bool,
};
pub const LoadAtomic = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_LOADATOMIC) },
ValueAbbrev,
.{ .fixed_runtime = Builder.Type },
.{ .fixed = @bitSizeOf(Builder.Alignment) },
.{ .fixed = 1 },
.{ .fixed = @bitSizeOf(Builder.AtomicOrdering) },
.{ .fixed = @bitSizeOf(Builder.SyncScope) },
};
ptr: u32,
ty: Builder.Type,
alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)),
is_volatile: bool,
success_ordering: Builder.AtomicOrdering,
sync_scope: Builder.SyncScope,
};
pub const Store = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_STORE) },
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(Builder.Alignment) },
.{ .fixed = 1 },
};
ptr: u32,
val: u32,
alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)),
is_volatile: bool,
};
pub const StoreAtomic = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_STOREATOMIC) },
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(Builder.Alignment) },
.{ .fixed = 1 },
.{ .fixed = @bitSizeOf(Builder.AtomicOrdering) },
.{ .fixed = @bitSizeOf(Builder.SyncScope) },
};
ptr: u32,
val: u32,
alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)),
is_volatile: bool,
success_ordering: Builder.AtomicOrdering,
sync_scope: Builder.SyncScope,
};
pub const BrUnconditional = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_BR) },
BlockAbbrev,
};
block: u32,
};
pub const BrConditional = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_BR) },
BlockAbbrev,
BlockAbbrev,
BlockAbbrev,
};
then_block: u32,
else_block: u32,
condition: u32,
};
pub const VaArg = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_VAARG) },
.{ .fixed_runtime = Builder.Type },
ValueAbbrev,
.{ .fixed_runtime = Builder.Type },
};
list_type: Builder.Type,
list: u32,
type: Builder.Type,
};
pub const AtomicRmw = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_ATOMICRMW) },
ValueAbbrev,
ValueAbbrev,
.{ .fixed = @bitSizeOf(Builder.Function.Instruction.AtomicRmw.Operation) },
.{ .fixed = 1 },
.{ .fixed = @bitSizeOf(Builder.AtomicOrdering) },
.{ .fixed = @bitSizeOf(Builder.SyncScope) },
.{ .fixed = @bitSizeOf(Builder.Alignment) },
};
ptr: u32,
val: u32,
operation: Builder.Function.Instruction.AtomicRmw.Operation,
is_volatile: bool,
success_ordering: Builder.AtomicOrdering,
sync_scope: Builder.SyncScope,
alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)),
};
pub const CmpXchg = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_CMPXCHG) },
ValueAbbrev,
ValueAbbrev,
ValueAbbrev,
.{ .fixed = 1 },
.{ .fixed = @bitSizeOf(Builder.AtomicOrdering) },
.{ .fixed = @bitSizeOf(Builder.SyncScope) },
.{ .fixed = @bitSizeOf(Builder.AtomicOrdering) },
.{ .fixed = 1 },
.{ .fixed = @bitSizeOf(Builder.Alignment) },
};
ptr: u32,
cmp: u32,
new: u32,
is_volatile: bool,
success_ordering: Builder.AtomicOrdering,
sync_scope: Builder.SyncScope,
failure_ordering: Builder.AtomicOrdering,
is_weak: bool,
alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)),
};
pub const Fence = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_FENCE) },
.{ .fixed = @bitSizeOf(Builder.AtomicOrdering) },
.{ .fixed = @bitSizeOf(Builder.SyncScope) },
};
ordering: Builder.AtomicOrdering,
sync_scope: Builder.SyncScope,
};
pub const DebugLoc = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.DEBUG_LOC) },
LineAbbrev,
ColumnAbbrev,
MetadataAbbrev,
MetadataAbbrev,
.{ .literal = 0 },
};
line: u32,
column: u32,
scope: Builder.Metadata.Optional,
inlined_at: Builder.Metadata.Optional,
};
pub const DebugLocAgain = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.DEBUG_LOC_AGAIN) },
};
};
pub const ColdOperandBundle = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.OPERAND_BUNDLE) },
.{ .literal = 0 },
};
};
pub const IndirectBr = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.Code.INST_INDIRECTBR) },
.{ .fixed_runtime = Builder.Type },
ValueAbbrev,
BlockArrayAbbrev,
};
ty: Builder.Type,
addr: Builder.Value,
targets: []const Builder.Function.Block.Index,
};
pub const ValueSymtabBlock = struct {
pub const id: BlockId = .VALUE_SYMTAB;
pub const abbrevs = [_]type{
ModuleBlock.FunctionBlock.ValueSymtabBlock.BlockEntry,
};
pub const Code = enum(u3) {
ENTRY = 1,
BBENTRY = 2,
FNENTRY = 3,
COMBINED_ENTRY = 5,
};
pub const BlockEntry = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.FunctionBlock.ValueSymtabBlock.Code.BBENTRY) },
ValueAbbrev,
.{ .array_fixed = 8 },
};
value_id: u32,
string: []const u8,
};
};
pub const MetadataBlock = struct {
pub const id: BlockId = .METADATA;
pub const abbrevs = [_]type{
ModuleBlock.FunctionBlock.MetadataBlock.Value,
};
pub const Value = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.VALUE) },
.{ .fixed = 32 },
.{ .fixed = 32 },
};
ty: Builder.Type,
value: Builder.Value,
};
};
pub const MetadataAttachmentBlock = struct {
pub const id: BlockId = .METADATA_ATTACHMENT;
pub const abbrevs = [_]type{
ModuleBlock.FunctionBlock.MetadataAttachmentBlock.AttachmentGlobalSingle,
ModuleBlock.FunctionBlock.MetadataAttachmentBlock.AttachmentInstructionSingle,
};
pub const AttachmentGlobalSingle = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.ATTACHMENT) },
.{ .fixed = 1 },
MetadataAbbrev,
};
kind: FixedMetadataKind,
metadata: Builder.Metadata,
};
pub const AttachmentInstructionSingle = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.ATTACHMENT) },
ValueAbbrev,
.{ .fixed = 5 },
MetadataAbbrev,
};
inst: u32,
kind: FixedMetadataKind,
metadata: Builder.Metadata,
};
};
};
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) {
STRING_OLD = 1,
VALUE = 2,
NODE = 3,
NAME = 4,
DISTINCT_NODE = 5,
KIND = 6,
LOCATION = 7,
OLD_NODE = 8,
OLD_FN_NODE = 9,
NAMED_NODE = 10,
ATTACHMENT = 11,
GENERIC_DEBUG = 12,
SUBRANGE = 13,
ENUMERATOR = 14,
BASIC_TYPE = 15,
FILE = 16,
DERIVED_TYPE = 17,
COMPOSITE_TYPE = 18,
SUBROUTINE_TYPE = 19,
COMPILE_UNIT = 20,
SUBPROGRAM = 21,
LEXICAL_BLOCK = 22,
LEXICAL_BLOCK_FILE = 23,
NAMESPACE = 24,
TEMPLATE_TYPE = 25,
TEMPLATE_VALUE = 26,
GLOBAL_VAR = 27,
LOCAL_VAR = 28,
EXPRESSION = 29,
OBJC_PROPERTY = 30,
IMPORTED_ENTITY = 31,
MODULE = 32,
MACRO = 33,
MACRO_FILE = 34,
STRINGS = 35,
GLOBAL_DECL_ATTACHMENT = 36,
GLOBAL_VAR_EXPR = 37,
INDEX_OFFSET = 38,
INDEX = 39,
LABEL = 40,
STRING_TYPE = 41,
COMMON_BLOCK = 44,
GENERIC_SUBRANGE = 45,
ARG_LIST = 46,
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 },
MetadataAbbrev,
MetadataAbbrev,
.{ .literal = 0 },
.{ .literal = 0 },
};
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 },
.{ .literal = std.dwarf.LANG.C99 },
MetadataAbbrev,
MetadataAbbrev,
.{ .fixed = 1 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 1 },
MetadataAbbrev,
.{ .literal = 0 },
.{ .literal = 0 },
MetadataAbbrev,
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
};
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 },
MetadataAbbrev,
MetadataAbbrev,
MetadataAbbrev,
MetadataAbbrev,
LineAbbrev,
MetadataAbbrev,
LineAbbrev,
.{ .literal = 0 },
.{ .fixed = 32 },
.{ .literal = 0 },
.{ .fixed = 32 },
MetadataAbbrev,
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
};
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 },
MetadataAbbrev,
MetadataAbbrev,
LineAbbrev,
ColumnAbbrev,
};
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 },
LineAbbrev,
ColumnAbbrev,
MetadataAbbrev,
MetadataAbbrev,
.{ .literal = 0 },
};
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 },
.{ .literal = std.dwarf.TAG.base_type },
MetadataAbbrev,
.{ .vbr = 6 },
.{ .literal = 0 },
.{ .vbr = 8 },
.{ .literal = 0 },
};
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 },
.{ .fixed = 32 },
MetadataAbbrev,
MetadataAbbrev,
LineAbbrev,
MetadataAbbrev,
MetadataAbbrev,
.{ .vbr = 6 },
.{ .vbr = 6 },
.{ .literal = 0 },
.{ .fixed = 32 },
MetadataAbbrev,
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
};
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 },
.{ .fixed = 32 },
MetadataAbbrev,
MetadataAbbrev,
LineAbbrev,
MetadataAbbrev,
MetadataAbbrev,
.{ .vbr = 6 },
.{ .vbr = 6 },
.{ .vbr = 6 },
.{ .literal = 0 },
.{ .literal = 0 },
};
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 },
.{ .literal = 0 },
MetadataAbbrev,
.{ .literal = 0 },
};
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) },
.{ .vbr = 6 },
MetadataAbbrev,
.{ .vbr = 16 },
};
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) },
MetadataAbbrev,
MetadataAbbrev,
.{ .literal = 0 },
.{ .literal = 0 },
};
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) },
MetadataArrayAbbrev,
};
elements: []const u32,
};
pub const Node = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.NODE) },
MetadataArrayAbbrev,
};
elements: []const Builder.Metadata.Optional,
};
pub const LocalVar = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.LOCAL_VAR) },
.{ .literal = 0b10 },
MetadataAbbrev,
MetadataAbbrev,
MetadataAbbrev,
LineAbbrev,
MetadataAbbrev,
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
};
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 },
MetadataAbbrev,
MetadataAbbrev,
MetadataAbbrev,
LineAbbrev,
MetadataAbbrev,
.{ .vbr = 4 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
};
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 },
MetadataAbbrev,
MetadataAbbrev,
MetadataAbbrev,
MetadataAbbrev,
LineAbbrev,
MetadataAbbrev,
.{ .fixed = 1 },
.{ .literal = 1 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
.{ .literal = 0 },
};
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 },
MetadataAbbrev,
MetadataAbbrev,
};
variable: Builder.Metadata.Optional,
expression: Builder.Metadata.Optional,
};
pub const Constant = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.VALUE) },
MetadataAbbrev,
MetadataAbbrev,
};
ty: Builder.Type,
constant: Builder.Constant,
};
pub const Name = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.NAME) },
.{ .array_fixed = 8 },
};
name: []const u8,
};
pub const NamedNode = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.NAMED_NODE) },
MetadataArrayAbbrev,
};
elements: []const Builder.Metadata,
};
pub const GlobalDeclAttachment = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.GLOBAL_DECL_ATTACHMENT) },
ValueAbbrev,
.{ .fixed = 1 },
MetadataAbbrev,
};
value: Builder.Constant,
kind: FixedMetadataKind,
metadata: Builder.Metadata,
};
};
pub const TypeBlock = struct {
pub const id: BlockId = .TYPE;
pub const abbrevs = [_]type{
ModuleBlock.TypeBlock.NumEntry,
ModuleBlock.TypeBlock.Simple,
ModuleBlock.TypeBlock.Opaque,
ModuleBlock.TypeBlock.Integer,
ModuleBlock.TypeBlock.StructAnon,
ModuleBlock.TypeBlock.StructNamed,
ModuleBlock.TypeBlock.StructName,
ModuleBlock.TypeBlock.Array,
ModuleBlock.TypeBlock.Vector,
ModuleBlock.TypeBlock.Pointer,
ModuleBlock.TypeBlock.Target,
ModuleBlock.TypeBlock.Function,
};
pub const Code = enum(u5) {
NUMENTRY = 1,
VOID = 2,
FLOAT = 3,
DOUBLE = 4,
LABEL = 5,
OPAQUE = 6,
INTEGER = 7,
POINTER = 8,
FUNCTION_OLD = 9,
HALF = 10,
ARRAY = 11,
VECTOR = 12,
// a late addition, and putting them in the right place breaks
// binary compatibility.
X86_FP80 = 13,
FP128 = 14,
PPC_FP128 = 15,
METADATA = 16,
X86_MMX = 17,
STRUCT_ANON = 18,
STRUCT_NAME = 19,
STRUCT_NAMED = 20,
FUNCTION = 21,
TOKEN = 22,
BFLOAT = 23,
X86_AMX = 24,
OPAQUE_POINTER = 25,
TARGET_TYPE = 26,
};
pub const NumEntry = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.NUMENTRY) },
.{ .fixed = 32 },
};
num: u32,
};
pub const Simple = struct {
pub const ops = [_]AbbrevOp{
.{ .vbr = 4 },
};
code: ModuleBlock.TypeBlock.Code,
};
pub const Opaque = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.OPAQUE) },
.{ .literal = 0 },
};
};
pub const Integer = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.INTEGER) },
.{ .fixed = 28 },
};
width: u28,
};
pub const StructAnon = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.STRUCT_ANON) },
.{ .fixed = 1 },
.{ .array_fixed_runtime = Builder.Type },
};
is_packed: bool,
types: []const Builder.Type,
};
pub const StructNamed = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.STRUCT_NAMED) },
.{ .fixed = 1 },
.{ .array_fixed_runtime = Builder.Type },
};
is_packed: bool,
types: []const Builder.Type,
};
pub const StructName = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.STRUCT_NAME) },
.{ .array_fixed = 8 },
};
string: []const u8,
};
pub const Array = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.ARRAY) },
.{ .vbr = 16 },
.{ .fixed_runtime = Builder.Type },
};
len: u64,
child: Builder.Type,
};
pub const Vector = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.VECTOR) },
.{ .vbr = 16 },
.{ .fixed_runtime = Builder.Type },
};
len: u64,
child: Builder.Type,
};
pub const Pointer = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.OPAQUE_POINTER) },
.{ .vbr = 4 },
};
addr_space: Builder.AddrSpace,
};
pub const Target = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.TARGET_TYPE) },
.{ .vbr = 4 },
.{ .array_fixed_runtime = Builder.Type },
.{ .array_fixed = 32 },
};
num_types: u32,
types: []const Builder.Type,
ints: []const u32,
};
pub const Function = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.TypeBlock.Code.FUNCTION) },
.{ .fixed = 1 },
.{ .fixed_runtime = Builder.Type },
.{ .array_fixed_runtime = Builder.Type },
};
is_vararg: bool,
return_type: Builder.Type,
param_types: []const Builder.Type,
};
};
pub const OperandBundleTagsBlock = struct {
pub const id: BlockId = .OPERAND_BUNDLE_TAGS;
pub const abbrevs = [_]type{
ModuleBlock.OperandBundleTagsBlock.OperandBundleTag,
};
pub const Code = enum(u1) {
OPERAND_BUNDLE_TAG = 1,
};
pub const OperandBundleTag = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.OperandBundleTagsBlock.Code.OPERAND_BUNDLE_TAG) },
.array_char6,
};
tag: []const u8,
};
};
pub const MetadataKindBlock = struct {
pub const id: BlockId = .METADATA_KIND;
pub const abbrevs = [_]type{
ModuleBlock.MetadataKindBlock.Kind,
};
pub const Kind = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(ModuleBlock.MetadataBlock.Code.KIND) },
.{ .vbr = 4 },
.{ .array_fixed = 8 },
};
id: u32,
name: []const u8,
};
};
};
pub const IdentificationBlock = struct {
pub const id: BlockId = .IDENTIFICATION;
pub const abbrevs = [_]type{
IdentificationBlock.Version,
IdentificationBlock.Epoch,
};
pub const Code = enum(u2) {
STRING = 1,
EPOCH = 2,
};
pub const Version = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(IdentificationBlock.Code.STRING) },
.{ .array_fixed = 8 },
};
string: []const u8,
};
pub const Epoch = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(IdentificationBlock.Code.EPOCH) },
.{ .vbr = 6 },
};
epoch: u32,
};
};
pub const StrtabBlock = struct {
pub const id: BlockId = .STRTAB;
pub const abbrevs = [_]type{Blob};
pub const Code = enum(u1) {
BLOB = 1,
};
pub const Blob = struct {
pub const ops = [_]AbbrevOp{
.{ .literal = @backingInt(StrtabBlock.Code.BLOB) },
.blob,
};
blob: []const u8,
};
};