mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-24 20:32:39 +00:00
Added a test with two levels of methods to test live ranges / call-paths and allocation of a minimal number of registers.
This commit is contained in:
parent
514797897e
commit
b0e6ae0b67
@ -24,6 +24,10 @@ public class TestPrograms extends TestCase {
|
|||||||
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
|
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testOverlapAllocation2() throws IOException, URISyntaxException {
|
||||||
|
compileAndCompare("overlap-allocation-2");
|
||||||
|
}
|
||||||
|
|
||||||
public void testOverlapAllocation() throws IOException, URISyntaxException {
|
public void testOverlapAllocation() throws IOException, URISyntaxException {
|
||||||
compileAndCompare("overlap-allocation");
|
compileAndCompare("overlap-allocation");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
// Two levels of functions to test that register allocation handles live ranges and call-ranges optimally to allocate the fewest possible ZP-variables
|
||||||
|
byte* SCREEN = $0400;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
for(byte i : 0..8) {
|
||||||
|
line(i);
|
||||||
|
}
|
||||||
|
for(byte j : 10..18) {
|
||||||
|
line(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void line(byte l) {
|
||||||
|
plot(l);
|
||||||
|
plot(l+20);
|
||||||
|
}
|
||||||
|
|
||||||
|
void plot(byte x) {
|
||||||
|
SCREEN[x] = '*';
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
.pc = $801 "Basic"
|
||||||
|
:BasicUpstart(main)
|
||||||
|
.pc = $80d "Program"
|
||||||
|
.const SCREEN = $400
|
||||||
|
jsr main
|
||||||
|
main: {
|
||||||
|
ldy #0
|
||||||
|
b1:
|
||||||
|
jsr line
|
||||||
|
iny
|
||||||
|
cpy #9
|
||||||
|
bne b1
|
||||||
|
ldy #$a
|
||||||
|
b2:
|
||||||
|
jsr line
|
||||||
|
iny
|
||||||
|
cpy #$13
|
||||||
|
bne b2
|
||||||
|
rts
|
||||||
|
}
|
||||||
|
line: {
|
||||||
|
tya
|
||||||
|
jsr plot
|
||||||
|
tya
|
||||||
|
clc
|
||||||
|
adc #$14
|
||||||
|
jsr plot
|
||||||
|
rts
|
||||||
|
}
|
||||||
|
plot: {
|
||||||
|
tax
|
||||||
|
lda #'*'
|
||||||
|
sta SCREEN,x
|
||||||
|
rts
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
@begin: scope:[] from
|
||||||
|
to:@3
|
||||||
|
@3: scope:[] from @begin
|
||||||
|
[0] call main param-assignment [ ] ( )
|
||||||
|
to:@end
|
||||||
|
@end: scope:[] from @3
|
||||||
|
main: scope:[main] from @3
|
||||||
|
[1] phi() [ ] ( main:0 [ ] )
|
||||||
|
to:main::@1
|
||||||
|
main::@1: scope:[main] from main main::@5
|
||||||
|
[2] (byte) main::i#2 ← phi( main/(byte) 0 main::@5/(byte) main::i#1 ) [ main::i#2 ] ( main:0 [ main::i#2 ] )
|
||||||
|
[3] (byte) line::l#0 ← (byte) main::i#2 [ main::i#2 line::l#0 ] ( main:0 [ main::i#2 line::l#0 ] )
|
||||||
|
[4] call line param-assignment [ main::i#2 ] ( main:0 [ main::i#2 ] )
|
||||||
|
to:main::@5
|
||||||
|
main::@5: scope:[main] from main::@1
|
||||||
|
[5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:0 [ main::i#1 ] )
|
||||||
|
[6] if((byte) main::i#1!=(byte) 9) goto main::@1 [ main::i#1 ] ( main:0 [ main::i#1 ] )
|
||||||
|
to:main::@2
|
||||||
|
main::@2: scope:[main] from main::@5 main::@6
|
||||||
|
[7] (byte) main::j#2 ← phi( main::@5/(byte) 10 main::@6/(byte) main::j#1 ) [ main::j#2 ] ( main:0 [ main::j#2 ] )
|
||||||
|
[8] (byte) line::l#1 ← (byte) main::j#2 [ main::j#2 line::l#1 ] ( main:0 [ main::j#2 line::l#1 ] )
|
||||||
|
[9] call line param-assignment [ main::j#2 ] ( main:0 [ main::j#2 ] )
|
||||||
|
to:main::@6
|
||||||
|
main::@6: scope:[main] from main::@2
|
||||||
|
[10] (byte) main::j#1 ← ++ (byte) main::j#2 [ main::j#1 ] ( main:0 [ main::j#1 ] )
|
||||||
|
[11] if((byte) main::j#1!=(byte) 19) goto main::@2 [ main::j#1 ] ( main:0 [ main::j#1 ] )
|
||||||
|
to:main::@return
|
||||||
|
main::@return: scope:[main] from main::@6
|
||||||
|
[12] return [ ] ( main:0 [ ] )
|
||||||
|
to:@return
|
||||||
|
line: scope:[line] from main::@1 main::@2
|
||||||
|
[13] (byte) line::l#2 ← phi( main::@1/(byte) line::l#0 main::@2/(byte) line::l#1 ) [ line::l#2 ] ( main:0::line:4 [ main::i#2 line::l#2 ] main:0::line:9 [ main::j#2 line::l#2 ] )
|
||||||
|
[14] (byte) plot::x#0 ← (byte) line::l#2 [ line::l#2 plot::x#0 ] ( main:0::line:4 [ main::i#2 line::l#2 plot::x#0 ] main:0::line:9 [ main::j#2 line::l#2 plot::x#0 ] )
|
||||||
|
[15] call plot param-assignment [ line::l#2 ] ( main:0::line:4 [ main::i#2 line::l#2 ] main:0::line:9 [ main::j#2 line::l#2 ] )
|
||||||
|
to:line::@1
|
||||||
|
line::@1: scope:[line] from line
|
||||||
|
[16] (byte~) line::$1 ← (byte) line::l#2 + (byte) 20 [ line::$1 ] ( main:0::line:4 [ main::i#2 line::$1 ] main:0::line:9 [ main::j#2 line::$1 ] )
|
||||||
|
[17] (byte) plot::x#1 ← (byte~) line::$1 [ plot::x#1 ] ( main:0::line:4 [ main::i#2 plot::x#1 ] main:0::line:9 [ main::j#2 plot::x#1 ] )
|
||||||
|
[18] call plot param-assignment [ ] ( main:0::line:4 [ main::i#2 ] main:0::line:9 [ main::j#2 ] )
|
||||||
|
to:line::@return
|
||||||
|
line::@return: scope:[line] from line::@1
|
||||||
|
[19] return [ ] ( main:0::line:4 [ main::i#2 ] main:0::line:9 [ main::j#2 ] )
|
||||||
|
to:@return
|
||||||
|
plot: scope:[plot] from line line::@1
|
||||||
|
[20] (byte) plot::x#2 ← phi( line/(byte) plot::x#0 line::@1/(byte) plot::x#1 ) [ plot::x#2 ] ( main:0::line:4::plot:15 [ main::i#2 line::l#2 plot::x#2 ] main:0::line:9::plot:15 [ main::j#2 line::l#2 plot::x#2 ] main:0::line:4::plot:18 [ main::i#2 plot::x#2 ] main:0::line:9::plot:18 [ main::j#2 plot::x#2 ] )
|
||||||
|
[21] *((const byte*) SCREEN#0 + (byte) plot::x#2) ← (byte) '*' [ ] ( main:0::line:4::plot:15 [ main::i#2 line::l#2 ] main:0::line:9::plot:15 [ main::j#2 line::l#2 ] main:0::line:4::plot:18 [ main::i#2 ] main:0::line:9::plot:18 [ main::j#2 ] )
|
||||||
|
to:plot::@return
|
||||||
|
plot::@return: scope:[plot] from plot
|
||||||
|
[22] return [ ] ( main:0::line:4::plot:15 [ main::i#2 line::l#2 ] main:0::line:9::plot:15 [ main::j#2 line::l#2 ] main:0::line:4::plot:18 [ main::i#2 ] main:0::line:9::plot:18 [ main::j#2 ] )
|
||||||
|
to:@return
|
2172
src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation-2.log
Normal file
2172
src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation-2.log
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
|||||||
|
(label) @3
|
||||||
|
(label) @begin
|
||||||
|
(label) @end
|
||||||
|
(byte*) SCREEN
|
||||||
|
(const byte*) SCREEN#0 SCREEN = (word) 1024
|
||||||
|
(void()) line((byte) line::l)
|
||||||
|
(byte~) line::$1 reg byte a 4.0
|
||||||
|
(label) line::@1
|
||||||
|
(label) line::@return
|
||||||
|
(byte) line::l
|
||||||
|
(byte) line::l#0 reg byte y 22.0
|
||||||
|
(byte) line::l#1 reg byte y 22.0
|
||||||
|
(byte) line::l#2 reg byte y 8.666666666666666
|
||||||
|
(void()) main()
|
||||||
|
(label) main::@1
|
||||||
|
(label) main::@2
|
||||||
|
(label) main::@5
|
||||||
|
(label) main::@6
|
||||||
|
(label) main::@return
|
||||||
|
(byte) main::i
|
||||||
|
(byte) main::i#1 reg byte y 16.5
|
||||||
|
(byte) main::i#2 reg byte y 11.0
|
||||||
|
(byte) main::j
|
||||||
|
(byte) main::j#1 reg byte y 16.5
|
||||||
|
(byte) main::j#2 reg byte y 11.0
|
||||||
|
(void()) plot((byte) plot::x)
|
||||||
|
(label) plot::@return
|
||||||
|
(byte) plot::x
|
||||||
|
(byte) plot::x#0 reg byte a 4.0
|
||||||
|
(byte) plot::x#1 reg byte a 4.0
|
||||||
|
(byte) plot::x#2 reg byte a 6.0
|
||||||
|
|
||||||
|
reg byte y [ main::i#2 main::i#1 ]
|
||||||
|
reg byte y [ main::j#2 main::j#1 ]
|
||||||
|
reg byte y [ line::l#2 line::l#0 line::l#1 ]
|
||||||
|
reg byte a [ plot::x#2 plot::x#0 plot::x#1 ]
|
||||||
|
reg byte a [ line::$1 ]
|
Loading…
Reference in New Issue
Block a user