mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Disable var and const declarations
This commit is contained in:
+25
-25
@@ -1,8 +1,8 @@
|
||||
#shared_global_scope;
|
||||
|
||||
proc __multi3(a, b: u128) -> u128 #cc_c #link_name "__multi3" {
|
||||
const bits_in_dword_2 = size_of(i64) * 4;
|
||||
const lower_mask = u128(~u64(0) >> bits_in_dword_2);
|
||||
bits_in_dword_2 :: size_of(i64) * 4;
|
||||
lower_mask :: u128(~u64(0) >> bits_in_dword_2);
|
||||
|
||||
|
||||
when ODIN_ENDIAN == "bit" {
|
||||
@@ -17,18 +17,18 @@ proc __multi3(a, b: u128) -> u128 #cc_c #link_name "__multi3" {
|
||||
};
|
||||
}
|
||||
|
||||
var r: TWords;
|
||||
var t: u64;
|
||||
r: TWords;
|
||||
t: u64;
|
||||
|
||||
r.lo = u64(a & lower_mask) * u64(b & lower_mask);
|
||||
t = r.lo >> bits_in_dword_2;
|
||||
r.lo = u64(a & lower_mask) * u64(b & lower_mask);
|
||||
t = r.lo >> bits_in_dword_2;
|
||||
r.lo &= u64(lower_mask);
|
||||
t += u64(a >> bits_in_dword_2) * u64(b & lower_mask);
|
||||
t += u64(a >> bits_in_dword_2) * u64(b & lower_mask);
|
||||
r.lo += u64(t & u64(lower_mask)) << bits_in_dword_2;
|
||||
r.hi = t >> bits_in_dword_2;
|
||||
t = r.lo >> bits_in_dword_2;
|
||||
r.hi = t >> bits_in_dword_2;
|
||||
t = r.lo >> bits_in_dword_2;
|
||||
r.lo &= u64(lower_mask);
|
||||
t += u64(b >> bits_in_dword_2) * u64(a & lower_mask);
|
||||
t += u64(b >> bits_in_dword_2) * u64(a & lower_mask);
|
||||
r.lo += u64(t & u64(lower_mask)) << bits_in_dword_2;
|
||||
r.hi += t >> bits_in_dword_2;
|
||||
r.hi += u64(a >> bits_in_dword_2) * u64(b >> bits_in_dword_2);
|
||||
@@ -36,7 +36,7 @@ proc __multi3(a, b: u128) -> u128 #cc_c #link_name "__multi3" {
|
||||
}
|
||||
|
||||
proc __u128_mod(a, b: u128) -> u128 #cc_c #link_name "__umodti3" {
|
||||
var r: u128;
|
||||
r: u128;
|
||||
__u128_quo_mod(a, b, &r);
|
||||
return r;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ proc __u128_quo(a, b: u128) -> u128 #cc_c #link_name "__udivti3" {
|
||||
}
|
||||
|
||||
proc __i128_mod(a, b: i128) -> i128 #cc_c #link_name "__modti3" {
|
||||
var r: i128;
|
||||
r: i128;
|
||||
__i128_quo_mod(a, b, &r);
|
||||
return r;
|
||||
}
|
||||
@@ -56,16 +56,16 @@ proc __i128_quo(a, b: i128) -> i128 #cc_c #link_name "__divti3" {
|
||||
}
|
||||
|
||||
proc __i128_quo_mod(a, b: i128, rem: ^i128) -> (quo: i128) #cc_c #link_name "__divmodti4" {
|
||||
var s: i128;
|
||||
s: i128;
|
||||
s = b >> 127;
|
||||
b = (b~s) - s;
|
||||
s = a >> 127;
|
||||
b = (a~s) - s;
|
||||
|
||||
var uquo: u128;
|
||||
var urem = __u128_quo_mod(transmute(u128, a), transmute(u128, b), &uquo);
|
||||
var iquo = transmute(i128, uquo);
|
||||
var irem = transmute(i128, urem);
|
||||
uquo: u128;
|
||||
urem := __u128_quo_mod(transmute(u128, a), transmute(u128, b), &uquo);
|
||||
iquo := transmute(i128, uquo);
|
||||
irem := transmute(i128, urem);
|
||||
|
||||
iquo = (iquo~s) - s;
|
||||
irem = (irem~s) - s;
|
||||
@@ -75,14 +75,14 @@ proc __i128_quo_mod(a, b: i128, rem: ^i128) -> (quo: i128) #cc_c #link_name "__d
|
||||
|
||||
|
||||
proc __u128_quo_mod(a, b: u128, rem: ^u128) -> (quo: u128) #cc_c #link_name "__udivmodti4" {
|
||||
var alo, ahi = u64(a), u64(a>>64);
|
||||
var blo, bhi = u64(b), u64(b>>64);
|
||||
alo, ahi := u64(a), u64(a>>64);
|
||||
blo, bhi := u64(b), u64(b>>64);
|
||||
if b == 0 {
|
||||
if rem != nil { rem^ = 0; }
|
||||
return u128(alo/blo);
|
||||
}
|
||||
|
||||
var r, d, x, q: u128 = a, b, 1, 0;
|
||||
r, d, x, q: u128 = a, b, 1, 0;
|
||||
|
||||
for r >= d && (d>>127)&1 == 0 {
|
||||
x <<= 1;
|
||||
@@ -106,7 +106,7 @@ proc __u128_quo_mod(a, b: u128, rem: ^u128) -> (quo: u128) #cc_c #link_name "__u
|
||||
proc __f16_to_f32(f: f16) -> f32 #cc_c #no_inline #link_name "__gnu_h2f_ieee" {
|
||||
when true {
|
||||
// Source: https://fgiesen.wordpress.com/2012/03/28/half-to-float-done-quic/
|
||||
const FP32 = raw_union {u: u32, f: f32};
|
||||
FP32 :: raw_union {u: u32, f: f32};
|
||||
|
||||
magic, was_infnan: FP32;
|
||||
magic.u = (254-15) << 23;
|
||||
@@ -130,16 +130,16 @@ proc __f16_to_f32(f: f16) -> f32 #cc_c #no_inline #link_name "__gnu_h2f_ieee" {
|
||||
proc __f32_to_f16(f_: f32) -> f16 #cc_c #no_inline #link_name "__gnu_f2h_ieee" {
|
||||
when false {
|
||||
// Source: https://gist.github.com/rygorous/2156668
|
||||
const FP16 = raw_union {u: u16, f: f16};
|
||||
const FP32 = raw_union {u: u32, f: f32};
|
||||
FP16 :: raw_union {u: u16, f: f16};
|
||||
FP32 :: raw_union {u: u32, f: f32};
|
||||
|
||||
f32infty, f16infty, magic: FP32;
|
||||
f32infty.u = 255<<23;
|
||||
f16infty.u = 31<<23;
|
||||
magic.u = 15<<23;
|
||||
|
||||
const sign_mask = u32(0x80000000);
|
||||
const round_mask = ~u32(0x0fff);
|
||||
sign_mask :: u32(0x80000000);
|
||||
round_mask :: ~u32(0x0fff);
|
||||
|
||||
f := transmute(FP32, f_);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user