aboutsummaryrefslogtreecommitdiff
path: root/base/runtime
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2024-08-18 17:09:57 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2024-08-18 17:09:57 +0200
commitb2e64b7ce043e2045551d43400a62a7897c1c430 (patch)
treed79ab77bd5c1270d9baf156ab4afc8943ecf679c /base/runtime
parentf49ebae9562257effe014e3c175496915041d5f2 (diff)
implement lshrti3 on wasm
Diffstat (limited to 'base/runtime')
-rw-r--r--base/runtime/procs_wasm.odin21
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
+}