mirror of
https://github.com/KarolS/millfork.git
synced 2024-05-31 18:41:30 +00:00
32 lines
987 B
Scala
32 lines
987 B
Scala
package millfork.assembly
|
|
|
|
import millfork.{CompilationFlag, CompilationOptions}
|
|
import millfork.compiler.LabelGenerator
|
|
import millfork.env.{Constant, NormalFunction, ThingInMemory}
|
|
import millfork.error.Logger
|
|
import millfork.node.NiceFunctionProperty
|
|
|
|
/**
|
|
* @author Karol Stasiak
|
|
*/
|
|
case class OptimizationContext(options: CompilationOptions,
|
|
labelMap: Map[String, (String, Int)],
|
|
zreg: Option[ThingInMemory],
|
|
identityPage: Constant,
|
|
niceFunctionProperties: Set[(NiceFunctionProperty, String)]) {
|
|
@inline
|
|
def log: Logger = options.log
|
|
@inline
|
|
def nextLabel: LabelGenerator = options.nextLabel
|
|
}
|
|
|
|
trait AssemblyOptimization[T <: AbstractCode] {
|
|
def name: String
|
|
|
|
def optimize(f: NormalFunction, code: List[T], context: OptimizationContext): List[T]
|
|
|
|
def requiredFlags: Set[CompilationFlag.Value] = Set.empty
|
|
|
|
def minimumRequiredLines: Int
|
|
}
|