ir tag change INLINEASM->ASM

This commit is contained in:
Irmen de Jong 2023-12-26 16:15:19 +01:00
parent 73864c8101
commit 7530f4407b
6 changed files with 15 additions and 13 deletions

View File

@ -258,7 +258,7 @@ main {
val virtfile = result.compilationOptions.outputDir.resolve(result.compilerAst.name + ".p8ir") val virtfile = result.compilationOptions.outputDir.resolve(result.compilerAst.name + ".p8ir")
val irSrc = virtfile.readText() val irSrc = virtfile.readText()
irSrc.shouldContain("incm.b $2000") irSrc.shouldContain("incm.b $2000")
irSrc.shouldNotContain("INLINEASM") irSrc.shouldNotContain("</ASM>")
VmRunner().runProgram(irSrc) VmRunner().runProgram(irSrc)
} }

View File

@ -2,6 +2,8 @@
TODO TODO
==== ====
- get rid of memory mapped variables: treat them as syntactic sugar for a poke/peek to the symbol.
- add -nowarnunused, or %option ignore_unused (module and block scope), to suppress all warnings about unused symbols. Useful in libraries. - add -nowarnunused, or %option ignore_unused (module and block scope), to suppress all warnings about unused symbols. Useful in libraries.
put this in all library code, like %option no_symbol_prefixing, and get rid of the "trick" it uses currently to suppress unused symbol warnings for library modules. put this in all library code, like %option no_symbol_prefixing, and get rid of the "trick" it uses currently to suppress unused symbol warnings for library modules.

View File

@ -354,7 +354,7 @@ class IRFileReader {
when(reader.peek().asStartElement().name.localPart) { when(reader.peek().asStartElement().name.localPart) {
"SUB" -> block += parseSubroutine(reader) "SUB" -> block += parseSubroutine(reader)
"ASMSUB" -> block += parseAsmSubroutine(reader) "ASMSUB" -> block += parseAsmSubroutine(reader)
"INLINEASM" -> block += parseInlineAssembly(reader) "ASM" -> block += parseInlineAssembly(reader)
"BYTES" -> block += parseBinaryBytes(reader) "BYTES" -> block += parseBinaryBytes(reader)
"CODE" -> { "CODE" -> {
val chunk = parseCodeChunk(reader) val chunk = parseCodeChunk(reader)
@ -387,7 +387,7 @@ class IRFileReader {
when(reader.peek().asStartElement().name.localPart) { when(reader.peek().asStartElement().name.localPart) {
"CODE" -> sub += parseCodeChunk(reader) "CODE" -> sub += parseCodeChunk(reader)
"BYTES" -> sub += parseBinaryBytes(reader) "BYTES" -> sub += parseBinaryBytes(reader)
"INLINEASM" -> sub += parseInlineAssembly(reader) "ASM" -> sub += parseInlineAssembly(reader)
else -> throw IRParseException("invalid line in SUB: ${reader.peek()}") else -> throw IRParseException("invalid line in SUB: ${reader.peek()}")
} }
skipText(reader) skipText(reader)
@ -479,7 +479,7 @@ class IRFileReader {
private fun parseInlineAssembly(reader: XMLEventReader): IRInlineAsmChunk { private fun parseInlineAssembly(reader: XMLEventReader): IRInlineAsmChunk {
skipText(reader) skipText(reader)
val start = reader.nextEvent().asStartElement() val start = reader.nextEvent().asStartElement()
require(start.name.localPart=="INLINEASM") { "missing INLINEASM" } require(start.name.localPart=="ASM") { "missing ASM" }
val label = start.attributes.asSequence().single { it.name.localPart == "LABEL" }.value.ifBlank { null } val label = start.attributes.asSequence().single { it.name.localPart == "LABEL" }.value.ifBlank { null }
val isIr = start.attributes.asSequence().single { it.name.localPart == "IR" }.value.toBoolean() val isIr = start.attributes.asSequence().single { it.name.localPart == "IR" }.value.toBoolean()
val text = readText(reader).trim() val text = readText(reader).trim()

View File

@ -168,7 +168,7 @@ class IRFileWriter(private val irProgram: IRProgram, outfileOverride: Path?) {
} }
private fun writeInlineAsm(chunk: IRInlineAsmChunk) { private fun writeInlineAsm(chunk: IRInlineAsmChunk) {
xml.writeStartElement("INLINEASM") xml.writeStartElement("ASM")
xml.writeAttribute("LABEL", chunk.label ?: "") xml.writeAttribute("LABEL", chunk.label ?: "")
xml.writeAttribute("IR", chunk.isIR.toString()) xml.writeAttribute("IR", chunk.isIR.toString())
xml.writeCharacters("\n") xml.writeCharacters("\n")

View File

@ -18,12 +18,12 @@ PROGRAM:
CODE-LINE (assignment to initialize a variable) CODE-LINE (assignment to initialize a variable)
... ...
BLOCK BLOCK
INLINEASM ASM
INLINEASM ASM
SUB SUB
PARAMS PARAMS
INLINEASM ASM
INLINEASM ASM
C (CODE) C (CODE)
CODE-LINE (label, instruction, comment, inlinebinary) CODE-LINE (label, instruction, comment, inlinebinary)
CODE-LINE CODE-LINE
@ -36,10 +36,10 @@ PROGRAM:
SUB SUB
ASMSUB ASMSUB
PARAMS PARAMS
INLINEASM ASM
ASMSUB ASMSUB
PARAMS PARAMS
INLINEASM ASM
... ...
BLOCK BLOCK
BLOCK BLOCK

View File

@ -86,9 +86,9 @@ return
<PARAMS> <PARAMS>
uword sys.wait.jiffies uword sys.wait.jiffies
</PARAMS> </PARAMS>
<INLINEASM LABEL="sys.wait" IR="true" POS="[library:/prog8lib/virtual/syslib.p8: line 17 col 10-13]"> <ASM LABEL="sys.wait" IR="true" POS="[library:/prog8lib/virtual/syslib.p8: line 17 col 10-13]">
loadm.w r0,sys.wait.jiffies loadm.w r0,sys.wait.jiffies
</INLINEASM> </ASM>
<CODE> <CODE>
return return
</CODE> </CODE>