1
0
mirror of https://github.com/KarolS/millfork.git synced 2025-08-15 19:27:22 +00:00

6502: Fix zp allocation

This commit is contained in:
Karol Stasiak
2020-03-26 01:38:54 +01:00
parent 2a3c9f04be
commit 59882cf765

View File

@@ -152,7 +152,10 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
case VariableAllocationMethod.Register => 2 case VariableAllocationMethod.Register => 2
case _ => 3 case _ => 3
} else 3 } else 3
val toAdd = things.values.flatMap {
def prioritize[T](list: List[T])(hasPriority: T => Boolean): List[T] = list.filter(hasPriority) ++ list.filterNot(hasPriority)
val toAdd = prioritize(things.values.toList)(th => th.name =="__reg").flatMap {
case m: UninitializedMemory if passForAlloc(m.alloc) == pass && nf.isDefined == isLocalVariableName(m.name) && !m.name.endsWith(".addr") && maybeGet[Thing](m.name + ".array").isEmpty => case m: UninitializedMemory if passForAlloc(m.alloc) == pass && nf.isDefined == isLocalVariableName(m.name) && !m.name.endsWith(".addr") && maybeGet[Thing](m.name + ".array").isEmpty =>
if (log.traceEnabled) log.trace("Allocating " + m.name) if (log.traceEnabled) log.trace("Allocating " + m.name)
val vertex = if (options.flag(CompilationFlag.VariableOverlap)) { val vertex = if (options.flag(CompilationFlag.VariableOverlap)) {
@@ -1467,7 +1470,7 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
val p = get[Type]("pointer") val p = get[Type]("pointer")
stmt.assemblyParamPassingConvention match { stmt.assemblyParamPassingConvention match {
case ByVariable(name) => case ByVariable(name) =>
val zp = typ.isPointy || pointies(name) // TODO val zp = pointies(name) // TODO
val v = UninitializedMemoryVariable(prefix + name, typ, if (zp) VariableAllocationMethod.Zeropage else VariableAllocationMethod.Auto, None, defaultVariableAlignment(options, 2), isVolatile = false) val v = UninitializedMemoryVariable(prefix + name, typ, if (zp) VariableAllocationMethod.Zeropage else VariableAllocationMethod.Auto, None, defaultVariableAlignment(options, 2), isVolatile = false)
addThing(v, stmt.position) addThing(v, stmt.position)
registerAddressConstant(v, stmt.position, options, Some(typ)) registerAddressConstant(v, stmt.position, options, Some(typ))