mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-20 02:32:36 +00:00
Changed fragment optimization _plus_2 to only be used for byte values.
This commit is contained in:
parent
06a2e00540
commit
d28bb8245b
@ -1,7 +0,0 @@
|
||||
lda {m1}
|
||||
clc
|
||||
adc #2
|
||||
sta {m1}
|
||||
bcc !+
|
||||
inc {m1}+1
|
||||
!:
|
@ -1,7 +0,0 @@
|
||||
lda {m2}
|
||||
clc
|
||||
adc #2
|
||||
sta {m1}
|
||||
lda {m2}+1
|
||||
adc #0
|
||||
sta {m1}+1
|
13
src/main/fragment/mos6502-common/vdum1=_dec_vdum1.asm
Normal file
13
src/main/fragment/mos6502-common/vdum1=_dec_vdum1.asm
Normal file
@ -0,0 +1,13 @@
|
||||
lda {m1}
|
||||
sec
|
||||
sbc #1
|
||||
sta {m1}
|
||||
lda {m1}+1
|
||||
sbc #0
|
||||
sta {m1}+1
|
||||
lda {m1}+2
|
||||
sbc #0
|
||||
sta {m1}+2
|
||||
lda {m1}+3
|
||||
sbc #0
|
||||
sta {m1}+3
|
@ -1,13 +0,0 @@
|
||||
clc
|
||||
lda {c1}
|
||||
adc #2
|
||||
sta {m1}
|
||||
lda {c1}+1
|
||||
adc #0
|
||||
sta {m1}+1
|
||||
lda {c1}+2
|
||||
adc #0
|
||||
sta {m1}+2
|
||||
lda {c1}+3
|
||||
adc #0
|
||||
sta {m1}+3
|
@ -1,7 +0,0 @@
|
||||
lda {m1}
|
||||
clc
|
||||
adc #2
|
||||
sta {m1}
|
||||
bcc !+
|
||||
inc {m1}+1
|
||||
!:
|
@ -1,7 +0,0 @@
|
||||
lda {m1}
|
||||
sec
|
||||
sbc #2
|
||||
sta {m1}
|
||||
bcs !+
|
||||
dec {m1}+1
|
||||
!:
|
@ -1,7 +0,0 @@
|
||||
lda {m1}
|
||||
clc
|
||||
adc #2
|
||||
sta {m1}
|
||||
bcc !+
|
||||
inc {m1}+1
|
||||
!:
|
@ -1,7 +0,0 @@
|
||||
lda {m2}
|
||||
sec
|
||||
sbc #2
|
||||
sta {m1}
|
||||
lda {m2}+1
|
||||
sbc #0
|
||||
sta {m1}+1
|
@ -134,6 +134,10 @@ public class AsmFragmentInstanceSpecFactory {
|
||||
}
|
||||
|
||||
private String assignmentRightSideSignature(RValue rValue1, Operator operator, RValue rValue2) {
|
||||
|
||||
final SymbolType rValue1Type = rValue1==null?null:SymbolTypeInference.inferType(program.getScope(), rValue1);
|
||||
final SymbolType rValue2Type = rValue2==null?null:SymbolTypeInference.inferType(program.getScope(), rValue2);
|
||||
|
||||
StringBuilder signature = new StringBuilder();
|
||||
if(rValue1 != null) {
|
||||
signature.append(bind(rValue1));
|
||||
@ -151,7 +155,9 @@ public class AsmFragmentInstanceSpecFactory {
|
||||
rValue2 instanceof ConstantInteger &&
|
||||
((ConstantInteger) rValue2).getValue() == 2 &&
|
||||
operator != null &&
|
||||
(operator.getOperator().equals("-") || operator.getOperator().equals("+"))) {
|
||||
(operator.getOperator().equals("-") || operator.getOperator().equals("+")) &&
|
||||
(SymbolType.BYTE.equals(rValue1Type) || SymbolType.SBYTE.equals(rValue1Type))
|
||||
) {
|
||||
signature.append("2");
|
||||
} else if(
|
||||
rValue2 instanceof ConstantInteger &&
|
||||
|
@ -125,6 +125,8 @@ public class SymbolTypeInference {
|
||||
return ((StructUnwoundPlaceholder) rValue).getTypeStruct();
|
||||
} else if(rValue instanceof ConstantStructValue) {
|
||||
return ((ConstantStructValue) rValue).getStructType();
|
||||
} else if(rValue instanceof StackPullValue) {
|
||||
return ((StackPullValue) rValue).getType();
|
||||
}
|
||||
if(type == null) {
|
||||
throw new InternalError("Cannot infer type for " + rValue.toString());
|
||||
|
@ -37,6 +37,11 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSqrDelta() throws IOException, URISyntaxException {
|
||||
compileAndCompare("sqr-delta");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegister1() throws IOException, URISyntaxException {
|
||||
assertError("register-1", "Unknown register");
|
||||
|
17
src/test/kc/sqr-delta.kc
Normal file
17
src/test/kc/sqr-delta.kc
Normal file
@ -0,0 +1,17 @@
|
||||
unsigned long ifunc(unsigned long a){
|
||||
unsigned long x = 1;
|
||||
unsigned long xsqr = 1;
|
||||
unsigned long delta = 3;
|
||||
while(xsqr <=a){
|
||||
++x;
|
||||
xsqr += delta;
|
||||
delta += 2;
|
||||
}
|
||||
return --x;
|
||||
}
|
||||
|
||||
unsigned long* SCREEN = 0x0400;
|
||||
|
||||
void main() {
|
||||
SCREEN[0] = ifunc(8);
|
||||
}
|
@ -73,9 +73,9 @@ print_word_at: {
|
||||
jsr print_byte_at
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
lda.z print_byte_at.at
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
@ -809,13 +809,13 @@ print_word_at: {
|
||||
// [23] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [24] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_2
|
||||
lda.z at
|
||||
// [24] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z at
|
||||
sta.z print_byte_at.at
|
||||
lda.z at+1
|
||||
adc #0
|
||||
lda #0
|
||||
adc.z at+1
|
||||
sta.z print_byte_at.at+1
|
||||
// [25] call print_byte_at
|
||||
// [27] phi from print_word_at::@1 to print_byte_at [phi:print_word_at::@1->print_byte_at]
|
||||
@ -1205,10 +1205,10 @@ print_word_at: {
|
||||
// [23] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [24] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [24] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
@ -1618,10 +1618,10 @@ print_word_at: {
|
||||
// [23] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [24] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [24] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
@ -54,9 +54,9 @@ print_word_at: {
|
||||
jsr print_byte_at
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
lda.z print_byte_at.at
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
@ -756,13 +756,13 @@ print_word_at: {
|
||||
// [20] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [21] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_2
|
||||
lda.z at
|
||||
// [21] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z at
|
||||
sta.z print_byte_at.at
|
||||
lda.z at+1
|
||||
adc #0
|
||||
lda #0
|
||||
adc.z at+1
|
||||
sta.z print_byte_at.at+1
|
||||
// [22] call print_byte_at
|
||||
// [24] phi from print_word_at::@1 to print_byte_at [phi:print_word_at::@1->print_byte_at]
|
||||
@ -1119,10 +1119,10 @@ print_word_at: {
|
||||
// [20] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [21] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [21] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
@ -1500,10 +1500,10 @@ print_word_at: {
|
||||
// [20] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [21] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [21] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
@ -295,11 +295,11 @@ mulf_init: {
|
||||
sta.z sqr+1
|
||||
lda.z add
|
||||
clc
|
||||
adc #2
|
||||
adc #<2
|
||||
sta.z add
|
||||
bcc !+
|
||||
inc.z add+1
|
||||
!:
|
||||
lda.z add+1
|
||||
adc #>2
|
||||
sta.z add+1
|
||||
iny
|
||||
cpy #$81
|
||||
bne __b1
|
||||
|
@ -2314,14 +2314,14 @@ mulf_init: {
|
||||
lda.z sqr+1
|
||||
adc.z add+1
|
||||
sta.z sqr+1
|
||||
// [103] (signed word) mulf_init::add#1 ← (signed word) mulf_init::add#2 + (signed byte) 2 -- vwsz1=vwsz1_plus_2
|
||||
// [103] (signed word) mulf_init::add#1 ← (signed word) mulf_init::add#2 + (signed byte) 2 -- vwsz1=vwsz1_plus_vbsc1
|
||||
lda.z add
|
||||
clc
|
||||
adc #2
|
||||
adc #<2
|
||||
sta.z add
|
||||
bcc !+
|
||||
inc.z add+1
|
||||
!:
|
||||
lda.z add+1
|
||||
adc #>2
|
||||
sta.z add+1
|
||||
// [104] (byte) mulf_init::i#1 ← ++ (byte) mulf_init::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc.z i
|
||||
// [105] if((byte) mulf_init::i#1!=(byte) $81) goto mulf_init::@1 -- vbuz1_neq_vbuc1_then_la1
|
||||
@ -2464,22 +2464,22 @@ Uplift Scope [main]
|
||||
Uplift Scope [do_perspective]
|
||||
Uplift Scope [perspective]
|
||||
|
||||
Uplifting [mulf_init] best 4030 combination reg byte y [ mulf_init::i#2 mulf_init::i#1 ] reg byte x [ mulf_init::$5 ] reg byte x [ mulf_init::$6 ] reg byte x [ mulf_init::$2 ] zp[2]:16 [ mulf_init::add#2 mulf_init::add#1 ] zp[1]:20 [ mulf_init::val#0 ] zp[2]:13 [ mulf_init::sqr#2 mulf_init::sqr#1 ]
|
||||
Uplifting [mulf_init] best 4035 combination reg byte y [ mulf_init::i#2 mulf_init::i#1 ] reg byte x [ mulf_init::$5 ] reg byte x [ mulf_init::$6 ] reg byte x [ mulf_init::$2 ] zp[2]:16 [ mulf_init::add#2 mulf_init::add#1 ] zp[1]:20 [ mulf_init::val#0 ] zp[2]:13 [ mulf_init::sqr#2 mulf_init::sqr#1 ]
|
||||
Limited combination testing to 100 combinations of 432 possible.
|
||||
Uplifting [] best 4030 combination zp[2]:2 [ print_line_cursor#11 print_line_cursor#1 ] zp[2]:8 [ print_char_cursor#44 print_char_cursor#69 print_char_cursor#2 print_char_cursor#74 print_char_cursor#12 print_char_cursor#1 ]
|
||||
Uplifting [memset] best 4030 combination zp[2]:11 [ memset::dst#2 memset::dst#1 ]
|
||||
Uplifting [print_str] best 4030 combination zp[2]:4 [ print_str::str#7 print_str::str#9 print_str::str#0 ]
|
||||
Uplifting [print_byte] best 4009 combination reg byte x [ print_byte::b#3 print_byte::b#5 print_byte::b#6 print_byte::b#0 ] reg byte a [ print_byte::$0 ] reg byte x [ print_byte::$2 ]
|
||||
Uplifting [print_char] best 3994 combination reg byte a [ print_char::ch#4 print_char::ch#2 print_char::ch#3 ]
|
||||
Uplifting [print_sbyte] best 3979 combination reg byte x [ print_sbyte::b#6 print_sbyte::b#0 print_sbyte::b#4 ]
|
||||
Uplifting [RADIX] best 3979 combination
|
||||
Uplifting [print_ln] best 3979 combination
|
||||
Uplifting [print_cls] best 3979 combination
|
||||
Uplifting [main] best 3979 combination
|
||||
Uplifting [do_perspective] best 3979 combination
|
||||
Uplifting [perspective] best 3979 combination
|
||||
Uplifting [] best 4035 combination zp[2]:2 [ print_line_cursor#11 print_line_cursor#1 ] zp[2]:8 [ print_char_cursor#44 print_char_cursor#69 print_char_cursor#2 print_char_cursor#74 print_char_cursor#12 print_char_cursor#1 ]
|
||||
Uplifting [memset] best 4035 combination zp[2]:11 [ memset::dst#2 memset::dst#1 ]
|
||||
Uplifting [print_str] best 4035 combination zp[2]:4 [ print_str::str#7 print_str::str#9 print_str::str#0 ]
|
||||
Uplifting [print_byte] best 4014 combination reg byte x [ print_byte::b#3 print_byte::b#5 print_byte::b#6 print_byte::b#0 ] reg byte a [ print_byte::$0 ] reg byte x [ print_byte::$2 ]
|
||||
Uplifting [print_char] best 3999 combination reg byte a [ print_char::ch#4 print_char::ch#2 print_char::ch#3 ]
|
||||
Uplifting [print_sbyte] best 3984 combination reg byte x [ print_sbyte::b#6 print_sbyte::b#0 print_sbyte::b#4 ]
|
||||
Uplifting [RADIX] best 3984 combination
|
||||
Uplifting [print_ln] best 3984 combination
|
||||
Uplifting [print_cls] best 3984 combination
|
||||
Uplifting [main] best 3984 combination
|
||||
Uplifting [do_perspective] best 3984 combination
|
||||
Uplifting [perspective] best 3984 combination
|
||||
Attempting to uplift remaining variables inzp[1]:20 [ mulf_init::val#0 ]
|
||||
Uplifting [mulf_init] best 3979 combination zp[1]:20 [ mulf_init::val#0 ]
|
||||
Uplifting [mulf_init] best 3984 combination zp[1]:20 [ mulf_init::val#0 ]
|
||||
Coalescing zero page register [ zp[2]:4 [ print_str::str#7 print_str::str#9 print_str::str#0 ] ] with [ zp[2]:2 [ print_line_cursor#11 print_line_cursor#1 ] ]
|
||||
Coalescing zero page register [ zp[2]:11 [ memset::dst#2 memset::dst#1 ] ] with [ zp[2]:8 [ print_char_cursor#44 print_char_cursor#69 print_char_cursor#2 print_char_cursor#74 print_char_cursor#12 print_char_cursor#1 ] ]
|
||||
Coalescing zero page register [ zp[2]:13 [ mulf_init::sqr#2 mulf_init::sqr#1 ] ] with [ zp[2]:4 [ print_str::str#7 print_str::str#9 print_str::str#0 print_line_cursor#11 print_line_cursor#1 ] ]
|
||||
@ -3118,14 +3118,14 @@ mulf_init: {
|
||||
lda.z sqr+1
|
||||
adc.z add+1
|
||||
sta.z sqr+1
|
||||
// [103] (signed word) mulf_init::add#1 ← (signed word) mulf_init::add#2 + (signed byte) 2 -- vwsz1=vwsz1_plus_2
|
||||
// [103] (signed word) mulf_init::add#1 ← (signed word) mulf_init::add#2 + (signed byte) 2 -- vwsz1=vwsz1_plus_vbsc1
|
||||
lda.z add
|
||||
clc
|
||||
adc #2
|
||||
adc #<2
|
||||
sta.z add
|
||||
bcc !+
|
||||
inc.z add+1
|
||||
!:
|
||||
lda.z add+1
|
||||
adc #>2
|
||||
sta.z add+1
|
||||
// [104] (byte) mulf_init::i#1 ← ++ (byte) mulf_init::i#2 -- vbuyy=_inc_vbuyy
|
||||
iny
|
||||
// [105] if((byte) mulf_init::i#1!=(byte) $81) goto mulf_init::@1 -- vbuyy_neq_vbuc1_then_la1
|
||||
@ -3473,7 +3473,7 @@ reg byte x [ mulf_init::$6 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 3375
|
||||
Score: 3380
|
||||
|
||||
// File Comments
|
||||
// 3D Rotation using a Rotation Matrix
|
||||
@ -4048,14 +4048,14 @@ mulf_init: {
|
||||
adc.z add+1
|
||||
sta.z sqr+1
|
||||
// add +=2
|
||||
// [103] (signed word) mulf_init::add#1 ← (signed word) mulf_init::add#2 + (signed byte) 2 -- vwsz1=vwsz1_plus_2
|
||||
// [103] (signed word) mulf_init::add#1 ← (signed word) mulf_init::add#2 + (signed byte) 2 -- vwsz1=vwsz1_plus_vbsc1
|
||||
lda.z add
|
||||
clc
|
||||
adc #2
|
||||
adc #<2
|
||||
sta.z add
|
||||
bcc !+
|
||||
inc.z add+1
|
||||
!:
|
||||
lda.z add+1
|
||||
adc #>2
|
||||
sta.z add+1
|
||||
// for( byte i:0..128)
|
||||
// [104] (byte) mulf_init::i#1 ← ++ (byte) mulf_init::i#2 -- vbuyy=_inc_vbuyy
|
||||
iny
|
||||
|
@ -208,9 +208,9 @@ print_word_at: {
|
||||
jsr print_byte_at
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
lda.z print_byte_at.at
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
@ -2833,13 +2833,13 @@ print_word_at: {
|
||||
// [72] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [73] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_2
|
||||
lda.z at
|
||||
// [73] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z at
|
||||
sta.z print_byte_at.at
|
||||
lda.z at+1
|
||||
adc #0
|
||||
lda #0
|
||||
adc.z at+1
|
||||
sta.z print_byte_at.at+1
|
||||
// [74] call print_byte_at
|
||||
// [76] phi from print_word_at::@1 to print_byte_at [phi:print_word_at::@1->print_byte_at]
|
||||
@ -4249,10 +4249,10 @@ print_word_at: {
|
||||
// [72] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [73] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [73] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
@ -5629,10 +5629,10 @@ print_word_at: {
|
||||
// [72] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [73] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [73] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
@ -116,9 +116,9 @@ main: {
|
||||
bne !+
|
||||
inc.z charset4+1
|
||||
!:
|
||||
lda.z chargen
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z chargen
|
||||
sta.z chargen
|
||||
bcc !+
|
||||
inc.z chargen+1
|
||||
|
@ -1118,10 +1118,10 @@ main: {
|
||||
bne !+
|
||||
inc.z charset4+1
|
||||
!:
|
||||
// [50] (byte*) main::chargen#1 ← (byte*) main::chargen#10 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z chargen
|
||||
// [50] (byte*) main::chargen#1 ← (byte*) main::chargen#10 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z chargen
|
||||
sta.z chargen
|
||||
bcc !+
|
||||
inc.z chargen+1
|
||||
@ -1585,10 +1585,10 @@ main: {
|
||||
bne !+
|
||||
inc.z charset4+1
|
||||
!:
|
||||
// [50] (byte*) main::chargen#1 ← (byte*) main::chargen#10 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z chargen
|
||||
// [50] (byte*) main::chargen#1 ← (byte*) main::chargen#10 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z chargen
|
||||
sta.z chargen
|
||||
bcc !+
|
||||
inc.z chargen+1
|
||||
@ -2057,10 +2057,10 @@ main: {
|
||||
inc.z charset4+1
|
||||
!:
|
||||
// chargen = chargen+2
|
||||
// [50] (byte*) main::chargen#1 ← (byte*) main::chargen#10 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z chargen
|
||||
// [50] (byte*) main::chargen#1 ← (byte*) main::chargen#10 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z chargen
|
||||
sta.z chargen
|
||||
bcc !+
|
||||
inc.z chargen+1
|
||||
|
@ -86,9 +86,9 @@ print_word_at: {
|
||||
jsr print_byte_at
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
lda.z print_byte_at.at
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
@ -2685,13 +2685,13 @@ print_word_at: {
|
||||
// [30] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_2
|
||||
lda.z at
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z at
|
||||
sta.z print_byte_at.at
|
||||
lda.z at+1
|
||||
adc #0
|
||||
lda #0
|
||||
adc.z at+1
|
||||
sta.z print_byte_at.at+1
|
||||
// [32] call print_byte_at
|
||||
// [34] phi from print_word_at::@1 to print_byte_at [phi:print_word_at::@1->print_byte_at]
|
||||
@ -4053,10 +4053,10 @@ print_word_at: {
|
||||
// [30] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
@ -5444,10 +5444,10 @@ print_word_at: {
|
||||
// [30] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
@ -91,9 +91,9 @@ print_word_at: {
|
||||
jsr print_byte_at
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
lda.z print_byte_at.at
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
@ -3195,13 +3195,13 @@ print_word_at: {
|
||||
// [30] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_2
|
||||
lda.z at
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz2_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z at
|
||||
sta.z print_byte_at.at
|
||||
lda.z at+1
|
||||
adc #0
|
||||
lda #0
|
||||
adc.z at+1
|
||||
sta.z print_byte_at.at+1
|
||||
// [32] call print_byte_at
|
||||
// [34] phi from print_word_at::@1 to print_byte_at [phi:print_word_at::@1->print_byte_at]
|
||||
@ -4683,10 +4683,10 @@ print_word_at: {
|
||||
// [30] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
@ -6126,10 +6126,10 @@ print_word_at: {
|
||||
// [30] (byte) print_byte_at::b#1 ← < (word) print_word_at::w#2 -- vbuz1=_lo_vwuz2
|
||||
lda.z w
|
||||
sta.z print_byte_at.b
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_2
|
||||
lda.z print_byte_at.at
|
||||
// [31] (byte*) print_byte_at::at#1 ← (byte*) print_word_at::at#2 + (byte) 2 -- pbuz1=pbuz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc #2
|
||||
adc.z print_byte_at.at
|
||||
sta.z print_byte_at.at
|
||||
bcc !+
|
||||
inc.z print_byte_at.at+1
|
||||
|
115
src/test/ref/sqr-delta.asm
Normal file
115
src/test/ref/sqr-delta.asm
Normal file
@ -0,0 +1,115 @@
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.label SCREEN = $400
|
||||
main: {
|
||||
.label __0 = 6
|
||||
jsr ifunc
|
||||
lda.z __0
|
||||
sta SCREEN
|
||||
lda.z __0+1
|
||||
sta SCREEN+1
|
||||
lda.z __0+2
|
||||
sta SCREEN+2
|
||||
lda.z __0+3
|
||||
sta SCREEN+3
|
||||
rts
|
||||
}
|
||||
ifunc: {
|
||||
.const a = 8
|
||||
.label x = 6
|
||||
.label xsqr = 2
|
||||
.label delta = $a
|
||||
.label return = 6
|
||||
lda #<3
|
||||
sta.z delta
|
||||
lda #>3
|
||||
sta.z delta+1
|
||||
lda #<3>>$10
|
||||
sta.z delta+2
|
||||
lda #>3>>$10
|
||||
sta.z delta+3
|
||||
lda #<1
|
||||
sta.z x
|
||||
lda #>1
|
||||
sta.z x+1
|
||||
lda #<1>>$10
|
||||
sta.z x+2
|
||||
lda #>1>>$10
|
||||
sta.z x+3
|
||||
lda #<1
|
||||
sta.z xsqr
|
||||
lda #>1
|
||||
sta.z xsqr+1
|
||||
lda #<1>>$10
|
||||
sta.z xsqr+2
|
||||
lda #>1>>$10
|
||||
sta.z xsqr+3
|
||||
__b1:
|
||||
lda.z xsqr+3
|
||||
cmp #>a+1>>$10
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr+2
|
||||
cmp #<a+1>>$10
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr+1
|
||||
cmp #>a+1
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr
|
||||
cmp #<a+1
|
||||
bcc __b2
|
||||
!:
|
||||
lda.z return
|
||||
sec
|
||||
sbc #1
|
||||
sta.z return
|
||||
lda.z return+1
|
||||
sbc #0
|
||||
sta.z return+1
|
||||
lda.z return+2
|
||||
sbc #0
|
||||
sta.z return+2
|
||||
lda.z return+3
|
||||
sbc #0
|
||||
sta.z return+3
|
||||
rts
|
||||
__b2:
|
||||
inc.z x
|
||||
bne !+
|
||||
inc.z x+1
|
||||
bne !+
|
||||
inc.z x+2
|
||||
bne !+
|
||||
inc.z x+3
|
||||
!:
|
||||
lda.z xsqr
|
||||
clc
|
||||
adc.z delta
|
||||
sta.z xsqr
|
||||
lda.z xsqr+1
|
||||
adc.z delta+1
|
||||
sta.z xsqr+1
|
||||
lda.z xsqr+2
|
||||
adc.z delta+2
|
||||
sta.z xsqr+2
|
||||
lda.z xsqr+3
|
||||
adc.z delta+3
|
||||
sta.z xsqr+3
|
||||
lda #2
|
||||
clc
|
||||
adc.z delta
|
||||
sta.z delta
|
||||
lda.z delta+1
|
||||
adc #0
|
||||
sta.z delta+1
|
||||
lda.z delta+2
|
||||
adc #0
|
||||
sta.z delta+2
|
||||
lda.z delta+3
|
||||
adc #0
|
||||
sta.z delta+3
|
||||
jmp __b1
|
||||
}
|
45
src/test/ref/sqr-delta.cfg
Normal file
45
src/test/ref/sqr-delta.cfg
Normal file
@ -0,0 +1,45 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
[5] call ifunc
|
||||
[6] (dword) ifunc::return#2 ← (dword) ifunc::return#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
[7] (dword~) main::$0 ← (dword) ifunc::return#2
|
||||
[8] *((const dword*) SCREEN) ← (dword~) main::$0
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[9] return
|
||||
to:@return
|
||||
|
||||
(dword()) ifunc((dword) ifunc::a)
|
||||
ifunc: scope:[ifunc] from main
|
||||
[10] phi()
|
||||
to:ifunc::@1
|
||||
ifunc::@1: scope:[ifunc] from ifunc ifunc::@2
|
||||
[11] (dword) ifunc::delta#2 ← phi( ifunc/(dword) 3 ifunc::@2/(dword) ifunc::delta#1 )
|
||||
[11] (dword) ifunc::x#3 ← phi( ifunc/(dword) 1 ifunc::@2/(dword) ifunc::x#1 )
|
||||
[11] (dword) ifunc::xsqr#2 ← phi( ifunc/(dword) 1 ifunc::@2/(dword) ifunc::xsqr#1 )
|
||||
[12] if((dword) ifunc::xsqr#2<(const dword) ifunc::a#0+(byte) 1) goto ifunc::@2
|
||||
to:ifunc::@3
|
||||
ifunc::@3: scope:[ifunc] from ifunc::@1
|
||||
[13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3
|
||||
to:ifunc::@return
|
||||
ifunc::@return: scope:[ifunc] from ifunc::@3
|
||||
[14] return
|
||||
to:@return
|
||||
ifunc::@2: scope:[ifunc] from ifunc::@1
|
||||
[15] (dword) ifunc::x#1 ← ++ (dword) ifunc::x#3
|
||||
[16] (dword) ifunc::xsqr#1 ← (dword) ifunc::xsqr#2 + (dword) ifunc::delta#2
|
||||
[17] (dword) ifunc::delta#1 ← (dword) ifunc::delta#2 + (byte) 2
|
||||
to:ifunc::@1
|
928
src/test/ref/sqr-delta.log
Normal file
928
src/test/ref/sqr-delta.log
Normal file
@ -0,0 +1,928 @@
|
||||
Fixing pointer array-indexing *((dword*) SCREEN + (number) 0)
|
||||
Identified constant variable (dword*) SCREEN
|
||||
Culled Empty Block (label) ifunc::@4
|
||||
Culled Empty Block (label) ifunc::@5
|
||||
Culled Empty Block (label) ifunc::@6
|
||||
Culled Empty Block (label) ifunc::@7
|
||||
Culled Empty Block (label) @1
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
to:@2
|
||||
|
||||
(dword()) ifunc((dword) ifunc::a)
|
||||
ifunc: scope:[ifunc] from main
|
||||
(dword) ifunc::a#2 ← phi( main/(dword) ifunc::a#0 )
|
||||
(dword) ifunc::x#0 ← (dword) 1
|
||||
(dword) ifunc::xsqr#0 ← (dword) 1
|
||||
(dword) ifunc::delta#0 ← (dword) 3
|
||||
to:ifunc::@1
|
||||
ifunc::@1: scope:[ifunc] from ifunc ifunc::@2
|
||||
(dword) ifunc::delta#3 ← phi( ifunc/(dword) ifunc::delta#0 ifunc::@2/(dword) ifunc::delta#1 )
|
||||
(dword) ifunc::x#5 ← phi( ifunc/(dword) ifunc::x#0 ifunc::@2/(dword) ifunc::x#1 )
|
||||
(dword) ifunc::a#1 ← phi( ifunc/(dword) ifunc::a#2 ifunc::@2/(dword) ifunc::a#3 )
|
||||
(dword) ifunc::xsqr#2 ← phi( ifunc/(dword) ifunc::xsqr#0 ifunc::@2/(dword) ifunc::xsqr#1 )
|
||||
(bool~) ifunc::$0 ← (dword) ifunc::xsqr#2 <= (dword) ifunc::a#1
|
||||
if((bool~) ifunc::$0) goto ifunc::@2
|
||||
to:ifunc::@3
|
||||
ifunc::@2: scope:[ifunc] from ifunc::@1
|
||||
(dword) ifunc::a#3 ← phi( ifunc::@1/(dword) ifunc::a#1 )
|
||||
(dword) ifunc::delta#2 ← phi( ifunc::@1/(dword) ifunc::delta#3 )
|
||||
(dword) ifunc::xsqr#3 ← phi( ifunc::@1/(dword) ifunc::xsqr#2 )
|
||||
(dword) ifunc::x#3 ← phi( ifunc::@1/(dword) ifunc::x#5 )
|
||||
(dword) ifunc::x#1 ← ++ (dword) ifunc::x#3
|
||||
(dword) ifunc::xsqr#1 ← (dword) ifunc::xsqr#3 + (dword) ifunc::delta#2
|
||||
(dword) ifunc::delta#1 ← (dword) ifunc::delta#2 + (number) 2
|
||||
to:ifunc::@1
|
||||
ifunc::@3: scope:[ifunc] from ifunc::@1
|
||||
(dword) ifunc::x#4 ← phi( ifunc::@1/(dword) ifunc::x#5 )
|
||||
(dword) ifunc::x#2 ← -- (dword) ifunc::x#4
|
||||
(dword) ifunc::return#0 ← (dword) ifunc::x#2
|
||||
to:ifunc::@return
|
||||
ifunc::@return: scope:[ifunc] from ifunc::@3
|
||||
(dword) ifunc::return#3 ← phi( ifunc::@3/(dword) ifunc::return#0 )
|
||||
(dword) ifunc::return#1 ← (dword) ifunc::return#3
|
||||
return
|
||||
to:@return
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from @2
|
||||
(dword) ifunc::a#0 ← (number) 8
|
||||
call ifunc
|
||||
(dword) ifunc::return#2 ← (dword) ifunc::return#1
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
(dword) ifunc::return#4 ← phi( main/(dword) ifunc::return#2 )
|
||||
(dword~) main::$0 ← (dword) ifunc::return#4
|
||||
(number~) main::$1 ← (number) 0 * (const byte) SIZEOF_DWORD
|
||||
*((const dword*) SCREEN + (number~) main::$1) ← (dword~) main::$0
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@2: scope:[] from @begin
|
||||
call main
|
||||
to:@3
|
||||
@3: scope:[] from @2
|
||||
to:@end
|
||||
@end: scope:[] from @3
|
||||
|
||||
SYMBOL TABLE SSA
|
||||
(label) @2
|
||||
(label) @3
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const dword*) SCREEN = (dword*)(number) $400
|
||||
(const byte) SIZEOF_DWORD = (byte) 4
|
||||
(dword()) ifunc((dword) ifunc::a)
|
||||
(bool~) ifunc::$0
|
||||
(label) ifunc::@1
|
||||
(label) ifunc::@2
|
||||
(label) ifunc::@3
|
||||
(label) ifunc::@return
|
||||
(dword) ifunc::a
|
||||
(dword) ifunc::a#0
|
||||
(dword) ifunc::a#1
|
||||
(dword) ifunc::a#2
|
||||
(dword) ifunc::a#3
|
||||
(dword) ifunc::delta
|
||||
(dword) ifunc::delta#0
|
||||
(dword) ifunc::delta#1
|
||||
(dword) ifunc::delta#2
|
||||
(dword) ifunc::delta#3
|
||||
(dword) ifunc::return
|
||||
(dword) ifunc::return#0
|
||||
(dword) ifunc::return#1
|
||||
(dword) ifunc::return#2
|
||||
(dword) ifunc::return#3
|
||||
(dword) ifunc::return#4
|
||||
(dword) ifunc::x
|
||||
(dword) ifunc::x#0
|
||||
(dword) ifunc::x#1
|
||||
(dword) ifunc::x#2
|
||||
(dword) ifunc::x#3
|
||||
(dword) ifunc::x#4
|
||||
(dword) ifunc::x#5
|
||||
(dword) ifunc::xsqr
|
||||
(dword) ifunc::xsqr#0
|
||||
(dword) ifunc::xsqr#1
|
||||
(dword) ifunc::xsqr#2
|
||||
(dword) ifunc::xsqr#3
|
||||
(void()) main()
|
||||
(dword~) main::$0
|
||||
(number~) main::$1
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
|
||||
Adding number conversion cast (unumber) 2 in (dword) ifunc::delta#1 ← (dword) ifunc::delta#2 + (number) 2
|
||||
Adding number conversion cast (unumber) 8 in (dword) ifunc::a#0 ← (number) 8
|
||||
Adding number conversion cast (unumber) 0 in (number~) main::$1 ← (number) 0 * (const byte) SIZEOF_DWORD
|
||||
Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (unumber)(number) 0 * (const byte) SIZEOF_DWORD
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Inlining cast (dword) ifunc::a#0 ← (unumber)(number) 8
|
||||
Successful SSA optimization Pass2InlineCast
|
||||
Simplifying constant pointer cast (dword*) 1024
|
||||
Simplifying constant integer cast 2
|
||||
Simplifying constant integer cast 8
|
||||
Simplifying constant integer cast 0
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Finalized unsigned number type (byte) 2
|
||||
Finalized unsigned number type (byte) 8
|
||||
Finalized unsigned number type (byte) 0
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Inferred type updated to byte in (unumber~) main::$1 ← (byte) 0 * (const byte) SIZEOF_DWORD
|
||||
Alias (dword) ifunc::x#3 = (dword) ifunc::x#5 (dword) ifunc::x#4
|
||||
Alias (dword) ifunc::xsqr#2 = (dword) ifunc::xsqr#3
|
||||
Alias (dword) ifunc::delta#2 = (dword) ifunc::delta#3
|
||||
Alias (dword) ifunc::a#1 = (dword) ifunc::a#3
|
||||
Alias (dword) ifunc::return#0 = (dword) ifunc::x#2 (dword) ifunc::return#3 (dword) ifunc::return#1
|
||||
Alias (dword) ifunc::return#2 = (dword) ifunc::return#4
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Identical Phi Values (dword) ifunc::a#2 (dword) ifunc::a#0
|
||||
Identical Phi Values (dword) ifunc::a#1 (dword) ifunc::a#2
|
||||
Successful SSA optimization Pass2IdenticalPhiElimination
|
||||
Simple Condition (bool~) ifunc::$0 [6] if((dword) ifunc::xsqr#2<=(dword) ifunc::a#0) goto ifunc::@2
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant right-side identified [22] (byte~) main::$1 ← (byte) 0 * (const byte) SIZEOF_DWORD
|
||||
Successful SSA optimization Pass2ConstantRValueConsolidation
|
||||
Constant (const dword) ifunc::x#0 = 1
|
||||
Constant (const dword) ifunc::xsqr#0 = 1
|
||||
Constant (const dword) ifunc::delta#0 = 3
|
||||
Constant (const dword) ifunc::a#0 = 8
|
||||
Constant (const byte) main::$1 = 0*SIZEOF_DWORD
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Rewriting conditional comparison [6] if((dword) ifunc::xsqr#2<=(const dword) ifunc::a#0) goto ifunc::@2
|
||||
Simplifying constant evaluating to zero (byte) 0*(const byte) SIZEOF_DWORD in
|
||||
Successful SSA optimization PassNSimplifyConstantZero
|
||||
Simplifying expression containing zero SCREEN in [23] *((const dword*) SCREEN + (const byte) main::$1) ← (dword~) main::$0
|
||||
Successful SSA optimization PassNSimplifyExpressionWithZero
|
||||
Eliminating unused constant (const byte) main::$1
|
||||
Eliminating unused constant (const byte) SIZEOF_DWORD
|
||||
Successful SSA optimization PassNEliminateUnusedVars
|
||||
Adding number conversion cast (unumber) ifunc::a#0+1 in if((dword) ifunc::xsqr#2<(const dword) ifunc::a#0+(number) 1) goto ifunc::@2
|
||||
Adding number conversion cast (unumber) 1 in if((dword) ifunc::xsqr#2<(unumber)(const dword) ifunc::a#0+(number) 1) goto ifunc::@2
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Simplifying constant integer cast (const dword) ifunc::a#0+(unumber)(number) 1
|
||||
Simplifying constant integer cast 1
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Finalized unsigned number type (byte) 1
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Inlining constant with var siblings (const dword) ifunc::x#0
|
||||
Inlining constant with var siblings (const dword) ifunc::xsqr#0
|
||||
Inlining constant with var siblings (const dword) ifunc::delta#0
|
||||
Constant inlined ifunc::xsqr#0 = (dword) 1
|
||||
Constant inlined ifunc::delta#0 = (dword) 3
|
||||
Constant inlined ifunc::x#0 = (dword) 1
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @2
|
||||
Adding NOP phi() at start of @3
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
Adding NOP phi() at start of ifunc
|
||||
CALL GRAPH
|
||||
Calls in [] to main:2
|
||||
Calls in [main] to ifunc:6
|
||||
|
||||
Created 3 initial phi equivalence classes
|
||||
Coalesced [19] ifunc::xsqr#4 ← ifunc::xsqr#1
|
||||
Coalesced [20] ifunc::x#6 ← ifunc::x#1
|
||||
Coalesced [21] ifunc::delta#4 ← ifunc::delta#1
|
||||
Coalesced down to 3 phi equivalence classes
|
||||
Culled Empty Block (label) @3
|
||||
Renumbering block @2 to @1
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
Adding NOP phi() at start of ifunc
|
||||
|
||||
FINAL CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
[5] call ifunc
|
||||
[6] (dword) ifunc::return#2 ← (dword) ifunc::return#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
[7] (dword~) main::$0 ← (dword) ifunc::return#2
|
||||
[8] *((const dword*) SCREEN) ← (dword~) main::$0
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[9] return
|
||||
to:@return
|
||||
|
||||
(dword()) ifunc((dword) ifunc::a)
|
||||
ifunc: scope:[ifunc] from main
|
||||
[10] phi()
|
||||
to:ifunc::@1
|
||||
ifunc::@1: scope:[ifunc] from ifunc ifunc::@2
|
||||
[11] (dword) ifunc::delta#2 ← phi( ifunc/(dword) 3 ifunc::@2/(dword) ifunc::delta#1 )
|
||||
[11] (dword) ifunc::x#3 ← phi( ifunc/(dword) 1 ifunc::@2/(dword) ifunc::x#1 )
|
||||
[11] (dword) ifunc::xsqr#2 ← phi( ifunc/(dword) 1 ifunc::@2/(dword) ifunc::xsqr#1 )
|
||||
[12] if((dword) ifunc::xsqr#2<(const dword) ifunc::a#0+(byte) 1) goto ifunc::@2
|
||||
to:ifunc::@3
|
||||
ifunc::@3: scope:[ifunc] from ifunc::@1
|
||||
[13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3
|
||||
to:ifunc::@return
|
||||
ifunc::@return: scope:[ifunc] from ifunc::@3
|
||||
[14] return
|
||||
to:@return
|
||||
ifunc::@2: scope:[ifunc] from ifunc::@1
|
||||
[15] (dword) ifunc::x#1 ← ++ (dword) ifunc::x#3
|
||||
[16] (dword) ifunc::xsqr#1 ← (dword) ifunc::xsqr#2 + (dword) ifunc::delta#2
|
||||
[17] (dword) ifunc::delta#1 ← (dword) ifunc::delta#2 + (byte) 2
|
||||
to:ifunc::@1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(dword()) ifunc((dword) ifunc::a)
|
||||
(dword) ifunc::a
|
||||
(dword) ifunc::delta
|
||||
(dword) ifunc::delta#1 22.0
|
||||
(dword) ifunc::delta#2 8.25
|
||||
(dword) ifunc::return
|
||||
(dword) ifunc::return#0 1.3333333333333333
|
||||
(dword) ifunc::return#2 4.0
|
||||
(dword) ifunc::x
|
||||
(dword) ifunc::x#1 7.333333333333333
|
||||
(dword) ifunc::x#3 12.0
|
||||
(dword) ifunc::xsqr
|
||||
(dword) ifunc::xsqr#1 11.0
|
||||
(dword) ifunc::xsqr#2 11.0
|
||||
(void()) main()
|
||||
(dword~) main::$0 4.0
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ ifunc::xsqr#2 ifunc::xsqr#1 ]
|
||||
[ ifunc::x#3 ifunc::x#1 ]
|
||||
[ ifunc::delta#2 ifunc::delta#1 ]
|
||||
Added variable ifunc::return#2 to live range equivalence class [ ifunc::return#2 ]
|
||||
Added variable main::$0 to live range equivalence class [ main::$0 ]
|
||||
Added variable ifunc::return#0 to live range equivalence class [ ifunc::return#0 ]
|
||||
Complete equivalence classes
|
||||
[ ifunc::xsqr#2 ifunc::xsqr#1 ]
|
||||
[ ifunc::x#3 ifunc::x#1 ]
|
||||
[ ifunc::delta#2 ifunc::delta#1 ]
|
||||
[ ifunc::return#2 ]
|
||||
[ main::$0 ]
|
||||
[ ifunc::return#0 ]
|
||||
Allocated zp[4]:2 [ ifunc::xsqr#2 ifunc::xsqr#1 ]
|
||||
Allocated zp[4]:6 [ ifunc::x#3 ifunc::x#1 ]
|
||||
Allocated zp[4]:10 [ ifunc::delta#2 ifunc::delta#1 ]
|
||||
Allocated zp[4]:14 [ ifunc::return#2 ]
|
||||
Allocated zp[4]:18 [ main::$0 ]
|
||||
Allocated zp[4]:22 [ ifunc::return#0 ]
|
||||
Warning! Unknown fragment for statement [13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3
|
||||
Missing ASM fragment Fragment not found vduz1=_dec_vduz2. Attempted variations vduz1=_dec_vduz2
|
||||
File /Users/jespergravgaard/c64/kickc/src/test/kc/sqr-delta.kc
|
||||
Line 10
|
||||
return --x;
|
||||
|
||||
INITIAL ASM
|
||||
Target platform is c64basic / MOS6502X
|
||||
// File Comments
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(__bbegin)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
.label SCREEN = $400
|
||||
// @begin
|
||||
__bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
__b1_from___bbegin:
|
||||
jmp __b1
|
||||
// @1
|
||||
__b1:
|
||||
// [2] call main
|
||||
// [4] phi from @1 to main [phi:@1->main]
|
||||
main_from___b1:
|
||||
jsr main
|
||||
// [3] phi from @1 to @end [phi:@1->@end]
|
||||
__bend_from___b1:
|
||||
jmp __bend
|
||||
// @end
|
||||
__bend:
|
||||
// main
|
||||
main: {
|
||||
.label __0 = $12
|
||||
// [5] call ifunc
|
||||
// [10] phi from main to ifunc [phi:main->ifunc]
|
||||
ifunc_from_main:
|
||||
jsr ifunc
|
||||
// [6] (dword) ifunc::return#2 ← (dword) ifunc::return#0 -- vduz1=vduz2
|
||||
lda.z ifunc.return
|
||||
sta.z ifunc.return_1
|
||||
lda.z ifunc.return+1
|
||||
sta.z ifunc.return_1+1
|
||||
lda.z ifunc.return+2
|
||||
sta.z ifunc.return_1+2
|
||||
lda.z ifunc.return+3
|
||||
sta.z ifunc.return_1+3
|
||||
jmp __b1
|
||||
// main::@1
|
||||
__b1:
|
||||
// [7] (dword~) main::$0 ← (dword) ifunc::return#2 -- vduz1=vduz2
|
||||
lda.z ifunc.return_1
|
||||
sta.z __0
|
||||
lda.z ifunc.return_1+1
|
||||
sta.z __0+1
|
||||
lda.z ifunc.return_1+2
|
||||
sta.z __0+2
|
||||
lda.z ifunc.return_1+3
|
||||
sta.z __0+3
|
||||
// [8] *((const dword*) SCREEN) ← (dword~) main::$0 -- _deref_pduc1=vduz1
|
||||
lda.z __0
|
||||
sta SCREEN
|
||||
lda.z __0+1
|
||||
sta SCREEN+1
|
||||
lda.z __0+2
|
||||
sta SCREEN+2
|
||||
lda.z __0+3
|
||||
sta SCREEN+3
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [9] return
|
||||
rts
|
||||
}
|
||||
// ifunc
|
||||
ifunc: {
|
||||
.const a = 8
|
||||
.label x = 6
|
||||
.label xsqr = 2
|
||||
.label delta = $a
|
||||
.label return = $16
|
||||
.label return_1 = $e
|
||||
// [11] phi from ifunc to ifunc::@1 [phi:ifunc->ifunc::@1]
|
||||
__b1_from_ifunc:
|
||||
// [11] phi (dword) ifunc::delta#2 = (dword) 3 [phi:ifunc->ifunc::@1#0] -- vduz1=vduc1
|
||||
lda #<3
|
||||
sta.z delta
|
||||
lda #>3
|
||||
sta.z delta+1
|
||||
lda #<3>>$10
|
||||
sta.z delta+2
|
||||
lda #>3>>$10
|
||||
sta.z delta+3
|
||||
// [11] phi (dword) ifunc::x#3 = (dword) 1 [phi:ifunc->ifunc::@1#1] -- vduz1=vduc1
|
||||
lda #<1
|
||||
sta.z x
|
||||
lda #>1
|
||||
sta.z x+1
|
||||
lda #<1>>$10
|
||||
sta.z x+2
|
||||
lda #>1>>$10
|
||||
sta.z x+3
|
||||
// [11] phi (dword) ifunc::xsqr#2 = (dword) 1 [phi:ifunc->ifunc::@1#2] -- vduz1=vduc1
|
||||
lda #<1
|
||||
sta.z xsqr
|
||||
lda #>1
|
||||
sta.z xsqr+1
|
||||
lda #<1>>$10
|
||||
sta.z xsqr+2
|
||||
lda #>1>>$10
|
||||
sta.z xsqr+3
|
||||
jmp __b1
|
||||
// ifunc::@1
|
||||
__b1:
|
||||
// [12] if((dword) ifunc::xsqr#2<(const dword) ifunc::a#0+(byte) 1) goto ifunc::@2 -- vduz1_lt_vduc1_then_la1
|
||||
lda.z xsqr+3
|
||||
cmp #>a+1>>$10
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr+2
|
||||
cmp #<a+1>>$10
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr+1
|
||||
cmp #>a+1
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr
|
||||
cmp #<a+1
|
||||
bcc __b2
|
||||
!:
|
||||
jmp __b3
|
||||
// ifunc::@3
|
||||
__b3:
|
||||
// [13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3
|
||||
.assert "Missing ASM fragment Fragment not found vduz1=_dec_vduz2. Attempted variations vduz1=_dec_vduz2 ", 0, 1
|
||||
jmp __breturn
|
||||
// ifunc::@return
|
||||
__breturn:
|
||||
// [14] return
|
||||
rts
|
||||
// ifunc::@2
|
||||
__b2:
|
||||
// [15] (dword) ifunc::x#1 ← ++ (dword) ifunc::x#3 -- vduz1=_inc_vduz1
|
||||
inc.z x
|
||||
bne !+
|
||||
inc.z x+1
|
||||
bne !+
|
||||
inc.z x+2
|
||||
bne !+
|
||||
inc.z x+3
|
||||
!:
|
||||
// [16] (dword) ifunc::xsqr#1 ← (dword) ifunc::xsqr#2 + (dword) ifunc::delta#2 -- vduz1=vduz1_plus_vduz2
|
||||
lda.z xsqr
|
||||
clc
|
||||
adc.z delta
|
||||
sta.z xsqr
|
||||
lda.z xsqr+1
|
||||
adc.z delta+1
|
||||
sta.z xsqr+1
|
||||
lda.z xsqr+2
|
||||
adc.z delta+2
|
||||
sta.z xsqr+2
|
||||
lda.z xsqr+3
|
||||
adc.z delta+3
|
||||
sta.z xsqr+3
|
||||
// [17] (dword) ifunc::delta#1 ← (dword) ifunc::delta#2 + (byte) 2 -- vduz1=vduz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc.z delta
|
||||
sta.z delta
|
||||
lda.z delta+1
|
||||
adc #0
|
||||
sta.z delta+1
|
||||
lda.z delta+2
|
||||
adc #0
|
||||
sta.z delta+2
|
||||
lda.z delta+3
|
||||
adc #0
|
||||
sta.z delta+3
|
||||
// [11] phi from ifunc::@2 to ifunc::@1 [phi:ifunc::@2->ifunc::@1]
|
||||
__b1_from___b2:
|
||||
// [11] phi (dword) ifunc::delta#2 = (dword) ifunc::delta#1 [phi:ifunc::@2->ifunc::@1#0] -- register_copy
|
||||
// [11] phi (dword) ifunc::x#3 = (dword) ifunc::x#1 [phi:ifunc::@2->ifunc::@1#1] -- register_copy
|
||||
// [11] phi (dword) ifunc::xsqr#2 = (dword) ifunc::xsqr#1 [phi:ifunc::@2->ifunc::@1#2] -- register_copy
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [6] (dword) ifunc::return#2 ← (dword) ifunc::return#0 [ ifunc::return#2 ] ( main:2 [ ifunc::return#2 ] ) always clobbers reg byte a
|
||||
Statement [7] (dword~) main::$0 ← (dword) ifunc::return#2 [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a
|
||||
Statement [8] *((const dword*) SCREEN) ← (dword~) main::$0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [12] if((dword) ifunc::xsqr#2<(const dword) ifunc::a#0+(byte) 1) goto ifunc::@2 [ ifunc::xsqr#2 ifunc::x#3 ifunc::delta#2 ] ( main:2::ifunc:5 [ ifunc::xsqr#2 ifunc::x#3 ifunc::delta#2 ] ) always clobbers reg byte a
|
||||
Potential register analysis [13] ifunc::return#0 ← -- ifunc::x#3 missing fragment Fragment not found vduz1=_dec_vduz2. Attempted variations vduz1=_dec_vduz2 allocation: zp[4]:22 [ ifunc::return#0 ] zp[4]:6 [ ifunc::x#3 ifunc::x#1 ]
|
||||
MISSING FRAGMENTS
|
||||
Fragment not found vduz1=_dec_vduz2. Attempted variations vduz1=_dec_vduz2
|
||||
Statement [13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3 [ ifunc::return#0 ] ( main:2::ifunc:5 [ ifunc::return#0 ] ) always clobbers reg byte a reg byte x reg byte y
|
||||
Statement [16] (dword) ifunc::xsqr#1 ← (dword) ifunc::xsqr#2 + (dword) ifunc::delta#2 [ ifunc::delta#2 ifunc::xsqr#1 ifunc::x#1 ] ( main:2::ifunc:5 [ ifunc::delta#2 ifunc::xsqr#1 ifunc::x#1 ] ) always clobbers reg byte a
|
||||
Statement [17] (dword) ifunc::delta#1 ← (dword) ifunc::delta#2 + (byte) 2 [ ifunc::xsqr#1 ifunc::x#1 ifunc::delta#1 ] ( main:2::ifunc:5 [ ifunc::xsqr#1 ifunc::x#1 ifunc::delta#1 ] ) always clobbers reg byte a
|
||||
Potential registers zp[4]:2 [ ifunc::xsqr#2 ifunc::xsqr#1 ] : zp[4]:2 ,
|
||||
Potential registers zp[4]:6 [ ifunc::x#3 ifunc::x#1 ] : zp[4]:6 ,
|
||||
Potential registers zp[4]:10 [ ifunc::delta#2 ifunc::delta#1 ] : zp[4]:10 ,
|
||||
Potential registers zp[4]:14 [ ifunc::return#2 ] : zp[4]:14 ,
|
||||
Potential registers zp[4]:18 [ main::$0 ] : zp[4]:18 ,
|
||||
Potential registers zp[4]:22 [ ifunc::return#0 ] : zp[4]:22 ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [ifunc] 30.25: zp[4]:10 [ ifunc::delta#2 ifunc::delta#1 ] 22: zp[4]:2 [ ifunc::xsqr#2 ifunc::xsqr#1 ] 19.33: zp[4]:6 [ ifunc::x#3 ifunc::x#1 ] 4: zp[4]:14 [ ifunc::return#2 ] 1.33: zp[4]:22 [ ifunc::return#0 ]
|
||||
Uplift Scope [main] 4: zp[4]:18 [ main::$0 ]
|
||||
Uplift Scope []
|
||||
|
||||
Warning! Unknown fragment for statement [13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3
|
||||
Missing ASM fragment Fragment not found vduz1=_dec_vduz2. Attempted variations vduz1=_dec_vduz2
|
||||
File /Users/jespergravgaard/c64/kickc/src/test/kc/sqr-delta.kc
|
||||
Line 10
|
||||
return --x;
|
||||
Uplifting [ifunc] best 2175 combination zp[4]:10 [ ifunc::delta#2 ifunc::delta#1 ] zp[4]:2 [ ifunc::xsqr#2 ifunc::xsqr#1 ] zp[4]:6 [ ifunc::x#3 ifunc::x#1 ] zp[4]:14 [ ifunc::return#2 ] zp[4]:22 [ ifunc::return#0 ]
|
||||
Warning! Unknown fragment for statement [13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3
|
||||
Missing ASM fragment Fragment not found vduz1=_dec_vduz2. Attempted variations vduz1=_dec_vduz2
|
||||
File /Users/jespergravgaard/c64/kickc/src/test/kc/sqr-delta.kc
|
||||
Line 10
|
||||
return --x;
|
||||
Uplifting [main] best 2175 combination zp[4]:18 [ main::$0 ]
|
||||
Warning! Unknown fragment for statement [13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3
|
||||
Missing ASM fragment Fragment not found vduz1=_dec_vduz2. Attempted variations vduz1=_dec_vduz2
|
||||
File /Users/jespergravgaard/c64/kickc/src/test/kc/sqr-delta.kc
|
||||
Line 10
|
||||
return --x;
|
||||
Uplifting [] best 2175 combination
|
||||
Coalescing zero page register [ zp[4]:6 [ ifunc::x#3 ifunc::x#1 ] ] with [ zp[4]:22 [ ifunc::return#0 ] ] - score: 1
|
||||
Coalescing zero page register [ zp[4]:14 [ ifunc::return#2 ] ] with [ zp[4]:18 [ main::$0 ] ] - score: 1
|
||||
Coalescing zero page register [ zp[4]:6 [ ifunc::x#3 ifunc::x#1 ifunc::return#0 ] ] with [ zp[4]:14 [ ifunc::return#2 main::$0 ] ] - score: 1
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
// File Comments
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(__bbegin)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
.label SCREEN = $400
|
||||
// @begin
|
||||
__bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
__b1_from___bbegin:
|
||||
jmp __b1
|
||||
// @1
|
||||
__b1:
|
||||
// [2] call main
|
||||
// [4] phi from @1 to main [phi:@1->main]
|
||||
main_from___b1:
|
||||
jsr main
|
||||
// [3] phi from @1 to @end [phi:@1->@end]
|
||||
__bend_from___b1:
|
||||
jmp __bend
|
||||
// @end
|
||||
__bend:
|
||||
// main
|
||||
main: {
|
||||
.label __0 = 6
|
||||
// [5] call ifunc
|
||||
// [10] phi from main to ifunc [phi:main->ifunc]
|
||||
ifunc_from_main:
|
||||
jsr ifunc
|
||||
// [6] (dword) ifunc::return#2 ← (dword) ifunc::return#0
|
||||
jmp __b1
|
||||
// main::@1
|
||||
__b1:
|
||||
// [7] (dword~) main::$0 ← (dword) ifunc::return#2
|
||||
// [8] *((const dword*) SCREEN) ← (dword~) main::$0 -- _deref_pduc1=vduz1
|
||||
lda.z __0
|
||||
sta SCREEN
|
||||
lda.z __0+1
|
||||
sta SCREEN+1
|
||||
lda.z __0+2
|
||||
sta SCREEN+2
|
||||
lda.z __0+3
|
||||
sta SCREEN+3
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [9] return
|
||||
rts
|
||||
}
|
||||
// ifunc
|
||||
ifunc: {
|
||||
.const a = 8
|
||||
.label x = 6
|
||||
.label xsqr = 2
|
||||
.label delta = $a
|
||||
.label return = 6
|
||||
// [11] phi from ifunc to ifunc::@1 [phi:ifunc->ifunc::@1]
|
||||
__b1_from_ifunc:
|
||||
// [11] phi (dword) ifunc::delta#2 = (dword) 3 [phi:ifunc->ifunc::@1#0] -- vduz1=vduc1
|
||||
lda #<3
|
||||
sta.z delta
|
||||
lda #>3
|
||||
sta.z delta+1
|
||||
lda #<3>>$10
|
||||
sta.z delta+2
|
||||
lda #>3>>$10
|
||||
sta.z delta+3
|
||||
// [11] phi (dword) ifunc::x#3 = (dword) 1 [phi:ifunc->ifunc::@1#1] -- vduz1=vduc1
|
||||
lda #<1
|
||||
sta.z x
|
||||
lda #>1
|
||||
sta.z x+1
|
||||
lda #<1>>$10
|
||||
sta.z x+2
|
||||
lda #>1>>$10
|
||||
sta.z x+3
|
||||
// [11] phi (dword) ifunc::xsqr#2 = (dword) 1 [phi:ifunc->ifunc::@1#2] -- vduz1=vduc1
|
||||
lda #<1
|
||||
sta.z xsqr
|
||||
lda #>1
|
||||
sta.z xsqr+1
|
||||
lda #<1>>$10
|
||||
sta.z xsqr+2
|
||||
lda #>1>>$10
|
||||
sta.z xsqr+3
|
||||
jmp __b1
|
||||
// ifunc::@1
|
||||
__b1:
|
||||
// [12] if((dword) ifunc::xsqr#2<(const dword) ifunc::a#0+(byte) 1) goto ifunc::@2 -- vduz1_lt_vduc1_then_la1
|
||||
lda.z xsqr+3
|
||||
cmp #>a+1>>$10
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr+2
|
||||
cmp #<a+1>>$10
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr+1
|
||||
cmp #>a+1
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr
|
||||
cmp #<a+1
|
||||
bcc __b2
|
||||
!:
|
||||
jmp __b3
|
||||
// ifunc::@3
|
||||
__b3:
|
||||
// [13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3 -- vduz1=_dec_vduz1
|
||||
lda.z return
|
||||
sec
|
||||
sbc #1
|
||||
sta.z return
|
||||
lda.z return+1
|
||||
sbc #0
|
||||
sta.z return+1
|
||||
lda.z return+2
|
||||
sbc #0
|
||||
sta.z return+2
|
||||
lda.z return+3
|
||||
sbc #0
|
||||
sta.z return+3
|
||||
jmp __breturn
|
||||
// ifunc::@return
|
||||
__breturn:
|
||||
// [14] return
|
||||
rts
|
||||
// ifunc::@2
|
||||
__b2:
|
||||
// [15] (dword) ifunc::x#1 ← ++ (dword) ifunc::x#3 -- vduz1=_inc_vduz1
|
||||
inc.z x
|
||||
bne !+
|
||||
inc.z x+1
|
||||
bne !+
|
||||
inc.z x+2
|
||||
bne !+
|
||||
inc.z x+3
|
||||
!:
|
||||
// [16] (dword) ifunc::xsqr#1 ← (dword) ifunc::xsqr#2 + (dword) ifunc::delta#2 -- vduz1=vduz1_plus_vduz2
|
||||
lda.z xsqr
|
||||
clc
|
||||
adc.z delta
|
||||
sta.z xsqr
|
||||
lda.z xsqr+1
|
||||
adc.z delta+1
|
||||
sta.z xsqr+1
|
||||
lda.z xsqr+2
|
||||
adc.z delta+2
|
||||
sta.z xsqr+2
|
||||
lda.z xsqr+3
|
||||
adc.z delta+3
|
||||
sta.z xsqr+3
|
||||
// [17] (dword) ifunc::delta#1 ← (dword) ifunc::delta#2 + (byte) 2 -- vduz1=vduz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc.z delta
|
||||
sta.z delta
|
||||
lda.z delta+1
|
||||
adc #0
|
||||
sta.z delta+1
|
||||
lda.z delta+2
|
||||
adc #0
|
||||
sta.z delta+2
|
||||
lda.z delta+3
|
||||
adc #0
|
||||
sta.z delta+3
|
||||
// [11] phi from ifunc::@2 to ifunc::@1 [phi:ifunc::@2->ifunc::@1]
|
||||
__b1_from___b2:
|
||||
// [11] phi (dword) ifunc::delta#2 = (dword) ifunc::delta#1 [phi:ifunc::@2->ifunc::@1#0] -- register_copy
|
||||
// [11] phi (dword) ifunc::x#3 = (dword) ifunc::x#1 [phi:ifunc::@2->ifunc::@1#1] -- register_copy
|
||||
// [11] phi (dword) ifunc::xsqr#2 = (dword) ifunc::xsqr#1 [phi:ifunc::@2->ifunc::@1#2] -- register_copy
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __bend
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __breturn
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __b3
|
||||
Removing instruction jmp __breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing label __bbegin with __b1
|
||||
Removing instruction __bbegin:
|
||||
Removing instruction __b1_from___bbegin:
|
||||
Removing instruction main_from___b1:
|
||||
Removing instruction __bend_from___b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction __bend:
|
||||
Removing instruction ifunc_from_main:
|
||||
Removing instruction __b1:
|
||||
Removing instruction __breturn:
|
||||
Removing instruction __b1_from_ifunc:
|
||||
Removing instruction __b3:
|
||||
Removing instruction __breturn:
|
||||
Removing instruction __b1_from___b2:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
Updating BasicUpstart to call main directly
|
||||
Removing instruction jsr main
|
||||
Succesful ASM optimization Pass5SkipBegin
|
||||
Removing instruction __b1:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const dword*) SCREEN = (dword*) 1024
|
||||
(dword()) ifunc((dword) ifunc::a)
|
||||
(label) ifunc::@1
|
||||
(label) ifunc::@2
|
||||
(label) ifunc::@3
|
||||
(label) ifunc::@return
|
||||
(dword) ifunc::a
|
||||
(const dword) ifunc::a#0 a = (byte) 8
|
||||
(dword) ifunc::delta
|
||||
(dword) ifunc::delta#1 delta zp[4]:10 22.0
|
||||
(dword) ifunc::delta#2 delta zp[4]:10 8.25
|
||||
(dword) ifunc::return
|
||||
(dword) ifunc::return#0 return zp[4]:6 1.3333333333333333
|
||||
(dword) ifunc::return#2 return zp[4]:6 4.0
|
||||
(dword) ifunc::x
|
||||
(dword) ifunc::x#1 x zp[4]:6 7.333333333333333
|
||||
(dword) ifunc::x#3 x zp[4]:6 12.0
|
||||
(dword) ifunc::xsqr
|
||||
(dword) ifunc::xsqr#1 xsqr zp[4]:2 11.0
|
||||
(dword) ifunc::xsqr#2 xsqr zp[4]:2 11.0
|
||||
(void()) main()
|
||||
(dword~) main::$0 zp[4]:6 4.0
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
|
||||
zp[4]:2 [ ifunc::xsqr#2 ifunc::xsqr#1 ]
|
||||
zp[4]:6 [ ifunc::x#3 ifunc::x#1 ifunc::return#0 ifunc::return#2 main::$0 ]
|
||||
zp[4]:10 [ ifunc::delta#2 ifunc::delta#1 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 2080
|
||||
|
||||
// File Comments
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
.label SCREEN = $400
|
||||
// @begin
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
// @1
|
||||
// [2] call main
|
||||
// [4] phi from @1 to main [phi:@1->main]
|
||||
// [3] phi from @1 to @end [phi:@1->@end]
|
||||
// @end
|
||||
// main
|
||||
main: {
|
||||
.label __0 = 6
|
||||
// ifunc(8)
|
||||
// [5] call ifunc
|
||||
// [10] phi from main to ifunc [phi:main->ifunc]
|
||||
jsr ifunc
|
||||
// ifunc(8)
|
||||
// [6] (dword) ifunc::return#2 ← (dword) ifunc::return#0
|
||||
// main::@1
|
||||
// [7] (dword~) main::$0 ← (dword) ifunc::return#2
|
||||
// SCREEN[0] = ifunc(8)
|
||||
// [8] *((const dword*) SCREEN) ← (dword~) main::$0 -- _deref_pduc1=vduz1
|
||||
lda.z __0
|
||||
sta SCREEN
|
||||
lda.z __0+1
|
||||
sta SCREEN+1
|
||||
lda.z __0+2
|
||||
sta SCREEN+2
|
||||
lda.z __0+3
|
||||
sta SCREEN+3
|
||||
// main::@return
|
||||
// }
|
||||
// [9] return
|
||||
rts
|
||||
}
|
||||
// ifunc
|
||||
ifunc: {
|
||||
.const a = 8
|
||||
.label x = 6
|
||||
.label xsqr = 2
|
||||
.label delta = $a
|
||||
.label return = 6
|
||||
// [11] phi from ifunc to ifunc::@1 [phi:ifunc->ifunc::@1]
|
||||
// [11] phi (dword) ifunc::delta#2 = (dword) 3 [phi:ifunc->ifunc::@1#0] -- vduz1=vduc1
|
||||
lda #<3
|
||||
sta.z delta
|
||||
lda #>3
|
||||
sta.z delta+1
|
||||
lda #<3>>$10
|
||||
sta.z delta+2
|
||||
lda #>3>>$10
|
||||
sta.z delta+3
|
||||
// [11] phi (dword) ifunc::x#3 = (dword) 1 [phi:ifunc->ifunc::@1#1] -- vduz1=vduc1
|
||||
lda #<1
|
||||
sta.z x
|
||||
lda #>1
|
||||
sta.z x+1
|
||||
lda #<1>>$10
|
||||
sta.z x+2
|
||||
lda #>1>>$10
|
||||
sta.z x+3
|
||||
// [11] phi (dword) ifunc::xsqr#2 = (dword) 1 [phi:ifunc->ifunc::@1#2] -- vduz1=vduc1
|
||||
lda #<1
|
||||
sta.z xsqr
|
||||
lda #>1
|
||||
sta.z xsqr+1
|
||||
lda #<1>>$10
|
||||
sta.z xsqr+2
|
||||
lda #>1>>$10
|
||||
sta.z xsqr+3
|
||||
// ifunc::@1
|
||||
__b1:
|
||||
// while(xsqr <=a)
|
||||
// [12] if((dword) ifunc::xsqr#2<(const dword) ifunc::a#0+(byte) 1) goto ifunc::@2 -- vduz1_lt_vduc1_then_la1
|
||||
lda.z xsqr+3
|
||||
cmp #>a+1>>$10
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr+2
|
||||
cmp #<a+1>>$10
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr+1
|
||||
cmp #>a+1
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z xsqr
|
||||
cmp #<a+1
|
||||
bcc __b2
|
||||
!:
|
||||
// ifunc::@3
|
||||
// return --x;
|
||||
// [13] (dword) ifunc::return#0 ← -- (dword) ifunc::x#3 -- vduz1=_dec_vduz1
|
||||
lda.z return
|
||||
sec
|
||||
sbc #1
|
||||
sta.z return
|
||||
lda.z return+1
|
||||
sbc #0
|
||||
sta.z return+1
|
||||
lda.z return+2
|
||||
sbc #0
|
||||
sta.z return+2
|
||||
lda.z return+3
|
||||
sbc #0
|
||||
sta.z return+3
|
||||
// ifunc::@return
|
||||
// }
|
||||
// [14] return
|
||||
rts
|
||||
// ifunc::@2
|
||||
__b2:
|
||||
// ++x;
|
||||
// [15] (dword) ifunc::x#1 ← ++ (dword) ifunc::x#3 -- vduz1=_inc_vduz1
|
||||
inc.z x
|
||||
bne !+
|
||||
inc.z x+1
|
||||
bne !+
|
||||
inc.z x+2
|
||||
bne !+
|
||||
inc.z x+3
|
||||
!:
|
||||
// xsqr += delta
|
||||
// [16] (dword) ifunc::xsqr#1 ← (dword) ifunc::xsqr#2 + (dword) ifunc::delta#2 -- vduz1=vduz1_plus_vduz2
|
||||
lda.z xsqr
|
||||
clc
|
||||
adc.z delta
|
||||
sta.z xsqr
|
||||
lda.z xsqr+1
|
||||
adc.z delta+1
|
||||
sta.z xsqr+1
|
||||
lda.z xsqr+2
|
||||
adc.z delta+2
|
||||
sta.z xsqr+2
|
||||
lda.z xsqr+3
|
||||
adc.z delta+3
|
||||
sta.z xsqr+3
|
||||
// delta += 2
|
||||
// [17] (dword) ifunc::delta#1 ← (dword) ifunc::delta#2 + (byte) 2 -- vduz1=vduz1_plus_vbuc1
|
||||
lda #2
|
||||
clc
|
||||
adc.z delta
|
||||
sta.z delta
|
||||
lda.z delta+1
|
||||
adc #0
|
||||
sta.z delta+1
|
||||
lda.z delta+2
|
||||
adc #0
|
||||
sta.z delta+2
|
||||
lda.z delta+3
|
||||
adc #0
|
||||
sta.z delta+3
|
||||
// [11] phi from ifunc::@2 to ifunc::@1 [phi:ifunc::@2->ifunc::@1]
|
||||
// [11] phi (dword) ifunc::delta#2 = (dword) ifunc::delta#1 [phi:ifunc::@2->ifunc::@1#0] -- register_copy
|
||||
// [11] phi (dword) ifunc::x#3 = (dword) ifunc::x#1 [phi:ifunc::@2->ifunc::@1#1] -- register_copy
|
||||
// [11] phi (dword) ifunc::xsqr#2 = (dword) ifunc::xsqr#1 [phi:ifunc::@2->ifunc::@1#2] -- register_copy
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
|
31
src/test/ref/sqr-delta.sym
Normal file
31
src/test/ref/sqr-delta.sym
Normal file
@ -0,0 +1,31 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const dword*) SCREEN = (dword*) 1024
|
||||
(dword()) ifunc((dword) ifunc::a)
|
||||
(label) ifunc::@1
|
||||
(label) ifunc::@2
|
||||
(label) ifunc::@3
|
||||
(label) ifunc::@return
|
||||
(dword) ifunc::a
|
||||
(const dword) ifunc::a#0 a = (byte) 8
|
||||
(dword) ifunc::delta
|
||||
(dword) ifunc::delta#1 delta zp[4]:10 22.0
|
||||
(dword) ifunc::delta#2 delta zp[4]:10 8.25
|
||||
(dword) ifunc::return
|
||||
(dword) ifunc::return#0 return zp[4]:6 1.3333333333333333
|
||||
(dword) ifunc::return#2 return zp[4]:6 4.0
|
||||
(dword) ifunc::x
|
||||
(dword) ifunc::x#1 x zp[4]:6 7.333333333333333
|
||||
(dword) ifunc::x#3 x zp[4]:6 12.0
|
||||
(dword) ifunc::xsqr
|
||||
(dword) ifunc::xsqr#1 xsqr zp[4]:2 11.0
|
||||
(dword) ifunc::xsqr#2 xsqr zp[4]:2 11.0
|
||||
(void()) main()
|
||||
(dword~) main::$0 zp[4]:6 4.0
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
|
||||
zp[4]:2 [ ifunc::xsqr#2 ifunc::xsqr#1 ]
|
||||
zp[4]:6 [ ifunc::x#3 ifunc::x#1 ifunc::return#0 ifunc::return#2 main::$0 ]
|
||||
zp[4]:10 [ ifunc::delta#2 ifunc::delta#1 ]
|
Loading…
Reference in New Issue
Block a user