1// 2// SPARC uses a different naming scheme for its support routines so we map it here to the x86 name. 3 4const std = @import("std"); 5const builtin = @import("builtin"); 6 7// The SPARC Architecture Manual, Version 9: 8// A.13 Floating-Point Compare 9const FCMP = enum(i32) { 10 Equal = 0, 11 Less = 1, 12 Greater = 2, 13 Unordered = 3, 14}; 15 16// Basic arithmetic 17 18pub fn _Qp_add(c: *f128, a: *f128, b: *f128) callconv(.C) void { 19 c.* = @import("addXf3.zig").__addtf3(a.*, b.*); 20} 21 22pub fn _Qp_div(c: *f128, a: *f128, b: *f128) callconv(.C) void { 23 c.* = @import("divtf3.zig").__divtf3(a.*, b.*); 24} 25 26pub fn _Qp_mul(c: *f128, a: *f128, b: *f128) callconv(.C) void { 27 c.* = @import("mulXf3.zig").__multf3(a.*, b.*); 28} 29 30pub fn _Qp_sub(c: *f128, a: *f128, b: *f128) callconv(.C) void { 31 c.* = @import("addXf3.zig").__subtf3(a.*, b.*); 32} 33 34// Comparison 35 36pub fn _Qp_cmp(a: *f128, b: *f128) callconv(.C) i32 { 37 return @enumToInt(@import("compareXf2.zig").cmp(f128, FCMP, a.*, b.*)); 38} 39 40pub fn _Qp_feq(a: *f128, b: *f128) callconv(.C) bool { 41 return _Qp_cmp(a, b) == @enumToInt(FCMP.Equal); 42} 43 44pub fn _Qp_fne(a: *f128, b: *f128) callconv(.C) bool { 45 return _Qp_cmp(a, b) != @enumToInt(FCMP.Equal); 46} 47 48pub fn _Qp_flt(a: *f128, b: *f128) callconv(.C) bool { 49 return _Qp_cmp(a, b) == @enumToInt(FCMP.Less); 50} 51 52pub fn _Qp_fle(a: *f128, b: *f128) callconv(.C) bool { 53 const cmp = _Qp_cmp(a, b); 54 return cmp == @enumToInt(FCMP.Less) or cmp == @enumToInt(FCMP.Equal); 55} 56 57pub fn _Qp_fgt(a: *f128, b: *f128) callconv(.C) bool { 58 return _Qp_cmp(a, b) == @enumToInt(FCMP.Greater); 59} 60 61pub fn _Qp_fge(a: *f128, b: *f128) callconv(.C) bool { 62 const cmp = _Qp_cmp(a, b); 63 return cmp == @enumToInt(FCMP.Greater) or cmp == @enumToInt(FCMP.Equal); 64} 65 66// Conversion 67 68pub fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void { 69 c.* = @import("floatsiXf.zig").__floatsitf(a); 70} 71 72pub fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void { 73 c.* = @import("floatunsitf.zig").__floatunsitf(a); 74} 75 76pub fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void { 77 c.* = @import("floatditf.zig").__floatditf(a); 78} 79 80pub fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void { 81 c.* = @import("floatunditf.zig").__floatunditf(a); 82} 83 84pub fn _Qp_stoq(c: *f128, a: f32) callconv(.C) void { 85 c.* = @import("extendXfYf2.zig").__extendsftf2(a); 86} 87 88pub fn _Qp_dtoq(c: *f128, a: f64) callconv(.C) void { 89 c.* = @import("extendXfYf2.zig").__extenddftf2(a); 90} 91 92pub fn _Qp_qtoi(a: *f128) callconv(.C) i32 { 93 return @import("fixtfsi.zig").__fixtfsi(a.*); 94} 95 96pub fn _Qp_qtoui(a: *f128) callconv(.C) u32 { 97 return @import("fixunstfsi.zig").__fixunstfsi(a.*); 98} 99 100pub fn _Qp_qtox(a: *f128) callconv(.C) i64 { 101 return @import("fixtfdi.zig").__fixtfdi(a.*); 102} 103 104pub fn _Qp_qtoux(a: *f128) callconv(.C) u64 { 105 return @import("fixunstfdi.zig").__fixunstfdi(a.*); 106} 107 108pub fn _Qp_qtos(a: *f128) callconv(.C) f32 { 109 return @import("truncXfYf2.zig").__trunctfsf2(a.*); 110} 111 112pub fn _Qp_qtod(a: *f128) callconv(.C) f64 { 113 return @import("truncXfYf2.zig").__trunctfdf2(a.*); 114} 115