IR support for instructions operating on cpu regs

This commit is contained in:
Irmen de Jong
2022-09-17 18:56:55 +02:00
parent 2f3e7d1c27
commit 3091e3a1c8
10 changed files with 93 additions and 32 deletions
@@ -24,8 +24,7 @@ class AssemblyProgram(override val name: String, private val allocations: Variab
println("write code to $outfile")
outfile.bufferedWriter().use { out ->
allocations.asVmMemory().forEach { (name, alloc) ->
out.write("; ${name.joinToString(".")}\n")
out.write(alloc + "\n")
out.write("var ${name.joinToString(".")} $alloc\n")
}
out.write("------PROGRAM------\n")
@@ -81,7 +81,7 @@ class VariableAllocator(private val st: SymbolTable, private val program: PtProg
}
else -> throw InternalCompilerException("weird dt")
}
mm.add(Pair(variable.scopedName, "$location $typeStr $value"))
mm.add(Pair(variable.scopedName, "@$location $typeStr $value"))
}
for (variable in st.allMemMappedVariables) {
val location = allocations.getValue(variable.scopedName)
@@ -100,7 +100,7 @@ class VariableAllocator(private val st: SymbolTable, private val program: PtProg
in ArrayDatatypes -> (1..variable.length!!).joinToString(",") { "0" }
else -> throw InternalCompilerException("weird dt for mem mapped var")
}
mm.add(Pair(variable.scopedName, "$location $typeStr $value"))
mm.add(Pair(variable.scopedName, "@$location $typeStr $value"))
}
return mm
}