1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-07-06 11:29:04 +00:00

Improved selfmod fragments. Added needed fragments that is not self-modifying. Fixed -Wfragment in pass4.

This commit is contained in:
jespergravgaard 2019-09-09 01:31:21 +02:00
parent 8d8dcd78fb
commit a1f4656f79
7 changed files with 25 additions and 15 deletions

View File

@ -0,0 +1,9 @@
pha
lda ({z1}),y
sta $fe
iny
lda ({z1}),y
sta $ff
pla
ldy #0
sta ($fe),y

View File

@ -4,5 +4,4 @@ sta !+ +1
iny
lda ({z1}),y
sta !+ +2
txa
!: sta $ffff
!: stx $ffff

View File

@ -35,9 +35,6 @@ public class Compiler {
* Currently the optimization is flaky and results in NPE's and wrong values in some programs. */
private boolean enableLoopHeadConstant = false;
/** Missing fragments produce a warning instead of an error */
private boolean warnFragmentMissing = false;
/** File name of link script to use (from command line parameter). */
private String linkScriptFileName;
@ -45,12 +42,8 @@ public class Compiler {
this.program = new Program();
}
public boolean isWarnFragmentMissing() {
return warnFragmentMissing;
}
public void setWarnFragmentMissing(boolean warnFragmentMissing) {
this.warnFragmentMissing = warnFragmentMissing;
program.setWarnFragmentMissing(warnFragmentMissing);
}
public void setLinkScriptFileName(String linkScript) {
@ -509,7 +502,7 @@ public class Compiler {
new Pass4RegistersFinalize(program).allocate(true);
// Initial Code generation
new Pass4CodeGeneration(program, false, warnFragmentMissing).generate();
new Pass4CodeGeneration(program, false, program.isWarnFragmentMissing()).generate();
new Pass4AssertNoCpuClobber(program).check();
getLog().append("\nINITIAL ASM");
getLog().append("Target platform is " + program.getTargetPlatform().getName() + " / " +program.getTargetCpu().getName().toUpperCase(Locale.ENGLISH));
@ -555,7 +548,7 @@ public class Compiler {
// Final ASM code generation before optimization
program.clearPhiTransitions();
new Pass4CodeGeneration(program, false, warnFragmentMissing).generate();
new Pass4CodeGeneration(program, false, program.isWarnFragmentMissing()).generate();
new Pass4AssertNoCpuClobber(program).check();
// Remove unnecessary register savings from interrupts {@link InterruptType#HARDWARE_NOCLOBBER}

View File

@ -41,6 +41,9 @@ public class Program {
/** The ASM fragment synthesizer responsible for loading/synthesizing ASM fragments. Depends on the target CPU. (STATIC) */
private AsmFragmentTemplateSynthesizer asmFragmentSynthesizer;
/** Missing fragments produce a warning instead of an error (STATIC) */
private boolean warnFragmentMissing = false;
/** Path to any custom link script file used for linking (STATIC) */
private Path linkScriptFilePath;
/** Body to any custom link script file used for linking (STATIC) */
@ -168,6 +171,14 @@ public class Program {
this.asm = null;
}
public boolean isWarnFragmentMissing() {
return warnFragmentMissing;
}
public void setWarnFragmentMissing(boolean warnFragmentMissing) {
this.warnFragmentMissing = warnFragmentMissing;
}
public Path getAsmFragmentCacheFolder() {
return asmFragmentCacheFolder;
}

View File

@ -110,7 +110,7 @@ public class Pass4RegisterUpliftCombinations extends Pass2Base {
// Generate ASM
try {
program.clearPhiTransitions();
new Pass4CodeGeneration(program, false, false).generate();
new Pass4CodeGeneration(program, false, program.isWarnFragmentMissing()).generate();
} catch(AsmFragmentTemplateSynthesizer.UnknownFragmentException e) {
unknownFragments.add(e.getFragmentSignature());
if(program.getLog().isVerboseUplift()) {

View File

@ -3,7 +3,6 @@ package dk.camelot64.kickc.test;
import dk.camelot64.kickc.CompileLog;
import dk.camelot64.kickc.Compiler;
import dk.camelot64.kickc.asm.AsmProgram;
import dk.camelot64.kickc.fragment.AsmFragmentTemplateSynthesizer;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.model.Program;
import kickass.KickAssembler;