diff --git a/lang/src/son.rs b/lang/src/son.rs index b5fcd9992..33cbf7c94 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -1765,6 +1765,11 @@ impl Nodes { (*target, self[*target].outputs.as_slice()) } } + + fn is_hard_zero(&self, nid: Nid) -> bool { + self[nid].kind == Kind::CInt { value: 0 } + && self[nid].outputs.iter().all(|&n| self[n].kind != Kind::Phi) + } } enum CondOptRes { @@ -2943,7 +2948,6 @@ 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); - let fty = ty.bin_ret(op); if matches!( op, TokenKind::Lt @@ -2967,9 +2971,12 @@ impl<'a> Codegen<'a> { } } } - let inps = [VOID, lhs.id, rhs.id]; - let bop = - self.ci.nodes.new_node_lit(fty, Kind::BinOp { op }, inps, self.tys); + let bop = self.ci.nodes.new_node_lit( + ty.bin_ret(op), + Kind::BinOp { op }, + [VOID, lhs.id, rhs.id], + self.tys, + ); self.ci.nodes.pass_aclass(aclass, bop.id); Some(bop) } diff --git a/lang/src/son/hbvm.rs b/lang/src/son/hbvm.rs index 24c594a01..8f1a243af 100644 --- a/lang/src/son/hbvm.rs +++ b/lang/src/son/hbvm.rs @@ -398,7 +398,8 @@ impl Nodes { fn is_never_used(&self, nid: Nid, tys: &Types) -> bool { let node = &self[nid]; match node.kind { - Kind::CInt { .. } => node.outputs.iter().all(|&o| { + Kind::CInt { value: 0 } => false, + Kind::CInt { value: 1.. } => node.outputs.iter().all(|&o| { matches!(self[o].kind, Kind::BinOp { op } if op.imm_binop(self[o].ty).is_some() && self.is_const(self[o].inputs[2]) diff --git a/lang/src/son/hbvm/their_regalloc.rs b/lang/src/son/hbvm/their_regalloc.rs index a4e36f035..a1e6b4aec 100644 --- a/lang/src/son/hbvm/their_regalloc.rs +++ b/lang/src/son/hbvm/their_regalloc.rs @@ -223,6 +223,7 @@ impl HbvmBackend { Kind::Die => { self.emit(instrs::un()); } + Kind::CInt { value: 0 } => self.emit(instrs::cp(atr(allocs[0]), reg::ZERO)), Kind::CInt { value } if node.ty.is_float() => { self.emit(match node.ty { ty::Id::F32 => instrs::li32( @@ -563,7 +564,11 @@ impl<'a> Function<'a> { } ); debug_assert!(self.nodes[nid].kind != Kind::Phi || self.nodes[nid].ty != ty::Id::VOID); - regalloc2::VReg::new(nid as _, regalloc2::RegClass::Int) + if self.nodes.is_hard_zero(nid) { + regalloc2::VReg::new(NEVER as _, regalloc2::RegClass::Int) + } else { + regalloc2::VReg::new(nid as _, regalloc2::RegClass::Int) + } } fn emit_node(&mut self, nid: Nid, prev: Nid) { @@ -680,6 +685,7 @@ impl<'a> Function<'a> { self.add_instr(nid, vec![]); self.emit_node(node.outputs[0], nid); } + Kind::CInt { value: 0 } if self.nodes.is_hard_zero(nid) => {} Kind::CInt { .. } => { let ops = vec![self.drg(nid)]; self.add_instr(nid, ops); @@ -687,6 +693,11 @@ impl<'a> Function<'a> { Kind::Entry => { self.backrefs[nid as usize] = self.add_block(nid); + self.add_instr(NEVER, vec![regalloc2::Operand::reg_fixed_def( + regalloc2::VReg::new(NEVER as _, regalloc2::RegClass::Int), + regalloc2::PReg::new(0, regalloc2::RegClass::Int), + )]); + let (ret, mut parama) = self.tys.parama(self.sig.ret); let mut typs = self.sig.args.args(); #[expect(clippy::unnecessary_to_owned)] diff --git a/lang/tests/son_tests_advanced_floating_point_arithmetic.txt b/lang/tests/son_tests_advanced_floating_point_arithmetic.txt index 6f5701661..283380972 100644 --- a/lang/tests/son_tests_advanced_floating_point_arithmetic.txt +++ b/lang/tests/son_tests_advanced_floating_point_arithmetic.txt @@ -10,34 +10,34 @@ main: ADDI64 r254, r254, 24d JALA r0, r31, 0a sin: - LI32 r4, 1124073472w - LI32 r5, 1078530011w - FMUL32 r7, r2, r4 - FDIV32 r9, r7, r5 - FTI32 r11, r9, 1b - ANDI r10, r11, 255d - ITF64 r5, r11 - MULI64 r4, r10, 4d - LRA r3, r0, :SIN_TABLE - LI32 r7, 1086918619w - FC64T32 r9, r5, 1b - ADDI64 r5, r11, 64d - ADD64 r8, r3, r4 - LI32 r1, 1132462080w - FMUL32 r6, r9, r7 - ANDI r7, r5, 255d - LI32 r5, 1056964608w - LD r4, r8, 0a, 4h - FDIV32 r8, r6, r1 - MULI64 r6, r7, 4d - FMUL32 r10, r4, r5 - FSUB32 r11, r2, r8 - ADD64 r9, r3, r6 - FMUL32 r2, r11, r10 - LD r12, r9, 0a, 4h - FSUB32 r5, r12, r2 - FMUL32 r7, r5, r11 - FADD32 r1, r4, r7 + LI32 r6, 1124073472w + LI32 r7, 1078530011w + FMUL32 r9, r2, r6 + FDIV32 r11, r9, r7 + FTI32 r1, r11, 1b + ANDI r12, r1, 255d + ITF64 r6, r1 + MULI64 r5, r12, 4d + LRA r4, r0, :SIN_TABLE + LI32 r9, 1086918619w + FC64T32 r11, r6, 1b + ADDI64 r6, r1, 64d + ADD64 r10, r4, r5 + LI32 r3, 1132462080w + FMUL32 r8, r11, r9 + ANDI r9, r6, 255d + LI32 r7, 1056964608w + LD r5, r10, 0a, 4h + FDIV32 r10, r8, r3 + MULI64 r8, r9, 4d + FMUL32 r12, r5, r7 + FSUB32 r1, r2, r10 + ADD64 r11, r4, r8 + FMUL32 r4, r1, r12 + LD r2, r11, 0a, 4h + FSUB32 r7, r2, r4 + FMUL32 r9, r7, r1 + FADD32 r1, r5, r9 JALA r0, r31, 0a code size: 1303 ret: 826 diff --git a/lang/tests/son_tests_aliasing_overoptimization.txt b/lang/tests/son_tests_aliasing_overoptimization.txt index e10b42134..5aa16aa1f 100644 --- a/lang/tests/son_tests_aliasing_overoptimization.txt +++ b/lang/tests/son_tests_aliasing_overoptimization.txt @@ -1,6 +1,6 @@ main: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 29 +code size: 22 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_arithmetic.txt b/lang/tests/son_tests_arithmetic.txt index e10b42134..5aa16aa1f 100644 --- a/lang/tests/son_tests_arithmetic.txt +++ b/lang/tests/son_tests_arithmetic.txt @@ -1,6 +1,6 @@ main: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 29 +code size: 22 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_arrays.txt b/lang/tests/son_tests_arrays.txt index b8c50e388..21929dbb0 100644 --- a/lang/tests/son_tests_arrays.txt +++ b/lang/tests/son_tests_arrays.txt @@ -14,13 +14,13 @@ main: ADDI64 r254, r254, 56d JALA r0, r31, 0a pass: - LD r4, r2, 8a, 8h - MULI64 r7, r4, 8d - LD r5, r2, 0a, 8h - ADD64 r10, r7, r2 - ADD64 r9, r4, r5 - LD r1, r10, 0a, 8h - ADD64 r1, r1, r9 + LD r6, r2, 8a, 8h + MULI64 r9, r6, 8d + LD r7, r2, 0a, 8h + ADD64 r12, r9, r2 + ADD64 r11, r6, r7 + LD r3, r12, 0a, 8h + ADD64 r1, r3, r11 JALA r0, r31, 0a code size: 231 ret: 8 diff --git a/lang/tests/son_tests_big_array_crash.txt b/lang/tests/son_tests_big_array_crash.txt index 23c0121eb..053fa9ee4 100644 --- a/lang/tests/son_tests_big_array_crash.txt +++ b/lang/tests/son_tests_big_array_crash.txt @@ -1,6 +1,6 @@ main: - LRA r1, r0, :SIN_TABLE - LD r1, r1, 80a, 8h + LRA r3, r0, :SIN_TABLE + LD r1, r3, 80a, 8h JALA r0, r31, 0a code size: 767 ret: 1736 diff --git a/lang/tests/son_tests_branch_assignments.txt b/lang/tests/son_tests_branch_assignments.txt index bec0bad09..ae2d21777 100644 --- a/lang/tests/son_tests_branch_assignments.txt +++ b/lang/tests/son_tests_branch_assignments.txt @@ -2,12 +2,11 @@ main: LI64 r1, 1d JNE r2, r1, :0 JMP :1 - 0: LI64 r7, 0d - JNE r2, r7, :2 + 0: JNE r2, r0, :2 LI64 r1, 2d JMP :1 2: LI64 r1, 3d 1: JALA r0, r31, 0a -code size: 79 +code size: 69 ret: 2 status: Ok(()) diff --git a/lang/tests/son_tests_c_strings.txt b/lang/tests/son_tests_c_strings.txt index be908d8cd..62042e7ea 100644 --- a/lang/tests/son_tests_c_strings.txt +++ b/lang/tests/son_tests_c_strings.txt @@ -11,16 +11,16 @@ main: ADDI64 r254, r254, 16d JALA r0, r31, 0a str_len: - LI64 r3, 0d - CP r1, r3 - 2: LD r7, r2, 0a, 1h - ANDI r9, r7, 255d - JNE r9, r3, :0 + CP r5, r0 + CP r1, r5 + 2: LD r9, r2, 0a, 1h + ANDI r11, r9, 255d + JNE r11, r5, :0 JMP :1 0: ADDI64 r2, r2, 1d ADDI64 r1, r1, 1d JMP :2 1: JALA r0, r31, 0a -code size: 205 +code size: 198 ret: 16 status: Ok(()) diff --git a/lang/tests/son_tests_comments.txt b/lang/tests/son_tests_comments.txt index 22a5c604b..5ae53459b 100644 --- a/lang/tests/son_tests_comments.txt +++ b/lang/tests/son_tests_comments.txt @@ -4,10 +4,10 @@ main: ADDI64 r254, r254, -8d ST r31, r254, 0a, 8h JAL r31, r0, :foo - LI64 r1, 0d + CP r1, r0 LD r31, r254, 0a, 8h ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 95 +code size: 88 ret: 0 status: Ok(()) 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 a9b8fb972..3a94ad03b 100644 --- a/lang/tests/son_tests_comptime_function_from_another_file.txt +++ b/lang/tests/son_tests_comptime_function_from_another_file.txt @@ -1,6 +1,6 @@ main: - LRA r1, r0, :a - LD r1, r1, 0a, 8h + LRA r3, r0, :a + LD r1, r3, 0a, 8h JALA r0, r31, 0a code size: 47 ret: 50 diff --git a/lang/tests/son_tests_comptime_min_reg_leak.txt b/lang/tests/son_tests_comptime_min_reg_leak.txt index a9b8fb972..3a94ad03b 100644 --- a/lang/tests/son_tests_comptime_min_reg_leak.txt +++ b/lang/tests/son_tests_comptime_min_reg_leak.txt @@ -1,6 +1,6 @@ main: - LRA r1, r0, :a - LD r1, r1, 0a, 8h + LRA r3, r0, :a + LD r1, r3, 0a, 8h JALA r0, r31, 0a code size: 47 ret: 50 diff --git a/lang/tests/son_tests_conditional_stores.txt b/lang/tests/son_tests_conditional_stores.txt index a9a249482..56f890a54 100644 --- a/lang/tests/son_tests_conditional_stores.txt +++ b/lang/tests/son_tests_conditional_stores.txt @@ -1,11 +1,11 @@ cond: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a main: ADDI64 r254, r254, -24d ST r31, r254, 0a, 24h JAL r31, r0, :cond - LI64 r32, 0d + CP r32, r0 CP r33, r32 JNE r1, r33, :0 CP r32, r33 @@ -15,6 +15,6 @@ main: 1: LD r31, r254, 0a, 24h ADDI64 r254, r254, 24d JALA r0, r31, 0a -code size: 134 +code size: 120 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_const_folding_with_arg.txt b/lang/tests/son_tests_const_folding_with_arg.txt index e10b42134..5aa16aa1f 100644 --- a/lang/tests/son_tests_const_folding_with_arg.txt +++ b/lang/tests/son_tests_const_folding_with_arg.txt @@ -1,6 +1,6 @@ main: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 29 +code size: 22 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_dead_code_in_loop.txt b/lang/tests/son_tests_dead_code_in_loop.txt index e10b42134..5aa16aa1f 100644 --- a/lang/tests/son_tests_dead_code_in_loop.txt +++ b/lang/tests/son_tests_dead_code_in_loop.txt @@ -1,6 +1,6 @@ main: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 29 +code size: 22 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_different_types.txt b/lang/tests/son_tests_different_types.txt index bad3ba803..e041f0853 100644 --- a/lang/tests/son_tests_different_types.txt +++ b/lang/tests/son_tests_different_types.txt @@ -1,29 +1,28 @@ main: ADDI64 r254, r254, -12d - LI64 r1, 0d - LI8 r2, 255b - ST r2, r254, 0a, 1h - LI8 r5, 0b - ST r5, r254, 1a, 1h - ST r5, r254, 2a, 1h - ST r2, r254, 3a, 1h - LI32 r10, 0w - ST r10, r254, 4a, 4h - LD r8, r254, 4a, 4h - LI32 r2, 2w - ST r2, r254, 8a, 4h - LD r5, r254, 8a, 4h - LI64 r9, 2d - ANDI r10, r5, 4294967295d - JEQ r10, r9, :0 + LI8 r3, 255b + ST r3, r254, 0a, 1h + ST r0, r254, 1a, 1h + ST r0, r254, 2a, 1h + ST r3, r254, 3a, 1h + ST r0, r254, 4a, 4h + LD r4, r254, 4a, 4h + LI32 r11, 2w + ST r11, r254, 8a, 4h + LD r2, r254, 8a, 4h + LI64 r5, 2d + ANDI r6, r2, 4294967295d + JEQ r6, r5, :0 + CP r1, r0 JMP :1 - 0: ANDI r2, r8, 4294967295d - JEQ r2, r1, :2 + 0: CP r1, r0 + ANDI r10, r4, 4294967295d + JEQ r10, r1, :2 LI64 r1, 64d JMP :1 2: LI64 r1, 512d 1: ADDI64 r254, r254, 12d JALA r0, r31, 0a -code size: 245 +code size: 232 ret: 512 status: Ok(()) diff --git a/lang/tests/son_tests_directives.txt b/lang/tests/son_tests_directives.txt index 9c25941b0..5f8268228 100644 --- a/lang/tests/son_tests_directives.txt +++ b/lang/tests/son_tests_directives.txt @@ -1,20 +1,20 @@ main: ADDI64 r254, r254, -16d - LI64 r1, 10d + LI64 r3, 10d ADDI64 r4, r254, 0d - ST r1, r254, 0a, 8h - LI64 r7, 20d - ST r7, r254, 8a, 8h + ST r3, r254, 0a, 8h + LI64 r9, 20d + ST r9, r254, 8a, 8h LI64 r6, 6d LI64 r5, 5d LI64 r2, 1d CP r3, r4 LD r3, r3, 0a, 16h ECA - LI64 r1, 0d + CP r1, r0 ADDI64 r254, r254, 16d JALA r0, r31, 0a ev: Ecall -code size: 155 +code size: 148 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 eaf456da8..483ea0fea 100644 --- a/lang/tests/son_tests_exhaustive_loop_testing.txt +++ b/lang/tests/son_tests_exhaustive_loop_testing.txt @@ -1,16 +1,16 @@ continue_and_state_change: - LI64 r7, 3d - LI64 r8, 4d - LI64 r9, 2d - LI64 r10, 10d - 6: JLTU r2, r10, :0 + LI64 r9, 3d + LI64 r10, 4d + LI64 r11, 2d + LI64 r12, 10d + 6: JLTU r2, r12, :0 CP r1, r2 JMP :1 - 0: JNE r2, r9, :2 - CP r2, r8 + 0: JNE r2, r11, :2 + CP r2, r10 JMP :3 - 2: JNE r2, r7, :4 - LI64 r1, 0d + 2: JNE r2, r9, :4 + CP r1, r0 1: JMP :5 4: ADDI64 r2, r2, 1d 3: JMP :6 @@ -19,7 +19,7 @@ infinite_loop: ADDI64 r254, r254, -24d ST r31, r254, 0a, 24h LI64 r32, 1d - LI64 r33, 0d + CP r33, r0 CP r1, r33 1: JNE r1, r32, :0 JMP :0 @@ -30,76 +30,74 @@ infinite_loop: ADDI64 r254, r254, 24d JALA r0, r31, 0a main: - ADDI64 r254, r254, -64d - ST r31, r254, 0a, 64h - LI64 r32, 0d - CP r2, r32 + ADDI64 r254, r254, -48d + ST r31, r254, 0a, 48h + CP r2, r0 JAL r31, r0, :multiple_breaks - CP r33, r1 + CP r32, r1 LI64 r1, 3d - JEQ r33, r1, :0 + JEQ r32, r1, :0 LI64 r1, 1d JMP :1 - 0: CP r34, r1 - LI64 r35, 4d - CP r2, r35 + 0: CP r33, r1 + LI64 r34, 4d + CP r2, r34 JAL r31, r0, :multiple_breaks - CP r36, r35 - LI64 r37, 10d - JEQ r1, r37, :2 + CP r35, r34 + LI64 r36, 10d + JEQ r1, r36, :2 LI64 r1, 2d JMP :1 - 2: CP r2, r32 + 2: CP r2, r0 JAL r31, r0, :state_change_in_break - JEQ r1, r32, :3 - CP r1, r34 + JEQ r1, r0, :3 + CP r1, r33 JMP :1 - 3: CP r2, r36 + 3: CP r2, r35 JAL r31, r0, :state_change_in_break - JEQ r1, r37, :4 - CP r1, r36 + JEQ r1, r36, :4 + CP r1, r35 JMP :1 - 4: CP r2, r37 + 4: CP r2, r36 JAL r31, r0, :continue_and_state_change - JEQ r1, r37, :5 + JEQ r1, r36, :5 LI64 r1, 5d JMP :1 - 5: CP r2, r34 + 5: CP r2, r33 JAL r31, r0, :continue_and_state_change - JEQ r1, r32, :6 + JEQ r1, r0, :6 LI64 r1, 6d JMP :1 - 6: CP r38, r32 - JAL r31, r0, :infinite_loop - CP r1, r38 - 1: LD r31, r254, 0a, 64h - ADDI64 r254, r254, 64d + 6: JAL r31, r0, :infinite_loop + CP r1, r0 + 1: LD r31, r254, 0a, 48h + ADDI64 r254, r254, 48d JALA r0, r31, 0a multiple_breaks: - LI64 r6, 3d - LI64 r5, 10d - 4: JLTU r2, r5, :0 + LI64 r8, 3d + LI64 r7, 10d + 4: JLTU r2, r7, :0 CP r1, r2 JMP :1 0: ADDI64 r1, r2, 1d - JNE r1, r6, :2 + JNE r1, r8, :2 1: JMP :3 2: CP r2, r1 JMP :4 3: JALA r0, r31, 0a state_change_in_break: - LI64 r5, 3d - LI64 r6, 10d - 4: JLTU r2, r6, :0 + LI64 r7, 3d + LI64 r8, 10d + 4: JLTU r2, r8, :0 CP r1, r2 JMP :1 - 0: JNE r2, r5, :2 - LI64 r1, 0d + 0: JNE r2, r7, :2 + CP r1, r0 1: JMP :3 2: ADDI64 r2, r2, 1d JMP :4 3: JALA r0, r31, 0a timed out -code size: 668 +code size: 634 ret: 10 status: Ok(()) diff --git a/lang/tests/son_tests_fb_driver.txt b/lang/tests/son_tests_fb_driver.txt index ae33add26..d5dd44899 100644 --- a/lang/tests/son_tests_fb_driver.txt +++ b/lang/tests/son_tests_fb_driver.txt @@ -9,7 +9,7 @@ main: ADDI64 r254, r254, -64d ST r31, r254, 0a, 64h JAL r31, r0, :check_platform - LI64 r32, 0d + CP r32, r0 LI64 r33, 30d LI64 r34, 100d CP r35, r32 @@ -42,12 +42,12 @@ main: ADDI64 r254, r254, 64d JALA r0, r31, 0a set_pixel: - MUL64 r7, r3, r4 - ADD64 r1, r7, r2 + MUL64 r9, r3, r4 + ADD64 r1, r9, r2 JALA r0, r31, 0a x86_fb_ptr: LI64 r1, 100d JALA r0, r31, 0a -code size: 330 +code size: 323 ret: 3000 status: Ok(()) diff --git a/lang/tests/son_tests_generic_type_mishap.txt b/lang/tests/son_tests_generic_type_mishap.txt index ab5bb18cf..dce806e6a 100644 --- a/lang/tests/son_tests_generic_type_mishap.txt +++ b/lang/tests/son_tests_generic_type_mishap.txt @@ -8,28 +8,26 @@ main: opaque: JALA r0, r31, 0a process: - ADDI64 r254, r254, -64d - ST r31, r254, 16a, 48h - LI64 r32, 0d - LI64 r33, 1000d - ADDI64 r34, r254, 0d - LI8 r35, 0b - ST r35, r254, 0a, 1h - 4: JGTU r33, r32, :0 + ADDI64 r254, r254, -48d + ST r31, r254, 16a, 32h + LI64 r32, 1000d + ADDI64 r33, r254, 0d + ST r0, r254, 0a, 1h + 4: JGTU r32, r0, :0 JMP :1 - 0: CP r2, r34 + 0: CP r2, r33 JAL r31, r0, :opaque - LD r36, r254, 0a, 1h - ANDI r36, r36, 255d - ANDI r35, r35, 255d - JEQ r36, r35, :2 + LD r34, r254, 0a, 1h + ANDI r34, r34, 255d + ANDI r0, r0, 255d + JEQ r34, r0, :2 JMP :3 - 2: ADDI64 r33, r33, -1d + 2: ADDI64 r32, r32, -1d 1: JMP :4 - 3: LD r31, r254, 16a, 48h - ADDI64 r254, r254, 64d + 3: LD r31, r254, 16a, 32h + ADDI64 r254, r254, 48d JALA r0, r31, 0a timed out -code size: 272 +code size: 259 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_generic_types.txt b/lang/tests/son_tests_generic_types.txt index 2fa320d95..f84a5c030 100644 --- a/lang/tests/son_tests_generic_types.txt +++ b/lang/tests/son_tests_generic_types.txt @@ -14,12 +14,12 @@ deinit: ADDI64 r254, r254, 32d JALA r0, r31, 0a free: - CP r10, r2 - LRA r7, r0, :FREE_SYS_CALL - LD r2, r7, 0a, 8h + CP r11, r2 + LRA r9, r0, :FREE_SYS_CALL + LD r2, r9, 0a, 8h CP r5, r4 CP r4, r3 - CP r3, r10 + CP r3, r11 ECA JALA r0, r31, 0a main: @@ -40,86 +40,83 @@ main: ADDI64 r254, r254, 56d JALA r0, r31, 0a malloc: - CP r9, r2 - LRA r5, r0, :MALLOC_SYS_CALL - LD r2, r5, 0a, 8h + CP r10, r2 + LRA r7, r0, :MALLOC_SYS_CALL + LD r2, r7, 0a, 8h CP r4, r3 - CP r3, r9 + CP r3, r10 ECA JALA r0, r31, 0a new: ADDI64 r254, r254, -24d - LI64 r4, 0d ADDI64 r5, r254, 0d - ST r4, r254, 0a, 8h - ST r4, r254, 8a, 8h - ST r4, r254, 16a, 8h + ST r0, r254, 0a, 8h + ST r0, r254, 8a, 8h + ST r0, r254, 16a, 8h BMC r5, r1, 24h ADDI64 r254, r254, 24d JALA r0, r31, 0a push: - ADDI64 r254, r254, -176d - ST r31, r254, 0a, 176h + ADDI64 r254, r254, -168d + ST r31, r254, 0a, 168h CP r32, r3 LI64 r33, 1d LD r34, r2, 8a, 8h LD r35, r2, 16a, 8h CP r36, r2 JNE r35, r34, :0 - LI64 r37, 0d - JNE r35, r37, :1 - CP r38, r33 + JNE r35, r0, :1 + CP r37, r33 JMP :2 - 1: MULI64 r38, r35, 2d - 2: LI64 r39, 8d - MUL64 r2, r38, r39 - CP r3, r39 + 1: MULI64 r37, r35, 2d + 2: LI64 r38, 8d + MUL64 r2, r37, r38 + CP r3, r38 JAL r31, r0, :malloc - CP r40, r1 - CP r41, r36 - ST r38, r41, 16a, 8h - LI64 r1, 0d - CP r42, r40 - JNE r42, r1, :3 + CP r39, r36 + ST r37, r39, 16a, 8h + JNE r1, r0, :3 + CP r1, r0 JMP :4 - 3: CP r40, r42 - MULI64 r43, r34, 8d - LD r44, r41, 0a, 8h - ADD64 r45, r44, r43 - CP r46, r40 - 9: LD r2, r41, 0a, 8h - LD r47, r41, 8a, 8h - JNE r45, r44, :5 - JEQ r47, r37, :6 - CP r4, r39 - MUL64 r3, r47, r4 + 3: CP r40, r1 + CP r1, r0 + MULI64 r41, r34, 8d + LD r42, r39, 0a, 8h + ADD64 r43, r42, r41 + CP r44, r40 + 9: LD r2, r39, 0a, 8h + LD r45, r39, 8a, 8h + JNE r43, r42, :5 + JEQ r45, r1, :6 + CP r4, r38 + MUL64 r3, r45, r4 JAL r31, r0, :free - CP r1, r40 + CP r46, r40 JMP :7 - 6: CP r1, r40 - 7: ST r1, r41, 0a, 8h + 6: CP r46, r40 + 7: ST r46, r39, 0a, 8h JMP :8 - 5: CP r1, r40 - CP r4, r39 - ADDI64 r48, r46, 8d - ADDI64 r42, r44, 8d - LD r49, r44, 0a, 8h - ST r49, r46, 0a, 8h - CP r44, r42 - CP r46, r48 + 5: CP r4, r38 + CP r46, r40 + ADDI64 r47, r44, 8d + ADDI64 r48, r42, 8d + LD r49, r42, 0a, 8h + ST r49, r44, 0a, 8h + CP r42, r48 + CP r44, r47 JMP :9 - 0: CP r41, r36 - 8: LD r50, r41, 8a, 8h - MULI64 r51, r50, 8d - LD r52, r41, 0a, 8h - ADD64 r1, r52, r51 + 0: CP r39, r36 + 8: LD r35, r39, 8a, 8h + MULI64 r50, r35, 8d + LD r46, r39, 0a, 8h + ADD64 r1, r46, r50 CP r3, r32 ST r3, r1, 0a, 8h - ADD64 r39, r50, r33 - ST r39, r41, 8a, 8h - 4: LD r31, r254, 0a, 176h - ADDI64 r254, r254, 176d + ADD64 r51, r35, r33 + ST r51, r39, 8a, 8h + 4: LD r31, r254, 0a, 168h + ADDI64 r254, r254, 168d JALA r0, r31, 0a -code size: 929 +code size: 899 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 9fe9282e3..9c9b3a693 100644 --- a/lang/tests/son_tests_global_aliasing_overptimization.txt +++ b/lang/tests/son_tests_global_aliasing_overptimization.txt @@ -1,7 +1,6 @@ clobber: - LRA r1, r0, :var - LI64 r3, 0d - ST r3, r1, 0a, 8h + LRA r3, r0, :var + ST r0, r3, 0a, 8h JALA r0, r31, 0a main: ADDI64 r254, r254, -24d @@ -14,6 +13,6 @@ main: LD r31, r254, 0a, 24h ADDI64 r254, r254, 24d JALA r0, r31, 0a -code size: 166 +code size: 156 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 448d583f8..ee9729a14 100644 --- a/lang/tests/son_tests_global_variable_wiredness.txt +++ b/lang/tests/son_tests_global_variable_wiredness.txt @@ -1,23 +1,22 @@ inb: - LI64 r1, 0d + 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 JNE r33, r0, :0 JMP :1 0: JAL r31, r0, :inb - LI64 r34, 0d - CMPU r35, r1, r34 - CMPUI r35, r35, 0d - NOT r35, r35 - ST r35, r32, 0a, 1h - 1: LD r31, r254, 0a, 40h - ADDI64 r254, r254, 40d + CMPU r34, r1, r0 + CMPUI r34, r34, 0d + NOT r34, r34 + ST r34, r32, 0a, 1h + 1: LD r31, r254, 0a, 32h + ADDI64 r254, r254, 32d JALA r0, r31, 0a -code size: 178 +code size: 161 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_global_variables.txt b/lang/tests/son_tests_global_variables.txt index c8a01e66c..2af554bb1 100644 --- a/lang/tests/son_tests_global_variables.txt +++ b/lang/tests/son_tests_global_variables.txt @@ -1,8 +1,8 @@ main: - LRA r2, r0, :complex_global_var - LD r3, r2, 0a, 8h - ADDI64 r1, r3, 5d - ST r1, r2, 0a, 8h + LRA r3, r0, :complex_global_var + LD r5, r3, 0a, 8h + ADDI64 r1, r5, 5d + ST r1, r3, 0a, 8h JALA r0, r31, 0a code size: 71 ret: 55 diff --git a/lang/tests/son_tests_hex_octal_binary_literals.txt b/lang/tests/son_tests_hex_octal_binary_literals.txt index e10b42134..5aa16aa1f 100644 --- a/lang/tests/son_tests_hex_octal_binary_literals.txt +++ b/lang/tests/son_tests_hex_octal_binary_literals.txt @@ -1,6 +1,6 @@ main: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 29 +code size: 22 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_idk.txt b/lang/tests/son_tests_idk.txt index 542ebd2f2..66945eebb 100644 --- a/lang/tests/son_tests_idk.txt +++ b/lang/tests/son_tests_idk.txt @@ -1,20 +1,20 @@ main: ADDI64 r254, r254, -128d - LI8 r6, 69b - LI64 r5, 128d - LI64 r7, 0d - ADDI64 r4, r254, 0d - 2: LD r1, r254, 42a, 1h - JLTU r7, r5, :0 - ANDI r1, r1, 255d + LI8 r8, 69b + LI64 r7, 128d + CP r9, r0 + ADDI64 r6, r254, 0d + 2: LD r3, r254, 42a, 1h + JLTU r9, r7, :0 + ANDI r1, r3, 255d JMP :1 - 0: ADDI64 r8, r7, 1d - ADD64 r3, r4, r7 - ST r6, r3, 0a, 1h - CP r7, r8 + 0: ADDI64 r10, r9, 1d + ADD64 r5, r6, r9 + ST r8, r5, 0a, 1h + CP r9, r10 JMP :2 1: ADDI64 r254, r254, 128d JALA r0, r31, 0a -code size: 145 +code size: 138 ret: 69 status: Ok(()) diff --git a/lang/tests/son_tests_infinite_loop_after_peephole.txt b/lang/tests/son_tests_infinite_loop_after_peephole.txt index e7d94df2e..69fa90301 100644 --- a/lang/tests/son_tests_infinite_loop_after_peephole.txt +++ b/lang/tests/son_tests_infinite_loop_after_peephole.txt @@ -1,9 +1,9 @@ main: - LI64 r2, 0d - 0: ADDI64 r2, r2, 1d + CP r4, r0 + 0: ADDI64 r4, r4, 1d JMP :0 JALA r0, r31, 0a timed out -code size: 45 +code size: 38 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_inline.txt b/lang/tests/son_tests_inline.txt index f144cb0ec..264cf2fd7 100644 --- a/lang/tests/son_tests_inline.txt +++ b/lang/tests/son_tests_inline.txt @@ -1,20 +1,19 @@ main: LI64 r2, 8d ECA - LI64 r10, 6d - LRA r6, r0, :gb - LI64 r9, 0d - LD r11, r6, 0a, 8h - CMPU r12, r11, r9 + LI64 r11, 6d + LRA r8, r0, :gb + LD r10, r8, 0a, 8h + CMPU r12, r10, r0 CMPUI r12, r12, 0d - ORI r2, r12, 0d + OR r2, r12, r0 ANDI r2, r2, 255d JNE r2, r0, :0 - CP r7, r10 + CP r7, r11 JMP :1 0: LI64 r7, 1d - 1: SUB64 r1, r7, r10 + 1: SUB64 r1, r7, r11 JALA r0, r31, 0a -code size: 142 +code size: 125 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_inline_test.txt b/lang/tests/son_tests_inline_test.txt index d9ecdcd94..a19ada5bb 100644 --- a/lang/tests/son_tests_inline_test.txt +++ b/lang/tests/son_tests_inline_test.txt @@ -1,28 +1,24 @@ main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -8d + ST r31, r254, 0a, 8h JAL r31, r0, :scalar_values - LI64 r32, 0d - CP r33, r32 - JEQ r1, r33, :0 + JEQ r1, r0, :0 LI64 r1, 1d JMP :1 0: JAL r31, r0, :structs - CP r34, r33 - JEQ r1, r34, :2 + JEQ r1, r0, :2 JAL r31, r0, :structs JMP :1 - 2: CP r1, r34 - CP r33, r34 - 1: LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + 2: CP r1, r0 + 1: LD r31, r254, 0a, 8h + ADDI64 r254, r254, 8d JALA r0, r31, 0a scalar_values: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a structs: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 182 +code size: 149 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_inlining_issues.txt b/lang/tests/son_tests_inlining_issues.txt index 896a6f593..e8fd8ac86 100644 --- a/lang/tests/son_tests_inlining_issues.txt +++ b/lang/tests/son_tests_inlining_issues.txt @@ -1,32 +1,30 @@ main: - ADDI64 r254, r254, -106d - ST r31, r254, 58a, 48h + ADDI64 r254, r254, -90d + ST r31, r254, 58a, 32h ADDI64 r32, r254, 33d ADDI64 r2, r254, 34d ADDI64 r6, r254, 1d - LI64 r33, 0d ADDI64 r4, r254, 17d ST r32, r254, 34a, 8h - LI64 r34, 100d + LI64 r33, 100d ADDI64 r7, r254, 0d - LI8 r35, 1b - ST r33, r254, 1a, 8h - ST r33, r254, 17a, 8h - ST r34, r254, 42a, 8h - LI8 r36, 0b - ST r35, r254, 0a, 1h - ST r33, r254, 9a, 8h - ST r33, r254, 25a, 8h - ST r34, r254, 50a, 8h - ST r36, r254, 33a, 1h + LI8 r34, 1b + ST r0, r254, 1a, 8h + ST r0, r254, 17a, 8h + ST r33, r254, 42a, 8h + ST r34, r254, 0a, 1h + ST r0, r254, 9a, 8h + ST r0, r254, 25a, 8h + ST r33, r254, 50a, 8h + ST r0, r254, 33a, 1h CP r3, r4 CP r5, r6 LD r3, r3, 0a, 16h LD r5, r5, 0a, 16h LD r7, r7, 0a, 1h JAL r31, r0, :put_filled_rect - LD r31, r254, 58a, 48h - ADDI64 r254, r254, 106d + LD r31, r254, 58a, 32h + ADDI64 r254, r254, 90d JALA r0, r31, 0a put_filled_rect: ADDI64 r254, r254, -212d @@ -38,72 +36,74 @@ put_filled_rect: ST r7, r254, 75a, 1h ADDI64 r7, r254, 75d LI64 r8, 25d - LI64 r32, 2d - LI64 r6, 8d - ADDI64 r33, r254, 25d - ADDI64 r34, r254, 50d - LI8 r35, 5b - ST r35, r254, 25a, 1h - LD r36, r5, 0a, 8h - ST r36, r254, 26a, 4h - LI64 r37, 1d - ST r37, r254, 30a, 4h + LI64 r6, 2d + LI64 r9, 8d + ADDI64 r32, r254, 25d + ADDI64 r33, r254, 50d + LI8 r34, 5b + ST r34, r254, 25a, 1h + LD r35, r5, 0a, 8h + ST r35, r254, 26a, 4h + LI64 r36, 1d + ST r36, r254, 30a, 4h ST r7, r254, 34a, 8h - ST r35, r254, 50a, 1h - ST r36, r254, 51a, 4h - ST r37, r254, 55a, 4h + ST r34, r254, 50a, 1h + ST r35, r254, 51a, 4h + ST r36, r254, 55a, 4h ST r7, r254, 59a, 8h - CP r38, r7 - LD r7, r3, 8a, 8h - LD r39, r5, 8a, 8h - ADD64 r11, r39, r7 - SUB64 r4, r11, r37 - LD r40, r2, 8a, 8h - MUL64 r5, r40, r4 - LD r9, r2, 0a, 8h - ADD64 r10, r9, r5 - LD r2, r3, 0a, 8h - ADD64 r41, r2, r10 - MUL64 r3, r40, r7 - ADD64 r4, r9, r3 - ADD64 r42, r2, r4 - 3: JGTU r39, r37, :0 - JNE r39, r37, :1 + CP r37, r7 + LD r4, r3, 8a, 8h + LD r38, r5, 8a, 8h + ADD64 r1, r38, r4 + SUB64 r5, r1, r36 + LD r39, r2, 8a, 8h + MUL64 r7, r39, r5 + LD r10, r2, 0a, 8h + ADD64 r11, r10, r7 + LD r5, r3, 0a, 8h + ADD64 r40, r5, r11 + MUL64 r4, r39, r4 + ADD64 r7, r10, r4 + ADD64 r41, r5, r7 + 3: JGTU r38, r36, :0 + JNE r38, r36, :1 ADDI64 r4, r254, 0d - ST r35, r254, 0a, 1h - ST r36, r254, 1a, 4h - ST r37, r254, 5a, 4h - ST r38, r254, 9a, 8h - ST r42, r254, 17a, 8h - CP r2, r6 - CP r3, r32 + ST r34, r254, 0a, 1h + ST r35, r254, 1a, 4h + ST r36, r254, 5a, 4h + ST r37, r254, 9a, 8h + ST r41, r254, 17a, 8h + CP r2, r9 + CP r3, r6 CP r5, r8 ECA JMP :1 1: JMP :2 - 0: CP r3, r32 - CP r43, r6 - CP r44, r8 - ST r42, r254, 67a, 8h - CP r2, r43 - CP r4, r34 - CP r5, r44 - ECA - ST r41, r254, 42a, 8h - CP r2, r43 - CP r3, r32 + 0: CP r3, r6 + CP r42, r9 + CP r43, r8 + ST r41, r254, 67a, 8h + CP r44, r3 + CP r2, r42 CP r4, r33 - CP r5, r44 + CP r5, r43 ECA - SUB64 r41, r41, r40 - ADD64 r42, r40, r42 - SUB64 r39, r39, r32 - CP r6, r43 - CP r8, r44 + ST r40, r254, 42a, 8h + CP r2, r42 + CP r3, r44 + CP r4, r32 + CP r5, r43 + ECA + SUB64 r40, r40, r39 + ADD64 r41, r39, r41 + SUB64 r38, r38, r44 + CP r6, r44 + CP r8, r43 + CP r9, r42 JMP :3 2: LD r32, r254, 108a, 104h ADDI64 r254, r254, 212d JALA r0, r31, 0a -code size: 917 +code size: 910 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_intcast_store.txt b/lang/tests/son_tests_intcast_store.txt index 8e8874ca2..b598fbfdd 100644 --- a/lang/tests/son_tests_intcast_store.txt +++ b/lang/tests/son_tests_intcast_store.txt @@ -1,20 +1,19 @@ main: - ADDI64 r254, r254, -32d - ST r31, r254, 16a, 16h + ADDI64 r254, r254, -24d + ST r31, r254, 16a, 8h ADDI64 r3, r254, 0d ADDI64 r2, r254, 8d - LI64 r32, 0d - ST r32, r254, 0a, 8h - ST r32, r254, 8a, 8h + ST r0, r254, 0a, 8h + ST r0, r254, 8a, 8h LI64 r4, 1024d JAL r31, r0, :set ANDI r1, r1, 4294967295d - LD r31, r254, 16a, 16h - ADDI64 r254, r254, 32d + LD r31, r254, 16a, 8h + ADDI64 r254, r254, 24d JALA r0, r31, 0a set: CP r1, r4 JALA r0, r31, 0a -code size: 167 +code size: 157 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 e4633ccc7..e3de9ac8d 100644 --- a/lang/tests/son_tests_integer_inference_issues.txt +++ b/lang/tests/son_tests_integer_inference_issues.txt @@ -8,10 +8,10 @@ integer_range: ECA CP r2, r32 CP r3, r33 - SUB64 r11, r3, r2 - ADDI64 r3, r11, 1d - DIRU64 r0, r3, r1, r3 - ADD64 r1, r3, r2 + SUB64 r3, r3, r2 + ADDI64 r3, r3, 1d + DIRU64 r0, r5, r1, r3 + ADD64 r1, r5, r2 LD r32, r254, 0a, 16h ADDI64 r254, r254, 16d JALA r0, r31, 0a @@ -19,11 +19,11 @@ main: ADDI64 r254, r254, -8d ST r31, r254, 0a, 8h LI64 r3, 1000d - LI64 r2, 0d + CP r2, r0 JAL r31, r0, :integer_range LD r31, r254, 0a, 8h ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 210 +code size: 203 ret: 42 status: Ok(()) diff --git a/lang/tests/son_tests_loop_stores.txt b/lang/tests/son_tests_loop_stores.txt index 19e9d458b..1fa378999 100644 --- a/lang/tests/son_tests_loop_stores.txt +++ b/lang/tests/son_tests_loop_stores.txt @@ -1,16 +1,15 @@ main: ADDI64 r254, r254, -8d - LI64 r3, 0d - LI64 r2, 10d - ST r2, r254, 0a, 8h + LI64 r3, 10d + ST r3, r254, 0a, 8h 2: LD r1, r254, 0a, 8h - JNE r1, r3, :0 + JNE r1, r0, :0 JMP :1 0: ADDI64 r11, r1, -1d ST r11, r254, 0a, 8h JMP :2 1: ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 126 +code size: 116 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_loops.txt b/lang/tests/son_tests_loops.txt index 1ddf33af4..13c3157b3 100644 --- a/lang/tests/son_tests_loops.txt +++ b/lang/tests/son_tests_loops.txt @@ -1,15 +1,14 @@ fib: - LI64 r4, 1d - LI64 r5, 0d - CP r1, r5 - CP r10, r4 - 2: JNE r2, r5, :0 + LI64 r6, 1d + CP r7, r0 + CP r1, r7 + CP r12, r6 + 2: JNE r2, r7, :0 JMP :1 - 0: ADD64 r1, r10, r1 - SUB64 r2, r2, r4 - CP r3, r1 - CP r1, r10 - CP r10, r3 + 0: ADD64 r3, r12, r1 + SUB64 r2, r2, r6 + CP r1, r12 + CP r12, r3 JMP :2 1: JALA r0, r31, 0a main: @@ -20,6 +19,6 @@ main: LD r31, r254, 0a, 8h ADDI64 r254, r254, 8d JALA r0, r31, 0a -code size: 153 +code size: 143 ret: 55 status: Ok(()) diff --git a/lang/tests/son_tests_memory_swap.txt b/lang/tests/son_tests_memory_swap.txt index 9fae971f0..e494653eb 100644 --- a/lang/tests/son_tests_memory_swap.txt +++ b/lang/tests/son_tests_memory_swap.txt @@ -1,18 +1,17 @@ decide: ADDI64 r254, r254, -24d - ADDI64 r5, r254, 0d + ADDI64 r7, r254, 0d ST r2, r254, 0a, 8h - LI64 r8, 0d - ST r8, r254, 8a, 8h - ST r8, r254, 16a, 8h - BMC r5, r1, 24h + ST r0, r254, 8a, 8h + ST r0, r254, 16a, 8h + BMC r7, r1, 24h ADDI64 r254, r254, 24d JALA r0, r31, 0a main: ADDI64 r254, r254, -112d ST r31, r254, 72a, 40h ADDI64 r32, r254, 48d - LI64 r2, 0d + CP r2, r0 CP r1, r32 JAL r31, r0, :decide ADDI64 r1, r254, 24d @@ -27,6 +26,6 @@ main: LD r31, r254, 72a, 40h ADDI64 r254, r254, 112d JALA r0, r31, 0a -code size: 275 +code size: 258 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 378e92567..fdcce38df 100644 --- a/lang/tests/son_tests_more_if_opts.txt +++ b/lang/tests/son_tests_more_if_opts.txt @@ -1,27 +1,26 @@ main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h JAL r31, r0, :opaque CP r32, r1 JAL r31, r0, :opaque - LI64 r33, 0d CP r1, r32 - JNE r1, r33, :0 + JNE r1, r0, :0 CP r32, r1 - LI64 r1, 0d - CP r34, r32 + CP r1, r0 + CP r33, r32 JMP :1 - 0: CP r34, r1 - LD r1, r34, 0a, 8h - 1: JEQ r34, r33, :2 - LD r1, r34, 0a, 8h + 0: CP r33, r1 + LD r1, r33, 0a, 8h + 1: JEQ r33, r0, :2 + LD r1, r33, 0a, 8h JMP :2 - 2: LD r31, r254, 0a, 32h - ADDI64 r254, r254, 32d + 2: LD r31, r254, 0a, 24h + ADDI64 r254, r254, 24d JALA r0, r31, 0a opaque: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 183 +code size: 159 ret: 0 status: Ok(()) 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 c7735b3f3..a8403376e 100644 --- a/lang/tests/son_tests_null_check_in_the_loop.txt +++ b/lang/tests/son_tests_null_check_in_the_loop.txt @@ -1,34 +1,32 @@ main: - ADDI64 r254, r254, -38d - ST r31, r254, 6a, 32h - LI8 r32, 0b - ADDI64 r33, r254, 0d + ADDI64 r254, r254, -30d + ST r31, r254, 6a, 24h + ADDI64 r32, r254, 0d 2: JAL r31, r0, :return_fn ST r1, r254, 0a, 6h - LD r34, r254, 0a, 1h - ANDI r34, r34, 255d - ANDI r32, r32, 255d - JEQ r34, r32, :0 + LD r33, r254, 0a, 1h + ANDI r33, r33, 255d + ANDI r0, r0, 255d + JEQ r33, r0, :0 LI64 r1, 1d 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, -6d - LI8 r4, 1b - ADDI64 r3, r254, 0d - ST r4, r254, 0a, 1h - LI8 r4, 0b - ST r4, r254, 1a, 1h - ST r4, r254, 2a, 1h - ST r4, r254, 3a, 1h - ST r4, r254, 4a, 1h - ST r4, r254, 5a, 1h - LD r1, r3, 0a, 6h + LI8 r5, 1b + ADDI64 r4, r254, 0d + ST r5, r254, 0a, 1h + ST r0, r254, 1a, 1h + ST r0, r254, 2a, 1h + ST r0, r254, 3a, 1h + ST r0, r254, 4a, 1h + ST r0, r254, 5a, 1h + LD r1, r4, 0a, 6h ADDI64 r254, r254, 6d JALA r0, r31, 0a -code size: 302 +code size: 296 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 4e6e3ef99..6c7d9c01b 100644 --- a/lang/tests/son_tests_null_check_returning_small_global.txt +++ b/lang/tests/son_tests_null_check_returning_small_global.txt @@ -1,80 +1,76 @@ foo: - ADDI64 r254, r254, -200d - ST r31, r254, 80a, 120h + ADDI64 r254, r254, -184d + ST r31, r254, 80a, 104h ADDI64 r32, r254, 64d LRA r3, r0, :some_file JAL r31, r0, :get ST r1, r254, 64a, 16h - LI8 r33, 0b - LD r34, r254, 64a, 1h - ANDI r34, r34, 255d + LD r33, r254, 64a, 1h ANDI r33, r33, 255d - JNE r34, r33, :0 - ADDI64 r35, r254, 48d - ST r33, r254, 48a, 1h - LD r1, r35, 0a, 16h + ANDI r0, r0, 255d + JNE r33, r0, :0 + ADDI64 r34, r254, 48d + ST r0, r254, 48a, 1h + LD r1, r34, 0a, 16h JMP :1 - 0: LI8 r36, 1b - LI64 r37, 4d - LD r38, r254, 72a, 8h - JNE r38, r37, :2 - ADDI64 r39, r254, 32d - ST r36, r254, 32a, 1h - LI64 r40, 2d - ST r40, r254, 40a, 8h - LD r1, r39, 0a, 16h + 0: LI8 r35, 1b + LI64 r36, 4d + LD r37, r254, 72a, 8h + JNE r37, r36, :2 + ADDI64 r38, r254, 32d + ST r35, r254, 32a, 1h + LI64 r39, 2d + ST r39, r254, 40a, 8h + LD r1, r38, 0a, 16h JMP :1 - 2: LRA r41, r0, :MAGIC - LD r42, r41, 0a, 8h - JNE r42, r38, :3 - ADDI64 r43, r254, 16d - ST r36, r254, 16a, 1h - LI64 r44, 0d - ST r44, r254, 24a, 8h + 2: LRA r40, r0, :MAGIC + LD r41, r40, 0a, 8h + JNE r41, r37, :3 + ADDI64 r42, r254, 16d + ST r35, r254, 16a, 1h + ST r0, r254, 24a, 8h + LD r1, r42, 0a, 16h + JMP :1 + 3: ADDI64 r43, r254, 0d + ST r0, r254, 0a, 1h LD r1, r43, 0a, 16h - JMP :1 - 3: ADDI64 r45, r254, 0d - ST r33, r254, 0a, 1h - LD r1, r45, 0a, 16h - 1: LD r31, r254, 80a, 120h - ADDI64 r254, r254, 200d + 1: LD r31, r254, 80a, 104h + ADDI64 r254, r254, 184d JALA r0, r31, 0a get: ADDI64 r254, r254, -32d - LD r3, r3, 0a, 1h - LRA r5, r0, :MAGIC - ANDI r9, r3, 255d - LD r8, r5, 0a, 8h - JNE r8, r9, :0 - LI8 r2, 1b - ADDI64 r1, r254, 16d - ST r2, r254, 16a, 1h - ST r8, r254, 24a, 8h - LD r1, r1, 0a, 16h + LD r5, r3, 0a, 1h + LRA r7, r0, :MAGIC + ANDI r11, r5, 255d + LD r10, r7, 0a, 8h + JNE r10, r11, :0 + LI8 r4, 1b + ADDI64 r3, r254, 16d + ST r4, r254, 16a, 1h + ST r10, r254, 24a, 8h + LD r1, r3, 0a, 16h JMP :1 - 0: ADDI64 r7, r254, 0d - LI8 r9, 0b - ST r9, r254, 0a, 1h - LD r1, r7, 0a, 16h + 0: ADDI64 r9, r254, 0d + ST r0, r254, 0a, 1h + LD r1, r9, 0a, 16h 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, r254, 0a, 16h - LI8 r33, 0b - LD r34, r254, 0a, 1h - ANDI r34, r34, 255d + LD r33, r254, 0a, 1h ANDI r33, r33, 255d - JNE r34, r33, :0 + ANDI r0, r0, 255d + JNE r33, r0, :0 LI64 r1, 100d JMP :1 0: LD r1, r254, 8a, 8h - 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: 768 +code size: 749 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 883264a37..4326b94a1 100644 --- a/lang/tests/son_tests_null_check_test.txt +++ b/lang/tests/son_tests_null_check_test.txt @@ -1,24 +1,23 @@ get_ptr: - LI64 r1, 0d + 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 - LI64 r32, 0d - JNE r1, r32, :0 - LI64 r1, 0d + JNE r1, r0, :0 + CP r1, r0 JMP :1 - 0: LI64 r33, 10d - CP r34, r1 - 2: LD r1, r34, 0a, 8h - JEQ r1, r33, :1 - ADDI64 r35, r1, 1d - ST r35, r34, 0a, 8h + 0: LI64 r32, 10d + CP r33, r1 + 2: LD r1, r33, 0a, 8h + JEQ r1, r32, :1 + ADDI64 r34, r1, 1d + ST r34, r33, 0a, 8h JMP :2 - 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: 185 +code size: 161 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_nullable_structure.txt b/lang/tests/son_tests_nullable_structure.txt index 4ee4ab41d..04fc68eb6 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, -122d - ST r31, r254, 26a, 96h + ADDI64 r254, r254, -98d + ST r31, r254, 26a, 72h JAL r31, r0, :returner_fn CP r32, r1 ADDI64 r1, r254, 2d @@ -8,52 +8,48 @@ main: ADDI64 r33, r254, 0d JAL r31, r0, :returner_cn ST r1, r254, 0a, 2h - LI8 r34, 0b - LI8 r35, 0b - LD r36, r254, 2a, 1h + LD r34, r254, 2a, 1h CP r1, r32 - CMPU r37, r1, r34 - CMPUI r37, r37, 0d - CMPU r38, r36, r35 + CMPU r35, r1, r0 + CMPUI r35, r35, 0d + CMPU r32, r34, r0 + CMPUI r32, r32, 0d + LD r36, r254, 0a, 1h + AND r37, r32, r35 + CMPU r38, r36, r0 CMPUI r38, r38, 0d - LD r39, r254, 0a, 1h - AND r40, r38, r37 - CMPU r41, r39, r35 - CMPUI r41, r41, 0d - AND r42, r41, r40 - ANDI r42, r42, 255d - JNE r42, r0, :0 - LI64 r1, 0d + AND r39, r38, r37 + ANDI r39, r39, 255d + JNE r39, r0, :0 + CP r1, r0 JMP :1 0: LI64 r1, 1d - 1: LD r31, r254, 26a, 96h - ADDI64 r254, r254, 122d + 1: LD r31, r254, 26a, 72h + ADDI64 r254, r254, 98d JALA r0, r31, 0a returner_bn: ADDI64 r254, r254, -24d - LI8 r6, 1b - ADDI64 r5, r254, 0d - ST r6, r254, 0a, 1h - LI64 r6, 0d - ST r6, r254, 8a, 8h - ST r6, r254, 16a, 8h - BMC r5, r1, 24h + LI8 r7, 1b + ADDI64 r6, r254, 0d + ST r7, r254, 0a, 1h + ST r0, r254, 8a, 8h + ST r0, r254, 16a, 8h + BMC r6, r1, 24h ADDI64 r254, r254, 24d JALA r0, r31, 0a returner_cn: ADDI64 r254, r254, -2d - LI8 r4, 1b - ADDI64 r3, r254, 0d - ST r4, r254, 0a, 1h - LI8 r4, 0b - ST r4, r254, 1a, 1h - LD r1, r3, 0a, 2h + LI8 r5, 1b + ADDI64 r4, r254, 0d + ST r5, r254, 0a, 1h + ST r0, r254, 1a, 1h + LD r1, r4, 0a, 2h ADDI64 r254, r254, 2d JALA r0, r31, 0a returner_fn: - LD r1, r254, 0a, 0h - ORI r1, r1, 128d + LD r3, r254, 0a, 0h + ORI r1, r3, 128d JALA r0, r31, 0a -code size: 480 +code size: 454 ret: 1 status: Ok(()) diff --git a/lang/tests/son_tests_nullable_types.txt b/lang/tests/son_tests_nullable_types.txt index e82d09acb..688f3007b 100644 --- a/lang/tests/son_tests_nullable_types.txt +++ b/lang/tests/son_tests_nullable_types.txt @@ -2,10 +2,10 @@ decide: LI8 r1, 1b JALA r0, r31, 0a main: - ADDI64 r254, r254, -232d - ST r31, r254, 80a, 152h + ADDI64 r254, r254, -224d + ST r31, r254, 80a, 144h JAL r31, r0, :decide - LI64 r32, 0d + CP r32, r0 ADDI64 r2, r254, 72d CP r33, r2 ANDI r1, r1, 255d @@ -19,23 +19,22 @@ main: LI64 r1, 9001d JMP :3 2: JAL r31, r0, :decide - LI8 r36, 0b ANDI r1, r1, 255d JNE r1, r0, :4 - LI8 r37, 1b - ST r37, r254, 56a, 1h + LI8 r36, 1b + ST r36, r254, 56a, 1h LD r37, r34, 0a, 8h ST r37, r254, 64a, 8h JMP :5 - 4: ST r36, r254, 56a, 1h + 4: ST r0, r254, 56a, 1h 5: LD r38, r254, 56a, 1h ANDI r38, r38, 255d - ANDI r36, r36, 255d - JEQ r38, r36, :6 + ANDI r0, r0, 255d + JEQ r38, r0, :6 LI64 r1, 42d JMP :3 6: JAL r31, r0, :decide - LI32 r39, 0w + CP r39, r0 ANDI r1, r1, 255d JNE r1, r0, :7 CP r40, r39 @@ -50,9 +49,8 @@ main: CP r41, r3 JAL r31, r0, :new_foo ST r1, r254, 40a, 16h - LI64 r42, 0d - LD r43, r254, 40a, 8h - JNE r43, r42, :10 + LD r42, r254, 40a, 8h + JNE r42, r0, :10 LI64 r1, 999d JMP :3 10: LRA r4, r0, :"foo\0" @@ -60,7 +58,7 @@ main: CP r2, r3 LD r2, r2, 0a, 16h JAL r31, r0, :use_foo - ADDI64 r44, r254, 0d + ADDI64 r43, r254, 0d JAL r31, r0, :no_foo ST r1, r254, 0a, 16h JAL r31, r0, :decide @@ -71,8 +69,8 @@ main: 11: CP r2, r33 ST r2, r254, 0a, 8h ST r35, r254, 8a, 8h -12: LD r45, r254, 0a, 8h - JNE r45, r42, :13 +12: LD r44, r254, 0a, 8h + JNE r44, r0, :13 LI64 r1, 34d JMP :3 13: ADDI64 r1, r254, 16d @@ -81,47 +79,45 @@ main: ANDI r1, r1, 255d JNE r1, r0, :14 JMP :15 -14: ST r36, r254, 16a, 1h -15: LD r46, r254, 16a, 1h - ANDI r46, r46, 255d - ANDI r36, r36, 255d - JEQ r46, r36, :16 +14: ST r0, r254, 16a, 1h +15: LD r45, r254, 16a, 1h + ANDI r45, r45, 255d + ANDI r0, r0, 255d + JEQ r45, r0, :16 LI64 r1, 420d JMP :3 -16: LD r47, r254, 0a, 8h - LD r48, r47, 0a, 8h - ANDI r49, r40, 65535d - SUB64 r1, r49, r48 - 3: LD r31, r254, 80a, 152h - ADDI64 r254, r254, 232d +16: LD r46, r254, 0a, 8h + LD r47, r46, 0a, 8h + ANDI r48, r40, 65535d + SUB64 r1, r48, r47 + 3: LD r31, r254, 80a, 144h + ADDI64 r254, r254, 224d JALA r0, r31, 0a new_bar: ADDI64 r254, r254, -24d - LI8 r8, 1b - ADDI64 r7, r254, 0d - ST r8, r254, 0a, 1h + LI8 r10, 1b + ADDI64 r9, r254, 0d + ST r10, r254, 0a, 1h ST r2, r254, 8a, 8h - LI64 r9, 1d - ST r9, r254, 16a, 8h - BMC r7, r1, 24h + LI64 r11, 1d + ST r11, r254, 16a, 8h + BMC r9, r1, 24h ADDI64 r254, r254, 24d JALA r0, r31, 0a new_foo: ADDI64 r254, r254, -24d - ADDI64 r3, r254, 0d - ADDI64 r2, r254, 8d - ST r3, r254, 8a, 8h - LI64 r5, 0d - ST r5, r254, 16a, 8h - LD r1, r2, 0a, 16h + ADDI64 r5, r254, 0d + ADDI64 r4, r254, 8d + ST r5, r254, 8a, 8h + ST r0, r254, 16a, 8h + LD r1, r4, 0a, 16h ADDI64 r254, r254, 24d JALA r0, r31, 0a no_foo: ADDI64 r254, r254, -16d - ADDI64 r1, r254, 0d - LI64 r3, 0d - ST r3, r254, 0a, 8h - LD r1, r1, 0a, 16h + ADDI64 r3, r254, 0d + ST r0, r254, 0a, 8h + LD r1, r3, 0a, 16h ADDI64 r254, r254, 16d JALA r0, r31, 0a use_foo: @@ -130,6 +126,6 @@ use_foo: ADDI64 r2, r254, 0d ADDI64 r254, r254, 16d JALA r0, r31, 0a -code size: 1143 +code size: 1100 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 b353a8cc4..62064b74a 100644 --- a/lang/tests/son_tests_only_break_loop.txt +++ b/lang/tests/son_tests_only_break_loop.txt @@ -2,29 +2,28 @@ inb: CP r1, r2 JALA r0, r31, 0a main: - ADDI64 r254, r254, -32d - ST r31, r254, 0a, 32h - LI64 r32, 0d - LI64 r33, 100d - 4: CP r2, r33 + ADDI64 r254, r254, -24d + ST r31, r254, 0a, 24h + LI64 r32, 100d + 4: CP r2, r32 JAL r31, r0, :inb - ANDI r34, r1, 2d - JNE r34, r32, :0 + ANDI r33, r1, 2d + JNE r33, r0, :0 LI64 r2, 96d - CP r3, r32 + CP r3, r0 JAL r31, r0, :outb - 3: CP r2, r33 + 3: CP r2, r32 JAL r31, r0, :inb - JEQ r1, r32, :1 + JEQ r1, r0, :1 LI64 r1, 1d 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: 198 +code size: 188 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 fe479eb7f..00ada79c5 100644 --- a/lang/tests/son_tests_optional_from_eca.txt +++ b/lang/tests/son_tests_optional_from_eca.txt @@ -1,22 +1,21 @@ main: ADDI64 r254, r254, -16d - ADDI64 r3, r254, 0d - LI64 r6, 0d - CP r3, r6 - CP r4, r6 - CP r5, r6 + ADDI64 r4, r254, 0d + CP r3, r0 + CP r4, r0 + CP r5, r0 + CP r6, r0 ECA ST r1, r254, 0a, 16h - LI8 r8, 0b - LD r9, r254, 0a, 1h - ANDI r9, r9, 255d - ANDI r8, r8, 255d - JNE r9, r8, :0 + LD r7, r254, 0a, 1h + ANDI r7, r7, 255d + ANDI r0, r0, 255d + JNE r7, r0, :0 UN 0: LD r1, r254, 8a, 8h ADDI64 r254, r254, 16d JALA r0, r31, 0a unknown ecall: 0 -code size: 142 +code size: 132 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 4441af264..c3a469c19 100644 --- a/lang/tests/son_tests_overwrite_aliasing_overoptimization.txt +++ b/lang/tests/son_tests_overwrite_aliasing_overoptimization.txt @@ -19,12 +19,12 @@ main: JALA r0, r31, 0a opaque: ADDI64 r254, r254, -16d - LI64 r3, 3d - ADDI64 r2, r254, 0d - ST r3, r254, 0a, 8h - LI64 r6, 2d - ST r6, r254, 8a, 8h - LD r1, r2, 0a, 16h + LI64 r5, 3d + ADDI64 r4, r254, 0d + ST r5, r254, 0a, 8h + LI64 r8, 2d + ST r8, r254, 8a, 8h + LD r1, r4, 0a, 16h ADDI64 r254, r254, 16d JALA r0, r31, 0a code size: 307 diff --git a/lang/tests/son_tests_pointer_opts.txt b/lang/tests/son_tests_pointer_opts.txt index f8db12265..311f353ee 100644 --- a/lang/tests/son_tests_pointer_opts.txt +++ b/lang/tests/son_tests_pointer_opts.txt @@ -1,6 +1,6 @@ clobber: - LI64 r3, 4d - ST r3, r2, 0a, 8h + LI64 r5, 4d + ST r5, r2, 0a, 8h JALA r0, r31, 0a main: ADDI64 r254, r254, -40d diff --git a/lang/tests/son_tests_pointers.txt b/lang/tests/son_tests_pointers.txt index 3376e7614..20c9ddf12 100644 --- a/lang/tests/son_tests_pointers.txt +++ b/lang/tests/son_tests_pointers.txt @@ -15,8 +15,8 @@ main: ADDI64 r254, r254, 32d JALA r0, r31, 0a modify: - LI64 r3, 2d - ST r3, r2, 0a, 8h + LI64 r5, 2d + ST r5, r2, 0a, 8h JALA r0, r31, 0a code size: 187 ret: 0 diff --git a/lang/tests/son_tests_reading_idk.txt b/lang/tests/son_tests_reading_idk.txt index e10b42134..5aa16aa1f 100644 --- a/lang/tests/son_tests_reading_idk.txt +++ b/lang/tests/son_tests_reading_idk.txt @@ -1,6 +1,6 @@ main: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 29 +code size: 22 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_request_page.txt b/lang/tests/son_tests_request_page.txt index e249c8f44..470440c9c 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, -56d - ST r31, r254, 0a, 56h + ADDI64 r254, r254, -48d + ST r31, r254, 0a, 48h LI64 r32, 255d JGTS r2, r32, :0 JAL r31, r0, :request_page @@ -9,23 +9,22 @@ create_back_buffer: LI8 r34, 255b CP r2, r34 JAL r31, r0, :request_page - LI64 r35, 0d CP r2, r33 - SUB64 r36, r2, r32 - 5: JGTS r36, r35, :2 + SUB64 r35, r2, r32 + 5: JGTS r35, r0, :2 JMP :1 - 2: CP r37, r1 - JLTS r36, r32, :3 + 2: CP r36, r1 + JLTS r35, r32, :3 CP r2, r34 JAL r31, r0, :request_page JMP :4 - 3: CP r2, r36 + 3: CP r2, r35 JAL r31, r0, :request_page - 4: SUB64 r36, r36, r32 - CP r1, r37 + 4: SUB64 r35, r35, r32 + CP r1, r36 JMP :5 - 1: LD r31, r254, 0a, 56h - ADDI64 r254, r254, 56d + 1: LD r31, r254, 0a, 48h + ADDI64 r254, r254, 48d JALA r0, r31, 0a main: ADDI64 r254, r254, -8d @@ -43,6 +42,6 @@ request_page: LI64 r2, 3d ECA JALA r0, r31, 0a -code size: 331 +code size: 321 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 ea20c838f..a9020adff 100644 --- a/lang/tests/son_tests_returning_global_struct.txt +++ b/lang/tests/son_tests_returning_global_struct.txt @@ -19,8 +19,8 @@ main: ADDI64 r254, r254, 100d JALA r0, r31, 0a random_color: - LRA r1, r0, :white - LD r1, r1, 0a, 4h + LRA r3, r0, :white + LD r1, r3, 0a, 4h JALA r0, r31, 0a code size: 241 ret: 1020 diff --git a/lang/tests/son_tests_returning_optional_issues.txt b/lang/tests/son_tests_returning_optional_issues.txt index a38591c53..6d3cf8cda 100644 --- a/lang/tests/son_tests_returning_optional_issues.txt +++ b/lang/tests/son_tests_returning_optional_issues.txt @@ -1,31 +1,30 @@ get_format: ADDI64 r254, r254, -16d - LI8 r5, 1b - ADDI64 r4, r254, 0d - LRA r3, r0, :BMP - ST r5, r254, 0a, 1h - LD r6, r3, 0a, 8h - ST r6, r254, 8a, 8h - LD r1, r4, 0a, 16h + LI8 r7, 1b + ADDI64 r6, r254, 0d + LRA r5, r0, :BMP + ST r7, r254, 0a, 1h + LD r8, r5, 0a, 8h + ST r8, r254, 8a, 8h + LD r1, r6, 0a, 16h 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, r254, 0a, 16h - LI8 r33, 0b - LD r34, r254, 0a, 1h - ANDI r34, r34, 255d + LD r33, r254, 0a, 1h ANDI r33, r33, 255d - JNE r34, r33, :0 + ANDI r0, r0, 255d + JNE r33, r0, :0 LI64 r1, 1d JMP :1 0: LD r1, r254, 8a, 8h - 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: 283 +code size: 280 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 34a3cfd7e..386085c18 100644 --- a/lang/tests/son_tests_scheduling_block_did_dirty.txt +++ b/lang/tests/son_tests_scheduling_block_did_dirty.txt @@ -14,18 +14,18 @@ main: ADDI64 r254, r254, -32d ST r31, r254, 16a, 16h ADDI64 r32, r254, 0d - LI64 r3, 0d + CP r3, r0 JAL r31, r0, :constructor ST r1, r254, 0a, 16h LD r31, r254, 16a, 16h ADDI64 r254, r254, 32d JALA r0, r31, 0a opaque: - LRA r3, r0, :file - ADD64 r5, r3, r2 - LD r7, r5, 0a, 1h - ANDI r1, r7, 255d + LRA r5, r0, :file + ADD64 r7, r5, r2 + LD r9, r7, 0a, 1h + ANDI r1, r9, 255d JALA r0, r31, 0a -code size: 274 +code size: 267 ret: 255 status: Ok(()) diff --git a/lang/tests/son_tests_small_struct_assignment.txt b/lang/tests/son_tests_small_struct_assignment.txt index 27ddda15e..94a589ceb 100644 --- a/lang/tests/son_tests_small_struct_assignment.txt +++ b/lang/tests/son_tests_small_struct_assignment.txt @@ -1,10 +1,10 @@ main: ADDI64 r254, r254, -4d - LRA r2, r0, :white - ADDI64 r3, r254, 0d - BMC r2, r3, 4h - LD r6, r254, 3a, 1h - ANDI r1, r6, 255d + LRA r4, r0, :white + ADDI64 r5, r254, 0d + BMC r4, r5, 4h + LD r8, r254, 3a, 1h + ANDI r1, r8, 255d ADDI64 r254, r254, 4d JALA r0, r31, 0a code size: 92 diff --git a/lang/tests/son_tests_sort_something_viredly.txt b/lang/tests/son_tests_sort_something_viredly.txt index 536fb47ac..1d59f8f8e 100644 --- a/lang/tests/son_tests_sort_something_viredly.txt +++ b/lang/tests/son_tests_sort_something_viredly.txt @@ -7,23 +7,23 @@ main: ADDI64 r254, r254, 8d JALA r0, r31, 0a sqrt: - LI64 r7, 15d - LI64 r8, 32768d - LI64 r5, 0d - CP r1, r5 - 3: JNE r8, r5, :0 + LI64 r9, 15d + LI64 r10, 32768d + CP r7, r0 + CP r1, r7 + 3: JNE r10, r7, :0 JMP :1 - 0: SLUI64 r4, r1, 1b - ADDI64 r7, r7, -1d - ADD64 r9, r4, r8 - SLU64 r9, r9, r7 - JLTU r2, r9, :2 - ADD64 r1, r8, r1 - SUB64 r2, r2, r9 + 0: SLUI64 r6, r1, 1b + ADDI64 r9, r9, -1d + ADD64 r11, r6, r10 + SLU64 r11, r11, r9 + JLTU r2, r11, :2 + ADD64 r1, r10, r1 + SUB64 r2, r2, r11 JMP :2 - 2: SRUI64 r8, r8, 1b + 2: SRUI64 r10, r10, 1b JMP :3 1: JALA r0, r31, 0a -code size: 188 +code size: 181 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 d0cc4854f..e521e2bdb 100644 --- a/lang/tests/son_tests_storing_into_nullable_struct.txt +++ b/lang/tests/son_tests_storing_into_nullable_struct.txt @@ -4,66 +4,63 @@ do_stuff: just_read: JALA r0, r31, 0a main: - ADDI64 r254, r254, -120d - ST r31, r254, 48a, 72h + ADDI64 r254, r254, -104d + ST r31, r254, 48a, 56h ADDI64 r32, r254, 16d CP r1, r32 JAL r31, r0, :optionala CP r2, r32 - LI64 r33, 0d - LD r34, r254, 16a, 8h - JNE r34, r33, :0 + LD r33, r254, 16a, 8h + JNE r33, r0, :0 LI64 r1, 10d JMP :1 - 0: ST r33, r254, 24a, 8h + 0: ST r0, r254, 24a, 8h JAL r31, r0, :just_read LD r2, r254, 24a, 8h JAL r31, r0, :do_stuff - CP r35, r1 - ADDI64 r36, r254, 0d + CP r34, r1 + ADDI64 r35, r254, 0d JAL r31, r0, :optional ST r1, r254, 0a, 16h - LI8 r37, 0b - LD r38, r254, 0a, 1h - ANDI r38, r38, 255d - ANDI r37, r37, 255d - JNE r38, r37, :2 + LD r36, r254, 0a, 1h + ANDI r36, r36, 255d + ANDI r0, r0, 255d + JNE r36, r0, :2 LI64 r1, 20d JMP :1 - 2: LI64 r39, 100d - ST r39, r254, 8a, 8h + 2: LI64 r37, 100d + ST r37, r254, 8a, 8h LD r2, r254, 8a, 8h JAL r31, r0, :do_stuff - ADD64 r1, r1, r35 - 1: LD r31, r254, 48a, 72h - ADDI64 r254, r254, 120d + ADD64 r1, r1, r34 + 1: LD r31, r254, 48a, 56h + 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 + LI8 r6, 1b + ADDI64 r5, r254, 0d + ST r6, r254, 0a, 1h + LI64 r6, 10d + ST r6, r254, 8a, 8h + LD r1, r5, 0a, 16h ADDI64 r254, r254, 16d JALA r0, r31, 0a optionala: ADDI64 r254, r254, -48d - ADDI64 r5, r254, 8d - ADDI64 r4, r254, 16d - ST r5, r254, 16a, 8h - LI64 r9, 1d - ST r9, r254, 24a, 8h - ADDI64 r12, r254, 0d - ST r12, r254, 32a, 8h - LI64 r11, 0d - ST r11, r254, 0a, 8h - ST r11, r254, 8a, 8h - ST r11, r254, 40a, 8h - BMC r4, r1, 32h + ADDI64 r7, r254, 8d + ADDI64 r6, r254, 16d + ST r7, r254, 16a, 8h + LI64 r10, 1d + ST r10, r254, 24a, 8h + ADDI64 r2, r254, 0d + ST r2, r254, 32a, 8h + ST r0, r254, 0a, 8h + ST r0, r254, 8a, 8h + ST r0, r254, 40a, 8h + BMC r6, r1, 32h ADDI64 r254, r254, 48d JALA r0, r31, 0a -code size: 603 +code size: 580 ret: 100 status: Ok(()) diff --git a/lang/tests/son_tests_string_flip.txt b/lang/tests/son_tests_string_flip.txt index 33856d5b3..76f68693f 100644 --- a/lang/tests/son_tests_string_flip.txt +++ b/lang/tests/son_tests_string_flip.txt @@ -1,44 +1,44 @@ main: ADDI64 r254, r254, -40d - LI64 r7, 1d - LI64 r6, 4d - LI64 r4, 0d - ADDI64 r5, r254, 0d - CP r8, r4 - 6: JNE r8, r6, :0 - LI64 r6, 2d - ADDI64 r3, r254, 32d - CP r8, r4 + LI64 r9, 1d + LI64 r8, 4d + CP r6, r0 + ADDI64 r7, r254, 0d + CP r10, r6 + 6: JNE r10, r8, :0 + LI64 r8, 2d + ADDI64 r5, r254, 32d + CP r10, r6 4: LD r1, r254, 16a, 8h - JNE r8, r7, :1 + JNE r10, r9, :1 JMP :2 - 1: MUL64 r12, r8, r6 - ADD64 r8, r8, r7 - SUB64 r9, r6, r8 - MUL64 r9, r9, r6 - CP r11, r4 - 5: JNE r11, r6, :3 + 1: MUL64 r2, r10, r8 + ADD64 r10, r10, r9 + SUB64 r11, r8, r10 + MUL64 r11, r11, r8 + CP r1, r6 + 5: JNE r1, r8, :3 JMP :4 - 3: ADD64 r10, r11, r7 - ADD64 r1, r12, r11 - ADD64 r2, r9, r11 - MULI64 r1, r1, 8d - MULI64 r11, r2, 8d - ADD64 r1, r5, r1 - ADD64 r11, r5, r11 + 3: ADD64 r12, r1, r9 + ADD64 r3, r2, r1 + ADD64 r4, r11, r1 + MULI64 r3, r3, 8d + MULI64 r1, r4, 8d + ADD64 r3, r7, r3 + ADD64 r1, r7, r1 + BMC r3, r5, 8h BMC r1, r3, 8h - BMC r11, r1, 8h - BMC r3, r11, 8h - CP r11, r10 + BMC r5, r1, 8h + CP r1, r12 JMP :5 - 0: ADD64 r2, r8, r7 - MULI64 r12, r8, 8d - ADD64 r3, r5, r12 - ST r8, r3, 0a, 8h - CP r8, r2 + 0: ADD64 r4, r10, r9 + MULI64 r2, r10, 8d + ADD64 r5, r7, r2 + ST r10, r5, 0a, 8h + CP r10, r4 JMP :6 2: ADDI64 r254, r254, 40d JALA r0, r31, 0a -code size: 271 +code size: 264 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 511ff1519..0759470e7 100644 --- a/lang/tests/son_tests_struct_in_register.txt +++ b/lang/tests/son_tests_struct_in_register.txt @@ -1,10 +1,10 @@ main: ADDI64 r254, r254, -4d - LRA r1, r0, :MAGENTA - ADDI64 r3, r254, 0d - BMC r1, r3, 4h - LD r6, r254, 2a, 1h - ANDI r1, r6, 255d + LRA r3, r0, :MAGENTA + ADDI64 r5, r254, 0d + BMC r3, r5, 4h + LD r8, r254, 2a, 1h + ANDI r1, r8, 255d ADDI64 r254, r254, 4d JALA r0, r31, 0a code size: 92 diff --git a/lang/tests/son_tests_struct_patterns.txt b/lang/tests/son_tests_struct_patterns.txt index 28b22bb28..0a96a2145 100644 --- a/lang/tests/son_tests_struct_patterns.txt +++ b/lang/tests/son_tests_struct_patterns.txt @@ -18,17 +18,16 @@ fib: ADDI64 r254, r254, 32d JALA r0, r31, 0a fib_iter: - LI64 r4, 1d - LI64 r5, 0d - CP r1, r5 - CP r10, r4 - 2: JNE r2, r5, :0 + LI64 r6, 1d + CP r7, r0 + CP r1, r7 + CP r12, r6 + 2: JNE r2, r7, :0 JMP :1 - 0: ADD64 r1, r10, r1 - SUB64 r2, r2, r4 - CP r3, r1 - CP r1, r10 - CP r10, r3 + 0: ADD64 r3, r12, r1 + SUB64 r2, r2, r6 + CP r1, r12 + CP r12, r3 JMP :2 1: JALA r0, r31, 0a main: @@ -44,6 +43,6 @@ main: LD r31, r254, 0a, 24h ADDI64 r254, r254, 24d JALA r0, r31, 0a -code size: 300 +code size: 290 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 c17dbb3b4..1fa54faf1 100644 --- a/lang/tests/son_tests_struct_return_from_module_function.txt +++ b/lang/tests/son_tests_struct_return_from_module_function.txt @@ -1,12 +1,12 @@ foo: ADDI64 r254, r254, -16d - LI64 r3, 3d - ADDI64 r2, r254, 0d - ST r3, r254, 0a, 8h - LI32 r6, 2w - ST r6, r254, 8a, 4h - ST r6, r254, 12a, 4h - LD r1, r2, 0a, 16h + LI64 r5, 3d + ADDI64 r4, r254, 0d + ST r5, r254, 0a, 8h + LI32 r8, 2w + ST r8, r254, 8a, 4h + ST r8, r254, 12a, 4h + LD r1, r4, 0a, 16h ADDI64 r254, r254, 16d JALA r0, r31, 0a main: diff --git a/lang/tests/son_tests_structs.txt b/lang/tests/son_tests_structs.txt index 7a590a33a..de32c6eb4 100644 --- a/lang/tests/son_tests_structs.txt +++ b/lang/tests/son_tests_structs.txt @@ -16,7 +16,7 @@ main: CP r2, r34 JAL r31, r0, :pass JMP :1 - 0: LI64 r1, 0d + 0: CP r1, r0 1: LD r31, r254, 32a, 40h ADDI64 r254, r254, 72d JALA r0, r31, 0a @@ -30,6 +30,6 @@ odher_pass: pass: LD r1, r2, 0a, 8h JALA r0, r31, 0a -code size: 308 +code size: 301 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 6a10f2f62..ce18be5f4 100644 --- a/lang/tests/son_tests_tests_ptr_to_ptr_copy.txt +++ b/lang/tests/son_tests_tests_ptr_to_ptr_copy.txt @@ -1,30 +1,30 @@ main: ADDI64 r254, r254, -10240d - LI64 r7, 1d - LI8 r8, 64b - LI64 r6, 1024d - LI64 r9, 0d - ADDI64 r5, r254, 0d - 4: JLTU r9, r6, :0 - LI64 r6, 10d - CP r8, r7 - 3: LD r11, r254, 2048a, 1h - JLTU r8, r6, :1 - ANDI r1, r11, 255d + LI64 r9, 1d + LI8 r10, 64b + LI64 r8, 1024d + CP r11, r0 + ADDI64 r7, r254, 0d + 4: JLTU r11, r8, :0 + LI64 r8, 10d + CP r10, r9 + 3: LD r1, r254, 2048a, 1h + JLTU r10, r8, :1 + ANDI r1, r1, 255d JMP :2 - 1: ADD64 r2, r8, r7 - MULI64 r1, r8, 1024d - ADD64 r3, r5, r1 - BMC r5, r3, 1024h - CP r8, r2 + 1: ADD64 r4, r10, r9 + MULI64 r3, r10, 1024d + ADD64 r5, r7, r3 + BMC r7, r5, 1024h + CP r10, r4 JMP :3 - 0: ADD64 r2, r9, r7 - ADD64 r12, r5, r9 - ST r8, r12, 0a, 1h - CP r9, r2 + 0: ADD64 r4, r11, r9 + ADD64 r2, r7, r11 + ST r10, r2, 0a, 1h + CP r11, r4 JMP :4 2: ADDI64 r254, r254, 10240d JALA r0, r31, 0a -code size: 198 +code size: 191 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 28f607652..538df1b39 100644 --- a/lang/tests/son_tests_triggering_store_in_divergent_branch.txt +++ b/lang/tests/son_tests_triggering_store_in_divergent_branch.txt @@ -1,10 +1,10 @@ main: ADDI64 r254, r254, -72d ST r31, r254, 0a, 72h - LI8 r32, 0b + CP r32, r0 LI64 r33, 65536d LI8 r34, 1b - LI64 r35, 0d + CP r35, r0 CP r36, r35 7: JAL r31, r0, :opaque JLTU r36, r1, :0 @@ -30,6 +30,6 @@ opaque: LI64 r1, 2147483648d JALA r0, r31, 0a timed out -code size: 218 +code size: 211 ret: 2147483648 status: Ok(()) diff --git a/lang/tests/son_tests_variables.txt b/lang/tests/son_tests_variables.txt index e10b42134..5aa16aa1f 100644 --- a/lang/tests/son_tests_variables.txt +++ b/lang/tests/son_tests_variables.txt @@ -1,6 +1,6 @@ main: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 29 +code size: 22 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_very_nested_loops.txt b/lang/tests/son_tests_very_nested_loops.txt index e10b42134..5aa16aa1f 100644 --- a/lang/tests/son_tests_very_nested_loops.txt +++ b/lang/tests/son_tests_very_nested_loops.txt @@ -1,6 +1,6 @@ main: - LI64 r1, 0d + CP r1, r0 JALA r0, r31, 0a -code size: 29 +code size: 22 ret: 0 status: Ok(()) diff --git a/lang/tests/son_tests_wide_ret.txt b/lang/tests/son_tests_wide_ret.txt index 2d01e0434..ff6a7c239 100644 --- a/lang/tests/son_tests_wide_ret.txt +++ b/lang/tests/son_tests_wide_ret.txt @@ -2,7 +2,7 @@ main: ADDI64 r254, r254, -56d ST r31, r254, 16a, 40h ADDI64 r32, r254, 0d - LI64 r4, 0d + CP r4, r0 CP r3, r4 JAL r31, r0, :maina ST r1, r254, 0a, 16h @@ -14,44 +14,42 @@ main: ADDI64 r254, r254, 56d 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, r254, 16a, 4h - LI8 r33, 0b - ADDI64 r34, r254, 0d - ST r33, r254, 0a, 1h - ST r33, r254, 1a, 1h - ST r33, r254, 2a, 1h - LI8 r35, 3b - ST r35, r254, 3a, 1h - LI8 r36, 1b - ST r36, r254, 4a, 1h - ST r33, r254, 5a, 1h - ST r33, r254, 6a, 1h - ST r33, r254, 7a, 1h - ST r33, r254, 8a, 1h - ST r33, r254, 9a, 1h - ST r33, r254, 10a, 1h - ST r35, r254, 11a, 1h - ST r36, r254, 12a, 1h - ST r33, r254, 13a, 1h - ST r33, r254, 14a, 1h - ST r33, r254, 15a, 1h - LD r1, r34, 0a, 16h - LD r31, r254, 20a, 48h - ADDI64 r254, r254, 68d + ADDI64 r33, r254, 0d + ST r0, r254, 0a, 1h + ST r0, r254, 1a, 1h + ST r0, r254, 2a, 1h + LI8 r34, 3b + ST r34, r254, 3a, 1h + LI8 r35, 1b + ST r35, r254, 4a, 1h + ST r0, r254, 5a, 1h + ST r0, r254, 6a, 1h + ST r0, r254, 7a, 1h + ST r0, r254, 8a, 1h + ST r0, r254, 9a, 1h + ST r0, r254, 10a, 1h + ST r34, r254, 11a, 1h + ST r35, r254, 12a, 1h + ST r0, r254, 13a, 1h + ST r0, r254, 14a, 1h + ST r0, r254, 15a, 1h + LD r1, r33, 0a, 16h + LD r31, r254, 20a, 40h + ADDI64 r254, r254, 60d JALA r0, r31, 0a small_struct: ADDI64 r254, r254, -4d - LI16 r2, 0h ADDI64 r3, r254, 0d - ST r2, r254, 0a, 2h - ST r2, r254, 2a, 2h + ST r0, r254, 0a, 2h + ST r0, r254, 2a, 2h LD r1, r3, 0a, 4h ADDI64 r254, r254, 4d JALA r0, r31, 0a -code size: 570 +code size: 556 ret: 2 status: Ok(()) diff --git a/lang/tests/son_tests_wrong_dead_code_elimination.txt b/lang/tests/son_tests_wrong_dead_code_elimination.txt index 7bce152b3..f028305ff 100644 --- a/lang/tests/son_tests_wrong_dead_code_elimination.txt +++ b/lang/tests/son_tests_wrong_dead_code_elimination.txt @@ -1,29 +1,27 @@ main: ADDI64 r254, r254, -1d - LI64 r7, 0d LI64 r6, 255d - LI8 r2, 1b - LI8 r4, 0b - ST r4, r254, 0a, 1h - 2: LD r9, r254, 0a, 1h - ANDI r11, r9, 255d - CMPU r3, r11, r6 + LI8 r1, 1b + ST r0, r254, 0a, 1h + 2: LD r8, r254, 0a, 1h + ANDI r10, r8, 255d + CMPU r2, r10, r6 + CMPUI r2, r2, 0d + NOT r2, r2 + CMPU r3, r10, r0 CMPUI r3, r3, 0d NOT r3, r3 - CMPU r5, r11, r7 - CMPUI r5, r5, 0d - NOT r5, r5 - OR r8, r5, r3 - ANDI r8, r8, 255d - JNE r8, r0, :0 + OR r5, r3, r2 + ANDI r5, r5, 255d + JNE r5, r0, :0 JMP :1 - 0: SUB8 r2, r0, r2 - 1: ADD8 r4, r9, r2 - ST r4, r254, 0a, 1h + 0: SUB8 r1, r0, r1 + 1: ADD8 r2, r8, r1 + ST r2, r254, 0a, 1h JMP :2 ADDI64 r254, r254, 1d JALA r0, r31, 0a timed out -code size: 191 -ret: 0 +code size: 178 +ret: 1 status: Ok(())