Skip to content

Commit

Permalink
test: enable hir test
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Nov 17, 2012
1 parent 4f678d5 commit 8b9420a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -25,7 +25,7 @@ test: test-runner can
@./test-runner parser
@./test-runner scope
@./test-runner fullgen
# @./test-runner hir
@./test-runner hir
# @./test-runner lir
@./test-runner functional
@./test-runner binary
Expand Down
6 changes: 3 additions & 3 deletions src/hir.cc
Expand Up @@ -577,12 +577,12 @@ void HIRGen::ScheduleLate(HIRInstruction* instr) {
// Select best block between ->block() and lca
HIRBlock* best = lca;

if (lca->loop_depth < best->loop_depth) best = lca;

while (lca->reachable_from()->Test(instr->block()->id) &&
lca != instr->block()) {
if (lca->loop_depth < best->loop_depth) {
best = lca;
}
lca = lca->dominator();
if (lca->loop_depth < best->loop_depth) best = lca;
}
instr->block(best);
}
Expand Down
71 changes: 36 additions & 35 deletions test/test-hir.cc
Expand Up @@ -56,9 +56,9 @@ TEST_START(hir)
"i12 = LoadProperty(i2, i10)\n"
"i14 = AlignStack(i8)\n"
"i16 = Literal[0]\n"
"i18 = StoreArg(i6, i16)\n"
"i22 = StoreArg(i4, i4)\n"
"i26 = StoreArg(i2, i6)\n"
"i22 = StoreArg(i6, i6)\n"
"i24 = StoreArg(i4, i4)\n"
"i26 = StoreArg(i2, i16)\n"
"i28 = Call(i12, i8)\n"
"i30 = Return(i28)\n")

Expand All @@ -75,31 +75,32 @@ TEST_START(hir)
"i12 = Literal[3]\n"
"i14 = StoreProperty(i8, i10, i12)\n"
"i18 = Literal[4]\n"
"i20 = StoreProperty(i14, i4, i18)\n"
"i24 = Sizeof(i20)\n"
"i20 = StoreProperty(i8, i4, i18)\n"
"i24 = Sizeof(i8)\n"
"i26 = BinOp(i6, i24)\n"
"i28 = AlignStack(i26)\n"
"i30 = StoreVarArg(i20)\n"
"i32 = StoreArg(i6)\n"
"i34 = StoreArg(i4)\n"
"i36 = Call(i2, i26)\n"
"i38 = Return(i36)\n"
"i40 = BinOp(i26, i4)\n"
"i42 = StoreVarArg(i8, i40)\n"
"i44 = StoreArg(i6, i4)\n"
"i46 = StoreArg(i4, i10)\n"
"i48 = Call(i2, i26)\n"
"i50 = Return(i48)\n"
"# Block 1\n"
"i40 = Entry[0]\n"
"i42 = Literal[0]\n"
"i44 = LoadArg(i42)\n"
"i46 = Literal[1]\n"
"i48 = AllocateArray\n"
"i52 = LoadVarArg(i46, i46, i48)\n"
"i54 = Sizeof(i48)\n"
"i56 = BinOp(i46, i54)\n"
"i58 = LoadArg(i56)\n"
"i62 = LoadProperty(i48, i42)\n"
"i66 = LoadProperty(i48, i46)\n"
"i68 = BinOp(i66, i58)\n"
"i70 = BinOp(i62, i68)\n"
"i72 = BinOp(i44, i70)\n"
"i74 = Return(i72)\n")
"i52 = Entry[0]\n"
"i54 = Literal[0]\n"
"i56 = LoadArg(i54)\n"
"i58 = Literal[1]\n"
"i60 = AllocateArray\n"
"i64 = LoadVarArg(i58, i58, i60)\n"
"i66 = Sizeof(i60)\n"
"i68 = BinOp(i58, i66)\n"
"i70 = LoadArg(i68)\n"
"i74 = LoadProperty(i60, i54)\n"
"i78 = LoadProperty(i60, i58)\n"
"i80 = BinOp(i78, i70)\n"
"i82 = BinOp(i74, i80)\n"
"i84 = BinOp(i56, i82)\n"
"i86 = Return(i84)\n")

// Unary operations
HIR_TEST("i = 0\nreturn !i",
Expand Down Expand Up @@ -132,18 +133,18 @@ TEST_START(hir)
HIR_TEST("i = 0\nreturn i && 1",
"# Block 0\n"
"i0 = Entry[0]\n"
"i2 = Literal[0]\n"
"i8 = Literal[1]\n"
"i4 = Goto\n"
"# succ: 1\n"
"--------\n"
"# Block 1\n"
"# dom: 0\n"
"i2 = Literal[0]\n"
"i6 = If(i2)\n"
"# succ: 2 3\n"
"--------\n"
"# Block 2\n"
"# dom: 1\n"
"i8 = Literal[1]\n"
"i10 = Goto\n"
"# succ: 4\n"
"--------\n"
Expand All @@ -159,13 +160,12 @@ TEST_START(hir)
HIR_TEST("i = 0\nreturn i || 1",
"# Block 0\n"
"i0 = Entry[0]\n"
"i2 = Literal[0]\n"
"i8 = Literal[1]\n"
"i4 = Goto\n"
"# succ: 1\n"
"--------\n"
"# Block 1\n"
"# dom: 0\n"
"i2 = Literal[0]\n"
"i6 = If(i2)\n"
"# succ: 2 3\n"
"--------\n"
Expand All @@ -176,6 +176,7 @@ TEST_START(hir)
"--------\n"
"# Block 3\n"
"# dom: 1\n"
"i8 = Literal[1]\n"
"i12 = Goto\n"
"# succ: 4\n"
"--------\n"
Expand All @@ -189,12 +190,12 @@ TEST_START(hir)
"# Block 0\n"
"i0 = Entry[0]\n"
"i2 = Nil\n"
"i6 = Literal[2]\n"
"i4 = If(i2)\n"
"# succ: 1 2\n"
"--------\n"
"# Block 1\n"
"# dom: 0\n"
"i6 = Literal[2]\n"
"i8 = Goto\n"
"# succ: 3\n"
"--------\n"
Expand All @@ -212,18 +213,18 @@ TEST_START(hir)
"# Block 0\n"
"i0 = Entry[0]\n"
"i2 = Nil\n"
"i6 = Literal[2]\n"
"i8 = Literal[3]\n"
"i4 = If(i2)\n"
"# succ: 1 2\n"
"--------\n"
"# Block 1\n"
"# dom: 0\n"
"i6 = Literal[2]\n"
"i10 = Goto\n"
"# succ: 3\n"
"--------\n"
"# Block 2\n"
"# dom: 0\n"
"i8 = Literal[3]\n"
"i12 = Goto\n"
"# succ: 3\n"
"--------\n"
Expand All @@ -247,14 +248,12 @@ TEST_START(hir)
"# Block 0\n"
"i0 = Entry[0]\n"
"i2 = Literal[1]\n"
"i6 = Literal[2]\n"
"i24 = Literal[4]\n"
"i16 = Literal[3]\n"
"i4 = If(i2)\n"
"# succ: 1 2\n"
"--------\n"
"# Block 1\n"
"# dom: 0\n"
"i6 = Literal[2]\n"
"i32 = Goto\n"
"# succ: 9\n"
"--------\n"
Expand All @@ -270,11 +269,13 @@ TEST_START(hir)
"--------\n"
"# Block 4\n"
"# dom: 2\n"
"i24 = Literal[4]\n"
"i28 = Goto\n"
"# succ: 8\n"
"--------\n"
"# Block 5\n"
"# dom: 3\n"
"i16 = Literal[3]\n"
"i18 = Goto\n"
"# succ: 7\n"
"--------\n"
Expand Down

0 comments on commit 8b9420a

Please sign in to comment.