-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
whole pipeline tests and some corrections/improvements to earlier cha…
…pter 19 tests
- Loading branch information
Showing
49 changed files
with
1,621 additions
and
135 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,4 @@ int main(void) { | |
} | ||
|
||
return 0; | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
tests/chapter_19/constant_folding/all_types/fold_conditional_jump.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* Test constant folding of JumpIfZero and JumpIfNotZero instructions | ||
* resulting from && and || operations, with operand types other than int. | ||
* Identical to chapter_19/constant_folding/int_only/fold_conditional_jump.c | ||
* but with non-int operands | ||
* */ | ||
#if defined SUPPRESS_WARNINGS && defined __clang__ | ||
#pragma clang diagnostic ignored "-Wliteral-conversion" | ||
#endif | ||
|
||
// We'll emit two TACKY instructions of the form | ||
// JumpIfZero(0, false_label) | ||
// both should be rewritten as Jump instructions | ||
int target_jz_to_jmp(void) { | ||
return 0l && 0; // 0 | ||
} | ||
|
||
// We'll emit two TACKY instructions of the form | ||
// JumpIfZero(1, false_label) | ||
// both should be removed | ||
int target_remove_jz(void) { | ||
return 1u && 1.; // 1 | ||
} | ||
|
||
// We'll emit two JumpIfNotZero instructions: | ||
// JumpIfNotZero(3, true_label) | ||
// JumpIfNotZero(99, true_label) | ||
// both should be written as Jump instructions | ||
int target_jnz_to_jmp(void) { | ||
return 3.5 || 99ul; // 1 | ||
} | ||
|
||
// We'll emit two JumpIfNotZero instructions: | ||
// JumpIfNotZero(0, true_label) | ||
// JumpIfNotZero(1, true_label) | ||
// we should remove the first, rewrite the second as a Jump instruction | ||
int target_remove_jnz(void) { | ||
return 0ul || 1; // 1 | ||
} | ||
|
||
int main(void) { | ||
if (target_jz_to_jmp() != 0) { | ||
return 1; | ||
} | ||
if (target_remove_jz() != 1) { | ||
return 2; | ||
} | ||
if (target_jnz_to_jmp() != 1) { | ||
return 3; | ||
} | ||
if (target_remove_jnz() != 1) { | ||
return 4; | ||
} | ||
return 0; // success | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/chapter_19/constant_folding/all_types/negative_zero.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* If we deduplicate floating-point StaticConstant constructs, make sure we | ||
* distinguish between constants with the same value but different alignments. | ||
* Specifically, if we've already added an ordinary constant -0.0, and then we | ||
* need a 16-byte aligned -0.0 to use for negation, don't just reuse the | ||
* previous 8-byte aligned one. (It's okay to either keep them as separate | ||
* constants, or merge them and keep the higher alignment.) This is a regression | ||
* test for a bug in the reference implementation. Note that we can only catch | ||
* this bug once we implement constant folding; before then, we don't add | ||
* positive StaticConstants. | ||
* No 'target' function here because we're just looking for correctness, | ||
* not inspecting assembly. | ||
* */ | ||
|
||
double x = 5.0; | ||
|
||
int main(void) { | ||
double d = -0.0; // add normal constant -0. to list of top-level constants | ||
return (-x > d); // add 16-byte-aligned constant -0. to negate x | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.