-
-
Save rhysd/d60105a4a24746cb5deb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module | |
(memory 1) | |
(export "memory" memory) | |
(export "abs" $abs) | |
(export "sqrt2" $sqrt2) | |
(export "sqrt" $sqrt) | |
(func $abs (param $$0 f64) (result f64) | |
(block $label$0 | |
(br_if $label$0 | |
(i32.or | |
(f64.gt | |
(get_local $$0) | |
(f64.const 0) | |
) | |
(f64.ne | |
(get_local $$0) | |
(get_local $$0) | |
) | |
) | |
) | |
(set_local $$0 | |
(f64.neg | |
(get_local $$0) | |
) | |
) | |
) | |
(return | |
(get_local $$0) | |
) | |
) | |
(func $sqrt2 (param $$0 f64) (param $$1 f64) (param $$2 f64) (result f64) | |
(block $label$0 | |
(br_if $label$0 | |
(f64.ge | |
(call $abs | |
(f64.sub | |
(get_local $$0) | |
(get_local $$1) | |
) | |
) | |
(f64.const 1e-05) | |
) | |
) | |
(return | |
(get_local $$1) | |
) | |
) | |
(return | |
(call $sqrt2 | |
(get_local $$1) | |
(f64.add | |
(get_local $$1) | |
(f64.div | |
(f64.sub | |
(f64.mul | |
(get_local $$1) | |
(get_local $$1) | |
) | |
(get_local $$2) | |
) | |
(f64.mul | |
(get_local $$1) | |
(f64.const -2) | |
) | |
) | |
) | |
(get_local $$2) | |
) | |
) | |
) | |
(func $sqrt (param $$0 f64) (result f64) | |
(return | |
(call $sqrt2 | |
(f64.const 0) | |
(get_local $$0) | |
(get_local $$0) | |
) | |
) | |
) | |
) | |
;; METADATA: { "asmConsts": {},"staticBump": 7 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment