Skip to content

Commit ac28e5f

Browse files
Merge pull request #222 from andrew-johnson-4/complex-match
Complex match
2 parents 4d6680c + 84a2e37 commit ac28e5f

File tree

7 files changed

+114
-9
lines changed

7 files changed

+114
-9
lines changed

BOOTSTRAP/cli.s

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73954,6 +73954,22 @@ uuid_000000000000045c:
7395473954
push %r13
7395573955
mov -72(%rbp),%r12
7395673956
mov -80(%rbp),%r13
73957+
call __expr_C__C_get_frame_C___
73958+
call uuid_0000000000000003
73959+
mov %r12, 0(%r8)
73960+
mov %r13, 8(%r8)
73961+
pop %r13
73962+
pop %r12
73963+
push %r8
73964+
call uuid_0000000000000003
73965+
mov %r12, 0(%r8)
73966+
mov %r13, 8(%r8)
73967+
mov %r8, %r12
73968+
pop %r13
73969+
push %r12
73970+
push %r13
73971+
mov -72(%rbp),%r12
73972+
mov -80(%rbp),%r13
7395773973
call __expr_C__C_get_prog_C___
7395873974
call uuid_0000000000000003
7395973975
mov %r12, 0(%r8)
@@ -74166,6 +74182,22 @@ uuid_000000000000045c:
7416674182
push %r13
7416774183
mov -88(%rbp),%r12
7416874184
mov -96(%rbp),%r13
74185+
call __expr_C__C_get_frame_C___
74186+
call uuid_0000000000000003
74187+
mov %r12, 0(%r8)
74188+
mov %r13, 8(%r8)
74189+
pop %r13
74190+
pop %r12
74191+
push %r8
74192+
call uuid_0000000000000003
74193+
mov %r12, 0(%r8)
74194+
mov %r13, 8(%r8)
74195+
mov %r8, %r12
74196+
pop %r13
74197+
push %r12
74198+
push %r13
74199+
mov -88(%rbp),%r12
74200+
mov -96(%rbp),%r13
7416974201
call __expr_C__C_get_prog_C___
7417074202
call uuid_0000000000000003
7417174203
mov %r12, 0(%r8)
@@ -74180,6 +74212,38 @@ uuid_000000000000045c:
7418074212
pop %r13
7418174213
push %r12
7418274214
push %r13
74215+
mov -88(%rbp),%r12
74216+
mov -96(%rbp),%r13
74217+
call __expr_C__C_get_unframe_C___
74218+
call uuid_0000000000000003
74219+
mov %r12, 0(%r8)
74220+
mov %r13, 8(%r8)
74221+
pop %r13
74222+
pop %r12
74223+
push %r8
74224+
call uuid_0000000000000003
74225+
mov %r12, 0(%r8)
74226+
mov %r13, 8(%r8)
74227+
mov %r8, %r12
74228+
pop %r13
74229+
push %r12
74230+
push %r13
74231+
mov -72(%rbp),%r12
74232+
mov -80(%rbp),%r13
74233+
call __expr_C__C_get_unframe_C___
74234+
call uuid_0000000000000003
74235+
mov %r12, 0(%r8)
74236+
mov %r13, 8(%r8)
74237+
pop %r13
74238+
pop %r12
74239+
push %r8
74240+
call uuid_0000000000000003
74241+
mov %r12, 0(%r8)
74242+
mov %r13, 8(%r8)
74243+
mov %r8, %r12
74244+
pop %r13
74245+
push %r12
74246+
push %r13
7418374247
mov $uuid_0000000000000008, %r12
7418474248
mov $0, %r13
7418574249
call uuid_0000000000000003
@@ -74298,6 +74362,22 @@ uuid_000000000000045c:
7429874362
mov %r13, 8(%r8)
7429974363
mov %r8, %r12
7430074364
pop %r13
74365+
push %r12
74366+
push %r13
74367+
mov -72(%rbp),%r12
74368+
mov -80(%rbp),%r13
74369+
call __expr_C__C_get_unframe_C___
74370+
call uuid_0000000000000003
74371+
mov %r12, 0(%r8)
74372+
mov %r13, 8(%r8)
74373+
pop %r13
74374+
pop %r12
74375+
push %r8
74376+
call uuid_0000000000000003
74377+
mov %r12, 0(%r8)
74378+
mov %r13, 8(%r8)
74379+
mov %r8, %r12
74380+
pop %r13
7430174381
call uuid_0000000000000003
7430274382
mov %r12, 0(%r8)
7430374383
mov %r13, 8(%r8)
@@ -74617,8 +74697,9 @@ uuid_000000000000046d:
7461774697
pop %r13
7461874698
push %r12
7461974699
push %r13
74620-
mov -24(%rbp),%r12
74621-
mov -32(%rbp),%r13
74700+
mov -72(%rbp),%r12
74701+
mov -80(%rbp),%r13
74702+
call __expr_C__C_get_offset_C___
7462274703
call uuid_0000000000000003
7462374704
mov %r12, 0(%r8)
7462474705
mov %r13, 8(%r8)
@@ -74667,8 +74748,9 @@ uuid_000000000000046d:
7466774748
pop %r13
7466874749
push %r12
7466974750
push %r13
74670-
mov -24(%rbp),%r12
74671-
mov -32(%rbp),%r13
74751+
mov -72(%rbp),%r12
74752+
mov -80(%rbp),%r13
74753+
call __expr_C__C_get_offset_C___
7467274754
call uuid_0000000000000003
7467374755
mov %r12, 0(%r8)
7467474756
mov %r13, 8(%r8)

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_mountain"
3-
version = "1.11.85"
3+
version = "1.11.86"
44
authors = ["Andrew <andrew@subarctic.org>"]
55
license = "MIT"
66
description = "Lambda Mountain"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
nostd: prod
3-
./production --nostd -o tmp.s tests/strict/match4.lm
3+
./production --nostd -o tmp.s tests/strict/match5.lm
44
as -o tmp.o tmp.s
55
ld -o tmp tmp.o
66
./tmp && echo $?

PRODUCTION/codegen-strict.lm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,25 @@ compile-expr-strict := λctx e offset used . (tail(
8787
(set label-end-loop (uuid()))
8888
(set e3 (expr::set-prog( e3 (
8989
label-begin-loop ': \n
90+
(expr::get-frame e1)
9091
(expr::get-prog e1)
9192
\t (expr::get-expr e1) \s label-do-loop \n
9293
\t 'jmp \s label-end-loop \n
9394
label-do-loop ': \n
95+
(expr::get-frame e2)
9496
(expr::get-prog e2)
97+
(expr::get-unframe e2)
98+
(expr::get-unframe e1)
9599
\t 'jmp \s label-begin-loop \n
96100
label-end-loop ': \n
101+
(expr::get-unframe e1)
97102
))))
98103
e3
99104
)))
100105
( (App( (App( (App( (Variable 'if) cond )) t )) f )) (tail(
101106
(set e1 (compile-expr-strict( ctx cond offset Used )))
102-
(set e2 (compile-expr-strict( (expr::get-context e1) t offset Used )))
103-
(set e3 (compile-expr-strict( ctx f offset Used )))
107+
(set e2 (compile-expr-strict( (expr::get-context e1) t (expr::get-offset e1) Used )))
108+
(set e3 (compile-expr-strict( ctx f (expr::get-offset e1) Used )))
104109
(match (expr::get-type e1) (
105110
()
106111
(BranchConditional ())

STDLIB/default-primitives.lm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ fragment branchtrue := λ(: _ Nil). (: (
8686
(.expression( 'jmp ))
8787
) BranchConditional);
8888
fragment branchfalse := λ(: _ Nil). (: (
89-
(.expression( 'nop ))
89+
(.program( \t 'cmp \s '%rsp, \s '%rsp \n ))
90+
(.expression( 'jne ))
9091
) BranchConditional);
9192

9293
fragment + := λ(: l LocalVariable+U8)(: r LocalVariable+U8). (: (

tests/strict/match5.lm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
import STDLIB/default-instruction-set.lm;
3+
import STDLIB/default-primitives.lm;
4+
import STDLIB/default-rules.lm;
5+
import STDLIB/default-stdlib.lm;
6+
7+
main := (tail(
8+
(let x 0u64)
9+
(while (<( x 4u64 )) (
10+
(match x (
11+
()
12+
(y (print y))
13+
))
14+
(set x (+( x 1u64 )))
15+
))
16+
));

tests/strict/match5.lm.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0123

0 commit comments

Comments
 (0)