From 397b2a4b1b7c088f379f32d846e235c1286e17e0 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Sun, 17 Nov 2024 10:06:10 +0100 Subject: [PATCH] fixed a stack prelude postlude being needlesly generated + struct can now be compared --- lang/README.md | 9 +- lang/src/lexer.rs | 4 + lang/src/lib.rs | 8 +- lang/src/son.rs | 87 +++++++++++++++++-- lang/src/son/hbvm/regalloc.rs | 4 +- ...sts_advanced_floating_point_arithmetic.txt | 14 ++- lang/tests/son_tests_arrays.txt | 14 ++- lang/tests/son_tests_big_array_crash.txt | 6 +- lang/tests/son_tests_branch_assignments.txt | 6 +- lang/tests/son_tests_c_strings.txt | 16 ++-- lang/tests/son_tests_comments.txt | 8 +- ...ts_comptime_function_from_another_file.txt | 6 +- .../tests/son_tests_comptime_min_reg_leak.txt | 6 +- lang/tests/son_tests_conditional_stores.txt | 8 +- lang/tests/son_tests_constants.txt | 6 +- ..._tests_different_function_destinations.txt | 16 ++-- lang/tests/son_tests_different_types.txt | 8 +- lang/tests/son_tests_directives.txt | 8 +- .../son_tests_exhaustive_loop_testing.txt | 36 +++----- lang/tests/son_tests_fb_driver.txt | 26 ++---- .../son_tests_floating_point_arithmetic.txt | 6 +- lang/tests/son_tests_functions.txt | 18 ++-- lang/tests/son_tests_generic_functions.txt | 18 ++-- lang/tests/son_tests_generic_type_mishap.txt | 16 ++-- lang/tests/son_tests_generic_types.txt | 40 ++++----- ..._tests_global_aliasing_overptimization.txt | 14 ++- .../son_tests_global_variable_wiredness.txt | 8 +- lang/tests/son_tests_global_variables.txt | 6 +- lang/tests/son_tests_idk.txt | 8 +- lang/tests/son_tests_if_statements.txt | 16 ++-- ...son_tests_infinite_loop_after_peephole.txt | 6 +- lang/tests/son_tests_inline.txt | 6 +- lang/tests/son_tests_inline_test.txt | 8 +- .../son_tests_inlined_generic_functions.txt | 6 +- lang/tests/son_tests_inlining_issues.txt | 16 ++-- lang/tests/son_tests_intcast_store.txt | 14 ++- .../son_tests_integer_inference_issues.txt | 14 ++- lang/tests/son_tests_loop_stores.txt | 8 +- lang/tests/son_tests_loops.txt | 16 ++-- lang/tests/son_tests_main_fn.txt | 6 +- lang/tests/son_tests_memory_swap.txt | 16 ++-- lang/tests/son_tests_more_if_opts.txt | 8 +- .../son_tests_null_check_in_the_loop.txt | 16 ++-- ...ests_null_check_returning_small_global.txt | 24 +++-- lang/tests/son_tests_null_check_test.txt | 8 +- lang/tests/son_tests_nullable_structure.txt | 26 ++---- lang/tests/son_tests_nullable_types.txt | 32 +++---- lang/tests/son_tests_only_break_loop.txt | 14 ++- lang/tests/son_tests_optional_from_eca.txt | 8 +- ...ts_overwrite_aliasing_overoptimization.txt | 16 ++-- lang/tests/son_tests_pointer_opts.txt | 14 ++- lang/tests/son_tests_pointers.txt | 14 ++- lang/tests/son_tests_request_page.txt | 22 ++--- .../son_tests_returning_global_struct.txt | 14 ++- .../son_tests_returning_optional_issues.txt | 16 ++-- .../son_tests_scheduling_block_did_dirty.txt | 22 ++--- .../son_tests_signed_to_unsigned_upcast.txt | 6 +- .../son_tests_small_struct_assignment.txt | 8 +- lang/tests/son_tests_small_struct_bitcast.txt | 22 ++--- lang/tests/son_tests_some_generic_code.txt | 8 +- .../son_tests_sort_something_viredly.txt | 16 ++-- ...son_tests_storing_into_nullable_struct.txt | 26 ++---- lang/tests/son_tests_string_flip.txt | 8 +- lang/tests/son_tests_struct_in_register.txt | 8 +- lang/tests/son_tests_struct_operators.txt | 6 +- lang/tests/son_tests_struct_patterns.txt | 24 +++-- ...sts_struct_return_from_module_function.txt | 16 ++-- lang/tests/son_tests_structs.txt | 20 ++--- .../tests/son_tests_tests_ptr_to_ptr_copy.txt | 8 +- ...s_triggering_store_in_divergent_branch.txt | 14 ++- lang/tests/son_tests_very_nested_loops.txt | 29 ++++++- lang/tests/son_tests_wide_ret.txt | 24 +++-- lang/tests/son_tests_writing_into_string.txt | 8 +- .../son_tests_wrong_dead_code_elimination.txt | 8 +- 74 files changed, 468 insertions(+), 607 deletions(-) diff --git a/lang/README.md b/lang/README.md index fa595d4..57a1ad8 100644 --- a/lang/README.md +++ b/lang/README.md @@ -313,9 +313,12 @@ Color := packed struct {b: u8, g: u8, r: u8, a: u8} main := fn(): uint { i := Color.(0, 0, 0, 0) i += .(1, 1, 1, 1) - if i.r + i.g + i.b + i.a != 4 { - return 1008 - } + if i.r + i.g + i.b + i.a != 4 return 1008 + + if Point.(1, 1) != Point.(1, 1) return 1009 + if Point.(1, 2) == Point.(1, 1) return 1010 + if Point.(1, 2) < Point.(1, 1) return 1011 + if Point.(1, 1) > Point.(2, 1) return 1012 a := Point.(1, 2) b := Point.(3, 4) diff --git a/lang/src/lexer.rs b/lang/src/lexer.rs index 4a7c9bb..002d4fd 100644 --- a/lang/src/lexer.rs +++ b/lang/src/lexer.rs @@ -193,6 +193,10 @@ impl TokenKind { matches!(self, S::Eq | S::Ne | S::Bor | S::Xor | S::Band | S::Add | S::Mul) } + pub fn is_compatison(self) -> bool { + matches!(self, Self::Lt | Self::Gt | Self::Ge | Self::Le | Self::Ne | Self::Eq) + } + pub fn is_supported_float_op(self) -> bool { matches!( self, diff --git a/lang/src/lib.rs b/lang/src/lib.rs index 0ec0601..5d13c4f 100644 --- a/lang/src/lib.rs +++ b/lang/src/lib.rs @@ -386,10 +386,10 @@ pub mod ty { pub const DINT: Self = Self::UINT; pub fn bin_ret(self, op: TokenKind) -> Id { - use TokenKind as T; - match op { - T::Lt | T::Gt | T::Le | T::Ge | T::Ne | T::Eq => Id::BOOL, - _ => self, + if op.is_compatison() { + Self::BOOL + } else { + self } } diff --git a/lang/src/son.rs b/lang/src/son.rs index 9208ed0..007792c 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -3066,15 +3066,7 @@ impl<'a> Codegen<'a> { self.strip_var(&mut rhs); self.implicit_unwrap(right.pos(), &mut rhs); let (ty, aclass) = self.binop_ty(pos, &mut lhs, &mut rhs, op); - if matches!( - op, - TokenKind::Lt - | TokenKind::Gt - | TokenKind::Ge - | TokenKind::Le - | TokenKind::Ne - | TokenKind::Eq - ) { + if op.is_compatison() { if lhs.ty.is_float() { } else { self.ci.nodes.lock(rhs.id); @@ -3109,6 +3101,22 @@ impl<'a> Codegen<'a> { self.struct_op(left.pos(), op, s, dst, lhs.id, rhs.id); Some(Value::ptr(dst).ty(lhs.ty)) } + ty::Kind::Struct(s) if op.is_compatison() => { + let binding_op = match op { + TokenKind::Eq => TokenKind::Band, + _ => TokenKind::Bor, + }; + + self.ci.nodes.lock(lhs.id); + let rhs = self.raw_expr_ctx(right, Ctx::default().with_ty(lhs.ty)); + self.ci.nodes.unlock(lhs.id); + let mut rhs = rhs?; + self.strip_var(&mut rhs); + self.assert_ty(pos, &mut rhs, lhs.ty, "struct operand"); + + self.struct_fold_op(left.pos(), op, binding_op, s, lhs.id, rhs.id) + .or(Value::NEVER) + } _ => { self.report( pos, @@ -4149,6 +4157,67 @@ impl<'a> Codegen<'a> { true } + fn struct_fold_op( + &mut self, + pos: Pos, + op: TokenKind, + fold_op: TokenKind, + s: ty::Struct, + lhs: Nid, + rhs: Nid, + ) -> Option { + debug_assert!(op.is_compatison()); + + let mut fold = None; + let mut offs = OffsetIter::new(s, self.tys); + while let Some((ty, off)) = offs.next_ty(self.tys) { + let lhs = self.offset(lhs, off); + let rhs = self.offset(rhs, off); + let vl = match ty.expand() { + _ if ty.is_pointer() || ty.is_integer() || ty == ty::Id::BOOL => { + let lhs = self.load_mem(lhs, ty); + let rhs = self.load_mem(rhs, ty); + self.ci.nodes.new_node( + ty::Id::BOOL, + Kind::BinOp { op }, + [VOID, lhs, rhs], + self.tys, + ) + } + ty::Kind::Struct(is) => match self.struct_fold_op(pos, op, fold_op, is, lhs, rhs) { + Some(v) => v.id, + None => { + self.report( + pos, + fa!("...when appliing '{0} {op} {0}'", self.ty_display(s.into())), + ); + return None; + } + }, + _ => { + self.report(pos, fa!("'{0} {op} {0}' is not supported", self.ty_display(ty))); + return None; + } + }; + + fold = Some(match fold { + None => vl, + Some(o) => self.ci.nodes.new_node( + ty::Id::BOOL, + Kind::BinOp { op: fold_op }, + [VOID, o, vl], + self.tys, + ), + }); + } + + match op { + _ if let Some(fold) = fold => Some(Value::new(fold).ty(ty::Id::BOOL)), + TokenKind::Eq => Some(self.ci.nodes.new_const_lit(ty::Id::BOOL, true)), + _ => Some(self.ci.nodes.new_const_lit(ty::Id::BOOL, false)), + } + } + fn compute_signature(&mut self, func: &mut ty::Func, pos: Pos, args: &[Expr]) -> Option { let Func { file, expr, sig, .. } = self.tys.ins.funcs[*func]; let fast = self.files[file.index()].clone(); diff --git a/lang/src/son/hbvm/regalloc.rs b/lang/src/son/hbvm/regalloc.rs index 8eadb73..f6c309a 100644 --- a/lang/src/son/hbvm/regalloc.rs +++ b/lang/src/son/hbvm/regalloc.rs @@ -301,10 +301,10 @@ impl HbvmBackend { let bundle_count = self.ralloc.bundles.len() + (reg_offset as usize); ( if tail { + bundle_count.saturating_sub(reg::RET_ADDR as _) + } else { assert!(bundle_count < reg::STACK_PTR as usize, "TODO: spill memory"); self.ralloc.bundles.len() - } else { - bundle_count.saturating_sub(reg::RET_ADDR as _) }, tail, ) diff --git a/lang/tests/son_tests_advanced_floating_point_arithmetic.txt b/lang/tests/son_tests_advanced_floating_point_arithmetic.txt index 1c95532..076c2e7 100644 --- a/lang/tests/son_tests_advanced_floating_point_arithmetic.txt +++ b/lang/tests/son_tests_advanced_floating_point_arithmetic.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h LI32 r32, 1148846080w CP r2, r32 JAL r31, r0, :sin @@ -8,12 +8,10 @@ main: FMUL32 r32, r33, r32 FTI32 r32, r32, 1b CP r1, r32 - LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + LD r31, r254, 0a, 24h + ADDI64 r254, r254, 24d JALA r0, r31, 0a sin: - ADDI64 r254, r254, -56d - ST r32, r254, 0a, 56h CP r13, r2 LI32 r14, 1124073472w LI32 r15, 1078530011w @@ -44,9 +42,7 @@ sin: FMUL32 r13, r14, r13 FADD32 r13, r15, r13 CP r1, r13 - LD r32, r254, 0a, 56h - ADDI64 r254, r254, 56d JALA r0, r31, 0a -code size: 1363 +code size: 1315 ret: 826 status: Ok(()) diff --git a/lang/tests/son_tests_arrays.txt b/lang/tests/son_tests_arrays.txt index b990646..451a888 100644 --- a/lang/tests/son_tests_arrays.txt +++ b/lang/tests/son_tests_arrays.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -64d - ST r31, r254, 24a, 40h + ADDI64 r254, r254, -56d + ST r31, r254, 24a, 32h LI64 r32, 1d ADDI64 r33, r254, 0d ST r32, r254, 0a, 8h @@ -13,12 +13,10 @@ main: CP r33, r1 ADD64 r32, r33, r32 CP r1, r32 - LD r31, r254, 24a, 40h - ADDI64 r254, r254, 64d + LD r31, r254, 24a, 32h + ADDI64 r254, r254, 56d JALA r0, r31, 0a pass: - ADDI64 r254, r254, -32d - ST r32, r254, 0a, 32h CP r13, r2 LD r14, r13, 8a, 8h MULI64 r15, r14, 8d @@ -28,9 +26,7 @@ pass: LD r13, r13, 0a, 8h ADD64 r13, r13, r14 CP r1, r13 - LD r32, r254, 0a, 32h - ADDI64 r254, r254, 32d JALA r0, r31, 0a -code size: 294 +code size: 246 ret: 8 status: Ok(()) diff --git a/lang/tests/son_tests_big_array_crash.txt b/lang/tests/son_tests_big_array_crash.txt index 8f92834..61ce17b 100644 --- a/lang/tests/son_tests_big_array_crash.txt +++ b/lang/tests/son_tests_big_array_crash.txt @@ -1,12 +1,8 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LRA r13, r0, :SIN_TABLE LD r13, r13, 80a, 8h CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 818 +code size: 770 ret: 1736 status: Ok(()) diff --git a/lang/tests/son_tests_branch_assignments.txt b/lang/tests/son_tests_branch_assignments.txt index 3f7738c..425456a 100644 --- a/lang/tests/son_tests_branch_assignments.txt +++ b/lang/tests/son_tests_branch_assignments.txt @@ -1,6 +1,4 @@ main: - ADDI64 r254, r254, -16d - ST r32, r254, 0a, 16h CP r14, r2 LI64 r13, 1d JNE r14, r13, :0 @@ -10,9 +8,7 @@ main: JMP :1 2: LI64 r13, 3d 1: CP r1, r13 - LD r32, r254, 0a, 16h - ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 123 +code size: 75 ret: 2 status: Ok(()) diff --git a/lang/tests/son_tests_c_strings.txt b/lang/tests/son_tests_c_strings.txt index a0e2d17..a4bc715 100644 --- a/lang/tests/son_tests_c_strings.txt +++ b/lang/tests/son_tests_c_strings.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h LRA r32, r0, :"abāļž\n\r\t56789\0" CP r2, r32 JAL r31, r0, :str_len @@ -11,12 +11,10 @@ main: CP r33, r1 ADD64 r32, r33, r32 CP r1, r32 - LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + LD r31, r254, 0a, 24h + ADDI64 r254, r254, 24d JALA r0, r31, 0a str_len: - ADDI64 r254, r254, -32d - ST r32, r254, 0a, 32h CP r15, r2 CP r14, r0 CP r13, r14 @@ -28,9 +26,7 @@ str_len: 0: ADDI64 r15, r15, 1d ADDI64 r13, r13, 1d JMP :2 - 1: LD r32, r254, 0a, 32h - ADDI64 r254, r254, 32d - JALA r0, r31, 0a -code size: 264 + 1: JALA r0, r31, 0a +code size: 216 ret: 16 status: Ok(()) diff --git a/lang/tests/son_tests_comments.txt b/lang/tests/son_tests_comments.txt index b91aab0..5ae5345 100644 --- a/lang/tests/son_tests_comments.txt +++ b/lang/tests/son_tests_comments.txt @@ -1,12 +1,12 @@ foo: JALA r0, r31, 0a main: - ADDI64 r254, r254, -16d - ST r31, r254, 0a, 16h + ADDI64 r254, r254, -8d + ST r31, r254, 0a, 8h JAL r31, r0, :foo CP r1, r0 - LD r31, r254, 0a, 16h - ADDI64 r254, r254, 16d + LD r31, r254, 0a, 8h + ADDI64 r254, r254, 8d JALA r0, r31, 0a code size: 88 ret: 0 diff --git a/lang/tests/son_tests_comptime_function_from_another_file.txt b/lang/tests/son_tests_comptime_function_from_another_file.txt index 16cc183..453d2c0 100644 --- a/lang/tests/son_tests_comptime_function_from_another_file.txt +++ b/lang/tests/son_tests_comptime_function_from_another_file.txt @@ -1,12 +1,8 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LRA r13, r0, :a LD r13, r13, 0a, 8h CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 98 +code size: 50 ret: 50 status: Ok(()) diff --git a/lang/tests/son_tests_comptime_min_reg_leak.txt b/lang/tests/son_tests_comptime_min_reg_leak.txt index 16cc183..453d2c0 100644 --- a/lang/tests/son_tests_comptime_min_reg_leak.txt +++ b/lang/tests/son_tests_comptime_min_reg_leak.txt @@ -1,12 +1,8 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LRA r13, r0, :a LD r13, r13, 0a, 8h CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 98 +code size: 50 ret: 50 status: Ok(()) diff --git a/lang/tests/son_tests_conditional_stores.txt b/lang/tests/son_tests_conditional_stores.txt index 8f448a8..4e7b7ec 100644 --- a/lang/tests/son_tests_conditional_stores.txt +++ b/lang/tests/son_tests_conditional_stores.txt @@ -2,8 +2,8 @@ cond: CP r1, r0 JALA r0, r31, 0a main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h JAL r31, r0, :cond CP r33, r1 CP r32, r0 @@ -11,8 +11,8 @@ main: JMP :1 0: LI64 r32, 2d 1: CP r1, r32 - LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + LD r31, r254, 0a, 24h + ADDI64 r254, r254, 24d JALA r0, r31, 0a code size: 117 ret: 0 diff --git a/lang/tests/son_tests_constants.txt b/lang/tests/son_tests_constants.txt index 6576f56..543f71d 100644 --- a/lang/tests/son_tests_constants.txt +++ b/lang/tests/son_tests_constants.txt @@ -1,11 +1,7 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LI32 r13, 69w CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 76 +code size: 28 ret: 69 status: Ok(()) diff --git a/lang/tests/son_tests_different_function_destinations.txt b/lang/tests/son_tests_different_function_destinations.txt index 18f9921..22d7555 100644 --- a/lang/tests/son_tests_different_function_destinations.txt +++ b/lang/tests/son_tests_different_function_destinations.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -152d - ST r31, r254, 80a, 72h + ADDI64 r254, r254, -144d + ST r31, r254, 80a, 64h LRA r32, r0, :glob_stru JAL r31, r0, :new_stru ST r1, r32, 0a, 16h @@ -68,19 +68,17 @@ main: ST r1, r34, 0a, 16h ADD64 r32, r32, r35 JMP :8 - 1: LD r31, r254, 80a, 72h - ADDI64 r254, r254, 152d + 1: LD r31, r254, 80a, 64h + ADDI64 r254, r254, 144d JALA r0, r31, 0a new_stru: - ADDI64 r254, r254, -24d - ST r32, r254, 16a, 8h + ADDI64 r254, r254, -16d ADDI64 r13, r254, 0d ST r0, r254, 0a, 8h ST r0, r254, 8a, 8h LD r1, r13, 0a, 16h - LD r32, r254, 16a, 8h - ADDI64 r254, r254, 24d + ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 791 +code size: 765 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_different_types.txt b/lang/tests/son_tests_different_types.txt index c2c72c1..f3f61d7 100644 --- a/lang/tests/son_tests_different_types.txt +++ b/lang/tests/son_tests_different_types.txt @@ -1,6 +1,5 @@ main: - ADDI64 r254, r254, -36d - ST r32, r254, 12a, 24h + ADDI64 r254, r254, -12d LI8 r13, 255b ST r13, r254, 0a, 1h ST r0, r254, 1a, 1h @@ -23,9 +22,8 @@ main: JMP :1 2: LI64 r13, 512d CP r1, r13 - 1: LD r32, r254, 12a, 24h - ADDI64 r254, r254, 36d + 1: ADDI64 r254, r254, 12d JALA r0, r31, 0a -code size: 261 +code size: 235 ret: 512 status: Ok(()) diff --git a/lang/tests/son_tests_directives.txt b/lang/tests/son_tests_directives.txt index a29e1a8..b2e84f9 100644 --- a/lang/tests/son_tests_directives.txt +++ b/lang/tests/son_tests_directives.txt @@ -1,6 +1,5 @@ main: - ADDI64 r254, r254, -48d - ST r32, r254, 16a, 32h + ADDI64 r254, r254, -16d LI64 r13, 10d ADDI64 r14, r254, 0d ST r13, r254, 0a, 8h @@ -15,10 +14,9 @@ main: LD r3, r14, 0a, 16h ECA CP r1, r0 - LD r32, r254, 16a, 32h - ADDI64 r254, r254, 48d + ADDI64 r254, r254, 16d JALA r0, r31, 0a ev: Ecall -code size: 180 +code size: 154 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_exhaustive_loop_testing.txt b/lang/tests/son_tests_exhaustive_loop_testing.txt index 23cb945..c4c1842 100644 --- a/lang/tests/son_tests_exhaustive_loop_testing.txt +++ b/lang/tests/son_tests_exhaustive_loop_testing.txt @@ -1,6 +1,4 @@ continue_and_state_change: - ADDI64 r254, r254, -48d - ST r32, r254, 0a, 48h CP r13, r2 CP r15, r0 LI64 r16, 3d @@ -18,12 +16,10 @@ continue_and_state_change: JMP :5 4: ADDI64 r13, r13, 1d 3: JMP :6 - 5: LD r32, r254, 0a, 48h - ADDI64 r254, r254, 48d - JALA r0, r31, 0a + 5: JALA r0, r31, 0a infinite_loop: - ADDI64 r254, r254, -40d - ST r31, r254, 0a, 40h + ADDI64 r254, r254, -32d + ST r31, r254, 0a, 32h LI64 r34, 1d CP r33, r0 CP r32, r33 @@ -33,12 +29,12 @@ infinite_loop: JAL r31, r0, :continue_and_state_change CP r32, r1 JMP :1 - LD r31, r254, 0a, 40h - ADDI64 r254, r254, 40d + LD r31, r254, 0a, 32h + ADDI64 r254, r254, 32d JALA r0, r31, 0a main: - ADDI64 r254, r254, -48d - ST r31, r254, 0a, 48h + ADDI64 r254, r254, -40d + ST r31, r254, 0a, 40h CP r2, r0 JAL r31, r0, :multiple_breaks CP r32, r1 @@ -84,12 +80,10 @@ main: JMP :1 6: JAL r31, r0, :infinite_loop CP r1, r0 - 1: LD r31, r254, 0a, 48h - ADDI64 r254, r254, 48d + 1: LD r31, r254, 0a, 40h + ADDI64 r254, r254, 40d JALA r0, r31, 0a multiple_breaks: - ADDI64 r254, r254, -24d - ST r32, r254, 0a, 24h CP r13, r2 LI64 r14, 3d LI64 r15, 10d @@ -100,12 +94,8 @@ multiple_breaks: 1: CP r1, r13 JMP :3 2: JMP :4 - 3: LD r32, r254, 0a, 24h - ADDI64 r254, r254, 24d - JALA r0, r31, 0a + 3: JALA r0, r31, 0a state_change_in_break: - ADDI64 r254, r254, -24d - ST r32, r254, 0a, 24h CP r13, r2 LI64 r14, 3d LI64 r15, 10d @@ -117,10 +107,8 @@ state_change_in_break: JMP :3 2: ADDI64 r13, r13, 1d JMP :4 - 3: LD r32, r254, 0a, 24h - ADDI64 r254, r254, 24d - JALA r0, r31, 0a + 3: JALA r0, r31, 0a timed out -code size: 811 +code size: 667 ret: 10 status: Ok(()) diff --git a/lang/tests/son_tests_fb_driver.txt b/lang/tests/son_tests_fb_driver.txt index c3f362b..6c45b87 100644 --- a/lang/tests/son_tests_fb_driver.txt +++ b/lang/tests/son_tests_fb_driver.txt @@ -1,15 +1,15 @@ check_platform: - ADDI64 r254, r254, -24d - ST r31, r254, 0a, 24h + ADDI64 r254, r254, -16d + ST r31, r254, 0a, 16h JAL r31, r0, :x86_fb_ptr CP r32, r1 CP r1, r32 - LD r31, r254, 0a, 24h - ADDI64 r254, r254, 24d + LD r31, r254, 0a, 16h + ADDI64 r254, r254, 16d JALA r0, r31, 0a main: - ADDI64 r254, r254, -64d - ST r31, r254, 0a, 64h + ADDI64 r254, r254, -56d + ST r31, r254, 0a, 56h JAL r31, r0, :check_platform CP r33, r0 LI64 r36, 30d @@ -35,29 +35,21 @@ main: 0: ADDI64 r35, r35, 1d ADDI64 r32, r32, 1d 4: JMP :5 - 2: LD r31, r254, 0a, 64h - ADDI64 r254, r254, 64d + 2: LD r31, r254, 0a, 56h + ADDI64 r254, r254, 56d JALA r0, r31, 0a set_pixel: - ADDI64 r254, r254, -24d - ST r32, r254, 0a, 24h CP r13, r2 CP r14, r3 CP r15, r4 MUL64 r14, r14, r15 ADD64 r13, r14, r13 CP r1, r13 - LD r32, r254, 0a, 24h - ADDI64 r254, r254, 24d JALA r0, r31, 0a x86_fb_ptr: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LI64 r13, 100d CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 425 +code size: 329 ret: 3000 status: Ok(()) diff --git a/lang/tests/son_tests_floating_point_arithmetic.txt b/lang/tests/son_tests_floating_point_arithmetic.txt index fde9aa7..0172efa 100644 --- a/lang/tests/son_tests_floating_point_arithmetic.txt +++ b/lang/tests/son_tests_floating_point_arithmetic.txt @@ -1,11 +1,7 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LI32 r13, 3212836864w CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 76 +code size: 28 ret: 3212836864 status: Ok(()) diff --git a/lang/tests/son_tests_functions.txt b/lang/tests/son_tests_functions.txt index 0dab658..6cc8971 100644 --- a/lang/tests/son_tests_functions.txt +++ b/lang/tests/son_tests_functions.txt @@ -1,24 +1,16 @@ add_one: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h CP r13, r2 ADDI64 r13, r13, 1d CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a add_two: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h CP r13, r2 ADDI64 r13, r13, 2d CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h LI64 r32, 10d CP r2, r32 JAL r31, r0, :add_one @@ -29,9 +21,9 @@ main: CP r33, r1 ADD64 r32, r33, r32 CP r1, r32 - LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + LD r31, r254, 0a, 24h + ADDI64 r254, r254, 24d JALA r0, r31, 0a -code size: 272 +code size: 176 ret: 33 status: Ok(()) diff --git a/lang/tests/son_tests_generic_functions.txt b/lang/tests/son_tests_generic_functions.txt index c796855..3e56d70 100644 --- a/lang/tests/son_tests_generic_functions.txt +++ b/lang/tests/son_tests_generic_functions.txt @@ -1,26 +1,18 @@ add: - ADDI64 r254, r254, -16d - ST r32, r254, 0a, 16h CP r13, r2 CP r14, r3 ADD64 r13, r13, r14 CP r1, r13 - LD r32, r254, 0a, 16h - ADDI64 r254, r254, 16d JALA r0, r31, 0a add: - ADDI64 r254, r254, -16d - ST r32, r254, 0a, 16h CP r13, r2 CP r14, r3 ADD32 r13, r13, r14 CP r1, r13 - LD r32, r254, 0a, 16h - ADDI64 r254, r254, 16d JALA r0, r31, 0a main: - ADDI64 r254, r254, -40d - ST r31, r254, 0a, 40h + ADDI64 r254, r254, -32d + ST r31, r254, 0a, 32h LI32 r32, 2w CP r2, r32 CP r3, r32 @@ -35,9 +27,9 @@ main: ANDI r32, r32, 4294967295d SUB64 r32, r32, r33 CP r1, r32 - LD r31, r254, 0a, 40h - ADDI64 r254, r254, 40d + LD r31, r254, 0a, 32h + ADDI64 r254, r254, 32d JALA r0, r31, 0a -code size: 287 +code size: 191 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_generic_type_mishap.txt b/lang/tests/son_tests_generic_type_mishap.txt index cbdeecb..4841b9f 100644 --- a/lang/tests/son_tests_generic_type_mishap.txt +++ b/lang/tests/son_tests_generic_type_mishap.txt @@ -1,15 +1,15 @@ main: - ADDI64 r254, r254, -16d - ST r31, r254, 0a, 16h + ADDI64 r254, r254, -8d + ST r31, r254, 0a, 8h JAL r31, r0, :process - LD r31, r254, 0a, 16h - ADDI64 r254, r254, 16d + LD r31, r254, 0a, 8h + ADDI64 r254, r254, 8d JALA r0, r31, 0a opaque: JALA r0, r31, 0a process: - ADDI64 r254, r254, -56d - ST r31, r254, 16a, 40h + ADDI64 r254, r254, -48d + ST r31, r254, 16a, 32h LI64 r32, 1000d ADDI64 r33, r254, 0d ST r0, r254, 0a, 1h @@ -23,8 +23,8 @@ process: JMP :3 2: ADDI64 r32, r32, -1d 1: JMP :4 - 3: LD r31, r254, 16a, 40h - ADDI64 r254, r254, 56d + 3: LD r31, r254, 16a, 32h + ADDI64 r254, r254, 48d JALA r0, r31, 0a timed out code size: 248 diff --git a/lang/tests/son_tests_generic_types.txt b/lang/tests/son_tests_generic_types.txt index f96cf42..b71e0bb 100644 --- a/lang/tests/son_tests_generic_types.txt +++ b/lang/tests/son_tests_generic_types.txt @@ -1,6 +1,6 @@ deinit: - ADDI64 r254, r254, -48d - ST r31, r254, 0a, 48h + ADDI64 r254, r254, -40d + ST r31, r254, 0a, 40h CP r32, r2 LD r33, r32, 16a, 8h LI64 r34, 8d @@ -12,12 +12,10 @@ deinit: JAL r31, r0, :free CP r1, r32 JAL r31, r0, :new - LD r31, r254, 0a, 48h - ADDI64 r254, r254, 48d + LD r31, r254, 0a, 40h + ADDI64 r254, r254, 40d JALA r0, r31, 0a free: - ADDI64 r254, r254, -32d - ST r32, r254, 0a, 32h CP r13, r2 CP r14, r3 CP r15, r4 @@ -28,12 +26,10 @@ free: CP r4, r14 CP r5, r15 ECA - LD r32, r254, 0a, 32h - ADDI64 r254, r254, 32d JALA r0, r31, 0a main: - ADDI64 r254, r254, -64d - ST r31, r254, 24a, 40h + ADDI64 r254, r254, -56d + ST r31, r254, 24a, 32h ADDI64 r32, r254, 0d CP r1, r32 JAL r31, r0, :new @@ -47,12 +43,10 @@ main: CP r2, r32 JAL r31, r0, :deinit CP r1, r33 - LD r31, r254, 24a, 40h - ADDI64 r254, r254, 64d + LD r31, r254, 24a, 32h + ADDI64 r254, r254, 56d JALA r0, r31, 0a malloc: - ADDI64 r254, r254, -24d - ST r32, r254, 0a, 24h CP r13, r2 CP r14, r3 LRA r15, r0, :MALLOC_SYS_CALL @@ -63,24 +57,20 @@ malloc: ECA CP r13, r1 CP r1, r13 - LD r32, r254, 0a, 24h - ADDI64 r254, r254, 24d JALA r0, r31, 0a new: - ADDI64 r254, r254, -32d - ST r32, r254, 24a, 8h + ADDI64 r254, r254, -24d CP r14, r1 ADDI64 r13, r254, 0d ST r0, r254, 0a, 8h ST r0, r254, 8a, 8h ST r0, r254, 16a, 8h BMC r13, r14, 24h - LD r32, r254, 24a, 8h - ADDI64 r254, r254, 32d + ADDI64 r254, r254, 24d JALA r0, r31, 0a push: - ADDI64 r254, r254, -112d - ST r31, r254, 0a, 112h + ADDI64 r254, r254, -104d + ST r31, r254, 0a, 104h CP r38, r2 CP r39, r3 LI64 r37, 1d @@ -132,9 +122,9 @@ push: ADD64 r32, r32, r37 ST r32, r38, 8a, 8h CP r1, r33 - 4: LD r31, r254, 0a, 112h - ADDI64 r254, r254, 112d + 4: LD r31, r254, 0a, 104h + ADDI64 r254, r254, 104d JALA r0, r31, 0a -code size: 1045 +code size: 923 ret: 69 status: Ok(()) diff --git a/lang/tests/son_tests_global_aliasing_overptimization.txt b/lang/tests/son_tests_global_aliasing_overptimization.txt index 3dbf30f..3b85124 100644 --- a/lang/tests/son_tests_global_aliasing_overptimization.txt +++ b/lang/tests/son_tests_global_aliasing_overptimization.txt @@ -1,23 +1,19 @@ clobber: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LRA r13, r0, :var ST r0, r13, 0a, 8h - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h LRA r32, r0, :var LI64 r33, 2d ST r33, r32, 0a, 8h JAL r31, r0, :clobber LD r32, r32, 0a, 8h CP r1, r32 - LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + LD r31, r254, 0a, 24h + ADDI64 r254, r254, 24d JALA r0, r31, 0a -code size: 207 +code size: 159 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_global_variable_wiredness.txt b/lang/tests/son_tests_global_variable_wiredness.txt index bf239e5..6fde6ec 100644 --- a/lang/tests/son_tests_global_variable_wiredness.txt +++ b/lang/tests/son_tests_global_variable_wiredness.txt @@ -2,8 +2,8 @@ inb: CP r1, r0 JALA r0, r31, 0a main: - ADDI64 r254, r254, -40d - ST r31, r254, 0a, 40h + ADDI64 r254, r254, -32d + ST r31, r254, 0a, 32h LRA r32, r0, :ports LD r33, r32, 0a, 1h ANDI r33, r33, 255d @@ -15,8 +15,8 @@ main: CMPUI r34, r34, 0d NOT r34, r34 ST r34, r32, 0a, 1h - 1: LD r31, r254, 0a, 40h - ADDI64 r254, r254, 40d + 1: LD r31, r254, 0a, 32h + ADDI64 r254, r254, 32d JALA r0, r31, 0a code size: 164 ret: 0 diff --git a/lang/tests/son_tests_global_variables.txt b/lang/tests/son_tests_global_variables.txt index f6547bc..30d4fe3 100644 --- a/lang/tests/son_tests_global_variables.txt +++ b/lang/tests/son_tests_global_variables.txt @@ -1,14 +1,10 @@ main: - ADDI64 r254, r254, -16d - ST r32, r254, 0a, 16h LRA r13, r0, :complex_global_var LD r14, r13, 0a, 8h ADDI64 r14, r14, 5d ST r14, r13, 0a, 8h CP r1, r14 - LD r32, r254, 0a, 16h - ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 122 +code size: 74 ret: 55 status: Ok(()) diff --git a/lang/tests/son_tests_idk.txt b/lang/tests/son_tests_idk.txt index 8a385b0..a58d12f 100644 --- a/lang/tests/son_tests_idk.txt +++ b/lang/tests/son_tests_idk.txt @@ -1,6 +1,5 @@ main: - ADDI64 r254, r254, -176d - ST r32, r254, 128a, 48h + ADDI64 r254, r254, -128d LI8 r15, 69b LI64 r16, 128d CP r13, r0 @@ -15,9 +14,8 @@ main: ST r15, r13, 0a, 1h CP r13, r14 JMP :2 - 1: LD r32, r254, 128a, 48h - ADDI64 r254, r254, 176d + 1: ADDI64 r254, r254, 128d JALA r0, r31, 0a -code size: 167 +code size: 141 ret: 69 status: Ok(()) diff --git a/lang/tests/son_tests_if_statements.txt b/lang/tests/son_tests_if_statements.txt index 8b32e41..287ef3c 100644 --- a/lang/tests/son_tests_if_statements.txt +++ b/lang/tests/son_tests_if_statements.txt @@ -1,6 +1,6 @@ fib: - ADDI64 r254, r254, -40d - ST r31, r254, 0a, 40h + ADDI64 r254, r254, -32d + ST r31, r254, 0a, 32h CP r32, r2 LI64 r33, 1d LI64 r34, 2d @@ -17,19 +17,19 @@ fib: CP r32, r1 ADD64 r32, r32, r33 CP r1, r32 - 1: LD r31, r254, 0a, 40h - ADDI64 r254, r254, 40d + 1: LD r31, r254, 0a, 32h + ADDI64 r254, r254, 32d JALA r0, r31, 0a main: - ADDI64 r254, r254, -24d - ST r31, r254, 0a, 24h + ADDI64 r254, r254, -16d + ST r31, r254, 0a, 16h LI64 r32, 10d CP r2, r32 JAL r31, r0, :fib CP r32, r1 CP r1, r32 - LD r31, r254, 0a, 24h - ADDI64 r254, r254, 24d + LD r31, r254, 0a, 16h + ADDI64 r254, r254, 16d JALA r0, r31, 0a code size: 229 ret: 55 diff --git a/lang/tests/son_tests_infinite_loop_after_peephole.txt b/lang/tests/son_tests_infinite_loop_after_peephole.txt index e4309f2..b1c96f0 100644 --- a/lang/tests/son_tests_infinite_loop_after_peephole.txt +++ b/lang/tests/son_tests_infinite_loop_after_peephole.txt @@ -1,13 +1,9 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h CP r13, r0 0: ADDI64 r13, r13, 1d JMP :0 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a timed out -code size: 86 +code size: 38 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_inline.txt b/lang/tests/son_tests_inline.txt index c40a6f5..9332068 100644 --- a/lang/tests/son_tests_inline.txt +++ b/lang/tests/son_tests_inline.txt @@ -1,6 +1,4 @@ main: - ADDI64 r254, r254, -16d - ST r32, r254, 0a, 16h LI64 r13, 8d CP r2, r13 ECA @@ -17,9 +15,7 @@ main: 0: LI64 r13, 1d 1: SUB64 r13, r13, r14 CP r1, r13 - LD r32, r254, 0a, 16h - ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 179 +code size: 131 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_inline_test.txt b/lang/tests/son_tests_inline_test.txt index 7a58794..af86bd3 100644 --- a/lang/tests/son_tests_inline_test.txt +++ b/lang/tests/son_tests_inline_test.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -24d - ST r31, r254, 0a, 24h + ADDI64 r254, r254, -16d + ST r31, r254, 0a, 16h JAL r31, r0, :scalar_values CP r32, r1 JEQ r32, r0, :0 @@ -15,8 +15,8 @@ main: CP r1, r32 JMP :1 2: CP r1, r0 - 1: LD r31, r254, 0a, 24h - ADDI64 r254, r254, 24d + 1: LD r31, r254, 0a, 16h + ADDI64 r254, r254, 16d JALA r0, r31, 0a scalar_values: CP r1, r0 diff --git a/lang/tests/son_tests_inlined_generic_functions.txt b/lang/tests/son_tests_inlined_generic_functions.txt index 7b61dc2..2d6710e 100644 --- a/lang/tests/son_tests_inlined_generic_functions.txt +++ b/lang/tests/son_tests_inlined_generic_functions.txt @@ -1,11 +1,7 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LI64 r13, 10d CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 80 +code size: 32 ret: 10 status: Ok(()) diff --git a/lang/tests/son_tests_inlining_issues.txt b/lang/tests/son_tests_inlining_issues.txt index f1c7692..906ddf0 100644 --- a/lang/tests/son_tests_inlining_issues.txt +++ b/lang/tests/son_tests_inlining_issues.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -130d - ST r31, r254, 58a, 72h + ADDI64 r254, r254, -122d + ST r31, r254, 58a, 64h ADDI64 r32, r254, 33d ADDI64 r33, r254, 34d ADDI64 r34, r254, 1d @@ -22,12 +22,11 @@ main: LD r5, r34, 0a, 16h LD r7, r37, 0a, 1h JAL r31, r0, :put_filled_rect - LD r31, r254, 58a, 72h - ADDI64 r254, r254, 130d + LD r31, r254, 58a, 64h + ADDI64 r254, r254, 122d JALA r0, r31, 0a put_filled_rect: - ADDI64 r254, r254, -236d - ST r32, r254, 108a, 128h + ADDI64 r254, r254, -108d CP r14, r2 ST r3, r254, 92a, 16h ADDI64 r3, r254, 92d @@ -98,9 +97,8 @@ put_filled_rect: ADD64 r14, r27, r14 SUB64 r13, r13, r18 JMP :3 - 2: LD r32, r254, 108a, 128h - ADDI64 r254, r254, 236d + 2: ADDI64 r254, r254, 108d JALA r0, r31, 0a -code size: 901 +code size: 875 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_intcast_store.txt b/lang/tests/son_tests_intcast_store.txt index b9a12d6..77e8cd4 100644 --- a/lang/tests/son_tests_intcast_store.txt +++ b/lang/tests/son_tests_intcast_store.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -56d - ST r31, r254, 16a, 40h + ADDI64 r254, r254, -48d + ST r31, r254, 16a, 32h ADDI64 r32, r254, 0d ADDI64 r33, r254, 8d ST r0, r254, 0a, 8h @@ -13,17 +13,13 @@ main: CP r32, r1 ANDI r32, r32, 4294967295d CP r1, r32 - LD r31, r254, 16a, 40h - ADDI64 r254, r254, 56d + LD r31, r254, 16a, 32h + ADDI64 r254, r254, 48d JALA r0, r31, 0a set: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h CP r13, r4 CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 223 +code size: 175 ret: 1024 status: Ok(()) diff --git a/lang/tests/son_tests_integer_inference_issues.txt b/lang/tests/son_tests_integer_inference_issues.txt index b62454f..7eea799 100644 --- a/lang/tests/son_tests_integer_inference_issues.txt +++ b/lang/tests/son_tests_integer_inference_issues.txt @@ -1,6 +1,4 @@ integer_range: - ADDI64 r254, r254, -32d - ST r32, r254, 0a, 32h CP r13, r2 CP r14, r3 LI64 r15, 4d @@ -14,19 +12,17 @@ integer_range: DIRU64 r0, r14, r15, r14 ADD64 r13, r14, r13 CP r1, r13 - LD r32, r254, 0a, 32h - ADDI64 r254, r254, 32d JALA r0, r31, 0a main: - ADDI64 r254, r254, -24d - ST r31, r254, 0a, 24h + ADDI64 r254, r254, -16d + ST r31, r254, 0a, 16h LI64 r32, 1000d CP r2, r0 CP r3, r32 JAL r31, r0, :integer_range - LD r31, r254, 0a, 24h - ADDI64 r254, r254, 24d + LD r31, r254, 0a, 16h + ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 212 +code size: 164 ret: 42 status: Ok(()) diff --git a/lang/tests/son_tests_loop_stores.txt b/lang/tests/son_tests_loop_stores.txt index b746c5b..0a45788 100644 --- a/lang/tests/son_tests_loop_stores.txt +++ b/lang/tests/son_tests_loop_stores.txt @@ -1,6 +1,5 @@ main: - ADDI64 r254, r254, -16d - ST r32, r254, 8a, 8h + ADDI64 r254, r254, -8d LI64 r13, 10d ST r13, r254, 0a, 8h 2: LD r13, r254, 0a, 8h @@ -10,9 +9,8 @@ main: 0: ADDI64 r13, r13, -1d ST r13, r254, 0a, 8h JMP :2 - 1: LD r32, r254, 8a, 8h - ADDI64 r254, r254, 16d + 1: ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 145 +code size: 119 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_loops.txt b/lang/tests/son_tests_loops.txt index a3318cd..7463236 100644 --- a/lang/tests/son_tests_loops.txt +++ b/lang/tests/son_tests_loops.txt @@ -1,6 +1,4 @@ fib: - ADDI64 r254, r254, -40d - ST r32, r254, 0a, 40h CP r13, r2 LI64 r17, 1d CP r15, r0 @@ -13,20 +11,18 @@ fib: SUB64 r13, r13, r17 SWA r14, r16 JMP :2 - 1: LD r32, r254, 0a, 40h - ADDI64 r254, r254, 40d - JALA r0, r31, 0a + 1: JALA r0, r31, 0a main: - ADDI64 r254, r254, -24d - ST r31, r254, 0a, 24h + ADDI64 r254, r254, -16d + ST r31, r254, 0a, 16h LI64 r32, 10d CP r2, r32 JAL r31, r0, :fib CP r32, r1 CP r1, r32 - LD r31, r254, 0a, 24h - ADDI64 r254, r254, 24d + LD r31, r254, 0a, 16h + ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 203 +code size: 155 ret: 55 status: Ok(()) diff --git a/lang/tests/son_tests_main_fn.txt b/lang/tests/son_tests_main_fn.txt index 48205d7..47c0a5e 100644 --- a/lang/tests/son_tests_main_fn.txt +++ b/lang/tests/son_tests_main_fn.txt @@ -1,11 +1,7 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LI64 r13, 1d CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 80 +code size: 32 ret: 1 status: Ok(()) diff --git a/lang/tests/son_tests_memory_swap.txt b/lang/tests/son_tests_memory_swap.txt index 0dbc2d9..ceccb91 100644 --- a/lang/tests/son_tests_memory_swap.txt +++ b/lang/tests/son_tests_memory_swap.txt @@ -1,6 +1,5 @@ decide: - ADDI64 r254, r254, -40d - ST r32, r254, 24a, 16h + ADDI64 r254, r254, -24d CP r14, r2 CP r15, r1 ADDI64 r13, r254, 0d @@ -8,12 +7,11 @@ decide: ST r0, r254, 8a, 8h ST r0, r254, 16a, 8h BMC r13, r15, 24h - LD r32, r254, 24a, 16h - ADDI64 r254, r254, 40d + ADDI64 r254, r254, 24d JALA r0, r31, 0a main: - ADDI64 r254, r254, -128d - ST r31, r254, 72a, 56h + ADDI64 r254, r254, -120d + ST r31, r254, 72a, 48h ADDI64 r32, r254, 48d CP r2, r0 CP r1, r32 @@ -30,9 +28,9 @@ main: LD r33, r254, 0a, 8h ADD64 r32, r33, r32 CP r1, r32 - LD r31, r254, 72a, 56h - ADDI64 r254, r254, 128d + LD r31, r254, 72a, 48h + ADDI64 r254, r254, 120d JALA r0, r31, 0a -code size: 299 +code size: 273 ret: 1 status: Ok(()) diff --git a/lang/tests/son_tests_more_if_opts.txt b/lang/tests/son_tests_more_if_opts.txt index c53e42d..732ddd1 100644 --- a/lang/tests/son_tests_more_if_opts.txt +++ b/lang/tests/son_tests_more_if_opts.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h JAL r31, r0, :opaque CP r33, r1 JAL r31, r0, :opaque @@ -12,8 +12,8 @@ main: LD r32, r33, 0a, 8h JMP :2 2: CP r1, r32 - LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + LD r31, r254, 0a, 24h + ADDI64 r254, r254, 24d JALA r0, r31, 0a opaque: CP r1, r0 diff --git a/lang/tests/son_tests_null_check_in_the_loop.txt b/lang/tests/son_tests_null_check_in_the_loop.txt index 333a368..93b6fbb 100644 --- a/lang/tests/son_tests_null_check_in_the_loop.txt +++ b/lang/tests/son_tests_null_check_in_the_loop.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -38d - ST r31, r254, 6a, 32h + ADDI64 r254, r254, -30d + ST r31, r254, 6a, 24h ADDI64 r32, r254, 0d 2: JAL r31, r0, :return_fn ST r1, r32, 0a, 6h @@ -11,12 +11,11 @@ main: CP r1, r32 JMP :1 0: JMP :2 - 1: LD r31, r254, 6a, 32h - ADDI64 r254, r254, 38d + 1: LD r31, r254, 6a, 24h + ADDI64 r254, r254, 30d JALA r0, r31, 0a return_fn: - ADDI64 r254, r254, -22d - ST r32, r254, 6a, 16h + ADDI64 r254, r254, -6d LI8 r13, 1b ADDI64 r14, r254, 0d ST r13, r254, 0a, 1h @@ -26,9 +25,8 @@ return_fn: ST r0, r254, 4a, 1h ST r0, r254, 5a, 1h LD r1, r14, 0a, 6h - LD r32, r254, 6a, 16h - ADDI64 r254, r254, 22d + ADDI64 r254, r254, 6d JALA r0, r31, 0a -code size: 314 +code size: 288 ret: 1 status: Ok(()) diff --git a/lang/tests/son_tests_null_check_returning_small_global.txt b/lang/tests/son_tests_null_check_returning_small_global.txt index 98a79a1..fc8fe55 100644 --- a/lang/tests/son_tests_null_check_returning_small_global.txt +++ b/lang/tests/son_tests_null_check_returning_small_global.txt @@ -1,6 +1,6 @@ foo: - ADDI64 r254, r254, -120d - ST r31, r254, 80a, 40h + ADDI64 r254, r254, -112d + ST r31, r254, 80a, 32h ADDI64 r32, r254, 64d LRA r33, r0, :some_file CP r3, r33 @@ -34,12 +34,11 @@ foo: 3: ADDI64 r32, r254, 0d ST r0, r254, 0a, 1h LD r1, r32, 0a, 16h - 1: LD r31, r254, 80a, 40h - ADDI64 r254, r254, 120d + 1: LD r31, r254, 80a, 32h + ADDI64 r254, r254, 112d JALA r0, r31, 0a get: - ADDI64 r254, r254, -56d - ST r32, r254, 32a, 24h + ADDI64 r254, r254, -32d CP r13, r3 LD r13, r13, 0a, 1h LRA r14, r0, :MAGIC @@ -55,12 +54,11 @@ get: 0: ADDI64 r13, r254, 0d ST r0, r254, 0a, 1h LD r1, r13, 0a, 16h - 1: LD r32, r254, 32a, 24h - ADDI64 r254, r254, 56d + 1: ADDI64 r254, r254, 32d JALA r0, r31, 0a main: - ADDI64 r254, r254, -48d - ST r31, r254, 16a, 32h + ADDI64 r254, r254, -40d + ST r31, r254, 16a, 24h ADDI64 r32, r254, 0d JAL r31, r0, :foo ST r1, r32, 0a, 16h @@ -72,9 +70,9 @@ main: JMP :1 0: LD r32, r254, 8a, 8h CP r1, r32 - 1: LD r31, r254, 16a, 32h - ADDI64 r254, r254, 48d + 1: LD r31, r254, 16a, 24h + ADDI64 r254, r254, 40d JALA r0, r31, 0a -code size: 765 +code size: 739 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_null_check_test.txt b/lang/tests/son_tests_null_check_test.txt index 5e244ed..b9980b0 100644 --- a/lang/tests/son_tests_null_check_test.txt +++ b/lang/tests/son_tests_null_check_test.txt @@ -2,8 +2,8 @@ get_ptr: CP r1, r0 JALA r0, r31, 0a main: - ADDI64 r254, r254, -40d - ST r31, r254, 0a, 40h + ADDI64 r254, r254, -32d + ST r31, r254, 0a, 32h JAL r31, r0, :get_ptr CP r32, r1 JNE r32, r0, :0 @@ -16,8 +16,8 @@ main: ST r34, r32, 0a, 8h JMP :3 2: CP r1, r34 - 1: LD r31, r254, 0a, 40h - ADDI64 r254, r254, 40d + 1: LD r31, r254, 0a, 32h + ADDI64 r254, r254, 32d JALA r0, r31, 0a code size: 164 ret: 0 diff --git a/lang/tests/son_tests_nullable_structure.txt b/lang/tests/son_tests_nullable_structure.txt index 9b7407a..a755078 100644 --- a/lang/tests/son_tests_nullable_structure.txt +++ b/lang/tests/son_tests_nullable_structure.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -74d - ST r31, r254, 26a, 48h + ADDI64 r254, r254, -66d + ST r31, r254, 26a, 40h JAL r31, r0, :returner_fn CP r32, r1 ADDI64 r33, r254, 2d @@ -25,12 +25,11 @@ main: JMP :1 0: LI64 r32, 1d CP r1, r32 - 1: LD r31, r254, 26a, 48h - ADDI64 r254, r254, 74d + 1: LD r31, r254, 26a, 40h + ADDI64 r254, r254, 66d JALA r0, r31, 0a returner_bn: - ADDI64 r254, r254, -40d - ST r32, r254, 24a, 16h + ADDI64 r254, r254, -24d CP r15, r1 LI8 r14, 1b ADDI64 r13, r254, 0d @@ -38,29 +37,22 @@ returner_bn: ST r0, r254, 8a, 8h ST r0, r254, 16a, 8h BMC r13, r15, 24h - LD r32, r254, 24a, 16h - ADDI64 r254, r254, 40d + ADDI64 r254, r254, 24d JALA r0, r31, 0a returner_cn: - ADDI64 r254, r254, -18d - ST r32, r254, 2a, 16h + ADDI64 r254, r254, -2d LI8 r13, 1b ADDI64 r14, r254, 0d ST r13, r254, 0a, 1h ST r0, r254, 1a, 1h LD r1, r14, 0a, 2h - LD r32, r254, 2a, 16h - ADDI64 r254, r254, 18d + ADDI64 r254, r254, 2d JALA r0, r31, 0a returner_fn: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LD r13, r254, 0a, 0h ORI r13, r13, 128d CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 563 +code size: 463 ret: 1 status: Ok(()) diff --git a/lang/tests/son_tests_nullable_types.txt b/lang/tests/son_tests_nullable_types.txt index ad4afa5..dfd596a 100644 --- a/lang/tests/son_tests_nullable_types.txt +++ b/lang/tests/son_tests_nullable_types.txt @@ -1,14 +1,10 @@ decide: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LI8 r13, 1b CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a main: - ADDI64 r254, r254, -136d - ST r31, r254, 80a, 56h + ADDI64 r254, r254, -128d + ST r31, r254, 80a, 48h JAL r31, r0, :decide CP r32, r1 CP r33, r0 @@ -102,12 +98,11 @@ main: ANDI r32, r32, 65535d SUB64 r32, r32, r33 CP r1, r32 - 3: LD r31, r254, 80a, 56h - ADDI64 r254, r254, 136d + 3: LD r31, r254, 80a, 48h + ADDI64 r254, r254, 128d JALA r0, r31, 0a new_bar: - ADDI64 r254, r254, -48d - ST r32, r254, 24a, 24h + ADDI64 r254, r254, -24d CP r14, r2 CP r16, r1 LI8 r15, 1b @@ -117,28 +112,23 @@ new_bar: LI64 r14, 1d ST r14, r254, 16a, 8h BMC r13, r16, 24h - LD r32, r254, 24a, 24h - ADDI64 r254, r254, 48d + ADDI64 r254, r254, 24d JALA r0, r31, 0a new_foo: - ADDI64 r254, r254, -40d - ST r32, r254, 24a, 16h + ADDI64 r254, r254, -24d ADDI64 r13, r254, 0d ADDI64 r14, r254, 8d ST r13, r254, 8a, 8h ST r0, r254, 16a, 8h LD r1, r14, 0a, 16h - LD r32, r254, 24a, 16h - ADDI64 r254, r254, 40d + ADDI64 r254, r254, 24d JALA r0, r31, 0a no_foo: - ADDI64 r254, r254, -24d - ST r32, r254, 16a, 8h + ADDI64 r254, r254, -16d ADDI64 r13, r254, 0d ST r0, r254, 0a, 8h LD r1, r13, 0a, 16h - LD r32, r254, 16a, 8h - ADDI64 r254, r254, 24d + ADDI64 r254, r254, 16d JALA r0, r31, 0a use_foo: ADDI64 r254, r254, -16d @@ -146,6 +136,6 @@ use_foo: ADDI64 r2, r254, 0d ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 1240 +code size: 1114 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_only_break_loop.txt b/lang/tests/son_tests_only_break_loop.txt index b491767..e70c794 100644 --- a/lang/tests/son_tests_only_break_loop.txt +++ b/lang/tests/son_tests_only_break_loop.txt @@ -1,14 +1,10 @@ inb: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h CP r13, r2 CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h LI64 r32, 100d 4: CP r2, r32 JAL r31, r0, :inb @@ -28,11 +24,11 @@ main: JMP :2 1: JMP :3 0: JMP :4 - 2: LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + 2: LD r31, r254, 0a, 24h + ADDI64 r254, r254, 24d JALA r0, r31, 0a outb: JALA r0, r31, 0a -code size: 251 +code size: 203 ret: 1 status: Ok(()) diff --git a/lang/tests/son_tests_optional_from_eca.txt b/lang/tests/son_tests_optional_from_eca.txt index 300709e..1e74ce8 100644 --- a/lang/tests/son_tests_optional_from_eca.txt +++ b/lang/tests/son_tests_optional_from_eca.txt @@ -1,6 +1,5 @@ main: - ADDI64 r254, r254, -32d - ST r32, r254, 16a, 16h + ADDI64 r254, r254, -16d ADDI64 r13, r254, 0d CP r3, r0 CP r4, r0 @@ -14,10 +13,9 @@ main: UN 0: LD r13, r254, 8a, 8h CP r1, r13 - LD r32, r254, 16a, 16h - ADDI64 r254, r254, 32d + ADDI64 r254, r254, 16d JALA r0, r31, 0a unknown ecall: 0 -code size: 150 +code size: 124 ret: 0 status: Err(Unreachable) diff --git a/lang/tests/son_tests_overwrite_aliasing_overoptimization.txt b/lang/tests/son_tests_overwrite_aliasing_overoptimization.txt index bcc7b93..5d53583 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, -72d - ST r31, r254, 24a, 48h + ADDI64 r254, r254, -64d + ST r31, r254, 24a, 40h ADDI64 r32, r254, 0d LI64 r33, 1d ST r33, r254, 16a, 8h @@ -15,21 +15,19 @@ main: LD r32, r254, 0a, 8h SUB64 r32, r32, r34 CP r1, r32 - LD r31, r254, 24a, 48h - ADDI64 r254, r254, 72d + LD r31, r254, 24a, 40h + ADDI64 r254, r254, 64d JALA r0, r31, 0a opaque: - ADDI64 r254, r254, -32d - ST r32, r254, 16a, 16h + ADDI64 r254, r254, -16d LI64 r13, 3d ADDI64 r14, r254, 0d ST r13, r254, 0a, 8h LI64 r13, 2d ST r13, r254, 8a, 8h LD r1, r14, 0a, 16h - LD r32, r254, 16a, 16h - ADDI64 r254, r254, 32d + ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 336 +code size: 310 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_pointer_opts.txt b/lang/tests/son_tests_pointer_opts.txt index 89462c1..9001210 100644 --- a/lang/tests/son_tests_pointer_opts.txt +++ b/lang/tests/son_tests_pointer_opts.txt @@ -1,15 +1,11 @@ clobber: - ADDI64 r254, r254, -16d - ST r32, r254, 0a, 16h CP r13, r2 LI64 r14, 4d ST r14, r13, 0a, 8h - LD r32, r254, 0a, 16h - ADDI64 r254, r254, 16d JALA r0, r31, 0a main: - ADDI64 r254, r254, -40d - ST r31, r254, 8a, 32h + ADDI64 r254, r254, -32d + ST r31, r254, 8a, 24h ADDI64 r32, r254, 0d LI64 r33, 2d ST r33, r254, 0a, 8h @@ -19,9 +15,9 @@ main: LI64 r33, 4d SUB64 r32, r33, r32 CP r1, r32 - LD r31, r254, 8a, 32h - ADDI64 r254, r254, 40d + LD r31, r254, 8a, 24h + ADDI64 r254, r254, 32d JALA r0, r31, 0a -code size: 226 +code size: 178 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_pointers.txt b/lang/tests/son_tests_pointers.txt index b74bd3b..0c5b1e1 100644 --- a/lang/tests/son_tests_pointers.txt +++ b/lang/tests/son_tests_pointers.txt @@ -1,8 +1,8 @@ drop: JALA r0, r31, 0a main: - ADDI64 r254, r254, -40d - ST r31, r254, 8a, 32h + ADDI64 r254, r254, -32d + ST r31, r254, 8a, 24h ADDI64 r32, r254, 0d LI64 r33, 1d ST r33, r254, 0a, 8h @@ -13,18 +13,14 @@ main: LD r32, r254, 0a, 8h ADDI64 r32, r32, -2d CP r1, r32 - LD r31, r254, 8a, 32h - ADDI64 r254, r254, 40d + LD r31, r254, 8a, 24h + ADDI64 r254, r254, 32d JALA r0, r31, 0a modify: - ADDI64 r254, r254, -16d - ST r32, r254, 0a, 16h CP r13, r2 LI64 r14, 2d ST r14, r13, 0a, 8h - LD r32, r254, 0a, 16h - ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 244 +code size: 196 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_request_page.txt b/lang/tests/son_tests_request_page.txt index 9cc0b1a..2b7f0ae 100644 --- a/lang/tests/son_tests_request_page.txt +++ b/lang/tests/son_tests_request_page.txt @@ -1,6 +1,6 @@ create_back_buffer: - ADDI64 r254, r254, -48d - ST r31, r254, 0a, 48h + ADDI64 r254, r254, -40d + ST r31, r254, 0a, 40h CP r32, r2 LI64 r33, 255d JGTS r32, r33, :0 @@ -25,21 +25,19 @@ create_back_buffer: JAL r31, r0, :request_page 4: SUB64 r32, r32, r33 JMP :5 - 1: LD r31, r254, 0a, 48h - ADDI64 r254, r254, 48d + 1: LD r31, r254, 0a, 40h + ADDI64 r254, r254, 40d JALA r0, r31, 0a main: - ADDI64 r254, r254, -24d - ST r31, r254, 0a, 24h + ADDI64 r254, r254, -16d + ST r31, r254, 0a, 16h LI64 r32, 400d CP r2, r32 JAL r31, r0, :create_back_buffer - LD r31, r254, 0a, 24h - ADDI64 r254, r254, 24d + LD r31, r254, 0a, 16h + ADDI64 r254, r254, 16d JALA r0, r31, 0a request_page: - ADDI64 r254, r254, -32d - ST r32, r254, 0a, 32h CP r13, r2 LRA r14, r0, :"\0\u{1}xxxxxxxx\0" ST r13, r14, 1a, 1h @@ -53,9 +51,7 @@ request_page: ECA CP r13, r1 CP r1, r13 - LD r32, r254, 0a, 32h - ADDI64 r254, r254, 32d JALA r0, r31, 0a -code size: 399 +code size: 351 ret: 42 status: Ok(()) diff --git a/lang/tests/son_tests_returning_global_struct.txt b/lang/tests/son_tests_returning_global_struct.txt index d6b621e..c52dcf9 100644 --- a/lang/tests/son_tests_returning_global_struct.txt +++ b/lang/tests/son_tests_returning_global_struct.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -60d - ST r31, r254, 4a, 56h + ADDI64 r254, r254, -52d + ST r31, r254, 4a, 48h ADDI64 r32, r254, 0d JAL r31, r0, :random_color ST r1, r32, 0a, 4h @@ -16,17 +16,13 @@ main: ADD64 r33, r34, r33 ADD64 r32, r33, r32 CP r1, r32 - LD r31, r254, 4a, 56h - ADDI64 r254, r254, 60d + LD r31, r254, 4a, 48h + ADDI64 r254, r254, 52d JALA r0, r31, 0a random_color: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LRA r13, r0, :white LD r1, r13, 0a, 4h - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 292 +code size: 244 ret: 1020 status: Ok(()) diff --git a/lang/tests/son_tests_returning_optional_issues.txt b/lang/tests/son_tests_returning_optional_issues.txt index 93effff..5b0422d 100644 --- a/lang/tests/son_tests_returning_optional_issues.txt +++ b/lang/tests/son_tests_returning_optional_issues.txt @@ -1,6 +1,5 @@ get_format: - ADDI64 r254, r254, -40d - ST r32, r254, 16a, 24h + ADDI64 r254, r254, -16d LI8 r13, 1b ADDI64 r14, r254, 0d LRA r15, r0, :BMP @@ -8,12 +7,11 @@ get_format: LD r13, r15, 0a, 8h ST r13, r254, 8a, 8h LD r1, r14, 0a, 16h - LD r32, r254, 16a, 24h - ADDI64 r254, r254, 40d + ADDI64 r254, r254, 16d JALA r0, r31, 0a main: - ADDI64 r254, r254, -48d - ST r31, r254, 16a, 32h + ADDI64 r254, r254, -40d + ST r31, r254, 16a, 24h ADDI64 r32, r254, 0d JAL r31, r0, :get_format ST r1, r32, 0a, 16h @@ -25,9 +23,9 @@ main: JMP :1 0: LD r32, r254, 8a, 8h CP r1, r32 - 1: LD r31, r254, 16a, 32h - ADDI64 r254, r254, 48d + 1: LD r31, r254, 16a, 24h + ADDI64 r254, r254, 40d JALA r0, r31, 0a -code size: 301 +code size: 275 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_scheduling_block_did_dirty.txt b/lang/tests/son_tests_scheduling_block_did_dirty.txt index 5cc1da2..2b2e7fd 100644 --- a/lang/tests/son_tests_scheduling_block_did_dirty.txt +++ b/lang/tests/son_tests_scheduling_block_did_dirty.txt @@ -1,6 +1,6 @@ constructor: - ADDI64 r254, r254, -48d - ST r31, r254, 16a, 32h + ADDI64 r254, r254, -40d + ST r31, r254, 16a, 24h CP r32, r3 CP r2, r32 JAL r31, r0, :opaque @@ -9,31 +9,27 @@ constructor: ST r32, r254, 0a, 8h ST r32, r254, 8a, 8h LD r1, r33, 0a, 16h - LD r31, r254, 16a, 32h - ADDI64 r254, r254, 48d + LD r31, r254, 16a, 24h + ADDI64 r254, r254, 40d JALA r0, r31, 0a main: - ADDI64 r254, r254, -40d - ST r31, r254, 16a, 24h + ADDI64 r254, r254, -32d + ST r31, r254, 16a, 16h ADDI64 r32, r254, 0d CP r3, r0 JAL r31, r0, :constructor ST r1, r32, 0a, 16h - LD r31, r254, 16a, 24h - ADDI64 r254, r254, 40d + LD r31, r254, 16a, 16h + ADDI64 r254, r254, 32d JALA r0, r31, 0a opaque: - ADDI64 r254, r254, -16d - ST r32, r254, 0a, 16h CP r13, r2 LRA r14, r0, :file ADD64 r13, r14, r13 LD r13, r13, 0a, 1h ANDI r13, r13, 255d CP r1, r13 - LD r32, r254, 0a, 16h - ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 327 +code size: 279 ret: 255 status: Ok(()) diff --git a/lang/tests/son_tests_signed_to_unsigned_upcast.txt b/lang/tests/son_tests_signed_to_unsigned_upcast.txt index 48205d7..47c0a5e 100644 --- a/lang/tests/son_tests_signed_to_unsigned_upcast.txt +++ b/lang/tests/son_tests_signed_to_unsigned_upcast.txt @@ -1,11 +1,7 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LI64 r13, 1d CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 80 +code size: 32 ret: 1 status: Ok(()) diff --git a/lang/tests/son_tests_small_struct_assignment.txt b/lang/tests/son_tests_small_struct_assignment.txt index 61400cb..b1ceade 100644 --- a/lang/tests/son_tests_small_struct_assignment.txt +++ b/lang/tests/son_tests_small_struct_assignment.txt @@ -1,15 +1,13 @@ main: - ADDI64 r254, r254, -20d - ST r32, r254, 4a, 16h + ADDI64 r254, r254, -4d LRA r13, r0, :white ADDI64 r14, r254, 0d BMC r13, r14, 4h LD r13, r254, 3a, 1h ANDI r13, r13, 255d CP r1, r13 - LD r32, r254, 4a, 16h - ADDI64 r254, r254, 20d + ADDI64 r254, r254, 4d JALA r0, r31, 0a -code size: 121 +code size: 95 ret: 255 status: Ok(()) diff --git a/lang/tests/son_tests_small_struct_bitcast.txt b/lang/tests/son_tests_small_struct_bitcast.txt index 50a9711..c934409 100644 --- a/lang/tests/son_tests_small_struct_bitcast.txt +++ b/lang/tests/son_tests_small_struct_bitcast.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -36d - ST r31, r254, 4a, 32h + ADDI64 r254, r254, -28d + ST r31, r254, 4a, 24h LRA r32, r0, :white ADDI64 r33, r254, 0d LD r32, r32, 0a, 4h @@ -10,12 +10,12 @@ main: LD r32, r254, 0a, 1h ANDI r32, r32, 255d CP r1, r32 - LD r31, r254, 4a, 32h - ADDI64 r254, r254, 36d + LD r31, r254, 4a, 24h + ADDI64 r254, r254, 28d JALA r0, r31, 0a u32_to_color: - ADDI64 r254, r254, -36d - ST r31, r254, 4a, 32h + ADDI64 r254, r254, -28d + ST r31, r254, 4a, 24h CP r32, r2 CP r2, r32 JAL r31, r0, :u32_to_u32 @@ -23,17 +23,13 @@ u32_to_color: ADDI64 r33, r254, 0d ST r32, r254, 0a, 4h LD r1, r33, 0a, 4h - LD r31, r254, 4a, 32h - ADDI64 r254, r254, 36d + LD r31, r254, 4a, 24h + ADDI64 r254, r254, 28d JALA r0, r31, 0a u32_to_u32: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h CP r13, r2 CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 329 +code size: 281 ret: 255 status: Ok(()) diff --git a/lang/tests/son_tests_some_generic_code.txt b/lang/tests/son_tests_some_generic_code.txt index 244aa5e..cfd61e9 100644 --- a/lang/tests/son_tests_some_generic_code.txt +++ b/lang/tests/son_tests_some_generic_code.txt @@ -1,9 +1,9 @@ main: - ADDI64 r254, r254, -16d - ST r31, r254, 0a, 16h + ADDI64 r254, r254, -8d + ST r31, r254, 0a, 8h JAL r31, r0, :some_func - LD r31, r254, 0a, 16h - ADDI64 r254, r254, 16d + LD r31, r254, 0a, 8h + ADDI64 r254, r254, 8d JALA r0, r31, 0a some_func: JALA r0, r31, 0a diff --git a/lang/tests/son_tests_sort_something_viredly.txt b/lang/tests/son_tests_sort_something_viredly.txt index 297d5f2..2351a62 100644 --- a/lang/tests/son_tests_sort_something_viredly.txt +++ b/lang/tests/son_tests_sort_something_viredly.txt @@ -1,17 +1,15 @@ main: - ADDI64 r254, r254, -24d - ST r31, r254, 0a, 24h + ADDI64 r254, r254, -16d + ST r31, r254, 0a, 16h LI64 r32, 100d CP r2, r32 JAL r31, r0, :sqrt CP r32, r1 CP r1, r32 - LD r31, r254, 0a, 24h - ADDI64 r254, r254, 24d + LD r31, r254, 0a, 16h + ADDI64 r254, r254, 16d JALA r0, r31, 0a sqrt: - ADDI64 r254, r254, -48d - ST r32, r254, 0a, 48h CP r13, r2 LI64 r16, 15d LI64 r15, 32768d @@ -30,9 +28,7 @@ sqrt: JMP :2 2: SRUI64 r15, r15, 1b JMP :3 - 1: LD r32, r254, 0a, 48h - ADDI64 r254, r254, 48d - JALA r0, r31, 0a -code size: 244 + 1: JALA r0, r31, 0a +code size: 196 ret: 14 status: Ok(()) diff --git a/lang/tests/son_tests_storing_into_nullable_struct.txt b/lang/tests/son_tests_storing_into_nullable_struct.txt index 06f1c06..9e4dacf 100644 --- a/lang/tests/son_tests_storing_into_nullable_struct.txt +++ b/lang/tests/son_tests_storing_into_nullable_struct.txt @@ -1,16 +1,12 @@ do_stuff: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h CP r13, r2 CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a just_read: JALA r0, r31, 0a main: - ADDI64 r254, r254, -88d - ST r31, r254, 48a, 40h + ADDI64 r254, r254, -80d + ST r31, r254, 48a, 32h ADDI64 r32, r254, 16d CP r1, r32 JAL r31, r0, :optionala @@ -41,24 +37,21 @@ main: CP r33, r1 ADD64 r32, r33, r32 CP r1, r32 - 1: LD r31, r254, 48a, 40h - ADDI64 r254, r254, 88d + 1: LD r31, r254, 48a, 32h + ADDI64 r254, r254, 80d JALA r0, r31, 0a optional: - ADDI64 r254, r254, -32d - ST r32, r254, 16a, 16h + ADDI64 r254, r254, -16d LI8 r13, 1b ADDI64 r14, r254, 0d ST r13, r254, 0a, 1h LI64 r13, 10d ST r13, r254, 8a, 8h LD r1, r14, 0a, 16h - LD r32, r254, 16a, 16h - ADDI64 r254, r254, 32d + ADDI64 r254, r254, 16d JALA r0, r31, 0a optionala: - ADDI64 r254, r254, -80d - ST r32, r254, 48a, 32h + ADDI64 r254, r254, -48d CP r17, r1 ADDI64 r14, r254, 8d ADDI64 r15, r254, 16d @@ -71,9 +64,8 @@ optionala: ST r0, r254, 8a, 8h ST r0, r254, 40a, 8h BMC r15, r17, 32h - LD r32, r254, 48a, 32h - ADDI64 r254, r254, 80d + ADDI64 r254, r254, 48d JALA r0, r31, 0a -code size: 667 +code size: 567 ret: 100 status: Ok(()) diff --git a/lang/tests/son_tests_string_flip.txt b/lang/tests/son_tests_string_flip.txt index 891f309..351d7a3 100644 --- a/lang/tests/son_tests_string_flip.txt +++ b/lang/tests/son_tests_string_flip.txt @@ -1,6 +1,5 @@ main: - ADDI64 r254, r254, -128d - ST r32, r254, 40a, 88h + ADDI64 r254, r254, -40d LI64 r17, 1d LI64 r16, 4d CP r14, r0 @@ -40,9 +39,8 @@ main: ST r13, r19, 0a, 8h CP r13, r15 JMP :6 - 2: LD r32, r254, 40a, 88h - ADDI64 r254, r254, 128d + 2: ADDI64 r254, r254, 40d JALA r0, r31, 0a -code size: 296 +code size: 270 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_struct_in_register.txt b/lang/tests/son_tests_struct_in_register.txt index b7147bb..ffac3b1 100644 --- a/lang/tests/son_tests_struct_in_register.txt +++ b/lang/tests/son_tests_struct_in_register.txt @@ -1,15 +1,13 @@ main: - ADDI64 r254, r254, -20d - ST r32, r254, 4a, 16h + ADDI64 r254, r254, -4d LRA r13, r0, :MAGENTA ADDI64 r14, r254, 0d BMC r13, r14, 4h LD r13, r254, 2a, 1h ANDI r13, r13, 255d CP r1, r13 - LD r32, r254, 4a, 16h - ADDI64 r254, r254, 20d + ADDI64 r254, r254, 4d JALA r0, r31, 0a -code size: 121 +code size: 95 ret: 205 status: Ok(()) diff --git a/lang/tests/son_tests_struct_operators.txt b/lang/tests/son_tests_struct_operators.txt index 7b61dc2..2d6710e 100644 --- a/lang/tests/son_tests_struct_operators.txt +++ b/lang/tests/son_tests_struct_operators.txt @@ -1,11 +1,7 @@ main: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LI64 r13, 10d CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 80 +code size: 32 ret: 10 status: Ok(()) diff --git a/lang/tests/son_tests_struct_patterns.txt b/lang/tests/son_tests_struct_patterns.txt index 6c9b038..1a0cb13 100644 --- a/lang/tests/son_tests_struct_patterns.txt +++ b/lang/tests/son_tests_struct_patterns.txt @@ -1,6 +1,6 @@ fib: - ADDI64 r254, r254, -40d - ST r31, r254, 0a, 40h + ADDI64 r254, r254, -32d + ST r31, r254, 0a, 32h CP r32, r2 LI64 r33, 2d JLTU r32, r33, :0 @@ -16,12 +16,10 @@ fib: CP r1, r32 JMP :1 0: CP r1, r32 - 1: LD r31, r254, 0a, 40h - ADDI64 r254, r254, 40d + 1: LD r31, r254, 0a, 32h + ADDI64 r254, r254, 32d JALA r0, r31, 0a fib_iter: - ADDI64 r254, r254, -40d - ST r32, r254, 0a, 40h CP r13, r2 LI64 r17, 1d CP r15, r0 @@ -34,12 +32,10 @@ fib_iter: SUB64 r13, r13, r17 SWA r14, r16 JMP :2 - 1: LD r32, r254, 0a, 40h - ADDI64 r254, r254, 40d - JALA r0, r31, 0a + 1: JALA r0, r31, 0a main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h LI64 r32, 10d CP r2, r32 JAL r31, r0, :fib @@ -49,9 +45,9 @@ main: CP r32, r1 SUB64 r32, r33, r32 CP r1, r32 - LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + LD r31, r254, 0a, 24h + ADDI64 r254, r254, 24d JALA r0, r31, 0a -code size: 353 +code size: 305 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_struct_return_from_module_function.txt b/lang/tests/son_tests_struct_return_from_module_function.txt index 1d38b39..b5687ac 100644 --- a/lang/tests/son_tests_struct_return_from_module_function.txt +++ b/lang/tests/son_tests_struct_return_from_module_function.txt @@ -1,6 +1,5 @@ foo: - ADDI64 r254, r254, -32d - ST r32, r254, 16a, 16h + ADDI64 r254, r254, -16d LI64 r13, 3d ADDI64 r14, r254, 0d ST r13, r254, 0a, 8h @@ -8,12 +7,11 @@ foo: ST r13, r254, 8a, 4h ST r13, r254, 12a, 4h LD r1, r14, 0a, 16h - LD r32, r254, 16a, 16h - ADDI64 r254, r254, 32d + ADDI64 r254, r254, 16d JALA r0, r31, 0a main: - ADDI64 r254, r254, -96d - ST r31, r254, 48a, 48h + ADDI64 r254, r254, -88d + ST r31, r254, 48a, 40h ADDI64 r32, r254, 32d JAL r31, r0, :foo ST r1, r32, 0a, 16h @@ -33,9 +31,9 @@ main: LI64 r33, 7d SUB64 r32, r33, r32 CP r1, r32 - LD r31, r254, 48a, 48h - ADDI64 r254, r254, 96d + LD r31, r254, 48a, 40h + ADDI64 r254, r254, 88d JALA r0, r31, 0a -code size: 384 +code size: 358 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_structs.txt b/lang/tests/son_tests_structs.txt index 3b354eb..f25ab46 100644 --- a/lang/tests/son_tests_structs.txt +++ b/lang/tests/son_tests_structs.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -72d - ST r31, r254, 32a, 40h + ADDI64 r254, r254, -64d + ST r31, r254, 32a, 32h LI64 r32, 4d ADDI64 r33, r254, 16d ST r32, r254, 16a, 8h @@ -18,28 +18,22 @@ main: CP r1, r32 JMP :1 0: CP r1, r0 - 1: LD r31, r254, 32a, 40h - ADDI64 r254, r254, 72d + 1: LD r31, r254, 32a, 32h + ADDI64 r254, r254, 64d JALA r0, r31, 0a odher_pass: - ADDI64 r254, r254, -24d - ST r32, r254, 16a, 8h + ADDI64 r254, r254, -16d ST r3, r254, 0a, 16h ADDI64 r3, r254, 0d CP r13, r3 LD r1, r13, 0a, 16h - LD r32, r254, 16a, 8h - ADDI64 r254, r254, 24d + ADDI64 r254, r254, 16d JALA r0, r31, 0a pass: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h CP r13, r2 LD r13, r13, 0a, 8h CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 387 +code size: 313 ret: 4 status: Ok(()) diff --git a/lang/tests/son_tests_tests_ptr_to_ptr_copy.txt b/lang/tests/son_tests_tests_ptr_to_ptr_copy.txt index 0aee892..22ae15a 100644 --- a/lang/tests/son_tests_tests_ptr_to_ptr_copy.txt +++ b/lang/tests/son_tests_tests_ptr_to_ptr_copy.txt @@ -1,6 +1,5 @@ main: - ADDI64 r254, r254, -10288d - ST r32, r254, 10240a, 48h + ADDI64 r254, r254, -10240d LI64 r14, 1d LI8 r16, 64b LI64 r17, 1024d @@ -25,9 +24,8 @@ main: ST r16, r13, 0a, 1h CP r13, r15 JMP :4 - 2: LD r32, r254, 10240a, 48h - ADDI64 r254, r254, 10288d + 2: ADDI64 r254, r254, 10240d JALA r0, r31, 0a -code size: 220 +code size: 194 ret: 64 status: Ok(()) diff --git a/lang/tests/son_tests_triggering_store_in_divergent_branch.txt b/lang/tests/son_tests_triggering_store_in_divergent_branch.txt index d103e49..89b8321 100644 --- a/lang/tests/son_tests_triggering_store_in_divergent_branch.txt +++ b/lang/tests/son_tests_triggering_store_in_divergent_branch.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -72d - ST r31, r254, 0a, 72h + ADDI64 r254, r254, -64d + ST r31, r254, 0a, 64h CP r34, r0 LI64 r37, 65536d LI8 r35, 1b @@ -25,18 +25,14 @@ main: 6: JMP :7 4: ADDI64 r33, r33, 1d JMP :8 - 1: LD r31, r254, 0a, 72h - ADDI64 r254, r254, 72d + 1: LD r31, r254, 0a, 64h + ADDI64 r254, r254, 64d JALA r0, r31, 0a opaque: - ADDI64 r254, r254, -8d - ST r32, r254, 0a, 8h LI64 r13, 2147483648d CP r1, r13 - LD r32, r254, 0a, 8h - ADDI64 r254, r254, 8d JALA r0, r31, 0a timed out -code size: 268 +code size: 220 ret: 2147483648 status: Ok(()) diff --git a/lang/tests/son_tests_very_nested_loops.txt b/lang/tests/son_tests_very_nested_loops.txt index 5aa16aa..246a255 100644 --- a/lang/tests/son_tests_very_nested_loops.txt +++ b/lang/tests/son_tests_very_nested_loops.txt @@ -1,6 +1,27 @@ main: - CP r1, r0 - JALA r0, r31, 0a -code size: 22 -ret: 0 + LI64 r16, 4621819117588971520d + LI64 r17, 1d + LI64 r18, 3d + CP r14, r0 + CP r15, r14 + 3: JNE r15, r18, :0 + CP r1, r17 + JMP :1 + 0: ITF64 r19, r15 + CP r13, r14 + 5: JNE r13, r18, :2 + ADD64 r15, r15, r17 + JMP :3 + 2: ITF64 r20, r13 + FMUL64 r20, r20, r19 + FCMPLT64 r20, r20, r16 + NOT r20, r20 + ANDI r20, r20, 255d + JNE r20, r0, :4 + ADD64 r13, r13, r17 + JMP :5 + 4: CP r1, r14 + 1: JALA r0, r31, 0a +code size: 130 +ret: 1 status: Ok(()) diff --git a/lang/tests/son_tests_wide_ret.txt b/lang/tests/son_tests_wide_ret.txt index c7b7006..9c8cbec 100644 --- a/lang/tests/son_tests_wide_ret.txt +++ b/lang/tests/son_tests_wide_ret.txt @@ -1,6 +1,6 @@ main: - ADDI64 r254, r254, -56d - ST r31, r254, 16a, 40h + ADDI64 r254, r254, -48d + ST r31, r254, 16a, 32h ADDI64 r32, r254, 0d CP r3, r0 CP r4, r0 @@ -11,12 +11,12 @@ main: SUB8 r32, r32, r34 ANDI r32, r32, 255d CP r1, r32 - LD r31, r254, 16a, 40h - ADDI64 r254, r254, 56d + LD r31, r254, 16a, 32h + ADDI64 r254, r254, 48d JALA r0, r31, 0a maina: - ADDI64 r254, r254, -68d - ST r31, r254, 20a, 48h + ADDI64 r254, r254, -60d + ST r31, r254, 20a, 40h ADDI64 r32, r254, 16d JAL r31, r0, :small_struct ST r1, r32, 0a, 4h @@ -40,19 +40,17 @@ maina: ST r0, r254, 14a, 1h ST r0, r254, 15a, 1h LD r1, r33, 0a, 16h - LD r31, r254, 20a, 48h - ADDI64 r254, r254, 68d + LD r31, r254, 20a, 40h + ADDI64 r254, r254, 60d JALA r0, r31, 0a small_struct: - ADDI64 r254, r254, -12d - ST r32, r254, 4a, 8h + ADDI64 r254, r254, -4d ADDI64 r13, r254, 0d ST r0, r254, 0a, 2h ST r0, r254, 2a, 2h LD r1, r13, 0a, 4h - LD r32, r254, 4a, 8h - ADDI64 r254, r254, 12d + ADDI64 r254, r254, 4d JALA r0, r31, 0a -code size: 585 +code size: 559 ret: 2 status: Ok(()) diff --git a/lang/tests/son_tests_writing_into_string.txt b/lang/tests/son_tests_writing_into_string.txt index 706fabc..7247085 100644 --- a/lang/tests/son_tests_writing_into_string.txt +++ b/lang/tests/son_tests_writing_into_string.txt @@ -1,12 +1,12 @@ inl: JALA r0, r31, 0a main: - ADDI64 r254, r254, -16d - ST r31, r254, 0a, 16h + ADDI64 r254, r254, -8d + ST r31, r254, 0a, 8h JAL r31, r0, :outl JAL r31, r0, :inl - LD r31, r254, 0a, 16h - ADDI64 r254, r254, 16d + LD r31, r254, 0a, 8h + ADDI64 r254, r254, 8d JALA r0, r31, 0a outl: JALA r0, r31, 0a diff --git a/lang/tests/son_tests_wrong_dead_code_elimination.txt b/lang/tests/son_tests_wrong_dead_code_elimination.txt index 8f39d8e..df3874a 100644 --- a/lang/tests/son_tests_wrong_dead_code_elimination.txt +++ b/lang/tests/son_tests_wrong_dead_code_elimination.txt @@ -1,6 +1,5 @@ main: - ADDI64 r254, r254, -41d - ST r32, r254, 1a, 40h + ADDI64 r254, r254, -1d LI64 r14, 255d LI8 r13, 1b ST r0, r254, 0a, 1h @@ -20,10 +19,9 @@ main: 1: ADD8 r15, r15, r13 ST r15, r254, 0a, 1h JMP :2 - LD r32, r254, 1a, 40h - ADDI64 r254, r254, 41d + ADDI64 r254, r254, 1d JALA r0, r31, 0a timed out -code size: 204 +code size: 178 ret: 0 status: Ok(())