about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-18 00:54:53 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-20 11:39:19 -0700
commitc41528dfe6364919feaf1d8e049c37d9b8ce5ca2 (patch)
tree1795d45d711533d30f2f4fed67b6a39370ec6de8 /apps
parenta2af4dedac491383c0c0169e75d32396a6ffd019 (diff)
downloadmu-c41528dfe6364919feaf1d8e049c37d9b8ce5ca2.tar.gz
mu.subx: 39 failing tests remaining
Diffstat (limited to 'apps')
-rw-r--r--apps/mu.subx62
1 files changed, 31 insertions, 31 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index 489f2b70..000d4af7 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -897,7 +897,7 @@ test-convert-function-call-with-literal-arg:
     5d/pop-to-ebp
     c3/return
 
-_failing-test-convert-function-with-local-var-in-mem:
+test-convert-function-with-local-var-in-mem:
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
@@ -7838,32 +7838,33 @@ emit-cleanup-code-until-depth:  # out: (addr buffered-file), vars: (addr stack (
     51/push-ecx
     52/push-edx
     53/push-ebx
+    56/push-esi
     # ecx = vars
     8b/-> *(ebp+0xc) 1/r32/ecx
-    # var eax: int = vars->top
-    8b/-> *ecx 0/r32/eax
+    # var esi: int = vars->top
+    8b/-> *ecx 6/r32/esi
     # var min/ecx: (addr handle var) = vars->data
     81 0/subop/add %ecx 8/imm32
-    # var curr/eax: (addr handle var) = &vars->data[vars->top - 4]
-    81 5/subop/subtract %eax 4/imm32
-    8d/copy-address *(ecx+eax) 0/r32/eax
+    # var curr/esi: (addr handle var) = &vars->data[vars->top - 8]
+    81 5/subop/subtract %esi 8/imm32
+    8d/copy-address *(ecx+esi) 6/r32/esi
     # edx = until-block-depth
     8b/-> *(ebp+0x10) 2/r32/edx
     {
 $emit-cleanup-code-until-depth:loop:
       # if (curr < min) break
-      39/compare %eax 1/r32/ecx
+      39/compare %esi 1/r32/ecx
       0f 82/jump-if-addr< break/disp32
-      # var v/ebx: (handle var) = *curr
-      8b/-> *eax 3/r32/ebx
+      # var v/ebx: (addr var) = lookup(*curr)
+      (lookup *esi *(esi+4))  # => eax
+      89/<- %ebx 0/r32/eax
       # if (v->block-depth < until-block-depth) break
-      39/compare *(ebx+8) 2/r32/edx  # Var-block-depth
+      39/compare *(ebx+0x10) 2/r32/edx  # Var-block-depth
       0f 8c/jump-if-< break/disp32
       # if v is in a register
-      81 7/subop/compare *(ebx+0x10) 0/imm32  # Var-register
+      81 7/subop/compare *(ebx+0x18) 0/imm32  # Var-register
       {
         0f 84/jump-if-= break/disp32
-        50/push-eax
         {
 $emit-cleanup-code-until-depth:check-for-previous-spill:
           (same-register-spilled-before? %ebx *(ebp+0xc) %eax)  # => eax
@@ -7872,17 +7873,16 @@ $emit-cleanup-code-until-depth:check-for-previous-spill:
 $emit-cleanup-code-until-depth:reclaim-var-in-register:
           (emit-indent *(ebp+8) *Curr-block-depth)
           (write-buffered *(ebp+8) "8f 0/subop/pop %")
-          (write-buffered *(ebp+8) *(ebx+0x10))
+          (lookup *(ebx+0x18) *(ebx+0x1c))  # Var-register Var-register => eax
+          (write-buffered *(ebp+8) %eax)
           (write-buffered *(ebp+8) Newline)
         }
-        58/pop-to-eax
         eb/jump $emit-cleanup-code-until-depth:continue/disp8
       }
       # otherwise v is on the stack
       {
         75/jump-if-!= break/disp8
 $emit-cleanup-code-until-depth:reclaim-var-on-stack:
-        50/push-eax
         (size-of %ebx)  # => eax
         # don't emit code for labels
         3d/compare-eax-and 0/imm32
@@ -7892,11 +7892,10 @@ $emit-cleanup-code-until-depth:reclaim-var-on-stack:
         (write-buffered *(ebp+8) "81 0/subop/add %esp ")
         (print-int32-buffered *(ebp+8) %eax)
         (write-buffered *(ebp+8) "/imm32\n")
-        58/pop-to-eax
       }
 $emit-cleanup-code-until-depth:continue:
-      # curr -= 4
-      2d/subtract-from-eax 4/imm32
+      # curr -= 8
+      81 5/subop/subtract %esi 8/imm32
       e9/jump loop/disp32
     }
 $emit-cleanup-code-until-depth:end:
@@ -7927,16 +7926,17 @@ emit-cleanup-code-until-target:  # out: (addr buffered-file), vars: (addr stack
     8b/-> *ecx 0/r32/eax
     # var min/ecx: (addr handle var) = vars->data
     81 0/subop/add %ecx 8/imm32
-    # var curr/edx: (addr handle var) = &vars->data[vars->top - 4]
-    81 5/subop/subtract %eax 4/imm32
+    # var curr/edx: (addr handle var) = &vars->data[vars->top - 8]
+    3d/subtract-from-eax 8/imm32
     8d/copy-address *(ecx+eax) 2/r32/edx
     {
 $emit-cleanup-code-until-target:loop:
       # if (curr < min) break
       39/compare %edx 1/r32/ecx
       0f 82/jump-if-addr< break/disp32
-      # var v/ebx: (handle var) = *curr
-      8b/-> *edx 3/r32/ebx
+      # var v/ebx: (handle var) = lookup(*curr)
+      (lookup *edx *(edx+4))  # => eax
+      89/<- %ebx 0/r32/eax
       # if (v->name == until-block-label) break
       (string-equal? *ebx *(ebp+0x10))  # => eax
       3d/compare-eax-and 0/imm32/false
@@ -7945,7 +7945,6 @@ $emit-cleanup-code-until-target:loop:
       81 7/subop/compare *(ebx+0x10) 0/imm32  # Var-register
       {
         74/jump-if-= break/disp8
-        50/push-eax
         {
 $emit-cleanup-code-until-target:check-for-previous-spill:
           (same-register-spilled-before? %ebx *(ebp+0xc) %edx)  # => eax
@@ -7957,7 +7956,6 @@ $emit-cleanup-code-until-target:reclaim-var-in-register:
           (write-buffered *(ebp+8) *(ebx+0x10))
           (write-buffered *(ebp+8) Newline)
         }
-        58/pop-to-eax
         eb/jump $emit-cleanup-code-until-target:continue/disp8
       }
       # otherwise v is on the stack
@@ -7975,8 +7973,8 @@ $emit-cleanup-code-until-target:reclaim-var-on-stack:
         (write-buffered *(ebp+8) "/imm32\n")
       }
 $emit-cleanup-code-until-target:continue:
-      # curr -= 4
-      81 5/subop/subtract %edx 4/imm32
+      # curr -= 8
+      81 5/subop/subtract %edx 8/imm32
       e9/jump loop/disp32
     }
 $emit-cleanup-code-until-target:end:
@@ -8179,11 +8177,12 @@ emit-subx-var-def:  # out: (addr buffered-file), stmt: (addr stmt)
     52/push-edx
     # eax = stmt
     8b/-> *(ebp+0xc) 0/r32/eax
-    # var v/ecx: (handle var)
-    8b/-> *(eax+4) 1/r32/ecx  # Vardef-var
+    # var v/ecx: (addr var)
+    (lookup *(eax+4) *(eax+8))  # Vardef-var Vardef-var => eax
+    89/<- %ecx 0/r32/eax
     # v->block-depth = *Curr-block-depth
     8b/-> *Curr-block-depth 0/r32/eax
-    89/<- *(ecx+8) 0/r32/eax  # Var-block-depth
+    89/<- *(ecx+0x10) 0/r32/eax  # Var-block-depth
     # var n/edx: int = size-of(stmt->var)
     (size-of %ecx)  # => eax
     89/<- %edx 0/r32/eax
@@ -8191,10 +8190,11 @@ emit-subx-var-def:  # out: (addr buffered-file), stmt: (addr stmt)
     29/subtract-from *Curr-local-stack-offset 2/r32/edx
     # v->offset = *Curr-local-stack-offset
     8b/-> *Curr-local-stack-offset 0/r32/eax
-    89/<- *(ecx+0xc) 0/r32/eax  # Var-offset
+    89/<- *(ecx+0x14) 0/r32/eax  # Var-offset
     # if v is an array, do something special
     {
-      (is-mu-array? *(ecx+4))  # Var-type => eax
+      (lookup *(ecx+8) *(ecx+0xc))  # Var-type Var-type => eax
+      (is-mu-array? %eax)  # => eax
       3d/compare-eax-and 0/imm32/false
       0f 84/jump-if-= break/disp32
       # var array-size-without-size/edx: int = n-4