Reorganize runtimes
This commit is contained in:
parent
76eb363d35
commit
75582f40bf
@ -75,12 +75,6 @@ do
|
|||||||
return (to_signed(math_floor(lhs / rhs)))
|
return (to_signed(math_floor(lhs / rhs)))
|
||||||
end
|
end
|
||||||
|
|
||||||
function div.u64(lhs, rhs)
|
|
||||||
assert(rhs ~= 0, "division by zero")
|
|
||||||
|
|
||||||
return (i64(u64(lhs) / u64(rhs)))
|
|
||||||
end
|
|
||||||
|
|
||||||
function rem.u32(lhs, rhs)
|
function rem.u32(lhs, rhs)
|
||||||
assert(rhs ~= 0, "division by zero")
|
assert(rhs ~= 0, "division by zero")
|
||||||
|
|
||||||
@ -90,6 +84,12 @@ do
|
|||||||
return (to_signed(lhs % rhs))
|
return (to_signed(lhs % rhs))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function div.u64(lhs, rhs)
|
||||||
|
assert(rhs ~= 0, "division by zero")
|
||||||
|
|
||||||
|
return (i64(u64(lhs) / u64(rhs)))
|
||||||
|
end
|
||||||
|
|
||||||
function rem.u64(lhs, rhs)
|
function rem.u64(lhs, rhs)
|
||||||
assert(rhs ~= 0, "division by zero")
|
assert(rhs ~= 0, "division by zero")
|
||||||
|
|
||||||
@ -223,38 +223,38 @@ do
|
|||||||
local ge = {}
|
local ge = {}
|
||||||
local gt = {}
|
local gt = {}
|
||||||
|
|
||||||
function ge.u32(lhs, rhs)
|
|
||||||
return u32(lhs) >= u32(rhs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ge.u64(lhs, rhs)
|
|
||||||
return u64(lhs) >= u64(rhs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function gt.u32(lhs, rhs)
|
|
||||||
return u32(lhs) > u32(rhs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function gt.u64(lhs, rhs)
|
|
||||||
return u64(lhs) > u64(rhs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function le.u32(lhs, rhs)
|
function le.u32(lhs, rhs)
|
||||||
return u32(lhs) <= u32(rhs)
|
return u32(lhs) <= u32(rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
function le.u64(lhs, rhs)
|
|
||||||
return u64(lhs) <= u64(rhs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function lt.u32(lhs, rhs)
|
function lt.u32(lhs, rhs)
|
||||||
return u32(lhs) < u32(rhs)
|
return u32(lhs) < u32(rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ge.u32(lhs, rhs)
|
||||||
|
return u32(lhs) >= u32(rhs)
|
||||||
|
end
|
||||||
|
|
||||||
|
function gt.u32(lhs, rhs)
|
||||||
|
return u32(lhs) > u32(rhs)
|
||||||
|
end
|
||||||
|
|
||||||
|
function le.u64(lhs, rhs)
|
||||||
|
return u64(lhs) <= u64(rhs)
|
||||||
|
end
|
||||||
|
|
||||||
function lt.u64(lhs, rhs)
|
function lt.u64(lhs, rhs)
|
||||||
return u64(lhs) < u64(rhs)
|
return u64(lhs) < u64(rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ge.u64(lhs, rhs)
|
||||||
|
return u64(lhs) >= u64(rhs)
|
||||||
|
end
|
||||||
|
|
||||||
|
function gt.u64(lhs, rhs)
|
||||||
|
return u64(lhs) > u64(rhs)
|
||||||
|
end
|
||||||
|
|
||||||
module.le = le
|
module.le = le
|
||||||
module.lt = lt
|
module.lt = lt
|
||||||
module.ge = ge
|
module.ge = ge
|
||||||
@ -276,21 +276,19 @@ do
|
|||||||
local rotl = {}
|
local rotl = {}
|
||||||
local rotr = {}
|
local rotr = {}
|
||||||
|
|
||||||
rotl.i32 = bit.rol
|
|
||||||
rotl.i64 = bit.rol
|
|
||||||
|
|
||||||
rotr.i32 = bit.ror
|
|
||||||
rotr.i64 = bit.ror
|
|
||||||
|
|
||||||
shl.i32 = bit.lshift
|
shl.i32 = bit.lshift
|
||||||
shl.i64 = bit.lshift
|
|
||||||
shl.u32 = bit.lshift
|
shl.u32 = bit.lshift
|
||||||
shl.u64 = bit.lshift
|
|
||||||
|
|
||||||
shr.i32 = bit.arshift
|
shr.i32 = bit.arshift
|
||||||
shr.i64 = bit.arshift
|
|
||||||
shr.u32 = bit.rshift
|
shr.u32 = bit.rshift
|
||||||
|
rotl.i32 = bit.rol
|
||||||
|
rotr.i32 = bit.ror
|
||||||
|
|
||||||
|
shl.i64 = bit.lshift
|
||||||
|
shl.u64 = bit.lshift
|
||||||
|
shr.i64 = bit.arshift
|
||||||
shr.u64 = bit.rshift
|
shr.u64 = bit.rshift
|
||||||
|
rotl.i64 = bit.rol
|
||||||
|
rotr.i64 = bit.ror
|
||||||
|
|
||||||
module.shl = shl
|
module.shl = shl
|
||||||
module.shr = shr
|
module.shr = shr
|
||||||
|
@ -67,14 +67,10 @@ do
|
|||||||
return to_u32(a + b)
|
return to_u32(a + b)
|
||||||
end
|
end
|
||||||
|
|
||||||
add.i64 = I64.add
|
|
||||||
|
|
||||||
function sub.i32(a, b)
|
function sub.i32(a, b)
|
||||||
return to_u32(a - b)
|
return to_u32(a - b)
|
||||||
end
|
end
|
||||||
|
|
||||||
sub.i64 = I64.subtract
|
|
||||||
|
|
||||||
function mul.i32(a, b)
|
function mul.i32(a, b)
|
||||||
if (a + b) < BIT_SET_27 then
|
if (a + b) < BIT_SET_27 then
|
||||||
return to_u32(a * b)
|
return to_u32(a * b)
|
||||||
@ -91,8 +87,6 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mul.i64 = I64.multiply
|
|
||||||
|
|
||||||
function div.i32(lhs, rhs)
|
function div.i32(lhs, rhs)
|
||||||
assert(rhs ~= 0, "division by zero")
|
assert(rhs ~= 0, "division by zero")
|
||||||
|
|
||||||
@ -102,16 +96,12 @@ do
|
|||||||
return to_u32(lhs / rhs)
|
return to_u32(lhs / rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
div.i64 = I64.divide_signed
|
|
||||||
|
|
||||||
function div.u32(lhs, rhs)
|
function div.u32(lhs, rhs)
|
||||||
assert(rhs ~= 0, "division by zero")
|
assert(rhs ~= 0, "division by zero")
|
||||||
|
|
||||||
return to_u32(lhs / rhs)
|
return to_u32(lhs / rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
div.u64 = I64.divide_unsigned
|
|
||||||
|
|
||||||
function rem.i32(lhs, rhs)
|
function rem.i32(lhs, rhs)
|
||||||
assert(rhs ~= 0, "division by zero")
|
assert(rhs ~= 0, "division by zero")
|
||||||
|
|
||||||
@ -121,6 +111,12 @@ do
|
|||||||
return to_u32(math_fmod(lhs, rhs))
|
return to_u32(math_fmod(lhs, rhs))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add.i64 = I64.add
|
||||||
|
sub.i64 = I64.subtract
|
||||||
|
mul.i64 = I64.multiply
|
||||||
|
div.i64 = I64.divide_signed
|
||||||
|
div.u64 = I64.divide_unsigned
|
||||||
|
|
||||||
function neg.f32(num)
|
function neg.f32(num)
|
||||||
return -num
|
return -num
|
||||||
end
|
end
|
||||||
@ -213,38 +209,31 @@ do
|
|||||||
local gt = {}
|
local gt = {}
|
||||||
|
|
||||||
local num_is_equal = I64.is_equal
|
local num_is_equal = I64.is_equal
|
||||||
local num_is_greater_signed = I64.is_greater_signed
|
|
||||||
local num_is_greater_unsigned = I64.is_greater_unsigned
|
|
||||||
local num_is_less_signed = I64.is_less_signed
|
local num_is_less_signed = I64.is_less_signed
|
||||||
local num_is_less_unsigned = I64.is_less_unsigned
|
local num_is_less_unsigned = I64.is_less_unsigned
|
||||||
|
local num_is_greater_signed = I64.is_greater_signed
|
||||||
|
local num_is_greater_unsigned = I64.is_greater_unsigned
|
||||||
|
|
||||||
eq.i64 = num_is_equal
|
function le.i32(lhs, rhs)
|
||||||
|
return to_i32(lhs) <= to_i32(rhs)
|
||||||
|
end
|
||||||
|
|
||||||
function ne.i64(lhs, rhs)
|
function lt.i32(lhs, rhs)
|
||||||
return not num_is_equal(lhs, rhs)
|
return to_i32(lhs) < to_i32(rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ge.i32(lhs, rhs)
|
function ge.i32(lhs, rhs)
|
||||||
return to_i32(lhs) >= to_i32(rhs)
|
return to_i32(lhs) >= to_i32(rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ge.i64(lhs, rhs)
|
|
||||||
return num_is_greater_signed(lhs, rhs) or num_is_equal(lhs, rhs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ge.u64(lhs, rhs)
|
|
||||||
return num_is_greater_unsigned(lhs, rhs) or num_is_equal(lhs, rhs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function gt.i32(lhs, rhs)
|
function gt.i32(lhs, rhs)
|
||||||
return to_i32(lhs) > to_i32(rhs)
|
return to_i32(lhs) > to_i32(rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
gt.i64 = num_is_greater_signed
|
eq.i64 = num_is_equal
|
||||||
gt.u64 = num_is_greater_unsigned
|
|
||||||
|
|
||||||
function le.i32(lhs, rhs)
|
function ne.i64(lhs, rhs)
|
||||||
return to_i32(lhs) <= to_i32(rhs)
|
return not num_is_equal(lhs, rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
function le.i64(lhs, rhs)
|
function le.i64(lhs, rhs)
|
||||||
@ -255,13 +244,20 @@ do
|
|||||||
return num_is_less_unsigned(lhs, rhs) or num_is_equal(lhs, rhs)
|
return num_is_less_unsigned(lhs, rhs) or num_is_equal(lhs, rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
function lt.i32(lhs, rhs)
|
|
||||||
return to_i32(lhs) < to_i32(rhs)
|
|
||||||
end
|
|
||||||
|
|
||||||
lt.i64 = num_is_less_signed
|
lt.i64 = num_is_less_signed
|
||||||
lt.u64 = num_is_less_unsigned
|
lt.u64 = num_is_less_unsigned
|
||||||
|
|
||||||
|
function ge.i64(lhs, rhs)
|
||||||
|
return num_is_greater_signed(lhs, rhs) or num_is_equal(lhs, rhs)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ge.u64(lhs, rhs)
|
||||||
|
return num_is_greater_unsigned(lhs, rhs) or num_is_equal(lhs, rhs)
|
||||||
|
end
|
||||||
|
|
||||||
|
gt.i64 = num_is_greater_signed
|
||||||
|
gt.u64 = num_is_greater_unsigned
|
||||||
|
|
||||||
module.eq = eq
|
module.eq = eq
|
||||||
module.ne = ne
|
module.ne = ne
|
||||||
module.le = le
|
module.le = le
|
||||||
@ -276,14 +272,12 @@ do
|
|||||||
local bxor = {}
|
local bxor = {}
|
||||||
local bnot = {}
|
local bnot = {}
|
||||||
|
|
||||||
band.i64 = I64.bit_and
|
|
||||||
|
|
||||||
bnot.i32 = bit32.bnot
|
bnot.i32 = bit32.bnot
|
||||||
bnot.i64 = I64.bit_not
|
|
||||||
|
|
||||||
|
band.i64 = I64.bit_and
|
||||||
bor.i64 = I64.bit_or
|
bor.i64 = I64.bit_or
|
||||||
|
|
||||||
bxor.i64 = I64.bit_xor
|
bxor.i64 = I64.bit_xor
|
||||||
|
bnot.i64 = I64.bit_not
|
||||||
|
|
||||||
module.band = band
|
module.band = band
|
||||||
module.bor = bor
|
module.bor = bor
|
||||||
@ -301,6 +295,18 @@ do
|
|||||||
local bit_lrotate = bit32.lrotate
|
local bit_lrotate = bit32.lrotate
|
||||||
local bit_rrotate = bit32.rrotate
|
local bit_rrotate = bit32.rrotate
|
||||||
|
|
||||||
|
function shl.i32(lhs, rhs)
|
||||||
|
return bit_lshift(lhs, rhs % 32)
|
||||||
|
end
|
||||||
|
|
||||||
|
function shr.u32(lhs, rhs)
|
||||||
|
return bit_rshift(lhs, rhs % 32)
|
||||||
|
end
|
||||||
|
|
||||||
|
function shr.i32(lhs, rhs)
|
||||||
|
return bit_arshift(lhs, rhs % 32)
|
||||||
|
end
|
||||||
|
|
||||||
function rotl.i32(lhs, rhs)
|
function rotl.i32(lhs, rhs)
|
||||||
return bit_lrotate(lhs, rhs % 32)
|
return bit_lrotate(lhs, rhs % 32)
|
||||||
end
|
end
|
||||||
@ -309,22 +315,8 @@ do
|
|||||||
return bit_rrotate(lhs, rhs % 32)
|
return bit_rrotate(lhs, rhs % 32)
|
||||||
end
|
end
|
||||||
|
|
||||||
function shl.i32(lhs, rhs)
|
|
||||||
return bit_lshift(lhs, rhs % 32)
|
|
||||||
end
|
|
||||||
|
|
||||||
shl.i64 = I64.shift_left
|
shl.i64 = I64.shift_left
|
||||||
|
|
||||||
function shr.i32(lhs, rhs)
|
|
||||||
return bit_arshift(lhs, rhs % 32)
|
|
||||||
end
|
|
||||||
|
|
||||||
shr.i64 = I64.shift_right_signed
|
shr.i64 = I64.shift_right_signed
|
||||||
|
|
||||||
function shr.u32(lhs, rhs)
|
|
||||||
return bit_rshift(lhs, rhs % 32)
|
|
||||||
end
|
|
||||||
|
|
||||||
shr.u64 = I64.shift_right_unsigned
|
shr.u64 = I64.shift_right_unsigned
|
||||||
|
|
||||||
module.shl = shl
|
module.shl = shl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user