| OLD | NEW |
| 1 //===- subzero/runtime/szrt.c - Subzero runtime source ----------*- C++ -*-===// | 1 //===- subzero/runtime/szrt.c - Subzero runtime source ----------*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file implements wrappers for particular bitcode instructions | 10 // This file implements wrappers for particular bitcode instructions |
| 11 // that are too uncommon and complex for a particular target to bother | 11 // that are too uncommon and complex for a particular target to bother |
| 12 // implementing directly in Subzero target lowering. This needs to be | 12 // implementing directly in Subzero target lowering. This needs to be |
| 13 // compiled by some non-Subzero compiler. | 13 // compiled by some non-Subzero compiler. |
| 14 // | 14 // |
| 15 //===----------------------------------------------------------------------===// | 15 //===----------------------------------------------------------------------===// |
| 16 | 16 |
| 17 #include <stdint.h> | 17 #include <stdint.h> |
| 18 | 18 |
| 19 // TODO(stichnot): The various NaN cross tests try to map Subzero's | 19 uint32_t __Sz_fptoui_f32_i32(float value) { return (uint32_t)value; } |
| 20 // undefined behavior to the same as llc's undefined behavior, as | |
| 21 // observed by the cross tests. This will have to be kept up to date | |
| 22 // with any future changes to llc, and may also have to be different | |
| 23 // for different targets. It would be better to find a more | |
| 24 // appropriate set of llc options when building the Subzero runtime. | |
| 25 // | |
| 26 // We test for NaN using "Value==Value" instead of using isnan(Value) | |
| 27 // to avoid an external dependency on fpclassify(). | |
| 28 | 20 |
| 29 uint32_t __Sz_fptoui_f32_i32(float Value) { | 21 uint32_t __Sz_fptoui_f64_i32(double value) { return (uint32_t)value; } |
| 30 if (Value == Value) // NaNaN | |
| 31 return (uint32_t)Value; | |
| 32 return 0x80000000; | |
| 33 } | |
| 34 | |
| 35 uint32_t __Sz_fptoui_f64_i32(double Value) { | |
| 36 if (Value == Value) // NaNaN | |
| 37 return (uint32_t)Value; | |
| 38 return 0x80000000; | |
| 39 } | |
| 40 | 22 |
| 41 uint64_t __Sz_fptoui_f32_i64(float Value) { return (uint64_t)Value; } | 23 uint64_t __Sz_fptoui_f32_i64(float Value) { return (uint64_t)Value; } |
| 42 | 24 |
| 43 uint64_t __Sz_fptoui_f64_i64(double Value) { return (uint64_t)Value; } | 25 uint64_t __Sz_fptoui_f64_i64(double Value) { return (uint64_t)Value; } |
| 44 | 26 |
| 45 int64_t __Sz_fptosi_f32_i64(float Value) { return (int64_t)Value; } | 27 int64_t __Sz_fptosi_f32_i64(float Value) { return (int64_t)Value; } |
| 46 | 28 |
| 47 int64_t __Sz_fptosi_f64_i64(double Value) { return (int64_t)Value; } | 29 int64_t __Sz_fptosi_f64_i64(double Value) { return (int64_t)Value; } |
| 48 | 30 |
| 49 float __Sz_uitofp_i32_f32(uint32_t Value) { return (float)Value; } | 31 float __Sz_uitofp_i32_f32(uint32_t Value) { return (float)Value; } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 70 // fmodf - frem f32 | 52 // fmodf - frem f32 |
| 71 // fmod - frem f64 | 53 // fmod - frem f64 |
| 72 // libc: | 54 // libc: |
| 73 // setjmp - call @llvm.nacl.setjmp | 55 // setjmp - call @llvm.nacl.setjmp |
| 74 // longjmp - call @llvm.nacl.longjmp | 56 // longjmp - call @llvm.nacl.longjmp |
| 75 // memcpy - call @llvm.memcpy.p0i8.p0i8.i32 | 57 // memcpy - call @llvm.memcpy.p0i8.p0i8.i32 |
| 76 // memmove - call @llvm.memmove.p0i8.p0i8.i32 | 58 // memmove - call @llvm.memmove.p0i8.p0i8.i32 |
| 77 // memset - call @llvm.memset.p0i8.i32 | 59 // memset - call @llvm.memset.p0i8.i32 |
| 78 // unsandboxed_irt: | 60 // unsandboxed_irt: |
| 79 // __nacl_read_tp | 61 // __nacl_read_tp |
| OLD | NEW |