| author | |
| committer | |
| log | 1f65828ec6caa7697b26d9e919112aa1715b57bc |
| tree | 73b67b9da631827bedf11127960a35c6ace161ae |
| parent | d2a297c2b3eb293b393f41640892ff7a5a71027f |
| parent | 1d67ab8823f417bba38f7a32c45912f8e8de393b |
| signature | Signed by PGP key 4AEE18F83AFDEB23 |
stage1: SPARCv9 f128 enablement3 files changed, 114 insertions(+), 5 deletions(-)
lib/std/special/compiler_rt.zig+19| ... | ... | @@ -277,6 +277,25 @@ comptime { |
| 277 | 277 | @export(@import("compiler_rt/aullrem.zig")._aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage }); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | if (builtin.arch.isSPARC()) { | |
| 281 | // SPARC systems use a different naming scheme | |
| 282 | @export(@import("compiler_rt/sparc.zig")._Qp_add, .{ .name = "_Qp_add", .linkage = linkage }); | |
| 283 | @export(@import("compiler_rt/sparc.zig")._Qp_div, .{ .name = "_Qp_div", .linkage = linkage }); | |
| 284 | @export(@import("compiler_rt/sparc.zig")._Qp_mul, .{ .name = "_Qp_mul", .linkage = linkage }); | |
| 285 | @export(@import("compiler_rt/sparc.zig")._Qp_sub, .{ .name = "_Qp_sub", .linkage = linkage }); | |
| 286 | ||
| 287 | @export(@import("compiler_rt/sparc.zig")._Qp_cmp, .{ .name = "_Qp_cmp", .linkage = linkage }); | |
| 288 | @export(@import("compiler_rt/sparc.zig")._Qp_feq, .{ .name = "_Qp_feq", .linkage = linkage }); | |
| 289 | @export(@import("compiler_rt/sparc.zig")._Qp_fne, .{ .name = "_Qp_fne", .linkage = linkage }); | |
| 290 | @export(@import("compiler_rt/sparc.zig")._Qp_flt, .{ .name = "_Qp_flt", .linkage = linkage }); | |
| 291 | @export(@import("compiler_rt/sparc.zig")._Qp_fle, .{ .name = "_Qp_fle", .linkage = linkage }); | |
| 292 | @export(@import("compiler_rt/sparc.zig")._Qp_fgt, .{ .name = "_Qp_fgt", .linkage = linkage }); | |
| 293 | @export(@import("compiler_rt/sparc.zig")._Qp_fge, .{ .name = "_Qp_fge", .linkage = linkage }); | |
| 294 | ||
| 295 | @export(@import("compiler_rt/sparc.zig")._Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = linkage }); | |
| 296 | @export(@import("compiler_rt/sparc.zig")._Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage }); | |
| 297 | } | |
| 298 | ||
| 280 | 299 | if (builtin.os.tag == .windows) { |
| 281 | 300 | // Default stack-probe functions emitted by LLVM |
| 282 | 301 | if (is_mingw) { |
lib/std/special/compiler_rt/sparc.zig created+80| ... | ... | @@ -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 | } |
src/stage1/codegen.cpp+15-5| ... | ... | @@ -19,6 +19,7 @@ |
| 19 | 19 | #include "stage2.h" |
| 20 | 20 | #include "dump_analysis.hpp" |
| 21 | 21 | #include "softfloat.hpp" |
| 22 | #include "zigendian.h" | |
| 22 | 23 | |
| 23 | 24 | #include <stdio.h> |
| 24 | 25 | #include <errno.h> |
| ... | ... | @@ -7421,11 +7422,20 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n |
| 7421 | 7422 | return LLVMConstReal(get_llvm_type(g, type_entry), const_val->data.x_f64); |
| 7422 | 7423 | case 128: |
| 7423 | 7424 | { |
| 7424 | // TODO make sure this is correct on big endian targets too | |
| 7425 | uint8_t buf[16]; | |
| 7426 | memcpy(buf, &const_val->data.x_f128, 16); | |
| 7427 | LLVMValueRef as_int = LLVMConstIntOfArbitraryPrecision(LLVMInt128Type(), 2, | |
| 7428 | (uint64_t*)buf); | |
| 7425 | uint64_t buf[2]; | |
| 7426 | ||
| 7427 | // LLVM seems to require that the lower half of the f128 be placed first in the buffer. | |
| 7428 | #if defined(ZIG_BYTE_ORDER) && ZIG_BYTE_ORDER == ZIG_LITTLE_ENDIAN | |
| 7429 | buf[0] = const_val->data.x_f128.v[0]; | |
| 7430 | buf[1] = const_val->data.x_f128.v[1]; | |
| 7431 | #elif defined(ZIG_BYTE_ORDER) && ZIG_BYTE_ORDER == ZIG_BIG_ENDIAN | |
| 7432 | buf[0] = const_val->data.x_f128.v[1]; | |
| 7433 | buf[1] = const_val->data.x_f128.v[0]; | |
| 7434 | #else | |
| 7435 | #error Unsupported endian | |
| 7436 | #endif | |
| 7437 | ||
| 7438 | LLVMValueRef as_int = LLVMConstIntOfArbitraryPrecision(LLVMInt128Type(), 2, buf); | |
| 7429 | 7439 | return LLVMConstBitCast(as_int, get_llvm_type(g, type_entry)); |
| 7430 | 7440 | } |
| 7431 | 7441 | default: |