mirror of
https://github.com/KarolS/millfork.git
synced 2024-06-16 18:29:31 +00:00
Added new -O1 optimization preset
This commit is contained in:
parent
a2b6a392a5
commit
747925f8fd
|
@ -4,6 +4,8 @@
|
|||
|
||||
* **Breaking change!** Renamed `inline` to `macro`.
|
||||
|
||||
* Added new `-O1` optimization preset; old `-O1` became `-O2`, old `-O2` became `-O3` and so on.
|
||||
|
||||
* Added support for parameters for macros written in Millfork.
|
||||
|
||||
* Enabled calling macros with index expression parameters.
|
||||
|
|
|
@ -86,14 +86,19 @@ object Main {
|
|||
|
||||
val env = new Environment(None, "")
|
||||
env.collectDeclarations(program, options)
|
||||
val extras = List(
|
||||
if (options.flag(CompilationFlag.EmitIllegals)) UndocumentedOptimizations.All else Nil,
|
||||
if (options.flag(CompilationFlag.EmitCmosOpcodes)) CmosOptimizations.All else LaterOptimizations.Nmos,
|
||||
if (options.flag(CompilationFlag.DangerousOptimizations)) DangerousOptimizations.All else Nil,
|
||||
).flatten
|
||||
val goodCycle = List.fill(optLevel - 1)(OptimizationPresets.Good).flatten
|
||||
val assemblyOptimizations = if (optLevel <= 0) Nil else if (optLevel >= 9) List(SuperOptimizer) else {
|
||||
goodCycle ++ OptimizationPresets.AssOpt ++ extras ++ goodCycle
|
||||
|
||||
val assemblyOptimizations = optLevel match {
|
||||
case 0 => Nil
|
||||
case 1 => OptimizationPresets.QuickPreset
|
||||
case i if i >= 9 => List(SuperOptimizer)
|
||||
case _ =>
|
||||
val extras = List(
|
||||
if (options.flag(CompilationFlag.EmitIllegals)) UndocumentedOptimizations.All else Nil,
|
||||
if (options.flag(CompilationFlag.EmitCmosOpcodes)) CmosOptimizations.All else LaterOptimizations.Nmos,
|
||||
if (options.flag(CompilationFlag.DangerousOptimizations)) DangerousOptimizations.All else Nil,
|
||||
).flatten
|
||||
val goodCycle = List.fill(optLevel - 2)(OptimizationPresets.Good).flatten
|
||||
goodCycle ++ OptimizationPresets.AssOpt ++ extras ++ goodCycle
|
||||
}
|
||||
|
||||
// compile
|
||||
|
@ -188,7 +193,7 @@ object Main {
|
|||
}.description("Whether should emit CMOS opcodes.")
|
||||
boolean("-fillegals", "-fno-illegals").action { (c, v) =>
|
||||
c.changeFlag(CompilationFlag.EmitIllegals, v)
|
||||
}.description("Whether should emit illegal (undocumented) NMOS opcodes.")
|
||||
}.description("Whether should emit illegal (undocumented) NMOS opcodes. Required -O2 or higher to have an effect.")
|
||||
boolean("-fjmp-fix", "-fno-jmp-fix").action { (c, v) =>
|
||||
c.changeFlag(CompilationFlag.PreventJmpIndirectBug, v)
|
||||
}.description("Whether should prevent indirect JMP bug on page boundary.")
|
||||
|
@ -230,18 +235,18 @@ object Main {
|
|||
c.changeFlag(CompilationFlag.OptimizeForSize, true)
|
||||
c.changeFlag(CompilationFlag.OptimizeForSpeed, false)
|
||||
c.changeFlag(CompilationFlag.OptimizeForSonicSpeed, false)
|
||||
}.description("Optimize for size at cost of lower speed (experimental).")
|
||||
}.description("Prefer smaller code even if it is slightly slower (experimental).")
|
||||
flag("-Of", "--fast").action { c =>
|
||||
c.changeFlag(CompilationFlag.OptimizeForSize, false)
|
||||
c.changeFlag(CompilationFlag.OptimizeForSpeed, true)
|
||||
c.changeFlag(CompilationFlag.OptimizeForSonicSpeed, false)
|
||||
}.description("Optimize for speed at cost of bigger size (experimental).")
|
||||
}.description("Prefer faster code even if it is slightly bigger (experimental).")
|
||||
flag("-Ob", "--blast-processing").action { c =>
|
||||
c.changeFlag(CompilationFlag.OptimizeForSize, false)
|
||||
c.changeFlag(CompilationFlag.OptimizeForSpeed, true)
|
||||
c.changeFlag(CompilationFlag.OptimizeForSonicSpeed, true)
|
||||
c.changeFlag(CompilationFlag.InlineFunctions, true)
|
||||
}.description("Optimize for speed at cost of much bigger size (experimental). Implies --inline.")
|
||||
}.description("Prefer faster code even if it is much bigger (experimental). Implies --inline.")
|
||||
flag("--detailed-flow").action { c =>
|
||||
c.changeFlag(CompilationFlag.DetailedFlowAnalysis, true)
|
||||
}.description("Use detailed flow analysis (experimental).")
|
||||
|
|
|
@ -179,4 +179,21 @@ object OptimizationPresets {
|
|||
AlwaysGoodOptimizations.UnusedLabelRemoval,
|
||||
VariableToRegisterOptimization,
|
||||
)
|
||||
|
||||
val QuickPreset: List[AssemblyOptimization] = List[AssemblyOptimization](
|
||||
AlwaysGoodOptimizations.Adc0Optimization,
|
||||
AlwaysGoodOptimizations.BranchInPlaceRemoval,
|
||||
AlwaysGoodOptimizations.CommonBranchBodyOptimization,
|
||||
AlwaysGoodOptimizations.CommonExpressionInConditional,
|
||||
AlwaysGoodOptimizations.CommonIndexSubexpressionElimination,
|
||||
AlwaysGoodOptimizations.IndexSequenceOptimization,
|
||||
AlwaysGoodOptimizations.PoinlessStoreBeforeStore,
|
||||
AlwaysGoodOptimizations.PointlessLoadAfterLoadOrStore,
|
||||
AlwaysGoodOptimizations.PointlessLoadBeforeTransfer,
|
||||
AlwaysGoodOptimizations.PointlessOperationFromFlow,
|
||||
AlwaysGoodOptimizations.ReverseFlowAnalysis,
|
||||
AlwaysGoodOptimizations.SimplifiableCondition,
|
||||
VariableToRegisterOptimization,
|
||||
LaterOptimizations.DoubleLoadToTheSameRegister
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user