From 2dce137d926150d34ff7a3650da48c211e34771a Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 8 May 2019 23:54:43 +0200 Subject: [PATCH] compiler-rt: Add __extendsfdf2 Add AEABI builtin __aeabi_f2d --- std/special/compiler_rt.zig | 3 +++ std/special/compiler_rt/extendXfYf2.zig | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/std/special/compiler_rt.zig b/std/special/compiler_rt.zig index 8784aa2b19..2f2c901f94 100644 --- a/std/special/compiler_rt.zig +++ b/std/special/compiler_rt.zig @@ -92,6 +92,8 @@ comptime { @export("__truncdfsf2", @import("compiler_rt/truncXfYf2.zig").__truncdfsf2, linkage); + @export("__extendsfdf2", @import("compiler_rt/extendXfYf2.zig").__extendsfdf2, linkage); + @export("__fixunssfsi", @import("compiler_rt/fixunssfsi.zig").__fixunssfsi, linkage); @export("__fixunssfdi", @import("compiler_rt/fixunssfdi.zig").__fixunssfdi, linkage); @export("__fixunssfti", @import("compiler_rt/fixunssfti.zig").__fixunssfti, linkage); @@ -161,6 +163,7 @@ comptime { @export("__aeabi_memcmp4", __aeabi_memcmp, linkage); @export("__aeabi_memcmp8", __aeabi_memcmp, linkage); + @export("__aeabi_f2d", @import("compiler_rt/extendXfYf2.zig").__extendsfdf2, linkage); @export("__aeabi_i2d", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage); @export("__aeabi_l2d", @import("compiler_rt/floatdidf.zig").__floatdidf, linkage); @export("__aeabi_ui2d", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage); diff --git a/std/special/compiler_rt/extendXfYf2.zig b/std/special/compiler_rt/extendXfYf2.zig index 953072b9e3..42559784bb 100644 --- a/std/special/compiler_rt/extendXfYf2.zig +++ b/std/special/compiler_rt/extendXfYf2.zig @@ -2,21 +2,27 @@ const std = @import("std"); const builtin = @import("builtin"); const is_test = builtin.is_test; +pub extern fn __extendsfdf2(a: f32) f64 { + return @inlineCall(extendXfYf2, f64, f32, @bitCast(u32, a)); +} + pub extern fn __extenddftf2(a: f64) f128 { - return extendXfYf2(f128, f64, @bitCast(u64, a)); + return @inlineCall(extendXfYf2, f128, f64, @bitCast(u64, a)); } pub extern fn __extendsftf2(a: f32) f128 { - return extendXfYf2(f128, f32, @bitCast(u32, a)); + return @inlineCall(extendXfYf2, f128, f32, @bitCast(u32, a)); } pub extern fn __extendhfsf2(a: u16) f32 { - return extendXfYf2(f32, f16, a); + return @inlineCall(extendXfYf2, f32, f16, a); } const CHAR_BIT = 8; -inline fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @typeInfo(src_t).Float.bits)) dst_t { +fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @typeInfo(src_t).Float.bits)) dst_t { + @setRuntimeSafety(builtin.is_test); + const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits); const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits); const srcSigBits = std.math.floatMantissaBits(src_t);