| author | |
| committer | |
| log | 7d94e712f125e10f234338e800953aa4837206ef |
| tree | 63372bf28dd8aa2eedd10660975d67a92e2aa5e3 |
| parent | fa52c9e36efde38f6d1c6e280636ba7f6cb6f83a |
2 files changed, 22 insertions(+), 152 deletions(-)
lib/std/special/compiler_rt/arm/aeabi_dcmp.zig+11-76| ... | ... | @@ -2,94 +2,29 @@ |
| 2 | 2 | // |
| 3 | 3 | // https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/arm/aeabi_dcmp.S |
| 4 | 4 | |
| 5 | const ConditionalOperator = enum { | |
| 6 | Eq, | |
| 7 | Lt, | |
| 8 | Le, | |
| 9 | Ge, | |
| 10 | Gt, | |
| 11 | }; | |
| 5 | const comparedf2 = @import("../comparedf2.zig"); | |
| 12 | 6 | |
| 13 | pub fn __aeabi_dcmpeq() callconv(.Naked) noreturn { | |
| 7 | pub fn __aeabi_dcmpeq(a: f64, b: f64) callconv(.AAPCS) i32 { | |
| 14 | 8 | @setRuntimeSafety(false); |
| 15 | @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Eq}); | |
| 16 | unreachable; | |
| 9 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparedf2.__eqdf2, .{ a, b }) == 0); | |
| 17 | 10 | } |
| 18 | 11 | |
| 19 | pub fn __aeabi_dcmplt() callconv(.Naked) noreturn { | |
| 12 | pub fn __aeabi_dcmplt(a: f64, b: f64) callconv(.AAPCS) i32 { | |
| 20 | 13 | @setRuntimeSafety(false); |
| 21 | @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Lt}); | |
| 22 | unreachable; | |
| 14 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparedf2.__ltdf2, .{ a, b }) < 0); | |
| 23 | 15 | } |
| 24 | 16 | |
| 25 | pub fn __aeabi_dcmple() callconv(.Naked) noreturn { | |
| 17 | pub fn __aeabi_dcmple(a: f64, b: f64) callconv(.AAPCS) i32 { | |
| 26 | 18 | @setRuntimeSafety(false); |
| 27 | @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Le}); | |
| 28 | unreachable; | |
| 19 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparedf2.__ledf2, .{ a, b }) <= 0); | |
| 29 | 20 | } |
| 30 | 21 | |
| 31 | pub fn __aeabi_dcmpge() callconv(.Naked) noreturn { | |
| 22 | pub fn __aeabi_dcmpge(a: f64, b: f64) callconv(.AAPCS) i32 { | |
| 32 | 23 | @setRuntimeSafety(false); |
| 33 | @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Ge}); | |
| 34 | unreachable; | |
| 24 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparedf2.__gedf2, .{ a, b }) >= 0); | |
| 35 | 25 | } |
| 36 | 26 | |
| 37 | pub fn __aeabi_dcmpgt() callconv(.Naked) noreturn { | |
| 27 | pub fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.AAPCS) i32 { | |
| 38 | 28 | @setRuntimeSafety(false); |
| 39 | @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Gt}); | |
| 40 | unreachable; | |
| 41 | } | |
| 42 | ||
| 43 | fn aeabi_dcmp(comptime cond: ConditionalOperator) void { | |
| 44 | @setRuntimeSafety(false); | |
| 45 | asm volatile ( | |
| 46 | \\ push { r4, lr } | |
| 47 | ); | |
| 48 | ||
| 49 | switch (cond) { | |
| 50 | .Eq => asm volatile ( | |
| 51 | \\ bl __eqdf2 | |
| 52 | \\ cmp r0, #0 | |
| 53 | \\ beq 1f | |
| 54 | \\ movs r0, #0 | |
| 55 | \\ pop { r4, pc } | |
| 56 | \\ 1: | |
| 57 | ), | |
| 58 | .Lt => asm volatile ( | |
| 59 | \\ bl __ltdf2 | |
| 60 | \\ cmp r0, #0 | |
| 61 | \\ blt 1f | |
| 62 | \\ movs r0, #0 | |
| 63 | \\ pop { r4, pc } | |
| 64 | \\ 1: | |
| 65 | ), | |
| 66 | .Le => asm volatile ( | |
| 67 | \\ bl __ledf2 | |
| 68 | \\ cmp r0, #0 | |
| 69 | \\ ble 1f | |
| 70 | \\ movs r0, #0 | |
| 71 | \\ pop { r4, pc } | |
| 72 | \\ 1: | |
| 73 | ), | |
| 74 | .Ge => asm volatile ( | |
| 75 | \\ bl __ltdf2 | |
| 76 | \\ cmp r0, #0 | |
| 77 | \\ bge 1f | |
| 78 | \\ movs r0, #0 | |
| 79 | \\ pop { r4, pc } | |
| 80 | \\ 1: | |
| 81 | ), | |
| 82 | .Gt => asm volatile ( | |
| 83 | \\ bl __gtdf2 | |
| 84 | \\ cmp r0, #0 | |
| 85 | \\ bgt 1f | |
| 86 | \\ movs r0, #0 | |
| 87 | \\ pop { r4, pc } | |
| 88 | \\ 1: | |
| 89 | ), | |
| 90 | } | |
| 91 | asm volatile ( | |
| 92 | \\ movs r0, #1 | |
| 93 | \\ pop { r4, pc } | |
| 94 | ); | |
| 29 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparedf2.__gtdf2, .{ a, b }) > 0); | |
| 95 | 30 | } |
lib/std/special/compiler_rt/arm/aeabi_fcmp.zig+11-76| ... | ... | @@ -2,94 +2,29 @@ |
| 2 | 2 | // |
| 3 | 3 | // https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/arm/aeabi_fcmp.S |
| 4 | 4 | |
| 5 | const ConditionalOperator = enum { | |
| 6 | Eq, | |
| 7 | Lt, | |
| 8 | Le, | |
| 9 | Ge, | |
| 10 | Gt, | |
| 11 | }; | |
| 5 | const comparesf2 = @import("../comparesf2.zig"); | |
| 12 | 6 | |
| 13 | pub fn __aeabi_fcmpeq() callconv(.Naked) noreturn { | |
| 7 | pub fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 { | |
| 14 | 8 | @setRuntimeSafety(false); |
| 15 | @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Eq}); | |
| 16 | unreachable; | |
| 9 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparesf2.__eqsf2, .{ a, b }) == 0); | |
| 17 | 10 | } |
| 18 | 11 | |
| 19 | pub fn __aeabi_fcmplt() callconv(.Naked) noreturn { | |
| 12 | pub fn __aeabi_fcmplt(a: f32, b: f32) callconv(.AAPCS) i32 { | |
| 20 | 13 | @setRuntimeSafety(false); |
| 21 | @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Lt}); | |
| 22 | unreachable; | |
| 14 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparesf2.__ltsf2, .{ a, b }) < 0); | |
| 23 | 15 | } |
| 24 | 16 | |
| 25 | pub fn __aeabi_fcmple() callconv(.Naked) noreturn { | |
| 17 | pub fn __aeabi_fcmple(a: f32, b: f32) callconv(.AAPCS) i32 { | |
| 26 | 18 | @setRuntimeSafety(false); |
| 27 | @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Le}); | |
| 28 | unreachable; | |
| 19 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparesf2.__lesf2, .{ a, b }) <= 0); | |
| 29 | 20 | } |
| 30 | 21 | |
| 31 | pub fn __aeabi_fcmpge() callconv(.Naked) noreturn { | |
| 22 | pub fn __aeabi_fcmpge(a: f32, b: f32) callconv(.AAPCS) i32 { | |
| 32 | 23 | @setRuntimeSafety(false); |
| 33 | @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Ge}); | |
| 34 | unreachable; | |
| 24 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparesf2.__gesf2, .{ a, b }) >= 0); | |
| 35 | 25 | } |
| 36 | 26 | |
| 37 | pub fn __aeabi_fcmpgt() callconv(.Naked) noreturn { | |
| 27 | pub fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.AAPCS) i32 { | |
| 38 | 28 | @setRuntimeSafety(false); |
| 39 | @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Gt}); | |
| 40 | unreachable; | |
| 41 | } | |
| 42 | ||
| 43 | fn aeabi_fcmp(comptime cond: ConditionalOperator) void { | |
| 44 | @setRuntimeSafety(false); | |
| 45 | asm volatile ( | |
| 46 | \\ push { r4, lr } | |
| 47 | ); | |
| 48 | ||
| 49 | switch (cond) { | |
| 50 | .Eq => asm volatile ( | |
| 51 | \\ bl __eqsf2 | |
| 52 | \\ cmp r0, #0 | |
| 53 | \\ beq 1f | |
| 54 | \\ movs r0, #0 | |
| 55 | \\ pop { r4, pc } | |
| 56 | \\ 1: | |
| 57 | ), | |
| 58 | .Lt => asm volatile ( | |
| 59 | \\ bl __ltsf2 | |
| 60 | \\ cmp r0, #0 | |
| 61 | \\ blt 1f | |
| 62 | \\ movs r0, #0 | |
| 63 | \\ pop { r4, pc } | |
| 64 | \\ 1: | |
| 65 | ), | |
| 66 | .Le => asm volatile ( | |
| 67 | \\ bl __lesf2 | |
| 68 | \\ cmp r0, #0 | |
| 69 | \\ ble 1f | |
| 70 | \\ movs r0, #0 | |
| 71 | \\ pop { r4, pc } | |
| 72 | \\ 1: | |
| 73 | ), | |
| 74 | .Ge => asm volatile ( | |
| 75 | \\ bl __ltsf2 | |
| 76 | \\ cmp r0, #0 | |
| 77 | \\ bge 1f | |
| 78 | \\ movs r0, #0 | |
| 79 | \\ pop { r4, pc } | |
| 80 | \\ 1: | |
| 81 | ), | |
| 82 | .Gt => asm volatile ( | |
| 83 | \\ bl __gtsf2 | |
| 84 | \\ cmp r0, #0 | |
| 85 | \\ bgt 1f | |
| 86 | \\ movs r0, #0 | |
| 87 | \\ pop { r4, pc } | |
| 88 | \\ 1: | |
| 89 | ), | |
| 90 | } | |
| 91 | asm volatile ( | |
| 92 | \\ movs r0, #1 | |
| 93 | \\ pop { r4, pc } | |
| 94 | ); | |
| 29 | return @boolToInt(@call(.{ .modifier = .always_inline }, comparesf2.__gtsf2, .{ a, b }) > 0); | |
| 95 | 30 | } |