| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | // SPDX-License-Identifier: MIT |
| 2 | // Copyright (c) 2015-2020 Zig Contributors |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. |
| 6 | // |
| 7 | // SPARC uses a different naming scheme for its support routines so we map it here to the x86 name. |
| 8 | |
| 9 | const std = @import("std"); |
| 10 | const builtin = @import("builtin"); |
| 11 | |
| 12 | // The SPARC Architecture Manual, Version 9: |
| 13 | // A.13 Floating-Point Compare |
| 14 | const FCMP = extern enum(i32) { |
| 15 | Equal = 0, |
| 16 | Less = 1, |
| 17 | Greater = 2, |
| 18 | Unordered = 3, |
| 19 | }; |
| 20 | |
| 21 | // Basic arithmetic |
| 22 | |
| 23 | pub fn _Qp_add(c: *f128, a: *f128, b: *f128) callconv(.C) void { |
| 24 | c.* = @import("addXf3.zig").__addtf3(a.*, b.*); |
| 25 | } |
| 26 | |
| 27 | pub fn _Qp_div(c: *f128, a: *f128, b: *f128) callconv(.C) void { |
| 28 | c.* = @import("divtf3.zig").__divtf3(a.*, b.*); |
| 29 | } |
| 30 | |
| 31 | pub fn _Qp_mul(c: *f128, a: *f128, b: *f128) callconv(.C) void { |
| 32 | c.* = @import("mulXf3.zig").__multf3(a.*, b.*); |
| 33 | } |
| 34 | |
| 35 | pub fn _Qp_sub(c: *f128, a: *f128, b: *f128) callconv(.C) void { |
| 36 | c.* = @import("addXf3.zig").__subtf3(a.*, b.*); |
| 37 | } |
| 38 | |
| 39 | // Comparison |
| 40 | |
| 41 | pub fn _Qp_cmp(a: f128, b: f128) callconv(.C) i32 { |
| 42 | return @enumToInt(@import("compareXf2.zig").cmp(f128, FCMP, a, b)); |
| 43 | } |
| 44 | |
| 45 | pub fn _Qp_feq(a: *f128, b: *f128) callconv(.C) bool { |
| 46 | return _Qp_cmp(a.*, b.*) == @enumToInt(FCMP.Equal); |
| 47 | } |
| 48 | |
| 49 | pub fn _Qp_fne(a: *f128, b: *f128) callconv(.C) bool { |
| 50 | return _Qp_cmp(a.*, b.*) != @enumToInt(FCMP.Equal); |
| 51 | } |
| 52 | |
| 53 | pub fn _Qp_flt(a: *f128, b: *f128) callconv(.C) bool { |
| 54 | return _Qp_cmp(a.*, b.*) == @enumToInt(FCMP.Less); |
| 55 | } |
| 56 | |
| 57 | pub fn _Qp_fle(a: *f128, b: *f128) callconv(.C) bool { |
| 58 | const cmp = _Qp_cmp(a.*, b.*); |
| 59 | return cmp == @enumToInt(FCMP.Less) or cmp == @enumToInt(FCMP.Equal); |
| 60 | } |
| 61 | |
| 62 | pub fn _Qp_fgt(a: *f128, b: *f128) callconv(.C) bool { |
| 63 | return _Qp_cmp(a.*, b.*) == @enumToInt(FCMP.Greater); |
| 64 | } |
| 65 | |
| 66 | pub fn _Qp_fge(a: *f128, b: *f128) callconv(.C) bool { |
| 67 | const cmp = _Qp_cmp(a.*, b.*); |
| 68 | return cmp == @enumToInt(FCMP.Greater) or cmp == @enumToInt(FCMP.Equal); |
| 69 | } |
| 70 | |
| 71 | |
| 72 | // Casting |
| 73 | |
| 74 | pub fn _Qp_dtoq(c: *f128, a: f64) callconv(.C) void { |
| 75 | c.* = @import("extendXfYf2.zig").__extenddftf2(a); |
| 76 | } |
| 77 | |
| 78 | pub fn _Qp_qtod(a: *f128) callconv(.C) f64 { |
| 79 | return @import("truncXfYf2.zig").__trunctfdf2(a.*); |
| 80 | } |