diff --git a/app/Gyehoek/ANF/Syntax.hs b/app/Gyehoek/ANF/Syntax.hs index dca3463..2b6a820 100644 --- a/app/Gyehoek/ANF/Syntax.hs +++ b/app/Gyehoek/ANF/Syntax.hs @@ -329,7 +329,7 @@ lowerArithmetic r p = QBE.BinaryOp r bop x y PrimMul a b -> (QBE.Mul,a,b) _ -> _ -sizeofScm :: Int +sizeofScm :: Integral a => a sizeofScm = 8 lowerCons diff --git a/example/cons b/example/cons new file mode 100755 index 0000000..26c03d7 Binary files /dev/null and b/example/cons differ diff --git a/example/cons.anf b/example/cons.anf new file mode 100644 index 0000000..b6008d9 --- /dev/null +++ b/example/cons.anf @@ -0,0 +1,4 @@ +;;; -*- mode:scheme -*- + +(let ((x0 (prim:cons 4 5)) (x1 (prim:write x0))) x1) + diff --git a/example/cons.s b/example/cons.s new file mode 100644 index 0000000..155dd85 --- /dev/null +++ b/example/cons.s @@ -0,0 +1,18 @@ +.text +.globl main +main: + pushq %rbp + movq %rsp, %rbp + movl $16, %edi + callq GC_malloc + movq %rax, %rdi + movq $18, (%rdi) + movq $22, 8(%rdi) + callq scm_write + leave + ret +.type main, @function +.size main, .-main +/* end function main */ + +.section .note.GNU-stack,"",@progbits diff --git a/example/cons.scm b/example/cons.scm new file mode 100644 index 0000000..172cb5d --- /dev/null +++ b/example/cons.scm @@ -0,0 +1 @@ +(prim:write (prim:cons 4 5)) diff --git a/example/cons.ssa b/example/cons.ssa new file mode 100644 index 0000000..f10a040 --- /dev/null +++ b/example/cons.ssa @@ -0,0 +1,10 @@ +export +function w $main () { +@start + %x0 =l call $GC_malloc (l 16) + %.2 =l add %x0, 8 + storel 18, %x0 + storel 22, %.2 + %x1 =l call $scm_write (l %x0) + ret %x1 +} \ No newline at end of file