mirror of
https://github.com/irmen/prog8.git
synced 2024-10-21 04:24:05 +00:00
never add rts to inline asmsubs and always inline them regardless of optimization setting
otherwise they can't specify a sequence of assembly instructions that should be inserted in-place, such as those that manipulate the cpu stack. for instance cx16.irqsafe_set_irqd() / cx16.irqsafe_clear_irqd()
This commit is contained in:
parent
b89ad4b328
commit
0816a57032
@ -63,8 +63,8 @@ internal class FunctionCallAsmGen(private val program: PtProgram, private val as
|
|||||||
|
|
||||||
if(sub is PtAsmSub) {
|
if(sub is PtAsmSub) {
|
||||||
argumentsViaRegisters(sub, call)
|
argumentsViaRegisters(sub, call)
|
||||||
if (sub.inline && asmgen.options.optimize) {
|
if (sub.inline) {
|
||||||
// inline the subroutine.
|
// inline the subroutine. (regardless of optimization settings!)
|
||||||
// we do this by copying the subroutine's statements at the call site.
|
// we do this by copying the subroutine's statements at the call site.
|
||||||
// NOTE: *if* there is a return statement, it will be the only one, and the very last statement of the subroutine
|
// NOTE: *if* there is a return statement, it will be the only one, and the very last statement of the subroutine
|
||||||
// (this condition has been enforced by an ast check earlier)
|
// (this condition has been enforced by an ast check earlier)
|
||||||
|
@ -271,9 +271,7 @@ internal class ProgramAndVarsGen(
|
|||||||
|
|
||||||
internal fun translateAsmSubroutine(sub: PtAsmSub) {
|
internal fun translateAsmSubroutine(sub: PtAsmSub) {
|
||||||
if(sub.inline) {
|
if(sub.inline) {
|
||||||
if(options.optimize) {
|
return // subroutine gets inlined at call site.
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asmgen.out("")
|
asmgen.out("")
|
||||||
|
@ -150,7 +150,7 @@ internal class BeforeAsmAstChanger(val program: Program,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!subroutine.inline || !options.optimize) {
|
if (!subroutine.inline) {
|
||||||
if (subroutine.isAsmSubroutine && subroutine.asmAddress==null && !subroutine.hasRtsInAsm()) {
|
if (subroutine.isAsmSubroutine && subroutine.asmAddress==null && !subroutine.hasRtsInAsm()) {
|
||||||
// make sure the NOT INLINED asm subroutine actually has a rts at the end
|
// make sure the NOT INLINED asm subroutine actually has a rts at the end
|
||||||
// (non-asm routines get a Return statement as needed, above)
|
// (non-asm routines get a Return statement as needed, above)
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
- compiling Rockrunner with -noopt crashes the program soon after startup
|
|
||||||
|
|
||||||
- IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction
|
- IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction
|
||||||
- IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified!
|
- IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified!
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user