mirror of
https://github.com/irmen/prog8.git
synced 2024-12-23 09:32:43 +00:00
IR: fix chunk reachability: via unchopped chunk label directly so that they don't get removed
This commit is contained in:
parent
325f55f22d
commit
b5e691f367
9
.idea/inspectionProfiles/Project_Default.xml
generated
9
.idea/inspectionProfiles/Project_Default.xml
generated
@ -9,6 +9,15 @@
|
|||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
<inspection_tool class="IncompleteDestructuring" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="IncompleteDestructuring" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="PyInterpreterInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
<inspection_tool class="PyInterpreterInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredPackages">
|
||||||
|
<value>
|
||||||
|
<list size="1">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="sphinx_rtd_theme" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
<inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
|
<inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
|
||||||
<option name="processCode" value="false" />
|
<option name="processCode" value="false" />
|
||||||
<option name="processLiterals" value="true" />
|
<option name="processLiterals" value="true" />
|
||||||
|
@ -168,7 +168,7 @@ class IRUnusedCodeRemover(
|
|||||||
it.instructions.forEach { instr ->
|
it.instructions.forEach { instr ->
|
||||||
if (instr.branchTarget == null)
|
if (instr.branchTarget == null)
|
||||||
instr.labelSymbol?.let { label ->
|
instr.labelSymbol?.let { label ->
|
||||||
val chunk = allLabeledChunks[label.substringBeforeLast('.')]
|
val chunk = allLabeledChunks[label] ?: allLabeledChunks[label.substringBeforeLast('.')]
|
||||||
if(chunk!=null)
|
if(chunk!=null)
|
||||||
new+=chunk
|
new+=chunk
|
||||||
else
|
else
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
|
make it possible to do indirect jumps in VM? (associate values with labels and if it jumps to a "address value" it looks up the label with that value again?)
|
||||||
|
|
||||||
replace Takes by Http4k in httpCompilerService project. https://github.com/http4k/examples/blob/master/hello-world/README.md
|
replace Takes by Http4k in httpCompilerService project. https://github.com/http4k/examples/blob/master/hello-world/README.md
|
||||||
|
|
||||||
...
|
...
|
||||||
@ -28,6 +30,7 @@ Compiler:
|
|||||||
- (need separate step in codegen and IR to write the "golden" variables)
|
- (need separate step in codegen and IR to write the "golden" variables)
|
||||||
|
|
||||||
- do we need (array)variable alignment tag instead of block alignment tag? You want to align the data, not the code in the block?
|
- do we need (array)variable alignment tag instead of block alignment tag? You want to align the data, not the code in the block?
|
||||||
|
- VM: implement diskio support (let's start with the basics load, save, delete, rename, status?. no streaming, no directory listing)
|
||||||
- ir: related to the one above: block alignment doesn't translate well to variables in the block (the actual stuff that needs to be aligned in memory) but: need variable alignment tag instead of block alignment tag, really
|
- ir: related to the one above: block alignment doesn't translate well to variables in the block (the actual stuff that needs to be aligned in memory) but: need variable alignment tag instead of block alignment tag, really
|
||||||
- ir: proper code gen for the CALLI instruction and that it (optionally) returns a word value that needs to be assigned to a reg
|
- ir: proper code gen for the CALLI instruction and that it (optionally) returns a word value that needs to be assigned to a reg
|
||||||
- ir: idea: (but LLVM IR simply keeps the variables, so not a good idea then?...): replace all scalar variables by an allocated register. Keep a table of the variable to register mapping (including the datatype)
|
- ir: idea: (but LLVM IR simply keeps the variables, so not a good idea then?...): replace all scalar variables by an allocated register. Keep a table of the variable to register mapping (including the datatype)
|
||||||
|
175
examples/test.p8
175
examples/test.p8
@ -1,54 +1,137 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import math
|
%zeropage dontuse
|
||||||
%zeropage basicsafe
|
|
||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
ubyte @shared pointer
|
uword @shared pointer
|
||||||
const uword value = 255
|
|
||||||
|
; if cx16.r0L>10
|
||||||
|
; goto label1
|
||||||
|
; if cx16.r0L>11
|
||||||
|
; goto label2
|
||||||
|
|
||||||
|
pointer = &label2
|
||||||
|
goto pointer
|
||||||
|
|
||||||
|
label1:
|
||||||
|
txt.print("fail\n")
|
||||||
|
return
|
||||||
|
|
||||||
|
label2:
|
||||||
|
txt.print("indirect jump ok\n")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
if pointer>value {
|
|
||||||
cx16.r0L++
|
|
||||||
}
|
}
|
||||||
; if pointer>50000 {
|
}
|
||||||
; cx16.r0L++
|
|
||||||
|
|
||||||
|
|
||||||
|
;%import textio
|
||||||
|
;%import floats
|
||||||
|
;%zeropage dontuse
|
||||||
|
;%option no_sysinit
|
||||||
|
;
|
||||||
|
;main {
|
||||||
|
; sub start() {
|
||||||
|
; test_bool()
|
||||||
|
;; test_byte()
|
||||||
|
;; test_ubyte()
|
||||||
|
;; test_word()
|
||||||
|
;; test_uword()
|
||||||
|
;; test_float()
|
||||||
|
; }
|
||||||
|
;
|
||||||
|
; /*
|
||||||
|
; tests:
|
||||||
|
; - if with only a single goto, direct
|
||||||
|
; - if with only a single indirect goto
|
||||||
|
; - if without an else block
|
||||||
|
; - if with both if and else blocks
|
||||||
|
; carthesian product with:
|
||||||
|
; - comparison with const zero
|
||||||
|
; - comparison with const values
|
||||||
|
; - comparison with variable
|
||||||
|
; - comparison with array
|
||||||
|
; - comparison with expression
|
||||||
|
; */
|
||||||
|
;
|
||||||
|
; sub fail(uword test) {
|
||||||
|
; txt.print("failed ")
|
||||||
|
; txt.print_uw(test)
|
||||||
|
; txt.nl()
|
||||||
|
; }
|
||||||
|
;
|
||||||
|
; sub test_bool() {
|
||||||
|
; bool @shared var1, var2
|
||||||
|
; uword success = 0
|
||||||
|
;
|
||||||
|
; single_goto()
|
||||||
|
; single_goto_indirect()
|
||||||
|
; no_else()
|
||||||
|
; ifelse()
|
||||||
|
;
|
||||||
|
; sub single_goto() {
|
||||||
|
; txt.print("bool single_goto\n")
|
||||||
|
;test1:
|
||||||
|
; var1 = false
|
||||||
|
; if var1
|
||||||
|
; goto lbl1
|
||||||
|
; success++
|
||||||
|
; goto test2
|
||||||
|
;lbl1:
|
||||||
|
; fail(1)
|
||||||
|
;
|
||||||
|
;test2:
|
||||||
|
; var1 = true
|
||||||
|
; if var1
|
||||||
|
; goto lbl2
|
||||||
|
; fail(1)
|
||||||
|
; goto test3
|
||||||
|
;lbl2: success++
|
||||||
|
;
|
||||||
|
;test3:
|
||||||
|
; if success==2
|
||||||
|
; txt.print(" ok\n")
|
||||||
|
; else
|
||||||
|
; txt.print(" failed\n")
|
||||||
|
; }
|
||||||
|
;
|
||||||
|
; sub single_goto_indirect() {
|
||||||
|
; uword pointer
|
||||||
|
; txt.print("bool single_goto_indirect\n")
|
||||||
|
;test1:
|
||||||
|
; var1 = false
|
||||||
|
; pointer = &lbl1
|
||||||
|
; if var1
|
||||||
|
; goto pointer
|
||||||
|
; success++
|
||||||
|
; goto test2
|
||||||
|
;lbl1:
|
||||||
|
; fail(1)
|
||||||
|
;
|
||||||
|
;test2:
|
||||||
|
; var1 = true
|
||||||
|
; pointer = &lbl2
|
||||||
|
; if var1
|
||||||
|
; goto pointer
|
||||||
|
; fail(1)
|
||||||
|
; goto test3
|
||||||
|
;lbl2: success++
|
||||||
|
;
|
||||||
|
;test3:
|
||||||
|
; if success==2
|
||||||
|
; txt.print(" ok\n")
|
||||||
|
; else
|
||||||
|
; txt.print(" failed\n")
|
||||||
|
; }
|
||||||
|
;
|
||||||
|
; sub no_else() {
|
||||||
|
; }
|
||||||
|
;
|
||||||
|
; sub ifelse() {
|
||||||
|
; }
|
||||||
|
; }
|
||||||
|
;
|
||||||
;}
|
;}
|
||||||
|
|
||||||
txt.bell()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*main222 {
|
|
||||||
sub start() {
|
|
||||||
|
|
||||||
str name1 = "name1"
|
|
||||||
str name2 = "name2"
|
|
||||||
uword[] @split names = [name1, name2, "name3"]
|
|
||||||
uword[] addresses = [0,1,2]
|
|
||||||
names = [1111,2222,3333]
|
|
||||||
|
|
||||||
for cx16.r0 in names {
|
|
||||||
txt.print_uw(cx16.r0)
|
|
||||||
txt.spc()
|
|
||||||
}
|
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
addresses = names
|
|
||||||
|
|
||||||
for cx16.r0 in addresses {
|
|
||||||
txt.print_uw(cx16.r0)
|
|
||||||
txt.spc()
|
|
||||||
}
|
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
names = [9999,8888,7777]
|
|
||||||
names = addresses
|
|
||||||
for cx16.r0 in names {
|
|
||||||
txt.print_uw(cx16.r0)
|
|
||||||
txt.spc()
|
|
||||||
}
|
|
||||||
txt.nl()
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
Loading…
Reference in New Issue
Block a user