Simplified verbose output for the IR
All checks were successful
/ test (push) Successful in 16s

This commit is contained in:
Eduard Urbach 2025-07-03 15:12:14 +02:00
parent cfc0f87c49
commit bdb1b9595f
Signed by: akyoto
GPG key ID: 49226B848C78F6C8
2 changed files with 7 additions and 18 deletions

View file

@ -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()
}
}

View file

@ -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 {