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: [numentries]
NUMENTRY = 1,
// Type Codes
/// VOID
VOID = 2,
/// FLOAT
FLOAT = 3,
/// DOUBLE
DOUBLE = 4,
/// LABEL
LABEL = 5,
/// OPAQUE
OPAQUE = 6,
/// INTEGER: [width]
INTEGER = 7,
/// POINTER: [pointee type]
POINTER = 8,
/// FUNCTION: [vararg, attrid, retty, paramty x N]
FUNCTION_OLD = 9,
/// HALF
HALF = 10,
/// ARRAY: [numelts, eltty]
ARRAY = 11,
/// VECTOR: [numelts, eltty]
VECTOR = 12,
// These are not with the other floating point types because they're
// a late addition, and putting them in the right place breaks
// binary compatibility.
/// X86 LONG DOUBLE
X86_FP80 = 13,
/// LONG DOUBLE (112 bit mantissa)
FP128 = 14,
/// PPC LONG DOUBLE (2 doubles)
PPC_FP128 = 15,
/// METADATA
METADATA = 16,
/// X86 MMX
X86_MMX = 17,
/// STRUCT_ANON: [ispacked, eltty x N]
STRUCT_ANON = 18,
/// STRUCT_NAME: [strchr x N]
STRUCT_NAME = 19,
/// STRUCT_NAMED: [ispacked, eltty x N]
STRUCT_NAMED = 20,
/// FUNCTION: [vararg, retty, paramty x N]
FUNCTION = 21,
/// TOKEN
TOKEN = 22,
/// BRAIN FLOATING POINT
BFLOAT = 23,
/// X86 AMX
X86_AMX = 24,
/// OPAQUE_POINTER: [addrspace]
OPAQUE_POINTER = 25,
/// TARGET_TYPE
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,
};
}
TYPE blocks have codes for each type primitive they use.