diff --git a/tests/4-opt/.gitignore b/tests/4-opt/.gitignore index acedccc9b8c69a072a363c100f233eb26230b8dd..7f2a8f5c87e6c90632846a6d5bbab0c5c62d0686 100755 --- a/tests/4-opt/.gitignore +++ b/tests/4-opt/.gitignore @@ -1,2 +1,5 @@ output -log.txt \ No newline at end of file +raw_log.txt +licm_log.txt +all_log.txt +mem2reg_log.txt \ No newline at end of file diff --git a/tests/4-opt/cleanup.sh b/tests/4-opt/cleanup.sh deleted file mode 100755 index 78fecdf3ce08ec95e2f7a2b0db9093dedb5ee19e..0000000000000000000000000000000000000000 --- a/tests/4-opt/cleanup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -rm -rf output log.txt diff --git a/tests/4-opt/eval_lab4.sh b/tests/4-opt/eval_lab4.sh deleted file mode 100755 index d9a314a6ddec779d279bcc1adfb187c56bf3b661..0000000000000000000000000000000000000000 --- a/tests/4-opt/eval_lab4.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash - -project_dir=$(realpath ../../) -io_dir=$(realpath "$project_dir"/src/io) -output_dir=output -suffix=cminus - -LOG=log.txt - -usage() { - cat </dev/null - -mkdir -p $output_dir - -truncate -s 0 $LOG - -if [ $debug_mode = false ]; then - exec 3>/dev/null 4>&1 5>&2 1>&3 2>&3 -else - exec 3>&1 -fi - -if [ $debug_mode = false ]; then - exec 1>&4 2>&5 -fi - -echo "[info] Start testing, using testcase dir: $test_dir" -# asm -for case in $testcases; do - echo "==========$case==========" >>$LOG - case_base_name=$(basename -s .$suffix "$case") - std_out_file=$test_dir/$case_base_name.out - in_file=$test_dir/$case_base_name.in - asm_file=$output_dir/$case_base_name.s - exe_file=$output_dir/$case_base_name - out_file=$output_dir/$case_base_name.out - ll_file=$output_dir/$case_base_name.ll - - echo -n "$case_base_name..." - # if debug mode on, generate .ll also - if [ $debug_mode = true ]; then - bash -c "cminusfc $flag -emit-llvm $case -o $ll_file" >>$LOG 2>&1 - fi - # cminusfc compile to .s - bash -c "cminusfc -S $flag $case -o $asm_file" >>$LOG 2>&1 - check_return_value $? 0 "CE" "cminusfc compiler error" || continue - - # gcc compile asm to executable - - if [ $debug_mode = true ]; then - loongarch64-unknown-linux-gnu-gcc -g -static \ - "$asm_file" "$io_dir"/io.c -o "$exe_file" \ - >>$LOG - else - loongarch64-unknown-linux-gnu-gcc -static \ - "$asm_file" "$io_dir"/io.c -o "$exe_file" \ - >>$LOG - fi - check_return_value $? 0 "CE" "gcc compiler error" || continue - - # qemu run - if [ -e "$in_file" ]; then - exec_cmd="qemu-loongarch64 $exe_file >$out_file <$in_file" - else - exec_cmd="qemu-loongarch64 $exe_file >$out_file" - fi - bash -c "$exec_cmd" - ret=$? - # remove trailing null byte in the end line - sed -i "\$s/\x00*$//" "$out_file" - # append return value - echo $ret >>"$out_file" - - # compare output - diff --strip-trailing-cr "$std_out_file" "$out_file" -y >>$LOG - check_return_value $? 0 "WA" "output differ, check $std_out_file and $out_file" || continue - - # ok - printf "\033[1;32mOK\033[0m\n" -done diff --git a/tests/4-opt/test_perf.sh b/tests/4-opt/test_perf.sh deleted file mode 100755 index bcd321302d4370eccb93826f23959a9327fe8fab..0000000000000000000000000000000000000000 --- a/tests/4-opt/test_perf.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -project_dir=$(realpath ../../) -io_dir=$(realpath "$project_dir"/src/io) -output_dir=output -suffix=cminus -flag="" -LOG=log.txt - -check_return_value() { - rv=$1 - expected_rv=$2 - fail_msg=$3 - detail=$4 - if [ "$rv" -eq "$expected_rv" ]; then - return 0 - else - printf "\033[1;31m%s: \033[0m%s\n" "$fail_msg" "$detail" - return 1 - fi -} - -usage() { - cat </dev/null - -mkdir -p $output_dir - -truncate -s 0 $LOG - -echo "[info] Start testing, using testcase dir: $test_dir" -# asm -for case in $testcases; do - echo "==========$case==========" >>$LOG - case_base_name=$(basename -s .$suffix "$case") - in_file=$test_dir/$case_base_name.in - asm_mem2reg_on=$output_dir/${case_base_name}-$1-on.s - asm_mem2reg_off=$output_dir/${case_base_name}-$1-off.s - exe_mem2reg_on=$output_dir/${case_base_name}-$1-on - exe_mem2reg_off=$output_dir/${case_base_name}-$1-off - - echo "==========$case==========" - #### mem2reg off - # cminusfc compile to .s - bash -c "cminusfc -S $nflag $case -o $asm_mem2reg_off" >>$LOG 2>&1 - check_return_value $? 0 "CE" "cminusfc compiler error" || continue - # gcc compile asm to executable - loongarch64-unknown-linux-gnu-gcc -static \ - "$asm_mem2reg_off" "$io_dir"/io.c -o "$exe_mem2reg_off" \ - >>$LOG - check_return_value $? 0 "CE" "gcc compiler error" || continue - - #### mem2reg on - # cminusfc compile to .s - bash -c "cminusfc -S $flag $case -o $asm_mem2reg_on" >>$LOG 2>&1 - check_return_value $? 0 "CE" "cminusfc compiler error" || continue - # gcc compile asm to executable - loongarch64-unknown-linux-gnu-gcc -static \ - "$asm_mem2reg_on" "$io_dir"/io.c -o "$exe_mem2reg_on" \ - >>$LOG - check_return_value $? 0 "CE" "gcc compiler error" || continue - - echo "==========$1 off" - if [ -e "$in_file" ]; then - exec_cmd="qemu-loongarch64 $exe_mem2reg_off >/dev/null <$in_file" - else - exec_cmd="qemu-loongarch64 $exe_mem2reg_off >/dev/null" - fi - time bash -c "$exec_cmd" - echo "==========$1 on" - if [ -e "$in_file" ]; then - exec_cmd="qemu-loongarch64 $exe_mem2reg_on >/dev/null <$in_file" - else - exec_cmd="qemu-loongarch64 $exe_mem2reg_on >/dev/null" - fi - time bash -c "$exec_cmd" - -done diff --git a/tests/4-opt/testcases/0_lab2_lv0_1.cminus b/tests/4-opt/testcases/0_lab2_lv0_1.cminus new file mode 100644 index 0000000000000000000000000000000000000000..f58f1dd8be2ff626f1e40a2b08a3c754dd0ccae2 --- /dev/null +++ b/tests/4-opt/testcases/0_lab2_lv0_1.cminus @@ -0,0 +1,11 @@ +void main(void) +{ + float a[10]; + float b; + int c[10]; + int d; + input(); + outputFloat(123.4); + output(1234); + return; +} diff --git a/tests/4-opt/testcases/0_lab2_lv0_1.in b/tests/4-opt/testcases/0_lab2_lv0_1.in new file mode 100644 index 0000000000000000000000000000000000000000..b8626c4cff2849624fb67f87cd0ad72b163671ad --- /dev/null +++ b/tests/4-opt/testcases/0_lab2_lv0_1.in @@ -0,0 +1 @@ +4 diff --git a/tests/4-opt/testcases/0_lab2_lv0_1.out b/tests/4-opt/testcases/0_lab2_lv0_1.out new file mode 100644 index 0000000000000000000000000000000000000000..2cc0e3d002538be1057128b9fccfaffca5de08a5 --- /dev/null +++ b/tests/4-opt/testcases/0_lab2_lv0_1.out @@ -0,0 +1,3 @@ +123.400002 +1234 +0 diff --git a/tests/4-opt/testcases/1_lab2_lv0_2.cminus b/tests/4-opt/testcases/1_lab2_lv0_2.cminus new file mode 100644 index 0000000000000000000000000000000000000000..f9e9cce357021301ead4d0cb76c73cc391f16715 --- /dev/null +++ b/tests/4-opt/testcases/1_lab2_lv0_2.cminus @@ -0,0 +1,75 @@ +void main(void) +{ + output(100.0 + 23.4); + output(1000 + 234); + output(1000 + 23.4); + outputFloat(9 + 1.2 / (2 * 2 + 5 - 6) * 3.2 - 55); + output((1 > 2.) < 3); + output((1 > 2) < ((3 == 4) >= 0)); + output(((3 == 4.) >= 0) <= (4 != 4)); + output(((1 > 2) < ((3 == 4) >= 0)) <= (4. != 4)); + output(24.68 / 2.); + output(2468 / 2); + output(24.68 / 2); + output(1. == 2.); + output(2. == 2.); + output(3. == 2.); + output(1 == 2); + output(2 == 2); + output(3 == 2); + output(1. == 2); + output(2. == 2); + output(3 == 2.); + output(1. >= 2.); + output(2. >= 2.); + output(3. >= 2.); + output(1 >= 2); + output(2 >= 2); + output(3 >= 2); + output(1. >= 2); + output(2. >= 2); + output(3 >= 2.); + output(1. > 2.); + output(2. > 2.); + output(3. > 2.); + output(1 > 2); + output(2 > 2); + output(3 > 2); + output(1. > 2); + output(2. > 2); + output(3 > 2.); + output(1. <= 2.); + output(2. <= 2.); + output(3. <= 2.); + output(1 <= 2); + output(2 <= 2); + output(3 <= 2); + output(1. <= 2); + output(2. <= 2); + output(3 <= 2.); + output(1. < 2.); + output(2. < 2.); + output(3. < 2.); + output(1 < 2); + output(2 < 2); + output(3 < 2); + output(1. < 2); + output(2 < 2.); + output(3. < 2); + output(2. * 61.7); + output(2 * 617); + output(2 * 61.7); + output(1. != 2.); + output(2. != 2.); + output(3. != 2.); + output(1 != 2); + output(2 != 2); + output(3 != 2); + output(1. != 2); + output(2 != 2.); + output(3 != 2.); + output(200.0 - 7.66); + output(2000 - 766); + output(2000 - 76.6); + return; +} diff --git a/tests/4-opt/testcases/1_lab2_lv0_2.out b/tests/4-opt/testcases/1_lab2_lv0_2.out new file mode 100644 index 0000000000000000000000000000000000000000..f36d324758d57e83df7e921019b35ac410ecf75b --- /dev/null +++ b/tests/4-opt/testcases/1_lab2_lv0_2.out @@ -0,0 +1,72 @@ +123 +1234 +1023 +-44.720001 +1 +1 +0 +0 +12 +1234 +12 +0 +1 +0 +0 +1 +0 +0 +1 +0 +0 +1 +1 +0 +1 +1 +0 +1 +1 +0 +0 +1 +0 +0 +1 +0 +0 +1 +1 +1 +0 +1 +1 +0 +1 +1 +0 +1 +0 +0 +1 +0 +0 +1 +0 +0 +123 +1234 +123 +1 +0 +1 +1 +0 +1 +1 +0 +1 +192 +1234 +1923 +0 diff --git a/tests/4-opt/testcases/2_lab2_lv1.cminus b/tests/4-opt/testcases/2_lab2_lv1.cminus new file mode 100644 index 0000000000000000000000000000000000000000..dcfb5c91405eb09e41459998eee22776393ba448 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv1.cminus @@ -0,0 +1,100 @@ +float d[10]; +float e; +int f[10]; +int g; + +void main(void) +{ + int a; + int b; + int c; + float h[10]; + float i; + int j[10]; + int k; + int l[10]; + int m; + int n; + int o; + int p; + int q; + int r; + float s; + a = 1 < 3; + b = 2 == 4; + c = 3 > 5; + output(a); + output(b); + output(c); + d[3] = 1234.0; + outputFloat(d[3]); + h[3] = 1234.0; + outputFloat(h[3]); + e = 1234.0; + outputFloat(e); + i = 1234.0; + outputFloat(i); + f[3] = 1234; + output(f[3]); + j[3] = 1234; + output(j[3]); + g = 1234; + output(g); + k = 1234; + output(k); + l[0] = 1024; + output(l[0.1]); + m = input(); + output(m); + n = 10; + while (n) + { + output(n); + n = n - 1; + } + o = 10; + while (o > 0) + { + output(o); + o = o - 1; + } + p = 3; + output(p); + { + int p; + p = 11; + output(p); + } + output(p); + q = 2; + if (q) + output(42); + output(24); + if (2 > 1) + output(42); + output(24); + if (1 > 2) + { + output(1234); + } + if (2 > 1) + { + output(42); + } + else + output(1234); + + output(24); + + if (2 < 1) + output(42); + else + { + output(1234); + } + r = 1.0; + output(r); + s = 1; + outputFloat(s); + return; +} diff --git a/tests/4-opt/testcases/2_lab2_lv1.in b/tests/4-opt/testcases/2_lab2_lv1.in new file mode 100644 index 0000000000000000000000000000000000000000..ec635144f60048986bc560c5576355344005e6e7 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv1.in @@ -0,0 +1 @@ +9 diff --git a/tests/4-opt/testcases/2_lab2_lv1.out b/tests/4-opt/testcases/2_lab2_lv1.out new file mode 100644 index 0000000000000000000000000000000000000000..a530fa22c756f3a39b7c0ecb455dac78d4c80d89 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv1.out @@ -0,0 +1,46 @@ +1 +0 +0 +1234.000000 +1234.000000 +1234.000000 +1234.000000 +1234 +1234 +1234 +1234 +1024 +9 +10 +9 +8 +7 +6 +5 +4 +3 +2 +1 +10 +9 +8 +7 +6 +5 +4 +3 +2 +1 +3 +11 +3 +42 +24 +42 +24 +42 +24 +1234 +1 +1.000000 +0 diff --git a/tests/4-opt/testcases/2_lab2_lv2.cminus b/tests/4-opt/testcases/2_lab2_lv2.cminus new file mode 100644 index 0000000000000000000000000000000000000000..a96a5680fabe0cc61210aabb2d151a0c0dd579f4 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv2.cminus @@ -0,0 +1,116 @@ +void p(int o[]) +{ + output(o[3]); + return; +} + +void q(int c[]) +{ + output(c[3]); + p(c); + return; +} + +int addone(int a) { return a + 1; } + +void r(float a[]) +{ + output(a[3]); + return; +} + +void s(int a[]) +{ + output(a[3]); + return; +} + +void t(int a) +{ + output(a); + return; +} + +void u(float a) +{ + outputFloat(a); + return; +} + +int v(void) +{ + int i; + if (1) + { + i = 1; + return 0; + } + else + { + i = 2; + } + output(3); + return 3; +} + +int w(void) +{ + int i; + i = 10; + while (i > 0) + { + return 0; + } + output(4); + return 1; +} + +int x(void) { return 233.3; } + +float y(void) { return 7; } + +void main(void) +{ + int a; + int c; + int d; + int e; + int f[10]; + int g; + float h[10]; + int i[10]; + float j; + int l; + int m; + a = 0; + while (a < 65536) + { + int o[32]; + o[0] = a; + a = a + 1; + } + output(0); + c = d = e = 3; + output(c); + output(d); + output(e); + f[3] = 1024; + q(f); + g = addone(addone(addone(addone(1230)))); + output(g); + h[3] = 3.14; + r(h); + i[3] = 10; + s(i); + j = 10; + t(j); + l = 4.5; + u(l); + m = 10; + t(m); + output(v()); + output(w()); + output(x()); + outputFloat(y()); + return; +} diff --git a/tests/4-opt/testcases/2_lab2_lv2.out b/tests/4-opt/testcases/2_lab2_lv2.out new file mode 100644 index 0000000000000000000000000000000000000000..ebe26c89001e71f8e7eeafa1272e528cfefde902 --- /dev/null +++ b/tests/4-opt/testcases/2_lab2_lv2.out @@ -0,0 +1,17 @@ +0 +3 +3 +3 +1024 +1024 +1234 +3 +10 +10 +4.000000 +10 +0 +0 +233 +7.000000 +0 diff --git a/tests/4-opt/testcases/3_complex1.cminus b/tests/4-opt/testcases/3_complex1.cminus new file mode 100644 index 0000000000000000000000000000000000000000..968827740377e07c2482c42a5814430cfd25226c --- /dev/null +++ b/tests/4-opt/testcases/3_complex1.cminus @@ -0,0 +1,77 @@ +/* + This code is adapted from Dik T. Winter at CWI + It computes pi to 800 decimal digits + */ + +int mod(int a, int b) { return a - a / b * b; } + +void printfour(int input) +{ + int a; + int b; + int c; + int d; + input = mod(input, 10000); + d = mod(input, 10); + input = input / 10; + c = mod(input, 10); + input = input / 10; + b = mod(input, 10); + input = input / 10; + a = input; + output(a); + output(b); + output(c); + output(d); + return; +} + +void main(void) +{ + int r[2801]; + int i; + int k; + int b; + int d; + int c; + c = 0; + d = 1234; + + { + int mod; + mod = 0; + while (mod < 2800) + { + r[mod] = 2000; + mod = mod + 1; + } + } + + k = 2800; + while (k) + { + int d; + d = 0; + i = k; + + while (i != 0) + { + d = d + r[i] * 10000; + b = 2 * i - 1; + r[i] = mod(d, b); + d = d / b; + i = i - 1; + if (i != 0) + { + d = d * i; + } + } + + printfour(c + d / 10000); + c = mod(d, 10000); + + k = k - 14; + } + + return; +} diff --git a/tests/4-opt/testcases/3_complex1.out b/tests/4-opt/testcases/3_complex1.out new file mode 100644 index 0000000000000000000000000000000000000000..068ee2c354b24848aa6e811b03e4135acde28da6 --- /dev/null +++ b/tests/4-opt/testcases/3_complex1.out @@ -0,0 +1,801 @@ +3 +1 +4 +1 +5 +9 +2 +6 +5 +3 +5 +8 +9 +7 +9 +3 +2 +3 +8 +4 +6 +2 +6 +4 +3 +3 +8 +3 +2 +7 +9 +5 +0 +2 +8 +8 +4 +1 +9 +7 +1 +6 +9 +3 +9 +9 +3 +7 +5 +1 +0 +5 +8 +2 +0 +9 +7 +4 +9 +4 +4 +5 +9 +2 +3 +0 +7 +8 +1 +6 +4 +0 +6 +2 +8 +6 +2 +0 +8 +9 +9 +8 +6 +2 +8 +0 +3 +4 +8 +2 +5 +3 +4 +2 +1 +1 +7 +0 +6 +7 +9 +8 +2 +1 +4 +8 +0 +8 +6 +5 +1 +3 +2 +8 +2 +3 +0 +6 +6 +4 +7 +0 +9 +3 +8 +4 +4 +6 +0 +9 +5 +5 +0 +5 +8 +2 +2 +3 +1 +7 +2 +5 +3 +5 +9 +4 +0 +8 +1 +2 +8 +4 +8 +1 +1 +1 +7 +4 +5 +0 +2 +8 +4 +1 +0 +2 +7 +0 +1 +9 +3 +8 +5 +2 +1 +1 +0 +5 +5 +5 +9 +6 +4 +4 +6 +2 +2 +9 +4 +8 +9 +5 +4 +9 +3 +0 +3 +8 +1 +9 +6 +4 +4 +2 +8 +8 +1 +0 +9 +7 +5 +6 +6 +5 +9 +3 +3 +4 +4 +6 +1 +2 +8 +4 +7 +5 +6 +4 +8 +2 +3 +3 +7 +8 +6 +7 +8 +3 +1 +6 +5 +2 +7 +1 +2 +0 +1 +9 +0 +9 +1 +4 +5 +6 +4 +8 +5 +6 +6 +9 +2 +3 +4 +6 +0 +3 +4 +8 +6 +1 +0 +4 +5 +4 +3 +2 +6 +6 +4 +8 +2 +1 +3 +3 +9 +3 +6 +0 +7 +2 +6 +0 +2 +4 +9 +1 +4 +1 +2 +7 +3 +7 +2 +4 +5 +8 +7 +0 +0 +6 +6 +0 +6 +3 +1 +5 +5 +8 +8 +1 +7 +4 +8 +8 +1 +5 +2 +0 +9 +2 +0 +9 +6 +2 +8 +2 +9 +2 +5 +4 +0 +9 +1 +7 +1 +5 +3 +6 +4 +3 +6 +7 +8 +9 +2 +5 +9 +0 +3 +6 +0 +0 +1 +1 +3 +3 +0 +5 +3 +0 +5 +4 +8 +8 +2 +0 +4 +6 +6 +5 +2 +1 +3 +8 +4 +1 +4 +6 +9 +5 +1 +9 +4 +1 +5 +1 +1 +6 +0 +9 +4 +3 +3 +0 +5 +7 +2 +7 +0 +3 +6 +5 +7 +5 +9 +5 +9 +1 +9 +5 +3 +0 +9 +2 +1 +8 +6 +1 +1 +7 +3 +8 +1 +9 +3 +2 +6 +1 +1 +7 +9 +3 +1 +0 +5 +1 +1 +8 +5 +4 +8 +0 +7 +4 +4 +6 +2 +3 +7 +9 +9 +6 +2 +7 +4 +9 +5 +6 +7 +3 +5 +1 +8 +8 +5 +7 +5 +2 +7 +2 +4 +8 +9 +1 +2 +2 +7 +9 +3 +8 +1 +8 +3 +0 +1 +1 +9 +4 +9 +1 +2 +9 +8 +3 +3 +6 +7 +3 +3 +6 +2 +4 +4 +0 +6 +5 +6 +6 +4 +3 +0 +8 +6 +0 +2 +1 +3 +9 +4 +9 +4 +6 +3 +9 +5 +2 +2 +4 +7 +3 +7 +1 +9 +0 +7 +0 +2 +1 +7 +9 +8 +6 +0 +9 +4 +3 +7 +0 +2 +7 +7 +0 +5 +3 +9 +2 +1 +7 +1 +7 +6 +2 +9 +3 +1 +7 +6 +7 +5 +2 +3 +8 +4 +6 +7 +4 +8 +1 +8 +4 +6 +7 +6 +6 +9 +4 +0 +5 +1 +3 +2 +0 +0 +0 +5 +6 +8 +1 +2 +7 +1 +4 +5 +2 +6 +3 +5 +6 +0 +8 +2 +7 +7 +8 +5 +7 +7 +1 +3 +4 +2 +7 +5 +7 +7 +8 +9 +6 +0 +9 +1 +7 +3 +6 +3 +7 +1 +7 +8 +7 +2 +1 +4 +6 +8 +4 +4 +0 +9 +0 +1 +2 +2 +4 +9 +5 +3 +4 +3 +0 +1 +4 +6 +5 +4 +9 +5 +8 +5 +3 +7 +1 +0 +5 +0 +7 +9 +2 +2 +7 +9 +6 +8 +9 +2 +5 +8 +9 +2 +3 +5 +4 +2 +0 +1 +9 +9 +5 +6 +1 +1 +2 +1 +2 +9 +0 +2 +1 +9 +6 +0 +8 +6 +4 +0 +3 +4 +4 +1 +8 +1 +5 +9 +8 +1 +3 +6 +2 +9 +7 +7 +4 +7 +7 +1 +3 +0 +9 +9 +6 +0 +5 +1 +8 +7 +0 +7 +2 +1 +1 +3 +4 +9 +9 +9 +9 +9 +9 +8 +3 +7 +2 +9 +7 +8 +0 +4 +9 +9 +5 +1 +0 +5 +9 +7 +3 +1 +7 +3 +2 +8 +1 +6 +0 +9 +6 +3 +1 +8 +5 +0 diff --git a/tests/4-opt/testcases/4_complex2.cminus b/tests/4-opt/testcases/4_complex2.cminus new file mode 100755 index 0000000000000000000000000000000000000000..f44dd25e157c50bc8300efb828325405ebe0dc80 --- /dev/null +++ b/tests/4-opt/testcases/4_complex2.cminus @@ -0,0 +1,59 @@ +/* this is the sample program in C- in the book "Compiler Construction" */ +/* A program to perform selection sort on a 10 element array. */ +float x[10]; + +int minloc(float a[], float low, int high) +{ + int i; + int x; + int k; + k = low; + x = a[low]; + i = low + 1; + while (i < high) + { + if (a[i] < x) + { + x = a[i]; + k = i; + } + i = i + 1; + } + return k; +} + +void sort(float a[], int low, float high) +{ + int i; + int k; + i = low; + while (i < high - 1) + { + int t; + k = minloc(a, i, high); + t = a[k]; + a[k] = a[i]; + a[i] = t; + i = i + 1; + } + return; +} + +void main(void) +{ + int i; + i = 0; + while (i < 10) + { + x[i] = input(); + i = i + 1; + } + sort(x, 0, 10); + i = 0; + while (i < 10) + { + output(x[i]); + i = i + 1; + } + return; +} diff --git a/tests/4-opt/testcases/4_complex2.in b/tests/4-opt/testcases/4_complex2.in new file mode 100755 index 0000000000000000000000000000000000000000..ba6e481592b31ff68ad338a32ff6f4fdff724f12 --- /dev/null +++ b/tests/4-opt/testcases/4_complex2.in @@ -0,0 +1,10 @@ +9 +8 +7 +6 +5 +4 +3 +2 +1 +0 diff --git a/tests/4-opt/testcases/functional-cases/5-while.out b/tests/4-opt/testcases/4_complex2.out old mode 100644 new mode 100755 similarity index 100% rename from tests/4-opt/testcases/functional-cases/5-while.out rename to tests/4-opt/testcases/4_complex2.out diff --git a/tests/4-opt/testcases/5_complex3.cminus b/tests/4-opt/testcases/5_complex3.cminus new file mode 100755 index 0000000000000000000000000000000000000000..e5285c7204e49534be96f62df87bf22e8d0672bd --- /dev/null +++ b/tests/4-opt/testcases/5_complex3.cminus @@ -0,0 +1,25 @@ +int gcd(int u, int v) +{ + if (v == 0) + return u; + else + return gcd(v, u - u / v * v); +} + +void main(void) +{ + int x; + int y; + int temp; + x = input(); + y = input(); + if (x < y) + { + temp = x; + x = y; + y = temp; + } + temp = gcd(x, y); + output(temp); + return; +} diff --git a/tests/4-opt/testcases/5_complex3.in b/tests/4-opt/testcases/5_complex3.in new file mode 100755 index 0000000000000000000000000000000000000000..50a3a30207190ecbfc3889b758bec1dc4cac547a --- /dev/null +++ b/tests/4-opt/testcases/5_complex3.in @@ -0,0 +1,2 @@ +78 +117 diff --git a/tests/4-opt/testcases/5_complex3.out b/tests/4-opt/testcases/5_complex3.out new file mode 100755 index 0000000000000000000000000000000000000000..435a54d44e490099aa17f50c8fbe990008507fe2 --- /dev/null +++ b/tests/4-opt/testcases/5_complex3.out @@ -0,0 +1,2 @@ +39 +0 diff --git a/tests/4-opt/testcases/6_complex4.cminus b/tests/4-opt/testcases/6_complex4.cminus new file mode 100755 index 0000000000000000000000000000000000000000..cbd8f942712340eecf642341b41fcf41ae1de398 --- /dev/null +++ b/tests/4-opt/testcases/6_complex4.cminus @@ -0,0 +1,122 @@ +float get(float a[], int x, int y, int row) { return a[x * row + y]; } + +float abs(float x) +{ + if (x > 0) + return x; + else + return 0 - x; +} + +float isZero(float t) { return abs(t) < 0.000001; } + +int gauss(float vars[], float equ[], int var) +{ + int i; + int j; + int k; + int varone; + int maxr; + int col; + float temp; + varone = var + 1; + + i = 0; + while (i < var) + { + vars[i] = 0; + i = i + 1; + } + + col = 0; + k = 0; + while (k < var) + { + maxr = k; + i = k + 1; + while (i < var) + { + if (abs(get(equ, i, col, varone)) > abs(get(equ, maxr, col, varone))) + maxr = i; + i = i + 1; + } + if (maxr != k) + { + j = k; + + while (j < varone) + { + temp = get(equ, k, j, varone); + equ[k * varone + j] = get(equ, maxr, j, varone); + equ[maxr * varone + j] = temp; + j = j + 1; + } + } + if (isZero(get(equ, k, col, varone))) + { + k = k - 1; + } + else + { + i = k + 1; + while (i < var) + { + if (1 - isZero(get(equ, i, col, varone))) + { + temp = get(equ, i, col, varone) / get(equ, k, col, varone); + j = col; + while (j < varone) + { + equ[i * varone + j] = equ[i * varone + j] - get(equ, k, j, varone) * temp; + j = j + 1; + } + } + i = i + 1; + } + } + k = k + 1; + col = col + 1; + } + + i = var - 1; + while (i >= 0) + { + temp = get(equ, i, var, varone); + j = i + 1; + while (j < var) + { + if (1 - isZero(get(equ, i, j, varone))) + temp = temp - get(equ, i, j, varone) * vars[j]; + j = j + 1; + } + vars[i] = temp / get(equ, i, i, varone); + i = i - 1; + } + return 0; +} + +void main(void) +{ + int num; + float vars[3]; + float equ[12]; + equ[0] = 1; + equ[1] = 2; + equ[2] = 1; + equ[3] = 1; + equ[1 * 4 + 0] = 2; + equ[1 * 4 + 1] = 3; + equ[1 * 4 + 2] = 4; + equ[1 * 4 + 3] = 3; + equ[2 * 4 + 0] = 1; + equ[2 * 4 + 1] = 1; + equ[2 * 4 + 2] = 0 - 2; + equ[2 * 4 + 3] = 0; + gauss(vars, equ, 3); + num = 0; + while (num < 3) + { + outputFloat(vars[num]); + num = num + 1; + } +} diff --git a/tests/4-opt/testcases/6_complex4.out b/tests/4-opt/testcases/6_complex4.out new file mode 100755 index 0000000000000000000000000000000000000000..02d220552cf38a24306079bff2f7a0dfd0fc0699 --- /dev/null +++ b/tests/4-opt/testcases/6_complex4.out @@ -0,0 +1,4 @@ +1.000000 +-0.200000 +0.400000 +0 diff --git a/tests/4-opt/testcases/7_return_early.cminus b/tests/4-opt/testcases/7_return_early.cminus new file mode 100644 index 0000000000000000000000000000000000000000..69ca5c104f43ec83326169cddf7a884413db84c1 --- /dev/null +++ b/tests/4-opt/testcases/7_return_early.cminus @@ -0,0 +1,44 @@ +int main(void) +{ + int b; + int a; + int flags[10]; + a = 0; + b = input(); + while (a < 10) + { + flags[a] = b * 2; + a = a + 1; + } + if (a > 1) + { + if (a < 10) + { + return 7; + } + else + { + return 2; + } + } + else + { + return 3; + } + while (a < 10) + { + int b; + b = 0; + while (b < 10) + { + b = b + 1; + flags[b] = flags[a]; + if (flags[a + b] < flags[a * b]) + { + return 4; + } + } + a = a + 1; + } + return 5; +} diff --git a/tests/4-opt/testcases/7_return_early.in b/tests/4-opt/testcases/7_return_early.in new file mode 100644 index 0000000000000000000000000000000000000000..00750edc07d6415dcc07ae0351e9397b0222b7ba --- /dev/null +++ b/tests/4-opt/testcases/7_return_early.in @@ -0,0 +1 @@ +3 diff --git a/tests/4-opt/testcases/7_return_early.out b/tests/4-opt/testcases/7_return_early.out new file mode 100644 index 0000000000000000000000000000000000000000..0cfbf08886fca9a91cb753ec8734c84fcbe52c9f --- /dev/null +++ b/tests/4-opt/testcases/7_return_early.out @@ -0,0 +1 @@ +2 diff --git a/tests/4-opt/testcases/8_licm0.cminus b/tests/4-opt/testcases/8_licm0.cminus new file mode 100644 index 0000000000000000000000000000000000000000..933411079b34450b5a64fd35af2d229be0ddd585 --- /dev/null +++ b/tests/4-opt/testcases/8_licm0.cminus @@ -0,0 +1,104 @@ +int ga; +int gb; + +int pure(int m, int n) { return m * n; } +int f(int m, int n) { return m * n + ga; } + +int g(int m, int n) +{ + ga = m + n; + return m * n + gb; +} + +int notsopure(void) +{ + return input(); +} + +int main(void) +{ + int t; + int a; + int b; + int c; + int d; + int ar[4]; + int br[4]; + int cr[4]; + t = 0; + while (t < 4) + { + cr[t] = notsopure(); + t = t + 1; + } + t = 0; + c = 1; + while (t < 10) + { + a = pure(c, c); + b = pure(a, c); + d = pure(b, t); + output(a + b + d); + t = t + 1; + } + t = 0; + while (t < 10) + { + a = pure(ga, c); + b = f(gb, c); + output(a + b); + t = t + 1; + } + t = 0; + while (t < 10) + { + a = f(gb, c); + b = f(c, c); + d = pure(gb, c); + d = d + g(c, c); + output(a + b + d); + t = t + 1; + } + t = 0; + while (t < 10) + { + if (t < 5) + { + a = c * 2; + } + else + { + a = c * 3; + } + output(a); + t = t + 1; + } + t = 0; + while (t < 4) + { + ar[t] = 1 + t; + br[t] = 1 - t; + t = t + 1; + } + t = 0; + while (t < 4) + { + int s; + s = 0; + while (s < 4) + { + cr[t] = cr[t] + ar[t] * br[s] + ga + gb; + s = s + 1; + gb = gb + 1; + } + t = t + 1; + ga = ga + 1; + } + t = 0; + while (t < 4) + { + output(cr[t]); + t = t + 1; + } + return 0; +} diff --git a/tests/4-opt/testcases/8_licm0.in b/tests/4-opt/testcases/8_licm0.in new file mode 100644 index 0000000000000000000000000000000000000000..94ebaf900161394059478fd88aec30e59092a1d7 --- /dev/null +++ b/tests/4-opt/testcases/8_licm0.in @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/tests/4-opt/testcases/8_licm0.out b/tests/4-opt/testcases/8_licm0.out new file mode 100644 index 0000000000000000000000000000000000000000..55a2cc34d289a2e32c719eb0d684a8d62dbd5a5f --- /dev/null +++ b/tests/4-opt/testcases/8_licm0.out @@ -0,0 +1,45 @@ +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +6 +6 +6 +6 +6 +6 +6 +6 +6 +2 +2 +2 +2 +2 +3 +3 +3 +3 +3 +13 +32 +51 +70 +0 diff --git a/tests/4-opt/testcases/9_licm_bad.cminus b/tests/4-opt/testcases/9_licm_bad.cminus new file mode 100644 index 0000000000000000000000000000000000000000..1ce2a95c4e27431b7ee4b530f69c05e2e66d4e5a --- /dev/null +++ b/tests/4-opt/testcases/9_licm_bad.cminus @@ -0,0 +1,27 @@ + + +int main(void) { + int t; + int a; + int b; + t = 0; + b = 1; + while (t < 0) { + a = b / b + b * b + a; + a = b / b + b * b + a; + t = t + 1; + } + while (t < 1) { + if (b > 2) { + a = b / b + b * b + a; + a = b / b + b * b + a; + } else + output(t); + t = t + 1; + } + while (t < 3) { + a = b / b + b * b + a; + t = t + 1; + } + return a; +} diff --git a/tests/4-opt/testcases/loop/loop-1.out b/tests/4-opt/testcases/9_licm_bad.out similarity index 50% rename from tests/4-opt/testcases/loop/loop-1.out rename to tests/4-opt/testcases/9_licm_bad.out index aa47d0d46d47a06090f436b0b851b76bb6f3b6e2..4f1d7cd301262e994b4343b2d4b3494063c05642 100644 --- a/tests/4-opt/testcases/loop/loop-1.out +++ b/tests/4-opt/testcases/9_licm_bad.out @@ -1,2 +1,2 @@ 0 -0 +4 diff --git a/tests/4-opt/testcases/functional-cases/0-io.cminus b/tests/4-opt/testcases/functional-cases/0-io.cminus deleted file mode 100644 index b73460e6f70228dfa1ce758f5b9182131c7d46dc..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/0-io.cminus +++ /dev/null @@ -1,4 +0,0 @@ -int main(void) { - output(input()); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/0-io.in b/tests/4-opt/testcases/functional-cases/0-io.in deleted file mode 100644 index 81c545efebe5f57d4cab2ba9ec294c4b0cadf672..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/0-io.in +++ /dev/null @@ -1 +0,0 @@ -1234 diff --git a/tests/4-opt/testcases/functional-cases/0-io.out b/tests/4-opt/testcases/functional-cases/0-io.out deleted file mode 100644 index 2b8eb81b54b5e42caf8d751595e576f6aebe7a42..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/0-io.out +++ /dev/null @@ -1,2 +0,0 @@ -1234 -0 diff --git a/tests/4-opt/testcases/functional-cases/1-return.cminus b/tests/4-opt/testcases/functional-cases/1-return.cminus deleted file mode 100644 index 91e77f24ebc661dcf7fb22883bb8ef52ccddae93..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/1-return.cminus +++ /dev/null @@ -1,4 +0,0 @@ -int main(void) { - output(111); - return 111; -} diff --git a/tests/4-opt/testcases/functional-cases/1-return.out b/tests/4-opt/testcases/functional-cases/1-return.out deleted file mode 100644 index 2bbe845f4ef76194eda16eaad3b846e7ba014516..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/1-return.out +++ /dev/null @@ -1,2 +0,0 @@ -111 -111 diff --git a/tests/4-opt/testcases/functional-cases/10-float.cminus b/tests/4-opt/testcases/functional-cases/10-float.cminus deleted file mode 100644 index 8de09f6119d7244a7df03187440e8469ef66dc96..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/10-float.cminus +++ /dev/null @@ -1,19 +0,0 @@ -int main(void) { - float a; - float b; - float c; - - a = 1.1; - b = 1.5; - c = 1.2; - - outputFloat(a * b + c); - return 0; -} - -/* - 用 gcc 编译此文件生成汇编代码时,命令为 gcc -include io.h -S 10-float.c - 其中 io.h 位于 src/io/io.h, - - 也可以在本文件开头加上 void outputFloat(float x); -*/ diff --git a/tests/4-opt/testcases/functional-cases/10-float.out b/tests/4-opt/testcases/functional-cases/10-float.out deleted file mode 100644 index 28c52e755c337283648fc20a7ade4ac29a98574f..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/10-float.out +++ /dev/null @@ -1,2 +0,0 @@ -2.850000 -0 diff --git a/tests/4-opt/testcases/functional-cases/11-floatcall.cminus b/tests/4-opt/testcases/functional-cases/11-floatcall.cminus deleted file mode 100644 index 23f73d7efb499b59c207c6730c8d4f3e356b3c1c..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/11-floatcall.cminus +++ /dev/null @@ -1,18 +0,0 @@ -/* float function call */ - -float mod(float x, float y) { - int div; - div = x / y; - return x - div * y; -} - -int main(void) { - float a; - float b; - - a = 11.2; - b = 2.2; - - outputFloat(mod(a, b)); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/11-floatcall.out b/tests/4-opt/testcases/functional-cases/11-floatcall.out deleted file mode 100644 index e1765193609cecdd1a26474b060effe9b0d36b69..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/11-floatcall.out +++ /dev/null @@ -1,2 +0,0 @@ -0.200000 -0 diff --git a/tests/4-opt/testcases/functional-cases/12-global.cminus b/tests/4-opt/testcases/functional-cases/12-global.cminus deleted file mode 100644 index 63bddbbd3feeca9e8abdedab92c3ef9bcf31b88f..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/12-global.cminus +++ /dev/null @@ -1,47 +0,0 @@ -int seed; - -int randomLCG(void) { - seed = seed * 1103515245 + 12345; - return seed; -} - -int randBin(void) { - if (randomLCG() > 0) - return 1; - else - return 0; -} - -/* random walk */ -int returnToZeroSteps(void) { - int x; - int steps; - - x = 0; - steps = 0; - - while (steps < 20) { - if (randBin()) - x = x + 1; - else - x = x - 1; - - steps = steps + 1; - if (x == 0) - return steps; - } - return 20; -} - -int main(void) { - int i; - i = 0; - - seed = 3407; - - while (i < 20) { - output(returnToZeroSteps()); - i = i + 1; - } - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/12-global.out b/tests/4-opt/testcases/functional-cases/12-global.out deleted file mode 100644 index 66bb32318d81ec4cac480a518a337e5c7aa5c632..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/12-global.out +++ /dev/null @@ -1,21 +0,0 @@ -4 -2 -2 -4 -8 -2 -2 -2 -2 -2 -6 -2 -10 -8 -4 -2 -20 -2 -2 -8 -0 diff --git a/tests/4-opt/testcases/functional-cases/13-complex.cminus b/tests/4-opt/testcases/functional-cases/13-complex.cminus deleted file mode 100644 index 22232fb669dadf8765c62b62df913bbe657817c0..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/13-complex.cminus +++ /dev/null @@ -1,67 +0,0 @@ -/* 01 背包问题 */ - -int n; -int m; - -int w[5]; -int v[5]; - -int dp[66]; /* dp[n * 11 + size] 表示前 n 个物品放入容量为 size 的背包中的最大价值,初始化为 -1 */ - -int max(int a, int b) { - if (a > b) - return a; - else - return b; -} - -/* 状态转移方程: - dp[n][size] = max(dp[n - 1][size], dp[n - 1][size - w[n]] + v[n]) - 边界条件: - dp[n][size <= 0] = 0 - dp[0][size] = 0 */ - -int knapsack(int n, int size) { - int result; - if (size <= 0) - return 0; - if (n == 0) - return 0; - if (dp[n * 11 + size] >= 0) - return dp[n * 11 + size]; - - if (size < w[n - 1]) - result = knapsack(n - 1, size); - else - result = max(knapsack(n - 1, size), knapsack(n - 1, size - w[n - 1]) + v[n - 1]); - - dp[n * 11 + size] = result; - return result; -} - -int main(void) { - int i; - i = 0; - - n = 5; - m = 10; - w[0] = 2; - w[1] = 2; - w[2] = 6; - w[3] = 5; - w[4] = 4; - - v[0] = 6; - v[1] = 3; - v[2] = 5; - v[3] = 4; - v[4] = 6; - - while (i < 66) { - dp[i] = 0 - 1; - i = i + 1; - } - - output(knapsack(n, m)); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/13-complex.out b/tests/4-opt/testcases/functional-cases/13-complex.out deleted file mode 100644 index 227eae2e84c4aa04d74e2afd977a8c52936dfaec..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/13-complex.out +++ /dev/null @@ -1,2 +0,0 @@ -15 -0 diff --git a/tests/4-opt/testcases/functional-cases/2-calculate.cminus b/tests/4-opt/testcases/functional-cases/2-calculate.cminus deleted file mode 100644 index fa4c9a1f341e58aff1d0f07e3f67ff26388c2415..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/2-calculate.cminus +++ /dev/null @@ -1,11 +0,0 @@ -int main(void) { - int a; - int b; - int c; - - a = 23; - b = 25; - c = 4; - - return a + b * c; -} diff --git a/tests/4-opt/testcases/functional-cases/2-calculate.out b/tests/4-opt/testcases/functional-cases/2-calculate.out deleted file mode 100644 index 190a18037c64c43e6b11489df4bf0b9eb6d2c9bf..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/2-calculate.out +++ /dev/null @@ -1 +0,0 @@ -123 diff --git a/tests/4-opt/testcases/functional-cases/3-output.cminus b/tests/4-opt/testcases/functional-cases/3-output.cminus deleted file mode 100644 index abe3222400d6ff8d1ac2e7e589011d97f2e23b06..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/3-output.cminus +++ /dev/null @@ -1,5 +0,0 @@ -int main(void) { - output(11); - output(22222); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/3-output.out b/tests/4-opt/testcases/functional-cases/3-output.out deleted file mode 100644 index 1983173f37dfac419ee2c5b5997f62d240be0d65..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/3-output.out +++ /dev/null @@ -1,3 +0,0 @@ -11 -22222 -0 diff --git a/tests/4-opt/testcases/functional-cases/4-if.cminus b/tests/4-opt/testcases/functional-cases/4-if.cminus deleted file mode 100644 index a4ba887f31161281363c4da0a69cc88a263de299..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/4-if.cminus +++ /dev/null @@ -1,23 +0,0 @@ -int main(void) { - int a; - int b; - int c; - - a = 11; - b = 22; - c = 33; - - /* max value */ - if (a > b) { - if (a > c) - output(a); - else - output(c); - } else { - if (c < b) - output(b); - else - output(c); - } - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/4-if.out b/tests/4-opt/testcases/functional-cases/4-if.out deleted file mode 100644 index 54a647cf204067321a9819d900b92ee655f99428..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/4-if.out +++ /dev/null @@ -1,2 +0,0 @@ -33 -0 diff --git a/tests/4-opt/testcases/functional-cases/5-while.cminus b/tests/4-opt/testcases/functional-cases/5-while.cminus deleted file mode 100644 index da3313b91c0c519a1af8c0aa98e7127fe400436c..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/5-while.cminus +++ /dev/null @@ -1,14 +0,0 @@ -int main(void) { - int n; - int i; - - n = 10; - i = 0; - - while (i < n) { - output(i); - i = i + 1; - } - - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/6-array.cminus b/tests/4-opt/testcases/functional-cases/6-array.cminus deleted file mode 100644 index 3383fcafa1c07a12cf3d3780fc4509e781ef0022..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/6-array.cminus +++ /dev/null @@ -1,15 +0,0 @@ -int main(void) { - int a[10]; - int i; - - i = 0; - a[0] = 11; - a[4] = 22; - a[9] = 33; - - output(a[0]); - output(a[4]); - output(a[9]); - - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/6-array.out b/tests/4-opt/testcases/functional-cases/6-array.out deleted file mode 100644 index d7fcd8c808df07b274ae64b8754e1617b37003aa..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/6-array.out +++ /dev/null @@ -1,4 +0,0 @@ -11 -22 -33 -0 diff --git a/tests/4-opt/testcases/functional-cases/7-function.cminus b/tests/4-opt/testcases/functional-cases/7-function.cminus deleted file mode 100644 index 2eb2620d1110b06d1f07ab51fbff8343e41b510c..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/7-function.cminus +++ /dev/null @@ -1,21 +0,0 @@ -int min(int a, int b) { - if (a <= b) - return a; - else - return b; -} - -int main(void) { - int a; - int b; - int c; - - a = 11; - b = 22; - c = 33; - - output(min(a, b)); - output(min(b, c)); - output(min(c, a)); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/7-function.out b/tests/4-opt/testcases/functional-cases/7-function.out deleted file mode 100644 index 38ea32361a25780c6da08b24aead9a02d32c3f0c..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/7-function.out +++ /dev/null @@ -1,4 +0,0 @@ -11 -22 -11 -0 diff --git a/tests/4-opt/testcases/functional-cases/8-store.cminus b/tests/4-opt/testcases/functional-cases/8-store.cminus deleted file mode 100644 index 15a438d24d427ad15ce892d4ce25102e6154113f..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/8-store.cminus +++ /dev/null @@ -1,26 +0,0 @@ -int store(int arr[], int index, int value) { - arr[index] = value; - return value; -} - -int main(void) { - int a[10]; - int i; - int sum; - - i = 0; - while (i < 10) { - store(a, i, i * 2); - i = i + 1; - } - - sum = 0; - i = 0; - while (i < 10) { - sum = sum + a[i]; - i = i + 1; - } - - output(sum); - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/8-store.out b/tests/4-opt/testcases/functional-cases/8-store.out deleted file mode 100644 index d2044a0e5daa8e8d2ed3a54a15127b6c919eb4f4..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/8-store.out +++ /dev/null @@ -1,2 +0,0 @@ -90 -0 diff --git a/tests/4-opt/testcases/functional-cases/9-fibonacci.cminus b/tests/4-opt/testcases/functional-cases/9-fibonacci.cminus deleted file mode 100644 index df0ee724c115a1339d59ae260be5519ea3b41c14..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/9-fibonacci.cminus +++ /dev/null @@ -1,23 +0,0 @@ -int fibonacci(int n) { - if (n == 0) - return 0; - else if (n == 1) - return 1; - else - return fibonacci(n - 1) + fibonacci(n - 2); -} - -int main(void) { - int n; - int i; - - n = 10; - i = 0; - - while (i < n) { - output(fibonacci(i)); - i = i + 1; - } - - return 0; -} diff --git a/tests/4-opt/testcases/functional-cases/9-fibonacci.out b/tests/4-opt/testcases/functional-cases/9-fibonacci.out deleted file mode 100644 index f53d098dcdc78d4553b72ce722b2d7e0b055435e..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/functional-cases/9-fibonacci.out +++ /dev/null @@ -1,11 +0,0 @@ -0 -1 -1 -2 -3 -5 -8 -13 -21 -34 -0 diff --git a/tests/4-opt/testcases/loop/baseline/loop-1.ll b/tests/4-opt/testcases/loop/baseline/loop-1.ll deleted file mode 100644 index 5b37e400aa0b0018405a8f950dc5d72192ebcee6..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/baseline/loop-1.ll +++ /dev/null @@ -1,60 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/haiqwa/2020fall-compiler_cminus/tests/lab5/./testcases/LoopInvHoist/testcase-5.cminus" - -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - br label %label3 -label3: ; preds = %label_entry, %label58 - %op61 = phi i32 [ %op64, %label58 ], [ undef, %label_entry ] - %op62 = phi i32 [ 1, %label_entry ], [ %op60, %label58 ] - %op63 = phi i32 [ %op65, %label58 ], [ undef, %label_entry ] - %op5 = icmp slt i32 %op62, 10000 - %op6 = zext i1 %op5 to i32 - %op7 = icmp ne i32 %op6, 0 - br i1 %op7, label %label8, label %label9 -label8: ; preds = %label3 - %op19 = mul i32 %op62, %op62 - %op21 = mul i32 %op19, %op62 - %op23 = mul i32 %op21, %op62 - %op25 = mul i32 %op23, %op62 - %op27 = mul i32 %op25, %op62 - %op29 = mul i32 %op27, %op62 - %op31 = mul i32 %op29, %op62 - %op33 = mul i32 %op31, %op62 - %op35 = mul i32 %op33, %op62 - %op37 = sdiv i32 %op35, %op62 - %op39 = sdiv i32 %op37, %op62 - %op41 = sdiv i32 %op39, %op62 - %op43 = sdiv i32 %op41, %op62 - %op45 = sdiv i32 %op43, %op62 - %op47 = sdiv i32 %op45, %op62 - %op49 = sdiv i32 %op47, %op62 - %op51 = sdiv i32 %op49, %op62 - %op53 = sdiv i32 %op51, %op62 - %op55 = sdiv i32 %op53, %op62 - br label %label11 -label9: ; preds = %label3 - call void @output(i32 %op61) - ret void -label11: ; preds = %label8, %label16 - %op64 = phi i32 [ %op61, %label8 ], [ %op55, %label16 ] - %op65 = phi i32 [ 0, %label8 ], [ %op57, %label16 ] - %op13 = icmp slt i32 %op65, 10000 - %op14 = zext i1 %op13 to i32 - %op15 = icmp ne i32 %op14, 0 - br i1 %op15, label %label16, label %label58 -label16: ; preds = %label11 - %op57 = add i32 %op65, 1 - br label %label11 -label58: ; preds = %label11 - %op60 = add i32 %op62, 1 - br label %label3 -} diff --git a/tests/4-opt/testcases/loop/baseline/loop-2.ll b/tests/4-opt/testcases/loop/baseline/loop-2.ll deleted file mode 100644 index d0983dd2ce7149344170278b5aebc7f09fd44e49..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/baseline/loop-2.ll +++ /dev/null @@ -1,60 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/haiqwa/2020fall-compiler_cminus/tests/lab5/./testcases/LoopInvHoist/testcase-6.cminus" - -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - %op20 = mul i32 2, 2 - %op22 = mul i32 %op20, 2 - %op24 = mul i32 %op22, 2 - %op26 = mul i32 %op24, 2 - %op28 = mul i32 %op26, 2 - %op30 = mul i32 %op28, 2 - %op32 = mul i32 %op30, 2 - %op34 = mul i32 %op32, 2 - %op36 = mul i32 %op34, 2 - %op38 = sdiv i32 %op36, 2 - %op40 = sdiv i32 %op38, 2 - %op42 = sdiv i32 %op40, 2 - %op44 = sdiv i32 %op42, 2 - %op46 = sdiv i32 %op44, 2 - %op48 = sdiv i32 %op46, 2 - %op50 = sdiv i32 %op48, 2 - %op52 = sdiv i32 %op50, 2 - %op54 = sdiv i32 %op52, 2 - %op56 = sdiv i32 %op54, 2 - br label %label4 -label4: ; preds = %label_entry, %label59 - %op62 = phi i32 [ %op65, %label59 ], [ undef, %label_entry ] - %op63 = phi i32 [ 0, %label_entry ], [ %op61, %label59 ] - %op64 = phi i32 [ %op66, %label59 ], [ undef, %label_entry ] - %op6 = icmp slt i32 %op63, 10000000 - %op7 = zext i1 %op6 to i32 - %op8 = icmp ne i32 %op7, 0 - br i1 %op8, label %label9, label %label10 -label9: ; preds = %label4 - br label %label12 -label10: ; preds = %label4 - call void @output(i32 %op62) - ret void -label12: ; preds = %label9, %label17 - %op65 = phi i32 [ %op62, %label9 ], [ %op56, %label17 ] - %op66 = phi i32 [ 0, %label9 ], [ %op58, %label17 ] - %op14 = icmp slt i32 %op66, 2 - %op15 = zext i1 %op14 to i32 - %op16 = icmp ne i32 %op15, 0 - br i1 %op16, label %label17, label %label59 -label17: ; preds = %label12 - %op58 = add i32 %op66, 1 - br label %label12 -label59: ; preds = %label12 - %op61 = add i32 %op63, 1 - br label %label4 -} diff --git a/tests/4-opt/testcases/loop/baseline/loop-3.ll b/tests/4-opt/testcases/loop/baseline/loop-3.ll deleted file mode 100644 index 257f877af5010ff1fa2fa4e51082c0e0cec6c6f6..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/baseline/loop-3.ll +++ /dev/null @@ -1,119 +0,0 @@ -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - %op60 = mul i32 2, 2 - %op62 = mul i32 %op60, 2 - %op64 = mul i32 %op62, 2 - %op66 = mul i32 %op64, 2 - %op68 = mul i32 %op66, 2 - %op70 = mul i32 %op68, 2 - %op72 = mul i32 %op70, 2 - %op74 = mul i32 %op72, 2 - %op76 = mul i32 %op74, 2 - %op78 = sdiv i32 %op76, 2 - %op80 = sdiv i32 %op78, 2 - %op82 = sdiv i32 %op80, 2 - %op84 = sdiv i32 %op82, 2 - %op86 = sdiv i32 %op84, 2 - %op88 = sdiv i32 %op86, 2 - %op90 = sdiv i32 %op88, 2 - %op92 = sdiv i32 %op90, 2 - %op94 = sdiv i32 %op92, 2 - %op96 = sdiv i32 %op94, 2 - br label %label8 -label8: ; preds = %label_entry, %label22 - %op102 = phi i32 [ %op109, %label22 ], [ undef, %label_entry ] - %op103 = phi i32 [ %op110, %label22 ], [ undef, %label_entry ] - %op104 = phi i32 [ %op111, %label22 ], [ undef, %label_entry ] - %op105 = phi i32 [ %op112, %label22 ], [ undef, %label_entry ] - %op106 = phi i32 [ %op113, %label22 ], [ undef, %label_entry ] - %op107 = phi i32 [ 0, %label_entry ], [ %op24, %label22 ] - %op108 = phi i32 [ %op114, %label22 ], [ undef, %label_entry ] - %op10 = icmp slt i32 %op107, 1000000 - %op11 = zext i1 %op10 to i32 - %op12 = icmp ne i32 %op11, 0 - br i1 %op12, label %label13, label %label14 -label13: ; preds = %label8 - br label %label16 -label14: ; preds = %label8 - call void @output(i32 %op102) - ret void -label16: ; preds = %label13, %label31 - %op109 = phi i32 [ %op102, %label13 ], [ %op115, %label31 ] - %op110 = phi i32 [ %op103, %label13 ], [ %op116, %label31 ] - %op111 = phi i32 [ %op104, %label13 ], [ %op117, %label31 ] - %op112 = phi i32 [ %op105, %label13 ], [ %op118, %label31 ] - %op113 = phi i32 [ %op106, %label13 ], [ %op119, %label31 ] - %op114 = phi i32 [ 0, %label13 ], [ %op33, %label31 ] - %op18 = icmp slt i32 %op114, 2 - %op19 = zext i1 %op18 to i32 - %op20 = icmp ne i32 %op19, 0 - br i1 %op20, label %label21, label %label22 -label21: ; preds = %label16 - br label %label25 -label22: ; preds = %label16 - %op24 = add i32 %op107, 1 - br label %label8 -label25: ; preds = %label21, %label40 - %op115 = phi i32 [ %op109, %label21 ], [ %op120, %label40 ] - %op116 = phi i32 [ %op110, %label21 ], [ %op121, %label40 ] - %op117 = phi i32 [ %op111, %label21 ], [ %op122, %label40 ] - %op118 = phi i32 [ %op112, %label21 ], [ %op123, %label40 ] - %op119 = phi i32 [ 0, %label21 ], [ %op42, %label40 ] - %op27 = icmp slt i32 %op119, 2 - %op28 = zext i1 %op27 to i32 - %op29 = icmp ne i32 %op28, 0 - br i1 %op29, label %label30, label %label31 -label30: ; preds = %label25 - br label %label34 -label31: ; preds = %label25 - %op33 = add i32 %op114, 1 - br label %label16 -label34: ; preds = %label30, %label49 - %op120 = phi i32 [ %op115, %label30 ], [ %op124, %label49 ] - %op121 = phi i32 [ %op116, %label30 ], [ %op125, %label49 ] - %op122 = phi i32 [ %op117, %label30 ], [ %op126, %label49 ] - %op123 = phi i32 [ 0, %label30 ], [ %op51, %label49 ] - %op36 = icmp slt i32 %op123, 2 - %op37 = zext i1 %op36 to i32 - %op38 = icmp ne i32 %op37, 0 - br i1 %op38, label %label39, label %label40 -label39: ; preds = %label34 - br label %label43 -label40: ; preds = %label34 - %op42 = add i32 %op119, 1 - br label %label25 -label43: ; preds = %label39, %label99 - %op124 = phi i32 [ %op120, %label39 ], [ %op127, %label99 ] - %op125 = phi i32 [ %op121, %label39 ], [ %op128, %label99 ] - %op126 = phi i32 [ 0, %label39 ], [ %op101, %label99 ] - %op45 = icmp slt i32 %op126, 2 - %op46 = zext i1 %op45 to i32 - %op47 = icmp ne i32 %op46, 0 - br i1 %op47, label %label48, label %label49 -label48: ; preds = %label43 - br label %label52 -label49: ; preds = %label43 - %op51 = add i32 %op123, 1 - br label %label34 -label52: ; preds = %label48, %label57 - %op127 = phi i32 [ %op124, %label48 ], [ %op96, %label57 ] - %op128 = phi i32 [ 0, %label48 ], [ %op98, %label57 ] - %op54 = icmp slt i32 %op128, 2 - %op55 = zext i1 %op54 to i32 - %op56 = icmp ne i32 %op55, 0 - br i1 %op56, label %label57, label %label99 -label57: ; preds = %label52 - %op98 = add i32 %op128, 1 - br label %label52 -label99: ; preds = %label52 - %op101 = add i32 %op126, 1 - br label %label43 -} diff --git a/tests/4-opt/testcases/loop/baseline/loop-4.ll b/tests/4-opt/testcases/loop/baseline/loop-4.ll deleted file mode 100644 index 838371ae861c0f3a234f7a1c95f085e2509e639a..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/baseline/loop-4.ll +++ /dev/null @@ -1,132 +0,0 @@ -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - %op71 = mul i32 2, 2 - %op73 = mul i32 %op71, 2 - %op75 = mul i32 %op73, 2 - %op77 = mul i32 %op75, 2 - %op79 = mul i32 %op77, 2 - %op81 = mul i32 %op79, 2 - %op83 = mul i32 %op81, 2 - %op85 = mul i32 %op83, 2 - %op87 = mul i32 %op85, 2 - %op89 = sdiv i32 %op87, 2 - %op91 = sdiv i32 %op89, 2 - %op93 = sdiv i32 %op91, 2 - %op95 = sdiv i32 %op93, 2 - %op97 = sdiv i32 %op95, 2 - %op99 = sdiv i32 %op97, 2 - %op101 = sdiv i32 %op99, 2 - %op103 = sdiv i32 %op101, 2 - %op105 = sdiv i32 %op103, 2 - %op107 = sdiv i32 %op105, 2 - %op59 = icmp sgt i32 2, 1 - %op60 = zext i1 %op59 to i32 - %op61 = icmp ne i32 %op60, 0 - br label %label8 -label8: ; preds = %label_entry, %label22 - %op110 = phi i32 [ %op117, %label22 ], [ undef, %label_entry ] - %op111 = phi i32 [ %op118, %label22 ], [ undef, %label_entry ] - %op112 = phi i32 [ %op119, %label22 ], [ undef, %label_entry ] - %op113 = phi i32 [ %op120, %label22 ], [ undef, %label_entry ] - %op114 = phi i32 [ %op121, %label22 ], [ undef, %label_entry ] - %op115 = phi i32 [ 0, %label_entry ], [ %op24, %label22 ] - %op116 = phi i32 [ %op122, %label22 ], [ undef, %label_entry ] - %op10 = icmp slt i32 %op115, 1000000 - %op11 = zext i1 %op10 to i32 - %op12 = icmp ne i32 %op11, 0 - br i1 %op12, label %label13, label %label14 -label13: ; preds = %label8 - br label %label16 -label14: ; preds = %label8 - call void @output(i32 %op110) - ret void -label16: ; preds = %label13, %label31 - %op117 = phi i32 [ %op110, %label13 ], [ %op123, %label31 ] - %op118 = phi i32 [ %op111, %label13 ], [ %op124, %label31 ] - %op119 = phi i32 [ %op112, %label13 ], [ %op125, %label31 ] - %op120 = phi i32 [ %op113, %label13 ], [ %op126, %label31 ] - %op121 = phi i32 [ %op114, %label13 ], [ %op127, %label31 ] - %op122 = phi i32 [ 0, %label13 ], [ %op33, %label31 ] - %op18 = icmp slt i32 %op122, 2 - %op19 = zext i1 %op18 to i32 - %op20 = icmp ne i32 %op19, 0 - br i1 %op20, label %label21, label %label22 -label21: ; preds = %label16 - br label %label25 -label22: ; preds = %label16 - %op24 = add i32 %op115, 1 - br label %label8 -label25: ; preds = %label21, %label40 - %op123 = phi i32 [ %op117, %label21 ], [ %op129, %label40 ] - %op124 = phi i32 [ %op118, %label21 ], [ %op130, %label40 ] - %op125 = phi i32 [ %op119, %label21 ], [ %op131, %label40 ] - %op126 = phi i32 [ %op120, %label21 ], [ %op132, %label40 ] - %op127 = phi i32 [ 0, %label21 ], [ %op42, %label40 ] - %op128 = phi i32 [ %op122, %label21 ], [ %op133, %label40 ] - %op27 = icmp slt i32 %op127, 2 - %op28 = zext i1 %op27 to i32 - %op29 = icmp ne i32 %op28, 0 - br i1 %op29, label %label30, label %label31 -label30: ; preds = %label25 - br label %label34 -label31: ; preds = %label25 - %op33 = add i32 %op128, 1 - br label %label16 -label34: ; preds = %label30, %label49 - %op129 = phi i32 [ %op123, %label30 ], [ %op134, %label49 ] - %op130 = phi i32 [ %op124, %label30 ], [ %op135, %label49 ] - %op131 = phi i32 [ %op125, %label30 ], [ %op136, %label49 ] - %op132 = phi i32 [ 0, %label30 ], [ %op51, %label49 ] - %op133 = phi i32 [ %op128, %label30 ], [ %op137, %label49 ] - %op36 = icmp slt i32 %op132, 2 - %op37 = zext i1 %op36 to i32 - %op38 = icmp ne i32 %op37, 0 - br i1 %op38, label %label39, label %label40 -label39: ; preds = %label34 - br label %label43 -label40: ; preds = %label34 - %op42 = add i32 %op127, 1 - br label %label25 -label43: ; preds = %label39, %label62 - %op134 = phi i32 [ %op129, %label39 ], [ %op138, %label62 ] - %op135 = phi i32 [ %op130, %label39 ], [ %op139, %label62 ] - %op136 = phi i32 [ 0, %label39 ], [ %op64, %label62 ] - %op137 = phi i32 [ %op133, %label39 ], [ %op140, %label62 ] - %op45 = icmp slt i32 %op136, 2 - %op46 = zext i1 %op45 to i32 - %op47 = icmp ne i32 %op46, 0 - br i1 %op47, label %label48, label %label49 -label48: ; preds = %label43 - br label %label52 -label49: ; preds = %label43 - %op51 = add i32 %op132, 1 - br label %label34 -label52: ; preds = %label48, %label68 - %op138 = phi i32 [ %op134, %label48 ], [ %op107, %label68 ] - %op139 = phi i32 [ 0, %label48 ], [ %op109, %label68 ] - %op140 = phi i32 [ %op137, %label48 ], [ %op141, %label68 ] - %op54 = icmp slt i32 %op139, 2 - %op55 = zext i1 %op54 to i32 - %op56 = icmp ne i32 %op55, 0 - br i1 %op56, label %label57, label %label62 -label57: ; preds = %label52 - br i1 %op61, label %label65, label %label68 -label62: ; preds = %label52 - %op64 = add i32 %op136, 1 - br label %label43 -label65: ; preds = %label57 - %op67 = add i32 %op140, 1 - br label %label68 -label68: ; preds = %label57, %label65 - %op141 = phi i32 [ %op140, %label57 ], [ %op67, %label65 ] - %op109 = add i32 %op139, 1 - br label %label52 -} diff --git a/tests/4-opt/testcases/loop/loop-1.cminus b/tests/4-opt/testcases/loop/loop-1.cminus deleted file mode 100644 index 82ce6d3cb5f2f55956ebef35dc340924a577255e..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/loop-1.cminus +++ /dev/null @@ -1,20 +0,0 @@ -void main(void){ - int i; - int j; - int ret; - - i = 1; - - while(i<10000) - { - j = 0; - while(j<10000) - { - ret = (i*i*i*i*i*i*i*i*i*i)/i/i/i/i/i/i/i/i/i/i; - j=j+1; - } - i=i+1; - } - output(ret); - return ; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/loop/loop-2.cminus b/tests/4-opt/testcases/loop/loop-2.cminus deleted file mode 100644 index 920c1ad9c6dd630df4a9916a723a80383c4f81a1..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/loop-2.cminus +++ /dev/null @@ -1,23 +0,0 @@ -void main(void){ - int i; - int j; - int a; - int ret; - - i = 0; - a = 2; - - while(i<10000000) - { - j = 0; - - while(j<2) - { - ret = (a*a*a*a*a*a*a*a*a*a)/a/a/a/a/a/a/a/a/a/a; - j=j+1; - } - i=i+1; - } - output(ret); - return ; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/loop/loop-2.out b/tests/4-opt/testcases/loop/loop-2.out deleted file mode 100644 index b261da18d51a39dc2cf0d156791e9c0b35dd83f4..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/loop-2.out +++ /dev/null @@ -1,2 +0,0 @@ -1 -0 diff --git a/tests/4-opt/testcases/loop/loop-3.cminus b/tests/4-opt/testcases/loop/loop-3.cminus deleted file mode 100644 index 8858c838c076a23df9b577485bd0a4114b108169..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/loop-3.cminus +++ /dev/null @@ -1,46 +0,0 @@ -void main(void){ - int i; - int j; - int k; - int o; - int p; - int q; - int a; - int ret; - - a = 2; - - i = 0; - while(i<1000000) - { - j = 0; - while(j<2) - { - k = 0; - while(k<2) - { - o = 0; - while(o<2) - { - p = 0; - while(p<2) - { - q = 0; - while(q<2) - { - ret = (a*a*a*a*a*a*a*a*a*a)/a/a/a/a/a/a/a/a/a/a; - q=q+1; - } - p=p+1; - } - o=o+1; - } - k=k+1; - } - j=j+1; - } - i=i+1; - } - output(ret); - return ; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/loop/loop-3.out b/tests/4-opt/testcases/loop/loop-3.out deleted file mode 100644 index b261da18d51a39dc2cf0d156791e9c0b35dd83f4..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/loop-3.out +++ /dev/null @@ -1,2 +0,0 @@ -1 -0 diff --git a/tests/4-opt/testcases/loop/loop-4.cminus b/tests/4-opt/testcases/loop/loop-4.cminus deleted file mode 100644 index 287098a7e602c453e0208584c5edc9aceb26139a..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/loop-4.cminus +++ /dev/null @@ -1,50 +0,0 @@ -void main(void){ - int i; - int j; - int k; - int o; - int p; - int q; - int a; - int ret; - - a = 2; - - i = 0; - while(i<1000000) - { - j = 0; - while(j<2) - { - k = 0; - while(k<2) - { - o = 0; - while(o<2) - { - p = 0; - while(p<2) - { - q = 0; - while(q<2) - { - if( a > 1 ) - { - j = j+1; - } - ret = (a*a*a*a*a*a*a*a*a*a)/a/a/a/a/a/a/a/a/a/a; - q=q+1; - } - p=p+1; - } - o=o+1; - } - k=k+1; - } - j=j+1; - } - i=i+1; - } - output(ret); - return ; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/loop/loop-4.out b/tests/4-opt/testcases/loop/loop-4.out deleted file mode 100644 index b261da18d51a39dc2cf0d156791e9c0b35dd83f4..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/loop/loop-4.out +++ /dev/null @@ -1,2 +0,0 @@ -1 -0 diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1 b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1 deleted file mode 100755 index 60e63e1726a9637f28dca2ff7a88d79bc99ba30e..0000000000000000000000000000000000000000 Binary files a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1 and /dev/null differ diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll deleted file mode 100644 index 00b6e15560fc5d4037c4ffb6dd2f8fb1639a3ace..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-1.ll +++ /dev/null @@ -1,54 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/zox/compiler/2024ustc-jianmu-compiler-ta/tests/4-mem2reg/performance-cases/testcase-1.cminus" - -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @main() { -label_entry: - %op0 = call i32 @input() - br label %label1 -label1: ; preds = %label_entry, %label7 - %op2 = phi i32 [ 0, %label_entry ], [ %op33, %label7 ] - %op3 = phi i32 [ 0, %label_entry ], [ %op32, %label7 ] - %op4 = icmp slt i32 %op2, %op0 - %op5 = zext i1 %op4 to i32 - %op6 = icmp ne i32 %op5, 0 - br i1 %op6, label %label7, label %label34 -label7: ; preds = %label1 - %op8 = fmul float 0x3ff3c0c200000000, 0x4016f06a20000000 - %op9 = fmul float %op8, 0x4002aa9940000000 - %op10 = fmul float %op9, 0x4011781d80000000 - %op11 = fmul float %op10, 0x401962ac40000000 - %op12 = fptosi float %op11 to i32 - %op13 = mul i32 %op12, %op12 - %op14 = mul i32 %op13, %op12 - %op15 = mul i32 %op14, %op12 - %op16 = mul i32 %op15, %op12 - %op17 = mul i32 %op16, %op12 - %op18 = mul i32 %op17, %op17 - %op19 = mul i32 %op18, %op17 - %op20 = mul i32 %op19, %op17 - %op21 = mul i32 %op20, %op17 - %op22 = mul i32 %op21, %op17 - %op23 = mul i32 %op22, %op22 - %op24 = mul i32 %op23, %op22 - %op25 = mul i32 %op24, %op22 - %op26 = mul i32 %op25, %op22 - %op27 = mul i32 %op26, %op22 - %op28 = mul i32 %op27, %op27 - %op29 = mul i32 %op28, %op27 - %op30 = mul i32 %op29, %op27 - %op31 = mul i32 %op30, %op27 - %op32 = mul i32 %op31, %op27 - %op33 = add i32 %op2, 1 - br label %label1 -label34: ; preds = %label1 - call void @output(i32 %op3) - ret void -} diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2 b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2 deleted file mode 100755 index 4a905ff6e89117910fab4c7a5bba89c800190b55..0000000000000000000000000000000000000000 Binary files a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2 and /dev/null differ diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll deleted file mode 100644 index 0fcadf5d42c3e4b27d7cbe1e9c0ce9c64fa611a2..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-2.ll +++ /dev/null @@ -1,26 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/zox/compiler/2024ustc-jianmu-compiler-ta/tests/4-mem2reg/performance-cases/testcase-2.cminus" - -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define i32 @main() { -label_entry: - br label %label0 -label0: ; preds = %label_entry, %label5 - %op1 = phi i32 [ 1, %label_entry ], [ %op6, %label5 ] - %op2 = icmp slt i32 %op1, 999999999 - %op3 = zext i1 %op2 to i32 - %op4 = icmp ne i32 %op3, 0 - br i1 %op4, label %label5, label %label7 -label5: ; preds = %label0 - %op6 = add i32 %op1, 1 - br label %label0 -label7: ; preds = %label0 - ret i32 %op1 -} diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3 b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3 deleted file mode 100755 index 477a8f55a2a2daf6bf8b2bb3b313aae93c139582..0000000000000000000000000000000000000000 Binary files a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3 and /dev/null differ diff --git a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll b/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll deleted file mode 100644 index c92c71efb104ce9ff13bae587173bf63e0d286c1..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/baseline/mem2reg-3.ll +++ /dev/null @@ -1,201 +0,0 @@ -; ModuleID = 'cminus' -source_filename = "/home/zox/compiler/2024ustc-jianmu-compiler-ta/tests/4-mem2reg/performance-cases/testcase-3.cminus" - -@matrix = global [20000000 x i32] zeroinitializer -@ad = global [100000 x i32] zeroinitializer -@len = global i32 zeroinitializer -declare i32 @input() - -declare void @output(i32) - -declare void @outputFloat(float) - -declare void @neg_idx_except() - -define void @readarray() { -label_entry: - br label %label0 -label0: ; preds = %label_entry, %label11 - %op1 = phi i32 [ 0, %label_entry ], [ %op13, %label11 ] - %op2 = load i32, i32* @len - %op3 = icmp slt i32 %op1, %op2 - %op4 = zext i1 %op3 to i32 - %op5 = icmp ne i32 %op4, 0 - br i1 %op5, label %label6, label %label9 -label6: ; preds = %label0 - %op7 = call i32 @input() - %op8 = icmp slt i32 %op1, 0 - br i1 %op8, label %label10, label %label11 -label9: ; preds = %label0 - ret void -label10: ; preds = %label6 - call void @neg_idx_except() - ret void -label11: ; preds = %label6 - %op12 = getelementptr [100000 x i32], [100000 x i32]* @ad, i32 0, i32 %op1 - store i32 %op7, i32* %op12 - %op13 = add i32 %op1, 1 - br label %label0 -} -define i32 @transpose(i32 %arg0, i32* %arg1, i32 %arg2) { -label_entry: - %op3 = sdiv i32 %arg0, %arg2 - br label %label4 -label4: ; preds = %label_entry, %label21 - %op5 = phi i32 [ 0, %label_entry ], [ %op22, %label21 ] - %op6 = icmp slt i32 %op5, %op3 - %op7 = zext i1 %op6 to i32 - %op8 = icmp ne i32 %op7, 0 - br i1 %op8, label %label9, label %label10 -label9: ; preds = %label4 - br label %label12 -label10: ; preds = %label4 - %op11 = sub i32 0, 1 - ret i32 %op11 -label12: ; preds = %label9, %label25 - %op13 = phi i32 [ 0, %label9 ], [ %op26, %label25 ] - %op14 = icmp slt i32 %op13, %arg2 - %op15 = zext i1 %op14 to i32 - %op16 = icmp ne i32 %op15, 0 - br i1 %op16, label %label17, label %label21 -label17: ; preds = %label12 - %op18 = icmp slt i32 %op5, %op13 - %op19 = zext i1 %op18 to i32 - %op20 = icmp ne i32 %op19, 0 - br i1 %op20, label %label23, label %label27 -label21: ; preds = %label12 - %op22 = add i32 %op5, 1 - br label %label4 -label23: ; preds = %label17 - %op24 = add i32 %op13, 1 - br label %label25 -label25: ; preds = %label23, %label52 - %op26 = phi i32 [ %op24, %label23 ], [ %op54, %label52 ] - br label %label12 -label27: ; preds = %label17 - %op28 = mul i32 %op5, %arg2 - %op29 = add i32 %op28, %op13 - %op30 = icmp slt i32 %op29, 0 - br i1 %op30, label %label31, label %label32 -label31: ; preds = %label27 - call void @neg_idx_except() - ret i32 0 -label32: ; preds = %label27 - %op33 = getelementptr i32, i32* %arg1, i32 %op29 - %op34 = load i32, i32* %op33 - %op35 = mul i32 %op5, %arg2 - %op36 = add i32 %op35, %op13 - %op37 = icmp slt i32 %op36, 0 - br i1 %op37, label %label38, label %label39 -label38: ; preds = %label32 - call void @neg_idx_except() - ret i32 0 -label39: ; preds = %label32 - %op40 = getelementptr i32, i32* %arg1, i32 %op36 - %op41 = load i32, i32* %op40 - %op42 = mul i32 %op13, %op3 - %op43 = add i32 %op42, %op5 - %op44 = icmp slt i32 %op43, 0 - br i1 %op44, label %label45, label %label46 -label45: ; preds = %label39 - call void @neg_idx_except() - ret i32 0 -label46: ; preds = %label39 - %op47 = getelementptr i32, i32* %arg1, i32 %op43 - store i32 %op41, i32* %op47 - %op48 = mul i32 %op5, %arg2 - %op49 = add i32 %op48, %op13 - %op50 = icmp slt i32 %op49, 0 - br i1 %op50, label %label51, label %label52 -label51: ; preds = %label46 - call void @neg_idx_except() - ret i32 0 -label52: ; preds = %label46 - %op53 = getelementptr i32, i32* %arg1, i32 %op49 - store i32 %op34, i32* %op53 - %op54 = add i32 %op13, 1 - br label %label25 -} -define i32 @main() { -label_entry: - %op0 = call i32 @input() - %op1 = call i32 @input() - store i32 %op1, i32* @len - call void @readarray() - br label %label2 -label2: ; preds = %label_entry, %label11 - %op3 = phi i32 [ 0, %label_entry ], [ %op13, %label11 ] - %op4 = icmp slt i32 %op3, %op0 - %op5 = zext i1 %op4 to i32 - %op6 = icmp ne i32 %op5, 0 - br i1 %op6, label %label7, label %label9 -label7: ; preds = %label2 - %op8 = icmp slt i32 %op3, 0 - br i1 %op8, label %label10, label %label11 -label9: ; preds = %label2 - br label %label14 -label10: ; preds = %label7 - call void @neg_idx_except() - ret i32 0 -label11: ; preds = %label7 - %op12 = getelementptr [20000000 x i32], [20000000 x i32]* @matrix, i32 0, i32 %op3 - store i32 %op3, i32* %op12 - %op13 = add i32 %op3, 1 - br label %label2 -label14: ; preds = %label9, %label25 - %op15 = phi i32 [ 0, %label9 ], [ %op29, %label25 ] - %op16 = load i32, i32* @len - %op17 = icmp slt i32 %op15, %op16 - %op18 = zext i1 %op17 to i32 - %op19 = icmp ne i32 %op18, 0 - br i1 %op19, label %label20, label %label23 -label20: ; preds = %label14 - %op21 = getelementptr [20000000 x i32], [20000000 x i32]* @matrix, i32 0, i32 0 - %op22 = icmp slt i32 %op15, 0 - br i1 %op22, label %label24, label %label25 -label23: ; preds = %label14 - br label %label30 -label24: ; preds = %label20 - call void @neg_idx_except() - ret i32 0 -label25: ; preds = %label20 - %op26 = getelementptr [100000 x i32], [100000 x i32]* @ad, i32 0, i32 %op15 - %op27 = load i32, i32* %op26 - %op28 = call i32 @transpose(i32 %op0, i32* %op21, i32 %op27) - %op29 = add i32 %op15, 1 - br label %label14 -label30: ; preds = %label23, %label45 - %op31 = phi i32 [ 0, %label23 ], [ %op49, %label45 ] - %op32 = phi i32 [ 0, %label23 ], [ %op50, %label45 ] - %op33 = load i32, i32* @len - %op34 = icmp slt i32 %op32, %op33 - %op35 = zext i1 %op34 to i32 - %op36 = icmp ne i32 %op35, 0 - br i1 %op36, label %label37, label %label40 -label37: ; preds = %label30 - %op38 = mul i32 %op32, %op32 - %op39 = icmp slt i32 %op32, 0 - br i1 %op39, label %label44, label %label45 -label40: ; preds = %label30 - %op41 = icmp slt i32 %op31, 0 - %op42 = zext i1 %op41 to i32 - %op43 = icmp ne i32 %op42, 0 - br i1 %op43, label %label51, label %label53 -label44: ; preds = %label37 - call void @neg_idx_except() - ret i32 0 -label45: ; preds = %label37 - %op46 = getelementptr [20000000 x i32], [20000000 x i32]* @matrix, i32 0, i32 %op32 - %op47 = load i32, i32* %op46 - %op48 = mul i32 %op38, %op47 - %op49 = add i32 %op31, %op48 - %op50 = add i32 %op32, 1 - br label %label30 -label51: ; preds = %label40 - %op52 = sub i32 0, %op31 - br label %label53 -label53: ; preds = %label40, %label51 - %op54 = phi i32 [ %op31, %label40 ], [ %op52, %label51 ] - call void @output(i32 %op54) - ret i32 0 -} diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-1 b/tests/4-opt/testcases/mem2reg/mem2reg-1 deleted file mode 100755 index ce0bb68c231d0534080201a8f6809d8aedc6194b..0000000000000000000000000000000000000000 Binary files a/tests/4-opt/testcases/mem2reg/mem2reg-1 and /dev/null differ diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-1.cminus b/tests/4-opt/testcases/mem2reg/mem2reg-1.cminus deleted file mode 100644 index 93d726f539fbb965d46b3c44f17ac8b1755740d7..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-1.cminus +++ /dev/null @@ -1,23 +0,0 @@ -void main(void) { - int c; - int a; - int b; - int d; - int f; - int g; - int loopCnt; - loopCnt = input(); - c = 0; - a = 0; - g = 0; - while (c < loopCnt) { - a = 1.23456 * 5.73478 * 2.3333 * 4.3673 * 6.34636; - b = a * a * a * a * a * a; - d = b * b * b * b * b * b; - f = d * d * d * d * d * d; - g = f * f * f * f * f * f; - c = c + 1; - } - output(g); - return; -} \ No newline at end of file diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-1.in b/tests/4-opt/testcases/mem2reg/mem2reg-1.in deleted file mode 100644 index ea600cb61b366b723c6e331e118865642391327f..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-1.in +++ /dev/null @@ -1 +0,0 @@ -100000000 diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-1.out b/tests/4-opt/testcases/mem2reg/mem2reg-1.out deleted file mode 100644 index f422395e55bfcb38cf4fa905452d5662b53d582c..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-1.out +++ /dev/null @@ -1,2 +0,0 @@ -711082625 -0 diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-2 b/tests/4-opt/testcases/mem2reg/mem2reg-2 deleted file mode 100755 index a3e30a3b90c21e6680b087bc7d9fa0d26656e7c5..0000000000000000000000000000000000000000 Binary files a/tests/4-opt/testcases/mem2reg/mem2reg-2 and /dev/null differ diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-2.cminus b/tests/4-opt/testcases/mem2reg/mem2reg-2.cminus deleted file mode 100644 index 7d85bd67dce4775296ab502924207af02539e02f..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-2.cminus +++ /dev/null @@ -1,9 +0,0 @@ -int main(void) { - int a; - a = 1; - - while (a < 999999999) { - a = a + 1; - } - return a; -} diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-2.out b/tests/4-opt/testcases/mem2reg/mem2reg-2.out deleted file mode 100644 index ace9d0362138cfabef3b6feb959808748e4263b4..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-2.out +++ /dev/null @@ -1 +0,0 @@ -255 diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-3 b/tests/4-opt/testcases/mem2reg/mem2reg-3 deleted file mode 100755 index 46b7cc4142e8c369e8673c2b5aa10fedb4ce2fcf..0000000000000000000000000000000000000000 Binary files a/tests/4-opt/testcases/mem2reg/mem2reg-3 and /dev/null differ diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-3.cminus b/tests/4-opt/testcases/mem2reg/mem2reg-3.cminus deleted file mode 100644 index 0aff64fd0996534f1612c3203c41dbf26b9a9812..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-3.cminus +++ /dev/null @@ -1,70 +0,0 @@ -int matrix[20000000]; -int ad[100000]; - -int len; - -void readarray(void) { - int cnt; - cnt = 0; - while (cnt < len) { - ad[cnt] = input(); - cnt = cnt + 1; - } -} - -int transpose(int n, int matrix[], int rowsize) { - int colsize; - int i; - int j; - int curr; - colsize = n / rowsize; - i = 0; - j = 0; - while (i < colsize) { - j = 0; - while (j < rowsize) { - if (i < j) { - j = j + 1; - } else { - curr = matrix[i * rowsize + j]; - matrix[j * colsize + i] = matrix[i * rowsize + j]; - matrix[i * rowsize + j] = curr; - j = j + 1; - } - } - i = i + 1; - } - return 0 - 1; -} - -int main(void) { - int n; - int i; - int ans; - n = input(); - len = input(); - readarray(); - i = 0; - - while (i < n) { - matrix[i] = i; - i = i + 1; - } - i = 0; - while (i < len) { - transpose(n, matrix, ad[i]); - i = i + 1; - } - - ans = 0; - i = 0; - while (i < len) { - ans = ans + i * i * matrix[i]; - i = i + 1; - } - if (ans < 0) { - ans = 0 - ans; - } - output(ans); - return 0; -} diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-3.in b/tests/4-opt/testcases/mem2reg/mem2reg-3.in deleted file mode 100644 index f37548b30c57768e9549667d431165587c834a8e..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-3.in +++ /dev/null @@ -1,32 +0,0 @@ -10000000 -30 -2 -5 -4 -25 -8 -125 -16 -625 -32 -3125 -2 -5 -4 -25 -8 -125 -16 -625 -32 -3125 -2 -5 -4 -25 -8 -125 -16 -625 -32 -3125 diff --git a/tests/4-opt/testcases/mem2reg/mem2reg-3.out b/tests/4-opt/testcases/mem2reg/mem2reg-3.out deleted file mode 100644 index 72f8a546d2a64e4847b5000bbd767c00dd274238..0000000000000000000000000000000000000000 --- a/tests/4-opt/testcases/mem2reg/mem2reg-3.out +++ /dev/null @@ -1,2 +0,0 @@ -1042523985 -0