mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-02-28 08:29:42 +00:00
Improved liverange testing
This commit is contained in:
parent
e385257cf4
commit
a44d8d5388
130
src/test/ref/liverange-10.asm
Normal file
130
src/test/ref/liverange-10.asm
Normal file
@ -0,0 +1,130 @@
|
||||
// Test effective live range and register allocation
|
||||
// Here outsw::sw and outw::w should have the same allocation
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.label SCREEN = $400
|
||||
main: {
|
||||
.label sw = 2
|
||||
.label w = 4
|
||||
ldx #0
|
||||
lda #<-$14
|
||||
sta.z sw
|
||||
lda #>-$14
|
||||
sta.z sw+1
|
||||
__b1:
|
||||
// outsw(sw)
|
||||
lda.z sw
|
||||
sta.z outsw.sw
|
||||
lda.z sw+1
|
||||
sta.z outsw.sw+1
|
||||
jsr outsw
|
||||
// for(signed int sw: -20..19 )
|
||||
inc.z sw
|
||||
bne !+
|
||||
inc.z sw+1
|
||||
!:
|
||||
lda.z sw+1
|
||||
cmp #>$14
|
||||
bne __b1
|
||||
lda.z sw
|
||||
cmp #<$14
|
||||
bne __b1
|
||||
lda #<0
|
||||
sta.z w
|
||||
sta.z w+1
|
||||
__b2:
|
||||
// outw(w)
|
||||
jsr outw
|
||||
// for(unsigned int w: 0..39 )
|
||||
inc.z w
|
||||
bne !+
|
||||
inc.z w+1
|
||||
!:
|
||||
lda.z w+1
|
||||
cmp #>$28
|
||||
bne __b2
|
||||
lda.z w
|
||||
cmp #<$28
|
||||
bne __b2
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// outw(word zp(4) w)
|
||||
outw: {
|
||||
.label w = 4
|
||||
// >w
|
||||
lda.z w+1
|
||||
// (>w)<<4
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
// out(HEXTAB[(>w)<<4])
|
||||
tay
|
||||
lda HEXTAB,y
|
||||
jsr out
|
||||
// >w
|
||||
lda.z w+1
|
||||
// (>w)&0x0f
|
||||
and #$f
|
||||
// out(HEXTAB[(>w)&0x0f])
|
||||
tay
|
||||
lda HEXTAB,y
|
||||
jsr out
|
||||
// <w
|
||||
lda.z w
|
||||
// (<w)<<4
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
// out(HEXTAB[(<w)<<4])
|
||||
tay
|
||||
lda HEXTAB,y
|
||||
jsr out
|
||||
// <w
|
||||
lda.z w
|
||||
// (<w)&0x0f
|
||||
and #$f
|
||||
// out(HEXTAB[(<w)&0x0f])
|
||||
tay
|
||||
lda HEXTAB,y
|
||||
jsr out
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// out(byte register(A) c)
|
||||
out: {
|
||||
// idx++;
|
||||
inx
|
||||
// SCREEN[idx] = c
|
||||
sta SCREEN,x
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// outsw(signed word zp(4) sw)
|
||||
outsw: {
|
||||
.label sw = 4
|
||||
// if(sw<0)
|
||||
lda.z sw+1
|
||||
bpl __b1
|
||||
// out('-')
|
||||
lda #'-'
|
||||
jsr out
|
||||
// sw = -sw
|
||||
sec
|
||||
lda #0
|
||||
sbc.z sw
|
||||
sta.z sw
|
||||
lda #0
|
||||
sbc.z sw+1
|
||||
sta.z sw+1
|
||||
__b1:
|
||||
// outw((unsigned int)sw)
|
||||
jsr outw
|
||||
// }
|
||||
rts
|
||||
}
|
||||
HEXTAB: .text "0123456789abcdef"
|
||||
.byte 0
|
99
src/test/ref/liverange-10.cfg
Normal file
99
src/test/ref/liverange-10.cfg
Normal file
@ -0,0 +1,99 @@
|
||||
@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()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@3
|
||||
[5] (byte) idx#29 ← phi( main/(byte) 0 main::@3/(byte) idx#12 )
|
||||
[5] (signed word) main::sw#2 ← phi( main/(signed word) -$14 main::@3/(signed word) main::sw#1 )
|
||||
[6] (signed word) outsw::sw#0 ← (signed word) main::sw#2
|
||||
[7] call outsw
|
||||
to:main::@3
|
||||
main::@3: scope:[main] from main::@1
|
||||
[8] (signed word) main::sw#1 ← ++ (signed word) main::sw#2
|
||||
[9] if((signed word) main::sw#1!=(signed byte) $14) goto main::@1
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@3 main::@4
|
||||
[10] (word) main::w#2 ← phi( main::@3/(word) 0 main::@4/(word) main::w#1 )
|
||||
[11] (word) outw::w#0 ← (word) main::w#2
|
||||
[12] call outw
|
||||
to:main::@4
|
||||
main::@4: scope:[main] from main::@2
|
||||
[13] (word) main::w#1 ← ++ (word) main::w#2
|
||||
[14] if((word) main::w#1!=(byte) $28) goto main::@2
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@4
|
||||
[15] return
|
||||
to:@return
|
||||
|
||||
(void()) outw((word) outw::w)
|
||||
outw: scope:[outw] from main::@2 outsw::@1
|
||||
[16] (byte) idx#33 ← phi( main::@2/(byte) idx#12 outsw::@1/(byte) idx#31 )
|
||||
[16] (word) outw::w#2 ← phi( main::@2/(word) outw::w#0 outsw::@1/(word) outw::w#1 )
|
||||
[17] (byte~) outw::$0 ← > (word) outw::w#2
|
||||
[18] (byte~) outw::$1 ← (byte~) outw::$0 << (byte) 4
|
||||
[19] (byte) out::c#1 ← *((const byte*) HEXTAB + (byte~) outw::$1)
|
||||
[20] call out
|
||||
to:outw::@1
|
||||
outw::@1: scope:[outw] from outw
|
||||
[21] (byte~) outw::$3 ← > (word) outw::w#2
|
||||
[22] (byte~) outw::$4 ← (byte~) outw::$3 & (byte) $f
|
||||
[23] (byte) out::c#2 ← *((const byte*) HEXTAB + (byte~) outw::$4)
|
||||
[24] call out
|
||||
to:outw::@2
|
||||
outw::@2: scope:[outw] from outw::@1
|
||||
[25] (byte~) outw::$6 ← < (word) outw::w#2
|
||||
[26] (byte~) outw::$7 ← (byte~) outw::$6 << (byte) 4
|
||||
[27] (byte) out::c#3 ← *((const byte*) HEXTAB + (byte~) outw::$7)
|
||||
[28] call out
|
||||
to:outw::@3
|
||||
outw::@3: scope:[outw] from outw::@2
|
||||
[29] (byte~) outw::$9 ← < (word) outw::w#2
|
||||
[30] (byte~) outw::$10 ← (byte~) outw::$9 & (byte) $f
|
||||
[31] (byte) out::c#4 ← *((const byte*) HEXTAB + (byte~) outw::$10)
|
||||
[32] call out
|
||||
to:outw::@return
|
||||
outw::@return: scope:[outw] from outw::@3
|
||||
[33] return
|
||||
to:@return
|
||||
|
||||
(void()) out((byte) out::c)
|
||||
out: scope:[out] from outsw::@2 outw outw::@1 outw::@2 outw::@3
|
||||
[34] (byte) out::c#5 ← phi( outsw::@2/(byte) '-' outw/(byte) out::c#1 outw::@1/(byte) out::c#2 outw::@2/(byte) out::c#3 outw::@3/(byte) out::c#4 )
|
||||
[34] (byte) idx#26 ← phi( outsw::@2/(byte) idx#29 outw/(byte) idx#33 outw::@1/(byte) idx#12 outw::@2/(byte) idx#12 outw::@3/(byte) idx#12 )
|
||||
[35] (byte) idx#12 ← ++ (byte) idx#26
|
||||
[36] *((const byte*) SCREEN + (byte) idx#12) ← (byte) out::c#5
|
||||
to:out::@return
|
||||
out::@return: scope:[out] from out
|
||||
[37] return
|
||||
to:@return
|
||||
|
||||
(void()) outsw((signed word) outsw::sw)
|
||||
outsw: scope:[outsw] from main::@1
|
||||
[38] if((signed word) outsw::sw#0>=(signed byte) 0) goto outsw::@1
|
||||
to:outsw::@2
|
||||
outsw::@2: scope:[outsw] from outsw
|
||||
[39] phi()
|
||||
[40] call out
|
||||
to:outsw::@3
|
||||
outsw::@3: scope:[outsw] from outsw::@2
|
||||
[41] (signed word) outsw::sw#1 ← - (signed word) outsw::sw#0
|
||||
to:outsw::@1
|
||||
outsw::@1: scope:[outsw] from outsw outsw::@3
|
||||
[42] (byte) idx#31 ← phi( outsw/(byte) idx#29 outsw::@3/(byte) idx#12 )
|
||||
[42] (signed word) outsw::sw#3 ← phi( outsw/(signed word) outsw::sw#0 outsw::@3/(signed word) outsw::sw#1 )
|
||||
[43] (word) outw::w#1 ← (word)(signed word) outsw::sw#3
|
||||
[44] call outw
|
||||
to:outsw::@return
|
||||
outsw::@return: scope:[outsw] from outsw::@1
|
||||
[45] return
|
||||
to:@return
|
1590
src/test/ref/liverange-10.log
Normal file
1590
src/test/ref/liverange-10.log
Normal file
File diff suppressed because it is too large
Load Diff
70
src/test/ref/liverange-10.sym
Normal file
70
src/test/ref/liverange-10.sym
Normal file
@ -0,0 +1,70 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte*) HEXTAB[] = (byte*) "0123456789abcdef"
|
||||
(const byte*) SCREEN = (byte*) 1024
|
||||
(byte) idx
|
||||
(byte) idx#12 reg byte x 7972.689655172414
|
||||
(byte) idx#26 reg byte x 141006.0
|
||||
(byte) idx#29 reg byte x 525.75
|
||||
(byte) idx#31 reg byte x 1501.5
|
||||
(byte) idx#33 reg byte x 2775.75
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@4
|
||||
(label) main::@return
|
||||
(signed word) main::sw
|
||||
(signed word) main::sw#1 sw zp[2]:2 151.5
|
||||
(signed word) main::sw#2 sw zp[2]:2 101.0
|
||||
(word) main::w
|
||||
(word) main::w#1 w zp[2]:4 151.5
|
||||
(word) main::w#2 w zp[2]:4 101.0
|
||||
(void()) out((byte) out::c)
|
||||
(label) out::@return
|
||||
(byte) out::c
|
||||
(byte) out::c#1 reg byte a 20002.0
|
||||
(byte) out::c#2 reg byte a 20002.0
|
||||
(byte) out::c#3 reg byte a 20002.0
|
||||
(byte) out::c#4 reg byte a 20002.0
|
||||
(byte) out::c#5 reg byte a 70002.5
|
||||
(void()) outsw((signed word) outsw::sw)
|
||||
(label) outsw::@1
|
||||
(label) outsw::@2
|
||||
(label) outsw::@3
|
||||
(label) outsw::@return
|
||||
(signed word) outsw::sw
|
||||
(signed word) outsw::sw#0 sw zp[2]:4 776.0
|
||||
(signed word) outsw::sw#1 sw zp[2]:4 2002.0
|
||||
(signed word) outsw::sw#3 sw zp[2]:4 2002.0
|
||||
(void()) outw((word) outw::w)
|
||||
(byte~) outw::$0 reg byte a 20002.0
|
||||
(byte~) outw::$1 reg byte a 20002.0
|
||||
(byte~) outw::$10 reg byte a 20002.0
|
||||
(byte~) outw::$3 reg byte a 20002.0
|
||||
(byte~) outw::$4 reg byte a 20002.0
|
||||
(byte~) outw::$6 reg byte a 20002.0
|
||||
(byte~) outw::$7 reg byte a 20002.0
|
||||
(byte~) outw::$9 reg byte a 20002.0
|
||||
(label) outw::@1
|
||||
(label) outw::@2
|
||||
(label) outw::@3
|
||||
(label) outw::@return
|
||||
(word) outw::w
|
||||
(word) outw::w#0 w zp[2]:4 202.0
|
||||
(word) outw::w#1 w zp[2]:4 2002.0
|
||||
(word) outw::w#2 w zp[2]:4 3162.0
|
||||
|
||||
zp[2]:2 [ main::sw#2 main::sw#1 ]
|
||||
zp[2]:4 [ main::w#2 main::w#1 outw::w#2 outw::w#0 outw::w#1 outsw::sw#3 outsw::sw#0 outsw::sw#1 ]
|
||||
reg byte x [ idx#26 idx#33 idx#29 idx#12 idx#31 ]
|
||||
reg byte a [ out::c#5 out::c#1 out::c#2 out::c#3 out::c#4 ]
|
||||
reg byte a [ outw::$0 ]
|
||||
reg byte a [ outw::$1 ]
|
||||
reg byte a [ outw::$3 ]
|
||||
reg byte a [ outw::$4 ]
|
||||
reg byte a [ outw::$6 ]
|
||||
reg byte a [ outw::$7 ]
|
||||
reg byte a [ outw::$9 ]
|
||||
reg byte a [ outw::$10 ]
|
Loading…
x
Reference in New Issue
Block a user