authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-07 17:44:20+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-07 13:42:47-05:00
loge81b505960b106a042e4cb890971ba365a5ef180
tree751dc190a6b9c95a9cfd33057657e2a55b94b691
parent4e4ba6c3e1273fda8137f9f7e26325051f92bfa4

Use the correct calling convention for AEABI intrinsics


38 files changed, 194 insertions(+), 156 deletions(-)

lib/std/fmt.zig-24
......@@ -1292,10 +1292,6 @@ test "cstr" {
12921292}
12931293
12941294test "filesize" {
1295 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1296 // TODO https://github.com/ziglang/zig/issues/3289
1297 return error.SkipZigTest;
1298 }
12991295 try testFmt("file size: 63MiB\n", "file size: {Bi}\n", .{@as(usize, 63 * 1024 * 1024)});
13001296 try testFmt("file size: 66.06MB\n", "file size: {B:.2}\n", .{@as(usize, 63 * 1024 * 1024)});
13011297}
......@@ -1330,10 +1326,6 @@ test "enum" {
13301326}
13311327
13321328test "float.scientific" {
1333 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1334 // TODO https://github.com/ziglang/zig/issues/3289
1335 return error.SkipZigTest;
1336 }
13371329 try testFmt("f32: 1.34000003e+00", "f32: {e}", .{@as(f32, 1.34)});
13381330 try testFmt("f32: 1.23400001e+01", "f32: {e}", .{@as(f32, 12.34)});
13391331 try testFmt("f64: -1.234e+11", "f64: {e}", .{@as(f64, -12.34e10)});
......@@ -1341,10 +1333,6 @@ test "float.scientific" {
13411333}
13421334
13431335test "float.scientific.precision" {
1344 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1345 // TODO https://github.com/ziglang/zig/issues/3289
1346 return error.SkipZigTest;
1347 }
13481336 try testFmt("f64: 1.40971e-42", "f64: {e:.5}", .{@as(f64, 1.409706e-42)});
13491337 try testFmt("f64: 1.00000e-09", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 814313563)))});
13501338 try testFmt("f64: 7.81250e-03", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1006632960)))});
......@@ -1354,10 +1342,6 @@ test "float.scientific.precision" {
13541342}
13551343
13561344test "float.special" {
1357 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1358 // TODO https://github.com/ziglang/zig/issues/3289
1359 return error.SkipZigTest;
1360 }
13611345 try testFmt("f64: nan", "f64: {}", .{math.nan_f64});
13621346 // negative nan is not defined by IEE 754,
13631347 // and ARM thus normalizes it to positive nan
......@@ -1369,10 +1353,6 @@ test "float.special" {
13691353}
13701354
13711355test "float.decimal" {
1372 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1373 // TODO https://github.com/ziglang/zig/issues/3289
1374 return error.SkipZigTest;
1375 }
13761356 try testFmt("f64: 152314000000000000000000000000", "f64: {d}", .{@as(f64, 1.52314e+29)});
13771357 try testFmt("f32: 1.1", "f32: {d:.1}", .{@as(f32, 1.1234)});
13781358 try testFmt("f32: 1234.57", "f32: {d:.2}", .{@as(f32, 1234.567)});
......@@ -1391,10 +1371,6 @@ test "float.decimal" {
13911371}
13921372
13931373test "float.libc.sanity" {
1394 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1395 // TODO https://github.com/ziglang/zig/issues/3289
1396 return error.SkipZigTest;
1397 }
13981374 try testFmt("f64: 0.00001", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 916964781)))});
13991375 try testFmt("f64: 0.00001", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 925353389)))});
14001376 try testFmt("f64: 0.10000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1036831278)))});
lib/std/fmt/parse_float.zig-4
......@@ -382,10 +382,6 @@ pub fn parseFloat(comptime T: type, s: []const u8) !T {
382382}
383383
384384test "fmt.parseFloat" {
385 if (@import("builtin").arch == .arm) {
386 // TODO https://github.com/ziglang/zig/issues/3289
387 return error.SkipZigTest;
388 }
389385 const testing = std.testing;
390386 const expect = testing.expect;
391387 const expectEqual = testing.expectEqual;
lib/std/math/big/rational.zig-8
......@@ -742,10 +742,6 @@ test "big.rational setFloatString" {
742742}
743743
744744test "big.rational toFloat" {
745 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
746 // TODO https://github.com/ziglang/zig/issues/3289
747 return error.SkipZigTest;
748 }
749745 var a = try Rational.init(al);
750746
751747 // = 3.14159297943115234375
......@@ -758,10 +754,6 @@ test "big.rational toFloat" {
758754}
759755
760756test "big.rational set/to Float round-trip" {
761 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
762 // TODO https://github.com/ziglang/zig/issues/3289
763 return error.SkipZigTest;
764 }
765757 var a = try Rational.init(al);
766758 var prng = std.rand.DefaultPrng.init(0x5EED);
767759 var i: usize = 0;
lib/std/math/complex/atan.zig-4
......@@ -130,10 +130,6 @@ test "complex.catan32" {
130130}
131131
132132test "complex.catan64" {
133 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
134 // TODO https://github.com/ziglang/zig/issues/3289
135 return error.SkipZigTest;
136 }
137133 const a = Complex(f64).new(5, 3);
138134 const c = atan(a);
139135
lib/std/math/complex/cosh.zig-4
......@@ -165,10 +165,6 @@ test "complex.ccosh32" {
165165}
166166
167167test "complex.ccosh64" {
168 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
169 // TODO https://github.com/ziglang/zig/issues/3289
170 return error.SkipZigTest;
171 }
172168 const a = Complex(f64).new(5, 3);
173169 const c = cosh(a);
174170
lib/std/math/complex/exp.zig-4
......@@ -131,10 +131,6 @@ test "complex.cexp32" {
131131}
132132
133133test "complex.cexp64" {
134 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
135 // TODO https://github.com/ziglang/zig/issues/3289
136 return error.SkipZigTest;
137 }
138134 const a = Complex(f64).new(5, 3);
139135 const c = exp(a);
140136
lib/std/math/complex/sinh.zig-4
......@@ -164,10 +164,6 @@ test "complex.csinh32" {
164164}
165165
166166test "complex.csinh64" {
167 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
168 // TODO https://github.com/ziglang/zig/issues/3289
169 return error.SkipZigTest;
170 }
171167 const a = Complex(f64).new(5, 3);
172168 const c = sinh(a);
173169
lib/std/math/complex/tanh.zig-4
......@@ -113,10 +113,6 @@ test "complex.ctanh32" {
113113}
114114
115115test "complex.ctanh64" {
116 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
117 // TODO https://github.com/ziglang/zig/issues/3289
118 return error.SkipZigTest;
119 }
120116 const a = Complex(f64).new(5, 3);
121117 const c = tanh(a);
122118
lib/std/math/cos.zig-4
......@@ -100,10 +100,6 @@ test "math.cos32" {
100100}
101101
102102test "math.cos64" {
103 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
104 // TODO https://github.com/ziglang/zig/issues/3289
105 return error.SkipZigTest;
106 }
107103 const epsilon = 0.000001;
108104
109105 expect(math.approxEq(f64, cos_(f64, 0.0), 1.0, epsilon));
lib/std/math/pow.zig-12
......@@ -184,10 +184,6 @@ fn isOddInteger(x: f64) bool {
184184}
185185
186186test "math.pow" {
187 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
188 // TODO https://github.com/ziglang/zig/issues/3289
189 return error.SkipZigTest;
190 }
191187 const epsilon = 0.000001;
192188
193189 expect(math.approxEq(f32, pow(f32, 0.0, 3.3), 0.0, epsilon));
......@@ -206,10 +202,6 @@ test "math.pow" {
206202}
207203
208204test "math.pow.special" {
209 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
210 // TODO https://github.com/ziglang/zig/issues/3289
211 return error.SkipZigTest;
212 }
213205 const epsilon = 0.000001;
214206
215207 expect(pow(f32, 4, 0.0) == 1.0);
......@@ -252,10 +244,6 @@ test "math.pow.special" {
252244}
253245
254246test "math.pow.overflow" {
255 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
256 // TODO https://github.com/ziglang/zig/issues/3289
257 return error.SkipZigTest;
258 }
259247 expect(math.isPositiveInf(pow(f64, 2, 1 << 32)));
260248 expect(pow(f64, 2, -(1 << 32)) == 0);
261249 expect(math.isNegativeInf(pow(f64, -2, (1 << 32) + 1)));
lib/std/math/sin.zig-20
......@@ -84,20 +84,12 @@ fn sin_(comptime T: type, x_: T) T {
8484}
8585
8686test "math.sin" {
87 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
88 // TODO https://github.com/ziglang/zig/issues/3289
89 return error.SkipZigTest;
90 }
9187 expect(sin(@as(f32, 0.0)) == sin_(f32, 0.0));
9288 expect(sin(@as(f64, 0.0)) == sin_(f64, 0.0));
9389 expect(comptime (math.sin(@as(f64, 2))) == math.sin(@as(f64, 2)));
9490}
9591
9692test "math.sin32" {
97 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
98 // TODO https://github.com/ziglang/zig/issues/3289
99 return error.SkipZigTest;
100 }
10193 const epsilon = 0.000001;
10294
10395 expect(math.approxEq(f32, sin_(f32, 0.0), 0.0, epsilon));
......@@ -110,10 +102,6 @@ test "math.sin32" {
110102}
111103
112104test "math.sin64" {
113 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
114 // TODO https://github.com/ziglang/zig/issues/3289
115 return error.SkipZigTest;
116 }
117105 const epsilon = 0.000001;
118106
119107 expect(math.approxEq(f64, sin_(f64, 0.0), 0.0, epsilon));
......@@ -126,10 +114,6 @@ test "math.sin64" {
126114}
127115
128116test "math.sin32.special" {
129 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
130 // TODO https://github.com/ziglang/zig/issues/3289
131 return error.SkipZigTest;
132 }
133117 expect(sin_(f32, 0.0) == 0.0);
134118 expect(sin_(f32, -0.0) == -0.0);
135119 expect(math.isNan(sin_(f32, math.inf(f32))));
......@@ -138,10 +122,6 @@ test "math.sin32.special" {
138122}
139123
140124test "math.sin64.special" {
141 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
142 // TODO https://github.com/ziglang/zig/issues/3289
143 return error.SkipZigTest;
144 }
145125 expect(sin_(f64, 0.0) == 0.0);
146126 expect(sin_(f64, -0.0) == -0.0);
147127 expect(math.isNan(sin_(f64, math.inf(f64))));
lib/std/math/tan.zig-4
......@@ -91,10 +91,6 @@ test "math.tan32" {
9191}
9292
9393test "math.tan64" {
94 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
95 // TODO https://github.com/ziglang/zig/issues/3289
96 return error.SkipZigTest;
97 }
9894 const epsilon = 0.000001;
9995
10096 expect(math.approxEq(f64, tan_(f64, 0.0), 0.0, epsilon));
lib/std/special/compiler_rt.zig+32-32
......@@ -181,62 +181,62 @@ comptime {
181181 @export("__aeabi_memcmp4", __aeabi_memcmp, linkage);
182182 @export("__aeabi_memcmp8", __aeabi_memcmp, linkage);
183183
184 @export("__aeabi_f2d", @import("compiler_rt/extendXfYf2.zig").__extendsfdf2, linkage);
185 @export("__aeabi_i2d", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage);
186 @export("__aeabi_l2d", @import("compiler_rt/floatdidf.zig").__floatdidf, linkage);
187 @export("__aeabi_ui2d", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage);
188 @export("__aeabi_ul2d", @import("compiler_rt/floatundidf.zig").__floatundidf, linkage);
189 @export("__aeabi_ui2f", @import("compiler_rt/floatunsisf.zig").__floatunsisf, linkage);
190 @export("__aeabi_ul2f", @import("compiler_rt/floatundisf.zig").__floatundisf, linkage);
184 @export("__aeabi_f2d", @import("compiler_rt/extendXfYf2.zig").__aeabi_f2d, linkage);
185 @export("__aeabi_i2d", @import("compiler_rt/floatsiXf.zig").__aeabi_i2d, linkage);
186 @export("__aeabi_l2d", @import("compiler_rt/floatdidf.zig").__aeabi_l2d, linkage);
187 @export("__aeabi_ui2d", @import("compiler_rt/floatunsidf.zig").__aeabi_ui2d, linkage);
188 @export("__aeabi_ul2d", @import("compiler_rt/floatundidf.zig").__aeabi_ul2d, linkage);
189 @export("__aeabi_ui2f", @import("compiler_rt/floatunsisf.zig").__aeabi_ui2f, linkage);
190 @export("__aeabi_ul2f", @import("compiler_rt/floatundisf.zig").__aeabi_ul2f, linkage);
191191
192 @export("__aeabi_fneg", @import("compiler_rt/negXf2.zig").__negsf2, linkage);
193 @export("__aeabi_dneg", @import("compiler_rt/negXf2.zig").__negdf2, linkage);
192 @export("__aeabi_fneg", @import("compiler_rt/negXf2.zig").__aeabi_fneg, linkage);
193 @export("__aeabi_dneg", @import("compiler_rt/negXf2.zig").__aeabi_dneg, linkage);
194194
195 @export("__aeabi_fmul", @import("compiler_rt/mulXf3.zig").__mulsf3, linkage);
196 @export("__aeabi_dmul", @import("compiler_rt/mulXf3.zig").__muldf3, linkage);
195 @export("__aeabi_fmul", @import("compiler_rt/mulXf3.zig").__aeabi_fmul, linkage);
196 @export("__aeabi_dmul", @import("compiler_rt/mulXf3.zig").__aeabi_dmul, linkage);
197197
198 @export("__aeabi_d2h", @import("compiler_rt/truncXfYf2.zig").__truncdfhf2, linkage);
198 @export("__aeabi_d2h", @import("compiler_rt/truncXfYf2.zig").__aeabi_d2h, linkage);
199199
200 @export("__aeabi_f2ulz", @import("compiler_rt/fixunssfdi.zig").__fixunssfdi, linkage);
201 @export("__aeabi_d2ulz", @import("compiler_rt/fixunsdfdi.zig").__fixunsdfdi, linkage);
200 @export("__aeabi_f2ulz", @import("compiler_rt/fixunssfdi.zig").__aeabi_f2ulz, linkage);
201 @export("__aeabi_d2ulz", @import("compiler_rt/fixunsdfdi.zig").__aeabi_d2ulz, linkage);
202202
203 @export("__aeabi_f2lz", @import("compiler_rt/fixsfdi.zig").__fixsfdi, linkage);
204 @export("__aeabi_d2lz", @import("compiler_rt/fixdfdi.zig").__fixdfdi, linkage);
203 @export("__aeabi_f2lz", @import("compiler_rt/fixsfdi.zig").__aeabi_f2lz, linkage);
204 @export("__aeabi_d2lz", @import("compiler_rt/fixdfdi.zig").__aeabi_d2lz, linkage);
205205
206 @export("__aeabi_d2uiz", @import("compiler_rt/fixunsdfsi.zig").__fixunsdfsi, linkage);
206 @export("__aeabi_d2uiz", @import("compiler_rt/fixunsdfsi.zig").__aeabi_d2uiz, linkage);
207207
208 @export("__aeabi_h2f", @import("compiler_rt/extendXfYf2.zig").__extendhfsf2, linkage);
209 @export("__aeabi_f2h", @import("compiler_rt/truncXfYf2.zig").__truncsfhf2, linkage);
208 @export("__aeabi_h2f", @import("compiler_rt/extendXfYf2.zig").__aeabi_h2f, linkage);
209 @export("__aeabi_f2h", @import("compiler_rt/truncXfYf2.zig").__aeabi_f2h, linkage);
210210
211 @export("__aeabi_i2f", @import("compiler_rt/floatsiXf.zig").__floatsisf, linkage);
212 @export("__aeabi_d2f", @import("compiler_rt/truncXfYf2.zig").__truncdfsf2, linkage);
211 @export("__aeabi_i2f", @import("compiler_rt/floatsiXf.zig").__aeabi_i2f, linkage);
212 @export("__aeabi_d2f", @import("compiler_rt/truncXfYf2.zig").__aeabi_d2f, linkage);
213213
214 @export("__aeabi_fadd", @import("compiler_rt/addXf3.zig").__addsf3, linkage);
215 @export("__aeabi_dadd", @import("compiler_rt/addXf3.zig").__adddf3, linkage);
216 @export("__aeabi_fsub", @import("compiler_rt/addXf3.zig").__subsf3, linkage);
217 @export("__aeabi_dsub", @import("compiler_rt/addXf3.zig").__subdf3, linkage);
214 @export("__aeabi_fadd", @import("compiler_rt/addXf3.zig").__aeabi_fadd, linkage);
215 @export("__aeabi_dadd", @import("compiler_rt/addXf3.zig").__aeabi_dadd, linkage);
216 @export("__aeabi_fsub", @import("compiler_rt/addXf3.zig").__aeabi_fsub, linkage);
217 @export("__aeabi_dsub", @import("compiler_rt/addXf3.zig").__aeabi_dsub, linkage);
218218
219 @export("__aeabi_f2uiz", @import("compiler_rt/fixunssfsi.zig").__fixunssfsi, linkage);
219 @export("__aeabi_f2uiz", @import("compiler_rt/fixunssfsi.zig").__aeabi_f2uiz, linkage);
220220
221 @export("__aeabi_f2iz", @import("compiler_rt/fixsfsi.zig").__fixsfsi, linkage);
222 @export("__aeabi_d2iz", @import("compiler_rt/fixdfsi.zig").__fixdfsi, linkage);
221 @export("__aeabi_f2iz", @import("compiler_rt/fixsfsi.zig").__aeabi_f2iz, linkage);
222 @export("__aeabi_d2iz", @import("compiler_rt/fixdfsi.zig").__aeabi_d2iz, linkage);
223223
224 @export("__aeabi_fdiv", @import("compiler_rt/divsf3.zig").__divsf3, linkage);
225 @export("__aeabi_ddiv", @import("compiler_rt/divdf3.zig").__divdf3, linkage);
224 @export("__aeabi_fdiv", @import("compiler_rt/divsf3.zig").__aeabi_fdiv, linkage);
225 @export("__aeabi_ddiv", @import("compiler_rt/divdf3.zig").__aeabi_ddiv, linkage);
226226
227227 @export("__aeabi_fcmpeq", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpeq, linkage);
228228 @export("__aeabi_fcmplt", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmplt, linkage);
229229 @export("__aeabi_fcmple", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmple, linkage);
230230 @export("__aeabi_fcmpge", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpge, linkage);
231231 @export("__aeabi_fcmpgt", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpgt, linkage);
232 @export("__aeabi_fcmpun", @import("compiler_rt/comparesf2.zig").__unordsf2, linkage);
232 @export("__aeabi_fcmpun", @import("compiler_rt/comparesf2.zig").__aeabi_fcmpun, linkage);
233233
234234 @export("__aeabi_dcmpeq", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpeq, linkage);
235235 @export("__aeabi_dcmplt", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmplt, linkage);
236236 @export("__aeabi_dcmple", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmple, linkage);
237237 @export("__aeabi_dcmpge", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpge, linkage);
238238 @export("__aeabi_dcmpgt", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpgt, linkage);
239 @export("__aeabi_dcmpun", @import("compiler_rt/comparedf2.zig").__unorddf2, linkage);
239 @export("__aeabi_dcmpun", @import("compiler_rt/comparedf2.zig").__aeabi_dcmpun, linkage);
240240 }
241241 if (builtin.os == .windows) {
242242 // Default stack-probe functions emitted by LLVM
lib/std/special/compiler_rt/addXf3.zig+20
......@@ -33,6 +33,26 @@ pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 {
3333 return addXf3(f128, a, neg_b);
3434}
3535
36pub fn __aeabi_fadd(a: f32, b: f32) callconv(.AAPCS) f32 {
37 @setRuntimeSafety(false);
38 return @call(.{ .modifier = .always_inline }, __addsf3, .{ a, b });
39}
40
41pub fn __aeabi_dadd(a: f64, b: f64) callconv(.AAPCS) f64 {
42 @setRuntimeSafety(false);
43 return @call(.{ .modifier = .always_inline }, __adddf3, .{ a, b });
44}
45
46pub fn __aeabi_fsub(a: f32, b: f32) callconv(.AAPCS) f32 {
47 @setRuntimeSafety(false);
48 return @call(.{ .modifier = .always_inline }, __subsf3, .{ a, b });
49}
50
51pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 {
52 @setRuntimeSafety(false);
53 return @call(.{ .modifier = .always_inline }, __subdf3, .{ a, b });
54}
55
3656// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
3757fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
3858 const Z = @IntType(false, T.bit_count);
lib/std/special/compiler_rt/arm/aeabi_dcmp.zig-13
......@@ -2,8 +2,6 @@
22//
33// https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/arm/aeabi_dcmp.S
44
5const compiler_rt_armhf_target = false; // TODO
6
75const ConditionalOperator = enum {
86 Eq,
97 Lt,
......@@ -42,23 +40,12 @@ pub fn __aeabi_dcmpgt() callconv(.Naked) noreturn {
4240 unreachable;
4341}
4442
45inline fn convert_dcmp_args_to_df2_args() void {
46 asm volatile (
47 \\ vmov d0, r0, r1
48 \\ vmov d1, r2, r3
49 );
50}
51
5243fn aeabi_dcmp(comptime cond: ConditionalOperator) void {
5344 @setRuntimeSafety(false);
5445 asm volatile (
5546 \\ push { r4, lr }
5647 );
5748
58 if (compiler_rt_armhf_target) {
59 convert_dcmp_args_to_df2_args();
60 }
61
6249 switch (cond) {
6350 .Eq => asm volatile (
6451 \\ bl __eqdf2
lib/std/special/compiler_rt/arm/aeabi_fcmp.zig-13
......@@ -2,8 +2,6 @@
22//
33// https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/arm/aeabi_fcmp.S
44
5const compiler_rt_armhf_target = false; // TODO
6
75const ConditionalOperator = enum {
86 Eq,
97 Lt,
......@@ -42,23 +40,12 @@ pub fn __aeabi_fcmpgt() callconv(.Naked) noreturn {
4240 unreachable;
4341}
4442
45inline fn convert_fcmp_args_to_sf2_args() void {
46 asm volatile (
47 \\ vmov s0, r0
48 \\ vmov s1, r1
49 );
50}
51
5243fn aeabi_fcmp(comptime cond: ConditionalOperator) void {
5344 @setRuntimeSafety(false);
5445 asm volatile (
5546 \\ push { r4, lr }
5647 );
5748
58 if (compiler_rt_armhf_target) {
59 convert_fcmp_args_to_sf2_args();
60 }
61
6249 switch (cond) {
6350 .Eq => asm volatile (
6451 \\ bl __eqsf2
lib/std/special/compiler_rt/comparedf2.zig+5
......@@ -117,6 +117,11 @@ pub fn __gtdf2(a: fp_t, b: fp_t) callconv(.C) c_int {
117117 return __gedf2(a, b);
118118}
119119
120pub fn __aeabi_dcmpun(a: fp_t, b: fp_t) callconv(.AAPCS) c_int {
121 @setRuntimeSafety(false);
122 return @call(.{ .modifier = .always_inline }, __unorddf2, .{ a, b });
123}
124
120125test "import comparedf2" {
121126 _ = @import("comparedf2_test.zig");
122127}
lib/std/special/compiler_rt/comparesf2.zig+5
......@@ -117,6 +117,11 @@ pub fn __gtsf2(a: fp_t, b: fp_t) callconv(.C) c_int {
117117 return __gesf2(a, b);
118118}
119119
120pub fn __aeabi_fcmpun(a: fp_t, b: fp_t) callconv(.AAPCS) c_int {
121 @setRuntimeSafety(false);
122 return @call(.{ .modifier = .always_inline }, __unordsf2, .{ a, b });
123}
124
120125test "import comparesf2" {
121126 _ = @import("comparesf2_test.zig");
122127}
lib/std/special/compiler_rt/divdf3.zig+5
......@@ -323,6 +323,11 @@ fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
323323 return 1 - shift;
324324}
325325
326pub fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 {
327 @setRuntimeSafety(false);
328 return @call(.{ .modifier = .always_inline }, __divdf3, .{ a, b });
329}
330
326331test "import divdf3" {
327332 _ = @import("divdf3_test.zig");
328333}
lib/std/special/compiler_rt/divsf3.zig+5
......@@ -196,6 +196,11 @@ fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
196196 return 1 - shift;
197197}
198198
199pub fn __aeabi_fdiv(a: f32, b: f32) callconv(.AAPCS) f32 {
200 @setRuntimeSafety(false);
201 return @call(.{ .modifier = .always_inline }, __divsf3, .{ a, b });
202}
203
199204test "import divsf3" {
200205 _ = @import("divsf3_test.zig");
201206}
lib/std/special/compiler_rt/extendXfYf2.zig+10
......@@ -18,6 +18,16 @@ pub fn __extendhfsf2(a: u16) callconv(.C) f32 {
1818 return @call(.{ .modifier = .always_inline }, extendXfYf2, .{ f32, f16, a });
1919}
2020
21pub fn __aeabi_h2f(arg: u16) callconv(.AAPCS) f32 {
22 @setRuntimeSafety(false);
23 return @call(.{ .modifier = .always_inline }, __extendhfsf2, .{arg});
24}
25
26pub fn __aeabi_f2d(arg: f32) callconv(.AAPCS) f64 {
27 @setRuntimeSafety(false);
28 return @call(.{ .modifier = .always_inline }, __extendsfdf2, .{arg});
29}
30
2131const CHAR_BIT = 8;
2232
2333fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @typeInfo(src_t).Float.bits)) dst_t {
lib/std/special/compiler_rt/fixdfdi.zig+5
......@@ -6,6 +6,11 @@ pub fn __fixdfdi(a: f64) callconv(.C) i64 {
66 return fixint(f64, i64, a);
77}
88
9pub fn __aeabi_d2lz(arg: f64) callconv(.AAPCS) i64 {
10 @setRuntimeSafety(false);
11 return @call(.{ .modifier = .always_inline }, __fixdfdi, .{arg});
12}
13
914test "import fixdfdi" {
1015 _ = @import("fixdfdi_test.zig");
1116}
lib/std/special/compiler_rt/fixdfsi.zig+5
......@@ -6,6 +6,11 @@ pub fn __fixdfsi(a: f64) callconv(.C) i32 {
66 return fixint(f64, i32, a);
77}
88
9pub fn __aeabi_d2iz(a: f64) callconv(.AAPCS) i32 {
10 @setRuntimeSafety(false);
11 return @call(.{ .modifier = .always_inline }, __fixdfsi, .{a});
12}
13
914test "import fixdfsi" {
1015 _ = @import("fixdfsi_test.zig");
1116}
lib/std/special/compiler_rt/fixsfdi.zig+5
......@@ -6,6 +6,11 @@ pub fn __fixsfdi(a: f32) callconv(.C) i64 {
66 return fixint(f32, i64, a);
77}
88
9pub fn __aeabi_f2lz(arg: f32) callconv(.AAPCS) i64 {
10 @setRuntimeSafety(false);
11 return @call(.{ .modifier = .always_inline }, __fixsfdi, .{arg});
12}
13
914test "import fixsfdi" {
1015 _ = @import("fixsfdi_test.zig");
1116}
lib/std/special/compiler_rt/fixsfsi.zig+5
......@@ -6,6 +6,11 @@ pub fn __fixsfsi(a: f32) callconv(.C) i32 {
66 return fixint(f32, i32, a);
77}
88
9pub fn __aeabi_f2iz(a: f32) callconv(.AAPCS) i32 {
10 @setRuntimeSafety(false);
11 return @call(.{ .modifier = .always_inline }, __fixsfsi, .{a});
12}
13
914test "import fixsfsi" {
1015 _ = @import("fixsfsi_test.zig");
1116}
lib/std/special/compiler_rt/fixunsdfdi.zig+5
......@@ -6,6 +6,11 @@ pub fn __fixunsdfdi(a: f64) callconv(.C) u64 {
66 return fixuint(f64, u64, a);
77}
88
9pub fn __aeabi_d2ulz(a: f64) callconv(.AAPCS) u64 {
10 @setRuntimeSafety(false);
11 return @call(.{ .modifier = .always_inline }, __fixunsdfdi, .{a});
12}
13
914test "import fixunsdfdi" {
1015 _ = @import("fixunsdfdi_test.zig");
1116}
lib/std/special/compiler_rt/fixunsdfsi.zig+5
......@@ -6,6 +6,11 @@ pub fn __fixunsdfsi(a: f64) callconv(.C) u32 {
66 return fixuint(f64, u32, a);
77}
88
9pub fn __aeabi_d2uiz(arg: f64) callconv(.AAPCS) u32 {
10 @setRuntimeSafety(false);
11 return @call(.{ .modifier = .always_inline }, __fixunsdfsi, .{arg});
12}
13
914test "import fixunsdfsi" {
1015 _ = @import("fixunsdfsi_test.zig");
1116}
lib/std/special/compiler_rt/fixunssfdi.zig+5
......@@ -6,6 +6,11 @@ pub fn __fixunssfdi(a: f32) callconv(.C) u64 {
66 return fixuint(f32, u64, a);
77}
88
9pub fn __aeabi_f2ulz(a: f32) callconv(.AAPCS) u64 {
10 @setRuntimeSafety(false);
11 return @call(.{ .modifier = .always_inline }, __fixunssfdi, .{a});
12}
13
914test "import fixunssfdi" {
1015 _ = @import("fixunssfdi_test.zig");
1116}
lib/std/special/compiler_rt/fixunssfsi.zig+5
......@@ -6,6 +6,11 @@ pub fn __fixunssfsi(a: f32) callconv(.C) u32 {
66 return fixuint(f32, u32, a);
77}
88
9pub fn __aeabi_f2uiz(a: f32) callconv(.AAPCS) u32 {
10 @setRuntimeSafety(false);
11 return @call(.{ .modifier = .always_inline }, __fixunssfsi, .{a});
12}
13
914test "import fixunssfsi" {
1015 _ = @import("fixunssfsi_test.zig");
1116}
lib/std/special/compiler_rt/floatdidf.zig+5
......@@ -17,6 +17,11 @@ pub fn __floatdidf(a: i64) callconv(.C) f64 {
1717 return (high - twop52) + @bitCast(f64, low);
1818}
1919
20pub fn __aeabi_l2d(arg: i64) callconv(.AAPCS) f64 {
21 @setRuntimeSafety(false);
22 return @call(.{ .modifier = .always_inline }, __floatdidf, .{arg});
23}
24
2025test "import floatdidf" {
2126 _ = @import("floatdidf_test.zig");
2227}
lib/std/special/compiler_rt/floatsiXf.zig+10
......@@ -68,6 +68,16 @@ pub fn __floatsitf(arg: i32) callconv(.C) f128 {
6868 return @call(.{ .modifier = .always_inline }, floatsiXf, .{ f128, arg });
6969}
7070
71pub fn __aeabi_i2d(arg: i32) callconv(.AAPCS) f64 {
72 @setRuntimeSafety(false);
73 return @call(.{ .modifier = .always_inline }, __floatsidf, .{arg});
74}
75
76pub fn __aeabi_i2f(arg: i32) callconv(.AAPCS) f32 {
77 @setRuntimeSafety(false);
78 return @call(.{ .modifier = .always_inline }, __floatsisf, .{arg});
79}
80
7181fn test_one_floatsitf(a: i32, expected: u128) void {
7282 const r = __floatsitf(a);
7383 std.testing.expect(@bitCast(u128, r) == expected);
lib/std/special/compiler_rt/floatundidf.zig+5
......@@ -19,6 +19,11 @@ pub fn __floatundidf(a: u64) callconv(.C) f64 {
1919 return (@bitCast(f64, high) - twop84_plus_twop52) + @bitCast(f64, low);
2020}
2121
22pub fn __aeabi_ul2d(arg: u64) callconv(.AAPCS) f64 {
23 @setRuntimeSafety(false);
24 return @call(.{ .modifier = .always_inline }, __floatundidf, .{arg});
25}
26
2227test "import floatundidf" {
2328 _ = @import("floatundidf_test.zig");
2429}
lib/std/special/compiler_rt/floatundisf.zig+6-1
......@@ -4,7 +4,7 @@ const maxInt = std.math.maxInt;
44
55const FLT_MANT_DIG = 24;
66
7pub extern fn __floatundisf(arg: u64) f32 {
7pub fn __floatundisf(arg: u64) callconv(.C) f32 {
88 @setRuntimeSafety(builtin.is_test);
99
1010 if (arg == 0) return 0;
......@@ -56,6 +56,11 @@ pub extern fn __floatundisf(arg: u64) f32 {
5656 return @bitCast(f32, result);
5757}
5858
59pub fn __aeabi_ul2f(arg: u64) callconv(.AAPCS) f32 {
60 @setRuntimeSafety(false);
61 return @call(.{ .modifier = .always_inline }, __floatundisf, .{arg});
62}
63
5964fn test__floatundisf(a: u64, expected: f32) void {
6065 std.testing.expectEqual(expected, __floatundisf(a));
6166}
lib/std/special/compiler_rt/floatunsidf.zig+5
......@@ -18,6 +18,11 @@ pub fn __floatunsidf(arg: u32) callconv(.C) f64 {
1818 return @bitCast(f64, mant | (exp + 1023) << 52);
1919}
2020
21pub fn __aeabi_ui2d(arg: u32) callconv(.AAPCS) f64 {
22 @setRuntimeSafety(false);
23 return @call(.{ .modifier = .always_inline }, __floatunsidf, .{arg});
24}
25
2126fn test_one_floatunsidf(a: u32, expected: u64) void {
2227 const r = __floatunsidf(a);
2328 std.testing.expect(@bitCast(u64, r) == expected);
lib/std/special/compiler_rt/floatunsisf.zig+6-1
......@@ -6,7 +6,7 @@ const significandBits = 23;
66const exponentBias = 127;
77const implicitBit = @as(u32, 1) << significandBits;
88
9pub extern fn __floatunsisf(arg: u32) f32 {
9pub fn __floatunsisf(arg: u32) callconv(.C) f32 {
1010 @setRuntimeSafety(builtin.is_test);
1111
1212 if (arg == 0) return 0.0;
......@@ -38,6 +38,11 @@ pub extern fn __floatunsisf(arg: u32) f32 {
3838 return @bitCast(f32, result);
3939}
4040
41pub fn __aeabi_ui2f(arg: u32) callconv(.AAPCS) f32 {
42 @setRuntimeSafety(false);
43 return @call(.{ .modifier = .always_inline }, __floatunsisf, .{arg});
44}
45
4146fn test_one_floatunsisf(a: u32, expected: u32) void {
4247 const r = __floatunsisf(a);
4348 std.testing.expect(@bitCast(u32, r) == expected);
lib/std/special/compiler_rt/mulXf3.zig+10
......@@ -16,6 +16,16 @@ pub fn __mulsf3(a: f32, b: f32) callconv(.C) f32 {
1616 return mulXf3(f32, a, b);
1717}
1818
19pub fn __aeabi_fmul(a: f32, b: f32) callconv(.C) f32 {
20 @setRuntimeSafety(false);
21 return @call(.{ .modifier = .always_inline }, __mulsf3, .{ a, b });
22}
23
24pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 {
25 @setRuntimeSafety(false);
26 return @call(.{ .modifier = .always_inline }, __muldf3, .{ a, b });
27}
28
1929fn mulXf3(comptime T: type, a: T, b: T) T {
2030 @setRuntimeSafety(builtin.is_test);
2131 const Z = @IntType(false, T.bit_count);
lib/std/special/compiler_rt/negXf2.zig+10
......@@ -8,6 +8,16 @@ pub fn __negdf2(a: f64) callconv(.C) f64 {
88 return negXf2(f64, a);
99}
1010
11pub fn __aeabi_fneg(arg: f32) callconv(.AAPCS) f32 {
12 @setRuntimeSafety(false);
13 return @call(.{ .modifier = .always_inline }, __negsf2, .{arg});
14}
15
16pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 {
17 @setRuntimeSafety(false);
18 return @call(.{ .modifier = .always_inline }, __negdf2, .{arg});
19}
20
1121fn negXf2(comptime T: type, a: T) T {
1222 const Z = @IntType(false, T.bit_count);
1323
lib/std/special/compiler_rt/truncXfYf2.zig+15
......@@ -20,6 +20,21 @@ pub fn __truncdfsf2(a: f64) callconv(.C) f32 {
2020 return truncXfYf2(f32, f64, a);
2121}
2222
23pub fn __aeabi_d2f(a: f64) callconv(.AAPCS) f32 {
24 @setRuntimeSafety(false);
25 return @call(.{ .modifier = .always_inline }, __truncdfsf2, .{a});
26}
27
28pub fn __aeabi_d2h(a: f64) callconv(.AAPCS) u16 {
29 @setRuntimeSafety(false);
30 return @call(.{ .modifier = .always_inline }, __truncdfhf2, .{a});
31}
32
33pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {
34 @setRuntimeSafety(false);
35 return @call(.{ .modifier = .always_inline }, __truncsfhf2, .{a});
36}
37
2338inline fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
2439 const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits);
2540 const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);