Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

lir: enable tests

  • Loading branch information...
commit 5b295881fdbb7b27f01f905642590fbc4f241e64 1 parent 8b9420a
@indutny authored
Showing with 67 additions and 60 deletions.
  1. +1 −1  Makefile
  2. +66 −59 test/test-lir.cc
View
2  Makefile
@@ -26,7 +26,7 @@ test: test-runner can
@./test-runner scope
@./test-runner fullgen
@./test-runner hir
-# @./test-runner lir
+ @./test-runner lir
@./test-runner functional
@./test-runner binary
@./test-runner numbers
View
125 test/test-lir.cc
@@ -7,112 +7,119 @@
#include <lir-inl.h>
TEST_START(lir)
+#ifdef CANDOR_ARCH_x64
// Simpliest
LIR_TEST("return 1\n",
"# Block 0\n"
"0: Label\n"
"2: Entry\n"
- "4: rax:4 = Literal[1]\n"
- "6: @rax:0 = Move rax:4\n"
+ "4: c10 = Literal[1]\n"
+ "5: Gap[c10 => @rax:11]\n"
+ "6: @rax:0 = Move rax:11\n"
"8: Return @rax:0\n\n")
LIR_TEST("return 1 + 2\n",
"# Block 0\n"
"0: Label\n"
"2: Entry\n"
- "4: rax:4 = Literal[1]\n"
- "6: rbx:5 = Literal[2]\n"
- "8: @rbx:1 = Move rbx:5\n"
- "10: @rax:0 = Move rax:4\n"
- "12: @rax:0 = BinOp @rax:0, @rbx:1\n"
- "14: rax:6 = Move @rax:0\n"
- "16: @rax:0 = Move rax:6\n"
- "18: Return @rax:0\n\n")
+ "4: c10 = Literal[1]\n"
+ "6: c11 = Literal[2]\n"
+ "7: Gap[c10 => @rax:14]\n"
+ "8: @rax:0(rax) = Move rax:14\n"
+ "9: Gap[c11 => @rbx:16]\n"
+ "10: @rbx:1 = Move rbx:16\n"
+ "12: @rax:0(rax) = BinOpNumber @rax:0(rax), @rbx:1 # scratches: @rcx:12\n"
+ "14: rax:13(rax) = Move @rax:0(rax)\n"
+ "16: @rax:0(rax) = Move rax:13(rax)\n"
+ "18: Return @rax:0(rax)\n\n")
// Ifs
LIR_TEST("if (true) { a = 1 } else { a = 2}\nreturn a\n",
"# Block 0\n"
"0: Label\n"
"2: Entry\n"
- "4: rax:4 = Literal[true]\n"
- "6: @rax:0 = Move rax:4\n"
+ "4: c10 = Literal[true]\n"
+ "5: Gap[c10 => @rax:14]\n"
+ "6: @rax:0 = Move rax:14\n"
"8: Branch @rax:0 (10), (18)\n"
"\n"
"# Block 1\n"
- "# in: , out: 6\n"
+ "# in: , out: 12\n"
"10: Label\n"
- "12: rax:5 = Literal[1]\n"
- "14: rax:6 = Move rax:5\n"
+ "12: c11 = Literal[1]\n"
+ "13: Gap[c11 => @rax:16]\n"
+ "14: rax:12(rax) = Move rax:16\n"
"16: Goto (26)\n"
"\n"
"# Block 2\n"
- "# in: , out: 6\n"
+ "# in: , out: 12\n"
"18: Label\n"
- "20: rax:7 = Literal[2]\n"
- "22: rax:6 = Move rax:7\n"
+ "20: c13 = Literal[2]\n"
+ "21: Gap[c13 => @rax:18]\n"
+ "22: rax:12(rax) = Move rax:18\n"
"\n"
"# Block 3\n"
- "# in: 6, out: \n"
+ "# in: 12, out: \n"
"26: Label\n"
- "28: rax:6 = Phi rax:6\n"
- "30: @rax:0 = Move rax:6\n"
+ "28: rax:12(rax) = Phi rax:12(rax)\n"
+ "30: @rax:0 = Move rax:12(rax)\n"
"32: Return @rax:0\n\n")
LIR_TEST("pass_through = 1\n"
"while (i < 10) { i++ }\n"
"return i + pass_through",
"# Block 0\n"
- "# in: , out: 6, 4\n"
+ "# in: 15, out: 13, 12, 10, 15\n"
"0: Label\n"
"2: Entry\n"
- "4: rcx:4 = Literal[1]\n"
- "6: rax:5 = Nil\n"
- "8: rdx:6 = Move rax:5\n"
+ "4: c10 = Literal[1]\n"
+ "6: c11 = Nil\n"
+ "8: c12 = Literal[10]\n"
+ "9: Gap[c11 => @rbx:18]\n"
+ "10: rcx:13(rax) = Move rbx:18\n"
"\n"
"# Block 1\n"
- "# in: 6, 4, out: 6, 4\n"
- "12: Label\n"
- "14: rdx:6 = Phi rdx:6\n"
+ "# in: 13, 12, 10, 15, out: 13, 12, 10, 15\n"
+ "14: Label\n"
+ "16: rcx:13(rax) = Phi rcx:13(rax)\n"
"\n"
"# Block 2\n"
- "# in: 6, 4, out: 6, 4\n"
- "18: Label\n"
- "20: rax:7 = Literal[10]\n"
- "22: @rbx:1 = Move rax:7\n"
- "24: @rax:0 = Move rdx:6\n"
- "25: Gap[rcx:4 => [1]:12, rdx:6 => [2]:14]\n"
- "26: @rax:0 = BinOp @rax:0, @rbx:1\n"
- "28: rax:8 = Move @rax:0\n"
- "30: @rax:0 = Move rax:8\n"
- "32: Branch @rax:0 (34), (54)\n"
+ "# in: 13, 12, 10, 15, out: 13, 10, 15, 12\n"
+ "20: Label\n"
+ "21: Gap[rax:15(rax) => rdx:22]\n"
+ "22: @rax:0(rax) = Move rcx:13(rax)\n"
+ "23: Gap[c12 => @rbx:20]\n"
+ "24: @rbx:1 = Move rbx:20\n"
+ "25: Gap[rcx:13(rax) => [1]:24, rdx:22 => [2]:26]\n"
+ "26: @rax:0(rax) = BinOp @rax:0(rax), @rbx:1\n"
+ "28: rax:14(rax) = Move @rax:0(rax)\n"
+ "30: @rax:0(rax) = Move rax:14(rax)\n"
+ "32: Branch @rax:0(rax) (34), (52)\n"
"\n"
"# Block 3\n"
- "# in: 6, 4, out: 10, 4\n"
+ "# in: 13, 10, 12, out: 15, 12, 10\n"
"34: Label\n"
- "36: rax:9 = Literal[1]\n"
- "38: @rbx:1 = Move rax:9\n"
- "40: @rax:0 = Move [2]:14\n"
- "42: @rax:0 = BinOp @rax:0, @rbx:1\n"
- "44: rax:10 = Move @rax:0\n"
+ "36: @rax:0(rax) = Move [1]:24\n"
+ "37: Gap[c10 => @rbx:16]\n"
+ "38: @rbx:1 = Move rbx:16\n"
+ "40: @rax:0(rax) = BinOp @rax:0(rax), @rbx:1\n"
+ "42: [2]:26 = Move @rax:0(rax)\n"
"\n"
"# Block 4\n"
- "# in: 10, 4, out: 6, 4\n"
- "48: Label\n"
- "50: [2]:14 = Move rax:10\n"
- "51: Gap[[2]:14 => rdx:6, [1]:12 => rcx:4]\n"
- "52: Goto (12)\n"
+ "# in: 15, 12, 10, out: 13, 12, 10, 15\n"
+ "46: Label\n"
+ "48: [1]:24 = Move [2]:26\n"
+ "49: Gap[[1]:24 => rcx:13(rax), [2]:26 => rax:15(rax)]\n"
+ "50: Goto (14)\n"
"\n"
"# Block 5\n"
- "# in: 4, 6, out: 4, 6\n"
- "54: Label\n"
+ "# in: 15, out: 15\n"
+ "52: Label\n"
"\n"
"# Block 6\n"
- "# in: 4, 6, out: \n"
- "58: Label\n"
- "60: @rbx:1 = Move [1]:12\n"
- "62: @rax:0 = Move [2]:14\n"
- "64: @rax:0 = BinOp @rax:0, @rbx:1\n"
- "66: rax:11 = Move @rax:0\n"
- "68: @rax:0 = Move rax:11\n"
- "70: Return @rax:0\n\n")
+ "# in: 15, out: \n"
+ "56: Label\n"
+ "58: @rax:0(rax) = Move [2]:26\n"
+ "60: Return @rax:0(rax)\n\n")
+#endif // CANDOR_ARCH_x64
TEST_END(lir)
Please sign in to comment.
Something went wrong with that request. Please try again.