From c5adbd6bf166bd0f08aca1d49750edea8d611151 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 8 Jan 2026 13:27:37 +0100 Subject: [PATCH] Reduced memory usage of codegen steps --- src/codegen/Index.go | 4 ++++ src/codegen/Step.go | 2 +- src/codegen/createSteps.go | 4 ++-- src/codegen/reorderParameters.go | 2 +- src/codegen/reorderPhis.go | 6 +++--- src/verbose/SSA.go | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 src/codegen/Index.go diff --git a/src/codegen/Index.go b/src/codegen/Index.go new file mode 100644 index 0000000..fec046f --- /dev/null +++ b/src/codegen/Index.go @@ -0,0 +1,4 @@ +package codegen + +// Index is the data type for storing step indices. +type Index uint16 \ No newline at end of file diff --git a/src/codegen/Step.go b/src/codegen/Step.go index 93e5eda..f48cc00 100644 --- a/src/codegen/Step.go +++ b/src/codegen/Step.go @@ -13,7 +13,7 @@ type Step struct { Phis set.Ordered[*Step] Live []*Step Hints []cpu.Register - Index int + Index Index Register cpu.Register } diff --git a/src/codegen/createSteps.go b/src/codegen/createSteps.go index 87bdc6b..04a97da 100644 --- a/src/codegen/createSteps.go +++ b/src/codegen/createSteps.go @@ -9,7 +9,7 @@ func createSteps(ir ssa.IR) IR { steps := make([]*Step, count) valueToStep := make(map[ssa.Value]*Step, count) blockToRegion := make(map[*ssa.Block]region, len(ir.Blocks)) - i := 0 + i := Index(0) for _, block := range ir.Blocks { if block != ir.Blocks[0] { @@ -24,7 +24,7 @@ func createSteps(ir ssa.IR) IR { blockToRegion[block] = region{ Start: uint32(i), - End: uint32(i + len(block.Instructions)), + End: uint32(i + Index(len(block.Instructions))), } for _, instr := range block.Instructions { diff --git a/src/codegen/reorderParameters.go b/src/codegen/reorderParameters.go index b0e194f..87fc231 100644 --- a/src/codegen/reorderParameters.go +++ b/src/codegen/reorderParameters.go @@ -22,7 +22,7 @@ func (f *Function) reorderParameters() { bringToFront(f.Steps[:i+1], i) for h := range i + 1 { - f.Steps[h].Index = h + f.Steps[h].Index = Index(h) } if usedRegisters&(1<