mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-01 13:30:50 +00:00
Fixed bug when using 2 function pointers in one block. Closes #463
This commit is contained in:
parent
7515c2d069
commit
a4c0627215
@ -1,6 +1,7 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import dk.camelot64.kickc.model.statements.Statement;
|
||||
import dk.camelot64.kickc.model.statements.StatementCalling;
|
||||
import dk.camelot64.kickc.model.statements.StatementPhiBlock;
|
||||
import dk.camelot64.kickc.model.symbols.Label;
|
||||
import dk.camelot64.kickc.model.symbols.Procedure;
|
||||
@ -160,6 +161,26 @@ public class ControlFlowGraph implements Serializable {
|
||||
return entryPointBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all called procedures in the graph
|
||||
* @return All called procedures
|
||||
*/
|
||||
public Set<ProcedureRef> getAllCalledProcedures() {
|
||||
Set<ProcedureRef> calledProcedures = new LinkedHashSet<>();
|
||||
for(ControlFlowBlock block : getAllBlocks()) {
|
||||
for(Statement statement : block.getStatements()) {
|
||||
if(statement instanceof StatementCalling) {
|
||||
StatementCalling call = (StatementCalling) statement;
|
||||
ProcedureRef procedureRef = call.getProcedure();
|
||||
calledProcedures.add(procedureRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
return calledProcedures;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -1,9 +1,8 @@
|
||||
package dk.camelot64.kickc.passes;
|
||||
|
||||
import dk.camelot64.kickc.model.ControlFlowBlock;
|
||||
import dk.camelot64.kickc.model.ControlFlowGraph;
|
||||
import dk.camelot64.kickc.model.Program;
|
||||
import dk.camelot64.kickc.model.statements.Statement;
|
||||
import dk.camelot64.kickc.model.statements.StatementCalling;
|
||||
import dk.camelot64.kickc.model.symbols.Procedure;
|
||||
import dk.camelot64.kickc.model.values.ProcedureRef;
|
||||
|
||||
@ -21,16 +20,7 @@ public class Pass1EliminateUncalledProcedures extends Pass1Base {
|
||||
|
||||
@Override
|
||||
public boolean step() {
|
||||
Set<ProcedureRef> calledProcedures = new LinkedHashSet<>();
|
||||
for(ControlFlowBlock block : getProgram().getGraph().getAllBlocks()) {
|
||||
for(Statement statement : block.getStatements()) {
|
||||
if(statement instanceof StatementCalling) {
|
||||
StatementCalling call = (StatementCalling) statement;
|
||||
ProcedureRef procedureRef = call.getProcedure();
|
||||
calledProcedures.add(procedureRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<ProcedureRef> calledProcedures = getGraph().getAllCalledProcedures();
|
||||
|
||||
Set<ProcedureRef> unusedProcedures = new LinkedHashSet<>();
|
||||
Collection<Procedure> allProcedures = getProgram().getScope().getAllProcedures(true);
|
||||
|
@ -5,6 +5,7 @@ import dk.camelot64.kickc.model.Program;
|
||||
import dk.camelot64.kickc.model.statements.Statement;
|
||||
import dk.camelot64.kickc.model.statements.StatementCall;
|
||||
import dk.camelot64.kickc.model.statements.StatementCallPointer;
|
||||
import dk.camelot64.kickc.model.symbols.Procedure;
|
||||
import dk.camelot64.kickc.model.symbols.Variable;
|
||||
import dk.camelot64.kickc.model.types.SymbolType;
|
||||
import dk.camelot64.kickc.model.types.SymbolTypePointer;
|
||||
@ -70,6 +71,8 @@ public class Pass2ConstantCallPointerIdentification extends Pass2SsaOptimization
|
||||
call.setIndex(callPointer.getIndex());
|
||||
block.setCallSuccessor(constProcedureRef.getLabelRef());
|
||||
statementsIt.add(call);
|
||||
final Procedure procedure = getScope().getProcedure(constProcedureRef);
|
||||
procedure.setCallingConvention(Procedure.CallingConvention.STACK_CALL);
|
||||
getLog().append("Replacing constant pointer function " + call.toString(getProgram(), false));
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,7 @@ import dk.camelot64.kickc.CompileLog;
|
||||
import dk.camelot64.kickc.model.CompileError;
|
||||
import dk.camelot64.kickc.model.ControlFlowBlock;
|
||||
import dk.camelot64.kickc.model.Program;
|
||||
import dk.camelot64.kickc.model.statements.Statement;
|
||||
import dk.camelot64.kickc.model.statements.StatementLValue;
|
||||
import dk.camelot64.kickc.model.statements.StatementPhiBlock;
|
||||
import dk.camelot64.kickc.model.statements.*;
|
||||
import dk.camelot64.kickc.model.symbols.Label;
|
||||
import dk.camelot64.kickc.model.symbols.Procedure;
|
||||
import dk.camelot64.kickc.model.symbols.Symbol;
|
||||
@ -55,7 +53,7 @@ public class Pass2EliminateUnusedBlocks extends Pass2SsaOptimization {
|
||||
|
||||
|
||||
Set<LabelRef> unusedProcedureBlocks = new HashSet<>();
|
||||
for( LabelRef unusedBlock : unusedBlocks) {
|
||||
for(LabelRef unusedBlock : unusedBlocks) {
|
||||
Symbol unusedSymbol = getScope().getSymbol(unusedBlock);
|
||||
if(unusedSymbol instanceof Label) {
|
||||
getGraph().remove(unusedBlock);
|
||||
@ -79,7 +77,7 @@ public class Pass2EliminateUnusedBlocks extends Pass2SsaOptimization {
|
||||
} else if(unusedProcedureBlocks.contains(unusedBlock)) {
|
||||
// Already removed - we are happy!
|
||||
} else {
|
||||
throw new CompileError("Unable to remove unused block "+unusedBlock);
|
||||
throw new CompileError("Unable to remove unused block " + unusedBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +95,7 @@ public class Pass2EliminateUnusedBlocks extends Pass2SsaOptimization {
|
||||
for(ControlFlowBlock entryPointBlock : entryPointBlocks) {
|
||||
findReferencedBlocks(entryPointBlock, referencedBlocks);
|
||||
}
|
||||
|
||||
return referencedBlocks;
|
||||
}
|
||||
|
||||
@ -158,6 +157,15 @@ public class Pass2EliminateUnusedBlocks extends Pass2SsaOptimization {
|
||||
}
|
||||
findReferencedBlocks(getGraph().getBlock(block.getDefaultSuccessor()), used);
|
||||
}
|
||||
for(Statement statement : block.getStatements()) {
|
||||
if(statement instanceof StatementCall) {
|
||||
final ProcedureRef procedure = ((StatementCall) statement).getProcedure();
|
||||
findReferencedBlocks(getGraph().getBlock(procedure.getLabelRef()), used);
|
||||
} else if(statement instanceof StatementCallExecute) {
|
||||
final ProcedureRef procedure = ((StatementCallExecute) statement).getProcedure();
|
||||
findReferencedBlocks(getGraph().getBlock(procedure.getLabelRef()), used);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2599,6 +2599,11 @@ public class TestPrograms {
|
||||
compileAndCompare("pointer-pointer-1.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunctionPointerNoargCall11() throws IOException, URISyntaxException {
|
||||
compileAndCompare("function-pointer-noarg-call-11.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunctionPointerNoargCall10() throws IOException, URISyntaxException {
|
||||
compileAndCompare("function-pointer-noarg-call-10.c");
|
||||
|
17
src/test/kc/function-pointer-noarg-call-11.c
Normal file
17
src/test/kc/function-pointer-noarg-call-11.c
Normal file
@ -0,0 +1,17 @@
|
||||
// Tests calling through pointers to non-args no-return functions
|
||||
|
||||
void myFunc(){
|
||||
byte* const BORDER_COLOR = $d020;
|
||||
(*BORDER_COLOR)++;
|
||||
}
|
||||
void myFunc2(){
|
||||
byte* const BG_COLOR = $d021;
|
||||
(*BG_COLOR)++;
|
||||
}
|
||||
void () *funcPointer;
|
||||
void main() {
|
||||
funcPointer=&myFunc;
|
||||
(*funcPointer)();
|
||||
funcPointer=&myFunc2;
|
||||
(*funcPointer)();
|
||||
}
|
25
src/test/ref/function-pointer-noarg-call-11.asm
Normal file
25
src/test/ref/function-pointer-noarg-call-11.asm
Normal file
@ -0,0 +1,25 @@
|
||||
// Tests calling through pointers to non-args no-return functions
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
main: {
|
||||
// (*funcPointer)()
|
||||
jsr myFunc
|
||||
jsr myFunc2
|
||||
// }
|
||||
rts
|
||||
}
|
||||
myFunc2: {
|
||||
.label BG_COLOR = $d021
|
||||
// (*BG_COLOR)++;
|
||||
inc BG_COLOR
|
||||
// }
|
||||
rts
|
||||
}
|
||||
myFunc: {
|
||||
.label BORDER_COLOR = $d020
|
||||
// (*BORDER_COLOR)++;
|
||||
inc BORDER_COLOR
|
||||
// }
|
||||
rts
|
||||
}
|
35
src/test/ref/function-pointer-noarg-call-11.cfg
Normal file
35
src/test/ref/function-pointer-noarg-call-11.cfg
Normal file
@ -0,0 +1,35 @@
|
||||
@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 myFunc
|
||||
[6] call myFunc2
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[7] return
|
||||
to:@return
|
||||
|
||||
__stackcall (void()) myFunc2()
|
||||
myFunc2: scope:[myFunc2] from main
|
||||
[8] *((const nomodify byte*) myFunc2::BG_COLOR) ← ++ *((const nomodify byte*) myFunc2::BG_COLOR)
|
||||
to:myFunc2::@return
|
||||
myFunc2::@return: scope:[myFunc2] from myFunc2
|
||||
[9] return
|
||||
to:@return
|
||||
|
||||
__stackcall (void()) myFunc()
|
||||
myFunc: scope:[myFunc] from
|
||||
[10] *((const nomodify byte*) myFunc::BORDER_COLOR) ← ++ *((const nomodify byte*) myFunc::BORDER_COLOR)
|
||||
to:myFunc::@return
|
||||
myFunc::@return: scope:[myFunc] from myFunc
|
||||
[11] return
|
||||
to:@return
|
381
src/test/ref/function-pointer-noarg-call-11.log
Normal file
381
src/test/ref/function-pointer-noarg-call-11.log
Normal file
@ -0,0 +1,381 @@
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
to:@1
|
||||
|
||||
(void()) myFunc()
|
||||
myFunc: scope:[myFunc] from
|
||||
*((const nomodify byte*) myFunc::BORDER_COLOR) ← ++ *((const nomodify byte*) myFunc::BORDER_COLOR)
|
||||
to:myFunc::@return
|
||||
myFunc::@return: scope:[myFunc] from myFunc
|
||||
return
|
||||
to:@return
|
||||
|
||||
(void()) myFunc2()
|
||||
myFunc2: scope:[myFunc2] from
|
||||
*((const nomodify byte*) myFunc2::BG_COLOR) ← ++ *((const nomodify byte*) myFunc2::BG_COLOR)
|
||||
to:myFunc2::@return
|
||||
myFunc2::@return: scope:[myFunc2] from myFunc2
|
||||
return
|
||||
to:@return
|
||||
@1: scope:[] from @begin
|
||||
(void()*) funcPointer#0 ← (void()*) 0
|
||||
to:@2
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from @2
|
||||
(void()*) funcPointer#1 ← &(void()) myFunc()
|
||||
call *((void()*) funcPointer#1)
|
||||
(void()*) funcPointer#2 ← &(void()) myFunc2()
|
||||
call *((void()*) funcPointer#2)
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
(void()*) funcPointer#5 ← phi( main/(void()*) funcPointer#2 )
|
||||
(void()*) funcPointer#3 ← (void()*) funcPointer#5
|
||||
return
|
||||
to:@return
|
||||
@2: scope:[] from @1
|
||||
(void()*) funcPointer#7 ← phi( @1/(void()*) funcPointer#0 )
|
||||
call main
|
||||
to:@3
|
||||
@3: scope:[] from @2
|
||||
(void()*) funcPointer#6 ← phi( @2/(void()*) funcPointer#3 )
|
||||
(void()*) funcPointer#4 ← (void()*) funcPointer#6
|
||||
to:@end
|
||||
@end: scope:[] from @3
|
||||
|
||||
SYMBOL TABLE SSA
|
||||
(label) @1
|
||||
(label) @2
|
||||
(label) @3
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()*) funcPointer
|
||||
(void()*) funcPointer#0
|
||||
(void()*) funcPointer#1
|
||||
(void()*) funcPointer#2
|
||||
(void()*) funcPointer#3
|
||||
(void()*) funcPointer#4
|
||||
(void()*) funcPointer#5
|
||||
(void()*) funcPointer#6
|
||||
(void()*) funcPointer#7
|
||||
(void()) main()
|
||||
(label) main::@return
|
||||
(void()) myFunc()
|
||||
(label) myFunc::@return
|
||||
(const nomodify byte*) myFunc::BORDER_COLOR = (byte*)(number) $d020
|
||||
(void()) myFunc2()
|
||||
(label) myFunc2::@return
|
||||
(const nomodify byte*) myFunc2::BG_COLOR = (byte*)(number) $d021
|
||||
|
||||
Simplifying constant pointer cast (byte*) 53280
|
||||
Simplifying constant pointer cast (byte*) 53281
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Alias funcPointer#2 = funcPointer#5 funcPointer#3
|
||||
Alias funcPointer#0 = funcPointer#7
|
||||
Alias funcPointer#4 = funcPointer#6
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Identical Phi Values (void()*) funcPointer#4 (void()*) funcPointer#2
|
||||
Successful SSA optimization Pass2IdenticalPhiElimination
|
||||
Constant (const void()*) funcPointer#0 = (void()*) 0
|
||||
Constant (const void()*) funcPointer#1 = &myFunc
|
||||
Constant (const void()*) funcPointer#2 = &myFunc2
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Replacing constant pointer function [6] call myFunc
|
||||
Replacing constant pointer function [8] call myFunc2
|
||||
Successful SSA optimization Pass2ConstantCallPointerIdentification
|
||||
Eliminating unused constant (const void()*) funcPointer#0
|
||||
Eliminating unused constant (const void()*) funcPointer#1
|
||||
Eliminating unused constant (const void()*) funcPointer#2
|
||||
Successful SSA optimization PassNEliminateUnusedVars
|
||||
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 @3
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
CALL GRAPH
|
||||
Calls in [] to main:3
|
||||
Calls in [main] to myFunc:7 myFunc2:8
|
||||
|
||||
Created 0 initial phi equivalence classes
|
||||
Coalesced down to 0 phi equivalence classes
|
||||
Culled Empty Block (label) @1
|
||||
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
|
||||
|
||||
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 myFunc
|
||||
[6] call myFunc2
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[7] return
|
||||
to:@return
|
||||
|
||||
__stackcall (void()) myFunc2()
|
||||
myFunc2: scope:[myFunc2] from main
|
||||
[8] *((const nomodify byte*) myFunc2::BG_COLOR) ← ++ *((const nomodify byte*) myFunc2::BG_COLOR)
|
||||
to:myFunc2::@return
|
||||
myFunc2::@return: scope:[myFunc2] from myFunc2
|
||||
[9] return
|
||||
to:@return
|
||||
|
||||
__stackcall (void()) myFunc()
|
||||
myFunc: scope:[myFunc] from
|
||||
[10] *((const nomodify byte*) myFunc::BORDER_COLOR) ← ++ *((const nomodify byte*) myFunc::BORDER_COLOR)
|
||||
to:myFunc::@return
|
||||
myFunc::@return: scope:[myFunc] from myFunc
|
||||
[11] return
|
||||
to:@return
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()*) funcPointer
|
||||
(void()) main()
|
||||
__stackcall (void()) myFunc()
|
||||
__stackcall (void()) myFunc2()
|
||||
|
||||
Initial phi equivalence classes
|
||||
Complete equivalence classes
|
||||
|
||||
INITIAL ASM
|
||||
Target platform is c64basic / MOS6502X
|
||||
// File Comments
|
||||
// Tests calling through pointers to non-args no-return functions
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
// @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: {
|
||||
// [5] call myFunc
|
||||
jsr myFunc
|
||||
// [6] call myFunc2
|
||||
jsr myFunc2
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [7] return
|
||||
rts
|
||||
}
|
||||
// myFunc2
|
||||
myFunc2: {
|
||||
.label BG_COLOR = $d021
|
||||
// [8] *((const nomodify byte*) myFunc2::BG_COLOR) ← ++ *((const nomodify byte*) myFunc2::BG_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
||||
inc BG_COLOR
|
||||
jmp __breturn
|
||||
// myFunc2::@return
|
||||
__breturn:
|
||||
// [9] return
|
||||
rts
|
||||
}
|
||||
// myFunc
|
||||
myFunc: {
|
||||
.label BORDER_COLOR = $d020
|
||||
// [10] *((const nomodify byte*) myFunc::BORDER_COLOR) ← ++ *((const nomodify byte*) myFunc::BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
||||
inc BORDER_COLOR
|
||||
jmp __breturn
|
||||
// myFunc::@return
|
||||
__breturn:
|
||||
// [11] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [myFunc]
|
||||
Uplift Scope [myFunc2]
|
||||
Uplift Scope [main]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [myFunc] best 63 combination
|
||||
Uplifting [myFunc2] best 63 combination
|
||||
Uplifting [main] best 63 combination
|
||||
Uplifting [] best 63 combination
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
// File Comments
|
||||
// Tests calling through pointers to non-args no-return functions
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
// @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: {
|
||||
// [5] call myFunc
|
||||
jsr myFunc
|
||||
// [6] call myFunc2
|
||||
jsr myFunc2
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [7] return
|
||||
rts
|
||||
}
|
||||
// myFunc2
|
||||
myFunc2: {
|
||||
.label BG_COLOR = $d021
|
||||
// [8] *((const nomodify byte*) myFunc2::BG_COLOR) ← ++ *((const nomodify byte*) myFunc2::BG_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
||||
inc BG_COLOR
|
||||
jmp __breturn
|
||||
// myFunc2::@return
|
||||
__breturn:
|
||||
// [9] return
|
||||
rts
|
||||
}
|
||||
// myFunc
|
||||
myFunc: {
|
||||
.label BORDER_COLOR = $d020
|
||||
// [10] *((const nomodify byte*) myFunc::BORDER_COLOR) ← ++ *((const nomodify byte*) myFunc::BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
||||
inc BORDER_COLOR
|
||||
jmp __breturn
|
||||
// myFunc::@return
|
||||
__breturn:
|
||||
// [11] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __bend
|
||||
Removing instruction jmp __breturn
|
||||
Removing instruction jmp __breturn
|
||||
Removing instruction jmp __breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction __b1_from___bbegin:
|
||||
Removing instruction __b1:
|
||||
Removing instruction main_from___b1:
|
||||
Removing instruction __bend_from___b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction __bbegin:
|
||||
Removing instruction __bend:
|
||||
Removing instruction __breturn:
|
||||
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
|
||||
(void()*) funcPointer
|
||||
(void()) main()
|
||||
(label) main::@return
|
||||
__stackcall (void()) myFunc()
|
||||
(label) myFunc::@return
|
||||
(const nomodify byte*) myFunc::BORDER_COLOR = (byte*) 53280
|
||||
__stackcall (void()) myFunc2()
|
||||
(label) myFunc2::@return
|
||||
(const nomodify byte*) myFunc2::BG_COLOR = (byte*) 53281
|
||||
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 42
|
||||
|
||||
// File Comments
|
||||
// Tests calling through pointers to non-args no-return functions
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
// @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: {
|
||||
// (*funcPointer)()
|
||||
// [5] call myFunc
|
||||
jsr myFunc
|
||||
// [6] call myFunc2
|
||||
jsr myFunc2
|
||||
// main::@return
|
||||
// }
|
||||
// [7] return
|
||||
rts
|
||||
}
|
||||
// myFunc2
|
||||
myFunc2: {
|
||||
.label BG_COLOR = $d021
|
||||
// (*BG_COLOR)++;
|
||||
// [8] *((const nomodify byte*) myFunc2::BG_COLOR) ← ++ *((const nomodify byte*) myFunc2::BG_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
||||
inc BG_COLOR
|
||||
// myFunc2::@return
|
||||
// }
|
||||
// [9] return
|
||||
rts
|
||||
}
|
||||
// myFunc
|
||||
myFunc: {
|
||||
.label BORDER_COLOR = $d020
|
||||
// (*BORDER_COLOR)++;
|
||||
// [10] *((const nomodify byte*) myFunc::BORDER_COLOR) ← ++ *((const nomodify byte*) myFunc::BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
||||
inc BORDER_COLOR
|
||||
// myFunc::@return
|
||||
// }
|
||||
// [11] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
|
13
src/test/ref/function-pointer-noarg-call-11.sym
Normal file
13
src/test/ref/function-pointer-noarg-call-11.sym
Normal file
@ -0,0 +1,13 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()*) funcPointer
|
||||
(void()) main()
|
||||
(label) main::@return
|
||||
__stackcall (void()) myFunc()
|
||||
(label) myFunc::@return
|
||||
(const nomodify byte*) myFunc::BORDER_COLOR = (byte*) 53280
|
||||
__stackcall (void()) myFunc2()
|
||||
(label) myFunc2::@return
|
||||
(const nomodify byte*) myFunc2::BG_COLOR = (byte*) 53281
|
||||
|
@ -24,7 +24,7 @@ main::@3: scope:[main] from main::@2
|
||||
[9] call fn1
|
||||
to:main::@1
|
||||
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
fn1: scope:[fn1] from main::@3
|
||||
[10] *((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR)
|
||||
to:fn1::@return
|
||||
|
@ -163,7 +163,7 @@ main::@3: scope:[main] from main::@2
|
||||
[9] call fn1
|
||||
to:main::@1
|
||||
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
fn1: scope:[fn1] from main::@3
|
||||
[10] *((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR)
|
||||
to:fn1::@return
|
||||
@ -181,7 +181,7 @@ getfn::@return: scope:[getfn] from getfn
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(void()*()) getfn((byte) getfn::b)
|
||||
(byte) getfn::b
|
||||
(void()*) getfn::return
|
||||
@ -396,7 +396,7 @@ FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(label) fn1::@return
|
||||
(const nomodify byte*) fn1::BORDER_COLOR = (byte*) 53280
|
||||
(void()*()) getfn((byte) getfn::b)
|
||||
|
@ -1,7 +1,7 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(label) fn1::@return
|
||||
(const nomodify byte*) fn1::BORDER_COLOR = (byte*) 53280
|
||||
(void()*()) getfn((byte) getfn::b)
|
||||
|
@ -26,7 +26,7 @@ main::@2: scope:[main] from main::@1
|
||||
[11] (byte*) main::cols#1 ← ++ (byte*) main::cols#2
|
||||
to:main::@1
|
||||
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
fn1: scope:[fn1] from main::@2
|
||||
[12] phi()
|
||||
to:fn1::@1
|
||||
|
@ -149,7 +149,7 @@ main::@2: scope:[main] from main::@1
|
||||
[11] (byte*) main::cols#1 ← ++ (byte*) main::cols#2
|
||||
to:main::@1
|
||||
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
fn1: scope:[fn1] from main::@2
|
||||
[12] phi()
|
||||
to:fn1::@1
|
||||
@ -167,7 +167,7 @@ fn1::@2: scope:[fn1] from fn1::@1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(byte*) fn1::screen
|
||||
(byte*) fn1::screen#1 200002.0
|
||||
(byte*) fn1::screen#2 166668.3333333333
|
||||
@ -243,8 +243,6 @@ main: {
|
||||
// main::@2
|
||||
__b2:
|
||||
// [9] call fn1
|
||||
// [12] phi from main::@2 to fn1 [phi:main::@2->fn1]
|
||||
fn1_from___b2:
|
||||
jsr fn1
|
||||
// [10] *((byte*) main::cols#2) ← ++ *((byte*) main::cols#2) -- _deref_pbuz1=_inc__deref_pbuz1
|
||||
ldy #0
|
||||
@ -324,9 +322,9 @@ Uplift Scope [fn1] 366,670.33: zp[2]:4 [ fn1::screen#2 fn1::screen#1 ]
|
||||
Uplift Scope [main] 303: zp[2]:2 [ main::cols#2 main::cols#1 ]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [fn1] best 7595 combination zp[2]:4 [ fn1::screen#2 fn1::screen#1 ]
|
||||
Uplifting [main] best 7595 combination zp[2]:2 [ main::cols#2 main::cols#1 ]
|
||||
Uplifting [] best 7595 combination
|
||||
Uplifting [fn1] best 7649 combination zp[2]:4 [ fn1::screen#2 fn1::screen#1 ]
|
||||
Uplifting [main] best 7649 combination zp[2]:2 [ main::cols#2 main::cols#1 ]
|
||||
Uplifting [] best 7649 combination
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
// File Comments
|
||||
@ -385,8 +383,6 @@ main: {
|
||||
// main::@2
|
||||
__b2:
|
||||
// [9] call fn1
|
||||
// [12] phi from main::@2 to fn1 [phi:main::@2->fn1]
|
||||
fn1_from___b2:
|
||||
jsr fn1
|
||||
// [10] *((byte*) main::cols#2) ← ++ *((byte*) main::cols#2) -- _deref_pbuz1=_inc__deref_pbuz1
|
||||
ldy #0
|
||||
@ -472,7 +468,6 @@ Removing instruction __b1:
|
||||
Removing instruction main_from___b1:
|
||||
Removing instruction __bend_from___b1:
|
||||
Removing instruction __b2_from___b1:
|
||||
Removing instruction fn1_from___b2:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction __bbegin:
|
||||
Removing instruction __bend:
|
||||
@ -490,7 +485,7 @@ FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(label) fn1::@1
|
||||
(label) fn1::@2
|
||||
(label) fn1::@return
|
||||
@ -510,7 +505,7 @@ zp[2]:4 [ fn1::screen#2 fn1::screen#1 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 6673
|
||||
Score: 6727
|
||||
|
||||
// File Comments
|
||||
// Tests calling into a function pointer with local variables
|
||||
@ -556,7 +551,6 @@ main: {
|
||||
__b2:
|
||||
// (*cls)()
|
||||
// [9] call fn1
|
||||
// [12] phi from main::@2 to fn1 [phi:main::@2->fn1]
|
||||
jsr fn1
|
||||
// (*cols)++;
|
||||
// [10] *((byte*) main::cols#2) ← ++ *((byte*) main::cols#2) -- _deref_pbuz1=_inc__deref_pbuz1
|
||||
|
@ -1,7 +1,7 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(label) fn1::@1
|
||||
(label) fn1::@2
|
||||
(label) fn1::@return
|
||||
|
@ -34,7 +34,7 @@ do10::@return: scope:[do10] from do10::@1
|
||||
[13] return
|
||||
to:@return
|
||||
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
hello: scope:[hello] from do10::@1
|
||||
[14] phi()
|
||||
to:hello::@1
|
||||
|
@ -193,7 +193,7 @@ do10::@return: scope:[do10] from do10::@1
|
||||
[13] return
|
||||
to:@return
|
||||
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
hello: scope:[hello] from do10::@1
|
||||
[14] phi()
|
||||
to:hello::@1
|
||||
@ -208,6 +208,7 @@ hello::@return: scope:[hello] from hello::@1
|
||||
[20] return
|
||||
to:@return
|
||||
|
||||
null depth in calling loop Loop head: do10::@1 tails: do10::@1 blocks: do10::@1 in scope hello
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) do10((void()*) do10::fn)
|
||||
@ -215,11 +216,11 @@ VARIABLE REGISTER WEIGHTS
|
||||
(byte) do10::i
|
||||
(byte) do10::i#1 1501.5
|
||||
(byte) do10::i#2 1001.0
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
(byte) hello::i
|
||||
(byte) hello::i#1 1500001.5
|
||||
(byte) hello::i#2 1000001.0
|
||||
(volatile byte) idx loadstore 200000.33333333334
|
||||
(byte) hello::i#1 150001.5
|
||||
(byte) hello::i#2 100001.0
|
||||
(volatile byte) idx loadstore 20000.333333333336
|
||||
(void()) main()
|
||||
|
||||
Initial phi equivalence classes
|
||||
@ -295,8 +296,6 @@ do10: {
|
||||
// do10::@1
|
||||
__b1:
|
||||
// [10] call hello
|
||||
// [14] phi from do10::@1 to hello [phi:do10::@1->hello]
|
||||
hello_from___b1:
|
||||
jsr hello
|
||||
// [11] (byte) do10::i#1 ← ++ (byte) do10::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc.z i
|
||||
@ -365,19 +364,19 @@ Potential registers zp[1]:3 [ hello::i#2 hello::i#1 ] : zp[1]:3 , reg byte x ,
|
||||
Potential registers zp[1]:4 [ idx ] : zp[1]:4 ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [hello] 2,500,002.5: zp[1]:3 [ hello::i#2 hello::i#1 ]
|
||||
Uplift Scope [] 200,000.33: zp[1]:4 [ idx ]
|
||||
Uplift Scope [hello] 250,002.5: zp[1]:3 [ hello::i#2 hello::i#1 ]
|
||||
Uplift Scope [] 20,000.33: zp[1]:4 [ idx ]
|
||||
Uplift Scope [do10] 2,502.5: zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplift Scope [main]
|
||||
|
||||
Uplifting [hello] best 4295 combination reg byte x [ hello::i#2 hello::i#1 ]
|
||||
Uplifting [] best 4295 combination zp[1]:4 [ idx ]
|
||||
Uplifting [do10] best 4295 combination zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplifting [main] best 4295 combination
|
||||
Uplifting [hello] best 794 combination reg byte x [ hello::i#2 hello::i#1 ]
|
||||
Uplifting [] best 794 combination zp[1]:4 [ idx ]
|
||||
Uplifting [do10] best 794 combination zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplifting [main] best 794 combination
|
||||
Attempting to uplift remaining variables inzp[1]:4 [ idx ]
|
||||
Uplifting [] best 4295 combination zp[1]:4 [ idx ]
|
||||
Uplifting [] best 794 combination zp[1]:4 [ idx ]
|
||||
Attempting to uplift remaining variables inzp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplifting [do10] best 4295 combination zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplifting [do10] best 794 combination zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Allocated (was zp[1]:4) zp[1]:3 [ idx ]
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
@ -440,8 +439,6 @@ do10: {
|
||||
// do10::@1
|
||||
__b1:
|
||||
// [10] call hello
|
||||
// [14] phi from do10::@1 to hello [phi:do10::@1->hello]
|
||||
hello_from___b1:
|
||||
jsr hello
|
||||
// [11] (byte) do10::i#1 ← ++ (byte) do10::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc.z i
|
||||
@ -507,7 +504,6 @@ Removing instruction __b2_from___b1:
|
||||
Removing instruction main_from___b2:
|
||||
Removing instruction __bend_from___b2:
|
||||
Removing instruction __b1_from___b1:
|
||||
Removing instruction hello_from___b1:
|
||||
Removing instruction __b1_from___b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction __b2:
|
||||
@ -538,13 +534,13 @@ FINAL SYMBOL TABLE
|
||||
(byte) do10::i
|
||||
(byte) do10::i#1 i zp[1]:2 1501.5
|
||||
(byte) do10::i#2 i zp[1]:2 1001.0
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
(label) hello::@1
|
||||
(label) hello::@return
|
||||
(byte) hello::i
|
||||
(byte) hello::i#1 reg byte x 1500001.5
|
||||
(byte) hello::i#2 reg byte x 1000001.0
|
||||
(volatile byte) idx loadstore zp[1]:3 200000.33333333334
|
||||
(byte) hello::i#1 reg byte x 150001.5
|
||||
(byte) hello::i#2 reg byte x 100001.0
|
||||
(volatile byte) idx loadstore zp[1]:3 20000.333333333336
|
||||
(void()) main()
|
||||
(label) main::@return
|
||||
(const to_nomodify byte*) msg[] = (byte*) "hello "
|
||||
@ -555,7 +551,7 @@ zp[1]:3 [ idx ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 3272
|
||||
Score: 581
|
||||
|
||||
// File Comments
|
||||
// Tests calling into a function pointer with local variables
|
||||
@ -605,7 +601,6 @@ do10: {
|
||||
__b1:
|
||||
// (*fn)()
|
||||
// [10] call hello
|
||||
// [14] phi from do10::@1 to hello [phi:do10::@1->hello]
|
||||
jsr hello
|
||||
// for( byte i: 0..9)
|
||||
// [11] (byte) do10::i#1 ← ++ (byte) do10::i#2 -- vbuz1=_inc_vbuz1
|
||||
|
@ -10,13 +10,13 @@
|
||||
(byte) do10::i
|
||||
(byte) do10::i#1 i zp[1]:2 1501.5
|
||||
(byte) do10::i#2 i zp[1]:2 1001.0
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
(label) hello::@1
|
||||
(label) hello::@return
|
||||
(byte) hello::i
|
||||
(byte) hello::i#1 reg byte x 1500001.5
|
||||
(byte) hello::i#2 reg byte x 1000001.0
|
||||
(volatile byte) idx loadstore zp[1]:3 200000.33333333334
|
||||
(byte) hello::i#1 reg byte x 150001.5
|
||||
(byte) hello::i#2 reg byte x 100001.0
|
||||
(volatile byte) idx loadstore zp[1]:3 20000.333333333336
|
||||
(void()) main()
|
||||
(label) main::@return
|
||||
(const to_nomodify byte*) msg[] = (byte*) "hello "
|
||||
|
@ -39,7 +39,7 @@ do10::@return: scope:[do10] from do10::@1
|
||||
[16] return
|
||||
to:@return
|
||||
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
hello: scope:[hello] from do10::@1
|
||||
[17] phi()
|
||||
to:hello::@1
|
||||
|
@ -211,7 +211,7 @@ do10::@return: scope:[do10] from do10::@1
|
||||
[16] return
|
||||
to:@return
|
||||
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
hello: scope:[hello] from do10::@1
|
||||
[17] phi()
|
||||
to:hello::@1
|
||||
@ -226,6 +226,7 @@ hello::@return: scope:[hello] from hello::@1
|
||||
[23] return
|
||||
to:@return
|
||||
|
||||
null depth in calling loop Loop head: do10::@1 tails: do10::@1 blocks: do10::@1 in scope hello
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) do10((void()*) do10::fn)
|
||||
@ -233,13 +234,13 @@ VARIABLE REGISTER WEIGHTS
|
||||
(byte) do10::i
|
||||
(byte) do10::i#1 1501.5
|
||||
(byte) do10::i#2 1001.0
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
(byte) hello::i
|
||||
(byte) hello::i#1 1500001.5
|
||||
(byte) hello::i#2 1000001.0
|
||||
(volatile byte) idx loadstore 166666.94444444444
|
||||
(byte) hello::i#1 150001.5
|
||||
(byte) hello::i#2 100001.0
|
||||
(volatile byte) idx loadstore 16666.944444444445
|
||||
(void()) main()
|
||||
(volatile byte*) msg loadstore 142859.0
|
||||
(volatile byte*) msg loadstore 14287.571428571428
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ do10::i#2 do10::i#1 ]
|
||||
@ -338,8 +339,6 @@ do10: {
|
||||
// do10::@1
|
||||
__b1:
|
||||
// [13] call hello
|
||||
// [17] phi from do10::@1 to hello [phi:do10::@1->hello]
|
||||
hello_from___b1:
|
||||
jsr hello
|
||||
// [14] (byte) do10::i#1 ← ++ (byte) do10::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc.z i
|
||||
@ -417,19 +416,19 @@ Potential registers zp[2]:4 [ msg ] : zp[2]:4 ,
|
||||
Potential registers zp[1]:6 [ idx ] : zp[1]:6 ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [hello] 2,500,002.5: zp[1]:3 [ hello::i#2 hello::i#1 ]
|
||||
Uplift Scope [] 166,666.94: zp[1]:6 [ idx ] 142,859: zp[2]:4 [ msg ]
|
||||
Uplift Scope [hello] 250,002.5: zp[1]:3 [ hello::i#2 hello::i#1 ]
|
||||
Uplift Scope [] 16,666.94: zp[1]:6 [ idx ] 14,287.57: zp[2]:4 [ msg ]
|
||||
Uplift Scope [do10] 2,502.5: zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplift Scope [main]
|
||||
|
||||
Uplifting [hello] best 4534 combination reg byte y [ hello::i#2 hello::i#1 ]
|
||||
Uplifting [] best 4534 combination zp[1]:6 [ idx ] zp[2]:4 [ msg ]
|
||||
Uplifting [do10] best 4534 combination zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplifting [main] best 4534 combination
|
||||
Uplifting [hello] best 853 combination reg byte y [ hello::i#2 hello::i#1 ]
|
||||
Uplifting [] best 853 combination zp[1]:6 [ idx ] zp[2]:4 [ msg ]
|
||||
Uplifting [do10] best 853 combination zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplifting [main] best 853 combination
|
||||
Attempting to uplift remaining variables inzp[1]:6 [ idx ]
|
||||
Uplifting [] best 4534 combination zp[1]:6 [ idx ]
|
||||
Uplifting [] best 853 combination zp[1]:6 [ idx ]
|
||||
Attempting to uplift remaining variables inzp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplifting [do10] best 4534 combination zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Uplifting [do10] best 853 combination zp[1]:2 [ do10::i#2 do10::i#1 ]
|
||||
Allocated (was zp[2]:4) zp[2]:3 [ msg ]
|
||||
Allocated (was zp[1]:6) zp[1]:5 [ idx ]
|
||||
|
||||
@ -514,8 +513,6 @@ do10: {
|
||||
// do10::@1
|
||||
__b1:
|
||||
// [13] call hello
|
||||
// [17] phi from do10::@1 to hello [phi:do10::@1->hello]
|
||||
hello_from___b1:
|
||||
jsr hello
|
||||
// [14] (byte) do10::i#1 ← ++ (byte) do10::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc.z i
|
||||
@ -586,7 +583,6 @@ Removing instruction __b1:
|
||||
Removing instruction __b2_from___b1:
|
||||
Removing instruction __bend_from___b2:
|
||||
Removing instruction __b1_from___b1:
|
||||
Removing instruction hello_from___b1:
|
||||
Removing instruction __b1_from___b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction __b2:
|
||||
@ -619,17 +615,17 @@ FINAL SYMBOL TABLE
|
||||
(byte) do10::i
|
||||
(byte) do10::i#1 i zp[1]:2 1501.5
|
||||
(byte) do10::i#2 i zp[1]:2 1001.0
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
(label) hello::@1
|
||||
(label) hello::@return
|
||||
(byte) hello::i
|
||||
(byte) hello::i#1 reg byte y 1500001.5
|
||||
(byte) hello::i#2 reg byte y 1000001.0
|
||||
(volatile byte) idx loadstore zp[1]:5 166666.94444444444
|
||||
(byte) hello::i#1 reg byte y 150001.5
|
||||
(byte) hello::i#2 reg byte y 100001.0
|
||||
(volatile byte) idx loadstore zp[1]:5 16666.944444444445
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(volatile byte*) msg loadstore zp[2]:3 142859.0
|
||||
(volatile byte*) msg loadstore zp[2]:3 14287.571428571428
|
||||
(const to_nomodify byte*) msg1[] = (byte*) "hello "
|
||||
(const to_nomodify byte*) msg2[] = (byte*) "world "
|
||||
|
||||
@ -640,7 +636,7 @@ zp[1]:5 [ idx ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 3504
|
||||
Score: 633
|
||||
|
||||
// File Comments
|
||||
// Tests calling into a function pointer with local variables
|
||||
@ -711,7 +707,6 @@ do10: {
|
||||
__b1:
|
||||
// (*fn)()
|
||||
// [13] call hello
|
||||
// [17] phi from do10::@1 to hello [phi:do10::@1->hello]
|
||||
jsr hello
|
||||
// for( byte i: 0..9)
|
||||
// [14] (byte) do10::i#1 ← ++ (byte) do10::i#2 -- vbuz1=_inc_vbuz1
|
||||
|
@ -10,17 +10,17 @@
|
||||
(byte) do10::i
|
||||
(byte) do10::i#1 i zp[1]:2 1501.5
|
||||
(byte) do10::i#2 i zp[1]:2 1001.0
|
||||
(void()) hello()
|
||||
__stackcall (void()) hello()
|
||||
(label) hello::@1
|
||||
(label) hello::@return
|
||||
(byte) hello::i
|
||||
(byte) hello::i#1 reg byte y 1500001.5
|
||||
(byte) hello::i#2 reg byte y 1000001.0
|
||||
(volatile byte) idx loadstore zp[1]:5 166666.94444444444
|
||||
(byte) hello::i#1 reg byte y 150001.5
|
||||
(byte) hello::i#2 reg byte y 100001.0
|
||||
(volatile byte) idx loadstore zp[1]:5 16666.944444444445
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(volatile byte*) msg loadstore zp[2]:3 142859.0
|
||||
(volatile byte*) msg loadstore zp[2]:3 14287.571428571428
|
||||
(const to_nomodify byte*) msg1[] = (byte*) "hello "
|
||||
(const to_nomodify byte*) msg2[] = (byte*) "world "
|
||||
|
||||
|
@ -20,7 +20,7 @@ main::@return: scope:[main] from main
|
||||
[9] return
|
||||
to:@return
|
||||
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
fn1: scope:[fn1] from main
|
||||
[10] (volatile byte) idx ← ++ (volatile byte) idx
|
||||
to:fn1::@return
|
||||
|
@ -87,7 +87,7 @@ main::@return: scope:[main] from main
|
||||
[9] return
|
||||
to:@return
|
||||
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
fn1: scope:[fn1] from main
|
||||
[10] (volatile byte) idx ← ++ (volatile byte) idx
|
||||
to:fn1::@return
|
||||
@ -97,7 +97,7 @@ fn1::@return: scope:[fn1] from fn1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(volatile byte) idx loadstore 28.25
|
||||
(void()) main()
|
||||
|
||||
@ -270,7 +270,7 @@ FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const nomodify byte*) SCREEN = (byte*) 1024
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(label) fn1::@return
|
||||
(volatile byte) idx loadstore zp[1]:2 28.25
|
||||
(void()) main()
|
||||
|
@ -2,7 +2,7 @@
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const nomodify byte*) SCREEN = (byte*) 1024
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(label) fn1::@return
|
||||
(volatile byte) idx loadstore zp[1]:2 28.25
|
||||
(void()) main()
|
||||
|
@ -17,7 +17,7 @@ main::@return: scope:[main] from main
|
||||
[6] return
|
||||
to:@return
|
||||
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
fn1: scope:[fn1] from main
|
||||
[7] *((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR)
|
||||
to:fn1::@return
|
||||
|
@ -80,7 +80,7 @@ main::@return: scope:[main] from main
|
||||
[6] return
|
||||
to:@return
|
||||
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
fn1: scope:[fn1] from main
|
||||
[7] *((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR)
|
||||
to:fn1::@return
|
||||
@ -90,7 +90,7 @@ fn1::@return: scope:[fn1] from fn1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(void()) main()
|
||||
|
||||
Initial phi equivalence classes
|
||||
@ -225,7 +225,7 @@ FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(label) fn1::@return
|
||||
(const nomodify byte*) fn1::BORDER_COLOR = (byte*) 53280
|
||||
(void()) main()
|
||||
|
@ -1,7 +1,7 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) fn1()
|
||||
__stackcall (void()) fn1()
|
||||
(label) fn1::@return
|
||||
(const nomodify byte*) fn1::BORDER_COLOR = (byte*) 53280
|
||||
(void()) main()
|
||||
|
Loading…
Reference in New Issue
Block a user