Skip to content

Commit 2fba28c

Browse files
Dump out the non SSA ID with the register pool data so that we can see what slots were assigned
1 parent f095db1 commit 2fba28c

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

optvm/src/main/java/com/compilerprogramming/ezlang/compiler/Register.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public String name() {
8383
* During SSA form this is not valid for registers that are instances of SSARegister.
8484
*/
8585
public int nonSSAId() {
86-
assert frameSlot >= 0;
86+
//assert frameSlot >= 0; // assert inteferes with verbose display
8787
return frameSlot;
8888
}
8989
public void updateSlot(int slot) {

optvm/src/main/java/com/compilerprogramming/ezlang/compiler/RegisterPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public int numRegisters() {
4949
}
5050
public void toStr(StringBuilder sb) {
5151
for (Register reg : registers) {
52-
sb.append("Reg #").append(reg.id).append(" ").append(reg.name()).append("\n");
52+
sb.append("Reg #").append(reg.id).append(" ").append(reg.name()).append(" ").append(reg.nonSSAId()).append("\n");
5353
}
5454
}
5555
}

optvm/src/test/java/com/compilerprogramming/ezlang/compiler/TestLiveness.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ func foo() {
3939
String output = Compiler.dumpIR(typeDict, true);
4040
Assert.assertEquals("""
4141
func print(n: Int)
42-
Reg #0 n
42+
Reg #0 n 0
4343
L0:
4444
arg n
4545
goto L1
4646
L1:
4747
func foo()
48-
Reg #0 i
49-
Reg #1 s
50-
Reg #2 %t2
51-
Reg #3 %t3
52-
Reg #4 %t4
53-
Reg #5 %t5
54-
Reg #6 %t6
48+
Reg #0 i 0
49+
Reg #1 s 1
50+
Reg #2 %t2 2
51+
Reg #3 %t3 3
52+
Reg #4 %t4 4
53+
Reg #5 %t5 5
54+
Reg #6 %t6 6
5555
L0:
5656
i = 1
5757
s = 1
@@ -159,13 +159,13 @@ func foo(a: Int, b: Int) {
159159
String output = Compiler.dumpIR(typeDict, true);
160160
Assert.assertEquals("""
161161
func foo(a: Int,b: Int)
162-
Reg #0 a
163-
Reg #1 b
164-
Reg #2 %t2
165-
Reg #3 %t3
166-
Reg #4 %t4
167-
Reg #5 %t5
168-
Reg #6 %t6
162+
Reg #0 a 0
163+
Reg #1 b 1
164+
Reg #2 %t2 2
165+
Reg #3 %t3 3
166+
Reg #4 %t4 4
167+
Reg #5 %t5 5
168+
Reg #6 %t6 6
169169
L0:
170170
arg a
171171
arg b
@@ -305,8 +305,8 @@ public void test3() {
305305
String actual = function.toStr(new StringBuilder(), true).toString();
306306
Assert.assertEquals("""
307307
func foo()->Int
308-
Reg #0 i
309-
Reg #1 s
308+
Reg #0 i 0
309+
Reg #1 s 1
310310
L0:
311311
i = 1
312312
goto L2
@@ -370,11 +370,11 @@ public void testSwapProblem() {
370370
String actual = function.toStr(new StringBuilder(), true).toString();
371371
Assert.assertEquals("""
372372
func foo(p: Int)
373-
Reg #0 p
374-
Reg #1 a1
375-
Reg #2 a2
376-
Reg #3 b1
377-
Reg #4 b2
373+
Reg #0 p 0
374+
Reg #1 a1 1
375+
Reg #2 a2 2
376+
Reg #3 b1 3
377+
Reg #4 b2 4
378378
L0:
379379
arg p
380380
a1 = 42
@@ -413,10 +413,10 @@ public void testLostCopyProblem() {
413413
String actual = function.toStr(new StringBuilder(), true).toString();
414414
Assert.assertEquals("""
415415
func foo(p: Int)->Int
416-
Reg #0 p
417-
Reg #1 x1
418-
Reg #2 x3
419-
Reg #3 x2
416+
Reg #0 p 0
417+
Reg #1 x1 1
418+
Reg #2 x3 2
419+
Reg #3 x2 3
420420
L0:
421421
arg p
422422
x1 = 1
@@ -470,7 +470,7 @@ func foo()->Int
470470
Assert.assertEquals("""
471471
Pre-SSA
472472
func foo()->Int
473-
Reg #0 %t0
473+
Reg #0 %t0 0
474474
L0:
475475
if 1 goto L2 else goto L3
476476
#PHIDEFS = {}
@@ -515,10 +515,10 @@ func foo()->Int
515515
#LIVEOUT = {0}
516516
Post-SSA
517517
func foo()->Int
518-
Reg #0 %t0
519-
Reg #1 %t0_0
520-
Reg #2 %t0_1
521-
Reg #3 %t0_2
518+
Reg #0 %t0 0
519+
Reg #1 %t0_0 0
520+
Reg #2 %t0_1 0
521+
Reg #3 %t0_2 0
522522
L0:
523523
if 1 goto L2 else goto L3
524524
#PHIDEFS = {}

0 commit comments

Comments
 (0)