Skip to content

Commit

Permalink
Merge pull request #37 from nlsandler/int-only-fix
Browse files Browse the repository at this point in the history
Avoid Part II features in --int-only chapter 20 tests; better CI
  • Loading branch information
nlsandler authored Jul 9, 2024
2 parents 4901505 + 44030b3 commit 914beab
Show file tree
Hide file tree
Showing 41 changed files with 70 additions and 38 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/test_all_commits.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/test_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Compiler Test Suite CI

on:
pull_request:
branches: [ "main", "complete-test-suite" ]
branches: [ "main" ]

workflow_dispatch:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../../libraries/util.h"
#include "../util.h"

int glob = 3;
double glob2 = 4.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_<PLATFORM>.s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Look for: no spills
*/

#include "../../libraries/util.h"
#include "../util.h"

int glob1 = 1;
int glob2 = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_<PLATFORM>.s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* pseudoregisters conflict at any time.
* */

#include "../../libraries/util.h"
#include "../util.h"

int glob0 = 0;
int glob1 = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/chapter_20/int_only/no_coalescing/division_uses_ax.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/chapter_20/int_only/no_coalescing/eax_live_at_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/chapter_20/int_only/no_coalescing/force_spill.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/chapter_20/int_only/no_coalescing/loop.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* accident.
*/

#include "../../libraries/util.h"
#include "../util.h"

int glob1 = 1;
int glob2 = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* resulting in more memory accesses overall.
*/

#include "../../libraries/util.h"
#include "../util.h"

int target(void) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* allocate them, resulting in spills.
* */

#include "../../libraries/util.h"
#include "../util.h"

int glob1;
int glob2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/chapter_20/int_only/no_coalescing/use_all_hardregs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions tests/chapter_20/int_only/util.h
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* mov %rbp, %rsp in the prologue and epilogue)
* */

#include "../../libraries/util.h"
#include "../util.h"

int glob0;
int glob1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* even if we don't perform register coalescing.
* */

#include "../../libraries/util.h"
#include "../util.h"

int flag = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* sure there are no spills.
* */

#include "../../libraries/util.h"
#include "../util.h"

int glob = 5;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* sure there are no spills.
* */

#include "../../libraries/util.h"
#include "../util.h"

int glob = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* assembly for target to make sure there are no spills.
* */

#include "../../libraries/util.h"
#include "../util.h"

int glob = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* adequately covered by other tests.
* */

#include "../../libraries/util.h"
#include "../util.h"

int glob = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 914beab

Please sign in to comment.