Better str8_fmt_ktl_buf (using simd)

This commit is contained in:
ed
2026-09-08 20:45:57 -04:00
parent 749a712ceb
commit b9b1ed460a
8 changed files with 387 additions and 296 deletions
+46 -55
View File
@@ -1,4 +1,5 @@
#include "duffle/dsl.h"
#include "duffle/asm.h"
#include "duffle/analysis.h"
#include "duffle/math.h"
#include "duffle/encoding.h"
@@ -274,9 +275,7 @@ x8616_decode_table_generate(X8616_DecodeGen* gen, FArena_R info_scratch) {
}
#ifndef X8616_DECODE_TABLE_OUTPUT
# define X8616_DECODE_TABLE_OUTPUT "./code/8086/gen/decoder_table.h"
#endif
#define X8616_DECODE_TABLE_OUTPUT "./code/8086/gen/decoder_table.h"
enum {
INFO_MEMORY_SIZE = kilo(64),
@@ -318,54 +317,51 @@ I_ Str8 str8_from_u4_opt(U4 num, Opt_str8_from_u4 o) { if (o.radix == 0) {o.radi
#define code_str8(...) slit8(stringify(__VA_ARGS__))
internal void
x8616_decode_gen_emit_plan(Str8Gen_R out, X8616_DecodePlan const* plan) {
defer_rewind(smem.scratch.top)
{
Str8 template = code_str8(
\t{
<flags>, <op>, <encoding_flags>, <width>,
{ <operands[0]> , <operands[1]> }, <operand_count>,
<payload>, <prefix_kind>,
<d_shift>, <w_shift>, <s_shift>, <v_shift>, <z_shift>, <reg_shift>, <sr_shift>,
{ <mod_rm.bits>, <mod_rm.mask> },
{ <post_opcode.bits>, <post_opcode.mask> },
},\n
);
KTL_Slot_Str8 tbl[] = {
#define dec(value) str8_from_u4(value, .radix = 10, .min_digits = 1)
#define hex_u1(value) str8_from_u4(value, .radix = 16, .min_digits = 2)
#define hex_u2(value) str8_from_u4(value, .radix = 16, .min_digits = 4)
#define entry(key,value) { ktl_str8_key(key), value }
entry("flags", hex_u2(plan->flags)),
entry("op", hex_u1(plan->op)),
entry("encoding_flags", hex_u1(plan->encoding_flags)),
entry("width", hex_u1(plan->width)),
entry("operands[0]", hex_u1(plan->operands[0])),
entry("operands[1]", hex_u1(plan->operands[1])),
entry("operand_count", dec(plan->operand_count)),
entry("payload", dec(plan->payload)),
entry("prefix_kind", dec(plan->prefix_kind)),
entry("d_shift", dec(plan->d_shift)),
entry("w_shift", dec(plan->w_shift)),
entry("s_shift", dec(plan->s_shift)),
entry("v_shift", dec(plan->v_shift)),
entry("z_shift", dec(plan->z_shift)),
entry("reg_shift", dec(plan->reg_shift)),
entry("sr_shift", dec(plan->sr_shift)),
entry("mod_rm.bits", hex_u1(plan->mod_rm.bits)),
entry("mod_rm.mask", hex_u1(plan->mod_rm.mask)),
entry("post_opcode.bits", hex_u1(plan->post_opcode.bits)),
entry("post_opcode.mask", hex_u1(plan->post_opcode.mask)),
#undef dec
#undef hex
#undef entry
};
str8gen_append_fmt(out, template, ktl_str8_from_arr(tbl));
}
}
x8616_decode_gen_emit_plan(Str8Gen_R out, X8616_DecodePlan_R plan) { defer_rewind(smem.scratch.top) {
Str8 template = code_str8(
\t{
<flags>, <op>, <encoding_flags>, <width>,
{<operands[0]>, <operands[1]>}, <operand_count>,
<payload>, <prefix_kind>,
<d_shift>, <w_shift>, <s_shift>, <v_shift>, <z_shift>, <reg_shift>, <sr_shift>,
{<mod_rm.bits>, <mod_rm.mask>},
{<post_opcode.bits>, <post_opcode.mask>},
},\n
);
KTL_Slot_Str8 tbl[] = {
#define dec(value) str8_from_u4(value, .radix = 10, .min_digits = 1)
#define hex_u1(value) str8_from_u4(value, .radix = 16, .min_digits = 2)
#define hex_u2(value) str8_from_u4(value, .radix = 16, .min_digits = 4)
#define entry(key,value) { ktl_str8_key(key), value }
entry("flags", hex_u2(plan->flags)),
entry("op", hex_u1(plan->op)),
entry("encoding_flags", hex_u1(plan->encoding_flags)),
entry("width", hex_u1(plan->width)),
entry("operands[0]", hex_u1(plan->operands[0])),
entry("operands[1]", hex_u1(plan->operands[1])),
entry("operand_count", dec(plan->operand_count)),
entry("payload", dec(plan->payload)),
entry("prefix_kind", dec(plan->prefix_kind)),
entry("d_shift", dec(plan->d_shift)),
entry("w_shift", dec(plan->w_shift)),
entry("s_shift", dec(plan->s_shift)),
entry("v_shift", dec(plan->v_shift)),
entry("z_shift", dec(plan->z_shift)),
entry("reg_shift", dec(plan->reg_shift)),
entry("sr_shift", dec(plan->sr_shift)),
entry("mod_rm.bits", hex_u1(plan->mod_rm.bits)),
entry("mod_rm.mask", hex_u1(plan->mod_rm.mask)),
entry("post_opcode.bits", hex_u1(plan->post_opcode.bits)),
entry("post_opcode.mask", hex_u1(plan->post_opcode.mask)),
#undef dec
#undef hex
#undef entry
};
str8gen_append_fmt(out, template, ktl_str8_from_arr(tbl));
}}
internal Str8
x8616_decode_gen_emit(Str8Gen_R out, X8616_DecodeGen const* gen) {
x8616_decode_gen_emit(Str8Gen_R out, X8616_DecodeGen_R gen) {
str8gen_append_str8(out, slit8(
"// Generated from encoder_table.h. Do not hand-edit.\n"
"// Plan 0 is the all-zero nil/invalid plan.\n\n"
@@ -397,17 +393,13 @@ x8616_decode_gen_emit(Str8Gen_R out, X8616_DecodeGen const* gen) {
return str8(out->ptr, out->len);
}
CLANG_OPTIMIZE_DISABLE
int
main(void) {
FArena info_scratch = farena_make(slice_ut_arr(smem.info));
X8616_DecodeGenInfo gen_info = x8616_decode_table_generate(& smem.gen, & info_scratch);
if (gen_info.msgs.error_count) { ms_exit_process(1); return 1; }
Str8Gen output = {
.ptr = C_(UTF8*, smem.text),
.cap = S_(smem.text),
};
Str8Gen output = str8gen_make(slice_ut_arr(smem.text));
Str8 generated = x8616_decode_gen_emit(& output, & smem.gen);
FArena file_scratch = farena_make(slice_ut_arr(smem.file));
@@ -418,4 +410,3 @@ main(void) {
ms_exit_process(0);
return 0;
}
CLANG_OPTIMIZE_ENABLE
+132 -132
View File
@@ -3,138 +3,138 @@
RO_ global X8616_DecodePlan x8616_decode_plans[132] =
{
{ 0x0000, 0x00, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x020d, 0x02, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0209, 0x02, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, },
{ 0x0088, 0x02, 0x00, 0x00, { 0x03 , 0x07 }, 2, 1, 0, 0, 3, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x000c, 0x02, 0x00, 0x00, { 0x06 , 0x0a }, 2, 4, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0205, 0x02, 0x00, 0x02, { 0x01 , 0x04 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x20 }, { 0x00, 0x00 }, },
{ 0x0201, 0x0b, 0x00, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x30, 0x38 }, { 0x00, 0x00 }, },
{ 0x0080, 0x0b, 0x00, 0x02, { 0x03 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0100, 0x0b, 0x00, 0x02, { 0x05 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0201, 0x0c, 0x00, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, },
{ 0x0080, 0x0c, 0x00, 0x02, { 0x03 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0100, 0x0c, 0x00, 0x02, { 0x05 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0209, 0x0d, 0x00, 0x00, { 0x02 , 0x01 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0080, 0x0d, 0x00, 0x02, { 0x06 , 0x03 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0008, 0x0e, 0x00, 0x00, { 0x06 , 0x08 }, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0008, 0x0e, 0x00, 0x00, { 0x06 , 0x0e }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0008, 0x0f, 0x00, 0x00, { 0x08 , 0x06 }, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0008, 0x0f, 0x00, 0x00, { 0x0e , 0x06 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x10, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0201, 0x11, 0x00, 0x02, { 0x02 , 0x01 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0201, 0x12, 0x00, 0x02, { 0x02 , 0x01 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0201, 0x13, 0x00, 0x02, { 0x02 , 0x01 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x14, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x15, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x16, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x17, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x020d, 0x03, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0219, 0x03, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, },
{ 0x0008, 0x03, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x020d, 0x04, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0209, 0x04, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x08, 0x38 }, { 0x00, 0x00 }, },
{ 0x0008, 0x04, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x020d, 0x05, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0219, 0x05, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x10, 0x38 }, { 0x00, 0x00 }, },
{ 0x0008, 0x05, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x020d, 0x06, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0219, 0x06, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x18, 0x38 }, { 0x00, 0x00 }, },
{ 0x0008, 0x06, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x020d, 0x07, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0209, 0x07, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x20, 0x38 }, { 0x00, 0x00 }, },
{ 0x0008, 0x07, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x020d, 0x08, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0219, 0x08, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x28, 0x38 }, { 0x00, 0x00 }, },
{ 0x0008, 0x08, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x020d, 0x09, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0209, 0x09, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x30, 0x38 }, { 0x00, 0x00 }, },
{ 0x0008, 0x09, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x020d, 0x0a, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0219, 0x0a, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x38, 0x38 }, { 0x00, 0x00 }, },
{ 0x0008, 0x0a, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0209, 0x18, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, },
{ 0x0080, 0x18, 0x00, 0x02, { 0x03 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x19, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x1a, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0209, 0x1b, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x08, 0x38 }, { 0x00, 0x00 }, },
{ 0x0080, 0x1b, 0x00, 0x02, { 0x03 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0209, 0x1c, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x18, 0x38 }, { 0x00, 0x00 }, },
{ 0x0209, 0x1f, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x20, 0x38 }, { 0x00, 0x00 }, },
{ 0x0209, 0x20, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x28, 0x38 }, { 0x00, 0x00 }, },
{ 0x0209, 0x22, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x30, 0x38 }, { 0x00, 0x00 }, },
{ 0x0209, 0x23, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x38, 0x38 }, { 0x00, 0x00 }, },
{ 0x0209, 0x27, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x10, 0x38 }, { 0x00, 0x00 }, },
{ 0x0000, 0x1d, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x1e, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0002, 0x21, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x0a, 0xff }, },
{ 0x0002, 0x24, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x0a, 0xff }, },
{ 0x0000, 0x25, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x26, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0229, 0x2b, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, },
{ 0x0229, 0x2c, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x08, 0x38 }, { 0x00, 0x00 }, },
{ 0x0229, 0x2d, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x10, 0x38 }, { 0x00, 0x00 }, },
{ 0x0229, 0x2e, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x18, 0x38 }, { 0x00, 0x00 }, },
{ 0x0229, 0x28, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x20, 0x38 }, { 0x00, 0x00 }, },
{ 0x0229, 0x29, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x28, 0x38 }, { 0x00, 0x00 }, },
{ 0x0229, 0x2a, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x38, 0x38 }, { 0x00, 0x00 }, },
{ 0x0209, 0x2f, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0209, 0x2f, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, },
{ 0x0008, 0x2f, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0440, 0x30, 0x02, 0x00, { 0x00 , 0x00 }, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0008, 0x31, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0008, 0x32, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0008, 0x33, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0008, 0x34, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0008, 0x35, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0400, 0x5b, 0x02, 0x00, { 0x00 , 0x00 }, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0500, 0x5c, 0x02, 0x00, { 0x00 , 0x00 }, 0, 0, 3, 0, 0, 0, 0, 0, 0, 3, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x36, 0x00, 0x00, { 0x0c , 0x00 }, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0201, 0x36, 0x00, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x10, 0x38 }, { 0x00, 0x00 }, },
{ 0x0000, 0x36, 0x01, 0x00, { 0x0d , 0x00 }, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0201, 0x36, 0x01, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x18, 0x38 }, { 0x00, 0x00 }, },
{ 0x0000, 0x37, 0x00, 0x00, { 0x0c , 0x00 }, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x37, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0201, 0x37, 0x00, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x20, 0x38 }, { 0x00, 0x00 }, },
{ 0x0000, 0x37, 0x01, 0x00, { 0x0d , 0x00 }, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0201, 0x37, 0x01, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x28, 0x38 }, { 0x00, 0x00 }, },
{ 0x0000, 0x38, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x38, 0x00, 0x00, { 0x09 , 0x00 }, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x39, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x39, 0x00, 0x00, { 0x09 , 0x00 }, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x40, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x48, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x3d, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x45, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x3a, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x42, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x3e, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x46, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x41, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x49, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x3f, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x47, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x3b, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x43, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x3c, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x44, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x4c, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x4b, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x4a, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x4d, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x4e, 0x00, 0x00, { 0x08 , 0x00 }, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x4f, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x50, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x51, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x52, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x53, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x54, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x55, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x56, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x57, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x58, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x59, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x5a, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, },
{ 0x0000, 0x00, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x020d, 0x02, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0209, 0x02, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x38}, {0x00, 0x00}, },
{ 0x0088, 0x02, 0x00, 0x00, {0x03, 0x07}, 2, 1, 0, 0, 3, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x000c, 0x02, 0x00, 0x00, {0x06, 0x0a}, 2, 4, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0205, 0x02, 0x00, 0x02, {0x01, 0x04}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x20}, {0x00, 0x00}, },
{ 0x0201, 0x0b, 0x00, 0x02, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x30, 0x38}, {0x00, 0x00}, },
{ 0x0080, 0x0b, 0x00, 0x02, {0x03, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0100, 0x0b, 0x00, 0x02, {0x05, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0201, 0x0c, 0x00, 0x02, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x38}, {0x00, 0x00}, },
{ 0x0080, 0x0c, 0x00, 0x02, {0x03, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0100, 0x0c, 0x00, 0x02, {0x05, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0209, 0x0d, 0x00, 0x00, {0x02, 0x01}, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0080, 0x0d, 0x00, 0x02, {0x06, 0x03}, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0008, 0x0e, 0x00, 0x00, {0x06, 0x08}, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0008, 0x0e, 0x00, 0x00, {0x06, 0x0e}, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0008, 0x0f, 0x00, 0x00, {0x08, 0x06}, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0008, 0x0f, 0x00, 0x00, {0x0e, 0x06}, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x10, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0201, 0x11, 0x00, 0x02, {0x02, 0x01}, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0201, 0x12, 0x00, 0x02, {0x02, 0x01}, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0201, 0x13, 0x00, 0x02, {0x02, 0x01}, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x14, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x15, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x16, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x17, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x020d, 0x03, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0219, 0x03, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, {0x00, 0x38}, {0x00, 0x00}, },
{ 0x0008, 0x03, 0x00, 0x00, {0x06, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x020d, 0x04, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0209, 0x04, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x08, 0x38}, {0x00, 0x00}, },
{ 0x0008, 0x04, 0x00, 0x00, {0x06, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x020d, 0x05, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0219, 0x05, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, {0x10, 0x38}, {0x00, 0x00}, },
{ 0x0008, 0x05, 0x00, 0x00, {0x06, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x020d, 0x06, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0219, 0x06, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, {0x18, 0x38}, {0x00, 0x00}, },
{ 0x0008, 0x06, 0x00, 0x00, {0x06, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x020d, 0x07, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0209, 0x07, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x20, 0x38}, {0x00, 0x00}, },
{ 0x0008, 0x07, 0x00, 0x00, {0x06, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x020d, 0x08, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0219, 0x08, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, {0x28, 0x38}, {0x00, 0x00}, },
{ 0x0008, 0x08, 0x00, 0x00, {0x06, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x020d, 0x09, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0209, 0x09, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x30, 0x38}, {0x00, 0x00}, },
{ 0x0008, 0x09, 0x00, 0x00, {0x06, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x020d, 0x0a, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0219, 0x0a, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, {0x38, 0x38}, {0x00, 0x00}, },
{ 0x0008, 0x0a, 0x00, 0x00, {0x06, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0209, 0x18, 0x00, 0x00, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x38}, {0x00, 0x00}, },
{ 0x0080, 0x18, 0x00, 0x02, {0x03, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x19, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x1a, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0209, 0x1b, 0x00, 0x00, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x08, 0x38}, {0x00, 0x00}, },
{ 0x0080, 0x1b, 0x00, 0x02, {0x03, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0209, 0x1c, 0x00, 0x00, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x18, 0x38}, {0x00, 0x00}, },
{ 0x0209, 0x1f, 0x00, 0x00, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x20, 0x38}, {0x00, 0x00}, },
{ 0x0209, 0x20, 0x00, 0x00, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x28, 0x38}, {0x00, 0x00}, },
{ 0x0209, 0x22, 0x00, 0x00, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x30, 0x38}, {0x00, 0x00}, },
{ 0x0209, 0x23, 0x00, 0x00, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x38, 0x38}, {0x00, 0x00}, },
{ 0x0209, 0x27, 0x00, 0x00, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x10, 0x38}, {0x00, 0x00}, },
{ 0x0000, 0x1d, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x1e, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0002, 0x21, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x0a, 0xff}, },
{ 0x0002, 0x24, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x0a, 0xff}, },
{ 0x0000, 0x25, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x26, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0229, 0x2b, 0x00, 0x00, {0x01, 0x0f}, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, {0x00, 0x38}, {0x00, 0x00}, },
{ 0x0229, 0x2c, 0x00, 0x00, {0x01, 0x0f}, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, {0x08, 0x38}, {0x00, 0x00}, },
{ 0x0229, 0x2d, 0x00, 0x00, {0x01, 0x0f}, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, {0x10, 0x38}, {0x00, 0x00}, },
{ 0x0229, 0x2e, 0x00, 0x00, {0x01, 0x0f}, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, {0x18, 0x38}, {0x00, 0x00}, },
{ 0x0229, 0x28, 0x00, 0x00, {0x01, 0x0f}, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, {0x20, 0x38}, {0x00, 0x00}, },
{ 0x0229, 0x29, 0x00, 0x00, {0x01, 0x0f}, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, {0x28, 0x38}, {0x00, 0x00}, },
{ 0x0229, 0x2a, 0x00, 0x00, {0x01, 0x0f}, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, {0x38, 0x38}, {0x00, 0x00}, },
{ 0x0209, 0x2f, 0x00, 0x00, {0x01, 0x02}, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0209, 0x2f, 0x00, 0x00, {0x01, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x38}, {0x00, 0x00}, },
{ 0x0008, 0x2f, 0x00, 0x00, {0x06, 0x07}, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0440, 0x30, 0x02, 0x00, {0x00, 0x00}, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0008, 0x31, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0008, 0x32, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0008, 0x33, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0008, 0x34, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0008, 0x35, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0400, 0x5b, 0x02, 0x00, {0x00, 0x00}, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0500, 0x5c, 0x02, 0x00, {0x00, 0x00}, 0, 0, 3, 0, 0, 0, 0, 0, 0, 3, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x36, 0x00, 0x00, {0x0c, 0x00}, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0201, 0x36, 0x00, 0x02, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x10, 0x38}, {0x00, 0x00}, },
{ 0x0000, 0x36, 0x01, 0x00, {0x0d, 0x00}, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0201, 0x36, 0x01, 0x02, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x18, 0x38}, {0x00, 0x00}, },
{ 0x0000, 0x37, 0x00, 0x00, {0x0c, 0x00}, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x37, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0201, 0x37, 0x00, 0x02, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x20, 0x38}, {0x00, 0x00}, },
{ 0x0000, 0x37, 0x01, 0x00, {0x0d, 0x00}, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0201, 0x37, 0x01, 0x02, {0x01, 0x00}, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x28, 0x38}, {0x00, 0x00}, },
{ 0x0000, 0x38, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x38, 0x00, 0x00, {0x09, 0x00}, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x39, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x39, 0x00, 0x00, {0x09, 0x00}, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x40, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x48, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x3d, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x45, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x3a, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x42, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x3e, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x46, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x41, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x49, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x3f, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x47, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x3b, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x43, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x3c, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x44, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x4c, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x4b, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x4a, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x4d, 0x00, 0x00, {0x0b, 0x00}, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x4e, 0x00, 0x00, {0x08, 0x00}, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x4f, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x50, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x51, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x52, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x53, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x54, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x55, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x56, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x57, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x58, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x59, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
{ 0x0000, 0x5a, 0x00, 0x00, {0x00, 0x00}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0x00, 0x00}, {0x00, 0x00}, },
};
RO_ global U2 x8616_decode_dispatch[256] =
+127
View File
@@ -0,0 +1,127 @@
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "dsl.h"
#endif
#define asm_out /* outputs */
#define asm_in /* inputs */
#define asm_clobber /* clobbers */
#define asm_out_r(name) [name] "=r"(name)
#define asm_in_r(name) [name] "r"(name)
#define asm_out_x(name) [name] "=&x"(name) /* XMM, earlyclobber */
#define asm_out_x0(name) [name] "=x"(name) /* XMM, no earlyclobber */
#define asm_in_x(name) [name] "x"(name)
#define x64_r(name) "%[" #name "]"
#define x64_m(name) "(%[" #name "])"
#define x64_xmm(name) "%x[" #name "]"
typedef U8 U8x2 attribute(vector_size(16));
typedef U8 U8x4 attribute(vector_size(32));
typedef U1 U1x16 attribute(vector_size(16));
#define x64_u4_from_byte_hits(dst, src) "pmovmskb " x64_r(src) ", " x64_r(dst) "\n"
#define x64_u4_count_trailing_zeros(dst, src) "tzcntl " x64_r(src) ", " x64_r(dst) "\n"
#define x64_u1x16_repeat_dwords(dst, src, n) "pshufd $" #n ", " x64_r(src) ", " x64_r(dst) "\n"
#define x64_u1x16_load_mem4(dst, src) "movd " x64_r(src) ", " x64_r(dst) "\n"
#define x64_u1x16_load_mem8(dst, src) "movq " x64_m(src) ", " x64_r(dst) "\n"
#define x64_u1x16_load_mem16(dst, src) "movdqu " x64_m(src) ", " x64_r(dst) "\n"
#define x64_u1x16_match_bytes(dst, src) "pcmpeqb " x64_r(src) ", " x64_r(dst) "\n"
#define x64_u8x2_load_u8(dst, src) "vmovq " x64_m(src) ", " x64_r(dst) "\n"
#define x64_u8x2_insert_u8(dst, src, n) "vpinsrq $" #n ", " x64_m(src) ", " x64_r(dst) ", " x64_r(dst) "\n"
#define x64_u8x4_insert_xmm(dst, src, n) "vinserti128 $" #n ", " x64_r(src) ", " x64_r(dst) ", " x64_r(dst) "\n"
#define x64_u8x4_broadcast(dst, src) "vpbroadcastq " x64_r(src) ", " x64_r(dst) "\n"
#define x64_u8x4_match(dst, a, b) "vpcmpeqq " x64_r(b) ", " x64_r(a) ", " x64_r(dst) "\n"
#define x64_u4_from_qword_hits(dst, src) "vmovmskpd " x64_r(src) ", " x64_r(dst) "\n"
I_ U4 count_trailing_zeros_u4(U4 mask) {
U4 n;
asm volatile(
x64_u4_count_trailing_zeros(n, mask)
asm_out : asm_out_r(n)
asm_in : asm_in_r(mask)
);
return n;
}
I_ U1x16 splat_u4_u1x16(U4 b4) {
U1x16 v;
asm volatile(
x64_u1x16_load_mem4 (v, b4)
x64_u1x16_repeat_dwords(v, v, 0)
asm_out : asm_out_x0(v)
asm_in : asm_in_r(b4)
);
return v;
}
I_ U4 mask_eq8_u1x16(U1_R p, U1x16 needle) {
U1x16 chunk;
U4 mask;
asm volatile(
x64_u1x16_load_mem8 (chunk, p)
x64_u1x16_match_bytes(chunk, needle)
x64_u4_from_byte_hits(mask, chunk)
asm_out : asm_out_x(chunk), asm_out_r(mask)
asm_in : asm_in_r(p), asm_in_x(needle)
asm_clobber : "memory"
);
return mask; /* movq zero-fills the high 8 bytes; bits 815 stay 0 */
}
I_ U4 mask_eq16_u1x16(U1_R p, U1x16 needle) {
U1x16 chunk;
U4 mask;
asm volatile(
x64_u1x16_load_mem16 (chunk, p)
x64_u1x16_match_bytes(chunk, needle)
x64_u4_from_byte_hits(mask, chunk)
asm_out : asm_out_x(chunk), asm_out_r(mask)
asm_in : asm_in_r(p), asm_in_x(needle)
asm_clobber : "memory"
);
return mask;
}
I_ U8 find_u1_via_u1x16(U1_R p, U8 len, U1 ch, U1x16 needle) {
U8 i = 0;
while (len - i >= 16) {
U4 mask = mask_eq16_u1x16(p + i, needle);
if (mask) return i + C_(U8, count_trailing_zeros_u4(mask));
i += 16;
}
while (len - i >= 8) {
U4 mask = mask_eq8_u1x16(p + i, needle);
if (mask) return i + C_(U8, count_trailing_zeros_u4(mask));
i += 8;
}
while (i < len) {
if (p[i] == ch) return i;
++ i;
}
return len; /* not found */
}
I_ U4 find_aos_keys_mask_u8x4(U8_R p0, U8_R p1, U8_R p2, U8_R p3, U8 key) {
U8x2 lo, hi;
U8x4 keys, splat, eq;
U4 mask;
asm volatile(
x64_u8x2_load_u8 (lo, p0)
x64_u8x2_insert_u8(lo, p1, 1)
x64_u8x2_load_u8 (hi, p2)
x64_u8x2_insert_u8(hi, p3, 1)
x64_u8x4_insert_xmm(keys, lo, 0)
x64_u8x4_insert_xmm(keys, hi, 1)
x64_u8x4_broadcast(splat, key)
x64_u8x4_match(eq, keys, splat)
x64_u4_from_qword_hits(mask, eq)
asm_out : asm_out_x(lo), asm_out_x(hi), asm_out_x(keys), asm_out_x(splat), asm_out_x(eq), asm_out_r(mask)
asm_in : asm_in_r(p0), asm_in_r(p1), asm_in_r(p2), asm_in_r(p3), asm_in_r(key)
asm_clobber : "memory"
);
return mask;
}
+15 -32
View File
@@ -54,16 +54,19 @@ Standard: c23
#define LP_ static // static data within procedure scope
#define internal static // internal
#define attribute(directive) __attribute__((directive))
#define asm __asm__
#define align_(value) __attribute__((aligned (value))) // for easy alignment
#define C_(type,data) ((type)(data)) // for enforced precedence
#define expect_(x, y) __builtin_expect(x, y) // so compiler knows the common path
#define align_(value) attribute(aligned(value)) // for easy alignment
#define C_(type,data) ((type)(data)) // for enforced precedence
#define expect_(x, y) __builtin_expect(x, y) // so compiler knows the common path
#define cexpr_ __builtin_constant_p
#define I_ internal inline
#define FI_ inline __attribute__((always_inline)) // inline always
#define NI_ internal __attribute__((noinline)) // inline never
#define RO_ __attribute__((section(".rodata"))) // Read only data allocation
#define FI_ inline attribute(always_inline) // inline always
#define NI_ internal attribute(noinline) // inline never
#define RO_ attribute(section(".rodata")) // Read only data allocation
#define T_ typeof //
#define T_same(a,b) _Generic((a), typeof((b)): 1, default: 0)
@@ -262,6 +265,10 @@ FI_ U8 atm_swap_u8(U8_R addr, U8 value){asm volatile("lock xchgq %0,%1":"=r"(val
#pragma endregion Thread Coherence
#pragma region Misc
#define byte_pos(pos) (pos * 8)
#define byte_shift(value,pos) (value << byte_pos(pos))
#define u4_byte_fill(value) byte_shift(value,0) | byte_shift(value,1) | byte_shift(value,2) | byte_shift(value,3)
enum {
Bitmask_3 = 0x00000007,
Bitmask_4 = 0x0000000f,
@@ -270,32 +277,8 @@ enum {
Bitmask_10 = 0x000003ff,
};
typedef Enum_(U4, WeekDay) {
WeekDay_Sun,
WeekDay_Mon,
WeekDay_Tue,
WeekDay_Wed,
WeekDay_Thu,
WeekDay_Fri,
WeekDay_Sat,
WeekDay_Num,
};
typedef Enum_(U4, Month) {
Month_Jan,
Month_Feb,
Month_Mar,
Month_Apr,
Month_May,
Month_Jun,
Month_Jul,
Month_Aug,
Month_Sep,
Month_Oct,
Month_Nov,
Month_Dec,
Month_Num,
};
typedef Enum_(U4,WeekDay){ WeekDay_Sun, WeekDay_Mon, WeekDay_Tue, WeekDay_Wed, WeekDay_Thu, WeekDay_Fri, WeekDay_Sat, WeekDay_Num, };
typedef Enum_(U4,Month) { Month_Jan, Month_Feb, Month_Mar, Month_Apr, Month_May, Month_Jun, Month_Jul, Month_Aug, Month_Sep, Month_Oct, Month_Nov, Month_Dec, Month_Num, };
typedef U8 DenseTime;
+18 -19
View File
@@ -39,8 +39,17 @@ FI_ B4 mem_match (U8 a, U8 b, U8 z) { return mem_compare(a, b, z) == 0; }
#define mem_match_struct(a,b) mem_match(C_(U8,a), C_(U8,b), S_((a)[0]))
#define mem_zero_struct(s) mem_zero(u8_(& s), S_(s))
#pragma region DAG
I_ void mem_push_aligned_typed(U8 start, U8 capacity, U8_R used, U8 amount, U4 alignment, U4 type_width, U8_R out_ptr, U8_R out_len) {
if (amount == 0) { out_ptr[0] = 0; out_len[0] = 0; return; }
U8 desired = amount * (type_width == 0 ? 1 : type_width);
U8 to_commit = align_pow2(desired, alignment ? alignment : MEM_ALIGNMENT_DEFAULT);
U8 ptr = start + used[0];
mem_bump_u8(start, capacity, used, to_commit);
out_ptr[0] = ptr;
out_len[0] = to_commit;
}
#pragma region DAG
#define check_nil(nil, p) ((p) == 0 || (p) == nil)
#define set_nil(nil, p) ((p) = nil)
@@ -59,11 +68,9 @@ FI_ B4 mem_match (U8 a, U8 b, U8 z) { return mem_compare(a, b, z) == 0; }
) \
)
#define sll_queue_push_n(f, l, n, next) sll_queue_push_nz(0, f, l, n, next)
#pragma endregion DAG
#pragma region Slice
typedef unsigned char TSet_(UTF8);
typedef Struct_(Str8) { UTF8* ptr; U8 len; }; typedef Str8 Slice_UTF8;
typedef Struct_(Slice_Str8) { Str8* ptr; U8 len; };
@@ -104,20 +111,9 @@ typedef Slice_(U1);
typedef Slice_(U2);
typedef Slice_(U4);
typedef Slice_(U8);
#pragma endregion Slice
I_ Slice mem_push_aligned_typed(U8 start, U8 capacity, U8_R used, U8 amount, U4 alignment, U4 type_width) {
if (amount == 0) { return (Slice){}; }
U8 desired = amount * (type_width == 0 ? 1 : type_width);
U8 to_commit = align_pow2(desired, alignment ? alignment : MEM_ALIGNMENT_DEFAULT);
U8 ptr = start + used[0];
mem_bump_u8(start, capacity, used, to_commit);
return (Slice){ ptr, to_commit };
}
#pragma region FArena
typedef Opt_(farena) { U8 alignment, type_width; };
typedef Struct_(FArena) { U8 start, capacity, used; };
FI_ void farena_init(FArena_R arena, Slice mem) { assert(arena != nullptr);
@@ -126,8 +122,10 @@ FI_ void farena_init(FArena_R arena, Slice mem) { assert(arena != nullptr);
arena->used = 0;
}
FI_ FArena farena_make(Slice mem) { FArena a; farena_init(& a, mem); return a; }
FI_ Slice farena_push(FArena_R arena, U8 amount, Opt_farena o) {
return mem_push_aligned_typed(arena->start, arena->capacity, & arena->used, amount, o.alignment, o.type_width);
FI_ Slice farena_push(FArena_R arena, U8 amount, Opt_farena o) { Slice res;
mem_push_aligned_typed(arena->start, arena->capacity, & arena->used, amount, o.alignment, o.type_width
, & res.ptr, & res.len);
return res;
}
FI_ void farena_reset (FArena_R arena) { arena->used = 0; }
FI_ void farena_rewind(FArena_R arena, U8 save_point) {
@@ -138,14 +136,15 @@ FI_ U8 farena_save(FArena arena) { return arena.used; }
#define farena_push_(arena, amount, ...) farena_push((arena),(amount),opt_(farena,__VA_ARGS__))
#define farena_push_type(arena, type, ...) C_(type*,farena_push((arena),1, opt_(farena,.type_width=S_(type),__VA_ARGS__)).ptr)
#define farena_push_array(arena, type, amount, ...) (tmpl(Slice,type)){ C_(type*,farena_push((arena),(amount),opt_(farena,.type_width=S_(type),__VA_ARGS__)).ptr),(amount) }
#pragma endregion FArena
#pragma region FStack
#define FStack_(name, type, width) Struct_(name) { U8 top; type arr[width]; }
FI_ Slice fstack_push(Slice mem, U8_R top, U8 amount, Opt_farena o) {
return mem_push_aligned_typed(mem.ptr, mem.len, top, amount, o.alignment, o.type_width);
FI_ Slice fstack_push(Slice mem, U8_R top, U8 amount, Opt_farena o) { Slice res;
mem_push_aligned_typed(mem.ptr, mem.len, top, amount, o.alignment, o.type_width
, & res.ptr, & res.len);
return res;
};
// This is here more for annotation than anything else.
+16 -1
View File
@@ -1,13 +1,13 @@
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "dsl.h"
# include "asm.h"
# include "memory.h"
# include "hashing.h"
# include "analysis.h"
#endif
#pragma region Key Table Linear (KTL)
enum { KT_Slot_value = S_(U8), };
#define KTL_Slot_(type) Struct_(tmpl(KTL_Slot,type)) { \
U8 key; \
@@ -37,4 +37,19 @@ FI_ void ktl_populate_slice_a2_str8(KTL_Str8* kt, Slice_A2_Str8 values) {
#define ktl_str8_key(str) hash64_fnv1a_ret(slice_to_ut(slit8(str)), 0)
#define ktl_str8_from_arr(arr) (KTL_Str8){arr, Array_len(arr)}
FI_ Str8_R ktl_str8_find(KTL_Str8 table, U8 key) {
U8 i = 0;
while (table.len - i >= 4) {
KTL_Slot_Str8_R p = table.ptr + i;
U4 mask = find_aos_keys_mask_u8x4(& p[0].key, & p[1].key, & p[2].key, & p[3].key, key);
if (mask) return & table.ptr[i + C_(U8, count_trailing_zeros_u4(mask))].value;
i += 4;
}
while (i < table.len) {
if (table.ptr[i].key == key) return & table.ptr[i].value;
++ i;
}
assert(false);
return nullptr;
}
#pragma endregion KTL
+29 -57
View File
@@ -6,6 +6,7 @@
# include "hashing.h"
# include "tables.h"
# include "analysis.h"
# include "asm.h"
#endif
// NOTE(rjf): Includes reverses for uppercase and lowercase hex.
@@ -123,8 +124,7 @@ I_ Str8 str8_from_u4_buf(Slice buf, U4 num, U4 radix, U4 min_digits, U4 digit_gr
return result;
}
I_ Str8 str8_fmt_ktl_buf(Slice buffer, KTL_Str8 table, Str8 fmt_template)
{
I_ Str8 str8_fmt_ktl_buf(Slice buffer, KTL_Str8 table, Str8 fmt_template){
slice_assert(buffer);
slice_assert(table);
slice_assert(fmt_template);
@@ -132,68 +132,41 @@ I_ Str8 str8_fmt_ktl_buf(Slice buffer, KTL_Str8 table, Str8 fmt_template)
U8 buffer_remaining = buffer.len;
UTF8_R cursor_fmt = fmt_template.ptr;
U8 left_fmt = fmt_template.len;
U1x16 needle_lt = splat_u4_u1x16(u4_byte_fill('<'));
U1x16 needle_gt = splat_u4_u1x16(u4_byte_fill('>'));
while (left_fmt && buffer_remaining)
{
// Forward until we hit the delimiter '<' or the template's contents are exhausted.
U8 copy_offset = 0;
if (cursor_fmt[0] == '<')
{
UTF8_R potential_token_cursor = cursor_fmt + 1; // Skip '<'
U8 potential_token_len = 0;
B4 fmt_overflow = false;
while(true) {
UTF8_R cursor = potential_token_cursor + potential_token_len;
fmt_overflow = cursor >= slice_end(fmt_template);
B4 found_terminator = potential_token_cursor[potential_token_len] == '>';
if (fmt_overflow || found_terminator) { break; }
++ potential_token_len;
}
if (fmt_overflow) {
// Failed to find a subst and we're at end of fmt, just copy segment.
copy_offset = 1 + potential_token_len; // '<' + token
goto write_to_buffer;
}
// Hashing the potential token and cross checking it with our token table
U8 key = hash64_fnv1a_ret(slice_ut(u8_(potential_token_cursor), potential_token_len), 0);
Str8_R value = nullptr; for slice_iter(table, token) {
// We do a linear iteration instead of a hash table lookup because the user should never subst with more than 32-128 unqiue tokens..
if (token->key == key) { value = & token->value; break; }
}
if (value)
{
// We're going to appending the string, make sure we have enough space in our buffer.
// NOTE(Ed): this version doesn't support growing the buffer (No Allocator Interface)
copy_offset = min(buffer_remaining, value->len); // Prevent Buffer overflow.
assert((buffer_remaining - copy_offset) > 0);
mem_copy(u8_(cursor_buffer), u8_(value->ptr), copy_offset);
// Sync cursor format to after the processed token
cursor_buffer += copy_offset;
buffer_remaining -= copy_offset;
cursor_fmt = potential_token_cursor + 1 + potential_token_len; // '<' + token
left_fmt -= potential_token_len + 2; // The 2 here are the '<' & '>' delimiters being omitted.
continue;
}
// If not a subsitution, we copy the segment and continue.
copy_offset = 1 + potential_token_len; // '<' + token
goto write_to_buffer;
if (cursor_fmt[0] == '<') {
UTF8_R sig = cursor_fmt + 1;
U8 sig_max = slice_end(fmt_template) - sig;
U8 sig_len = find_u1_via_u1x16(sig, sig_max, '>', needle_gt);
assert(sig_len < sig_max);
Str8_R value = ktl_str8_find(table, hash64_fnv1a_ret(slice_ut(sig, sig_len), 0));
U8 n = min(buffer_remaining, value->len);
assert((buffer_remaining - n) > 0); mem_copy(u8_(cursor_buffer), u8_(value->ptr), n);
cursor_buffer += n;
buffer_remaining -= n;
cursor_fmt = sig + sig_len + 1;
left_fmt -= sig_len + 2;
continue;
}
else do {
++ copy_offset;
}
while ( (cursor_fmt[copy_offset] != '<' && (cursor_fmt + copy_offset) < slice_end(fmt_template)) );
write_to_buffer:
assert((buffer_remaining - copy_offset) > 0);
copy_offset = min(buffer_remaining, copy_offset); // Prevent buffer overflow.
mem_copy(u8_(cursor_buffer), u8_(cursor_fmt), copy_offset);
buffer_remaining -= copy_offset;
left_fmt -= copy_offset;
cursor_buffer += copy_offset;
cursor_fmt += copy_offset;
U8 n = find_u1_via_u1x16(cursor_fmt, min(left_fmt, buffer_remaining), '<', needle_lt);
assert((buffer_remaining - 1) > 0); n = min(buffer_remaining, n);
mem_copy(u8_(cursor_buffer), u8_(cursor_fmt), n);
cursor_buffer += n;
cursor_fmt += n;
buffer_remaining -= n;
left_fmt -= n;
}
return (Str8){C_(UTF8*, buffer.ptr), buffer.len - buffer_remaining};
return str8(C_(UTF8*,buffer.ptr), buffer.len - buffer_remaining);
}
typedef Struct_(Str8Gen) { UTF8* ptr; U8 cap, len; };
FI_ Str8Gen str8gen_make(Slice s) { return (Str8Gen){C_(UTF8*,s.ptr), s.len, 0}; }
FI_ Slice str8gen_buf(Str8Gen_R gen) { return (Slice){u8_(gen->ptr) + gen->len, gen->cap - gen->len}; }
FI_ void str8gen_append_str8(Str8Gen_R gen, Str8 str) { assert(gen != nullptr);
@@ -224,8 +197,7 @@ str16_from_8(FArena* arena, Str8 in) {
U1* opl = ptr + in.len;
U8 size = 0;
UnicodeDecode consume;
for(;ptr < opl; ptr += consume.inc)
{
for(;ptr < opl; ptr += consume.inc) {
consume = utf8_decode(ptr, opl - ptr);
size += utf16_encode(str.ptr + size, consume.codepoint);
}
+4
View File
@@ -145,6 +145,9 @@ $f_sanitize_hwaddress = '-fsanitize=hwaddress'
$f_sanitize_address_safe = '-fsanitize=address,safe-stack'
$f_sanitize_cfi = '-fsanitize=cfi'
# --- Compiler Flags: Hardware Architecture ---
$f_arch_haswell = '-march=haswell'
# --- Compiler Flags: Environment / Target ---
$f_no_stdlib = '-nostdlib'
$f_freestanding = '-ffreestanding'
@@ -286,6 +289,7 @@ function compile-unit { param(
$compile_args = @()
$compile_args += $f_std_c11
$compile_args += $f_all_c
$compile_args += $f_arch_haswell
$compile_args += $f_ms_ex
$compile_args += $f_wall
$compile_args += $f_wno_attributes