]> rethought.computer Git - sorel-lang.git/commitdiff
more labels in asm output
authorBryan English <bryan@rethought.computer>
Sat, 22 Aug 2026 02:48:28 +0000 (22:48 -0400)
committerBryan English <bryan@rethought.computer>
Sat, 22 Aug 2026 02:49:58 +0000 (22:49 -0400)
sorel-codegen/src/lib.rs
sorel-codegen/src/riscv64_asm.rs

index 72a6c86034dd727d26229a1cbe9b018a7f3dc6da..577501c49335102f959546c0b5d2fddc9ba67400 100644 (file)
@@ -1,2 +1 @@
 pub mod riscv64_asm;
-
index 4b2f27253c0aae6e728f95db46dd396829e627b2..b2763662558b4fbffbac8f95313972f7dedce31f 100644 (file)
@@ -216,18 +216,22 @@ impl<'a> CodeGen<'a> {
                     self.copy_to_top_of_stack("t0");
                 },
                 IR::Store8 => { // ( x addr -- )
+                    self.label("# store 8");
                     self.pop_some_to("t0 t1");
                     self.line("sb t0, 0(t1)"); // store x at addr 
                 },
                 IR::Store16 => { // ( x addr -- )
+                    self.label("# store 16");
                     self.pop_some_to("t0 t1");
                     self.line("sh t0, 0(t1)"); // store x at addr 
                 },
                 IR::Store32 => { // ( x addr -- )
+                    self.label("# store 32");
                     self.pop_some_to("t0 t1");
                     self.line("sw t0, 0(t1)"); // store x at addr 
                 },
                 IR::Store => { // ( x addr -- )
+                    self.label("# store 64");
                     self.pop_some_to("t0 t1");
                     self.line("sd t0, 0(t1)"); // store x at addr 
                 },
@@ -250,12 +254,15 @@ impl<'a> CodeGen<'a> {
                     self.pop_call_push("t0 t1", "sub t0, t0, t1", "t0"); 
                 },
                 IR::MultiplyU64 => {
+                    self.label("# multiply");
                     self.pop_call_push("t0 t1", "mul t0, t0, t1", "t0"); 
                 },
                 IR::DivideU64 => {
+                    self.label("# divide");
                     self.pop_call_push("t0 t1", "div t0, t0, t1", "t0"); 
                 },
                 IR::ModU64 => {
+                    self.label("# mod");
                     self.pop_call_push("t0 t1", "rem t0, t0, t1", "t0"); 
                 },
                 IR::Dup => {
@@ -300,6 +307,7 @@ impl<'a> CodeGen<'a> {
                     self.move_stack_ptr_by_cells(1);
                 },
                 IR::Equals => {
+                    self.label("# equals");
                     // Yes, this is the same as subtract, since we're treating 0 as true, and
                     // others as false.
                     self.pop_call_push("t0 t1", "sub t0, t0, t1", "t0"); 
@@ -319,27 +327,35 @@ impl<'a> CodeGen<'a> {
                     self.push_from("t0");
                 },
                 IR::BitwiseOr => {
+                    self.label("# |");
                     self.pop_call_push("t0 t1", "or t0, t0, t1", "t0"); 
                 },
                 IR::Sys0 => {
+                    self.label("# syscall 0 args");
                     self.pop_call_push("a7", "ecall", "a0");
                 },
                 IR::Sys1 => {
+                    self.label("# syscall 1 arg");
                     self.pop_call_push("a0 a7", "ecall", "a0");
                 },
                 IR::Sys2 => {
+                    self.label("# syscall 2 args");
                     self.pop_call_push("a0 a1 a7", "ecall", "a0");
                 },
                 IR::Sys3 => {
+                    self.label("# syscall 3 args");
                     self.pop_call_push("a0 a1 a2 a7", "ecall", "a0");
                 },
                 IR::Sys4 => {
+                    self.label("# syscall 4 args");
                     self.pop_call_push("a0 a1 a2 a3 a7", "ecall", "a0");
                 },
                 IR::Sys5 => {
+                    self.label("# syscall 5 args");
                     self.pop_call_push("a0 a1 a2 a3 a4 a7", "ecall", "a0");
                 },
                 IR::Sys6 => {
+                    self.label("# syscall 6 args");
                     self.pop_call_push("a0 a1 a2 a3 a4 a5 a7", "ecall", "a0");
                 },
                 // https://cmput229.github.io/229-labs-RISCV/RISC-V-Examples_Public/03-Conditionals/03b-If_Else.html