1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-24 20:32:39 +00:00

Introduces void-pointer synthesis. This enables removal of a lot of pointer fragments. #449

This commit is contained in:
jespergravgaard 2020-05-30 23:12:44 +02:00
parent 74d83caaf9
commit 08d90f90d9
97 changed files with 19 additions and 233 deletions

View File

@ -3,4 +3,4 @@ lda {m2}
sta ({z1}),y
iny
lda {m2}+1
sta ({z1}),y
sta ({z1}),y

View File

@ -1,6 +0,0 @@
ldy #0
lda {m2}
sta ({z1}),y
iny
lda {m2}+1
sta ({z1}),y

View File

@ -1 +0,0 @@
// No operation needed

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -1,5 +0,0 @@
tsx
lda STACK_BASE+{c1},x
sta {m1}
lda STACK_BASE+{c1}+1,x
sta {m1}+1

View File

@ -1,4 +0,0 @@
pla
sta {m1}
pla
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1

View File

@ -1,8 +0,0 @@
ldy #0
lda ({z1}),y
pha
iny
lda ({z1}),y
sta {z1}+1
pla
sta {z1}

View File

@ -1,7 +0,0 @@
lda ({z1}),y
pha
iny
lda ({z1}),y
sta {z1}+1
pla
sta {z1}

View File

@ -1,4 +0,0 @@
lda {c1}
sta {m1}
lda {c1}+1
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {c1}
sta {m1}
lda {c1}+1
sta {m1}+1

View File

@ -1,5 +0,0 @@
tsx
lda STACK_BASE+{c1},x
sta {m1}
lda STACK_BASE+{c1}+1,x
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {c1},x
sta {m1}
lda {c1}+1,x
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {c1},y
sta {m1}
lda {c1}+1,y
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {m1}
sta {c1},y
lda {m1}+1
sta {c1}+1,y

View File

@ -1 +0,0 @@
// No operation needed

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -1,5 +0,0 @@
tsx
lda STACK_BASE+{c1},x
sta {m1}
lda STACK_BASE+{c1}+1,x
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -1,6 +0,0 @@
ldy #{c1}
lda {m2}
sta ({z1}),y
iny
lda {m2}+1
sta ({z1}),y

View File

@ -1,6 +0,0 @@
ldy #{c1}
lda {m2}
sta ({z1}),y
iny
lda {m2}+1
sta ({z1}),y

View File

@ -1,6 +0,0 @@
ldy #{c1}
lda {m2}
sta ({z1}),y
iny
lda {m2}+1
sta ({z1}),y

View File

@ -1,5 +1,5 @@
lda ({z2}),y
sta {m1}
sta ({z1}),y
iny
lda ({z2}),y
sta {m1}+1
sta ({z1}),y

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1

View File

@ -1,6 +0,0 @@
ldy #0
lda ({z2}),y
sta {m1}
iny
lda ({z2}),y
sta {m1}+1

View File

@ -1,5 +0,0 @@
tsx
lda STACK_BASE+{c1},x
sta {m1}
lda STACK_BASE+{c1}+1,x
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1

View File

@ -1,5 +0,0 @@
tsx
lda STACK_BASE+{c1},x
sta {m1}
lda STACK_BASE+{c1}+1,x
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {c1}
sta {m1}
lda {c1}+1
sta {m1}+1

View File

@ -1,6 +0,0 @@
ldy #0
lda ({z2}),y
sta {m1}
iny
lda ({z2}),y
sta {m1}+1

View File

@ -1 +0,0 @@
// No operation needed

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -1,5 +0,0 @@
tsx
lda STACK_BASE+{c1},x
sta {m1}
lda STACK_BASE+{c1}+1,x
sta {m1}+1

View File

@ -1,4 +0,0 @@
pla
sta {m1}
pla
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {c1},x
sta {m1}
lda {c1}+1,x
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {c1},y
sta {m1}
lda {c1}+1,y
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -1,8 +0,0 @@
ldy #0
lda ({z1}),y
pha
iny
lda ({z1}),y
sta {z1}+1
pla
sta {z1}

View File

@ -1,7 +0,0 @@
lda ({z1}),y
pha
iny
lda ({z1}),y
sta {z1}+1
pla
sta {z1}

View File

@ -1,4 +0,0 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -710,6 +710,10 @@ class AsmFragmentTemplateSynthesisRule {
// Rewrite (Z1),a to save A to $FF and reload it into YY
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)z1_derefidx_vbuaa=(.*)", twoZM1, "sta $ff" , "vb$1aa=$2", "ldy $ff\nsta ({z1}),y", mapZM1));
// Synthesize typed pointer math using void pointers
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)p..([czm][1-9])(.*)", null, null, "$1pvo$2$3", null, null));
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)p..([czm][1-9])(.*p.*)", null, null, "$1pvo$2$3", null, null));
// Synthesize some constant pointers as constant words (remove when the above section can be included)
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)_(lt|gt|le|ge|eq|neq)_p..([czm].)_then_(.*)", null, null, "$1_$2_vwu$3_then_$4", null, null));
synths.add(new AsmFragmentTemplateSynthesisRule("p..([czm].)_(lt|gt|le|ge|eq|neq)_(.*)", null, null, "vwu$1_$2_$3", null, null));

View File

@ -518,7 +518,6 @@ public class TestPrograms {
compileAndCompare("millfork-benchmarks/linkedlist-kc.c");
}
@Test
public void testSqrDelta() throws IOException, URISyntaxException {
compileAndCompare("sqr-delta.c");

View File

@ -3147,12 +3147,12 @@ main: {
rol
sta.z __12+1
// [8] (signed word*~) main::$16 ← (const signed word*) primenum + (signed word~) main::$12 -- pwsz1=pwsc1_plus_vwsz2
lda.z __12
lda #<primenum
clc
adc #<primenum
adc.z __12
sta.z __16
lda.z __12+1
adc #>primenum
lda #>primenum
adc.z __12+1
sta.z __16+1
// [9] (signed word) main::p#0 ← *((signed word*~) main::$16) -- vwsz1=_deref_pwsz2
ldy #0
@ -3260,12 +3260,12 @@ main: {
lda.z testnum+1
sta.z div16s.dividend+1
// [23] (signed word*~) main::$17 ← (const signed word*) primenum + (signed word~) main::$13 -- pwsz1=pwsc1_plus_vwsz2
lda.z __13
lda #<primenum
clc
adc #<primenum
adc.z __13
sta.z __17
lda.z __13+1
adc #>primenum
lda #>primenum
adc.z __13+1
sta.z __17+1
// [24] (signed word) div16s::divisor#0 ← *((signed word*~) main::$17) -- vwsz1=_deref_pwsz2
ldy #0
@ -3341,12 +3341,12 @@ main: {
rol
sta.z __14+1
// [33] (signed word*~) main::$18 ← (const signed word*) primenum + (signed word~) main::$14 -- pwsz1=pwsc1_plus_vwsz2
lda.z __14
lda #<primenum
clc
adc #<primenum
adc.z __14
sta.z __18
lda.z __14+1
adc #>primenum
lda #>primenum
adc.z __14+1
sta.z __18+1
// [34] *((signed word*~) main::$18) ← (signed word) testnum#10 -- _deref_pwsz1=vwsz2
ldy #0