mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-10-21 17:24:39 +00:00
462 lines
14 KiB
Plaintext
462 lines
14 KiB
Plaintext
Resolved forward reference irq to interrupt(KERNEL_MIN)(void()) irq()
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
@begin: scope:[] from
|
|
to:@1
|
|
|
|
(void()) main()
|
|
main: scope:[main] from @1
|
|
asm { sei }
|
|
*((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR
|
|
*((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (number) $80
|
|
*((const nomodify byte*) RASTER) ← (number) 0
|
|
*((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER
|
|
*((const nomodify void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq()
|
|
asm { cli }
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
return
|
|
to:@return
|
|
|
|
interrupt(KERNEL_MIN)(void()) irq()
|
|
irq: scope:[irq] from
|
|
*((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE
|
|
*((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK
|
|
*((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER
|
|
to:irq::@return
|
|
irq::@return: scope:[irq] from irq
|
|
return
|
|
to:@return
|
|
@1: scope:[] from @begin
|
|
call main
|
|
to:@2
|
|
@2: scope:[] from @1
|
|
to:@end
|
|
@end: scope:[] from @2
|
|
|
|
SYMBOL TABLE SSA
|
|
(label) @1
|
|
(label) @2
|
|
(label) @begin
|
|
(label) @end
|
|
(const nomodify byte*) BG_COLOR = (byte*)(number) $d020
|
|
(const nomodify byte) BLACK = (byte) 0
|
|
(const nomodify byte*) CIA1_INTERRUPT = (byte*)(number) $dc0d
|
|
(const nomodify byte) CIA_INTERRUPT_CLEAR = (byte) $7f
|
|
(const nomodify byte*) IRQ_ENABLE = (byte*)(number) $d01a
|
|
(const nomodify byte) IRQ_RASTER = (byte) 1
|
|
(const nomodify byte*) IRQ_STATUS = (byte*)(number) $d019
|
|
(const nomodify void()**) KERNEL_IRQ = (void()**)(number) $314
|
|
(const nomodify byte*) RASTER = (byte*)(number) $d012
|
|
(const nomodify byte*) VIC_CONTROL = (byte*)(number) $d011
|
|
(const nomodify byte) WHITE = (byte) 1
|
|
interrupt(KERNEL_MIN)(void()) irq()
|
|
(label) irq::@return
|
|
(void()) main()
|
|
(label) main::@return
|
|
|
|
Adding number conversion cast (unumber) $80 in *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (number) $80
|
|
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) RASTER) ← (number) 0
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Inlining cast *((const nomodify byte*) RASTER) ← (unumber)(number) 0
|
|
Successful SSA optimization Pass2InlineCast
|
|
Simplifying constant pointer cast (void()**) 788
|
|
Simplifying constant pointer cast (byte*) 53266
|
|
Simplifying constant pointer cast (byte*) 53265
|
|
Simplifying constant pointer cast (byte*) 53273
|
|
Simplifying constant pointer cast (byte*) 53274
|
|
Simplifying constant pointer cast (byte*) 53280
|
|
Simplifying constant pointer cast (byte*) 56333
|
|
Simplifying constant integer cast $80
|
|
Simplifying constant integer cast 0
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) $80
|
|
Finalized unsigned number type (byte) 0
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Adding NOP phi() at start of @begin
|
|
Adding NOP phi() at start of @1
|
|
Adding NOP phi() at start of @2
|
|
Adding NOP phi() at start of @end
|
|
CALL GRAPH
|
|
Calls in [] to main:2
|
|
|
|
Created 0 initial phi equivalence classes
|
|
Coalesced down to 0 phi equivalence classes
|
|
Culled Empty Block (label) @2
|
|
Adding NOP phi() at start of @begin
|
|
Adding NOP phi() at start of @1
|
|
Adding NOP phi() at start of @end
|
|
|
|
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
|
|
asm { sei }
|
|
[5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR
|
|
[6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80
|
|
[7] *((const nomodify byte*) RASTER) ← (byte) 0
|
|
[8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER
|
|
[9] *((const nomodify void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq()
|
|
asm { cli }
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
[11] return
|
|
to:@return
|
|
|
|
interrupt(KERNEL_MIN)(void()) irq()
|
|
irq: scope:[irq] from
|
|
[12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE
|
|
[13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK
|
|
[14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER
|
|
to:irq::@return
|
|
irq::@return: scope:[irq] from irq
|
|
[15] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
interrupt(KERNEL_MIN)(void()) irq()
|
|
(void()) main()
|
|
|
|
Initial phi equivalence classes
|
|
Complete equivalence classes
|
|
|
|
INITIAL ASM
|
|
Target platform is c64basic / MOS6502X
|
|
// File Comments
|
|
// A minimal working raster IRQ
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.const IRQ_RASTER = 1
|
|
.const WHITE = 1
|
|
.const BLACK = 0
|
|
.const CIA_INTERRUPT_CLEAR = $7f
|
|
.label KERNEL_IRQ = $314
|
|
.label RASTER = $d012
|
|
.label VIC_CONTROL = $d011
|
|
.label IRQ_STATUS = $d019
|
|
.label IRQ_ENABLE = $d01a
|
|
.label BG_COLOR = $d020
|
|
.label CIA1_INTERRUPT = $dc0d
|
|
// @begin
|
|
__bbegin:
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
__b1_from___bbegin:
|
|
jmp __b1
|
|
// @1
|
|
__b1:
|
|
// [2] call main
|
|
jsr main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
__bend_from___b1:
|
|
jmp __bend
|
|
// @end
|
|
__bend:
|
|
// main
|
|
main: {
|
|
// asm { sei }
|
|
sei
|
|
// [5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
|
|
// Disable CIA 1 Timer IRQ
|
|
lda #CIA_INTERRUPT_CLEAR
|
|
sta CIA1_INTERRUPT
|
|
// [6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
|
// Set raster line to $100
|
|
lda #$80
|
|
ora VIC_CONTROL
|
|
sta VIC_CONTROL
|
|
// [7] *((const nomodify byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
|
lda #0
|
|
sta RASTER
|
|
// [8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Enable Raster Interrupt
|
|
lda #IRQ_RASTER
|
|
sta IRQ_ENABLE
|
|
// [9] *((const nomodify void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2
|
|
// Set the IRQ routine
|
|
lda #<irq
|
|
sta KERNEL_IRQ
|
|
lda #>irq
|
|
sta KERNEL_IRQ+1
|
|
// asm { cli }
|
|
cli
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [11] return
|
|
rts
|
|
}
|
|
// irq
|
|
// Interrupt Routine
|
|
irq: {
|
|
// entry interrupt(KERNEL_MIN)
|
|
// [12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE -- _deref_pbuc1=vbuc2
|
|
lda #WHITE
|
|
sta BG_COLOR
|
|
// [13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK -- _deref_pbuc1=vbuc2
|
|
lda #BLACK
|
|
sta BG_COLOR
|
|
// [14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Acknowledge the IRQ
|
|
lda #IRQ_RASTER
|
|
sta IRQ_STATUS
|
|
jmp __breturn
|
|
// irq::@return
|
|
__breturn:
|
|
// [15] return - exit interrupt(KERNEL_MIN)
|
|
jmp $ea81
|
|
}
|
|
// File Data
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [7] *((const nomodify byte*) RASTER) ← (byte) 0 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [9] *((const nomodify void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq() [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER [ ] ( [ ] { } ) always clobbers reg byte a
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [main]
|
|
Uplift Scope [irq]
|
|
Uplift Scope []
|
|
|
|
Uplifting [main] best 89 combination
|
|
Uplifting [irq] best 89 combination
|
|
Uplifting [] best 89 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// A minimal working raster IRQ
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.const IRQ_RASTER = 1
|
|
.const WHITE = 1
|
|
.const BLACK = 0
|
|
.const CIA_INTERRUPT_CLEAR = $7f
|
|
.label KERNEL_IRQ = $314
|
|
.label RASTER = $d012
|
|
.label VIC_CONTROL = $d011
|
|
.label IRQ_STATUS = $d019
|
|
.label IRQ_ENABLE = $d01a
|
|
.label BG_COLOR = $d020
|
|
.label CIA1_INTERRUPT = $dc0d
|
|
// @begin
|
|
__bbegin:
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
__b1_from___bbegin:
|
|
jmp __b1
|
|
// @1
|
|
__b1:
|
|
// [2] call main
|
|
jsr main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
__bend_from___b1:
|
|
jmp __bend
|
|
// @end
|
|
__bend:
|
|
// main
|
|
main: {
|
|
// asm { sei }
|
|
sei
|
|
// [5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
|
|
// Disable CIA 1 Timer IRQ
|
|
lda #CIA_INTERRUPT_CLEAR
|
|
sta CIA1_INTERRUPT
|
|
// [6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
|
// Set raster line to $100
|
|
lda #$80
|
|
ora VIC_CONTROL
|
|
sta VIC_CONTROL
|
|
// [7] *((const nomodify byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
|
lda #0
|
|
sta RASTER
|
|
// [8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Enable Raster Interrupt
|
|
lda #IRQ_RASTER
|
|
sta IRQ_ENABLE
|
|
// [9] *((const nomodify void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2
|
|
// Set the IRQ routine
|
|
lda #<irq
|
|
sta KERNEL_IRQ
|
|
lda #>irq
|
|
sta KERNEL_IRQ+1
|
|
// asm { cli }
|
|
cli
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [11] return
|
|
rts
|
|
}
|
|
// irq
|
|
// Interrupt Routine
|
|
irq: {
|
|
// entry interrupt(KERNEL_MIN)
|
|
// [12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE -- _deref_pbuc1=vbuc2
|
|
lda #WHITE
|
|
sta BG_COLOR
|
|
// [13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK -- _deref_pbuc1=vbuc2
|
|
lda #BLACK
|
|
sta BG_COLOR
|
|
// [14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Acknowledge the IRQ
|
|
lda #IRQ_RASTER
|
|
sta IRQ_STATUS
|
|
jmp __breturn
|
|
// irq::@return
|
|
__breturn:
|
|
// [15] return - exit interrupt(KERNEL_MIN)
|
|
jmp $ea81
|
|
}
|
|
// File Data
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __bend
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction __b1_from___bbegin:
|
|
Removing instruction __b1:
|
|
Removing instruction __bend_from___b1:
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
Removing instruction __bbegin:
|
|
Removing instruction __bend:
|
|
Removing instruction __breturn:
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
Removing instruction jsr main
|
|
Succesful ASM optimization Pass5SkipBegin
|
|
|
|
FINAL SYMBOL TABLE
|
|
(label) @1
|
|
(label) @begin
|
|
(label) @end
|
|
(const nomodify byte*) BG_COLOR = (byte*) 53280
|
|
(const nomodify byte) BLACK = (byte) 0
|
|
(const nomodify byte*) CIA1_INTERRUPT = (byte*) 56333
|
|
(const nomodify byte) CIA_INTERRUPT_CLEAR = (byte) $7f
|
|
(const nomodify byte*) IRQ_ENABLE = (byte*) 53274
|
|
(const nomodify byte) IRQ_RASTER = (byte) 1
|
|
(const nomodify byte*) IRQ_STATUS = (byte*) 53273
|
|
(const nomodify void()**) KERNEL_IRQ = (void()**) 788
|
|
(const nomodify byte*) RASTER = (byte*) 53266
|
|
(const nomodify byte*) VIC_CONTROL = (byte*) 53265
|
|
(const nomodify byte) WHITE = (byte) 1
|
|
interrupt(KERNEL_MIN)(void()) irq()
|
|
(label) irq::@return
|
|
(void()) main()
|
|
(label) main::@return
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 71
|
|
|
|
// File Comments
|
|
// A minimal working raster IRQ
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.const IRQ_RASTER = 1
|
|
.const WHITE = 1
|
|
.const BLACK = 0
|
|
.const CIA_INTERRUPT_CLEAR = $7f
|
|
.label KERNEL_IRQ = $314
|
|
.label RASTER = $d012
|
|
.label VIC_CONTROL = $d011
|
|
.label IRQ_STATUS = $d019
|
|
.label IRQ_ENABLE = $d01a
|
|
.label BG_COLOR = $d020
|
|
.label CIA1_INTERRUPT = $dc0d
|
|
// @begin
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
// @1
|
|
// [2] call main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
// @end
|
|
// main
|
|
main: {
|
|
// asm
|
|
// asm { sei }
|
|
sei
|
|
// *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR
|
|
// [5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
|
|
// Disable CIA 1 Timer IRQ
|
|
lda #CIA_INTERRUPT_CLEAR
|
|
sta CIA1_INTERRUPT
|
|
// *VIC_CONTROL |=$80
|
|
// [6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
|
// Set raster line to $100
|
|
lda #$80
|
|
ora VIC_CONTROL
|
|
sta VIC_CONTROL
|
|
// *RASTER = $00
|
|
// [7] *((const nomodify byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
|
lda #0
|
|
sta RASTER
|
|
// *IRQ_ENABLE = IRQ_RASTER
|
|
// [8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Enable Raster Interrupt
|
|
lda #IRQ_RASTER
|
|
sta IRQ_ENABLE
|
|
// *KERNEL_IRQ = &irq
|
|
// [9] *((const nomodify void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2
|
|
// Set the IRQ routine
|
|
lda #<irq
|
|
sta KERNEL_IRQ
|
|
lda #>irq
|
|
sta KERNEL_IRQ+1
|
|
// asm
|
|
// asm { cli }
|
|
cli
|
|
// main::@return
|
|
// }
|
|
// [11] return
|
|
rts
|
|
}
|
|
// irq
|
|
// Interrupt Routine
|
|
irq: {
|
|
// entry interrupt(KERNEL_MIN)
|
|
// *BG_COLOR = WHITE
|
|
// [12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE -- _deref_pbuc1=vbuc2
|
|
lda #WHITE
|
|
sta BG_COLOR
|
|
// *BG_COLOR = BLACK
|
|
// [13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK -- _deref_pbuc1=vbuc2
|
|
lda #BLACK
|
|
sta BG_COLOR
|
|
// *IRQ_STATUS = IRQ_RASTER
|
|
// [14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Acknowledge the IRQ
|
|
lda #IRQ_RASTER
|
|
sta IRQ_STATUS
|
|
// irq::@return
|
|
// }
|
|
// [15] return - exit interrupt(KERNEL_MIN)
|
|
jmp $ea81
|
|
}
|
|
// File Data
|
|
|