From 2b26c813d989907f0ead3bed66e975c0b0aebfca Mon Sep 17 00:00:00 2001 From: Jesper Gravgaard Date: Mon, 20 May 2019 11:01:58 +0200 Subject: [PATCH] Rafactoring pass 2 --- src/main/fragment/vduz1=vwuz2_dword_vbuc1.asm | 8 ++++---- src/main/fragment/vduz1=vwuz2_dword_vwuc1.asm | 8 ++++++++ src/main/java/dk/camelot64/kickc/Compiler.java | 2 +- ...rd.java => PassNDowngradeConstantTypeConversions.java} | 4 ++-- src/test/ref/linegen.asm | 5 ++--- 5 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 src/main/fragment/vduz1=vwuz2_dword_vwuc1.asm rename src/main/java/dk/camelot64/kickc/passes/{PassNDowngradeBytePlusWord.java => PassNDowngradeConstantTypeConversions.java} (96%) diff --git a/src/main/fragment/vduz1=vwuz2_dword_vbuc1.asm b/src/main/fragment/vduz1=vwuz2_dword_vbuc1.asm index a704a0e79..ee4169530 100644 --- a/src/main/fragment/vduz1=vwuz2_dword_vbuc1.asm +++ b/src/main/fragment/vduz1=vwuz2_dword_vbuc1.asm @@ -1,8 +1,8 @@ -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 lda {z2} sta {z1}+2 lda {z2}+1 sta {z1}+3 +lda #{c1} +sta {z1} +lda #0 +sta {z1}+1 diff --git a/src/main/fragment/vduz1=vwuz2_dword_vwuc1.asm b/src/main/fragment/vduz1=vwuz2_dword_vwuc1.asm new file mode 100644 index 000000000..a704a0e79 --- /dev/null +++ b/src/main/fragment/vduz1=vwuz2_dword_vwuc1.asm @@ -0,0 +1,8 @@ +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 +lda {z2} +sta {z1}+2 +lda {z2}+1 +sta {z1}+3 diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index 252e07f27..5c86cc61e 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -233,7 +233,7 @@ public class Compiler { List optimizations = new ArrayList<>(); optimizations.add(new PassNAddNumberTypeConversions(program)); optimizations.add(new PassNAddArrayNumberTypeConversions(program)); - optimizations.add(new PassNDowngradeBytePlusWord(program)); + optimizations.add(new PassNDowngradeConstantTypeConversions(program)); optimizations.add(new PassNTypeInference(program)); optimizations.add(new PassNTypeIdSimplification(program)); optimizations.add(new Pass2SizeOfSimplification(program)); diff --git a/src/main/java/dk/camelot64/kickc/passes/PassNDowngradeBytePlusWord.java b/src/main/java/dk/camelot64/kickc/passes/PassNDowngradeConstantTypeConversions.java similarity index 96% rename from src/main/java/dk/camelot64/kickc/passes/PassNDowngradeBytePlusWord.java rename to src/main/java/dk/camelot64/kickc/passes/PassNDowngradeConstantTypeConversions.java index b3f819d53..85a6db2cb 100644 --- a/src/main/java/dk/camelot64/kickc/passes/PassNDowngradeBytePlusWord.java +++ b/src/main/java/dk/camelot64/kickc/passes/PassNDowngradeConstantTypeConversions.java @@ -13,9 +13,9 @@ import java.util.concurrent.atomic.AtomicBoolean; /** * Downgrade any number expression cast that are part of a WORD+NUMBER expression to BYTE if the number is small enough to fit in the byte. */ -public class PassNDowngradeBytePlusWord extends Pass2SsaOptimization { +public class PassNDowngradeConstantTypeConversions extends Pass2SsaOptimization { - public PassNDowngradeBytePlusWord(Program program) { + public PassNDowngradeConstantTypeConversions(Program program) { super(program); } diff --git a/src/test/ref/linegen.asm b/src/test/ref/linegen.asm index 4cbd79681..4b4fcd8a9 100644 --- a/src/test/ref/linegen.asm +++ b/src/test/ref/linegen.asm @@ -335,14 +335,13 @@ lin16u_gen: { sta step lda stepf+1 sta step+1 - lda #<0 - sta val - sta val+1 lda min sta val+2 lda min+1 sta val+3 lda #0 + sta val + sta val+1 sta i sta i+1 b1: