diff --git a/.github/workflows/test_all_commits.yaml b/.github/workflows/test_all_commits.yaml new file mode 100644 index 00000000..b76fb0bf --- /dev/null +++ b/.github/workflows/test_all_commits.yaml @@ -0,0 +1,15 @@ +# Run test_each_chapter.yaml, from nqcc2 repo, to make sure we're not +# e.g. using a language feature before the test where it's added + +name: Test All Chapters + +on: + pull_request: + branches: [ "main" ] + +jobs: + test_all_chapters: + uses: nlsandler/nqcc2/.github/workflows/test_each_chapter.yaml@extra-credit + with: + tests-branch: ${{ github.head_ref }} + cc-branch: extra-credit \ No newline at end of file diff --git a/.github/workflows/test_tests.yaml b/.github/workflows/test_tests.yaml index 78c23684..a6e92ba8 100644 --- a/.github/workflows/test_tests.yaml +++ b/.github/workflows/test_tests.yaml @@ -5,7 +5,7 @@ name: Compiler Test Suite CI on: pull_request: - branches: [ "main", "complete-test-suite" ] + branches: [ "main" ] workflow_dispatch: diff --git a/tests/chapter_20/all_types/no_coalescing/div_interference.c b/tests/chapter_20/all_types/no_coalescing/div_interference.c index 26eb2e38..38f7cb3c 100644 --- a/tests/chapter_20/all_types/no_coalescing/div_interference.c +++ b/tests/chapter_20/all_types/no_coalescing/div_interference.c @@ -7,7 +7,7 @@ * This test program is generated from templates/chapter_20_templates/division_interference.c.jinja */ -#include "../../libraries/util.h" +#include "../util.h" unsigned int glob = 3; diff --git a/tests/chapter_20/all_types/no_coalescing/force_spill_doubles.c b/tests/chapter_20/all_types/no_coalescing/force_spill_doubles.c index 02affed9..389a13ce 100644 --- a/tests/chapter_20/all_types/no_coalescing/force_spill_doubles.c +++ b/tests/chapter_20/all_types/no_coalescing/force_spill_doubles.c @@ -1,4 +1,4 @@ -#include "../../libraries/util.h" +#include "../util.h" int glob = 3; double glob2 = 4.0; diff --git a/tests/chapter_20/all_types/no_coalescing/force_spill_mixed_ints.c b/tests/chapter_20/all_types/no_coalescing/force_spill_mixed_ints.c index 83a8b9cf..57c1ff18 100644 --- a/tests/chapter_20/all_types/no_coalescing/force_spill_mixed_ints.c +++ b/tests/chapter_20/all_types/no_coalescing/force_spill_mixed_ints.c @@ -7,7 +7,7 @@ * This test program is generated from templates/chapter_20_templates/force_spill.c.jinja * */ -#include "../../libraries/util.h" +#include "../util.h" unsigned int glob_three = 3; long glob_11 = 11l; diff --git a/tests/chapter_20/all_types/no_coalescing/mixed_type_stack_alignment.c b/tests/chapter_20/all_types/no_coalescing/mixed_type_stack_alignment.c index 30216521..99048655 100644 --- a/tests/chapter_20/all_types/no_coalescing/mixed_type_stack_alignment.c +++ b/tests/chapter_20/all_types/no_coalescing/mixed_type_stack_alignment.c @@ -7,7 +7,7 @@ * but with a mix of types. * */ -#include "../../libraries/util.h" // declares check_* and id functions +#include "../util.h" // declares check_* and id functions // check alignment of RSP and exit with exit_code if it's misaligned // defined in tests/chapter_20/libraries/alignment_check_.s diff --git a/tests/chapter_20/all_types/no_coalescing/store_pointer_in_register.c b/tests/chapter_20/all_types/no_coalescing/store_pointer_in_register.c index 242dbe5d..c050ecf7 100644 --- a/tests/chapter_20/all_types/no_coalescing/store_pointer_in_register.c +++ b/tests/chapter_20/all_types/no_coalescing/store_pointer_in_register.c @@ -7,7 +7,7 @@ * Look for: no spills */ -#include "../../libraries/util.h" +#include "../util.h" int glob1 = 1; int glob2 = 2; diff --git a/tests/chapter_20/all_types/no_coalescing/track_dbl_arg_registers.c b/tests/chapter_20/all_types/no_coalescing/track_dbl_arg_registers.c index 60b5fd79..462383b7 100644 --- a/tests/chapter_20/all_types/no_coalescing/track_dbl_arg_registers.c +++ b/tests/chapter_20/all_types/no_coalescing/track_dbl_arg_registers.c @@ -9,7 +9,7 @@ * in spills. * */ -#include "../../libraries/util.h" +#include "../util.h" // defined in libraries/trakc_dbl_arg_registers_lib.c int callee(double a, double b, double c); diff --git a/tests/chapter_20/libraries/util.h b/tests/chapter_20/all_types/util.h similarity index 100% rename from tests/chapter_20/libraries/util.h rename to tests/chapter_20/all_types/util.h diff --git a/tests/chapter_20/int_only/no_coalescing/bin_uses_operands.c b/tests/chapter_20/int_only/no_coalescing/bin_uses_operands.c index 9364e050..6102a0db 100644 --- a/tests/chapter_20/int_only/no_coalescing/bin_uses_operands.c +++ b/tests/chapter_20/int_only/no_coalescing/bin_uses_operands.c @@ -4,7 +4,7 @@ * NOTE: only works as intended after we've implemented register coalescing. */ -#include "../../libraries/util.h" +#include "../util.h" // recognize that add uses its source int src_test(int i) { diff --git a/tests/chapter_20/int_only/no_coalescing/callee_saved_stack_alignment.c b/tests/chapter_20/int_only/no_coalescing/callee_saved_stack_alignment.c index 40b8a3e7..d7546988 100644 --- a/tests/chapter_20/int_only/no_coalescing/callee_saved_stack_alignment.c +++ b/tests/chapter_20/int_only/no_coalescing/callee_saved_stack_alignment.c @@ -5,7 +5,7 @@ * exit code. * */ -#include "../../libraries/util.h" // declares check_* and id functions +#include "../util.h" // declares check_* and id functions // check alignment of RSP and exit with exit_code if it's misaligned // defined in tests/chapter_20/libraries/alignment_check_.s diff --git a/tests/chapter_20/int_only/no_coalescing/cmp_generates_operands.c b/tests/chapter_20/int_only/no_coalescing/cmp_generates_operands.c index 201ef621..4dedd625 100644 --- a/tests/chapter_20/int_only/no_coalescing/cmp_generates_operands.c +++ b/tests/chapter_20/int_only/no_coalescing/cmp_generates_operands.c @@ -3,7 +3,7 @@ * Note: this only works as intended after we've implemented register * coalescing. * */ -#include "../../libraries/util.h" +#include "../util.h" int glob = 10; int glob2 = 20; diff --git a/tests/chapter_20/int_only/no_coalescing/copy_no_interference.c b/tests/chapter_20/int_only/no_coalescing/copy_no_interference.c index 1665e622..f5060705 100644 --- a/tests/chapter_20/int_only/no_coalescing/copy_no_interference.c +++ b/tests/chapter_20/int_only/no_coalescing/copy_no_interference.c @@ -3,7 +3,7 @@ * pseudoregisters conflict at any time. * */ -#include "../../libraries/util.h" +#include "../util.h" int glob0 = 0; int glob1 = 1; diff --git a/tests/chapter_20/int_only/no_coalescing/division_uses_ax.c b/tests/chapter_20/int_only/no_coalescing/division_uses_ax.c index 4632a216..1041c6ae 100644 --- a/tests/chapter_20/int_only/no_coalescing/division_uses_ax.c +++ b/tests/chapter_20/int_only/no_coalescing/division_uses_ax.c @@ -4,7 +4,7 @@ * NOTE: only works as intended once we implement coalescing. */ -#include "../../libraries/util.h" +#include "../util.h" int main(void) { // we'll coalesce this into EAX because it's a function's return value, diff --git a/tests/chapter_20/int_only/no_coalescing/eax_live_at_exit.c b/tests/chapter_20/int_only/no_coalescing/eax_live_at_exit.c index bc15706b..c7b10838 100644 --- a/tests/chapter_20/int_only/no_coalescing/eax_live_at_exit.c +++ b/tests/chapter_20/int_only/no_coalescing/eax_live_at_exit.c @@ -3,7 +3,7 @@ * Note: only works as intended once we've implemented register coalescing. * */ -#include "../../libraries/util.h" +#include "../util.h" int glob = 10; int glob2 = 0; diff --git a/tests/chapter_20/int_only/no_coalescing/force_spill.c b/tests/chapter_20/int_only/no_coalescing/force_spill.c index 0bcd3700..8e368812 100644 --- a/tests/chapter_20/int_only/no_coalescing/force_spill.c +++ b/tests/chapter_20/int_only/no_coalescing/force_spill.c @@ -7,7 +7,7 @@ * This test program is generated from templates/chapter_20_templates/force_spill.c.jinja * */ -#include "../../libraries/util.h" +#include "../util.h" int glob_three = 3; diff --git a/tests/chapter_20/int_only/no_coalescing/funcall_generates_args.c b/tests/chapter_20/int_only/no_coalescing/funcall_generates_args.c index b6b63c6a..b827d94a 100644 --- a/tests/chapter_20/int_only/no_coalescing/funcall_generates_args.c +++ b/tests/chapter_20/int_only/no_coalescing/funcall_generates_args.c @@ -3,7 +3,7 @@ * NOTE: only works as intended after we've implemented register coalescing. * */ -#include "../../libraries/util.h" +#include "../util.h" // defined in funcall_generates_args_lib, // exits early with return code -1 if a and b don't have diff --git a/tests/chapter_20/int_only/no_coalescing/idiv_interference.c b/tests/chapter_20/int_only/no_coalescing/idiv_interference.c index 5f9bf3f2..452f74d1 100644 --- a/tests/chapter_20/int_only/no_coalescing/idiv_interference.c +++ b/tests/chapter_20/int_only/no_coalescing/idiv_interference.c @@ -7,7 +7,7 @@ * This test program is generated from templates/chapter_20_templates/division_interference.c.jinja */ -#include "../../libraries/util.h" +#include "../util.h" int glob = 3; diff --git a/tests/chapter_20/int_only/no_coalescing/loop.c b/tests/chapter_20/int_only/no_coalescing/loop.c index 759b0f1e..04ec0a23 100644 --- a/tests/chapter_20/int_only/no_coalescing/loop.c +++ b/tests/chapter_20/int_only/no_coalescing/loop.c @@ -1,6 +1,6 @@ /* Test that liveness analysis for registers handles loop correctly */ -#include "../../libraries/util.h" +#include "../util.h" int counter = 5; int expected_a = 2; diff --git a/tests/chapter_20/int_only/no_coalescing/many_pseudos_fewer_conflicts.c b/tests/chapter_20/int_only/no_coalescing/many_pseudos_fewer_conflicts.c index fdef52f5..b859a919 100644 --- a/tests/chapter_20/int_only/no_coalescing/many_pseudos_fewer_conflicts.c +++ b/tests/chapter_20/int_only/no_coalescing/many_pseudos_fewer_conflicts.c @@ -3,7 +3,7 @@ * conflict */ -#include "../../libraries/util.h" +#include "../util.h" // define a function that returns a value // so we can't just constant fold everything away diff --git a/tests/chapter_20/int_only/no_coalescing/optimistic_coloring.c b/tests/chapter_20/int_only/no_coalescing/optimistic_coloring.c index 07c488f3..4b35dde2 100644 --- a/tests/chapter_20/int_only/no_coalescing/optimistic_coloring.c +++ b/tests/chapter_20/int_only/no_coalescing/optimistic_coloring.c @@ -3,7 +3,7 @@ * spill candidates but only spill 5 of them. */ -#include "../../libraries/util.h" +#include "../util.h" int flag = 0; int result = 0; diff --git a/tests/chapter_20/int_only/no_coalescing/preserve_across_fun_call.c b/tests/chapter_20/int_only/no_coalescing/preserve_across_fun_call.c index 89c7f826..d94d248c 100644 --- a/tests/chapter_20/int_only/no_coalescing/preserve_across_fun_call.c +++ b/tests/chapter_20/int_only/no_coalescing/preserve_across_fun_call.c @@ -5,7 +5,7 @@ * accident. */ -#include "../../libraries/util.h" +#include "../util.h" int glob1 = 1; int glob2 = 2; diff --git a/tests/chapter_20/int_only/no_coalescing/rewrite_regression_test.c b/tests/chapter_20/int_only/no_coalescing/rewrite_regression_test.c index 045123d8..49b4d446 100644 --- a/tests/chapter_20/int_only/no_coalescing/rewrite_regression_test.c +++ b/tests/chapter_20/int_only/no_coalescing/rewrite_regression_test.c @@ -8,7 +8,7 @@ * This test program is generated from templates/chapter_20_templates/rewrite_regression_test.c.jinja * */ -#include "../../libraries/util.h" +#include "../util.h" int glob_three = 3; int glob_four = 4; diff --git a/tests/chapter_20/int_only/no_coalescing/same_instr_interference.c b/tests/chapter_20/int_only/no_coalescing/same_instr_interference.c index e1404b3f..4e7677cb 100644 --- a/tests/chapter_20/int_only/no_coalescing/same_instr_interference.c +++ b/tests/chapter_20/int_only/no_coalescing/same_instr_interference.c @@ -3,7 +3,7 @@ * Only guaranteed to work as intended after implementing register coalescing. */ -#include "../../libraries/util.h" // declares check_* and id functions +#include "../util.h" // declares check_* and id functions int main(void) { // addition diff --git a/tests/chapter_20/int_only/no_coalescing/same_instr_no_interference.c b/tests/chapter_20/int_only/no_coalescing/same_instr_no_interference.c index 7843910e..d3d03f22 100644 --- a/tests/chapter_20/int_only/no_coalescing/same_instr_no_interference.c +++ b/tests/chapter_20/int_only/no_coalescing/same_instr_no_interference.c @@ -5,7 +5,7 @@ * allocate every register without spilling. */ -#include "../../libraries/util.h" // declares check_* and id functions +#include "../util.h" // declares check_* and id functions int target(void) { /* define some values - must be in callee-saved regs */ diff --git a/tests/chapter_20/int_only/no_coalescing/test_spill_metric.c b/tests/chapter_20/int_only/no_coalescing/test_spill_metric.c index 5366d52c..4bd94340 100644 --- a/tests/chapter_20/int_only/no_coalescing/test_spill_metric.c +++ b/tests/chapter_20/int_only/no_coalescing/test_spill_metric.c @@ -2,7 +2,7 @@ * we spill the one with the lowest spill cost (i.e. fewest uses) */ -#include "../../libraries/util.h" // declares check_* and id functions +#include "../util.h" // declares check_* and id functions int target(void) { // Define 6 callee-saved regs that interfere with each other; diff --git a/tests/chapter_20/int_only/no_coalescing/test_spill_metric_2.c b/tests/chapter_20/int_only/no_coalescing/test_spill_metric_2.c index 85bc1b12..0c7f9b3e 100644 --- a/tests/chapter_20/int_only/no_coalescing/test_spill_metric_2.c +++ b/tests/chapter_20/int_only/no_coalescing/test_spill_metric_2.c @@ -7,7 +7,7 @@ * resulting in more memory accesses overall. */ -#include "../../libraries/util.h" +#include "../util.h" int target(void) { diff --git a/tests/chapter_20/int_only/no_coalescing/track_arg_registers.c b/tests/chapter_20/int_only/no_coalescing/track_arg_registers.c index 8996479d..6be12b0c 100644 --- a/tests/chapter_20/int_only/no_coalescing/track_arg_registers.c +++ b/tests/chapter_20/int_only/no_coalescing/track_arg_registers.c @@ -7,7 +7,7 @@ * allocate them, resulting in spills. * */ -#include "../../libraries/util.h" +#include "../util.h" int glob1; int glob2; diff --git a/tests/chapter_20/int_only/no_coalescing/trivially_colorable.c b/tests/chapter_20/int_only/no_coalescing/trivially_colorable.c index c53a15ac..123499c0 100644 --- a/tests/chapter_20/int_only/no_coalescing/trivially_colorable.c +++ b/tests/chapter_20/int_only/no_coalescing/trivially_colorable.c @@ -2,7 +2,7 @@ * The test script validates that we don't spill any pseudoregisters in target. */ -#include "../../libraries/util.h" +#include "../util.h" int target(int one, int two) { // perform a few calculations that make one, two, three, four, and five diff --git a/tests/chapter_20/int_only/no_coalescing/unary_interference.c b/tests/chapter_20/int_only/no_coalescing/unary_interference.c index 3d828988..65c9aea1 100644 --- a/tests/chapter_20/int_only/no_coalescing/unary_interference.c +++ b/tests/chapter_20/int_only/no_coalescing/unary_interference.c @@ -3,7 +3,7 @@ * Only guaranteed to work as intended after implementing register coalescing. * */ -#include "../../libraries/util.h" // declares check_* and id functions +#include "../util.h" // declares check_* and id functions int main(void) { // negation diff --git a/tests/chapter_20/int_only/no_coalescing/unary_uses_operand.c b/tests/chapter_20/int_only/no_coalescing/unary_uses_operand.c index c3ac3650..08405416 100644 --- a/tests/chapter_20/int_only/no_coalescing/unary_uses_operand.c +++ b/tests/chapter_20/int_only/no_coalescing/unary_uses_operand.c @@ -4,7 +4,7 @@ * TODO consider using a common template for this and bin_uses_operand * */ -#include "../../libraries/util.h" +#include "../util.h" int glob = 1; diff --git a/tests/chapter_20/int_only/no_coalescing/use_all_hardregs.c b/tests/chapter_20/int_only/no_coalescing/use_all_hardregs.c index ce5cf7fe..fdd768f5 100644 --- a/tests/chapter_20/int_only/no_coalescing/use_all_hardregs.c +++ b/tests/chapter_20/int_only/no_coalescing/use_all_hardregs.c @@ -3,7 +3,7 @@ * and make sure we assign all of them to hardregs * This test program is generated from templates/chapter_20_templates/use_all_hardregs.c.jinja * */ -#include "../../libraries/util.h" +#include "../util.h" int global_one = 1; // to prevent constant-folding diff --git a/tests/chapter_20/int_only/util.h b/tests/chapter_20/int_only/util.h new file mode 100644 index 00000000..829e303f --- /dev/null +++ b/tests/chapter_20/int_only/util.h @@ -0,0 +1,17 @@ +/* Helper functions defined in tests/chapter_20/libraries/util.c */ + +/* The validate_* functions return 0 on success, + * print and exit with code -1 on failure. + */ + +int check_one_int(int actual, int expected); + +// Validates a == start, b == start + 1, ...e == start + 5 +int check_5_ints(int a, int b, int c, int d, int e, int start); + +// Validates a == start, b == start + 1, ... l == start + 11 +int check_12_ints(int a, int b, int c, int d, int e, int f, int g, int h, int i, + int j, int k, int l, int start); + +// return x; used to get constants in a way that can't be optimized away +int id(int x); diff --git a/tests/chapter_20/int_only/with_coalescing/briggs_coalesce.c b/tests/chapter_20/int_only/with_coalescing/briggs_coalesce.c index e9ceb96b..00ca84e2 100644 --- a/tests/chapter_20/int_only/with_coalescing/briggs_coalesce.c +++ b/tests/chapter_20/int_only/with_coalescing/briggs_coalesce.c @@ -6,7 +6,7 @@ * mov %rbp, %rsp in the prologue and epilogue) * */ -#include "../../libraries/util.h" +#include "../util.h" int glob0; int glob1; diff --git a/tests/chapter_20/int_only/with_coalescing/briggs_coalesce_hardreg.c b/tests/chapter_20/int_only/with_coalescing/briggs_coalesce_hardreg.c index 93e1fcad..f379c3db 100644 --- a/tests/chapter_20/int_only/with_coalescing/briggs_coalesce_hardreg.c +++ b/tests/chapter_20/int_only/with_coalescing/briggs_coalesce_hardreg.c @@ -10,7 +10,7 @@ * even if we don't perform register coalescing. * */ -#include "../../libraries/util.h" +#include "../util.h" int flag = 1; diff --git a/tests/chapter_20/int_only/with_coalescing/briggs_dont_coalesce.c b/tests/chapter_20/int_only/with_coalescing/briggs_dont_coalesce.c index 2eaa96e4..2fc19923 100644 --- a/tests/chapter_20/int_only/with_coalescing/briggs_dont_coalesce.c +++ b/tests/chapter_20/int_only/with_coalescing/briggs_dont_coalesce.c @@ -4,7 +4,7 @@ * sure there are no spills. * */ -#include "../../libraries/util.h" +#include "../util.h" int glob = 5; diff --git a/tests/chapter_20/int_only/with_coalescing/george_coalesce.c b/tests/chapter_20/int_only/with_coalescing/george_coalesce.c index 8b2c8ada..605e8311 100644 --- a/tests/chapter_20/int_only/with_coalescing/george_coalesce.c +++ b/tests/chapter_20/int_only/with_coalescing/george_coalesce.c @@ -5,7 +5,7 @@ * and destination are both general-purpose registers (except mov %rsp, %rbp and * mov %rbp, %rsp in the prologue and epilogue) * */ -#include "../../libraries/util.h" +#include "../util.h" int glob = 1; diff --git a/tests/chapter_20/int_only/with_coalescing/george_dont_coalesce.c b/tests/chapter_20/int_only/with_coalescing/george_dont_coalesce.c index e04e5ce3..64be2db2 100644 --- a/tests/chapter_20/int_only/with_coalescing/george_dont_coalesce.c +++ b/tests/chapter_20/int_only/with_coalescing/george_dont_coalesce.c @@ -6,7 +6,7 @@ * sure there are no spills. * */ -#include "../../libraries/util.h" +#include "../util.h" int glob = 1; diff --git a/tests/chapter_20/int_only/with_coalescing/george_dont_coalesce_2.c b/tests/chapter_20/int_only/with_coalescing/george_dont_coalesce_2.c index 28ddfac0..d8b95d6f 100644 --- a/tests/chapter_20/int_only/with_coalescing/george_dont_coalesce_2.c +++ b/tests/chapter_20/int_only/with_coalescing/george_dont_coalesce_2.c @@ -6,7 +6,7 @@ * assembly for target to make sure there are no spills. * */ -#include "../../libraries/util.h" +#include "../util.h" int glob = 1; diff --git a/tests/chapter_20/int_only/with_coalescing/george_off_by_one.c b/tests/chapter_20/int_only/with_coalescing/george_off_by_one.c index 5e53244b..90a659b9 100644 --- a/tests/chapter_20/int_only/with_coalescing/george_off_by_one.c +++ b/tests/chapter_20/int_only/with_coalescing/george_off_by_one.c @@ -4,7 +4,7 @@ * adequately covered by other tests. * */ -#include "../../libraries/util.h" +#include "../util.h" int glob = 0; diff --git a/tests/chapter_20/int_only/with_coalescing/no_george_test_for_pseudos.c b/tests/chapter_20/int_only/with_coalescing/no_george_test_for_pseudos.c index 3846c2c8..8ce87b05 100644 --- a/tests/chapter_20/int_only/with_coalescing/no_george_test_for_pseudos.c +++ b/tests/chapter_20/int_only/with_coalescing/no_george_test_for_pseudos.c @@ -7,7 +7,7 @@ * make sure it has no more than the expected number of spill instructions. * */ -#include "../../libraries/util.h" // declares check_* and id functions +#include "../util.h" // declares check_* and id functions // TODO consider refactoring with spill_test_metric, some of this is copy-pasted // from there