1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-06-25 19:29:49 +00:00

Compare commits

..

No commits in common. "6f294d6dec78bbcea5f7818d97c5a71e7132e4f7" and "6af84d1628cd6e8b62e5c4df83198dcfa052719b" have entirely different histories.

5 changed files with 5 additions and 23 deletions

View File

@ -662,7 +662,7 @@ object Main {
c.changeFlag(CompilationFlag.CompactReturnDispatchParams, v)
}.description("Whether parameter values in return dispatch statements may overlap other objects. Enabled by default.")
boolean("-fbounds-checking", "-fno-bounds-checking").action { (c, v) =>
c.changeFlag(CompilationFlag.CheckIndexOutOfBounds, v)
c.changeFlag(CompilationFlag.VariableOverlap, v)
}.description("Whether should insert bounds checking on array access.")
boolean("-flenient-encoding", "-fno-lenient-encoding").action { (c, v) =>
c.changeFlag(CompilationFlag.LenientTextEncoding, v)

View File

@ -15,7 +15,7 @@ object DangerousOptimizations {
// TODO: try to guess when overflow can happen
needsFlowInfo = FlowInfoRequirement.BothFlows,
(Elidable & HasOpcode(CLC)).? ~
(Elidable & HasClear(State.C) & HasClear(State.D) & HasOpcode(ADC) & MatchImmediate(0) & DoesntMatterWhatItDoesWith(State.V, State.C)) ~
(Elidable & HasClear(State.C) & HasOpcode(ADC) & MatchImmediate(0) & DoesntMatterWhatItDoesWith(State.V, State.C)) ~
(
(HasOpcode(TAY) & DoesntMatterWhatItDoesWith(State.N, State.Z, State.A)) ~
(Linear & Not(ConcernsY)).*
@ -25,7 +25,7 @@ object DangerousOptimizations {
ctx.get[List[AssemblyLine]](1) :+ last.copy(parameter = last.parameter.+(ctx.get[Constant](0)).quickSimplify)
},
(Elidable & HasOpcode(CLC)).? ~
(Elidable & HasClear(State.C) & HasClear(State.D) & HasOpcode(ADC) & MatchImmediate(0) & DoesntMatterWhatItDoesWith(State.V, State.C)) ~
(Elidable & HasClear(State.C) & HasOpcode(ADC) & MatchImmediate(0) & DoesntMatterWhatItDoesWith(State.V, State.C)) ~
(
(HasOpcode(TAX) & DoesntMatterWhatItDoesWith(State.N, State.Z, State.A)) ~
(Linear & Not(ConcernsX)).*

View File

@ -48,7 +48,7 @@ abstract class CallGraph(program: Program, log: Logger) {
case f: FunctionDeclarationStatement =>
allFunctions += f.name
allFunctions += f.name + ".trampoline" // TODO: ???
if (f.address.isDefined || f.interrupt || f.kernalInterrupt) entryPoints += f.name
if (f.address.isDefined || f.interrupt) entryPoints += f.name
f.statements.getOrElse(Nil).foreach(s => this.add(Some(f.name), Nil, s))
case s: Statement =>
s.getAllExpressions.foreach(e => add(currentFunction, callingFunctions, e))

View File

@ -722,7 +722,7 @@ case class StandardReturnDispatchLabel(labels:List[Expression]) extends ReturnDi
}
case class ReturnDispatchBranch(label: ReturnDispatchLabel, function: Expression, params: List[Expression]) extends Node {
def getAllExpressions: List[Expression] = label.getAllExpressions ++ params :+ function
def getAllExpressions: List[Expression] = label.getAllExpressions ++ params
}
case class ReturnDispatchStatement(indexer: Expression, params: List[LhsExpression], branches: List[ReturnDispatchBranch]) extends ExecutableStatement {

View File

@ -167,22 +167,4 @@ class ReturnDispatchSuite extends FunSuite with Matchers {
| void success() {}
""".stripMargin)
}
test("Optimization test") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Motorola6809)(
"""
| byte output @$c000
| void main () {
| if true {
| return [1] {
| 1 @ success
| }
| }
| }
| void success() {
| output = 42
| }
""".stripMargin) { m =>
m.readByte(0xc000) should equal(42)
}
}
}