From 7720eb8c13da06e016c74654155f1f852632693b Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 1 Mar 2020 17:05:54 +0100 Subject: [PATCH] Added tests illustrating stack call live range problems. --- .../dk/camelot64/kickc/test/TestPrograms.java | 14 ++++++++++++ .../kc/procedure-callingconvention-stack-7.kc | 21 ++++++++++++++++++ .../kc/procedure-callingconvention-stack-8.kc | 22 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/test/kc/procedure-callingconvention-stack-7.kc create mode 100644 src/test/kc/procedure-callingconvention-stack-8.kc diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index f27f8f086..f918d7d97 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -279,6 +279,20 @@ public class TestPrograms { compileAndCompare("declared-memory-var-0"); } + /* + @Test + public void testProcedureCallingConventionStack8() throws IOException, URISyntaxException { + compileAndCompare("procedure-callingconvention-stack-8", log().verboseLiveRanges()); //, log().verboseCreateSsa().verboseParse().verboseStatementSequence()); + } + */ + + /* + @Test + public void testProcedureCallingConventionStack7() throws IOException, URISyntaxException { + compileAndCompare("procedure-callingconvention-stack-7", log().verboseLiveRanges()); //, log().verboseCreateSsa().verboseParse().verboseStatementSequence()); + } + */ + /* @Test public void testProcedureCallingConventionStack6() throws IOException, URISyntaxException { diff --git a/src/test/kc/procedure-callingconvention-stack-7.kc b/src/test/kc/procedure-callingconvention-stack-7.kc new file mode 100644 index 000000000..fa6972f4a --- /dev/null +++ b/src/test/kc/procedure-callingconvention-stack-7.kc @@ -0,0 +1,21 @@ +// Test a procedure with calling convention stack +// Illustrates live range problem with variables in different functions main::val and printline::i + +#pragma calling(__stackcall) +#pragma var_model(ma_zp) + +const char* SCREEN = 0x0400; + +void main(void) { + char val = 0; + val = '-'; + printline(); + SCREEN[80] = val; +} + +void printline() { + for(char i=0; i<40; i++) { + SCREEN[i] = '*'; + } +} + diff --git a/src/test/kc/procedure-callingconvention-stack-8.kc b/src/test/kc/procedure-callingconvention-stack-8.kc new file mode 100644 index 000000000..e58b16489 --- /dev/null +++ b/src/test/kc/procedure-callingconvention-stack-8.kc @@ -0,0 +1,22 @@ +// Test a procedure with calling convention stack +// Illustrates live range problem with variable function printline::i and global variable val + +#pragma calling(__stackcall) +#pragma var_model(ma_zp) + +const char* SCREEN = 0x0400; + +char val = 0; + +void main(void) { + val = '-'; + printline(); + SCREEN[80] = val; +} + +void printline() { + for(char i=0; i<40; i++) { + SCREEN[i] = '*'; + } +} +