From bdb1b9595fd92456a36d6d8ffe6d7a7e9438ebae Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 3 Jul 2025 15:12:14 +0200 Subject: [PATCH] Simplified verbose output for the IR --- src/compiler/showSSA.go | 23 ++++++----------------- src/ssa/Parameter.go | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/compiler/showSSA.go b/src/compiler/showSSA.go index 4e5a178..f425215 100644 --- a/src/compiler/showSSA.go +++ b/src/compiler/showSSA.go @@ -2,7 +2,6 @@ package compiler import ( "fmt" - "strings" "git.urbach.dev/cli/q/src/core" "git.urbach.dev/go/color/ansi" @@ -11,26 +10,16 @@ import ( // showSSA shows the SSA IR. func showSSA(root *core.Function) { root.EachDependency(make(map[*core.Function]bool), func(f *core.Function) { - fmt.Print("# ") - ansi.Green.Print(f.UniqueName) - fmt.Print("\n\n") + ansi.Yellow.Println(f.UniqueName + ":") for _, block := range f.Blocks { - ansi.Dim.Printf("| %-3s | %-30s | %-30s | %-4s |\n", "ID", "Raw", "Type", "Uses") - ansi.Dim.Printf("| %s | %s | %s | %s |\n", strings.Repeat("-", 3), strings.Repeat("-", 30), strings.Repeat("-", 30), strings.Repeat("-", 4)) + // ansi.Dim.Printf("| %-3s | %-30s | %-30s | %-4s |\n", "ID", "Raw", "Type", "Uses") + // ansi.Dim.Printf("| %s | %s | %s | %s |\n", strings.Repeat("-", 3), strings.Repeat("-", 30), strings.Repeat("-", 30), strings.Repeat("-", 4)) for i, instr := range block.Instructions { - ansi.Dim.Printf("| %%%-2d | ", i) - - if instr.IsConst() { - fmt.Printf("%-30s ", instr.Debug()) - } else { - ansi.Yellow.Printf("%-30s ", instr.Debug()) - } - - ansi.Dim.Print("|") - ansi.Dim.Printf(" %-30s |", instr.Type().Name()) - ansi.Dim.Printf(" %-4d |", instr.CountUsers()) + ansi.Dim.Printf("%%%-1d = ", i) + fmt.Printf("%-30s ", instr.Debug()) + ansi.Dim.Printf(" %-30s", instr.Type().Name()) fmt.Println() } } diff --git a/src/ssa/Parameter.go b/src/ssa/Parameter.go index 7cd158c..d813d4b 100644 --- a/src/ssa/Parameter.go +++ b/src/ssa/Parameter.go @@ -38,7 +38,7 @@ func (v *Parameter) Debug() string { } func (v *Parameter) String() string { - return fmt.Sprintf("in[%d]", v.Index) + return fmt.Sprintf("args[%d]", v.Index) } func (v *Parameter) Type() types.Type {