authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-28 04:28:42-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-28 04:28:42-04:00
logb8ed0cb3741533e036ee05faa165d2f0c49064f4
treeb49d168bb11b5fe40748a38cb758ddf6e68d7e04
parentd7a539906d2dd49872abb161f3d3364c9641ccd2

remove workaround for LLVM not respecting "nobuiltin"

now that we depend on LLVM 5.0.0 we can remove the workaround. closes #393

38 files changed, 51 insertions(+), 163 deletions(-)

std/math/acos.zig+3-6
......@@ -5,10 +5,7 @@
55const math = @import("index.zig");
66const assert = @import("../debug.zig").assert;
77
8pub const acos = acos_workaround;
9
10// TODO issue #393
11pub fn acos_workaround(x: var) -> @typeOf(x) {
8pub fn acos(x: var) -> @typeOf(x) {
129 const T = @typeOf(x);
1310 switch (T) {
1411 f32 => @inlineCall(acos32, x),
......@@ -145,8 +142,8 @@ fn acos64(x: f64) -> f64 {
145142}
146143
147144test "math.acos" {
148 assert(acos_workaround(f32(0.0)) == acos32(0.0));
149 assert(acos_workaround(f64(0.0)) == acos64(0.0));
145 assert(acos(f32(0.0)) == acos32(0.0));
146 assert(acos(f64(0.0)) == acos64(0.0));
150147}
151148
152149test "math.acos32" {
std/math/acosh.zig+3-6
......@@ -6,10 +6,7 @@
66const math = @import("index.zig");
77const assert = @import("../debug.zig").assert;
88
9pub const acosh = acosh_workaround;
10
11// TODO issue #393
12pub fn acosh_workaround(x: var) -> @typeOf(x) {
9pub fn acosh(x: var) -> @typeOf(x) {
1310 const T = @typeOf(x);
1411 switch (T) {
1512 f32 => @inlineCall(acosh32, x),
......@@ -56,8 +53,8 @@ fn acosh64(x: f64) -> f64 {
5653}
5754
5855test "math.acosh" {
59 assert(acosh_workaround(f32(1.5)) == acosh32(1.5));
60 assert(acosh_workaround(f64(1.5)) == acosh64(1.5));
56 assert(acosh(f32(1.5)) == acosh32(1.5));
57 assert(acosh(f64(1.5)) == acosh64(1.5));
6158}
6259
6360test "math.acosh32" {
std/math/asin.zig+3-6
......@@ -6,10 +6,7 @@
66const math = @import("index.zig");
77const assert = @import("../debug.zig").assert;
88
9pub const asin = asin_workaround;
10
11// TODO issue #393
12pub fn asin_workaround(x: var) -> @typeOf(x) {
9pub fn asin(x: var) -> @typeOf(x) {
1310 const T = @typeOf(x);
1411 switch (T) {
1512 f32 => @inlineCall(asin32, x),
......@@ -138,8 +135,8 @@ fn asin64(x: f64) -> f64 {
138135}
139136
140137test "math.asin" {
141 assert(asin_workaround(f32(0.0)) == asin32(0.0));
142 assert(asin_workaround(f64(0.0)) == asin64(0.0));
138 assert(asin(f32(0.0)) == asin32(0.0));
139 assert(asin(f64(0.0)) == asin64(0.0));
143140}
144141
145142test "math.asin32" {
std/math/asinh.zig+3-6
......@@ -7,10 +7,7 @@
77const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99
10pub const asinh = asinh_workaround;
11
12// TODO issue #393
13pub fn asinh_workaround(x: var) -> @typeOf(x) {
10pub fn asinh(x: var) -> @typeOf(x) {
1411 const T = @typeOf(x);
1512 switch (T) {
1613 f32 => @inlineCall(asinh32, x),
......@@ -84,8 +81,8 @@ fn asinh64(x: f64) -> f64 {
8481}
8582
8683test "math.asinh" {
87 assert(asinh_workaround(f32(0.0)) == asinh32(0.0));
88 assert(asinh_workaround(f64(0.0)) == asinh64(0.0));
84 assert(asinh(f32(0.0)) == asinh32(0.0));
85 assert(asinh(f64(0.0)) == asinh64(0.0));
8986}
9087
9188test "math.asinh32" {
std/math/atan.zig+3-6
......@@ -6,10 +6,7 @@
66const math = @import("index.zig");
77const assert = @import("../debug.zig").assert;
88
9// TODO issue #393
10pub const atan = atan_workaround;
11
12pub fn atan_workaround(x: var) -> @typeOf(x) {
9pub fn atan(x: var) -> @typeOf(x) {
1310 const T = @typeOf(x);
1411 switch (T) {
1512 f32 => @inlineCall(atan32, x),
......@@ -210,8 +207,8 @@ fn atan64(x_: f64) -> f64 {
210207}
211208
212209test "math.atan" {
213 assert(atan_workaround(f32(0.2)) == atan32(0.2));
214 assert(atan_workaround(f64(0.2)) == atan64(0.2));
210 assert(atan(f32(0.2)) == atan32(0.2));
211 assert(atan(f64(0.2)) == atan64(0.2));
215212}
216213
217214test "math.atan32" {
std/math/atan2.zig+3-6
......@@ -21,10 +21,7 @@
2121const math = @import("index.zig");
2222const assert = @import("../debug.zig").assert;
2323
24pub const atan2 = atan2_workaround;
25
26// TODO issue #393
27fn atan2_workaround(comptime T: type, x: T, y: T) -> T {
24fn atan2(comptime T: type, x: T, y: T) -> T {
2825 switch (T) {
2926 f32 => @inlineCall(atan2_32, x, y),
3027 f64 => @inlineCall(atan2_64, x, y),
......@@ -208,8 +205,8 @@ fn atan2_64(y: f64, x: f64) -> f64 {
208205}
209206
210207test "math.atan2" {
211 assert(atan2_workaround(f32, 0.2, 0.21) == atan2_32(0.2, 0.21));
212 assert(atan2_workaround(f64, 0.2, 0.21) == atan2_64(0.2, 0.21));
208 assert(atan2(f32, 0.2, 0.21) == atan2_32(0.2, 0.21));
209 assert(atan2(f64, 0.2, 0.21) == atan2_64(0.2, 0.21));
213210}
214211
215212test "math.atan2_32" {
std/math/atanh.zig+1-4
......@@ -7,10 +7,7 @@
77const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99
10// TODO issue #393
11pub const atanh = atanh_workaround;
12
13pub fn atanh_workaround(x: var) -> @typeOf(x) {
10pub fn atanh(x: var) -> @typeOf(x) {
1411 const T = @typeOf(x);
1512 switch (T) {
1613 f32 => @inlineCall(atanh_32, x),
std/math/cbrt.zig+1-4
......@@ -7,10 +7,7 @@
77const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99
10// TODO issue #393
11pub const cbrt = cbrt_workaround;
12
13pub fn cbrt_workaround(x: var) -> @typeOf(x) {
10pub fn cbrt(x: var) -> @typeOf(x) {
1411 const T = @typeOf(x);
1512 switch (T) {
1613 f32 => @inlineCall(cbrt32, x),
std/math/ceil.zig+1-4
......@@ -8,10 +8,7 @@ const builtin = @import("builtin");
88const math = @import("index.zig");
99const assert = @import("../debug.zig").assert;
1010
11// TODO issue #393
12pub const ceil = ceil_workaround;
13
14pub fn ceil_workaround(x: var) -> @typeOf(x) {
11pub fn ceil(x: var) -> @typeOf(x) {
1512 const T = @typeOf(x);
1613 switch (T) {
1714 f32 => @inlineCall(ceil32, x),
std/math/copysign.zig+1-4
......@@ -1,10 +1,7 @@
11const math = @import("index.zig");
22const assert = @import("../debug.zig").assert;
33
4// TODO issue #393
5pub const copysign = copysign_workaround;
6
7pub fn copysign_workaround(comptime T: type, x: T, y: T) -> T {
4pub fn copysign(comptime T: type, x: T, y: T) -> T {
85 switch (T) {
96 f32 => @inlineCall(copysign32, x, y),
107 f64 => @inlineCall(copysign64, x, y),
std/math/cos.zig+1-4
......@@ -6,10 +6,7 @@
66const math = @import("index.zig");
77const assert = @import("../debug.zig").assert;
88
9// TODO issue #393
10pub const cos = cos_workaround;
11
12pub fn cos_workaround(x: var) -> @typeOf(x) {
9pub fn cos(x: var) -> @typeOf(x) {
1310 const T = @typeOf(x);
1411 switch (T) {
1512 f32 => @inlineCall(cos32, x),
std/math/cosh.zig+1-4
......@@ -8,10 +8,7 @@ const math = @import("index.zig");
88const expo2 = @import("expo2.zig").expo2;
99const assert = @import("../debug.zig").assert;
1010
11// TODO issue #393
12pub const cosh = cosh_workaround;
13
14pub fn cosh_workaround(x: var) -> @typeOf(x) {
11pub fn cosh(x: var) -> @typeOf(x) {
1512 const T = @typeOf(x);
1613 switch (T) {
1714 f32 => @inlineCall(cosh32, x),
std/math/exp.zig+1-4
......@@ -6,10 +6,7 @@
66const math = @import("index.zig");
77const assert = @import("../debug.zig").assert;
88
9// TODO issue #393
10pub const exp = exp_workaround;
11
12pub fn exp_workaround(x: var) -> @typeOf(x) {
9pub fn exp(x: var) -> @typeOf(x) {
1310 const T = @typeOf(x);
1411 switch (T) {
1512 f32 => @inlineCall(exp32, x),
std/math/exp2.zig+1-4
......@@ -6,10 +6,7 @@
66const math = @import("index.zig");
77const assert = @import("../debug.zig").assert;
88
9// TODO issue #393
10pub const exp2 = exp2_workaround;
11
12pub fn exp2_workaround(x: var) -> @typeOf(x) {
9pub fn exp2(x: var) -> @typeOf(x) {
1310 const T = @typeOf(x);
1411 switch (T) {
1512 f32 => @inlineCall(exp2_32, x),
std/math/expm1.zig+1-4
......@@ -7,10 +7,7 @@
77const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99
10// TODO issue #393
11pub const expm1 = expm1_workaround;
12
13pub fn expm1_workaround(x: var) -> @typeOf(x) {
10pub fn expm1(x: var) -> @typeOf(x) {
1411 const T = @typeOf(x);
1512 switch (T) {
1613 f32 => @inlineCall(expm1_32, x),
std/math/fabs.zig+1-4
......@@ -6,10 +6,7 @@
66const math = @import("index.zig");
77const assert = @import("../debug.zig").assert;
88
9// TODO issue #393
10pub const fabs = fabs_workaround;
11
12pub fn fabs_workaround(x: var) -> @typeOf(x) {
9pub fn fabs(x: var) -> @typeOf(x) {
1310 const T = @typeOf(x);
1411 switch (T) {
1512 f32 => @inlineCall(fabs32, x),
std/math/floor.zig+1-4
......@@ -8,10 +8,7 @@ const builtin = @import("builtin");
88const assert = @import("../debug.zig").assert;
99const math = @import("index.zig");
1010
11// TODO issue #393
12pub const floor = floor_workaround;
13
14pub fn floor_workaround(x: var) -> @typeOf(x) {
11pub fn floor(x: var) -> @typeOf(x) {
1512 const T = @typeOf(x);
1613 switch (T) {
1714 f32 => @inlineCall(floor32, x),
std/math/fma.zig+1-4
......@@ -1,10 +1,7 @@
11const math = @import("index.zig");
22const assert = @import("../debug.zig").assert;
33
4// TODO issue #393
5pub const fma = fma_workaround;
6
7pub fn fma_workaround(comptime T: type, x: T, y: T, z: T) -> T {
4pub fn fma(comptime T: type, x: T, y: T, z: T) -> T {
85 switch (T) {
96 f32 => @inlineCall(fma32, x, y, z),
107 f64 => @inlineCall(fma64, x, y ,z),
std/math/frexp.zig+1-4
......@@ -7,9 +7,6 @@
77const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99
10// TODO issue #393
11pub const frexp = frexp_workaround;
12
1310fn frexp_result(comptime T: type) -> type {
1411 struct {
1512 significand: T,
......@@ -19,7 +16,7 @@ fn frexp_result(comptime T: type) -> type {
1916pub const frexp32_result = frexp_result(f32);
2017pub const frexp64_result = frexp_result(f64);
2118
22pub fn frexp_workaround(x: var) -> frexp_result(@typeOf(x)) {
19pub fn frexp(x: var) -> frexp_result(@typeOf(x)) {
2320 const T = @typeOf(x);
2421 switch (T) {
2522 f32 => @inlineCall(frexp32, x),
std/math/hypot.zig+1-4
......@@ -8,10 +8,7 @@
88const math = @import("index.zig");
99const assert = @import("../debug.zig").assert;
1010
11// TODO issue #393
12pub const hypot = hypot_workaround;
13
14pub fn hypot_workaround(comptime T: type, x: T, y: T) -> T {
11pub fn hypot(comptime T: type, x: T, y: T) -> T {
1512 switch (T) {
1613 f32 => @inlineCall(hypot32, x, y),
1714 f64 => @inlineCall(hypot64, x, y),
std/math/ilogb.zig+1-4
......@@ -7,10 +7,7 @@
77const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99
10// TODO issue #393
11pub const ilogb = ilogb_workaround;
12
13pub fn ilogb_workaround(x: var) -> i32 {
10pub fn ilogb(x: var) -> i32 {
1411 const T = @typeOf(x);
1512 switch (T) {
1613 f32 => @inlineCall(ilogb32, x),
std/math/ln.zig+1-3
......@@ -10,9 +10,7 @@ const assert = @import("../debug.zig").assert;
1010const builtin = @import("builtin");
1111const TypeId = builtin.TypeId;
1212
13pub const ln = ln_workaround;
14
15fn ln_workaround(x: var) -> @typeOf(x) {
13pub fn ln(x: var) -> @typeOf(x) {
1614 const T = @typeOf(x);
1715 switch (@typeId(T)) {
1816 TypeId.FloatLiteral => {
std/math/log.zig+1-4
......@@ -3,10 +3,7 @@ const builtin = @import("builtin");
33const TypeId = builtin.TypeId;
44const assert = @import("../debug.zig").assert;
55
6// TODO issue #393
7pub const log = log_workaround;
8
9fn log_workaround(comptime T: type, base: T, x: T) -> T {
6pub fn log(comptime T: type, base: T, x: T) -> T {
107 if (base == 2) {
118 return math.log2(x);
129 } else if (base == 10) {
std/math/log10.zig+1-4
......@@ -10,10 +10,7 @@ const assert = @import("../debug.zig").assert;
1010const builtin = @import("builtin");
1111const TypeId = builtin.TypeId;
1212
13// TODO issue #393
14pub const log10 = log10_workaround;
15
16fn log10_workaround(x: var) -> @typeOf(x) {
13pub fn log10(x: var) -> @typeOf(x) {
1714 const T = @typeOf(x);
1815 switch (@typeId(T)) {
1916 TypeId.FloatLiteral => {
std/math/log1p.zig+1-4
......@@ -9,10 +9,7 @@
99const math = @import("index.zig");
1010const assert = @import("../debug.zig").assert;
1111
12// TODO issue #393
13pub const log1p = log1p_workaround;
14
15pub fn log1p_workaround(x: var) -> @typeOf(x) {
12pub fn log1p(x: var) -> @typeOf(x) {
1613 const T = @typeOf(x);
1714 switch (T) {
1815 f32 => @inlineCall(log1p_32, x),
std/math/log2.zig+1-4
......@@ -10,10 +10,7 @@ const assert = @import("../debug.zig").assert;
1010const builtin = @import("builtin");
1111const TypeId = builtin.TypeId;
1212
13// TODO issue #393
14pub const log2 = log2_workaround;
15
16fn log2_workaround(x: var) -> @typeOf(x) {
13pub fn log2(x: var) -> @typeOf(x) {
1714 const T = @typeOf(x);
1815 switch (@typeId(T)) {
1916 TypeId.FloatLiteral => {
std/math/modf.zig+1-4
......@@ -6,9 +6,6 @@
66const math = @import("index.zig");
77const assert = @import("../debug.zig").assert;
88
9// TODO issue #393
10pub const modf = modf_workaround;
11
129fn modf_result(comptime T: type) -> type {
1310 struct {
1411 fpart: T,
......@@ -18,7 +15,7 @@ fn modf_result(comptime T: type) -> type {
1815pub const modf32_result = modf_result(f32);
1916pub const modf64_result = modf_result(f64);
2017
21pub fn modf_workaround(x: var) -> modf_result(@typeOf(x)) {
18pub fn modf(x: var) -> modf_result(@typeOf(x)) {
2219 const T = @typeOf(x);
2320 switch (T) {
2421 f32 => @inlineCall(modf32, x),
std/math/nan.zig+2-6
......@@ -1,8 +1,6 @@
11const math = @import("index.zig");
22
3pub const nan = nan_workaround;
4
5pub fn nan_workaround(comptime T: type) -> T {
3pub fn nan(comptime T: type) -> T {
64 switch (T) {
75 f32 => @bitCast(f32, math.nan_u32),
86 f64 => @bitCast(f64, math.nan_u64),
......@@ -10,11 +8,9 @@ pub fn nan_workaround(comptime T: type) -> T {
108 }
119}
1210
13pub const snan = snan_workaround;
14
1511// Note: A signalling nan is identical to a standard right now by may have a different bit
1612// representation in the future when required.
17pub fn snan_workaround(comptime T: type) -> T {
13pub fn snan(comptime T: type) -> T {
1814 switch (T) {
1915 f32 => @bitCast(f32, math.nan_u32),
2016 f64 => @bitCast(f64, math.nan_u64),
std/math/pow.zig+1-4
......@@ -24,11 +24,8 @@
2424const math = @import("index.zig");
2525const assert = @import("../debug.zig").assert;
2626
27// TODO issue #393
28pub const pow = pow_workaround;
29
3027// This implementation is taken from the go stlib, musl is a bit more complex.
31pub fn pow_workaround(comptime T: type, x: T, y: T) -> T {
28pub fn pow(comptime T: type, x: T, y: T) -> T {
3229
3330 @setFloatMode(this, @import("builtin").FloatMode.Strict);
3431
std/math/round.zig+1-4
......@@ -8,10 +8,7 @@ const builtin = @import("builtin");
88const assert = @import("../debug.zig").assert;
99const math = @import("index.zig");
1010
11// TODO issue #393
12pub const round = round_workaround;
13
14pub fn round_workaround(x: var) -> @typeOf(x) {
11pub fn round(x: var) -> @typeOf(x) {
1512 const T = @typeOf(x);
1613 switch (T) {
1714 f32 => @inlineCall(round32, x),
std/math/scalbn.zig+1-4
......@@ -1,10 +1,7 @@
11const math = @import("index.zig");
22const assert = @import("../debug.zig").assert;
33
4// TODO issue #393
5pub const scalbn = scalbn_workaround;
6
7pub fn scalbn_workaround(x: var, n: i32) -> @typeOf(x) {
4pub fn scalbn(x: var, n: i32) -> @typeOf(x) {
85 const T = @typeOf(x);
96 switch (T) {
107 f32 => @inlineCall(scalbn32, x, n),
std/math/signbit.zig+1-4
......@@ -1,10 +1,7 @@
11const math = @import("index.zig");
22const assert = @import("../debug.zig").assert;
33
4// TODO issue #393
5pub const signbit = signbit_workaround;
6
7pub fn signbit_workaround(x: var) -> bool {
4pub fn signbit(x: var) -> bool {
85 const T = @typeOf(x);
96 switch (T) {
107 f32 => @inlineCall(signbit32, x),
std/math/sin.zig+1-4
......@@ -7,10 +7,7 @@
77const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99
10// TODO issue #393
11pub const sin = sin_workaround;
12
13pub fn sin_workaround(x: var) -> @typeOf(x) {
10pub fn sin(x: var) -> @typeOf(x) {
1411 const T = @typeOf(x);
1512 switch (T) {
1613 f32 => @inlineCall(sin32, x),
std/math/sinh.zig+1-4
......@@ -8,10 +8,7 @@ const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99const expo2 = @import("expo2.zig").expo2;
1010
11// TODO issue #393
12pub const sinh = sinh_workaround;
13
14pub fn sinh_workaround(x: var) -> @typeOf(x) {
11pub fn sinh(x: var) -> @typeOf(x) {
1512 const T = @typeOf(x);
1613 switch (T) {
1714 f32 => @inlineCall(sinh32, x),
std/math/sqrt.zig+1-4
......@@ -8,10 +8,7 @@
88const math = @import("index.zig");
99const assert = @import("../debug.zig").assert;
1010
11// TODO issue #393
12pub const sqrt = sqrt_workaround;
13
14pub fn sqrt_workaround(x: var) -> @typeOf(x) {
11pub fn sqrt(x: var) -> @typeOf(x) {
1512 const T = @typeOf(x);
1613 switch (T) {
1714 f32 => @inlineCall(sqrt32, x),
std/math/tan.zig+1-3
......@@ -7,9 +7,7 @@
77const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99
10pub const tan = tan_workaround;
11
12pub fn tan_workaround(x: var) -> @typeOf(x) {
10pub fn tan(x: var) -> @typeOf(x) {
1311 const T = @typeOf(x);
1412 switch (T) {
1513 f32 => @inlineCall(tan32, x),
std/math/tanh.zig+1-4
......@@ -8,10 +8,7 @@ const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99const expo2 = @import("expo2.zig").expo2;
1010
11// TODO issue #393
12pub const tanh = tanh_workaround;
13
14pub fn tanh_workaround(x: var) -> @typeOf(x) {
11pub fn tanh(x: var) -> @typeOf(x) {
1512 const T = @typeOf(x);
1613 switch (T) {
1714 f32 => @inlineCall(tanh32, x),
std/math/trunc.zig+1-3
......@@ -7,9 +7,7 @@
77const math = @import("index.zig");
88const assert = @import("../debug.zig").assert;
99
10pub const trunc = trunc_workaround;
11
12pub fn trunc_workaround(x: var) -> @typeOf(x) {
10pub fn trunc(x: var) -> @typeOf(x) {
1311 const T = @typeOf(x);
1412 switch (T) {
1513 f32 => @inlineCall(trunc32, x),