x86_64: use ZON for encodings

This commit is contained in:
mlugg
2025-02-02 17:05:06 +00:00
committed by Matthew Lugg
parent de8a1211c1
commit e0a955afb3
4 changed files with 2620 additions and 2629 deletions

View File

@ -559,7 +559,7 @@ set(ZIG_STAGE2_SOURCES
src/arch/x86_64/abi.zig
src/arch/x86_64/bits.zig
src/arch/x86_64/encoder.zig
src/arch/x86_64/encodings.zig
src/arch/x86_64/encodings.zon
src/clang.zig
src/clang_options.zig
src/clang_options_data.zig

View File

@ -1015,11 +1015,14 @@ fn estimateInstructionLength(prefix: Prefix, encoding: Encoding, ops: []const Op
const mnemonic_to_encodings_map = init: {
@setEvalBranchQuota(5_800);
const ModrmExt = u3;
const Entry = struct { Mnemonic, OpEn, []const Op, []const u8, ModrmExt, Mode, Feature };
const encodings: []const Entry = @import("encodings.zon");
const mnemonic_count = @typeInfo(Mnemonic).@"enum".fields.len;
var mnemonic_map: [mnemonic_count][]Data = @splat(&.{});
const encodings = @import("encodings.zig");
for (encodings.table) |entry| mnemonic_map[@intFromEnum(entry[0])].len += 1;
var data_storage: [encodings.table.len]Data = undefined;
for (encodings) |entry| mnemonic_map[@intFromEnum(entry[0])].len += 1;
var data_storage: [encodings.len]Data = undefined;
var storage_i: usize = 0;
for (&mnemonic_map) |*value| {
value.ptr = data_storage[storage_i..].ptr;
@ -1028,7 +1031,7 @@ const mnemonic_to_encodings_map = init: {
var mnemonic_i: [mnemonic_count]usize = @splat(0);
const ops_len = @typeInfo(std.meta.FieldType(Data, .ops)).array.len;
const opc_len = @typeInfo(std.meta.FieldType(Data, .opc)).array.len;
for (encodings.table) |entry| {
for (encodings) |entry| {
const i = &mnemonic_i[@intFromEnum(entry[0])];
mnemonic_map[@intFromEnum(entry[0])][i.*] = .{
.op_en = entry[1],

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff