Implemented compilation to SSA form
All checks were successful
/ test (push) Successful in 31s

This commit is contained in:
Eduard Urbach 2025-06-23 00:17:05 +02:00
parent f7be86a3d9
commit 31c5ed614c
Signed by: akyoto
GPG key ID: 49226B848C78F6C8
27 changed files with 548 additions and 61 deletions

View file

@ -7,16 +7,20 @@ import (
"git.urbach.dev/go/assert"
)
func TestBlock(t *testing.T) {
f := ssa.Function{}
block := f.AddBlock()
a := block.Append(ssa.Instruction{Type: ssa.Int, Int: 1})
b := block.Append(ssa.Instruction{Type: ssa.Int, Int: 2})
c := block.Append(ssa.Instruction{Type: ssa.Add, Args: []*ssa.Instruction{a, b}})
func TestFunction(t *testing.T) {
fn := ssa.Function{}
a := fn.AppendInt(1)
b := fn.AppendInt(2)
c := fn.Append(ssa.Value{Type: ssa.Add, Args: []*ssa.Value{a, b}})
fn.AddBlock()
d := fn.AppendInt(3)
e := fn.AppendInt(4)
f := fn.Append(ssa.Value{Type: ssa.Add, Args: []*ssa.Value{d, e}})
assert.Equal(t, c.String(), "1 + 2")
assert.Equal(t, f.String(), "3 + 4")
}
func TestInvalidInstruction(t *testing.T) {
instr := ssa.Instruction{}
instr := ssa.Value{}
assert.Equal(t, instr.String(), "")
}