zig/lib/compiler_rt/sparc.zig
Andrew Kelley ec95e00e28 flatten lib/std/special and improve "pkg inside another" logic
stage2: change logic for detecting whether the main package is inside
the std package. Previously it relied on realpath() which is not portable.
This uses resolve() which is how imports already work.

 * stage2: fix cleanup bug when creating Module
 * flatten lib/std/special/* to lib/*
   - this was motivated by making main_pkg_is_inside_std false for
     compiler_rt & friends.
 * rename "mini libc" to "universal libc"
2022-05-06 22:41:00 -07:00

115 lines
3.0 KiB
Zig

//
// SPARC uses a different naming scheme for its support routines so we map it here to the x86 name.
const std = @import("std");
const builtin = @import("builtin");
// The SPARC Architecture Manual, Version 9:
// A.13 Floating-Point Compare
const FCMP = enum(i32) {
Equal = 0,
Less = 1,
Greater = 2,
Unordered = 3,
};
// Basic arithmetic
pub fn _Qp_add(c: *f128, a: *f128, b: *f128) callconv(.C) void {
c.* = @import("addXf3.zig").__addtf3(a.*, b.*);
}
pub fn _Qp_div(c: *f128, a: *f128, b: *f128) callconv(.C) void {
c.* = @import("divtf3.zig").__divtf3(a.*, b.*);
}
pub fn _Qp_mul(c: *f128, a: *f128, b: *f128) callconv(.C) void {
c.* = @import("mulXf3.zig").__multf3(a.*, b.*);
}
pub fn _Qp_sub(c: *f128, a: *f128, b: *f128) callconv(.C) void {
c.* = @import("addXf3.zig").__subtf3(a.*, b.*);
}
// Comparison
pub fn _Qp_cmp(a: *f128, b: *f128) callconv(.C) i32 {
return @enumToInt(@import("compareXf2.zig").cmp(f128, FCMP, a.*, b.*));
}
pub fn _Qp_feq(a: *f128, b: *f128) callconv(.C) bool {
return _Qp_cmp(a, b) == @enumToInt(FCMP.Equal);
}
pub fn _Qp_fne(a: *f128, b: *f128) callconv(.C) bool {
return _Qp_cmp(a, b) != @enumToInt(FCMP.Equal);
}
pub fn _Qp_flt(a: *f128, b: *f128) callconv(.C) bool {
return _Qp_cmp(a, b) == @enumToInt(FCMP.Less);
}
pub fn _Qp_fle(a: *f128, b: *f128) callconv(.C) bool {
const cmp = _Qp_cmp(a, b);
return cmp == @enumToInt(FCMP.Less) or cmp == @enumToInt(FCMP.Equal);
}
pub fn _Qp_fgt(a: *f128, b: *f128) callconv(.C) bool {
return _Qp_cmp(a, b) == @enumToInt(FCMP.Greater);
}
pub fn _Qp_fge(a: *f128, b: *f128) callconv(.C) bool {
const cmp = _Qp_cmp(a, b);
return cmp == @enumToInt(FCMP.Greater) or cmp == @enumToInt(FCMP.Equal);
}
// Conversion
pub fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void {
c.* = @import("floatXiYf.zig").__floatsitf(a);
}
pub fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void {
c.* = @import("floatXiYf.zig").__floatunsitf(a);
}
pub fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void {
c.* = @import("floatXiYf.zig").__floatditf(a);
}
pub fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void {
c.* = @import("floatXiYf.zig").__floatunditf(a);
}
pub fn _Qp_stoq(c: *f128, a: f32) callconv(.C) void {
c.* = @import("extendXfYf2.zig").__extendsftf2(a);
}
pub fn _Qp_dtoq(c: *f128, a: f64) callconv(.C) void {
c.* = @import("extendXfYf2.zig").__extenddftf2(a);
}
pub fn _Qp_qtoi(a: *f128) callconv(.C) i32 {
return @import("fixXfYi.zig").__fixtfsi(a.*);
}
pub fn _Qp_qtoui(a: *f128) callconv(.C) u32 {
return @import("fixXfYi.zig").__fixunstfsi(a.*);
}
pub fn _Qp_qtox(a: *f128) callconv(.C) i64 {
return @import("fixXfYi.zig").__fixtfdi(a.*);
}
pub fn _Qp_qtoux(a: *f128) callconv(.C) u64 {
return @import("fixXfYi.zig").__fixunstfdi(a.*);
}
pub fn _Qp_qtos(a: *f128) callconv(.C) f32 {
return @import("truncXfYf2.zig").__trunctfsf2(a.*);
}
pub fn _Qp_qtod(a: *f128) callconv(.C) f64 {
return @import("truncXfYf2.zig").__trunctfdf2(a.*);
}