diff --git a/bootstrap/compiler.zig b/bootstrap/compiler.zig index eebf53b..a83a284 100644 --- a/bootstrap/compiler.zig +++ b/bootstrap/compiler.zig @@ -1041,14 +1041,407 @@ fn resolve_value(thread: *Thread, file_index: u32, value: *Value) void { // } } -const Bitcode = struct {}; +const Bitcode = struct { + const Block = struct{ + start_size_index: u32, + previous_code_size: u32, + previous_abbreviations: PinnedArray(*Abbreviation) = .{}, + }; + const BlockId = enum(u8){ + identification = 13, + }; + const Abbreviation = struct{ + operands: PinnedArray(Op) = .{}, + + const Op = struct{ + value: u64, + encoding: Encoding, + is_literal: bool, + + const Encoding = enum(u3) { + fixed = 1, + vbr = 2, + array = 3, + char6 = 4, + blob = 5, + _, + }; + + pub fn get_encoding_data(operand: Op) ?u64 { + return switch (operand.encoding) { + .fixed, .vbr => operand.value, + .array, .char6, .blob => null, + _ => unreachable, + }; + } + }; + + pub fn add_literal(abbreviation: *Abbreviation, value: u64) void { + abbreviation.add_with_encoding_advanced(.{ + .value = value, + .encoding = @enumFromInt(0), + .is_literal = true, + }); + } + + pub fn add_with_encoding(abbreviation: *Abbreviation, data: struct { + encoding: Op.Encoding, + value: u64 = 0, + }) void { + abbreviation.add_with_encoding_advanced(.{ + .value = data.value, + .encoding = data.encoding, + .is_literal = false, + }); + } + + pub fn add_with_encoding_advanced(abbreviation: *Abbreviation, op: Op) void { + _ = abbreviation.operands.append(op); + } + }; + + + const FixedAbbreviationId = enum(u8) { + end_block = 0, + enter_subblock = 1, + define_abbrev = 2, + unabbrev_record = 3, + first_application_abbrev = 4, + }; + + const width = struct { + const block_id = 8; + const code_length = 8; + const block_size = 32; + }; + + const IdentificationCode = enum(u2) { + string = 1, + epoch = 2, + }; + + const Writer = struct { + buffer: PinnedArray(u32) = .{}, + block_scope: PinnedArray(Block) = .{}, + current_abbreviations: PinnedArray(*Abbreviation) = .{}, + abbreviation_buffer: PinnedArray(Abbreviation) = .{}, + current_bit: u32 = 0, + current_value: u32 = 0, + current_codesize: u32 = 2, + + fn get_byte_slice(writer: *Writer) []const u8 { + const final_slice_len = writer.buffer.length * @sizeOf(u32); + const final_slice_ptr: [*]const u8 = @alignCast(@ptrCast(writer.buffer.pointer)); + const final_slice = final_slice_ptr[0..final_slice_len]; + return final_slice; + } + + pub fn write(writer: *Writer) void { + const magic align(4) = [_]u8{ 0x42, 0x43, 0xc0, 0xde }; + writer.append_bytes(&magic); + + writer.write_identification_block(); + } + + fn write_raw(writer: *Writer, value: u32) void { + _ = writer.buffer.append(value); + } + + pub fn append_bytes(writer: *Writer, bytes: []const u8) void { + assert(bytes.len % 4 == 0); + + var slice: []const u32 = undefined; + slice.ptr = @alignCast(@ptrCast(bytes.ptr)); + slice.len = @divExact(bytes.len, @sizeOf(u32)); + + writer.buffer.append_slice(slice); + } + + fn emit(writer: *Writer, value: u32, bit_count: u32) void { + assert(bit_count > 0 and bit_count <= 32); + assert(value & ~(~@as(u32, 0) >> @as(u5, @intCast(32 - bit_count))) == 0); + const shifted = value << @as(u5, @intCast(writer.current_bit)); + writer.current_value |= shifted; + + if (writer.current_bit + bit_count < 32) { + writer.current_bit += bit_count; + } else { + writer.write_raw(writer.current_value); + + if (writer.current_bit != 0) { + writer.current_value = value >> @as(u5, @intCast(32 - writer.current_bit)); + } else { + writer.current_value = 0; + } + + writer.current_bit = (writer.current_bit + bit_count) & 31; + } + } + + fn flush(writer: *Writer) void { + if (writer.current_bit != 0) { + writer.write_raw(writer.current_value); + writer.current_bit = 0; + writer.current_value = 0; + } + } + + fn encode_abbreviation(writer: *Writer, abbreviation: *Abbreviation) void { + writer.emit_code(@intFromEnum(FixedAbbreviationId.define_abbrev)); + writer.emit_vbr(abbreviation.operands.length, 5); + + for (abbreviation.operands.const_slice()) |*operand| { + writer.emit(@intFromBool(operand.is_literal), 1); + if (operand.is_literal) { + writer.emit_vbr64(operand.value, 8); + } else { + writer.emit(@intFromEnum(operand.encoding), 3); + if (operand.get_encoding_data()) |encoding_data| { + writer.emit_vbr64(encoding_data, 5); + } + } + } + } + + fn emit_abbreviation(writer: *Writer, abbreviation: *Abbreviation) u32 { + writer.encode_abbreviation(abbreviation); + _ = writer.current_abbreviations.append(abbreviation); + return writer.current_abbreviations.length - 1 + @intFromEnum(FixedAbbreviationId.first_application_abbrev); + } + + fn emit_abbreviated_literal(writer: *Writer, operand: *Abbreviation.Op, value: u32) void { + _ = writer; // autofix + assert(operand.is_literal); + assert(value == operand.value); + } + + fn write_identification_block(writer: *Writer) void { + writer.enter_subblock(.identification, 5); + + { + const abbreviation = writer.abbreviation_buffer.append(.{}); + abbreviation.add_literal(@intFromEnum(IdentificationCode.string)); + abbreviation.add_with_encoding(.{ .encoding = .array }); + abbreviation.add_with_encoding(.{ .encoding = .char6 }); + const string_abbreviation = writer.emit_abbreviation(abbreviation); + writer.write_string_record(@intFromEnum(IdentificationCode.string), "LLVM17.0.6", string_abbreviation); + } + + { + const abbreviation = writer.abbreviation_buffer.append(.{}); + abbreviation.add_literal(@intFromEnum(IdentificationCode.epoch)); + abbreviation.add_with_encoding_advanced(.{ + .encoding = .vbr, + .value = 6, + .is_literal = false, + }); + const epoch_abbreviation = writer.emit_abbreviation(abbreviation); + const current_epoch = 0; + const values = [1]u32{current_epoch}; + writer.emit_record(u32, @intFromEnum(IdentificationCode.epoch), &values, epoch_abbreviation); + writer.exit_block(); + } + } + + fn exit_block(writer: *Writer) void { + assert(writer.block_scope.length != 0); + + const last = &writer.block_scope.slice()[writer.block_scope.length - 1]; + + writer.emit_code(@intFromEnum(FixedAbbreviationId.end_block)); + writer.flush(); + + const size32 = writer.buffer.length - last.start_size_index - 1; + + writer.buffer.slice()[last.start_size_index] = size32; + + writer.current_codesize = last.previous_code_size; + writer.current_abbreviations = last.previous_abbreviations; + writer.block_scope.length -= 1; + } + + fn is_char6(ch: u8) bool { + return (is_alphabetic(ch) or is_decimal_digit(ch)) or (ch == '.' or ch == '_'); + } + + fn write_string_record(writer: *Writer, code: u32, string: []const u8, abbreviation_to_use: u32) void { + var values = std.BoundedArray(u32, 64){}; + var a = abbreviation_to_use; + for (string) |ch| { + if (a != 0 and !is_char6(ch)) { + a = 0; + } + values.appendAssumeCapacity(ch); + } + writer.emit_record(u32, code, values.constSlice(), a); + } + + fn emit_record(writer: *Writer, comptime T: type, code: u32, values: []const T, abbreviation: u32) void { + if (abbreviation == 0) { + const count: u32 = @intCast(values.len); + + writer.emit_code(@intFromEnum(FixedAbbreviationId.unabbrev_record)); + writer.emit_vbr(code, 6); + writer.emit_vbr(count, 6); + + for (values) |v| { + writer.emit_vbr64(v, 6); + } + } else { + writer.emit_record_with_abbrev(u32, abbreviation, values, null, code); + } + } + + fn emit_record_with_abbrev(writer: *Writer, comptime T: type, abbreviation_int: u32, values: []const T, string: ?[]const u8, code: ?u32) void { + const abbreviation_number = abbreviation_int - @intFromEnum(FixedAbbreviationId.first_application_abbrev); + assert(abbreviation_number < writer.current_abbreviations.length); + const abbreviation = writer.current_abbreviations.slice()[abbreviation_number]; + + writer.emit_code(abbreviation_int); + + const operand_count = abbreviation.operands.length; + var operand_index: u32 = 0; + if (code) |c| { + assert(operand_count > 0); + const operand = &abbreviation.operands.slice()[operand_index]; + operand_index += 1; + + if (operand.is_literal) { + writer.emit_abbreviated_literal(operand, c); + } else { + unreachable; + } + } + + var record_index: u32 = 0; + while (operand_index < operand_count) : (operand_index += 1) { + const operand = &abbreviation.operands.slice()[operand_index]; + + if (operand.is_literal) { + unreachable; + } else if (operand.encoding == .array) { + assert(operand_index + 2 == operand_count); + operand_index += 1; + const elt_enc = &abbreviation.operands.slice()[operand_index]; + if (string) |s| { + _ = s; // autofix + unreachable; + } else { + writer.emit_vbr(@intCast(values.len - record_index), 6); + while (record_index < values.len) : (record_index += 1) { + writer.emit_abbreviated_field(T, elt_enc, values[record_index]); + } + } + } else if (operand.encoding == .blob) { + unreachable; + } else { + assert(record_index < values.len); + writer.emit_abbreviated_field(T, operand, values[record_index]); + record_index += 1; + } + } + assert(record_index == values.len); + } + + fn emit_abbreviated_field(writer: *Writer, comptime T: type, operand: *Abbreviation.Op, value: T) void { + assert(!operand.is_literal); + + switch (operand.encoding) { + else => unreachable, + .fixed => { + unreachable; + }, + .vbr => { + if (operand.get_encoding_data()) |v| { + writer.emit_vbr64(value, @intCast(v)); + } + }, + .char6 => { + const ch6 = encode_char6(@intCast(value)); + writer.emit(ch6, 6); + }, + } + } + + fn encode_char6(ch: u8) u32 { + if (is_lower(ch)) return ch - 'a'; + if (is_upper(ch)) return ch - 'A' + 26; + if (is_decimal_digit(ch)) return ch - '0' + 26 + 26; + if (ch == '.') return 62; + if (ch == '_') return 63; + unreachable; + } + + fn enter_subblock(writer: *Writer, block_id: BlockId, code_length: u32) void { + writer.emit_code(@intFromEnum(FixedAbbreviationId.enter_subblock)); + writer.emit_vbr(@intFromEnum(block_id), width.block_id); + writer.emit_vbr(code_length, width.code_length); + writer.flush(); + + const block_size_index = writer.buffer.length; + const old_code_size = writer.current_codesize; + + writer.write_raw(0); + + writer.current_codesize = code_length; + + const block = writer.block_scope.append(.{ + .start_size_index = block_size_index, + .previous_code_size = old_code_size, + }); + block.previous_abbreviations = writer.current_abbreviations; + writer.current_abbreviations = .{}; + + // getBlockInfo + if (false) { + unreachable; + } + } + + fn emit_code(writer: *Writer, value: u32) void { + writer.emit(value, writer.current_codesize); + } + + fn emit_vbr(writer: *Writer, value: u32, bit_count: u32) void { + assert(bit_count <= 32); + const shifter: u5 = @intCast(bit_count - 1); + const threshold = @as(u32, 1) << shifter; + var v = value; + + while (v >= threshold) : (v >>= shifter) { + const value_to_emit = (v & (threshold - 1)) | threshold; + writer.emit(value_to_emit, bit_count); + } + + writer.emit(v, bit_count); + } + + fn emit_vbr64(writer: *Writer, value: u64, bit_count: u32) void { + assert(bit_count <= 32); + if (@as(u32, @truncate(value)) == value) { + writer.emit_vbr(@truncate(value), bit_count); + } else { + const shifter: u5 = @intCast(bit_count - 1); + const threshold = @as(u32, 1) << shifter; + + var v = value; + while (v >= threshold) : (v >>= shifter) { + const v32: u32 = @truncate(v); + const value_to_emit = (v32 & (threshold - 1)) | threshold; + writer.emit(value_to_emit, bit_count); + } + + writer.emit(@truncate(v), bit_count); + } + } + }; +}; fn write_bitcode() void { - var buffer = PinnedArray(u8){}; - // Magic - const magic = [_]u8{ 0x42, 0x43, 0xc0, 0xde }; - buffer.append_slice(&magic); - const identification_block = [_]u8{ + var writer = Bitcode.Writer{}; + writer.write(); + + const identification_block = .{ 0x35, 0x14, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x62, 0x0c, 0x30, 0x24, @@ -1057,17 +1450,12 @@ fn write_bitcode() void { 0x0b, 0x51, 0x80, 0x4c, 0x01, 0x00, 0x00, 0x00, }; - buffer.append_slice(&identification_block); - // ================== - // MODULE BLOCK START - // ================== - const module_block_start = [_]u8{ + std.testing.expectEqualSlices(u8, &identification_block, writer.get_byte_slice()[4..]) catch unreachable; + + const module_block align(4) = [_]u8{ 0x21, 0x0c, 0x00, 0x00, - 0x1f, 0x01, 0x00, 0x00, + 0xe6, 0x01, 0x00, 0x00, 0x0b, 0x02, 0x21, 0x00, - }; - buffer.append_slice(&module_block_start); - const blockinfo_block = [_]u8{ 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, @@ -1076,45 +1464,169 @@ fn write_bitcode() void { 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, - 0x80, 0x04, 0x45, 0x02, + 0x80, 0x0c, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, - 0x24, 0x10, 0x32, 0x14, + 0x64, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x4b, - 0x0a, 0x32, 0x12, 0x88, + 0x0a, 0x32, 0x32, 0x88, 0x48, 0x70, 0xc4, 0x21, 0x23, 0x44, 0x12, 0x87, 0x8c, 0x10, 0x41, 0x92, 0x02, 0x64, 0xc8, 0x08, 0xb1, 0x14, 0x20, 0x43, 0x46, 0x88, 0x20, 0xc9, - 0x01, 0x32, 0x12, 0x84, + 0x01, 0x32, 0x32, 0x84, 0x18, 0x2a, 0x28, 0x2a, 0x90, 0x31, 0x7c, 0xb0, - 0x5c, 0x91, 0x20, 0xc1, + 0x5c, 0x91, 0x20, 0xc3, 0xc8, 0x00, 0x00, 0x00, - }; - buffer.append_slice(&blockinfo_block); - const typeinfo_block = [_]u8{ 0x89, 0x20, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x22, 0x66, 0x04, 0x10, - 0xb2, 0x42, 0x82, 0x49, + 0xb2, 0x42, 0x82, 0xc9, 0x10, 0x52, 0x42, 0x82, - 0x49, 0x90, 0x71, 0xc2, + 0xc9, 0x90, 0x71, 0xc2, 0x50, 0x48, 0x0a, 0x09, - 0x26, 0x41, 0xc6, 0x05, - 0x42, 0x12, 0x26, 0x08, - 0x82, 0x81, 0x00, 0x00, - 0x1a, 0x21, 0x4c, 0x0e, - 0x13, 0x36, 0xdb, 0xde, - 0x6e, 0xb1, 0xd3, 0xee, - 0xb5, 0xc4, 0x06, 0x81, - 0xa2, 0x24, 0x01, 0x00, - }; - buffer.append_slice(&typeinfo_block); - - const metadata_kind_block = [_]u8{ - 0x00, 0xb1, 0x18, 0x00, + 0x26, 0x43, 0xc6, 0x05, + 0x42, 0x32, 0x26, 0x08, + 0x0a, 0x9a, 0x23, 0x00, + 0x83, 0x32, 0x24, 0x18, + 0x08, 0x18, 0x01, 0x00, + 0x51, 0x18, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, + 0x1b, 0x58, 0x23, 0xf8, + 0xff, 0xff, 0xff, 0xff, + 0x01, 0x70, 0x00, 0x09, + 0x28, 0x03, 0x80, 0x0b, + 0xc2, 0x40, 0x20, 0xcc, + 0x41, 0x1e, 0xc2, 0xa1, + 0x1d, 0xca, 0xa1, 0x0d, + 0xe0, 0xe1, 0x1d, 0xd2, + 0xc1, 0x1d, 0xe8, 0xa1, + 0x1c, 0xe4, 0x01, 0x08, + 0x07, 0x76, 0x60, 0x07, + 0x80, 0x68, 0x87, 0x74, + 0x70, 0x87, 0x36, 0x60, + 0x87, 0x72, 0x38, 0x87, + 0x70, 0x60, 0x87, 0x36, + 0xb0, 0x87, 0x72, 0x18, + 0x07, 0x7a, 0x78, 0x07, + 0x79, 0x68, 0x83, 0x7b, + 0x48, 0x07, 0x72, 0xa0, + 0x07, 0x74, 0x00, 0xe0, + 0x00, 0x20, 0xdc, 0xe1, + 0x1d, 0xda, 0x80, 0x1e, + 0xe4, 0x21, 0x1c, 0xe0, + 0x01, 0x1e, 0xd2, 0xc1, + 0x1d, 0xce, 0xa1, 0x0d, + 0xda, 0x21, 0x1c, 0xe8, + 0x01, 0x1d, 0x00, 0x7a, + 0x90, 0x87, 0x7a, 0x28, + 0x07, 0x80, 0x98, 0x07, + 0x7a, 0x08, 0x87, 0x71, + 0x58, 0x87, 0x36, 0x80, + 0x07, 0x79, 0x78, 0x07, + 0x7a, 0x28, 0x87, 0x71, + 0xa0, 0x87, 0x77, 0x90, + 0x87, 0x36, 0x10, 0x87, + 0x7a, 0x30, 0x07, 0x73, + 0x28, 0x07, 0x79, 0x68, + 0x83, 0x79, 0x48, 0x07, + 0x7d, 0x28, 0x07, 0x00, + 0x0f, 0x00, 0x82, 0x1e, + 0xc2, 0x41, 0x1e, 0xce, + 0xa1, 0x1c, 0xe8, 0xa1, + 0x0d, 0xc6, 0x01, 0x1e, + 0xea, 0x01, 0xc0, 0x07, + 0x3c, 0xb0, 0x83, 0x36, + 0xb0, 0x03, 0x3a, 0x00, + 0x08, 0x7a, 0x08, 0x07, + 0x79, 0x38, 0x87, 0x72, + 0xa0, 0x87, 0x36, 0x30, + 0x87, 0x72, 0x08, 0x07, + 0x7a, 0xa8, 0x07, 0x79, + 0x28, 0x87, 0x79, 0x00, + 0xd6, 0x60, 0x1c, 0xda, + 0xe1, 0x1d, 0xec, 0x81, + 0x0d, 0xd6, 0x60, 0x1c, + 0xf0, 0x01, 0x0f, 0xd8, + 0x60, 0x0d, 0xcc, 0x01, + 0x1f, 0xe6, 0x41, 0x1e, + 0xd8, 0x60, 0x0d, 0xda, + 0xa1, 0x1d, 0xf0, 0x81, + 0x0d, 0xd6, 0x60, 0x1e, + 0xe6, 0xa1, 0x1c, 0xd8, + 0x60, 0x0d, 0xe6, 0x61, + 0x1e, 0xca, 0x41, 0x0e, + 0xd8, 0x60, 0x0d, 0xf0, + 0x01, 0x0f, 0xee, 0x00, + 0x20, 0xe8, 0xa1, 0x1e, + 0xdc, 0xa1, 0x1c, 0xda, + 0x60, 0x1c, 0xe0, 0xa1, + 0x1e, 0x80, 0x73, 0x28, + 0x07, 0x77, 0x28, 0x07, + 0x79, 0x48, 0x87, 0x71, + 0x00, 0x36, 0x10, 0x42, + 0x00, 0x90, 0xc2, 0x06, + 0x62, 0x10, 0x00, 0x52, + 0x00, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, + 0x13, 0x86, 0x40, 0x18, + 0x00, 0x00, 0x00, 0x00, + 0x13, 0x26, 0x7c, 0xc0, + 0x03, 0x3b, 0xf8, 0x05, + 0x3b, 0xa0, 0x83, 0x36, + 0x80, 0x87, 0x71, 0x68, + 0x03, 0x76, 0x48, 0x07, + 0x77, 0xa8, 0x07, 0x7c, + 0x68, 0x83, 0x73, 0x70, + 0x87, 0x7a, 0xd8, 0x60, + 0x0a, 0xe5, 0xd0, 0x06, + 0xed, 0xa0, 0x07, 0xe5, + 0xd0, 0x06, 0xf0, 0x20, + 0x07, 0x77, 0x00, 0x07, + 0x7a, 0x30, 0x07, 0x72, + 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x6d, 0x00, 0x0f, + 0x72, 0x70, 0x07, 0x71, + 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xf0, + 0x20, 0x07, 0x77, 0x20, + 0x07, 0x7a, 0x60, 0x07, + 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x90, + 0x0e, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, + 0xd0, 0x06, 0xe6, 0x80, + 0x07, 0x70, 0xa0, 0x07, + 0x71, 0x20, 0x07, 0x78, + 0xd0, 0x06, 0xee, 0x80, + 0x07, 0x7a, 0x10, 0x07, + 0x76, 0xa0, 0x07, 0x73, + 0x20, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, + 0xb3, 0x10, 0x07, 0x72, + 0x80, 0x07, 0x1a, 0x21, + 0x4c, 0x0e, 0x13, 0x36, + 0xdb, 0xde, 0x6e, 0xb1, + 0xd3, 0xee, 0xf5, 0x90, + 0x0a, 0x20, 0x04, 0x00, + 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x00, 0x02, + 0x90, 0xd8, 0x20, 0x50, + 0x54, 0x3d, 0x00, 0x00, + 0x20, 0x0b, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, + 0x32, 0x1e, 0x98, 0x0c, + 0x19, 0x11, 0x4c, 0x90, + 0x8c, 0x09, 0x26, 0x47, + 0xc6, 0x04, 0x43, 0x4a, + 0x09, 0x14, 0x42, 0x41, + 0x14, 0x41, 0x39, 0x00, + 0xb1, 0x18, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, @@ -1301,10 +1813,57 @@ fn write_bitcode() void { 0x61, 0x1e, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, 0x52, 0x81, 0x14, 0x00, - }; - buffer.append_slice(&metadata_kind_block); - - const operand_bundle_tag = [_]u8{ + 0x79, 0x20, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, + 0x72, 0x1e, 0x48, 0x20, + 0x43, 0x88, 0x0c, 0x19, + 0x09, 0x72, 0x32, 0x48, + 0x20, 0x23, 0x81, 0x8c, + 0x91, 0x91, 0xd1, 0x44, + 0xa0, 0x10, 0x28, 0x64, + 0x3c, 0x31, 0x32, 0x42, + 0x8e, 0x90, 0x21, 0xa3, + 0x68, 0x20, 0xac, 0x00, + 0x94, 0x92, 0x24, 0x47, + 0x03, 0x00, 0x00, 0x00, + 0x63, 0x6c, 0x61, 0x6e, + 0x67, 0x20, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x20, 0x31, 0x37, + 0x2e, 0x30, 0x2e, 0x36, + 0x77, 0x63, 0x68, 0x61, + 0x72, 0x5f, 0x73, 0x69, + 0x7a, 0x65, 0x50, 0x49, + 0x43, 0x20, 0x4c, 0x65, + 0x76, 0x65, 0x6c, 0x50, + 0x49, 0x45, 0x20, 0x4c, + 0x65, 0x76, 0x65, 0x6c, + 0x75, 0x77, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x66, + 0x72, 0x61, 0x6d, 0x65, + 0x2d, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x65, 0x72, + 0x23, 0x08, 0x41, 0x30, + 0x82, 0x10, 0x08, 0x23, + 0x08, 0xc1, 0x30, 0x82, + 0x10, 0x10, 0x23, 0x08, + 0x41, 0x31, 0x43, 0x10, + 0xcc, 0x30, 0x1c, 0x02, + 0x32, 0xc3, 0x90, 0x0c, + 0xca, 0x0c, 0xc3, 0x42, + 0x28, 0x33, 0x0c, 0x4b, + 0xa1, 0xcc, 0x30, 0x2c, + 0x86, 0x22, 0x23, 0x81, + 0x09, 0x4a, 0x85, 0x8d, + 0xcd, 0xae, 0xcd, 0x25, + 0x8d, 0xac, 0xcc, 0x8d, + 0x6e, 0x94, 0x60, 0xc9, + 0x88, 0x8d, 0xcd, 0xae, + 0xcd, 0xa5, 0xed, 0x8d, + 0xac, 0x8e, 0xad, 0xcc, + 0xc5, 0x8c, 0x2d, 0xec, + 0x6c, 0x6e, 0x94, 0x82, + 0x69, 0x9c, 0x07, 0x02, 0xa9, 0x18, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x0b, 0x0a, 0x72, 0x28, @@ -1352,10 +1911,6 @@ fn write_bitcode() void { 0x43, 0x39, 0x8c, 0x03, 0x3d, 0xc8, 0x03, 0x3b, 0x00, 0x00, 0x00, 0x00, - }; - buffer.append_slice(&operand_bundle_tag); - - const value26 = [_]u8{ 0xd1, 0x10, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0xcc, 0x3c, 0xa4, @@ -1364,43 +1919,96 @@ fn write_bitcode() void { 0xa0, 0x83, 0x3c, 0x94, 0x43, 0x38, 0x90, 0xc3, 0x01, 0x00, 0x00, 0x00, - }; - buffer.append_slice(&value26); - const value_symtab = [_]u8{ + 0x61, 0x20, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, + 0x13, 0x04, 0x41, 0x2c, + 0x10, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, + 0x94, 0x11, 0x00, 0x00, + 0x33, 0x11, 0x41, 0x10, + 0x8c, 0xc2, 0x4c, 0x44, + 0x10, 0x04, 0xa3, 0x30, + 0x13, 0x01, 0x04, 0x01, + 0x29, 0x0c, 0x1b, 0x10, + 0x03, 0x31, 0x00, 0xc3, + 0x06, 0x84, 0x60, 0x0c, + 0xc0, 0xb0, 0x01, 0x11, + 0x14, 0x04, 0xb0, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x32, 0x0e, 0x10, 0x22, + 0x84, 0x00, 0xda, 0x03, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }; + writer.append_bytes(&module_block); + + const symtab_block align(4) = .{ + 0x65, 0x0c, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, + 0x12, 0x03, 0x94, 0xf0, + 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - buffer.append_slice(&value_symtab); - - const strtab = [_]u8{ - 0x5d, 0x0c, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, - 0x12, 0x03, 0x94, 0x0f, - 0x31, 0x37, 0x2e, 0x30, - 0x2e, 0x36, 0x6c, 0x6c, - 0x76, 0x6d, 0x2d, 0x6c, - 0x69, 0x6e, 0x6b, 0x00, + 0x70, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, + 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + writer.append_bytes(&symtab_block); - buffer.append_slice(&strtab); - - assert(buffer.length == sample_bitcode.len); + const strtab_block align(4) = .{ + 0x5d, 0x0c, 0x00, 0x00, + 0x0d, 0x00, 0x00, 0x00, + 0x12, 0x03, 0x94, 0x66, + 0x00, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, + 0x31, 0x37, 0x2e, 0x30, + 0x2e, 0x36, 0x78, 0x38, + 0x36, 0x5f, 0x36, 0x34, + 0x2d, 0x70, 0x63, 0x2d, + 0x6c, 0x69, 0x6e, 0x75, + 0x78, 0x2d, 0x67, 0x6e, + 0x75, 0x6c, 0x6c, 0x76, + 0x6d, 0x2d, 0x6c, 0x69, + 0x6e, 0x6b, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }; + writer.append_bytes(&strtab_block); const context = LLVM.Context.create(); - const module = context.parse_bitcode(buffer.slice()) orelse exit(1); + const module = context.parse_bitcode(writer.get_byte_slice()) orelse exit(1); _ = module; // autofix - // + exit(0); } -const sample_bitcode = [_]u8{ - // Magic +const main_bitcode = [_]u8{ 0x42, 0x43, 0xc0, 0xde, - // Start of the identification block 0x35, 0x14, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x62, 0x0c, 0x30, 0x24, @@ -1408,11 +2016,9 @@ const sample_bitcode = [_]u8{ 0xbd, 0xfb, 0xb4, 0xaf, 0x0b, 0x51, 0x80, 0x4c, 0x01, 0x00, 0x00, 0x00, - // It looks like this is the start of the module block 0x21, 0x0c, 0x00, 0x00, - 0x1f, 0x01, 0x00, 0x00, + 0xe6, 0x01, 0x00, 0x00, 0x0b, 0x02, 0x21, 0x00, - // start of the blockinfo block? 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, @@ -1421,40 +2027,169 @@ const sample_bitcode = [_]u8{ 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, - 0x80, 0x04, 0x45, 0x02, + 0x80, 0x0c, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, - 0x24, 0x10, 0x32, 0x14, + 0x64, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x4b, - 0x0a, 0x32, 0x12, 0x88, + 0x0a, 0x32, 0x32, 0x88, 0x48, 0x70, 0xc4, 0x21, 0x23, 0x44, 0x12, 0x87, 0x8c, 0x10, 0x41, 0x92, 0x02, 0x64, 0xc8, 0x08, 0xb1, 0x14, 0x20, 0x43, 0x46, 0x88, 0x20, 0xc9, - 0x01, 0x32, 0x12, 0x84, + 0x01, 0x32, 0x32, 0x84, 0x18, 0x2a, 0x28, 0x2a, 0x90, 0x31, 0x7c, 0xb0, - 0x5c, 0x91, 0x20, 0xc1, + 0x5c, 0x91, 0x20, 0xc3, 0xc8, 0x00, 0x00, 0x00, - // type block? 0x89, 0x20, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x22, 0x66, 0x04, 0x10, - 0xb2, 0x42, 0x82, 0x49, + 0xb2, 0x42, 0x82, 0xc9, 0x10, 0x52, 0x42, 0x82, - 0x49, 0x90, 0x71, 0xc2, + 0xc9, 0x90, 0x71, 0xc2, 0x50, 0x48, 0x0a, 0x09, - 0x26, 0x41, 0xc6, 0x05, - 0x42, 0x12, 0x26, 0x08, - 0x82, 0x81, 0x00, 0x00, - 0x1a, 0x21, 0x4c, 0x0e, - 0x13, 0x36, 0xdb, 0xde, - 0x6e, 0xb1, 0xd3, 0xee, - 0xb5, 0xc4, 0x06, 0x81, - 0xa2, 0x24, 0x01, 0x00, - // metadata kind block? - 0x00, 0xb1, 0x18, 0x00, + 0x26, 0x43, 0xc6, 0x05, + 0x42, 0x32, 0x26, 0x08, + 0x0a, 0x9a, 0x23, 0x00, + 0x83, 0x32, 0x24, 0x18, + 0x08, 0x18, 0x01, 0x00, + 0x51, 0x18, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, + 0x1b, 0x58, 0x23, 0xf8, + 0xff, 0xff, 0xff, 0xff, + 0x01, 0x70, 0x00, 0x09, + 0x28, 0x03, 0x80, 0x0b, + 0xc2, 0x40, 0x20, 0xcc, + 0x41, 0x1e, 0xc2, 0xa1, + 0x1d, 0xca, 0xa1, 0x0d, + 0xe0, 0xe1, 0x1d, 0xd2, + 0xc1, 0x1d, 0xe8, 0xa1, + 0x1c, 0xe4, 0x01, 0x08, + 0x07, 0x76, 0x60, 0x07, + 0x80, 0x68, 0x87, 0x74, + 0x70, 0x87, 0x36, 0x60, + 0x87, 0x72, 0x38, 0x87, + 0x70, 0x60, 0x87, 0x36, + 0xb0, 0x87, 0x72, 0x18, + 0x07, 0x7a, 0x78, 0x07, + 0x79, 0x68, 0x83, 0x7b, + 0x48, 0x07, 0x72, 0xa0, + 0x07, 0x74, 0x00, 0xe0, + 0x00, 0x20, 0xdc, 0xe1, + 0x1d, 0xda, 0x80, 0x1e, + 0xe4, 0x21, 0x1c, 0xe0, + 0x01, 0x1e, 0xd2, 0xc1, + 0x1d, 0xce, 0xa1, 0x0d, + 0xda, 0x21, 0x1c, 0xe8, + 0x01, 0x1d, 0x00, 0x7a, + 0x90, 0x87, 0x7a, 0x28, + 0x07, 0x80, 0x98, 0x07, + 0x7a, 0x08, 0x87, 0x71, + 0x58, 0x87, 0x36, 0x80, + 0x07, 0x79, 0x78, 0x07, + 0x7a, 0x28, 0x87, 0x71, + 0xa0, 0x87, 0x77, 0x90, + 0x87, 0x36, 0x10, 0x87, + 0x7a, 0x30, 0x07, 0x73, + 0x28, 0x07, 0x79, 0x68, + 0x83, 0x79, 0x48, 0x07, + 0x7d, 0x28, 0x07, 0x00, + 0x0f, 0x00, 0x82, 0x1e, + 0xc2, 0x41, 0x1e, 0xce, + 0xa1, 0x1c, 0xe8, 0xa1, + 0x0d, 0xc6, 0x01, 0x1e, + 0xea, 0x01, 0xc0, 0x07, + 0x3c, 0xb0, 0x83, 0x36, + 0xb0, 0x03, 0x3a, 0x00, + 0x08, 0x7a, 0x08, 0x07, + 0x79, 0x38, 0x87, 0x72, + 0xa0, 0x87, 0x36, 0x30, + 0x87, 0x72, 0x08, 0x07, + 0x7a, 0xa8, 0x07, 0x79, + 0x28, 0x87, 0x79, 0x00, + 0xd6, 0x60, 0x1c, 0xda, + 0xe1, 0x1d, 0xec, 0x81, + 0x0d, 0xd6, 0x60, 0x1c, + 0xf0, 0x01, 0x0f, 0xd8, + 0x60, 0x0d, 0xcc, 0x01, + 0x1f, 0xe6, 0x41, 0x1e, + 0xd8, 0x60, 0x0d, 0xda, + 0xa1, 0x1d, 0xf0, 0x81, + 0x0d, 0xd6, 0x60, 0x1e, + 0xe6, 0xa1, 0x1c, 0xd8, + 0x60, 0x0d, 0xe6, 0x61, + 0x1e, 0xca, 0x41, 0x0e, + 0xd8, 0x60, 0x0d, 0xf0, + 0x01, 0x0f, 0xee, 0x00, + 0x20, 0xe8, 0xa1, 0x1e, + 0xdc, 0xa1, 0x1c, 0xda, + 0x60, 0x1c, 0xe0, 0xa1, + 0x1e, 0x80, 0x73, 0x28, + 0x07, 0x77, 0x28, 0x07, + 0x79, 0x48, 0x87, 0x71, + 0x00, 0x36, 0x10, 0x42, + 0x00, 0x90, 0xc2, 0x06, + 0x62, 0x10, 0x00, 0x52, + 0x00, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, + 0x13, 0x86, 0x40, 0x18, + 0x00, 0x00, 0x00, 0x00, + 0x13, 0x26, 0x7c, 0xc0, + 0x03, 0x3b, 0xf8, 0x05, + 0x3b, 0xa0, 0x83, 0x36, + 0x80, 0x87, 0x71, 0x68, + 0x03, 0x76, 0x48, 0x07, + 0x77, 0xa8, 0x07, 0x7c, + 0x68, 0x83, 0x73, 0x70, + 0x87, 0x7a, 0xd8, 0x60, + 0x0a, 0xe5, 0xd0, 0x06, + 0xed, 0xa0, 0x07, 0xe5, + 0xd0, 0x06, 0xf0, 0x20, + 0x07, 0x77, 0x00, 0x07, + 0x7a, 0x30, 0x07, 0x72, + 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x6d, 0x00, 0x0f, + 0x72, 0x70, 0x07, 0x71, + 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xf0, + 0x20, 0x07, 0x77, 0x20, + 0x07, 0x7a, 0x60, 0x07, + 0x74, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x6d, 0x90, + 0x0e, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, + 0xd0, 0x06, 0xe6, 0x80, + 0x07, 0x70, 0xa0, 0x07, + 0x71, 0x20, 0x07, 0x78, + 0xd0, 0x06, 0xee, 0x80, + 0x07, 0x7a, 0x10, 0x07, + 0x76, 0xa0, 0x07, 0x73, + 0x20, 0x07, 0x7a, 0x60, + 0x07, 0x74, 0xd0, 0x06, + 0xb3, 0x10, 0x07, 0x72, + 0x80, 0x07, 0x1a, 0x21, + 0x4c, 0x0e, 0x13, 0x36, + 0xdb, 0xde, 0x6e, 0xb1, + 0xd3, 0xee, 0xf5, 0x90, + 0x0a, 0x20, 0x04, 0x00, + 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x00, 0x02, + 0x90, 0xd8, 0x20, 0x50, + 0x54, 0x3d, 0x00, 0x00, + 0x20, 0x0b, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, + 0x32, 0x1e, 0x98, 0x0c, + 0x19, 0x11, 0x4c, 0x90, + 0x8c, 0x09, 0x26, 0x47, + 0xc6, 0x04, 0x43, 0x4a, + 0x09, 0x14, 0x42, 0x41, + 0x14, 0x41, 0x39, 0x00, + 0xb1, 0x18, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, @@ -1641,7 +2376,57 @@ const sample_bitcode = [_]u8{ 0x61, 0x1e, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, 0x52, 0x81, 0x14, 0x00, - // operand bundle tags block? + 0x79, 0x20, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, + 0x72, 0x1e, 0x48, 0x20, + 0x43, 0x88, 0x0c, 0x19, + 0x09, 0x72, 0x32, 0x48, + 0x20, 0x23, 0x81, 0x8c, + 0x91, 0x91, 0xd1, 0x44, + 0xa0, 0x10, 0x28, 0x64, + 0x3c, 0x31, 0x32, 0x42, + 0x8e, 0x90, 0x21, 0xa3, + 0x68, 0x20, 0xac, 0x00, + 0x94, 0x92, 0x24, 0x47, + 0x03, 0x00, 0x00, 0x00, + 0x63, 0x6c, 0x61, 0x6e, + 0x67, 0x20, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x20, 0x31, 0x37, + 0x2e, 0x30, 0x2e, 0x36, + 0x77, 0x63, 0x68, 0x61, + 0x72, 0x5f, 0x73, 0x69, + 0x7a, 0x65, 0x50, 0x49, + 0x43, 0x20, 0x4c, 0x65, + 0x76, 0x65, 0x6c, 0x50, + 0x49, 0x45, 0x20, 0x4c, + 0x65, 0x76, 0x65, 0x6c, + 0x75, 0x77, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x66, + 0x72, 0x61, 0x6d, 0x65, + 0x2d, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x65, 0x72, + 0x23, 0x08, 0x41, 0x30, + 0x82, 0x10, 0x08, 0x23, + 0x08, 0xc1, 0x30, 0x82, + 0x10, 0x10, 0x23, 0x08, + 0x41, 0x31, 0x43, 0x10, + 0xcc, 0x30, 0x1c, 0x02, + 0x32, 0xc3, 0x90, 0x0c, + 0xca, 0x0c, 0xc3, 0x42, + 0x28, 0x33, 0x0c, 0x4b, + 0xa1, 0xcc, 0x30, 0x2c, + 0x86, 0x22, 0x23, 0x81, + 0x09, 0x4a, 0x85, 0x8d, + 0xcd, 0xae, 0xcd, 0x25, + 0x8d, 0xac, 0xcc, 0x8d, + 0x6e, 0x94, 0x60, 0xc9, + 0x88, 0x8d, 0xcd, 0xae, + 0xcd, 0xa5, 0xed, 0x8d, + 0xac, 0x8e, 0xad, 0xcc, + 0xc5, 0x8c, 0x2d, 0xec, + 0x6c, 0x6e, 0x94, 0x82, + 0x69, 0x9c, 0x07, 0x02, 0xa9, 0x18, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x0b, 0x0a, 0x72, 0x28, @@ -1689,7 +2474,6 @@ const sample_bitcode = [_]u8{ 0x43, 0x39, 0x8c, 0x03, 0x3d, 0xc8, 0x03, 0x3b, 0x00, 0x00, 0x00, 0x00, - // Unknown block 26? 0xd1, 0x10, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0xcc, 0x3c, 0xa4, @@ -1698,20 +2482,75 @@ const sample_bitcode = [_]u8{ 0xa0, 0x83, 0x3c, 0x94, 0x43, 0x38, 0x90, 0xc3, 0x01, 0x00, 0x00, 0x00, - // Value symtab block? + 0x61, 0x20, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, + 0x13, 0x04, 0x41, 0x2c, + 0x10, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, + 0x94, 0x11, 0x00, 0x00, + 0x33, 0x11, 0x41, 0x10, + 0x8c, 0xc2, 0x4c, 0x44, + 0x10, 0x04, 0xa3, 0x30, + 0x13, 0x01, 0x04, 0x01, + 0x29, 0x0c, 0x1b, 0x10, + 0x03, 0x31, 0x00, 0xc3, + 0x06, 0x84, 0x60, 0x0c, + 0xc0, 0xb0, 0x01, 0x11, + 0x14, 0x04, 0xb0, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x32, 0x0e, 0x10, 0x22, + 0x84, 0x00, 0xda, 0x03, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x65, 0x0c, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, + 0x12, 0x03, 0x94, 0xf0, + 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // Start of the strtab block + 0x70, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, + 0x00, 0x24, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x5d, 0x0c, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, - 0x12, 0x03, 0x94, 0x0f, + 0x0d, 0x00, 0x00, 0x00, + 0x12, 0x03, 0x94, 0x66, + 0x00, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x31, 0x37, 0x2e, 0x30, - 0x2e, 0x36, 0x6c, 0x6c, - 0x76, 0x6d, 0x2d, 0x6c, - 0x69, 0x6e, 0x6b, 0x00, + 0x2e, 0x36, 0x78, 0x38, + 0x36, 0x5f, 0x36, 0x34, + 0x2d, 0x70, 0x63, 0x2d, + 0x6c, 0x69, 0x6e, 0x75, + 0x78, 0x2d, 0x67, 0x6e, + 0x75, 0x6c, 0x6c, 0x76, + 0x6d, 0x2d, 0x6c, 0x69, + 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; @@ -1917,7 +2756,7 @@ fn thread_callback(thread_index: u32) void { }, .llvm_codegen_thread_module => { if (thread.functions.length > 0) { - // const bytes = library.read_file(instance.arena, std.fs.cwd(), "/home/david/empty.ll"); + // const bytes = library.read_file(instance.arena, std.fs.cwd(), "/home/david/main.ll"); // for (bytes, 0..) |b, i| { // if (i % 4 == 0) { // std.debug.print("\n ", .{});