diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-18 17:09:57 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-18 17:09:57 +0200 |
| commit | b2e64b7ce043e2045551d43400a62a7897c1c430 (patch) | |
| tree | d79ab77bd5c1270d9baf156ab4afc8943ecf679c /base | |
| parent | f49ebae9562257effe014e3c175496915041d5f2 (diff) | |
implement lshrti3 on wasm
Diffstat (limited to 'base')
| -rw-r--r-- | base/runtime/procs_wasm.odin | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/base/runtime/procs_wasm.odin b/base/runtime/procs_wasm.odin index 7501df460..9f2e9befc 100644 --- a/base/runtime/procs_wasm.odin +++ b/base/runtime/procs_wasm.odin @@ -52,3 +52,24 @@ udivti3 :: proc "c" (la, ha, lb, hb: u64) -> u128 { b.lo, b.hi = lb, hb return udivmodti4(a.all, b.all, nil) } + +@(link_name="__lshrti3", linkage="strong") +__lshrti3 :: proc "c" (la, ha: u64, b: u32) -> i128 { + bits :: size_of(u32)*8 + + input, result: ti_int + input.lo = la + input.hi = ha + + if b & bits != 0 { + result.hi = 0 + result.lo = input.hi >> (b - bits) + } else if b == 0 { + return input.all + } else { + result.hi = input.hi >> b + result.lo = (input.hi << (bits - b)) | (input.lo >> b) + } + + return result.all +} |