From 9c6e67ddc5295f840228d8a2696a0649088e7e9c Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 19 Apr 2020 11:53:15 +0200 Subject: [PATCH] Printf tests rewritten to use inline struct constructors. --- .../java/dk/camelot64/kickc/Compiler.java | 2 +- ...lue.java => Pass1PrepareUnwindStruct.java} | 31 +- .../dk/camelot64/kickc/test/TestPrograms.java | 5 + src/test/kc/printf-1.c | 12 +- src/test/kc/printf-2.c | 20 +- .../kc/problem-struct-inline-parameter-1.c | 19 + src/test/ref/printf-1.asm | 11 +- src/test/ref/printf-1.cfg | 2 +- src/test/ref/printf-1.log | 190 +++----- src/test/ref/printf-1.sym | 3 - src/test/ref/printf-2.asm | 15 +- src/test/ref/printf-2.cfg | 6 +- src/test/ref/printf-2.log | 346 +++++--------- src/test/ref/printf-2.sym | 8 +- .../ref/problem-struct-inline-parameter-1.asm | 27 ++ .../ref/problem-struct-inline-parameter-1.cfg | 28 ++ .../ref/problem-struct-inline-parameter-1.log | 443 ++++++++++++++++++ .../ref/problem-struct-inline-parameter-1.sym | 19 + 18 files changed, 790 insertions(+), 397 deletions(-) rename src/main/java/dk/camelot64/kickc/passes/{Pass1ConstantifyRValue.java => Pass1PrepareUnwindStruct.java} (55%) create mode 100644 src/test/kc/problem-struct-inline-parameter-1.c create mode 100644 src/test/ref/problem-struct-inline-parameter-1.asm create mode 100644 src/test/ref/problem-struct-inline-parameter-1.cfg create mode 100644 src/test/ref/problem-struct-inline-parameter-1.log create mode 100644 src/test/ref/problem-struct-inline-parameter-1.sym diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index cb2011f12..1365032d4 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -280,7 +280,7 @@ public class Compiler { new PassNAssertTypeMatch(program).check(); - new Pass1ConstantifyRValue(program).execute(); + new Pass1PrepareUnwindStruct(program).execute(); new Pass1UnwindStructVariables(program).execute(); new Pass1UnwindStructValues(program).execute(); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1ConstantifyRValue.java b/src/main/java/dk/camelot64/kickc/passes/Pass1PrepareUnwindStruct.java similarity index 55% rename from src/main/java/dk/camelot64/kickc/passes/Pass1ConstantifyRValue.java rename to src/main/java/dk/camelot64/kickc/passes/Pass1PrepareUnwindStruct.java index d50a58676..e2694ba63 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1ConstantifyRValue.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1PrepareUnwindStruct.java @@ -5,18 +5,24 @@ import dk.camelot64.kickc.model.Initializers; import dk.camelot64.kickc.model.Program; import dk.camelot64.kickc.model.statements.Statement; import dk.camelot64.kickc.model.statements.StatementAssignment; +import dk.camelot64.kickc.model.statements.StatementCall; +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.SymbolTypeInference; import dk.camelot64.kickc.model.types.SymbolTypeStruct; -import dk.camelot64.kickc.model.values.ConstantValue; -import dk.camelot64.kickc.model.values.RValue; +import dk.camelot64.kickc.model.values.*; + +import java.util.List; /** - * Constantify all assignment RValues that are structs + * Prepare structs for unwinding. + * - Constantify all assignment RValues that are structs + * - Add casts to struct parameter values in calls */ -public class Pass1ConstantifyRValue extends Pass2SsaOptimization { +public class Pass1PrepareUnwindStruct extends Pass2SsaOptimization { - public Pass1ConstantifyRValue(Program program) { + public Pass1PrepareUnwindStruct(Program program) { super(program); } @@ -41,6 +47,21 @@ public class Pass1ConstantifyRValue extends Pass2SsaOptimization { } } + if(statement instanceof StatementCall) { + final StatementCall call = (StatementCall) statement; + final Procedure procedure = getScope().getProcedure(call.getProcedure()); + final List paramDefs = procedure.getParameters(); + final List paramVals = call.getParameters(); + for(int i=0;istr @@ -33,7 +32,7 @@ main: { jsr printf_string // printf_ln() jsr printf_ln - // printf_string( "rules", format) + // printf_string( "rules", { 10, 0 } ) lda #str1 @@ -43,7 +42,7 @@ main: { jsr printf_string // printf_ln() jsr printf_ln - // printf_string( "cml", format) + // printf_string( "cml", { 10, 1 } ) lda #str @@ -53,7 +52,7 @@ main: { jsr printf_string // printf_ln() jsr printf_ln - // printf_string( "rules", format) + // printf_string( "rules", { 10, 1 } ) lda #str1 @@ -88,7 +87,7 @@ printf_string: { // padding = (signed char)format.min_length - len eor #$ff clc - adc #main.format_min_length+1 + adc #$a+1 sta.z padding // if(padding<0) cmp #0 diff --git a/src/test/ref/printf-1.cfg b/src/test/ref/printf-1.cfg index 72ba5327b..5b5687c1a 100644 --- a/src/test/ref/printf-1.cfg +++ b/src/test/ref/printf-1.cfg @@ -62,7 +62,7 @@ printf_string::@3: scope:[printf_string] from printf_string printf_string::@6: scope:[printf_string] from printf_string::@3 [27] (word~) printf_string::$9 ← (word) strlen::return#2 [28] (signed byte) printf_string::len#0 ← (signed byte)(word~) printf_string::$9 - [29] (signed byte) printf_string::padding#1 ← (signed byte)(const byte) main::format_min_length#1 - (signed byte) printf_string::len#0 + [29] (signed byte) printf_string::padding#1 ← (signed byte) $a - (signed byte) printf_string::len#0 [30] if((signed byte) printf_string::padding#1>=(signed byte) 0) goto printf_string::@10 to:printf_string::@1 printf_string::@10: scope:[printf_string] from printf_string::@6 diff --git a/src/test/ref/printf-1.log b/src/test/ref/printf-1.log index 9e726ab2a..f4cd33592 100644 --- a/src/test/ref/printf-1.log +++ b/src/test/ref/printf-1.log @@ -7,6 +7,10 @@ Fixing pointer addition (word*~) bsearch16u::$13 ← (word*) bsearch16u::pivot + Fixing pointer addition (word*~) bsearch16u::$1 ← (word*) bsearch16u::items - (number) 1 Fixing pointer array-indexing *((word*) utoa::digit_values + (byte) utoa::digit) Fixing pointer array-indexing *((dword*) ultoa::digit_values + (byte) ultoa::digit) +Added struct type cast to parameter value list (void~) main::$1 ← call printf_string (byte*) "cml" (struct printf_format_string){ (number) $a, (number) 0 } +Added struct type cast to parameter value list (void~) main::$3 ← call printf_string (byte*) "rules" (struct printf_format_string){ (number) $a, (number) 0 } +Added struct type cast to parameter value list (void~) main::$5 ← call printf_string (byte*) "cml" (struct printf_format_string){ (number) $a, (number) 1 } +Added struct type cast to parameter value list (void~) main::$7 ← call printf_string (byte*) "rules" (struct printf_format_string){ (number) $a, (number) 1 } Created struct value member variable (byte) printf_slong::format_min_length Created struct value member variable (byte) printf_slong::format_justify_left Created struct value member variable (byte) printf_slong::format_sign_always @@ -55,9 +59,6 @@ Converted struct value to member variables (struct printf_format_number) printf_ Created struct value member variable (byte) printf_string::format_min_length Created struct value member variable (byte) printf_string::format_justify_left Converted struct value to member variables (struct printf_format_string) printf_string::format -Created struct value member variable (byte) main::format_min_length -Created struct value member variable (byte) main::format_justify_left -Converted struct value to member variables (struct printf_format_string) main::format Converted procedure struct value parameter to member unwinding (void()) printf_slong((signed dword) printf_slong::value , (byte) printf_slong::format_min_length , (byte) printf_slong::format_justify_left , (byte) printf_slong::format_sign_always , (byte) printf_slong::format_zero_padding , (byte) printf_slong::format_radix) Converted procedure struct value parameter to member unwinding (void()) printf_ulong((dword) printf_ulong::uvalue , (byte) printf_ulong::format_min_length , (byte) printf_ulong::format_justify_left , (byte) printf_ulong::format_sign_always , (byte) printf_ulong::format_zero_padding , (byte) printf_ulong::format_radix) Converted procedure struct value parameter to member unwinding (void()) printf_sint((signed word) printf_sint::value , (byte) printf_sint::format_min_length , (byte) printf_sint::format_justify_left , (byte) printf_sint::format_sign_always , (byte) printf_sint::format_zero_padding , (byte) printf_sint::format_radix) @@ -72,13 +73,10 @@ Converted call struct value parameter to member unwinding (void~) printf_sint::$ Converted call struct value parameter to member unwinding (void~) printf_uint::$4 ← call printf_number_buffer *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS (byte) printf_uint::format_min_length (byte) printf_uint::format_justify_left (byte) printf_uint::format_sign_always (byte) printf_uint::format_zero_padding (byte) printf_uint::format_radix Converted call struct value parameter to member unwinding (void~) printf_schar::$2 ← call printf_number_buffer *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS (byte) printf_schar::format_min_length (byte) printf_schar::format_justify_left (byte) printf_schar::format_sign_always (byte) printf_schar::format_zero_padding (byte) printf_schar::format_radix Converted call struct value parameter to member unwinding (void~) printf_uchar::$4 ← call printf_number_buffer *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS (byte) printf_uchar::format_min_length (byte) printf_uchar::format_justify_left (byte) printf_uchar::format_sign_always (byte) printf_uchar::format_zero_padding (byte) printf_uchar::format_radix -Unwinding value copy (struct printf_format_string) main::format ← {} -Adding value simple copy (byte) main::format_min_length ← (byte) 0 -Adding value simple copy (byte) main::format_justify_left ← (byte) 0 -Converted call struct value parameter to member unwinding (void~) main::$1 ← call printf_string (byte*) "cml" (byte) main::format_min_length (byte) main::format_justify_left -Converted call struct value parameter to member unwinding (void~) main::$3 ← call printf_string (byte*) "rules" (byte) main::format_min_length (byte) main::format_justify_left -Converted call struct value parameter to member unwinding (void~) main::$5 ← call printf_string (byte*) "cml" (byte) main::format_min_length (byte) main::format_justify_left -Converted call struct value parameter to member unwinding (void~) main::$7 ← call printf_string (byte*) "rules" (byte) main::format_min_length (byte) main::format_justify_left +Converted call struct value parameter to member unwinding (void~) main::$1 ← call printf_string (byte*) "cml" (number) $a (number) 0 +Converted call struct value parameter to member unwinding (void~) main::$3 ← call printf_string (byte*) "rules" (number) $a (number) 0 +Converted call struct value parameter to member unwinding (void~) main::$5 ← call printf_string (byte*) "cml" (number) $a (number) 1 +Converted call struct value parameter to member unwinding (void~) main::$7 ← call printf_string (byte*) "rules" (number) $a (number) 1 Replacing struct member reference (struct printf_buffer_number) printf_buffer.sign with member unwinding reference *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) Replacing struct member reference (struct printf_buffer_number) printf_buffer.sign with member unwinding reference *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) Replacing struct member reference (struct printf_format_number) printf_slong::format.sign_always with member unwinding reference (byte) printf_slong::format_sign_always @@ -125,9 +123,6 @@ Replacing struct member reference (struct printf_format_string) printf_string::f Replacing struct member reference (struct printf_format_string) printf_string::format.justify_left with member unwinding reference (byte) printf_string::format_justify_left Replacing struct member reference (struct printf_format_string) printf_string::format.min_length with member unwinding reference (byte) printf_string::format_min_length Replacing struct member reference (struct printf_format_string) printf_string::format.justify_left with member unwinding reference (byte) printf_string::format_justify_left -Replacing struct member reference (struct printf_format_string) main::format.min_length with member unwinding reference (byte) main::format_min_length -Replacing struct member reference (struct printf_format_string) main::format.justify_left with member unwinding reference (byte) main::format_justify_left -Replacing struct member reference (struct printf_format_string) main::format.justify_left with member unwinding reference (byte) main::format_justify_left De-inlining cast (byte*)memcpy::source De-inlining cast (word)memmove::destination De-inlining cast (word)memmove::source @@ -540,51 +535,36 @@ main: scope:[main] from @29 call printf_cls to:main::@1 main::@1: scope:[main] from main - (byte) main::format_min_length#0 ← (byte) 0 - (byte) main::format_justify_left#0 ← (byte) 0 - (byte) main::format_min_length#1 ← (number) $a - (byte) main::format_justify_left#1 ← (number) 0 (byte*) printf_string::str#0 ← (const byte*) main::str - (byte) printf_string::format_min_length#0 ← (byte) main::format_min_length#1 - (byte) printf_string::format_justify_left#0 ← (byte) main::format_justify_left#1 + (byte) printf_string::format_min_length#0 ← (number) $a + (byte) printf_string::format_justify_left#0 ← (number) 0 call printf_string to:main::@2 main::@2: scope:[main] from main::@1 - (byte) main::format_justify_left#5 ← phi( main::@1/(byte) main::format_justify_left#1 ) - (byte) main::format_min_length#5 ← phi( main::@1/(byte) main::format_min_length#1 ) call printf_ln to:main::@3 main::@3: scope:[main] from main::@2 - (byte) main::format_justify_left#3 ← phi( main::@2/(byte) main::format_justify_left#5 ) - (byte) main::format_min_length#2 ← phi( main::@2/(byte) main::format_min_length#5 ) (byte*) printf_string::str#1 ← (const byte*) main::str1 - (byte) printf_string::format_min_length#1 ← (byte) main::format_min_length#2 - (byte) printf_string::format_justify_left#1 ← (byte) main::format_justify_left#3 + (byte) printf_string::format_min_length#1 ← (number) $a + (byte) printf_string::format_justify_left#1 ← (number) 0 call printf_string to:main::@4 main::@4: scope:[main] from main::@3 - (byte) main::format_min_length#6 ← phi( main::@3/(byte) main::format_min_length#2 ) call printf_ln to:main::@5 main::@5: scope:[main] from main::@4 - (byte) main::format_min_length#3 ← phi( main::@4/(byte) main::format_min_length#6 ) - (byte) main::format_justify_left#2 ← (number) 1 (byte*) printf_string::str#2 ← (const byte*) main::str2 - (byte) printf_string::format_min_length#2 ← (byte) main::format_min_length#3 - (byte) printf_string::format_justify_left#2 ← (byte) main::format_justify_left#2 + (byte) printf_string::format_min_length#2 ← (number) $a + (byte) printf_string::format_justify_left#2 ← (number) 1 call printf_string to:main::@6 main::@6: scope:[main] from main::@5 - (byte) main::format_justify_left#6 ← phi( main::@5/(byte) main::format_justify_left#2 ) - (byte) main::format_min_length#7 ← phi( main::@5/(byte) main::format_min_length#3 ) call printf_ln to:main::@7 main::@7: scope:[main] from main::@6 - (byte) main::format_justify_left#4 ← phi( main::@6/(byte) main::format_justify_left#6 ) - (byte) main::format_min_length#4 ← phi( main::@6/(byte) main::format_min_length#7 ) (byte*) printf_string::str#3 ← (const byte*) main::str3 - (byte) printf_string::format_min_length#3 ← (byte) main::format_min_length#4 - (byte) printf_string::format_justify_left#3 ← (byte) main::format_justify_left#4 + (byte) printf_string::format_min_length#3 ← (number) $a + (byte) printf_string::format_justify_left#3 ← (number) 1 call printf_string to:main::@8 main::@8: scope:[main] from main::@7 @@ -619,23 +599,6 @@ SYMBOL TABLE SSA (label) main::@7 (label) main::@8 (label) main::@return -(byte) main::format_justify_left -(byte) main::format_justify_left#0 -(byte) main::format_justify_left#1 -(byte) main::format_justify_left#2 -(byte) main::format_justify_left#3 -(byte) main::format_justify_left#4 -(byte) main::format_justify_left#5 -(byte) main::format_justify_left#6 -(byte) main::format_min_length -(byte) main::format_min_length#0 -(byte) main::format_min_length#1 -(byte) main::format_min_length#2 -(byte) main::format_min_length#3 -(byte) main::format_min_length#4 -(byte) main::format_min_length#5 -(byte) main::format_min_length#6 -(byte) main::format_min_length#7 (const byte*) main::str[(byte) 4] = (byte*) "cml" (const byte*) main::str1[(byte) 6] = (byte*) "rules" (const byte*) main::str2[(byte) 4] = (byte*) "cml" @@ -914,9 +877,14 @@ Adding number conversion cast (unumber) 0 in (bool~) printf_string::$14 ← (num Adding number conversion cast (unumber) 0 in (bool~) printf_string::$15 ← (number) 0 != (byte) printf_string::format_justify_left#4 Adding number conversion cast (snumber) 0 in (bool~) printf_string::$11 ← (signed byte) printf_string::padding#1 < (number) 0 Adding number conversion cast (snumber) 0 in (signed byte) printf_string::padding#2 ← (number) 0 -Adding number conversion cast (unumber) $a in (byte) main::format_min_length#1 ← (number) $a -Adding number conversion cast (unumber) 0 in (byte) main::format_justify_left#1 ← (number) 0 -Adding number conversion cast (unumber) 1 in (byte) main::format_justify_left#2 ← (number) 1 +Adding number conversion cast (unumber) $a in (byte) printf_string::format_min_length#0 ← (number) $a +Adding number conversion cast (unumber) 0 in (byte) printf_string::format_justify_left#0 ← (number) 0 +Adding number conversion cast (unumber) $a in (byte) printf_string::format_min_length#1 ← (number) $a +Adding number conversion cast (unumber) 0 in (byte) printf_string::format_justify_left#1 ← (number) 0 +Adding number conversion cast (unumber) $a in (byte) printf_string::format_min_length#2 ← (number) $a +Adding number conversion cast (unumber) 1 in (byte) printf_string::format_justify_left#2 ← (number) 1 +Adding number conversion cast (unumber) $a in (byte) printf_string::format_min_length#3 ← (number) $a +Adding number conversion cast (unumber) 1 in (byte) printf_string::format_justify_left#3 ← (number) 1 Successful SSA optimization PassNAddNumberTypeConversions Inlining cast (byte*) memcpy::src#0 ← (byte*)(void*) memcpy::source#1 Inlining cast (byte*) memcpy::dst#0 ← (byte*)(void*) memcpy::destination#1 @@ -925,9 +893,14 @@ Inlining cast (word) memset::num#0 ← (unumber)(number) $28*(number) $19 Inlining cast (word) memcpy::num#0 ← (unumber)(number) $28*(number) $19-(number) $28 Inlining cast (word) memset::num#1 ← (unumber)(number) $28 Inlining cast (signed byte) printf_string::padding#2 ← (snumber)(number) 0 -Inlining cast (byte) main::format_min_length#1 ← (unumber)(number) $a -Inlining cast (byte) main::format_justify_left#1 ← (unumber)(number) 0 -Inlining cast (byte) main::format_justify_left#2 ← (unumber)(number) 1 +Inlining cast (byte) printf_string::format_min_length#0 ← (unumber)(number) $a +Inlining cast (byte) printf_string::format_justify_left#0 ← (unumber)(number) 0 +Inlining cast (byte) printf_string::format_min_length#1 ← (unumber)(number) $a +Inlining cast (byte) printf_string::format_justify_left#1 ← (unumber)(number) 0 +Inlining cast (byte) printf_string::format_min_length#2 ← (unumber)(number) $a +Inlining cast (byte) printf_string::format_justify_left#2 ← (unumber)(number) 1 +Inlining cast (byte) printf_string::format_min_length#3 ← (unumber)(number) $a +Inlining cast (byte) printf_string::format_justify_left#3 ← (unumber)(number) 1 Successful SSA optimization Pass2InlineCast Simplifying constant pointer cast (byte*) 1024 Simplifying constant integer cast 0 @@ -946,6 +919,11 @@ Simplifying constant integer cast 0 Simplifying constant integer cast 0 Simplifying constant integer cast $a Simplifying constant integer cast 0 +Simplifying constant integer cast $a +Simplifying constant integer cast 0 +Simplifying constant integer cast $a +Simplifying constant integer cast 1 +Simplifying constant integer cast $a Simplifying constant integer cast 1 Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) 0 @@ -962,6 +940,11 @@ Finalized signed number type (signed byte) 0 Finalized signed number type (signed byte) 0 Finalized unsigned number type (byte) $a Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $a +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $a +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) $a Finalized unsigned number type (byte) 1 Successful SSA optimization PassNFinalizeNumberTypeConversions Inversing boolean not [20] (bool~) memset::$1 ← (word) memset::num#2 <= (byte) 0 from [19] (bool~) memset::$0 ← (word) memset::num#2 > (byte) 0 @@ -1001,9 +984,6 @@ Alias printf_string::padding#4 = printf_string::padding#7 printf_string::padding Alias printf_string::padding#3 = printf_string::padding#5 printf_string::padding#8 Alias printf_string::str#11 = printf_string::str#7 printf_string::str#8 Alias printf_string::format_justify_left#11 = printf_string::format_justify_left#12 printf_string::format_justify_left#4 -Alias main::format_min_length#1 = main::format_min_length#5 main::format_min_length#2 main::format_min_length#6 main::format_min_length#3 main::format_min_length#7 main::format_min_length#4 -Alias main::format_justify_left#1 = main::format_justify_left#5 main::format_justify_left#3 -Alias main::format_justify_left#2 = main::format_justify_left#6 main::format_justify_left#4 Successful SSA optimization Pass2AliasElimination Alias candidate removed (volatile)printf_char_cursor = printf_char::$8 Alias printf_string::format_justify_left#10 = printf_string::format_justify_left#11 printf_string::format_justify_left#5 @@ -1069,27 +1049,22 @@ Constant (const signed byte) printf_string::padding#0 = 0 Constant (const signed byte) printf_string::padding#2 = 0 Constant (const byte) printf_padding::pad#0 = ' ' Constant (const byte) printf_padding::pad#1 = ' ' -Constant (const byte) main::format_min_length#0 = 0 -Constant (const byte) main::format_justify_left#0 = 0 -Constant (const byte) main::format_min_length#1 = $a -Constant (const byte) main::format_justify_left#1 = 0 Constant (const byte*) printf_string::str#0 = main::str +Constant (const byte) printf_string::format_min_length#0 = $a +Constant (const byte) printf_string::format_justify_left#0 = 0 Constant (const byte*) printf_string::str#1 = main::str1 -Constant (const byte) main::format_justify_left#2 = 1 +Constant (const byte) printf_string::format_min_length#1 = $a +Constant (const byte) printf_string::format_justify_left#1 = 0 Constant (const byte*) printf_string::str#2 = main::str2 +Constant (const byte) printf_string::format_min_length#2 = $a +Constant (const byte) printf_string::format_justify_left#2 = 1 Constant (const byte*) printf_string::str#3 = main::str3 +Constant (const byte) printf_string::format_min_length#3 = $a +Constant (const byte) printf_string::format_justify_left#3 = 1 Successful SSA optimization Pass2ConstantIdentification Constant (const byte*) memcpy::dst#0 = (byte*)memcpy::destination#0 Constant (const void*) memcpy::source#0 = (void*)printf_char::$3 Constant (const void*) memcpy::return#2 = memcpy::destination#0 -Constant (const byte) printf_string::format_min_length#0 = main::format_min_length#1 -Constant (const byte) printf_string::format_justify_left#0 = main::format_justify_left#1 -Constant (const byte) printf_string::format_min_length#1 = main::format_min_length#1 -Constant (const byte) printf_string::format_justify_left#1 = main::format_justify_left#1 -Constant (const byte) printf_string::format_min_length#2 = main::format_min_length#1 -Constant (const byte) printf_string::format_justify_left#2 = main::format_justify_left#2 -Constant (const byte) printf_string::format_min_length#3 = main::format_min_length#1 -Constant (const byte) printf_string::format_justify_left#3 = main::format_justify_left#2 Successful SSA optimization Pass2ConstantIdentification Constant (const byte*) memcpy::src#0 = (byte*)memcpy::source#0 Constant (const byte*) memcpy::$2 = (byte*)memcpy::source#0 @@ -1100,8 +1075,6 @@ Successful SSA optimization Pass2ConstantStringConsolidation Eliminating unused variable (void*) memset::return#2 and assignment [25] (void*) memset::return#2 ← (void*) memset::str#3 Eliminating unused variable (void*) memset::return#3 and assignment [37] (void*) memset::return#3 ← (void*) memset::str#3 Eliminating unused constant (const void*) memcpy::return#2 -Eliminating unused constant (const byte) main::format_min_length#0 -Eliminating unused constant (const byte) main::format_justify_left#0 Successful SSA optimization PassNEliminateUnusedVars Adding number conversion cast (unumber) 0 in (bool~) printf_string::$16 ← (number) 0 != (byte) printf_string::format_justify_left#10 Adding number conversion cast (snumber) 0 in (bool~) printf_string::$17 ← (number) 0 != (signed byte) printf_string::padding#3 @@ -1152,30 +1125,28 @@ Inlining constant with var siblings (const byte) printf_padding::pad#1 Inlining constant with var siblings (const signed byte) printf_string::padding#0 Inlining constant with var siblings (const signed byte) printf_string::padding#2 Inlining constant with var siblings (const byte*) printf_string::str#0 -Inlining constant with var siblings (const byte*) printf_string::str#1 -Inlining constant with var siblings (const byte*) printf_string::str#2 -Inlining constant with var siblings (const byte*) printf_string::str#3 Inlining constant with var siblings (const byte) printf_string::format_min_length#0 Inlining constant with var siblings (const byte) printf_string::format_justify_left#0 +Inlining constant with var siblings (const byte*) printf_string::str#1 Inlining constant with var siblings (const byte) printf_string::format_min_length#1 Inlining constant with var siblings (const byte) printf_string::format_justify_left#1 +Inlining constant with var siblings (const byte*) printf_string::str#2 Inlining constant with var siblings (const byte) printf_string::format_min_length#2 Inlining constant with var siblings (const byte) printf_string::format_justify_left#2 +Inlining constant with var siblings (const byte*) printf_string::str#3 Inlining constant with var siblings (const byte) printf_string::format_min_length#3 Inlining constant with var siblings (const byte) printf_string::format_justify_left#3 -Inlining constant with different constant siblings (const byte) main::format_justify_left#1 -Inlining constant with different constant siblings (const byte) main::format_justify_left#2 Constant inlined memcpy::dst#0 = (byte*)(const void*) memcpy::destination#0 Constant inlined main::str2 = (const byte*) main::str Constant inlined main::str3 = (const byte*) main::str1 -Constant inlined printf_string::format_min_length#3 = (const byte) main::format_min_length#1 +Constant inlined printf_string::format_min_length#3 = (byte) $a Constant inlined memset::num#1 = (byte) $28 Constant inlined memcpy::src#0 = (byte*)(const void*) memcpy::source#0 Constant inlined memset::num#0 = (word)(number) $28*(number) $19 -Constant inlined printf_string::format_min_length#0 = (const byte) main::format_min_length#1 Constant inlined strlen::len#0 = (word) 0 -Constant inlined printf_string::format_min_length#1 = (const byte) main::format_min_length#1 -Constant inlined printf_string::format_min_length#2 = (const byte) main::format_min_length#1 +Constant inlined printf_string::format_min_length#0 = (byte) $a +Constant inlined printf_string::format_min_length#1 = (byte) $a +Constant inlined printf_string::format_min_length#2 = (byte) $a Constant inlined printf_string::str#0 = (const byte*) main::str Constant inlined memcpy::$2 = (byte*)(const void*) memcpy::source#0 Constant inlined printf_string::str#3 = (const byte*) main::str1 @@ -1193,22 +1164,23 @@ Constant inlined printf_char::$5 = (const byte*) printf_screen+(word)(number) $2 Constant inlined printf_string::padding#0 = (signed byte) 0 Constant inlined printf_string::padding#2 = (signed byte) 0 Constant inlined memset::c#0 = (byte) ' ' -Constant inlined main::format_justify_left#2 = (byte) 1 -Constant inlined printf_string::format_justify_left#1 = (byte) 0 Constant inlined memset::c#1 = (byte) ' ' -Constant inlined main::format_justify_left#1 = (byte) 0 +Constant inlined printf_string::format_justify_left#1 = (byte) 0 Constant inlined printf_string::format_justify_left#0 = (byte) 0 Constant inlined printf_string::format_justify_left#3 = (byte) 1 Constant inlined printf_string::format_justify_left#2 = (byte) 1 Successful SSA optimization Pass2ConstantInlining Alias candidate removed (volatile)printf_char_cursor = printf_char::$8 -Identical Phi Values (byte) printf_string::format_min_length#4 (const byte) main::format_min_length#1 +Identical Phi Values (byte) printf_string::format_min_length#4 (byte) $a Successful SSA optimization Pass2IdenticalPhiElimination -Constant value identified (signed byte)main::format_min_length#1 in [61] (signed byte) printf_string::padding#1 ← (signed byte)(const byte) main::format_min_length#1 - (signed byte) printf_string::len#0 +Constant value identified (signed byte)$a in [61] (signed byte) printf_string::padding#1 ← (signed byte)(byte) $a - (signed byte) printf_string::len#0 Successful SSA optimization Pass2ConstantValues Removing PHI-reference to removed block (printf_string) in block printf_string::@1 -if() condition always false - eliminating [53] if((byte) 0==(const byte) main::format_min_length#1) goto printf_string::@1 +if() condition always false - eliminating [53] if((byte) 0==(byte) $a) goto printf_string::@1 Successful SSA optimization Pass2ConstantIfs +Simplifying constant integer cast $a +Successful SSA optimization PassNCastSimplification +Alias candidate removed (volatile)printf_char_cursor = printf_char::$8 Alias candidate removed (volatile)printf_char_cursor = printf_char::$8 Added new block during phi lifting printf_string::@15(between printf_string::@9 and printf_string::@1) Adding NOP phi() at start of @begin @@ -1371,7 +1343,7 @@ printf_string::@3: scope:[printf_string] from printf_string printf_string::@6: scope:[printf_string] from printf_string::@3 [27] (word~) printf_string::$9 ← (word) strlen::return#2 [28] (signed byte) printf_string::len#0 ← (signed byte)(word~) printf_string::$9 - [29] (signed byte) printf_string::padding#1 ← (signed byte)(const byte) main::format_min_length#1 - (signed byte) printf_string::len#0 + [29] (signed byte) printf_string::padding#1 ← (signed byte) $a - (signed byte) printf_string::len#0 [30] if((signed byte) printf_string::padding#1>=(signed byte) 0) goto printf_string::@10 to:printf_string::@1 printf_string::@10: scope:[printf_string] from printf_string::@6 @@ -1560,8 +1532,6 @@ null depth in calling loop Loop head: printf_str::@1 tails: printf_str::@3 block VARIABLE REGISTER WEIGHTS (void()) main() -(byte) main::format_justify_left -(byte) main::format_min_length (void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num) (void*) memcpy::destination (byte*) memcpy::dst @@ -1761,7 +1731,6 @@ __bend_from___b2: __bend: // main main: { - .label format_min_length = $a // [7] call printf_cls // [97] phi from main to printf_cls [phi:main->printf_cls] printf_cls_from_main: @@ -1909,8 +1878,8 @@ printf_string: { // [28] (signed byte) printf_string::len#0 ← (signed byte)(word~) printf_string::$9 -- vbsz1=_sbyte_vwuz2 lda.z __9 sta.z len - // [29] (signed byte) printf_string::padding#1 ← (signed byte)(const byte) main::format_min_length#1 - (signed byte) printf_string::len#0 -- vbsz1=vbsc1_minus_vbsz2 - lda #main.format_min_length + // [29] (signed byte) printf_string::padding#1 ← (signed byte) $a - (signed byte) printf_string::len#0 -- vbsz1=vbsc1_minus_vbsz2 + lda #$a sec sbc.z len sta.z padding @@ -2429,7 +2398,7 @@ Removing always clobbered register reg byte a as potential for zp[1]:2 [ printf_ Statement [26] (word) strlen::return#2 ← (word) strlen::len#2 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] { { strlen::str#1 = printf_string::str#10 } { strlen::return#2 = strlen::len#2 } } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] { { strlen::str#1 = printf_string::str#10 } { strlen::return#2 = strlen::len#2 } } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] { { strlen::str#1 = printf_string::str#10 } { strlen::return#2 = strlen::len#2 } } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] { { strlen::str#1 = printf_string::str#10 } { strlen::return#2 = strlen::len#2 } } ) always clobbers reg byte a Statement [27] (word~) printf_string::$9 ← (word) strlen::return#2 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] { } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] { } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] { } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] { } ) always clobbers reg byte a Statement [28] (signed byte) printf_string::len#0 ← (signed byte)(word~) printf_string::$9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] { } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] { } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] { } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] { } ) always clobbers reg byte a -Statement [29] (signed byte) printf_string::padding#1 ← (signed byte)(const byte) main::format_min_length#1 - (signed byte) printf_string::len#0 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } ) always clobbers reg byte a +Statement [29] (signed byte) printf_string::padding#1 ← (signed byte) $a - (signed byte) printf_string::len#0 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } ) always clobbers reg byte a Statement [37] (byte*) printf_str::str#1 ← (byte*) printf_string::str#10 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] { { printf_str::str#1 = printf_string::str#10 } } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] { { printf_str::str#1 = printf_string::str#10 } } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] { { printf_str::str#1 = printf_string::str#10 } } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] { { printf_str::str#1 = printf_string::str#10 } } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:5 [ printf_string::padding#3 printf_string::padding#1 ] Statement [52] *((byte*) printf_char_cursor) ← (byte) printf_char::ch#2 [ printf_line_cursor printf_char_cursor ] ( main:4::printf_string:9::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:13::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:17::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:21::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:9::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:13::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:17::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:21::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:9::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } main:4::printf_string:13::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } main:4::printf_string:17::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } main:4::printf_string:21::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } ) always clobbers reg byte y @@ -2468,7 +2437,7 @@ Statement [24] (byte*) strlen::str#1 ← (byte*) printf_string::str#10 [ printf_ Statement [26] (word) strlen::return#2 ← (word) strlen::len#2 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] { { strlen::str#1 = printf_string::str#10 } { strlen::return#2 = strlen::len#2 } } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] { { strlen::str#1 = printf_string::str#10 } { strlen::return#2 = strlen::len#2 } } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] { { strlen::str#1 = printf_string::str#10 } { strlen::return#2 = strlen::len#2 } } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 strlen::return#2 ] { { strlen::str#1 = printf_string::str#10 } { strlen::return#2 = strlen::len#2 } } ) always clobbers reg byte a Statement [27] (word~) printf_string::$9 ← (word) strlen::return#2 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] { } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] { } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] { } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::$9 ] { } ) always clobbers reg byte a Statement [28] (signed byte) printf_string::len#0 ← (signed byte)(word~) printf_string::$9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] { } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] { } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] { } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::len#0 ] { } ) always clobbers reg byte a -Statement [29] (signed byte) printf_string::padding#1 ← (signed byte)(const byte) main::format_min_length#1 - (signed byte) printf_string::len#0 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } ) always clobbers reg byte a +Statement [29] (signed byte) printf_string::padding#1 ← (signed byte) $a - (signed byte) printf_string::len#0 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#1 ] { } ) always clobbers reg byte a Statement [37] (byte*) printf_str::str#1 ← (byte*) printf_string::str#10 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] ( main:4::printf_string:9 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] { { printf_str::str#1 = printf_string::str#10 } } main:4::printf_string:13 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] { { printf_str::str#1 = printf_string::str#10 } } main:4::printf_string:17 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] { { printf_str::str#1 = printf_string::str#10 } } main:4::printf_string:21 [ printf_line_cursor printf_char_cursor printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#1 ] { { printf_str::str#1 = printf_string::str#10 } } ) always clobbers reg byte a Statement [52] *((byte*) printf_char_cursor) ← (byte) printf_char::ch#2 [ printf_line_cursor printf_char_cursor ] ( main:4::printf_string:9::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:13::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:17::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:21::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:9::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:13::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:17::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:21::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:9::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } main:4::printf_string:13::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } main:4::printf_string:17::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } main:4::printf_string:21::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } ) always clobbers reg byte y Statement [54] if((byte*) printf_char_cursor!=(const byte*) printf_screen+(word)(number) $28*(number) $19) goto printf_char::@return [ printf_line_cursor printf_char_cursor ] ( main:4::printf_string:9::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:13::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:17::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:21::printf_padding:36::printf_char:49 [ printf_string::format_justify_left#10 printf_string::str#10 printf_string::padding#3 printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#0 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:9::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:13::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:17::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:21::printf_padding:42::printf_char:49 [ printf_padding::length#3 printf_padding::pad#4 printf_padding::i#2 printf_line_cursor printf_char_cursor ] { { printf_padding::length#1 = printf_padding::length#3 } { printf_char::ch#0 = printf_char::ch#2 printf_padding::pad#4 } } main:4::printf_string:9::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } main:4::printf_string:13::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } main:4::printf_string:17::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } main:4::printf_string:21::printf_str:38::printf_char:84 [ printf_string::format_justify_left#10 printf_string::padding#3 printf_str::str#2 printf_line_cursor printf_char_cursor ] { { printf_str::str#1 = printf_string::str#10 } { printf_char::ch#1 = printf_char::ch#2 } } ) always clobbers reg byte a @@ -2614,7 +2583,6 @@ __bend_from___b2: __bend: // main main: { - .label format_min_length = $a // [7] call printf_cls // [97] phi from main to printf_cls [phi:main->printf_cls] printf_cls_from_main: @@ -2752,10 +2720,10 @@ printf_string: { // [27] (word~) printf_string::$9 ← (word) strlen::return#2 // [28] (signed byte) printf_string::len#0 ← (signed byte)(word~) printf_string::$9 -- vbsaa=_sbyte_vwuz1 lda.z __9 - // [29] (signed byte) printf_string::padding#1 ← (signed byte)(const byte) main::format_min_length#1 - (signed byte) printf_string::len#0 -- vbsz1=vbsc1_minus_vbsaa + // [29] (signed byte) printf_string::padding#1 ← (signed byte) $a - (signed byte) printf_string::len#0 -- vbsz1=vbsc1_minus_vbsaa eor #$ff clc - adc #main.format_min_length+1 + adc #$a+1 sta.z padding // [30] if((signed byte) printf_string::padding#1>=(signed byte) 0) goto printf_string::@10 -- vbsz1_ge_0_then_la1 lda.z padding @@ -3399,9 +3367,6 @@ FINAL SYMBOL TABLE (label) main::@6 (label) main::@7 (label) main::@return -(byte) main::format_justify_left -(byte) main::format_min_length -(const byte) main::format_min_length#1 format_min_length = (byte) $a (const byte*) main::str[(byte) 4] = (byte*) "cml" (const byte*) main::str1[(byte) 6] = (byte*) "rules" (void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num) @@ -3585,14 +3550,13 @@ __bbegin: // @end // main main: { - .label format_min_length = $a // printf_cls() // [7] call printf_cls // [97] phi from main to printf_cls [phi:main->printf_cls] jsr printf_cls // [8] phi from main to main::@1 [phi:main->main::@1] // main::@1 - // printf_string( "cml", format) + // printf_string( "cml", { 10, 0 } ) // [9] call printf_string // [23] phi from main::@1 to printf_string [phi:main::@1->printf_string] // [23] phi (byte*) printf_string::str#10 = (const byte*) main::str [phi:main::@1->printf_string#0] -- pbuz1=pbuc1 @@ -3612,7 +3576,7 @@ main: { jsr printf_ln // [12] phi from main::@2 to main::@3 [phi:main::@2->main::@3] // main::@3 - // printf_string( "rules", format) + // printf_string( "rules", { 10, 0 } ) // [13] call printf_string // [23] phi from main::@3 to printf_string [phi:main::@3->printf_string] // [23] phi (byte*) printf_string::str#10 = (const byte*) main::str1 [phi:main::@3->printf_string#0] -- pbuz1=pbuc1 @@ -3632,7 +3596,7 @@ main: { jsr printf_ln // [16] phi from main::@4 to main::@5 [phi:main::@4->main::@5] // main::@5 - // printf_string( "cml", format) + // printf_string( "cml", { 10, 1 } ) // [17] call printf_string // [23] phi from main::@5 to printf_string [phi:main::@5->printf_string] // [23] phi (byte*) printf_string::str#10 = (const byte*) main::str [phi:main::@5->printf_string#0] -- pbuz1=pbuc1 @@ -3652,7 +3616,7 @@ main: { jsr printf_ln // [20] phi from main::@6 to main::@7 [phi:main::@6->main::@7] // main::@7 - // printf_string( "rules", format) + // printf_string( "rules", { 10, 1 } ) // [21] call printf_string // [23] phi from main::@7 to printf_string [phi:main::@7->printf_string] // [23] phi (byte*) printf_string::str#10 = (const byte*) main::str1 [phi:main::@7->printf_string#0] -- pbuz1=pbuc1 @@ -3700,10 +3664,10 @@ printf_string: { // [28] (signed byte) printf_string::len#0 ← (signed byte)(word~) printf_string::$9 -- vbsaa=_sbyte_vwuz1 lda.z __9 // padding = (signed char)format.min_length - len - // [29] (signed byte) printf_string::padding#1 ← (signed byte)(const byte) main::format_min_length#1 - (signed byte) printf_string::len#0 -- vbsz1=vbsc1_minus_vbsaa + // [29] (signed byte) printf_string::padding#1 ← (signed byte) $a - (signed byte) printf_string::len#0 -- vbsz1=vbsc1_minus_vbsaa eor #$ff clc - adc #main.format_min_length+1 + adc #$a+1 sta.z padding // if(padding<0) // [30] if((signed byte) printf_string::padding#1>=(signed byte) 0) goto printf_string::@10 -- vbsz1_ge_0_then_la1 diff --git a/src/test/ref/printf-1.sym b/src/test/ref/printf-1.sym index 87ada0db7..764f7333c 100644 --- a/src/test/ref/printf-1.sym +++ b/src/test/ref/printf-1.sym @@ -15,9 +15,6 @@ (label) main::@6 (label) main::@7 (label) main::@return -(byte) main::format_justify_left -(byte) main::format_min_length -(const byte) main::format_min_length#1 format_min_length = (byte) $a (const byte*) main::str[(byte) 4] = (byte*) "cml" (const byte*) main::str1[(byte) 6] = (byte*) "rules" (void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num) diff --git a/src/test/ref/printf-2.asm b/src/test/ref/printf-2.asm index cbad95cb1..0ad8decc0 100644 --- a/src/test/ref/printf-2.asm +++ b/src/test/ref/printf-2.asm @@ -28,7 +28,7 @@ __bbegin: main: { // printf_cls() jsr printf_cls - // printf_schar(-77, format) + // printf_schar(-77, { 6, 0, 0, 0, DECIMAL}) lda #0 sta.z printf_schar.format_zero_padding lda #DECIMAL @@ -38,7 +38,7 @@ main: { jsr printf_schar // printf_ln() jsr printf_ln - // printf_schar(99, format) + // printf_schar(99, {6, 0, 1, 1, OCTAL}) lda #1 sta.z printf_schar.format_zero_padding lda #OCTAL @@ -48,7 +48,7 @@ main: { jsr printf_schar // printf_ln() jsr printf_ln - // printf_uint(3456, format) + // printf_uint(3456, {10, 1, 0, 0, HEXADECIMAL}) jsr printf_uint // printf_ln() jsr printf_ln @@ -86,6 +86,9 @@ printf_ln: { // Print an unsigned int using a specific format printf_uint: { .label uvalue = $d80 + .const format_min_length = $a + .const format_justify_left = 1 + .const format_zero_padding = 0 // printf_buffer.sign = format.sign_always?'+':0 // Handle any sign lda #0 @@ -101,11 +104,11 @@ printf_uint: { sta.z printf_number_buffer.buffer_digits lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS sta.z printf_number_buffer.buffer_digits+1 - lda #0 + lda #format_zero_padding sta.z printf_number_buffer.format_zero_padding - lda #1 + lda #format_justify_left sta.z printf_number_buffer.format_justify_left - ldx #$a + ldx #format_min_length jsr printf_number_buffer // } rts diff --git a/src/test/ref/printf-2.cfg b/src/test/ref/printf-2.cfg index b526e9a7b..ef8cfe4b7 100644 --- a/src/test/ref/printf-2.cfg +++ b/src/test/ref/printf-2.cfg @@ -80,9 +80,9 @@ printf_uint::@return: scope:[printf_uint] from printf_uint::@2 printf_number_buffer: scope:[printf_number_buffer] from printf_schar::@5 printf_uint::@2 [32] (byte) printf_number_buffer::buffer_sign#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::buffer_sign#1 printf_uint::@2/(byte) printf_number_buffer::buffer_sign#0 ) [32] (byte*) printf_number_buffer::buffer_digits#10 ← phi( printf_schar::@5/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS printf_uint::@2/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS ) - [32] (byte) printf_number_buffer::format_zero_padding#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::format_zero_padding#1 printf_uint::@2/(byte) 0 ) - [32] (byte) printf_number_buffer::format_justify_left#10 ← phi( printf_schar::@5/(byte) 0 printf_uint::@2/(byte) 1 ) - [32] (byte) printf_number_buffer::format_min_length#2 ← phi( printf_schar::@5/(byte) 6 printf_uint::@2/(byte) $a ) + [32] (byte) printf_number_buffer::format_zero_padding#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::format_zero_padding#1 printf_uint::@2/(const byte) printf_uint::format_zero_padding#0 ) + [32] (byte) printf_number_buffer::format_justify_left#10 ← phi( printf_schar::@5/(byte) 0 printf_uint::@2/(const byte) printf_uint::format_justify_left#0 ) + [32] (byte) printf_number_buffer::format_min_length#2 ← phi( printf_schar::@5/(byte) 6 printf_uint::@2/(const byte) printf_uint::format_min_length#0 ) [33] if((byte) 0==(byte) printf_number_buffer::format_min_length#2) goto printf_number_buffer::@1 to:printf_number_buffer::@5 printf_number_buffer::@5: scope:[printf_number_buffer] from printf_number_buffer diff --git a/src/test/ref/printf-2.log b/src/test/ref/printf-2.log index d7b8443fa..541ca9cf5 100644 --- a/src/test/ref/printf-2.log +++ b/src/test/ref/printf-2.log @@ -7,6 +7,9 @@ Fixing pointer addition (word*~) bsearch16u::$13 ← (word*) bsearch16u::pivot + Fixing pointer addition (word*~) bsearch16u::$1 ← (word*) bsearch16u::items - (number) 1 Fixing pointer array-indexing *((word*) utoa::digit_values + (byte) utoa::digit) Fixing pointer array-indexing *((dword*) ultoa::digit_values + (byte) ultoa::digit) +Added struct type cast to parameter value list (void~) main::$1 ← call printf_schar (number) -$4d (struct printf_format_number){ (number) 6, (number) 0, (number) 0, (number) 0, (const byte) DECIMAL } +Added struct type cast to parameter value list (void~) main::$3 ← call printf_schar (number) $63 (struct printf_format_number){ (number) 6, (number) 0, (number) 1, (number) 1, (const byte) OCTAL } +Added struct type cast to parameter value list (void~) main::$5 ← call printf_uint (number) $d80 (struct printf_format_number){ (number) $a, (number) 1, (number) 0, (number) 0, (const byte) HEXADECIMAL } Created struct value member variable (byte) printf_slong::format_min_length Created struct value member variable (byte) printf_slong::format_justify_left Created struct value member variable (byte) printf_slong::format_sign_always @@ -55,12 +58,6 @@ Converted struct value to member variables (struct printf_format_number) printf_ Created struct value member variable (byte) printf_string::format_min_length Created struct value member variable (byte) printf_string::format_justify_left Converted struct value to member variables (struct printf_format_string) printf_string::format -Created struct value member variable (byte) main::format_min_length -Created struct value member variable (byte) main::format_justify_left -Created struct value member variable (byte) main::format_sign_always -Created struct value member variable (byte) main::format_zero_padding -Created struct value member variable (byte) main::format_radix -Converted struct value to member variables (struct printf_format_number) main::format Converted procedure struct value parameter to member unwinding (void()) printf_slong((signed dword) printf_slong::value , (byte) printf_slong::format_min_length , (byte) printf_slong::format_justify_left , (byte) printf_slong::format_sign_always , (byte) printf_slong::format_zero_padding , (byte) printf_slong::format_radix) Converted procedure struct value parameter to member unwinding (void()) printf_ulong((dword) printf_ulong::uvalue , (byte) printf_ulong::format_min_length , (byte) printf_ulong::format_justify_left , (byte) printf_ulong::format_sign_always , (byte) printf_ulong::format_zero_padding , (byte) printf_ulong::format_radix) Converted procedure struct value parameter to member unwinding (void()) printf_sint((signed word) printf_sint::value , (byte) printf_sint::format_min_length , (byte) printf_sint::format_justify_left , (byte) printf_sint::format_sign_always , (byte) printf_sint::format_zero_padding , (byte) printf_sint::format_radix) @@ -75,15 +72,9 @@ Converted call struct value parameter to member unwinding (void~) printf_sint::$ Converted call struct value parameter to member unwinding (void~) printf_uint::$4 ← call printf_number_buffer *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS (byte) printf_uint::format_min_length (byte) printf_uint::format_justify_left (byte) printf_uint::format_sign_always (byte) printf_uint::format_zero_padding (byte) printf_uint::format_radix Converted call struct value parameter to member unwinding (void~) printf_schar::$2 ← call printf_number_buffer *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS (byte) printf_schar::format_min_length (byte) printf_schar::format_justify_left (byte) printf_schar::format_sign_always (byte) printf_schar::format_zero_padding (byte) printf_schar::format_radix Converted call struct value parameter to member unwinding (void~) printf_uchar::$4 ← call printf_number_buffer *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS (byte) printf_uchar::format_min_length (byte) printf_uchar::format_justify_left (byte) printf_uchar::format_sign_always (byte) printf_uchar::format_zero_padding (byte) printf_uchar::format_radix -Unwinding value copy (struct printf_format_number) main::format ← {} -Adding value simple copy (byte) main::format_min_length ← (byte) 0 -Adding value simple copy (byte) main::format_justify_left ← (byte) 0 -Adding value simple copy (byte) main::format_sign_always ← (byte) 0 -Adding value simple copy (byte) main::format_zero_padding ← (byte) 0 -Adding value simple copy (byte) main::format_radix ← (byte) 0 -Converted call struct value parameter to member unwinding (void~) main::$1 ← call printf_schar (number) -$4d (byte) main::format_min_length (byte) main::format_justify_left (byte) main::format_sign_always (byte) main::format_zero_padding (byte) main::format_radix -Converted call struct value parameter to member unwinding (void~) main::$3 ← call printf_schar (number) $63 (byte) main::format_min_length (byte) main::format_justify_left (byte) main::format_sign_always (byte) main::format_zero_padding (byte) main::format_radix -Converted call struct value parameter to member unwinding (void~) main::$5 ← call printf_uint (number) $d80 (byte) main::format_min_length (byte) main::format_justify_left (byte) main::format_sign_always (byte) main::format_zero_padding (byte) main::format_radix +Converted call struct value parameter to member unwinding (void~) main::$1 ← call printf_schar (number) -$4d (number) 6 (number) 0 (number) 0 (number) 0 (const byte) DECIMAL +Converted call struct value parameter to member unwinding (void~) main::$3 ← call printf_schar (number) $63 (number) 6 (number) 0 (number) 1 (number) 1 (const byte) OCTAL +Converted call struct value parameter to member unwinding (void~) main::$5 ← call printf_uint (number) $d80 (number) $a (number) 1 (number) 0 (number) 0 (const byte) HEXADECIMAL Replacing struct member reference (struct printf_buffer_number) printf_buffer.sign with member unwinding reference *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) Replacing struct member reference (struct printf_buffer_number) printf_buffer.sign with member unwinding reference *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) Replacing struct member reference (struct printf_format_number) printf_slong::format.sign_always with member unwinding reference (byte) printf_slong::format_sign_always @@ -130,19 +121,6 @@ Replacing struct member reference (struct printf_format_string) printf_string::f Replacing struct member reference (struct printf_format_string) printf_string::format.justify_left with member unwinding reference (byte) printf_string::format_justify_left Replacing struct member reference (struct printf_format_string) printf_string::format.min_length with member unwinding reference (byte) printf_string::format_min_length Replacing struct member reference (struct printf_format_string) printf_string::format.justify_left with member unwinding reference (byte) printf_string::format_justify_left -Replacing struct member reference (struct printf_format_number) main::format.min_length with member unwinding reference (byte) main::format_min_length -Replacing struct member reference (struct printf_format_number) main::format.justify_left with member unwinding reference (byte) main::format_justify_left -Replacing struct member reference (struct printf_format_number) main::format.sign_always with member unwinding reference (byte) main::format_sign_always -Replacing struct member reference (struct printf_format_number) main::format.zero_padding with member unwinding reference (byte) main::format_zero_padding -Replacing struct member reference (struct printf_format_number) main::format.radix with member unwinding reference (byte) main::format_radix -Replacing struct member reference (struct printf_format_number) main::format.radix with member unwinding reference (byte) main::format_radix -Replacing struct member reference (struct printf_format_number) main::format.zero_padding with member unwinding reference (byte) main::format_zero_padding -Replacing struct member reference (struct printf_format_number) main::format.sign_always with member unwinding reference (byte) main::format_sign_always -Replacing struct member reference (struct printf_format_number) main::format.min_length with member unwinding reference (byte) main::format_min_length -Replacing struct member reference (struct printf_format_number) main::format.justify_left with member unwinding reference (byte) main::format_justify_left -Replacing struct member reference (struct printf_format_number) main::format.sign_always with member unwinding reference (byte) main::format_sign_always -Replacing struct member reference (struct printf_format_number) main::format.zero_padding with member unwinding reference (byte) main::format_zero_padding -Replacing struct member reference (struct printf_format_number) main::format.radix with member unwinding reference (byte) main::format_radix De-inlining cast (byte*)memcpy::source De-inlining cast (word)memmove::destination De-inlining cast (word)memmove::source @@ -1177,58 +1155,36 @@ main: scope:[main] from @29 call printf_cls to:main::@1 main::@1: scope:[main] from main - (byte) main::format_min_length#0 ← (byte) 0 - (byte) main::format_justify_left#0 ← (byte) 0 - (byte) main::format_sign_always#0 ← (byte) 0 - (byte) main::format_zero_padding#0 ← (byte) 0 - (byte) main::format_radix#0 ← (byte) 0 - (byte) main::format_min_length#1 ← (number) 6 - (byte) main::format_justify_left#1 ← (number) 0 - (byte) main::format_sign_always#1 ← (number) 0 - (byte) main::format_zero_padding#1 ← (number) 0 - (byte) main::format_radix#1 ← (const byte) DECIMAL (signed byte) printf_schar::value#1 ← (number) -$4d - (byte) printf_schar::format_min_length#0 ← (byte) main::format_min_length#1 - (byte) printf_schar::format_justify_left#0 ← (byte) main::format_justify_left#1 - (byte) printf_schar::format_sign_always#0 ← (byte) main::format_sign_always#1 - (byte) printf_schar::format_zero_padding#0 ← (byte) main::format_zero_padding#1 - (byte) printf_schar::format_radix#0 ← (byte) main::format_radix#1 + (byte) printf_schar::format_min_length#0 ← (number) 6 + (byte) printf_schar::format_justify_left#0 ← (number) 0 + (byte) printf_schar::format_sign_always#0 ← (number) 0 + (byte) printf_schar::format_zero_padding#0 ← (number) 0 + (byte) printf_schar::format_radix#0 ← (const byte) DECIMAL call printf_schar to:main::@2 main::@2: scope:[main] from main::@1 - (byte) main::format_justify_left#4 ← phi( main::@1/(byte) main::format_justify_left#1 ) - (byte) main::format_min_length#4 ← phi( main::@1/(byte) main::format_min_length#1 ) call printf_ln to:main::@3 main::@3: scope:[main] from main::@2 - (byte) main::format_justify_left#3 ← phi( main::@2/(byte) main::format_justify_left#4 ) - (byte) main::format_min_length#3 ← phi( main::@2/(byte) main::format_min_length#4 ) - (byte) main::format_radix#2 ← (const byte) OCTAL - (byte) main::format_zero_padding#2 ← (number) 1 - (byte) main::format_sign_always#2 ← (number) 1 (signed byte) printf_schar::value#2 ← (number) $63 - (byte) printf_schar::format_min_length#1 ← (byte) main::format_min_length#3 - (byte) printf_schar::format_justify_left#1 ← (byte) main::format_justify_left#3 - (byte) printf_schar::format_sign_always#1 ← (byte) main::format_sign_always#2 - (byte) printf_schar::format_zero_padding#1 ← (byte) main::format_zero_padding#2 - (byte) printf_schar::format_radix#1 ← (byte) main::format_radix#2 + (byte) printf_schar::format_min_length#1 ← (number) 6 + (byte) printf_schar::format_justify_left#1 ← (number) 0 + (byte) printf_schar::format_sign_always#1 ← (number) 1 + (byte) printf_schar::format_zero_padding#1 ← (number) 1 + (byte) printf_schar::format_radix#1 ← (const byte) OCTAL call printf_schar to:main::@4 main::@4: scope:[main] from main::@3 call printf_ln to:main::@5 main::@5: scope:[main] from main::@4 - (byte) main::format_min_length#2 ← (number) $a - (byte) main::format_justify_left#2 ← (number) 1 - (byte) main::format_sign_always#3 ← (number) 0 - (byte) main::format_zero_padding#3 ← (number) 0 - (byte) main::format_radix#3 ← (const byte) HEXADECIMAL (word) printf_uint::uvalue#0 ← (number) $d80 - (byte) printf_uint::format_min_length#0 ← (byte) main::format_min_length#2 - (byte) printf_uint::format_justify_left#0 ← (byte) main::format_justify_left#2 - (byte) printf_uint::format_sign_always#0 ← (byte) main::format_sign_always#3 - (byte) printf_uint::format_zero_padding#0 ← (byte) main::format_zero_padding#3 - (byte) printf_uint::format_radix#0 ← (byte) main::format_radix#3 + (byte) printf_uint::format_min_length#0 ← (number) $a + (byte) printf_uint::format_justify_left#0 ← (number) 1 + (byte) printf_uint::format_sign_always#0 ← (number) 0 + (byte) printf_uint::format_zero_padding#0 ← (number) 0 + (byte) printf_uint::format_radix#0 ← (const byte) HEXADECIMAL call printf_uint to:main::@6 main::@6: scope:[main] from main::@5 @@ -1281,33 +1237,6 @@ SYMBOL TABLE SSA (label) main::@6 (label) main::@7 (label) main::@return -(byte) main::format_justify_left -(byte) main::format_justify_left#0 -(byte) main::format_justify_left#1 -(byte) main::format_justify_left#2 -(byte) main::format_justify_left#3 -(byte) main::format_justify_left#4 -(byte) main::format_min_length -(byte) main::format_min_length#0 -(byte) main::format_min_length#1 -(byte) main::format_min_length#2 -(byte) main::format_min_length#3 -(byte) main::format_min_length#4 -(byte) main::format_radix -(byte) main::format_radix#0 -(byte) main::format_radix#1 -(byte) main::format_radix#2 -(byte) main::format_radix#3 -(byte) main::format_sign_always -(byte) main::format_sign_always#0 -(byte) main::format_sign_always#1 -(byte) main::format_sign_always#2 -(byte) main::format_sign_always#3 -(byte) main::format_zero_padding -(byte) main::format_zero_padding#0 -(byte) main::format_zero_padding#1 -(byte) main::format_zero_padding#2 -(byte) main::format_zero_padding#3 (void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num) (byte*~) memcpy::$0 (bool~) memcpy::$1 @@ -2133,19 +2062,21 @@ Adding number conversion cast (snumber) 0 in (bool~) printf_number_buffer::$21 Adding number conversion cast (snumber) 0 in (signed byte) printf_number_buffer::padding#2 ← (number) 0 Adding number conversion cast (unumber) 0 in (bool~) printf_number_buffer::$28 ← (number) 0 != (byte) printf_number_buffer::buffer_sign#3 Adding number conversion cast (unumber) 0 in (bool~) printf_number_buffer::$29 ← (number) 0 != (byte) printf_number_buffer::format_zero_padding#4 -Adding number conversion cast (unumber) 6 in (byte) main::format_min_length#1 ← (number) 6 -Adding number conversion cast (unumber) 0 in (byte) main::format_justify_left#1 ← (number) 0 -Adding number conversion cast (unumber) 0 in (byte) main::format_sign_always#1 ← (number) 0 -Adding number conversion cast (unumber) 0 in (byte) main::format_zero_padding#1 ← (number) 0 Adding number conversion cast (snumber) -$4d in (signed byte) printf_schar::value#1 ← (number) -$4d -Adding number conversion cast (unumber) 1 in (byte) main::format_zero_padding#2 ← (number) 1 -Adding number conversion cast (unumber) 1 in (byte) main::format_sign_always#2 ← (number) 1 +Adding number conversion cast (unumber) 6 in (byte) printf_schar::format_min_length#0 ← (number) 6 +Adding number conversion cast (unumber) 0 in (byte) printf_schar::format_justify_left#0 ← (number) 0 +Adding number conversion cast (unumber) 0 in (byte) printf_schar::format_sign_always#0 ← (number) 0 +Adding number conversion cast (unumber) 0 in (byte) printf_schar::format_zero_padding#0 ← (number) 0 Adding number conversion cast (snumber) $63 in (signed byte) printf_schar::value#2 ← (number) $63 -Adding number conversion cast (unumber) $a in (byte) main::format_min_length#2 ← (number) $a -Adding number conversion cast (unumber) 1 in (byte) main::format_justify_left#2 ← (number) 1 -Adding number conversion cast (unumber) 0 in (byte) main::format_sign_always#3 ← (number) 0 -Adding number conversion cast (unumber) 0 in (byte) main::format_zero_padding#3 ← (number) 0 +Adding number conversion cast (unumber) 6 in (byte) printf_schar::format_min_length#1 ← (number) 6 +Adding number conversion cast (unumber) 0 in (byte) printf_schar::format_justify_left#1 ← (number) 0 +Adding number conversion cast (unumber) 1 in (byte) printf_schar::format_sign_always#1 ← (number) 1 +Adding number conversion cast (unumber) 1 in (byte) printf_schar::format_zero_padding#1 ← (number) 1 Adding number conversion cast (unumber) $d80 in (word) printf_uint::uvalue#0 ← (number) $d80 +Adding number conversion cast (unumber) $a in (byte) printf_uint::format_min_length#0 ← (number) $a +Adding number conversion cast (unumber) 1 in (byte) printf_uint::format_justify_left#0 ← (number) 1 +Adding number conversion cast (unumber) 0 in (byte) printf_uint::format_sign_always#0 ← (number) 0 +Adding number conversion cast (unumber) 0 in (byte) printf_uint::format_zero_padding#0 ← (number) 0 Successful SSA optimization PassNAddNumberTypeConversions Adding number conversion cast (unumber) 0 in (unumber~) printf_uint::$0 ← (number) 0 Successful SSA optimization PassNAddNumberTypeConversions @@ -2172,19 +2103,21 @@ Inlining cast (word) memset::num#1 ← (unumber)(number) $28 Inlining cast (unumber~) printf_uint::$0 ← (unumber)(number) 0 Inlining cast *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN) ← (unumber)(number) 0 Inlining cast (signed byte) printf_number_buffer::padding#2 ← (snumber)(number) 0 -Inlining cast (byte) main::format_min_length#1 ← (unumber)(number) 6 -Inlining cast (byte) main::format_justify_left#1 ← (unumber)(number) 0 -Inlining cast (byte) main::format_sign_always#1 ← (unumber)(number) 0 -Inlining cast (byte) main::format_zero_padding#1 ← (unumber)(number) 0 Inlining cast (signed byte) printf_schar::value#1 ← (snumber)(number) -$4d -Inlining cast (byte) main::format_zero_padding#2 ← (unumber)(number) 1 -Inlining cast (byte) main::format_sign_always#2 ← (unumber)(number) 1 +Inlining cast (byte) printf_schar::format_min_length#0 ← (unumber)(number) 6 +Inlining cast (byte) printf_schar::format_justify_left#0 ← (unumber)(number) 0 +Inlining cast (byte) printf_schar::format_sign_always#0 ← (unumber)(number) 0 +Inlining cast (byte) printf_schar::format_zero_padding#0 ← (unumber)(number) 0 Inlining cast (signed byte) printf_schar::value#2 ← (snumber)(number) $63 -Inlining cast (byte) main::format_min_length#2 ← (unumber)(number) $a -Inlining cast (byte) main::format_justify_left#2 ← (unumber)(number) 1 -Inlining cast (byte) main::format_sign_always#3 ← (unumber)(number) 0 -Inlining cast (byte) main::format_zero_padding#3 ← (unumber)(number) 0 +Inlining cast (byte) printf_schar::format_min_length#1 ← (unumber)(number) 6 +Inlining cast (byte) printf_schar::format_justify_left#1 ← (unumber)(number) 0 +Inlining cast (byte) printf_schar::format_sign_always#1 ← (unumber)(number) 1 +Inlining cast (byte) printf_schar::format_zero_padding#1 ← (unumber)(number) 1 Inlining cast (word) printf_uint::uvalue#0 ← (unumber)(number) $d80 +Inlining cast (byte) printf_uint::format_min_length#0 ← (unumber)(number) $a +Inlining cast (byte) printf_uint::format_justify_left#0 ← (unumber)(number) 1 +Inlining cast (byte) printf_uint::format_sign_always#0 ← (unumber)(number) 0 +Inlining cast (byte) printf_uint::format_zero_padding#0 ← (unumber)(number) 0 Successful SSA optimization Pass2InlineCast Simplifying constant pointer cast (byte*) 1024 Simplifying constant integer cast 0 @@ -2227,19 +2160,21 @@ Simplifying constant integer cast 0 Simplifying constant integer cast 0 Simplifying constant integer cast 0 Simplifying constant integer cast 0 +Simplifying constant integer cast -$4d Simplifying constant integer cast 6 Simplifying constant integer cast 0 Simplifying constant integer cast 0 Simplifying constant integer cast 0 -Simplifying constant integer cast -$4d -Simplifying constant integer cast 1 -Simplifying constant integer cast 1 Simplifying constant integer cast $63 +Simplifying constant integer cast 6 +Simplifying constant integer cast 0 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast $d80 Simplifying constant integer cast $a Simplifying constant integer cast 1 Simplifying constant integer cast 0 Simplifying constant integer cast 0 -Simplifying constant integer cast $d80 Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0 @@ -2278,19 +2213,21 @@ Finalized signed number type (signed byte) 0 Finalized signed number type (signed byte) 0 Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0 +Finalized signed number type (signed byte) -$4d Finalized unsigned number type (byte) 6 Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0 -Finalized signed number type (signed byte) -$4d -Finalized unsigned number type (byte) 1 -Finalized unsigned number type (byte) 1 Finalized signed number type (signed byte) $63 +Finalized unsigned number type (byte) 6 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (word) $d80 Finalized unsigned number type (byte) $a Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0 -Finalized unsigned number type (word) $d80 Successful SSA optimization PassNFinalizeNumberTypeConversions Inferred type updated to byte in (unumber~) uctoa::$4 ← (byte) uctoa::max_digits#5 - (byte) 1 Inferred type updated to byte in (unumber~) utoa::$4 ← (byte) utoa::max_digits#5 - (byte) 1 @@ -2412,8 +2349,6 @@ Alias printf_number_buffer::padding#14 = printf_number_buffer::padding#7 printf_ Alias printf_number_buffer::buffer_digits#5 = printf_number_buffer::buffer_digits#9 printf_number_buffer::buffer_digits#6 Alias printf_number_buffer::format_zero_padding#15 = printf_number_buffer::format_zero_padding#18 printf_number_buffer::format_zero_padding#3 Alias printf_number_buffer::format_justify_left#10 = printf_number_buffer::format_justify_left#15 printf_number_buffer::format_justify_left#11 -Alias main::format_min_length#1 = main::format_min_length#4 main::format_min_length#3 -Alias main::format_justify_left#1 = main::format_justify_left#4 main::format_justify_left#3 Successful SSA optimization Pass2AliasElimination Alias candidate removed (volatile)printf_char_cursor = printf_char::$8 Alias uctoa::value#10 = uctoa::value#7 @@ -2603,50 +2538,29 @@ Constant (const signed byte) printf_number_buffer::padding#2 = 0 Constant (const byte) printf_padding::pad#0 = ' ' Constant (const byte) printf_padding::pad#1 = '0' Constant (const byte) printf_padding::pad#2 = ' ' -Constant (const byte) main::format_min_length#0 = 0 -Constant (const byte) main::format_justify_left#0 = 0 -Constant (const byte) main::format_sign_always#0 = 0 -Constant (const byte) main::format_zero_padding#0 = 0 -Constant (const byte) main::format_radix#0 = 0 -Constant (const byte) main::format_min_length#1 = 6 -Constant (const byte) main::format_justify_left#1 = 0 -Constant (const byte) main::format_sign_always#1 = 0 -Constant (const byte) main::format_zero_padding#1 = 0 -Constant (const byte) main::format_radix#1 = DECIMAL Constant (const signed byte) printf_schar::value#1 = -$4d -Constant (const byte) main::format_radix#2 = OCTAL -Constant (const byte) main::format_zero_padding#2 = 1 -Constant (const byte) main::format_sign_always#2 = 1 +Constant (const byte) printf_schar::format_min_length#0 = 6 +Constant (const byte) printf_schar::format_justify_left#0 = 0 +Constant (const byte) printf_schar::format_sign_always#0 = 0 +Constant (const byte) printf_schar::format_zero_padding#0 = 0 +Constant (const byte) printf_schar::format_radix#0 = DECIMAL Constant (const signed byte) printf_schar::value#2 = $63 -Constant (const byte) main::format_min_length#2 = $a -Constant (const byte) main::format_justify_left#2 = 1 -Constant (const byte) main::format_sign_always#3 = 0 -Constant (const byte) main::format_zero_padding#3 = 0 -Constant (const byte) main::format_radix#3 = HEXADECIMAL +Constant (const byte) printf_schar::format_min_length#1 = 6 +Constant (const byte) printf_schar::format_justify_left#1 = 0 +Constant (const byte) printf_schar::format_sign_always#1 = 1 +Constant (const byte) printf_schar::format_zero_padding#1 = 1 +Constant (const byte) printf_schar::format_radix#1 = OCTAL Constant (const word) printf_uint::uvalue#0 = $d80 +Constant (const byte) printf_uint::format_min_length#0 = $a +Constant (const byte) printf_uint::format_justify_left#0 = 1 +Constant (const byte) printf_uint::format_sign_always#0 = 0 +Constant (const byte) printf_uint::format_zero_padding#0 = 0 +Constant (const byte) printf_uint::format_radix#0 = HEXADECIMAL Successful SSA optimization Pass2ConstantIdentification Constant (const byte*) memcpy::dst#0 = (byte*)memcpy::destination#0 Constant (const void*) memcpy::source#0 = (void*)printf_char::$3 Constant (const void*) memcpy::return#2 = memcpy::destination#0 Constant (const word) utoa::value#1 = printf_uint::uvalue#0 -Constant (const byte) printf_schar::format_min_length#0 = main::format_min_length#1 -Constant (const byte) printf_schar::format_justify_left#0 = main::format_justify_left#1 -Constant (const byte) printf_schar::format_sign_always#0 = main::format_sign_always#1 -Constant (const byte) printf_schar::format_zero_padding#0 = main::format_zero_padding#1 -Constant (const byte) printf_schar::format_radix#0 = main::format_radix#1 -Constant (const byte) printf_schar::format_min_length#1 = main::format_min_length#1 -Constant (const byte) printf_schar::format_justify_left#1 = main::format_justify_left#1 -Constant (const byte) printf_schar::format_sign_always#1 = main::format_sign_always#2 -Constant (const byte) printf_schar::format_zero_padding#1 = main::format_zero_padding#2 -Constant (const byte) printf_schar::format_radix#1 = main::format_radix#2 -Constant (const byte) printf_uint::format_min_length#0 = main::format_min_length#2 -Constant (const byte) printf_uint::format_justify_left#0 = main::format_justify_left#2 -Constant (const byte) printf_uint::format_sign_always#0 = main::format_sign_always#3 -Constant (const byte) printf_uint::format_zero_padding#0 = main::format_zero_padding#3 -Constant (const byte) printf_uint::format_radix#0 = main::format_radix#3 -Successful SSA optimization Pass2ConstantIdentification -Constant (const byte*) memcpy::src#0 = (byte*)memcpy::source#0 -Constant (const byte*) memcpy::$2 = (byte*)memcpy::source#0 Constant (const byte) utoa::radix#0 = printf_uint::format_radix#0 Constant (const byte) printf_number_buffer::format_min_length#0 = printf_uint::format_min_length#0 Constant (const byte) printf_number_buffer::format_justify_left#0 = printf_uint::format_justify_left#0 @@ -2654,6 +2568,9 @@ Constant (const byte) printf_number_buffer::format_sign_always#0 = printf_uint:: Constant (const byte) printf_number_buffer::format_zero_padding#0 = printf_uint::format_zero_padding#0 Constant (const byte) printf_number_buffer::format_radix#0 = printf_uint::format_radix#0 Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) memcpy::src#0 = (byte*)memcpy::source#0 +Constant (const byte*) memcpy::$2 = (byte*)memcpy::source#0 +Successful SSA optimization Pass2ConstantIdentification if() condition always false - eliminating [98] if((const byte) utoa::radix#0==(const byte) DECIMAL) goto utoa::@1 if() condition always true - replacing block destination [102] if((const byte) utoa::radix#0==(const byte) HEXADECIMAL) goto utoa::@2 if() condition always false - eliminating [106] if((const byte) utoa::radix#0==(const byte) OCTAL) goto utoa::@3 @@ -2679,19 +2596,11 @@ Eliminating unused constant (const word*) utoa::digit_values#0 Eliminating unused constant (const byte) utoa::radix#0 Eliminating unused constant (const byte) printf_number_buffer::format_sign_always#0 Eliminating unused constant (const byte) printf_number_buffer::format_radix#0 -Eliminating unused constant (const byte) main::format_min_length#0 -Eliminating unused constant (const byte) main::format_justify_left#0 -Eliminating unused constant (const byte) main::format_sign_always#0 -Eliminating unused constant (const byte) main::format_zero_padding#0 -Eliminating unused constant (const byte) main::format_radix#0 Eliminating unused constant (const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_SIGN Successful SSA optimization PassNEliminateUnusedVars Eliminating unused constant (const byte) printf_uint::format_sign_always#0 Eliminating unused constant (const byte) printf_uint::format_radix#0 Successful SSA optimization PassNEliminateUnusedVars -Eliminating unused constant (const byte) main::format_sign_always#3 -Eliminating unused constant (const byte) main::format_radix#3 -Successful SSA optimization PassNEliminateUnusedVars Eliminating variable (byte*) utoa::buffer#0 from unused block utoa::@12 Eliminating variable (byte*) utoa::buffer#1 from unused block utoa::@12 Eliminating variable (byte*) utoa::buffer#2 from unused block utoa::@12 @@ -2836,12 +2745,12 @@ Inlining constant with var siblings (const byte) printf_padding::pad#0 Inlining constant with var siblings (const byte) printf_padding::pad#1 Inlining constant with var siblings (const byte) printf_padding::pad#2 Inlining constant with var siblings (const signed byte) printf_schar::value#1 -Inlining constant with var siblings (const signed byte) printf_schar::value#2 Inlining constant with var siblings (const byte) printf_schar::format_min_length#0 Inlining constant with var siblings (const byte) printf_schar::format_justify_left#0 Inlining constant with var siblings (const byte) printf_schar::format_sign_always#0 Inlining constant with var siblings (const byte) printf_schar::format_zero_padding#0 Inlining constant with var siblings (const byte) printf_schar::format_radix#0 +Inlining constant with var siblings (const signed byte) printf_schar::value#2 Inlining constant with var siblings (const byte) printf_schar::format_min_length#1 Inlining constant with var siblings (const byte) printf_schar::format_justify_left#1 Inlining constant with var siblings (const byte) printf_schar::format_sign_always#1 @@ -2854,28 +2763,16 @@ Inlining constant with var siblings (const signed byte) printf_number_buffer::pa Inlining constant with var siblings (const byte) printf_number_buffer::format_min_length#0 Inlining constant with var siblings (const byte) printf_number_buffer::format_justify_left#0 Inlining constant with var siblings (const byte) printf_number_buffer::format_zero_padding#0 -Inlining constant with different constant siblings (const byte) main::format_min_length#1 -Inlining constant with different constant siblings (const byte) main::format_justify_left#1 -Inlining constant with different constant siblings (const byte) main::format_sign_always#1 -Inlining constant with different constant siblings (const byte) main::format_zero_padding#1 -Inlining constant with different constant siblings (const byte) main::format_zero_padding#2 -Inlining constant with different constant siblings (const byte) main::format_sign_always#2 -Inlining constant with different constant siblings (const byte) main::format_min_length#2 -Inlining constant with different constant siblings (const byte) main::format_justify_left#2 -Inlining constant with different constant siblings (const byte) main::format_zero_padding#3 Constant inlined uctoa_append::digit#0 = (byte) 0 -Constant inlined main::format_zero_padding#2 = (byte) 1 -Constant inlined main::format_zero_padding#3 = (byte) 0 -Constant inlined printf_number_buffer::format_justify_left#0 = (byte) 1 +Constant inlined printf_number_buffer::format_justify_left#0 = (const byte) printf_uint::format_justify_left#0 Constant inlined printf_number_buffer::buffer_digits#0 = (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS Constant inlined printf_number_buffer::buffer_digits#1 = (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS Constant inlined utoa::digit_values#2 = (const word*) RADIX_HEXADECIMAL_VALUES Constant inlined printf_schar::format_min_length#0 = (byte) 6 -Constant inlined printf_schar::format_min_length#1 = (byte) 6 Constant inlined memset::num#1 = (byte) $28 +Constant inlined printf_schar::format_min_length#1 = (byte) 6 Constant inlined memset::num#0 = (word)(number) $28*(number) $19 Constant inlined strlen::len#0 = (word) 0 -Constant inlined main::format_zero_padding#1 = (byte) 0 Constant inlined printf_schar::format_sign_always#1 = (byte) 1 Constant inlined printf_schar::format_sign_always#0 = (byte) 0 Constant inlined memcpy::$2 = (byte*)(const void*) memcpy::source#0 @@ -2884,18 +2781,12 @@ Constant inlined printf_schar::format_justify_left#1 = (byte) 0 Constant inlined utoa::$4 = (const byte) utoa::max_digits#2-(byte) 1 Constant inlined printf_number_buffer::padding#2 = (signed byte) 0 Constant inlined uctoa::digit#0 = (byte) 0 -Constant inlined main::format_min_length#1 = (byte) 6 -Constant inlined main::format_min_length#2 = (byte) $a Constant inlined utoa::buffer#5 = (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS Constant inlined memset::c#0 = (byte) ' ' -Constant inlined main::format_justify_left#2 = (byte) 1 Constant inlined memset::c#1 = (byte) ' ' -Constant inlined main::format_justify_left#1 = (byte) 0 -Constant inlined printf_uint::format_zero_padding#0 = (byte) 0 Constant inlined printf_number_buffer::padding#0 = (signed byte) 0 Constant inlined utoa_append::digit#0 = (byte) 0 Constant inlined uctoa::digit_values#2 = (const byte*) RADIX_HEXADECIMAL_VALUES_CHAR -Constant inlined printf_uint::format_justify_left#0 = (byte) 1 Constant inlined uctoa::started#0 = (byte) 0 Constant inlined uctoa::digit_values#1 = (const byte*) RADIX_DECIMAL_VALUES_CHAR Constant inlined uctoa::started#1 = (byte) 1 @@ -2905,16 +2796,13 @@ Constant inlined memcpy::dst#0 = (byte*)(const void*) memcpy::destination#0 Constant inlined uctoa::digit_values#3 = (const byte*) RADIX_OCTAL_VALUES_CHAR Constant inlined printf_schar::format_radix#0 = (const byte) DECIMAL Constant inlined printf_schar::format_zero_padding#1 = (byte) 1 -Constant inlined printf_schar::format_zero_padding#0 = (byte) 0 Constant inlined memcpy::src#0 = (byte*)(const void*) memcpy::source#0 +Constant inlined printf_schar::format_zero_padding#0 = (byte) 0 Constant inlined uctoa::max_digits#1 = (byte) 3 -Constant inlined printf_uint::format_min_length#0 = (byte) $a -Constant inlined main::format_sign_always#2 = (byte) 1 Constant inlined utoa::digit#0 = (byte) 0 -Constant inlined main::format_sign_always#1 = (byte) 0 -Constant inlined printf_number_buffer::format_min_length#0 = (byte) $a +Constant inlined printf_number_buffer::format_min_length#0 = (const byte) printf_uint::format_min_length#0 Constant inlined uctoa::max_digits#3 = (byte) 3 -Constant inlined printf_number_buffer::format_zero_padding#0 = (byte) 0 +Constant inlined printf_number_buffer::format_zero_padding#0 = (const byte) printf_uint::format_zero_padding#0 Constant inlined uctoa::max_digits#2 = (byte) 2 Constant inlined uctoa::max_digits#4 = (byte) 8 Constant inlined uctoa::buffer#1 = ++++(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS @@ -2936,9 +2824,7 @@ Constant inlined utoa::started#0 = (byte) 0 Constant inlined printf_char::$6 = (const byte*) printf_screen+(word)(number) $28*(number) $19-(byte) $28 Constant inlined uctoa::buffer#5 = (byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS Constant inlined printf_char::$5 = (const byte*) printf_screen+(word)(number) $28*(number) $19 -Constant inlined main::format_radix#1 = (const byte) DECIMAL Constant inlined utoa::value#1 = (const word) printf_uint::uvalue#0 -Constant inlined main::format_radix#2 = (const byte) OCTAL Successful SSA optimization Pass2ConstantInlining Simplifying constant integer increment ++(byte*)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS Simplifying constant integer increment ++(byte*)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS @@ -3258,9 +3144,9 @@ printf_uint::@return: scope:[printf_uint] from printf_uint::@2 printf_number_buffer: scope:[printf_number_buffer] from printf_schar::@5 printf_uint::@2 [32] (byte) printf_number_buffer::buffer_sign#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::buffer_sign#1 printf_uint::@2/(byte) printf_number_buffer::buffer_sign#0 ) [32] (byte*) printf_number_buffer::buffer_digits#10 ← phi( printf_schar::@5/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS printf_uint::@2/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS ) - [32] (byte) printf_number_buffer::format_zero_padding#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::format_zero_padding#1 printf_uint::@2/(byte) 0 ) - [32] (byte) printf_number_buffer::format_justify_left#10 ← phi( printf_schar::@5/(byte) 0 printf_uint::@2/(byte) 1 ) - [32] (byte) printf_number_buffer::format_min_length#2 ← phi( printf_schar::@5/(byte) 6 printf_uint::@2/(byte) $a ) + [32] (byte) printf_number_buffer::format_zero_padding#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::format_zero_padding#1 printf_uint::@2/(const byte) printf_uint::format_zero_padding#0 ) + [32] (byte) printf_number_buffer::format_justify_left#10 ← phi( printf_schar::@5/(byte) 0 printf_uint::@2/(const byte) printf_uint::format_justify_left#0 ) + [32] (byte) printf_number_buffer::format_min_length#2 ← phi( printf_schar::@5/(byte) 6 printf_uint::@2/(const byte) printf_uint::format_min_length#0 ) [33] if((byte) 0==(byte) printf_number_buffer::format_min_length#2) goto printf_number_buffer::@1 to:printf_number_buffer::@5 printf_number_buffer::@5: scope:[printf_number_buffer] from printf_number_buffer @@ -3660,11 +3546,6 @@ null depth in calling loop Loop head: printf_str::@1 tails: printf_str::@3 block VARIABLE REGISTER WEIGHTS (void()) main() -(byte) main::format_justify_left -(byte) main::format_min_length -(byte) main::format_radix -(byte) main::format_sign_always -(byte) main::format_zero_padding (void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num) (void*) memcpy::destination (byte*) memcpy::dst @@ -4222,6 +4103,9 @@ printf_ln: { // Print an unsigned int using a specific format printf_uint: { .label uvalue = $d80 + .const format_min_length = $a + .const format_justify_left = 1 + .const format_zero_padding = 0 jmp __b1 // printf_uint::@1 __b1: @@ -4250,14 +4134,14 @@ printf_uint: { sta.z printf_number_buffer.buffer_digits lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS sta.z printf_number_buffer.buffer_digits+1 - // [32] phi (byte) printf_number_buffer::format_zero_padding#10 = (byte) 0 [phi:printf_uint::@2->printf_number_buffer#2] -- vbuz1=vbuc1 - lda #0 + // [32] phi (byte) printf_number_buffer::format_zero_padding#10 = (const byte) printf_uint::format_zero_padding#0 [phi:printf_uint::@2->printf_number_buffer#2] -- vbuz1=vbuc1 + lda #format_zero_padding sta.z printf_number_buffer.format_zero_padding - // [32] phi (byte) printf_number_buffer::format_justify_left#10 = (byte) 1 [phi:printf_uint::@2->printf_number_buffer#3] -- vbuz1=vbuc1 - lda #1 + // [32] phi (byte) printf_number_buffer::format_justify_left#10 = (const byte) printf_uint::format_justify_left#0 [phi:printf_uint::@2->printf_number_buffer#3] -- vbuz1=vbuc1 + lda #format_justify_left sta.z printf_number_buffer.format_justify_left - // [32] phi (byte) printf_number_buffer::format_min_length#2 = (byte) $a [phi:printf_uint::@2->printf_number_buffer#4] -- vbuz1=vbuc1 - lda #$a + // [32] phi (byte) printf_number_buffer::format_min_length#2 = (const byte) printf_uint::format_min_length#0 [phi:printf_uint::@2->printf_number_buffer#4] -- vbuz1=vbuc1 + lda #format_min_length sta.z printf_number_buffer.format_min_length jsr printf_number_buffer jmp __breturn @@ -6052,6 +5936,9 @@ printf_ln: { // Print an unsigned int using a specific format printf_uint: { .label uvalue = $d80 + .const format_min_length = $a + .const format_justify_left = 1 + .const format_zero_padding = 0 jmp __b1 // printf_uint::@1 __b1: @@ -6080,14 +5967,14 @@ printf_uint: { sta.z printf_number_buffer.buffer_digits lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS sta.z printf_number_buffer.buffer_digits+1 - // [32] phi (byte) printf_number_buffer::format_zero_padding#10 = (byte) 0 [phi:printf_uint::@2->printf_number_buffer#2] -- vbuz1=vbuc1 - lda #0 + // [32] phi (byte) printf_number_buffer::format_zero_padding#10 = (const byte) printf_uint::format_zero_padding#0 [phi:printf_uint::@2->printf_number_buffer#2] -- vbuz1=vbuc1 + lda #format_zero_padding sta.z printf_number_buffer.format_zero_padding - // [32] phi (byte) printf_number_buffer::format_justify_left#10 = (byte) 1 [phi:printf_uint::@2->printf_number_buffer#3] -- vbuz1=vbuc1 - lda #1 + // [32] phi (byte) printf_number_buffer::format_justify_left#10 = (const byte) printf_uint::format_justify_left#0 [phi:printf_uint::@2->printf_number_buffer#3] -- vbuz1=vbuc1 + lda #format_justify_left sta.z printf_number_buffer.format_justify_left - // [32] phi (byte) printf_number_buffer::format_min_length#2 = (byte) $a [phi:printf_uint::@2->printf_number_buffer#4] -- vbuxx=vbuc1 - ldx #$a + // [32] phi (byte) printf_number_buffer::format_min_length#2 = (const byte) printf_uint::format_min_length#0 [phi:printf_uint::@2->printf_number_buffer#4] -- vbuxx=vbuc1 + ldx #format_min_length jsr printf_number_buffer jmp __breturn // printf_uint::@return @@ -7481,11 +7368,6 @@ FINAL SYMBOL TABLE (label) main::@5 (label) main::@6 (label) main::@return -(byte) main::format_justify_left -(byte) main::format_min_length -(byte) main::format_radix -(byte) main::format_sign_always -(byte) main::format_zero_padding (void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num) (label) memcpy::@1 (label) memcpy::@2 @@ -7651,10 +7533,13 @@ FINAL SYMBOL TABLE (label) printf_uint::@return (struct printf_format_number) printf_uint::format (byte) printf_uint::format_justify_left +(const byte) printf_uint::format_justify_left#0 format_justify_left = (byte) 1 (byte) printf_uint::format_min_length +(const byte) printf_uint::format_min_length#0 format_min_length = (byte) $a (byte) printf_uint::format_radix (byte) printf_uint::format_sign_always (byte) printf_uint::format_zero_padding +(const byte) printf_uint::format_zero_padding#0 format_zero_padding = (byte) 0 (word) printf_uint::uvalue (const word) printf_uint::uvalue#0 uvalue = (word) $d80 (word()) strlen((byte*) strlen::str) @@ -7862,7 +7747,7 @@ main: { jsr printf_cls // [8] phi from main to main::@1 [phi:main->main::@1] // main::@1 - // printf_schar(-77, format) + // printf_schar(-77, { 6, 0, 0, 0, DECIMAL}) // [9] call printf_schar // [142] phi from main::@1 to printf_schar [phi:main::@1->printf_schar] // [142] phi (byte) printf_schar::format_zero_padding#2 = (byte) 0 [phi:main::@1->printf_schar#0] -- vbuz1=vbuc1 @@ -7884,7 +7769,7 @@ main: { jsr printf_ln // [12] phi from main::@2 to main::@3 [phi:main::@2->main::@3] // main::@3 - // printf_schar(99, format) + // printf_schar(99, {6, 0, 1, 1, OCTAL}) // [13] call printf_schar // [142] phi from main::@3 to printf_schar [phi:main::@3->printf_schar] // [142] phi (byte) printf_schar::format_zero_padding#2 = (byte) 1 [phi:main::@3->printf_schar#0] -- vbuz1=vbuc1 @@ -7906,7 +7791,7 @@ main: { jsr printf_ln // [16] phi from main::@4 to main::@5 [phi:main::@4->main::@5] // main::@5 - // printf_uint(3456, format) + // printf_uint(3456, {10, 1, 0, 0, HEXADECIMAL}) // [17] call printf_uint // [26] phi from main::@5 to printf_uint [phi:main::@5->printf_uint] jsr printf_uint @@ -7961,6 +7846,9 @@ printf_ln: { // Print an unsigned int using a specific format printf_uint: { .label uvalue = $d80 + .const format_min_length = $a + .const format_justify_left = 1 + .const format_zero_padding = 0 // printf_uint::@1 // printf_buffer.sign = format.sign_always?'+':0 // [27] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0 -- _deref_pbuc1=vbuc2 @@ -7986,14 +7874,14 @@ printf_uint: { sta.z printf_number_buffer.buffer_digits lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS sta.z printf_number_buffer.buffer_digits+1 - // [32] phi (byte) printf_number_buffer::format_zero_padding#10 = (byte) 0 [phi:printf_uint::@2->printf_number_buffer#2] -- vbuz1=vbuc1 - lda #0 + // [32] phi (byte) printf_number_buffer::format_zero_padding#10 = (const byte) printf_uint::format_zero_padding#0 [phi:printf_uint::@2->printf_number_buffer#2] -- vbuz1=vbuc1 + lda #format_zero_padding sta.z printf_number_buffer.format_zero_padding - // [32] phi (byte) printf_number_buffer::format_justify_left#10 = (byte) 1 [phi:printf_uint::@2->printf_number_buffer#3] -- vbuz1=vbuc1 - lda #1 + // [32] phi (byte) printf_number_buffer::format_justify_left#10 = (const byte) printf_uint::format_justify_left#0 [phi:printf_uint::@2->printf_number_buffer#3] -- vbuz1=vbuc1 + lda #format_justify_left sta.z printf_number_buffer.format_justify_left - // [32] phi (byte) printf_number_buffer::format_min_length#2 = (byte) $a [phi:printf_uint::@2->printf_number_buffer#4] -- vbuxx=vbuc1 - ldx #$a + // [32] phi (byte) printf_number_buffer::format_min_length#2 = (const byte) printf_uint::format_min_length#0 [phi:printf_uint::@2->printf_number_buffer#4] -- vbuxx=vbuc1 + ldx #format_min_length jsr printf_number_buffer // printf_uint::@return // } diff --git a/src/test/ref/printf-2.sym b/src/test/ref/printf-2.sym index 5d0a891d6..d9bab147a 100644 --- a/src/test/ref/printf-2.sym +++ b/src/test/ref/printf-2.sym @@ -26,11 +26,6 @@ (label) main::@5 (label) main::@6 (label) main::@return -(byte) main::format_justify_left -(byte) main::format_min_length -(byte) main::format_radix -(byte) main::format_sign_always -(byte) main::format_zero_padding (void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num) (label) memcpy::@1 (label) memcpy::@2 @@ -196,10 +191,13 @@ (label) printf_uint::@return (struct printf_format_number) printf_uint::format (byte) printf_uint::format_justify_left +(const byte) printf_uint::format_justify_left#0 format_justify_left = (byte) 1 (byte) printf_uint::format_min_length +(const byte) printf_uint::format_min_length#0 format_min_length = (byte) $a (byte) printf_uint::format_radix (byte) printf_uint::format_sign_always (byte) printf_uint::format_zero_padding +(const byte) printf_uint::format_zero_padding#0 format_zero_padding = (byte) 0 (word) printf_uint::uvalue (const word) printf_uint::uvalue#0 uvalue = (word) $d80 (word()) strlen((byte*) strlen::str) diff --git a/src/test/ref/problem-struct-inline-parameter-1.asm b/src/test/ref/problem-struct-inline-parameter-1.asm new file mode 100644 index 000000000..ebe18d42b --- /dev/null +++ b/src/test/ref/problem-struct-inline-parameter-1.asm @@ -0,0 +1,27 @@ +// Illustrates problem with passing an inline struct value as a parameter +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .label SCREEN = $400 +main: { + // print('c', { '-', '-' } ) + jsr print + // } + rts +} +print: { + .const c = 'c' + .const fmt_prefix = '-' + .const fmt_postfix = '-' + // SCREEN[idx++] = fmt.prefix + lda #fmt_prefix + sta SCREEN + // SCREEN[idx++] = c + lda #c + sta SCREEN+1 + // SCREEN[idx++] = fmt.postfix + lda #fmt_postfix + sta SCREEN+2 + // } + rts +} diff --git a/src/test/ref/problem-struct-inline-parameter-1.cfg b/src/test/ref/problem-struct-inline-parameter-1.cfg new file mode 100644 index 000000000..7e6c7e285 --- /dev/null +++ b/src/test/ref/problem-struct-inline-parameter-1.cfg @@ -0,0 +1,28 @@ +@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 print + to:main::@return +main::@return: scope:[main] from main + [6] return + to:@return + +(void()) print((byte) print::c , (byte) print::fmt_prefix , (byte) print::fmt_postfix) +print: scope:[print] from main + [7] *((const nomodify byte*) SCREEN) ← (const byte) print::fmt_prefix#0 + [8] *((const nomodify byte*) SCREEN+(byte) 1) ← (const byte) print::c#0 + [9] *((const nomodify byte*) SCREEN+(byte) 2) ← (const byte) print::fmt_postfix#0 + to:print::@return +print::@return: scope:[print] from print + [10] return + to:@return diff --git a/src/test/ref/problem-struct-inline-parameter-1.log b/src/test/ref/problem-struct-inline-parameter-1.log new file mode 100644 index 000000000..9e3076ade --- /dev/null +++ b/src/test/ref/problem-struct-inline-parameter-1.log @@ -0,0 +1,443 @@ +Added struct type cast to parameter value list (void~) main::$0 ← call print (byte) 'c' (struct format){ (byte) '-', (byte) '-' } +Created struct value member variable (byte) print::fmt_prefix +Created struct value member variable (byte) print::fmt_postfix +Converted struct value to member variables (struct format) print::fmt +Converted procedure struct value parameter to member unwinding (void()) print((byte) print::c , (byte) print::fmt_prefix , (byte) print::fmt_postfix) +Converted call struct value parameter to member unwinding (void~) main::$0 ← call print (byte) 'c' (byte) '-' (byte) '-' +Replacing struct member reference (struct format) print::fmt.prefix with member unwinding reference (byte) print::fmt_prefix +Replacing struct member reference (struct format) print::fmt.postfix with member unwinding reference (byte) print::fmt_postfix + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + to:@1 + +(void()) main() +main: scope:[main] from @2 + (byte) idx#13 ← phi( @2/(byte) idx#14 ) + (byte) print::c#0 ← (byte) 'c' + (byte) print::fmt_prefix#0 ← (byte) '-' + (byte) print::fmt_postfix#0 ← (byte) '-' + call print + to:main::@1 +main::@1: scope:[main] from main + (byte) idx#8 ← phi( main/(byte) idx#6 ) + (byte) idx#0 ← (byte) idx#8 + to:main::@return +main::@return: scope:[main] from main::@1 + (byte) idx#9 ← phi( main::@1/(byte) idx#0 ) + (byte) idx#1 ← (byte) idx#9 + return + to:@return +@1: scope:[] from @begin + (byte) idx#2 ← (byte) 0 + to:@2 + +(void()) print((byte) print::c , (byte) print::fmt_prefix , (byte) print::fmt_postfix) +print: scope:[print] from main + (byte) print::fmt_postfix#1 ← phi( main/(byte) print::fmt_postfix#0 ) + (byte) print::c#1 ← phi( main/(byte) print::c#0 ) + (byte) idx#10 ← phi( main/(byte) idx#13 ) + (byte) print::fmt_prefix#1 ← phi( main/(byte) print::fmt_prefix#0 ) + *((const nomodify byte*) SCREEN + (byte) idx#10) ← (byte) print::fmt_prefix#1 + (byte) idx#3 ← ++ (byte) idx#10 + *((const nomodify byte*) SCREEN + (byte) idx#3) ← (byte) print::c#1 + (byte) idx#4 ← ++ (byte) idx#3 + *((const nomodify byte*) SCREEN + (byte) idx#4) ← (byte) print::fmt_postfix#1 + (byte) idx#5 ← ++ (byte) idx#4 + to:print::@return +print::@return: scope:[print] from print + (byte) idx#11 ← phi( print/(byte) idx#5 ) + (byte) idx#6 ← (byte) idx#11 + return + to:@return +@2: scope:[] from @1 + (byte) idx#14 ← phi( @1/(byte) idx#2 ) + call main + to:@3 +@3: scope:[] from @2 + (byte) idx#12 ← phi( @2/(byte) idx#1 ) + (byte) idx#7 ← (byte) idx#12 + to:@end +@end: scope:[] from @3 + +SYMBOL TABLE SSA +(label) @1 +(label) @2 +(label) @3 +(label) @begin +(label) @end +(const nomodify byte*) SCREEN = (byte*)(number) $400 +(byte) format::postfix +(byte) format::prefix +(byte) idx +(byte) idx#0 +(byte) idx#1 +(byte) idx#10 +(byte) idx#11 +(byte) idx#12 +(byte) idx#13 +(byte) idx#14 +(byte) idx#2 +(byte) idx#3 +(byte) idx#4 +(byte) idx#5 +(byte) idx#6 +(byte) idx#7 +(byte) idx#8 +(byte) idx#9 +(void()) main() +(label) main::@1 +(label) main::@return +(void()) print((byte) print::c , (byte) print::fmt_prefix , (byte) print::fmt_postfix) +(label) print::@return +(byte) print::c +(byte) print::c#0 +(byte) print::c#1 +(struct format) print::fmt +(byte) print::fmt_postfix +(byte) print::fmt_postfix#0 +(byte) print::fmt_postfix#1 +(byte) print::fmt_prefix +(byte) print::fmt_prefix#0 +(byte) print::fmt_prefix#1 + +Simplifying constant pointer cast (byte*) 1024 +Successful SSA optimization PassNCastSimplification +Alias idx#0 = idx#8 idx#9 idx#1 +Alias idx#11 = idx#5 idx#6 +Alias idx#14 = idx#2 +Alias idx#12 = idx#7 +Successful SSA optimization Pass2AliasElimination +Identical Phi Values (byte) idx#13 (byte) idx#14 +Identical Phi Values (byte) idx#0 (byte) idx#11 +Identical Phi Values (byte) print::fmt_prefix#1 (byte) print::fmt_prefix#0 +Identical Phi Values (byte) idx#10 (byte) idx#13 +Identical Phi Values (byte) print::c#1 (byte) print::c#0 +Identical Phi Values (byte) print::fmt_postfix#1 (byte) print::fmt_postfix#0 +Identical Phi Values (byte) idx#12 (byte) idx#0 +Successful SSA optimization Pass2IdenticalPhiElimination +Constant (const byte) print::c#0 = 'c' +Constant (const byte) print::fmt_prefix#0 = '-' +Constant (const byte) print::fmt_postfix#0 = '-' +Constant (const byte) idx#14 = 0 +Successful SSA optimization Pass2ConstantIdentification +Simplifying expression containing zero SCREEN in [9] *((const nomodify byte*) SCREEN + (const byte) idx#14) ← (const byte) print::fmt_prefix#0 +Successful SSA optimization PassNSimplifyExpressionWithZero +Eliminating unused variable (byte) idx#11 and assignment [7] (byte) idx#11 ← ++ (byte) idx#4 +Successful SSA optimization PassNEliminateUnusedVars +Constant right-side identified [3] (byte) idx#3 ← ++ (const byte) idx#14 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) idx#3 = ++idx#14 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [4] (byte) idx#4 ← ++ (const byte) idx#3 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) idx#4 = ++idx#3 +Successful SSA optimization Pass2ConstantIdentification +Inlining constant with different constant siblings (const byte) idx#14 +Inlining constant with different constant siblings (const byte) idx#3 +Inlining constant with different constant siblings (const byte) idx#4 +Constant inlined idx#4 = ++++(byte) 0 +Constant inlined idx#3 = ++(byte) 0 +Constant inlined idx#14 = (byte) 0 +Successful SSA optimization Pass2ConstantInlining +Consolidated array index constant in *(SCREEN+++0) +Consolidated array index constant in *(SCREEN+++++0) +Successful SSA optimization Pass2ConstantAdditionElimination +Simplifying constant integer increment ++0 +Simplifying constant integer increment ++0 +Successful SSA optimization Pass2ConstantSimplification +Simplifying constant integer increment ++1 +Successful SSA optimization Pass2ConstantSimplification +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 +Adding NOP phi() at start of main::@1 +CALL GRAPH +Calls in [] to main:3 +Calls in [main] to print:7 + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes +Culled Empty Block (label) @1 +Culled Empty Block (label) @3 +Culled Empty Block (label) main::@1 +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 print + to:main::@return +main::@return: scope:[main] from main + [6] return + to:@return + +(void()) print((byte) print::c , (byte) print::fmt_prefix , (byte) print::fmt_postfix) +print: scope:[print] from main + [7] *((const nomodify byte*) SCREEN) ← (const byte) print::fmt_prefix#0 + [8] *((const nomodify byte*) SCREEN+(byte) 1) ← (const byte) print::c#0 + [9] *((const nomodify byte*) SCREEN+(byte) 2) ← (const byte) print::fmt_postfix#0 + to:print::@return +print::@return: scope:[print] from print + [10] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(byte) format::postfix +(byte) format::prefix +(byte) idx +(void()) main() +(void()) print((byte) print::c , (byte) print::fmt_prefix , (byte) print::fmt_postfix) +(byte) print::c +(struct format) print::fmt +(byte) print::fmt_postfix +(byte) print::fmt_prefix + +Initial phi equivalence classes +Complete equivalence classes + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Illustrates problem with passing an inline struct value as a parameter + // Upstart +.pc = $801 "Basic" +:BasicUpstart(__bbegin) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // @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 print + jsr print + jmp __breturn + // main::@return + __breturn: + // [6] return + rts +} + // print +print: { + .const c = 'c' + .const fmt_prefix = '-' + .const fmt_postfix = '-' + // [7] *((const nomodify byte*) SCREEN) ← (const byte) print::fmt_prefix#0 -- _deref_pbuc1=vbuc2 + lda #fmt_prefix + sta SCREEN + // [8] *((const nomodify byte*) SCREEN+(byte) 1) ← (const byte) print::c#0 -- _deref_pbuc1=vbuc2 + lda #c + sta SCREEN+1 + // [9] *((const nomodify byte*) SCREEN+(byte) 2) ← (const byte) print::fmt_postfix#0 -- _deref_pbuc1=vbuc2 + lda #fmt_postfix + sta SCREEN+2 + jmp __breturn + // print::@return + __breturn: + // [10] return + rts +} + // File Data + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [7] *((const nomodify byte*) SCREEN) ← (const byte) print::fmt_prefix#0 [ ] ( main:2::print:5 [ ] { } ) always clobbers reg byte a +Statement [8] *((const nomodify byte*) SCREEN+(byte) 1) ← (const byte) print::c#0 [ ] ( main:2::print:5 [ ] { } ) always clobbers reg byte a +Statement [9] *((const nomodify byte*) SCREEN+(byte) 2) ← (const byte) print::fmt_postfix#0 [ ] ( main:2::print:5 [ ] { } ) always clobbers reg byte a + +REGISTER UPLIFT SCOPES +Uplift Scope [format] +Uplift Scope [main] +Uplift Scope [print] +Uplift Scope [] + +Uplifting [format] best 54 combination +Uplifting [main] best 54 combination +Uplifting [print] best 54 combination +Uplifting [] best 54 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Illustrates problem with passing an inline struct value as a parameter + // Upstart +.pc = $801 "Basic" +:BasicUpstart(__bbegin) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // @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 print + jsr print + jmp __breturn + // main::@return + __breturn: + // [6] return + rts +} + // print +print: { + .const c = 'c' + .const fmt_prefix = '-' + .const fmt_postfix = '-' + // [7] *((const nomodify byte*) SCREEN) ← (const byte) print::fmt_prefix#0 -- _deref_pbuc1=vbuc2 + lda #fmt_prefix + sta SCREEN + // [8] *((const nomodify byte*) SCREEN+(byte) 1) ← (const byte) print::c#0 -- _deref_pbuc1=vbuc2 + lda #c + sta SCREEN+1 + // [9] *((const nomodify byte*) SCREEN+(byte) 2) ← (const byte) print::fmt_postfix#0 -- _deref_pbuc1=vbuc2 + lda #fmt_postfix + sta SCREEN+2 + jmp __breturn + // print::@return + __breturn: + // [10] return + rts +} + // 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 main_from___b1: +Removing instruction __bend_from___b1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction __bend: +Removing instruction __breturn: +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin +Removing instruction __bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @begin +(label) @end +(const nomodify byte*) SCREEN = (byte*) 1024 +(byte) format::postfix +(byte) format::prefix +(byte) idx +(void()) main() +(label) main::@return +(void()) print((byte) print::c , (byte) print::fmt_prefix , (byte) print::fmt_postfix) +(label) print::@return +(byte) print::c +(const byte) print::c#0 c = (byte) 'c' +(struct format) print::fmt +(byte) print::fmt_postfix +(const byte) print::fmt_postfix#0 fmt_postfix = (byte) '-' +(byte) print::fmt_prefix +(const byte) print::fmt_prefix#0 fmt_prefix = (byte) '-' + + + +FINAL ASSEMBLER +Score: 36 + + // File Comments +// Illustrates problem with passing an inline struct value as a parameter + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // @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: { + // print('c', { '-', '-' } ) + // [5] call print + jsr print + // main::@return + // } + // [6] return + rts +} + // print +print: { + .const c = 'c' + .const fmt_prefix = '-' + .const fmt_postfix = '-' + // SCREEN[idx++] = fmt.prefix + // [7] *((const nomodify byte*) SCREEN) ← (const byte) print::fmt_prefix#0 -- _deref_pbuc1=vbuc2 + lda #fmt_prefix + sta SCREEN + // SCREEN[idx++] = c + // [8] *((const nomodify byte*) SCREEN+(byte) 1) ← (const byte) print::c#0 -- _deref_pbuc1=vbuc2 + lda #c + sta SCREEN+1 + // SCREEN[idx++] = fmt.postfix + // [9] *((const nomodify byte*) SCREEN+(byte) 2) ← (const byte) print::fmt_postfix#0 -- _deref_pbuc1=vbuc2 + lda #fmt_postfix + sta SCREEN+2 + // print::@return + // } + // [10] return + rts +} + // File Data + diff --git a/src/test/ref/problem-struct-inline-parameter-1.sym b/src/test/ref/problem-struct-inline-parameter-1.sym new file mode 100644 index 000000000..0106dcf49 --- /dev/null +++ b/src/test/ref/problem-struct-inline-parameter-1.sym @@ -0,0 +1,19 @@ +(label) @1 +(label) @begin +(label) @end +(const nomodify byte*) SCREEN = (byte*) 1024 +(byte) format::postfix +(byte) format::prefix +(byte) idx +(void()) main() +(label) main::@return +(void()) print((byte) print::c , (byte) print::fmt_prefix , (byte) print::fmt_postfix) +(label) print::@return +(byte) print::c +(const byte) print::c#0 c = (byte) 'c' +(struct format) print::fmt +(byte) print::fmt_postfix +(const byte) print::fmt_postfix#0 fmt_postfix = (byte) '-' +(byte) print::fmt_prefix +(const byte) print::fmt_prefix#0 fmt_prefix = (byte) '-' +