Update again

This commit is contained in:
gingerBill
2024-04-30 11:53:54 +01:00
parent d378a06404
commit d77a8fc876
5 changed files with 66 additions and 23 deletions

View File

@@ -454,23 +454,17 @@ string_decode_rune :: #force_inline proc "contextless" (s: string) -> (rune, int
// NOTE(bill): Duplicated here to remove dependency on package unicode/utf8
@static accept_sizes := [256]u8{
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x00-0x0f
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x10-0x1f
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x20-0x2f
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x30-0x3f
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x40-0x4f
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x50-0x5f
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x60-0x6f
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x70-0x7f
0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, // 0x80-0x8f
0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, // 0x90-0x9f
0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, // 0xa0-0xaf
0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, // 0xb0-0xbf
0xf1, 0xf1, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, // 0xc0-0xcf
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, // 0xd0-0xdf
0x13, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x23, 0x03, 0x03, // 0xe0-0xef
0x34, 0x04, 0x04, 0x04, 0x44, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, // 0xf0-0xff
0x00..=0x7f = 0xf0, // ascii, size 1
0x80..=0xc1 = 0xf1, // invalid, size 1
0xc2..=0xdf = 0x02, // accept 1, size 2
0xe0 = 0x13, // accept 1, size 3
0xe1..=0xec = 0x03, // accept 0, size 3
0xed = 0x23, // accept 2, size 3
0xee..=0xef = 0x03, // accept 0, size 3
0xf0 = 0x34, // accept 3, size 4
0xf1..=0xf3 = 0x04, // accept 0, size 4
0xf4 = 0x44, // accept 4, size 4
0xf5..=0xff = 0xf1, // ascii, size 1
}
Accept_Range :: struct {lo, hi: u8}

View File

@@ -467,9 +467,38 @@ gb_internal cgModule *cg_module_create(Checker *c) {
m->checker = c;
m->info = &c->info;
bool is_jit = false;
m->mod = tb_module_create(TB_ARCH_X86_64, TB_SYSTEM_WINDOWS, is_jit);
TB_Arch arch = TB_ARCH_X86_64;
TB_System system = TB_SYSTEM_WINDOWS;
switch (build_context.metrics.arch) {
case TargetArch_amd64: arch = TB_ARCH_X86_64; break;
case TargetArch_arm64: arch = TB_ARCH_AARCH64; break;
case TargetArch_wasm32: arch = TB_ARCH_WASM32; break;
case TargetArch_wasm64p32: arch = TB_ARCH_WASM32; break;
case TargetArch_i386:
case TargetArch_arm32:
default:
GB_PANIC("UNSUPPORTED ARCH");
break;
}
switch (build_context.metrics.os) {
case TargetOs_windows: system = TB_SYSTEM_WINDOWS; break;
case TargetOs_darwin: system = TB_SYSTEM_MACOS; break;
case TargetOs_linux: system = TB_SYSTEM_LINUX; break;
case TargetOs_essence:
case TargetOs_freebsd:
case TargetOs_openbsd:
case TargetOs_haiku:
default:
GB_PANIC("UNSUPPORTED OS");
break;
}
m->mod = tb_module_create(arch, system, is_jit);
tb_module_set_tls_index(m->mod, 10, "_tls_index");
map_init(&m->values);
@@ -833,20 +862,25 @@ gb_internal bool cg_generate_code(Checker *c, LinkerData *linker_data) {
thread_pool_wait();
{
{ // Create startup
cgProcedure *p = cg_startup_runtime_proc;
cg_procedure_begin(p);
cg_global_variables_initialize(p, &global_variables);
tb_inst_ret(p->func, 0, nullptr);
cg_procedure_end(p);
}
{
{ // Create cleanup
cgProcedure *p = cg_cleanup_runtime_proc;
cg_procedure_begin(p);
tb_inst_ret(p->func, 0, nullptr);
cg_procedure_end(p);
}
{ // Module passes
if (build_context.optimization_level > 0) {
tb_module_ipo(m->mod);
}
}
TB_DebugFormat debug_format = TB_DEBUGFMT_NONE;
if (build_context.ODIN_DEBUG) {

View File

@@ -145,8 +145,8 @@ typedef enum TB_FeatureSet_Generic {
} TB_FeatureSet_Generic;
typedef struct TB_FeatureSet {
TB_FeatureSet_Generic gen;
TB_FeatureSet_X64 x64;
uint32_t gen; // TB_FeatureSet_Generic
uint32_t x64; // TB_FeatureSet_X64
} TB_FeatureSet;
typedef enum TB_Linkage {

Binary file not shown.

View File

@@ -381,6 +381,21 @@ gb_internal WORKER_TASK_PROC(cg_procedure_compile_worker_proc) {
cgProcedure *p = cast(cgProcedure *)data;
gb_unused(p);
TB_FeatureSet feature_set = {};
if (build_context.metrics.arch == TargetArch_amd64) {
feature_set.x64 |= TB_FEATURE_X64_SSE2;
feature_set.x64 |= TB_FEATURE_X64_SSE3;
feature_set.x64 |= TB_FEATURE_X64_SSE41;
// feature_set.x64 |= TB_FEATURE_X64_POPCNT;
// feature_set.x64 |= TB_FEATURE_X64_LZCNT;
}
bool emit_asm = false;
TB_FunctionOutput *output = tb_codegen(p->func, cg_worklist(), cg_arena(), &feature_set, emit_asm);
gb_unused(output);
// tb_print(p->func, cg_arena());
// fprintf(stdout, "\n");