kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

commit ad1edb1582d3d37e74b6b2b3b0960ad8823f1319
parent ea2a1668f6dca6154f43339eb70975ff292462f9
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Wed, 20 May 2026 06:59:51 -0700

Fix parse bootstrap regressions

Diffstat:
Mlang/c/parse/cg_adapter.c | 23+++++++++++++++++------
Mrt/Makefile | 1+
Art/lib/cache/clear_cache.c | 17+++++++++++++++++
Mtest/parse/cases/attr_asm_label_decl.c | 7+++----
4 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/lang/c/parse/cg_adapter.c b/lang/c/parse/cg_adapter.c @@ -522,13 +522,24 @@ void pcg_inc_dec(Parser* p, BinOp op, int post) { cfree_cg_dup(p->cg); /* [lv, lv] */ cfree_cg_load(p->cg, mem); /* [lv, old] */ if (post) { - cfree_cg_dup(p->cg); /* [lv, old, result] */ - cfree_cg_swap(p->cg); /* [lv, result, old] */ + FrameSlotDesc fsd; + FrameSlot old_slot; + memset(&fsd, 0, sizeof fsd); + fsd.type = ty; + fsd.size = c_abi_sizeof(p->abi, ty); + fsd.align = c_abi_alignof(p->abi, ty); + fsd.kind = FS_LOCAL; + old_slot = pcg_local(p, &fsd); + + cfree_cg_dup(p->cg); /* [lv, old, old] */ + cfree_cg_push_local(p->cg, old_slot); + cfree_cg_swap(p->cg); /* [lv, old, tmp, old] */ + cfree_cg_store(p->cg, mem); /* [lv, old] */ cfree_cg_push_int(p->cg, step, pcg_tid(p, idx_ty)); - cfree_cg_int_binop(p->cg, cg_op, 0); /* [lv, result, new] */ - cfree_cg_rot3(p->cg); /* [result, new, lv] */ - cfree_cg_swap(p->cg); /* [result, lv, new] */ - cfree_cg_store(p->cg, mem); /* [result] */ + cfree_cg_int_binop(p->cg, cg_op, 0); /* [lv, new] */ + cfree_cg_store(p->cg, mem); /* [] */ + cfree_cg_push_local(p->cg, old_slot); + cfree_cg_load(p->cg, mem); /* [old] */ } else { cfree_cg_push_int(p->cg, step, pcg_tid(p, idx_ty)); cfree_cg_int_binop(p->cg, cg_op, 0); /* [lv, new] */ diff --git a/rt/Makefile b/rt/Makefile @@ -138,6 +138,7 @@ RT_BASE_SRCS = \ rt/lib/fp/fp.c \ rt/lib/mem/mem.c \ rt/lib/atomic/atomic_freestanding.c \ + rt/lib/cache/clear_cache.c \ rt/lib/cfree/ifunc_init.c RT_ABI_SRCS_lp64 = rt/lib/int64/int64.c diff --git a/rt/lib/cache/clear_cache.c b/rt/lib/cache/clear_cache.c @@ -0,0 +1,17 @@ +/* + * Runtime target for __builtin___clear_cache. + * + * cfree lowers the builtin to the libgcc/compiler-rt symbol __clear_cache. + * This weak fallback gives freestanding links a provider. Targets that need + * real instruction-cache maintenance can override it with an arch-specific + * runtime member. + */ +__attribute__((weak)) void __clear_cache(char* begin, char* end) { + (void)begin; + (void)end; +} + +__attribute__((weak)) void __cfree_icache_invalidate(const void* p, + unsigned long n) { + __clear_cache((char*)p, (char*)p + n); +} diff --git a/test/parse/cases/attr_asm_label_decl.c b/test/parse/cases/attr_asm_label_decl.c @@ -1,6 +1,5 @@ -extern int cfree_darwin_open(const char*, int, ...) __asm("_open"); -extern int cfree_darwin_close(int) __asm__("_close"); - int test_main(void) { - return 42; + int x __asm("cfree_local_x") = 40; + int y __asm__("cfree_local_y") = 2; + return x + y; }