mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-26 12:49:21 +00:00
Added -vfixlongbranch to give more info about the fix long branch pass.
This commit is contained in:
parent
5d6fcca6c2
commit
075974063a
9
.idea/codeStyles/Project.xml
generated
9
.idea/codeStyles/Project.xml
generated
@ -4,15 +4,6 @@
|
||||
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
|
||||
<option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
|
||||
</JavaCodeStyleSettings>
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" withSubpackages="false" static="false" />
|
||||
<package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
|
||||
<package name="io.ktor" withSubpackages="true" static="false" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
|
||||
|
@ -85,6 +85,11 @@ public class CompileLog {
|
||||
*/
|
||||
private boolean verboseSsaSourceCode = false;
|
||||
|
||||
/**
|
||||
* Print verbose info in the fix long branch fix pass
|
||||
*/
|
||||
private boolean verboseFixLongBranch = false;
|
||||
|
||||
/**
|
||||
* Should the log be output to System.out while being built
|
||||
*/
|
||||
@ -132,6 +137,14 @@ public class CompileLog {
|
||||
this.verboseSsaSourceCode = verboseSsaSourceCode;
|
||||
}
|
||||
|
||||
public boolean isVerboseFixLongBranch() {
|
||||
return verboseFixLongBranch;
|
||||
}
|
||||
|
||||
public void setVerboseFixLongBranch(boolean verboseFixLongBranch) {
|
||||
this.verboseFixLongBranch = verboseFixLongBranch;
|
||||
}
|
||||
|
||||
public boolean isVerboseCreateSsa() {
|
||||
return verboseCreateSsa;
|
||||
}
|
||||
|
@ -146,6 +146,9 @@ public class KickC implements Callable<Integer> {
|
||||
@CommandLine.Option(names = {"-vasmoptimize"}, description = "Verbosity Option. Assembler optimization.")
|
||||
private boolean verboseAsmOptimize = false;
|
||||
|
||||
@CommandLine.Option(names = {"-vfixlongbranch"}, description = "Verbosity Option. Fix Long ASM branches.")
|
||||
private boolean verboseFixLongBranch = false;
|
||||
|
||||
@CommandLine.Option(names = {"-Wfragment"}, description = "Warning Option. Missing fragments produces a warning instead of an error.")
|
||||
private boolean warnFragmentMissing = false;
|
||||
|
||||
@ -564,6 +567,11 @@ public class KickC implements Callable<Integer> {
|
||||
compiler.getLog().setVerboseAsmOptimize(true);
|
||||
compiler.getLog().setSysOut(true);
|
||||
}
|
||||
if(verboseFixLongBranch) {
|
||||
compiler.getLog().setVerboseFixLongBranch(true);
|
||||
compiler.getLog().setSysOut(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,30 +80,37 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization {
|
||||
} catch(Throwable e) {
|
||||
if(e instanceof AssertionError && e.getMessage().contains("Invalid number of bytes in memblock!")) {
|
||||
throw new CompileError("Error! KickAssembler failed due to assertion. Please run java without -ea / -enableassertions.", e);
|
||||
} else {
|
||||
} else {
|
||||
throw new CompileError("Error! KickAssembler failed, while trying to fix long branch. " + e);
|
||||
}
|
||||
} finally {
|
||||
} finally {
|
||||
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
|
||||
}
|
||||
String output = kickAssOut.toString();
|
||||
|
||||
if(getLog().isVerboseFixLongBranch())
|
||||
getLog().append("Pass5FixLongBranches: ASM process result " + asmRes);
|
||||
|
||||
// Look for a long branch distance error
|
||||
if(asmRes != 0) {
|
||||
String outputLines[] = output.split("\\r?\\n");
|
||||
if(getLog().isVerboseFixLongBranch())
|
||||
getLog().append("Pass5FixLongBranches: Number of ASM lines " + outputLines.length);
|
||||
for(int i = 0; i < outputLines.length; i++) {
|
||||
String outputLine = outputLines[i];
|
||||
if(outputLine.contains("Error: relative address is illegal (jump distance is too far).")) {
|
||||
// Found a long branch!
|
||||
String contextLine = outputLines[i + 1];
|
||||
if(getLog().isVerboseFixLongBranch())
|
||||
getLog().append("Pass5FixLongBranches: Found long branch " + contextLine);
|
||||
Pattern contextPattern = Pattern.compile("at line ([0-9]*),.*");
|
||||
Matcher matcher = contextPattern.matcher(contextLine);
|
||||
//getLog().append("Found long branch "+contextLine);
|
||||
if(matcher.matches()) {
|
||||
String contextLineIdxStr = matcher.group(1);
|
||||
int contextLineIdx = Integer.parseInt(contextLineIdxStr);
|
||||
// Found line number
|
||||
//getLog().append("Found long branch line number "+contextLineIdx);
|
||||
if(getLog().isVerboseFixLongBranch())
|
||||
getLog().append("Pass5FixLongBranches: Found long branch line number " + contextLineIdx);
|
||||
if(fixLongBranch(contextLineIdx - 1)) {
|
||||
return true;
|
||||
}
|
||||
@ -138,7 +145,7 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization {
|
||||
String branchDest = asmInstruction.getOperandJumpTarget();
|
||||
asmInstruction.setCpuOpcode(inverseCpuOpcode);
|
||||
String newLabel = AsmFormat.asmFix("!" + branchDest);
|
||||
asmInstruction.setOperandJumpTarget(newLabel+"+");
|
||||
asmInstruction.setOperandJumpTarget(newLabel + "+");
|
||||
CpuOpcode jmpOpcode = getAsmProgram().getTargetCpu().getCpu65xx().getOpcode("jmp", CpuAddressingMode.ABS, false);
|
||||
AsmInstruction jmpInstruction = new AsmInstruction(jmpOpcode, branchDest, null);
|
||||
asmChunk.addLineAfter(asmInstruction, jmpInstruction);
|
||||
@ -186,7 +193,7 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization {
|
||||
}
|
||||
|
||||
private static File getTmpFile(Path tmpDir, String fileName) {
|
||||
return new File(tmpDir.toFile(), fileName );
|
||||
return new File(tmpDir.toFile(), fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user