mirror of
https://github.com/irmen/prog8.git
synced 2024-12-22 18:30:01 +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 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="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">
|
||||
<option name="processCode" value="false" />
|
||||
<option name="processLiterals" value="true" />
|
||||
|
@ -168,7 +168,7 @@ class IRUnusedCodeRemover(
|
||||
it.instructions.forEach { instr ->
|
||||
if (instr.branchTarget == null)
|
||||
instr.labelSymbol?.let { label ->
|
||||
val chunk = allLabeledChunks[label.substringBeforeLast('.')]
|
||||
val chunk = allLabeledChunks[label] ?: allLabeledChunks[label.substringBeforeLast('.')]
|
||||
if(chunk!=null)
|
||||
new+=chunk
|
||||
else
|
||||
|
@ -1,6 +1,8 @@
|
||||
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
|
||||
|
||||
...
|
||||
@ -28,6 +30,7 @@ Compiler:
|
||||
- (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?
|
||||
- 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: 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)
|
||||
|
167
examples/test.p8
167
examples/test.p8
@ -1,54 +1,137 @@
|
||||
%import textio
|
||||
%import math
|
||||
%zeropage basicsafe
|
||||
%zeropage dontuse
|
||||
%option no_sysinit
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
ubyte @shared pointer
|
||||
const uword value = 255
|
||||
uword @shared pointer
|
||||
|
||||
; 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++
|
||||
; }
|
||||
|
||||
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()
|
||||
}
|
||||
}*/
|
||||
;%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() {
|
||||
; }
|
||||
; }
|
||||
;
|
||||
;}
|
||||
|
Loading…
Reference in New Issue
Block a user