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

simplified synthesis rules for pointer treated like unsigned int.

This commit is contained in:
jespergravgaard 2021-12-28 16:21:38 +01:00
parent 4964a44660
commit 657537eb0d
11 changed files with 6391 additions and 45 deletions

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE ee4196b87 ee4199084
//KICKC FRAGMENT CACHE 10f5477f59 10f547a456
//FRAGMENT vbuzz=vbuc1
ldz #{c1}
//FRAGMENT vbuzz_lt_vbuc1_then_la1

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE ee4196b87 ee4199084
//KICKC FRAGMENT CACHE 10f5477f59 10f547a456
//FRAGMENT vbuz1=vbuc1
ldz #{c1}
stz {z1}

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE ee4196b87 ee4199084
//KICKC FRAGMENT CACHE 10f5477f59 10f547a456
//FRAGMENT vbuz1=vbuc1
lda #{c1}
sta {z1}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE ee4196b87 ee4199084
//KICKC FRAGMENT CACHE 10f5477f59 10f547a456
//FRAGMENT _deref_pbuc1=_inc__deref_pbuc1
inc {c1}
//FRAGMENT isr_hardware_all_entry

File diff suppressed because it is too large Load Diff

View File

@ -24,11 +24,12 @@ public interface AsmFragmentTemplateSynthesisRule {
String getSubSignature(String signature);
/**
* Synthesize a template from a sub template.
* Synthesize a fragment template from a sub fragment template.
*
* @param signature The signature to synthesize
* @param subTemplate A sub-template that matches the sub-signature
* @return The synthesized ASM fragment template
* @return The synthesized ASM fragment template.
* Null if the fragment cannot be synthesized (for instance due to clobber constraints).
*/
AsmFragmentTemplate synthesize(String signature, AsmFragmentTemplate subTemplate);

View File

@ -718,15 +718,10 @@ public class AsmFragmentTemplateSynthesisRuleRegexManager {
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)q[^v][^o]([czm][1-9])(.*)", null, null, "$1qvo$2$3", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)q[^v][^o]([czm][1-9])(.*[pq].*)", null, null, "$1qvo$2$3", null, null));
// Synthesize some constant pointers as constant words (remove when the above section can be included)
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)_(lt|gt|le|ge|eq|neq)_p..([czm][0-9])_then_(.*)", null, null, "$1_$2_vwu$3_then_$4", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("p..([czm][0-9])_(lt|gt|le|ge|eq|neq)_(.*)", null, null, "vwu$1_$2_$3", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)=p..([czm][0-9])", null, null, "$1=vwu$2", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)=(.*)_(plus|minus|bor|bxor)_p..([czm][0-9])", null, null, "$1=$2_$3_vwu$4", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)=p..([czm][0-9])_(plus|minus|bor|bxor)_(.*)", null, null, "$1=vwu$2_$3_$4", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("p..([czm][0-9])=(.*)_(sethi|setlo|plus|minus)_(.*)", null, null, "vwu$1=$2_$3_$4", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)=p..([czm][0-9])_(sethi|setlo|plus|minus)_(.*)", null, null, "$1=vwu$2_$3_$4", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("p..([czm][0-9])=_(inc|dec)_p..([czm][0-9])", null, null, "vwu$1=_$2_vwu$3", null, null));
// Synthesize pointers as words
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)p..([czm][0-9])(.*)", null, null, "$1vwu$2$3", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)p..([czm][0-9])(.*p..[czm][0-9].*)", null, null, "$1vwu$2$3", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)p..([czm][0-9])(.*p..[czm][0-9].*p..[czm][0-9].*)", null, null, "$1vwu$2$3", null, null));
// Synthesize constants using AA/XX/YY
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)vb(.)c1(.*)", rvalAa+"|"+ derefC1, "lda #{c1}", "$1vb$2aa$3", null, null));
@ -735,7 +730,6 @@ public class AsmFragmentTemplateSynthesisRuleRegexManager {
if(targetCpu.getCpu65xx().hasRegisterZ())
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)vb(.)c1(.*)", rvalZz+"|"+ derefC1, "ldz #{c1}", "$1vb$2zz$3", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)vb(.)c2(.*)", rvalAa+"|"+ derefC2, "lda #{c2}", "$1vb$2aa$3", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)vb(.)c2(.*)", rvalYy+"|"+ derefC2, "ldy #{c2}", "$1vb$2yy$3", null, null));
synths.add(new AsmFragmentTemplateSynthesisRuleRegex("(.*)vb(.)c2(.*)", rvalXx+"|"+ derefC2, "ldx #{c2}", "$1vb$2xx$3", null, null));

View File

@ -34,11 +34,10 @@ public class TestFragments {
AsmFragmentTemplateUsages.logUsages(asmFragmentTemplateSynthesizer, log, false, false, false, false, false, false);
}
// @Test
// public void testSynthesis() throws IOException {
// List<String> signatures = Arrays.asList("_deref_pwsc1_ge_vwsm1_then_la1");
// testFragments("fragment-synthesis", signatures);
// }
@Test
public void testSynthesis() throws IOException {
testFragmentExists("pbuz1=pbuz2_plus_pwuc1_derefidx_vbuxx");
}
@Test
public void testAssignmentsBu() throws IOException {

View File

@ -846,11 +846,10 @@ Removing always clobbered register reg byte a as potential for zp[1]:26 [ init_p
Statement [26] plot_bit[init_plot_tables::x#2] = init_plot_tables::bits#3 [ init_plot_tables::x#2 init_plot_tables::bits#3 ] ( init_plot_tables:6 [ init_plot_tables::x#2 init_plot_tables::bits#3 ] { } ) always clobbers reg byte a
Statement [41] init_plot_tables::yoffs#1 = init_plot_tables::yoffs#2 + (unsigned int)$28*8 [ init_plot_tables::y#2 init_plot_tables::yoffs#1 ] ( init_plot_tables:6 [ init_plot_tables::y#2 init_plot_tables::yoffs#1 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:28 [ init_plot_tables::y#2 init_plot_tables::y#1 ]
Statement [55] plot::plotter_x#1 = (char *) 0 byte1= plot::$6 [ plot::x#0 plot::y#0 plot::plotter_x#1 ] ( plots:9::plot:52 [ plots::i#2 plot::x#0 plot::y#0 plot::plotter_x#1 ] { } ) always clobbers reg byte a
Statement [57] plot::plotter_x#2 = plot::plotter_x#1 byte0= plot::$7 [ plot::x#0 plot::y#0 plot::plotter_x#2 ] ( plots:9::plot:52 [ plots::i#2 plot::x#0 plot::y#0 plot::plotter_x#2 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:17 [ plots::i#2 plots::i#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:19 [ plot::x#0 ]
Removing always clobbered register reg byte a as potential for zp[1]:18 [ plot::y#0 ]
Statement [57] plot::plotter_x#2 = plot::plotter_x#1 byte0= plot::$7 [ plot::x#0 plot::y#0 plot::plotter_x#2 ] ( plots:9::plot:52 [ plots::i#2 plot::x#0 plot::y#0 plot::plotter_x#2 ] { } ) always clobbers reg byte a
Statement [61] plot::plotter_y#2 = plot::plotter_y#1 byte0= plot::$9 [ plot::x#0 plot::plotter_x#2 plot::plotter_y#2 ] ( plots:9::plot:52 [ plots::i#2 plot::x#0 plot::plotter_x#2 plot::plotter_y#2 ] { } ) always clobbers reg byte a
Statement [62] plot::plotter#0 = plot::plotter_x#2 + plot::plotter_y#2 [ plot::x#0 plot::plotter#0 ] ( plots:9::plot:52 [ plots::i#2 plot::x#0 plot::plotter#0 ] { } ) always clobbers reg byte a
Statement [63] plot::$5 = *plot::plotter#0 | plot_bit[plot::x#0] [ plot::plotter#0 plot::$5 ] ( plots:9::plot:52 [ plots::i#2 plot::plotter#0 plot::$5 ] { } ) always clobbers reg byte a reg byte y
@ -870,7 +869,6 @@ Statement [25] plot_xhi[init_plot_tables::x#2] = byte1 BITMAP [ init_plot_tables
Statement [26] plot_bit[init_plot_tables::x#2] = init_plot_tables::bits#3 [ init_plot_tables::x#2 init_plot_tables::bits#3 ] ( init_plot_tables:6 [ init_plot_tables::x#2 init_plot_tables::bits#3 ] { } ) always clobbers reg byte a
Statement [34] init_plot_tables::$9 = init_plot_tables::y#2 & 7 [ init_plot_tables::y#2 init_plot_tables::yoffs#2 init_plot_tables::$9 ] ( init_plot_tables:6 [ init_plot_tables::y#2 init_plot_tables::yoffs#2 init_plot_tables::$9 ] { } ) always clobbers reg byte a
Statement [41] init_plot_tables::yoffs#1 = init_plot_tables::yoffs#2 + (unsigned int)$28*8 [ init_plot_tables::y#2 init_plot_tables::yoffs#1 ] ( init_plot_tables:6 [ init_plot_tables::y#2 init_plot_tables::yoffs#1 ] { } ) always clobbers reg byte a
Statement [55] plot::plotter_x#1 = (char *) 0 byte1= plot::$6 [ plot::x#0 plot::y#0 plot::plotter_x#1 ] ( plots:9::plot:52 [ plots::i#2 plot::x#0 plot::y#0 plot::plotter_x#1 ] { } ) always clobbers reg byte a
Statement [57] plot::plotter_x#2 = plot::plotter_x#1 byte0= plot::$7 [ plot::x#0 plot::y#0 plot::plotter_x#2 ] ( plots:9::plot:52 [ plots::i#2 plot::x#0 plot::y#0 plot::plotter_x#2 ] { } ) always clobbers reg byte a
Statement [61] plot::plotter_y#2 = plot::plotter_y#1 byte0= plot::$9 [ plot::x#0 plot::plotter_x#2 plot::plotter_y#2 ] ( plots:9::plot:52 [ plots::i#2 plot::x#0 plot::plotter_x#2 plot::plotter_y#2 ] { } ) always clobbers reg byte a
Statement [62] plot::plotter#0 = plot::plotter_x#2 + plot::plotter_y#2 [ plot::x#0 plot::plotter#0 ] ( plots:9::plot:52 [ plots::i#2 plot::x#0 plot::plotter#0 ] { } ) always clobbers reg byte a

View File

@ -265,7 +265,7 @@ main: {
// [5] call get
// [10] phi from main::@1 to get [phi:main::@1->get]
get_from___b1:
// [10] phi get::ptr#2 = 0 [phi:main::@1->get#0] -- pbuz1=vwuc1
// [10] phi get::ptr#2 = 0 [phi:main::@1->get#0] -- pbuz1=vbuc1
lda #<0
sta.z get.ptr
lda #>0
@ -395,7 +395,7 @@ main: {
// get(NULL)
// [5] call get
// [10] phi from main::@1 to get [phi:main::@1->get]
// [10] phi get::ptr#2 = 0 [phi:main::@1->get#0] -- pbuz1=vwuc1
// [10] phi get::ptr#2 = 0 [phi:main::@1->get#0] -- pbuz1=vbuc1
lda #<0
sta.z get.ptr
sta.z get.ptr+1