1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-08-02 09:29:35 +00:00

Removed all redundant fragment ASM files.

This commit is contained in:
jespergravgaard 2017-12-30 22:17:42 +01:00
parent 4f30cef2d3
commit aeba75906b
131 changed files with 36 additions and 428 deletions

View File

@ -8,7 +8,6 @@ import org.antlr.v4.runtime.CharStreams;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.text.NumberFormat;
import java.util.*;
/**
@ -103,10 +102,12 @@ public class AsmFragmentManager {
* @param log The compile log to add the output to
*/
public static void logUsages(CompileLog log) {
log.append("ASM FRAGMENT USAGES");
ArrayList<String> signatures = new ArrayList<>(fragmentTemplateCache.keySet());
Collections.sort(signatures);
/*
log.append("ASM FRAGMENT USAGES");
for (String signature : signatures) {
List<AsmFragmentTemplate> templates = fragmentTemplateCache.get(signature);
for (AsmFragmentTemplate template : templates) {
@ -115,6 +116,34 @@ public class AsmFragmentManager {
log.append(String.format("%8d", usage)+" "+template.getName());
}
}
*/
// Find all file fragments that were bested by a synthesized fragment
log.append("\nREDUNDANT ASM FRAGMENT FILES - REMOVE FROM DISK");
for (String signature : signatures) {
List<AsmFragmentTemplate> templates = fragmentTemplateCache.get(signature);
AsmFragmentTemplate fileTemplate = null;
int fileUsage = 0;
AsmFragmentTemplate maxTemplate = null;
int maxUsage = 0;
for (AsmFragmentTemplate template : templates) {
Integer usage = fragmentTemplateUsage.get(template);
if(usage==null) usage = 0;
if(template.isFile()) {
fileTemplate = template;
fileUsage = usage;
}
if(usage>maxUsage) {
maxUsage = usage;
maxTemplate = template;
}
}
if(fileTemplate!=null && fileUsage==0 && maxUsage>0) {
log.append("rm "+fileTemplate.getName()+".asm #synthesized by "+maxTemplate.getName()+" - usages: "+maxUsage);
}
}
}

View File

@ -20,7 +20,7 @@ public class AsmFragmentTemplate {
private KickCParser.AsmLinesContext bodyAsm;
/** true if the fragment was loaded from disk. */
boolean loaded;
boolean file;
/** The synthesis that created the fragment. null if the fragment template was loaded. */
private AsmFragmentSynthesis synthesis;
@ -31,7 +31,7 @@ public class AsmFragmentTemplate {
public AsmFragmentTemplate(String signature, String body) {
this.signature = signature;
this.body = body;
this.loaded = true;
this.file = true;
}
AsmFragmentTemplate(String signature, String body, AsmFragmentSynthesis synthesis, AsmFragmentTemplate subFragment) {
@ -39,7 +39,7 @@ public class AsmFragmentTemplate {
this.body = body;
this.synthesis = synthesis;
this.subFragment = subFragment;
this.loaded = false;
this.file = false;
}
/**
@ -90,8 +90,8 @@ public class AsmFragmentTemplate {
}
public boolean isLoaded() {
return loaded;
public boolean isFile() {
return file;
}
public AsmFragmentSynthesis getSynthesis() {

View File

@ -1,2 +0,0 @@
lda #{c2}
sta {c1}

View File

@ -1,2 +0,0 @@
lda {z1}
sta {c1}

View File

@ -1,3 +0,0 @@
ldy #0
lda #{c1}
sta ({z1}),y

View File

@ -1,3 +0,0 @@
txa
ldy #0
sta ({z1}),y

View File

@ -1,3 +0,0 @@
tya
ldy #0
sta ({z1}),y

View File

@ -1,3 +0,0 @@
ldy #0
lda {z2}
sta ({z1}),y

View File

@ -1,3 +0,0 @@
tax
lda {z1}
sta {c1},x

View File

@ -1,2 +0,0 @@
lda #{c2}
sta {c1},x

View File

@ -1,2 +0,0 @@
lda #{c2}
sta {c1},y

View File

@ -1,3 +0,0 @@
lda #{c2}
ldx {z1}
sta {c1},x

View File

@ -1,3 +0,0 @@
txa
ldx {z1}
sta {c1},x

View File

@ -1,3 +0,0 @@
tya
ldy {z1}
sta {c1},y

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {z1}
lda #>{c1}
sta {z1}+1

View File

@ -1,4 +0,0 @@
inc {z1}
bne !+
inc {z1}+1
!:

View File

@ -1,8 +0,0 @@
lda {z1}
clc
adc #<{c1}
sta {z1}
lda {z1}+1
adc #>{c1}
sta {z1}+1

View File

@ -1,7 +0,0 @@
lda {z2}
clc
adc #1
sta {z1}
lda {z2}+1
adc #0
sta {z1}+1

View File

@ -1,7 +0,0 @@
lda #<{c1}
clc
adc {z2}
sta {z1}
lda #>{c1}
adc {z2}+1
sta {z1}+1

View File

@ -1,4 +0,0 @@
stx $ff
tay
lda $ff
sta ({z1}),y

View File

@ -1,4 +0,0 @@
sty $ff
tay
lda $ff
sta ({z1}),y

View File

@ -1,3 +0,0 @@
tay
lda {z2}
sta ({z1}),y

View File

@ -1,3 +0,0 @@
txa
ldy #{c1}
sta ({z1}),y

View File

@ -1,3 +0,0 @@
tya
ldy #{c1}
sta ({z1}),y

View File

@ -1,3 +0,0 @@
lda {z2}
ldy #{c1}
sta ({z1}),y

View File

@ -1,5 +0,0 @@
sty $ff
txa
tay
lda $ff
sta ({z1}),y

View File

@ -1,2 +0,0 @@
lda {z2}
sta ({z1}),y

View File

@ -1,3 +0,0 @@
ldy {z2}
txa
sta ({z1}),y

View File

@ -1,3 +0,0 @@
tya
ldy {z2}
sta ({z1}),y

View File

@ -1,3 +0,0 @@
lda {z3}
ldy {z2}
sta ({z1}),y

View File

@ -1,3 +0,0 @@
txa
clc
adc #1

View File

@ -1,3 +0,0 @@
tya
clc
adc #1

View File

@ -1,3 +0,0 @@
lda {z1}
clc
adc #1

View File

@ -1,2 +0,0 @@
ldy {z2}
lda ({z1}),y

View File

@ -1,4 +0,0 @@
stx $ff
lda #{c1}
sec
sbc $ff

View File

@ -1,4 +0,0 @@
sty $ff
lda #{c1}
sec
sbc $ff

View File

@ -1,3 +0,0 @@
lda {z1}
clc
adc #{c1}

View File

@ -1,4 +0,0 @@
txa
sty $ff
sec
sbc $ff

View File

@ -1,3 +0,0 @@
stx $ff
clc
adc $ff

View File

@ -1,3 +0,0 @@
txa
clc
adc #{c1}

View File

@ -1,4 +0,0 @@
stx $ff
tya
clc
adc $ff

View File

@ -1,4 +0,0 @@
tya
stx $ff
sec
sbc $ff

View File

@ -1,3 +0,0 @@
sty $ff
clc
adc $ff

View File

@ -1,3 +0,0 @@
tya
clc
adc #{c1}

View File

@ -1,4 +0,0 @@
sty $ff
txa
clc
adc $ff

View File

@ -1,4 +0,0 @@
stx $ff
lda {z1}
sec
sbc $ff

View File

@ -1,4 +0,0 @@
sty $ff
lda {z1}
sec
sbc $ff

View File

@ -1,3 +0,0 @@
lda {z1}
sec
sbc {z2}

View File

@ -1,3 +0,0 @@
lda {z1}
clc
adc #1

View File

@ -1,3 +0,0 @@
lda {z1}
clc
adc #{c1}

View File

@ -1,3 +0,0 @@
lda {z1}
clc
adc {z2}

View File

@ -1,3 +0,0 @@
lda {z1}
lsr
lsr

View File

@ -1,2 +0,0 @@
sty $ff
ldx $ff

View File

@ -1,3 +0,0 @@
ldy #0
lda ({z1}),y
tax

View File

@ -1,3 +0,0 @@
sty $ff
ldx $ff
inx

View File

@ -1,2 +0,0 @@
stx $ff
ldy $ff

View File

@ -1,3 +0,0 @@
stx $ff
ldy $ff
iny

View File

@ -1,3 +0,0 @@
sty $ff
cpx $ff
bne {la1}

View File

@ -1,2 +0,0 @@
sta {z1}
inc {z1}

View File

@ -1,3 +0,0 @@
lda {z2}
sta {z1}
inc {z1}

View File

@ -1,3 +0,0 @@
ldy {z3}
lda ({z2}),y
sta {z1}

View File

@ -1,4 +0,0 @@
txa
lsr
lsr
sta {z1}

View File

@ -1,5 +0,0 @@
sta $ff
lda {z1}
sec
sbc $ff
sta {z1}

Some files were not shown because too many files have changed in this diff Show More