From cc901026c25e1fd3ad3059933d3a5c1c7b593f8b Mon Sep 17 00:00:00 2001 From: Steven Massey Date: Wed, 14 Apr 2021 11:08:54 -0700 Subject: [PATCH] slot allocation logging --- source/m3_info.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/source/m3_info.c b/source/m3_info.c index 0b1a9aa..24a0a69 100644 --- a/source/m3_info.c +++ b/source/m3_info.c @@ -334,8 +334,8 @@ void dump_type_stack (IM3Compilation o) i32 regAllocated [2] = { (i32) IsRegisterAllocated (o, 0), (i32) IsRegisterAllocated (o, 1) }; // display whether r0 or fp0 is allocated. these should then also be reflected somewhere in the stack too. - d_m3Log(stack, ""); - printf (" "); + d_m3Log(stack, "\n"); + d_m3Log(stack, " "); printf ("%s %s ", regAllocated [0] ? "(r0)" : " ", regAllocated [1] ? "(fp0)" : " "); // printf ("%d", o->stackIndex -) @@ -373,6 +373,33 @@ void dump_type_stack (IM3Compilation o) for (u32 r = 0; r < 2; ++r) d_m3Assert (regAllocated [r] == 0); // reg allocation & stack out of sync + + u16 maxSlot = GetMaxUsedSlotPlusOne (o); + + if (maxSlot > o->slotFirstDynamicIndex) + { + d_m3Log (stack, " -"); + + for (u16 i = o->slotFirstDynamicIndex; i < maxSlot; ++i) + printf ("----"); + + printf ("\n"); + + d_m3Log (stack, " slot |"); + for (u16 i = o->slotFirstDynamicIndex; i < maxSlot; ++i) + printf ("%3d|", i); + + printf ("\n"); + d_m3Log (stack, " alloc |"); + + for (u16 i = o->slotFirstDynamicIndex; i < maxSlot; ++i) + { + printf ("%3d|", o->m3Slots [i]); + } + + printf ("\n"); + } + d_m3Log(stack, "\n"); }