mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 23:29:55 +00:00
fix name check in inline asm
this no longer removes a subroutine that is otherwise only called from inlined asm.
This commit is contained in:
parent
af5ca2d0b8
commit
62d3f01948
@ -776,4 +776,20 @@ main {
|
||||
"""
|
||||
compileText(VMTarget(), true, text, writeAssembly = false) shouldNotBe null
|
||||
}
|
||||
|
||||
test("sub only called by asm should not be optimized away") {
|
||||
val src="""
|
||||
main {
|
||||
sub start() {
|
||||
%asm{{
|
||||
jsr p8_test
|
||||
}}
|
||||
}
|
||||
|
||||
sub test() {
|
||||
cx16.r0++
|
||||
}
|
||||
}"""
|
||||
compileText(Cx16Target(), true, src, writeAssembly = true) shouldNotBe null
|
||||
}
|
||||
})
|
||||
|
@ -163,7 +163,7 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
return allIdentifiersAndTargets.filter { decl===it.value }.map{ it.key }
|
||||
}
|
||||
|
||||
private fun nameInAssemblyCode(name: String) = allAssemblyNodes.any { name in it.names }
|
||||
private fun nameInAssemblyCode(name: String) = allAssemblyNodes.any { "p8_$name" in it.names || name in it.names }
|
||||
|
||||
inline fun unused(label: Label) = false // just always output labels
|
||||
|
||||
|
@ -4,8 +4,6 @@ TODO
|
||||
|
||||
- IRQ callback should return boolean to tell Prog8 to call the kernal ISR or not.
|
||||
|
||||
- Is there a way to tell prog8 not to optimize out a function that is only called from within %asm{{}}? like a @shared but for subs?
|
||||
|
||||
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
||||
|
||||
...
|
||||
|
@ -1,14 +1,14 @@
|
||||
%import textio
|
||||
%import floats
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
float fl1 = 999.8877
|
||||
float fl2 = sqrt(fl1) * fl1 + fl1*33.44
|
||||
floats.print_f(fl2)
|
||||
txt.nl()
|
||||
fl1=0
|
||||
floats.print_f(fl1)
|
||||
%asm{{
|
||||
jsr p8_test
|
||||
}}
|
||||
}
|
||||
|
||||
sub test() {
|
||||
cx16.r0++
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user