Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,17 @@
(module
;; recursive
(func $fac (param f64) (result f64)
get_local 0
f64.const 1
f64.lt
if (result f64)
f64.const 1
else
get_local 0
get_local 0
f64.const 1
f64.sub
call $fac
f64.mul
end)
(export "fac" (func $fac)))

View file

@ -0,0 +1,14 @@
(module
;; recursive, more compact version
(func $fac_f64 (export "fac_f64") (param f64) (result f64)
get_local 0 f64.const 1 f64.lt
if (result f64)
f64.const 1
else
get_local 0
get_local 0 f64.const 1 f64.sub
call $fac_f64
f64.mul
end
)
)

View file

@ -0,0 +1,14 @@
(module
;; recursive, refactored to use s-expressions
(func $fact_f64 (export "fact_f64") (param f64) (result f64)
(if (result f64) (f64.lt (get_local 0) (f64.const 1))
(then f64.const 1)
(else
(f64.mul
(get_local 0)
(call $fact_f64 (f64.sub (get_local 0) (f64.const 1)))
)
)
)
)
)

View file

@ -0,0 +1,14 @@
(module
;; recursive, refactored to use s-expressions and named variables
(func $fact_f64 (export "fact_f64") (param $n f64) (result f64)
(if (result f64) (f64.lt (get_local $n) (f64.const 1))
(then f64.const 1)
(else
(f64.mul
(get_local $n)
(call $fact_f64 (f64.sub (get_local $n) (f64.const 1)))
)
)
)
)
)

View file

@ -0,0 +1,29 @@
(module
;; iterative, generated by C compiler (LLVM) from recursive code!
(func $factorial (export "factorial") (param $p0 i32) (result i32)
(local $l0 i32) (local $l1 i32)
block $B0
get_local $p0
i32.eqz
br_if $B0
i32.const 1
set_local $l0
loop $L1
get_local $p0
get_local $l0
i32.mul
set_local $l0
get_local $p0
i32.const -1
i32.add
tee_local $l1
set_local $p0
get_local $l1
br_if $L1
end
get_local $l0
return
end
i32.const 1
)
)