mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-11 20:30:08 +00:00
Added missing files.
This commit is contained in:
parent
b9d69db454
commit
cd2dcd1614
@ -44,6 +44,11 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProblemBoolCompare2() throws IOException, URISyntaxException {
|
||||
compileAndCompare("problem-bool-compare-2.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProblemBoolCompare() throws IOException, URISyntaxException {
|
||||
compileAndCompare("problem-bool-compare.c");
|
||||
|
16
src/test/kc/problem-bool-compare-2.c
Normal file
16
src/test/kc/problem-bool-compare-2.c
Normal file
@ -0,0 +1,16 @@
|
||||
// Test work-around for boolean comparison false!=false
|
||||
// https://atariage.com/forums/topic/311788-kickc-optimizing-c-compiler-now-supports-atari-8bit-xlxe/?tab=comments#comment-4644101
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
void main() {
|
||||
char * SCREEN = 0x0400;
|
||||
|
||||
if(FALSE!=FALSE)
|
||||
SCREEN[0] = '*';
|
||||
if(TRUE!=FALSE)
|
||||
SCREEN[1] = '*';
|
||||
|
||||
|
||||
}
|
13
src/test/kc/problem-bool-compare.c
Normal file
13
src/test/kc/problem-bool-compare.c
Normal file
@ -0,0 +1,13 @@
|
||||
// Test boolean comparison false!=false
|
||||
// https://atariage.com/forums/topic/311788-kickc-optimizing-c-compiler-now-supports-atari-8bit-xlxe/?tab=comments#comment-4644101
|
||||
|
||||
void main() {
|
||||
char * SCREEN = 0x0400;
|
||||
|
||||
if(false!=false)
|
||||
SCREEN[0] = '*';
|
||||
if(true!=false)
|
||||
SCREEN[1] = '*';
|
||||
|
||||
|
||||
}
|
13
src/test/ref/problem-bool-compare-2.asm
Normal file
13
src/test/ref/problem-bool-compare-2.asm
Normal file
@ -0,0 +1,13 @@
|
||||
// Test work-around for boolean comparison false!=false
|
||||
// https://atariage.com/forums/topic/311788-kickc-optimizing-c-compiler-now-supports-atari-8bit-xlxe/?tab=comments#comment-4644101
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
// SCREEN[1] = '*'
|
||||
lda #'*'
|
||||
sta SCREEN+1
|
||||
// }
|
||||
rts
|
||||
}
|
11
src/test/ref/problem-bool-compare-2.cfg
Normal file
11
src/test/ref/problem-bool-compare-2.cfg
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from
|
||||
[0] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
[1] *((const byte*) main::SCREEN+(byte) 1) ← (byte) '*'
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[2] return
|
||||
to:@return
|
207
src/test/ref/problem-bool-compare-2.log
Normal file
207
src/test/ref/problem-bool-compare-2.log
Normal file
@ -0,0 +1,207 @@
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from __start
|
||||
(bool~) main::$0 ← ! (number) 0!=(number) 0
|
||||
if((bool~) main::$0) goto main::@1
|
||||
to:main::@2
|
||||
main::@1: scope:[main] from main main::@2
|
||||
(bool~) main::$1 ← ! (number) 1!=(number) 0
|
||||
if((bool~) main::$1) goto main::@return
|
||||
to:main::@3
|
||||
main::@2: scope:[main] from main
|
||||
*((const byte*) main::SCREEN + (number) 0) ← (byte) '*'
|
||||
to:main::@1
|
||||
main::@3: scope:[main] from main::@1
|
||||
*((const byte*) main::SCREEN + (number) 1) ← (byte) '*'
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1 main::@3
|
||||
return
|
||||
to:@return
|
||||
|
||||
(void()) __start()
|
||||
__start: scope:[__start] from
|
||||
call main
|
||||
to:__start::@1
|
||||
__start::@1: scope:[__start] from __start
|
||||
to:__start::@return
|
||||
__start::@return: scope:[__start] from __start::@1
|
||||
return
|
||||
to:@return
|
||||
|
||||
SYMBOL TABLE SSA
|
||||
(void()) __start()
|
||||
(label) __start::@1
|
||||
(label) __start::@return
|
||||
(void()) main()
|
||||
(bool~) main::$0
|
||||
(bool~) main::$1
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@return
|
||||
(const byte*) main::SCREEN = (byte*)(number) $400
|
||||
|
||||
Adding number conversion cast (unumber) 0 in *((const byte*) main::SCREEN + (number) 0) ← (byte) '*'
|
||||
Adding number conversion cast (unumber) 1 in *((const byte*) main::SCREEN + (number) 1) ← (byte) '*'
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Simplifying constant pointer cast (byte*) 1024
|
||||
Simplifying constant integer cast 0
|
||||
Simplifying constant integer cast 1
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Finalized unsigned number type (byte) 0
|
||||
Finalized unsigned number type (byte) 1
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Rewriting ! if()-condition to reversed if() [0] (bool~) main::$0 ← ! (number) 0!=(number) 0
|
||||
Rewriting ! if()-condition to reversed if() [2] (bool~) main::$1 ← ! (number) 1!=(number) 0
|
||||
Successful SSA optimization Pass2ConditionalAndOrRewriting
|
||||
if() condition always false - eliminating [1] if((number) 0!=(number) 0) goto main::@2
|
||||
if() condition always true - replacing block destination [3] if((number) 1!=(number) 0) goto main::@3
|
||||
Successful SSA optimization Pass2ConstantIfs
|
||||
Simplifying expression containing zero main::SCREEN in [4] *((const byte*) main::SCREEN + (byte) 0) ← (byte) '*'
|
||||
Successful SSA optimization PassNSimplifyExpressionWithZero
|
||||
Removing unused block main::@2
|
||||
Successful SSA optimization Pass2EliminateUnusedBlocks
|
||||
Removing unused procedure __start
|
||||
Removing unused procedure block __start
|
||||
Removing unused procedure block __start::@1
|
||||
Removing unused procedure block __start::@return
|
||||
Successful SSA optimization PassNEliminateEmptyStart
|
||||
Consolidated array index constant in *(main::SCREEN+1)
|
||||
Successful SSA optimization Pass2ConstantAdditionElimination
|
||||
Adding NOP phi() at start of main
|
||||
Adding NOP phi() at start of main::@1
|
||||
CALL GRAPH
|
||||
|
||||
Created 0 initial phi equivalence classes
|
||||
Coalesced down to 0 phi equivalence classes
|
||||
Culled Empty Block (label) main::@1
|
||||
Renumbering block main::@3 to main::@1
|
||||
Adding NOP phi() at start of main
|
||||
|
||||
FINAL CONTROL FLOW GRAPH
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from
|
||||
[0] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
[1] *((const byte*) main::SCREEN+(byte) 1) ← (byte) '*'
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[2] return
|
||||
to:@return
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) main()
|
||||
|
||||
Initial phi equivalence classes
|
||||
Complete equivalence classes
|
||||
|
||||
INITIAL ASM
|
||||
Target platform is c64basic / MOS6502X
|
||||
// File Comments
|
||||
// Test work-around for boolean comparison false!=false
|
||||
// https://atariage.com/forums/topic/311788-kickc-optimizing-c-compiler-now-supports-atari-8bit-xlxe/?tab=comments#comment-4644101
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
// main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
jmp __b1
|
||||
// main::@1
|
||||
__b1:
|
||||
// [1] *((const byte*) main::SCREEN+(byte) 1) ← (byte) '*' -- _deref_pbuc1=vbuc2
|
||||
lda #'*'
|
||||
sta SCREEN+1
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [2] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [1] *((const byte*) main::SCREEN+(byte) 1) ← (byte) '*' [ ] ( [ ] { } ) always clobbers reg byte a
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 45 combination
|
||||
Uplifting [] best 45 combination
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
// File Comments
|
||||
// Test work-around for boolean comparison false!=false
|
||||
// https://atariage.com/forums/topic/311788-kickc-optimizing-c-compiler-now-supports-atari-8bit-xlxe/?tab=comments#comment-4644101
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
// main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
jmp __b1
|
||||
// main::@1
|
||||
__b1:
|
||||
// [1] *((const byte*) main::SCREEN+(byte) 1) ← (byte) '*' -- _deref_pbuc1=vbuc2
|
||||
lda #'*'
|
||||
sta SCREEN+1
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [2] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction __b1:
|
||||
Removing instruction __breturn:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(const byte*) main::SCREEN = (byte*) 1024
|
||||
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 12
|
||||
|
||||
// File Comments
|
||||
// Test work-around for boolean comparison false!=false
|
||||
// https://atariage.com/forums/topic/311788-kickc-optimizing-c-compiler-now-supports-atari-8bit-xlxe/?tab=comments#comment-4644101
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
// main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
// main::@1
|
||||
// SCREEN[1] = '*'
|
||||
// [1] *((const byte*) main::SCREEN+(byte) 1) ← (byte) '*' -- _deref_pbuc1=vbuc2
|
||||
lda #'*'
|
||||
sta SCREEN+1
|
||||
// main::@return
|
||||
// }
|
||||
// [2] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
|
5
src/test/ref/problem-bool-compare-2.sym
Normal file
5
src/test/ref/problem-bool-compare-2.sym
Normal file
@ -0,0 +1,5 @@
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(const byte*) main::SCREEN = (byte*) 1024
|
||||
|
Loading…
x
Reference in New Issue
Block a user