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 irSrc = virtfile.readText()
irSrc.shouldContain("incm.b $2000")
irSrc.shouldNotContain("INLINEASM")
irSrc.shouldNotContain("</ASM>")
VmRunner().runProgram(irSrc)
}

View File

@ -2,6 +2,8 @@
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.
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) {
"SUB" -> block += parseSubroutine(reader)
"ASMSUB" -> block += parseAsmSubroutine(reader)
"INLINEASM" -> block += parseInlineAssembly(reader)
"ASM" -> block += parseInlineAssembly(reader)
"BYTES" -> block += parseBinaryBytes(reader)
"CODE" -> {
val chunk = parseCodeChunk(reader)
@ -387,7 +387,7 @@ class IRFileReader {
when(reader.peek().asStartElement().name.localPart) {
"CODE" -> sub += parseCodeChunk(reader)
"BYTES" -> sub += parseBinaryBytes(reader)
"INLINEASM" -> sub += parseInlineAssembly(reader)
"ASM" -> sub += parseInlineAssembly(reader)
else -> throw IRParseException("invalid line in SUB: ${reader.peek()}")
}
skipText(reader)
@ -479,7 +479,7 @@ class IRFileReader {
private fun parseInlineAssembly(reader: XMLEventReader): IRInlineAsmChunk {
skipText(reader)
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 isIr = start.attributes.asSequence().single { it.name.localPart == "IR" }.value.toBoolean()
val text = readText(reader).trim()

View File

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

View File

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

View File

@ -86,9 +86,9 @@ return
<PARAMS>
uword sys.wait.jiffies
</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
</INLINEASM>
</ASM>
<CODE>
return
</CODE>