From 654005eea293b1a2e7d81a08d5d4cb542d4cc8a2 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Sun, 10 Nov 2024 18:59:29 +0100 Subject: [PATCH] updating tests --- lang/README.md | 15 ++--- lang/src/son.rs | 2 +- lang/tests/son_tests_different_types.txt | 18 +++--- lang/tests/son_tests_generic_types.txt | 50 +++++++-------- lang/tests/son_tests_inline_test.txt | 15 +---- ...ts_overwrite_aliasing_overoptimization.txt | 12 ++-- ...son_tests_storing_into_nullable_struct.txt | 64 +++++++++++++++++++ 7 files changed, 113 insertions(+), 63 deletions(-) diff --git a/lang/README.md b/lang/README.md index 40495772..0dbfea3d 100644 --- a/lang/README.md +++ b/lang/README.md @@ -640,14 +640,13 @@ main := fn(): uint { a.b = .(0) innera := do_stuff(a.b.c) - //val := optional() - //if val == null { - // return 20 - //} - //val.inner = 100 - //inner := do_stuff(val.inner) - return innera - //+ inner + val := optional() + if val == null { + return 20 + } + val.inner = 100 + inner := do_stuff(val.inner) + return innera + inner } ``` diff --git a/lang/src/son.rs b/lang/src/son.rs index 841fa8e9..6a263e32 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -4360,7 +4360,7 @@ impl<'a> Codegen<'a> { self.ci.nodes.basic_blocks(); self.ci.nodes.graphviz(self.ty_display(ty::Id::VOID)); } else { - self.ci.nodes.graphviz_in_browser(self.ty_display(ty::Id::VOID)); + //self.ci.nodes.graphviz_in_browser(self.ty_display(ty::Id::VOID)); } self.errors.borrow().len() == prev_err_len diff --git a/lang/tests/son_tests_different_types.txt b/lang/tests/son_tests_different_types.txt index b4d9b134..289bd70f 100644 --- a/lang/tests/son_tests_different_types.txt +++ b/lang/tests/son_tests_different_types.txt @@ -8,18 +8,18 @@ main: ST r1, r254, 3a, 1h LI32 r9, 0w ST r9, r254, 4a, 4h - LI32 r12, 2w - ST r12, r254, 8a, 4h - LD r3, r254, 8a, 4h - ANDI r3, r3, 4294967295d - ANDI r12, r12, 4294967295d - JEQ r3, r12, :0 + LD r4, r254, 4a, 4h + LI32 r1, 2w + ST r1, r254, 8a, 4h + LD r5, r254, 8a, 4h + ANDI r5, r5, 4294967295d + ANDI r1, r1, 4294967295d + JEQ r5, r1, :0 LI64 r1, 0d JMP :1 - 0: LD r10, r254, 4a, 4h - ANDI r10, r10, 4294967295d + 0: ANDI r4, r4, 4294967295d ANDI r9, r9, 4294967295d - JEQ r10, r9, :2 + JEQ r4, r9, :2 LI64 r1, 64d JMP :1 2: LI64 r1, 512d diff --git a/lang/tests/son_tests_generic_types.txt b/lang/tests/son_tests_generic_types.txt index 211b4a66..2fa320d9 100644 --- a/lang/tests/son_tests_generic_types.txt +++ b/lang/tests/son_tests_generic_types.txt @@ -58,8 +58,8 @@ new: ADDI64 r254, r254, 24d JALA r0, r31, 0a push: - ADDI64 r254, r254, -192d - ST r31, r254, 0a, 192h + ADDI64 r254, r254, -176d + ST r31, r254, 0a, 176h CP r32, r3 LI64 r33, 1d LD r34, r2, 8a, 8h @@ -76,20 +76,19 @@ push: CP r3, r39 JAL r31, r0, :malloc CP r40, r1 + CP r41, r36 + ST r38, r41, 16a, 8h LI64 r1, 0d - CP r41, r40 - JNE r41, r1, :3 + CP r42, r40 + JNE r42, r1, :3 JMP :4 - 3: CP r40, r41 - CP r42, r36 - ST r38, r42, 16a, 8h - LD r36, r42, 8a, 8h - MULI64 r43, r36, 8d - LD r44, r42, 0a, 8h + 3: CP r40, r42 + MULI64 r43, r34, 8d + LD r44, r41, 0a, 8h ADD64 r45, r44, r43 CP r46, r40 - 9: LD r2, r42, 0a, 8h - LD r47, r42, 8a, 8h + 9: LD r2, r41, 0a, 8h + LD r47, r41, 8a, 8h JNE r45, r44, :5 JEQ r47, r37, :6 CP r4, r39 @@ -98,30 +97,29 @@ push: CP r1, r40 JMP :7 6: CP r1, r40 - 7: ST r1, r42, 0a, 8h + 7: ST r1, r41, 0a, 8h JMP :8 5: CP r1, r40 CP r4, r39 - ADDI64 r41, r46, 8d - ADDI64 r48, r44, 8d + ADDI64 r48, r46, 8d + ADDI64 r42, r44, 8d LD r49, r44, 0a, 8h ST r49, r46, 0a, 8h - CP r44, r48 - CP r46, r41 + CP r44, r42 + CP r46, r48 JMP :9 - 0: CP r42, r36 - 8: LD r50, r42, 8a, 8h + 0: CP r41, r36 + 8: LD r50, r41, 8a, 8h MULI64 r51, r50, 8d - LD r52, r42, 0a, 8h + LD r52, r41, 0a, 8h ADD64 r1, r52, r51 CP r3, r32 ST r3, r1, 0a, 8h - LD r53, r42, 8a, 8h - ADD64 r54, r53, r33 - ST r54, r42, 8a, 8h - 4: LD r31, r254, 0a, 192h - ADDI64 r254, r254, 192d + ADD64 r39, r50, r33 + ST r39, r41, 8a, 8h + 4: LD r31, r254, 0a, 176h + ADDI64 r254, r254, 176d JALA r0, r31, 0a -code size: 955 +code size: 929 ret: 69 status: Ok(()) diff --git a/lang/tests/son_tests_inline_test.txt b/lang/tests/son_tests_inline_test.txt index 035bb3fb..d9ecdcd9 100644 --- a/lang/tests/son_tests_inline_test.txt +++ b/lang/tests/son_tests_inline_test.txt @@ -21,19 +21,8 @@ scalar_values: LI64 r1, 0d JALA r0, r31, 0a structs: - ADDI64 r254, r254, -32d - LI64 r1, 5d - ST r1, r254, 16a, 8h - ST r1, r254, 24a, 8h - LD r5, r254, 16a, 8h - ADDI64 r7, r5, 15d - ST r7, r254, 0a, 8h - LI64 r10, 20d - ST r10, r254, 8a, 8h - LD r1, r254, 0a, 8h - SUB64 r1, r1, r10 - ADDI64 r254, r254, 32d + LI64 r1, 0d JALA r0, r31, 0a -code size: 307 +code size: 182 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_overwrite_aliasing_overoptimization.txt b/lang/tests/son_tests_overwrite_aliasing_overoptimization.txt index ec02decd..8ca6b6fe 100644 --- a/lang/tests/son_tests_overwrite_aliasing_overoptimization.txt +++ b/lang/tests/son_tests_overwrite_aliasing_overoptimization.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -104d - ST r31, r254, 40a, 64h + ADDI64 r254, r254, -112d + ST r31, r254, 40a, 72h LI64 r32, 4d ADDI64 r33, r254, 24d ADDI64 r34, r254, 0d @@ -14,10 +14,10 @@ main: LD r36, r254, 8a, 8h LD r37, r254, 16a, 8h ADD64 r38, r37, r36 - LD r37, r254, 0a, 8h - SUB64 r1, r37, r38 - LD r31, r254, 40a, 64h - ADDI64 r254, r254, 104d + LD r39, r254, 0a, 8h + SUB64 r1, r39, r38 + LD r31, r254, 40a, 72h + ADDI64 r254, r254, 112d JALA r0, r31, 0a opaque: ADDI64 r254, r254, -16d diff --git a/lang/tests/son_tests_storing_into_nullable_struct.txt b/lang/tests/son_tests_storing_into_nullable_struct.txt index e69de29b..ac3afdd2 100644 --- a/lang/tests/son_tests_storing_into_nullable_struct.txt +++ b/lang/tests/son_tests_storing_into_nullable_struct.txt @@ -0,0 +1,64 @@ +do_stuff: + CP r1, r2 + JALA r0, r31, 0a +main: + ADDI64 r254, r254, -104d + ST r31, r254, 32a, 72h + ADDI64 r32, r254, 16d + JAL r31, r0, :optionala + ST r1, r254, 16a, 16h + LI8 r33, 0b + LD r34, r254, 16a, 1h + ANDI r34, r34, 255d + ANDI r33, r33, 255d + JNE r34, r33, :0 + LI64 r1, 10d + JMP :1 + 0: LI64 r35, 0d + ST r35, r254, 24a, 8h + LD r2, r254, 24a, 8h + JAL r31, r0, :do_stuff + CP r36, r1 + ADDI64 r37, r254, 0d + JAL r31, r0, :optional + ST r1, r254, 0a, 16h + LD r38, r254, 0a, 1h + ANDI r38, r38, 255d + ANDI r33, r33, 255d + JNE r38, r33, :2 + LI64 r1, 20d + JMP :1 + 2: LI64 r39, 100d + ST r39, r254, 8a, 8h + LD r2, r254, 8a, 8h + JAL r31, r0, :do_stuff + ADD64 r1, r1, r36 + 1: LD r31, r254, 32a, 72h + ADDI64 r254, r254, 104d + JALA r0, r31, 0a +optional: + ADDI64 r254, r254, -16d + LI8 r4, 1b + ADDI64 r3, r254, 0d + ST r4, r254, 0a, 1h + LI64 r4, 10d + ST r4, r254, 8a, 8h + LD r1, r3, 0a, 16h + ADDI64 r254, r254, 16d + JALA r0, r31, 0a +optionala: + ADDI64 r254, r254, -24d + ADDI64 r1, r254, 0d + LI64 r3, 1d + LI8 r7, 1b + ADDI64 r6, r254, 8d + ST r3, r254, 0a, 8h + ST r7, r254, 8a, 1h + ADDI64 r11, r6, 8d + BMC r1, r11, 8h + LD r1, r6, 0a, 16h + ADDI64 r254, r254, 24d + JALA r0, r31, 0a +code size: 568 +ret: 100 +status: Ok(())