Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 1 | //===- subzero/runtime/szrt.c - Subzero runtime source ----------*- C++ -*-===// |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 10 | // This file implements wrappers for particular bitcode instructions |
| 11 | // that are too uncommon and complex for a particular target to bother |
| 12 | // implementing directly in Subzero target lowering. This needs to be |
| 13 | // compiled by some non-Subzero compiler. |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #include <stdint.h> |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 18 | |
Jim Stichnoth | a67fc44 | 2015-03-03 16:13:11 -0800 | [diff] [blame] | 19 | uint32_t __Sz_fptoui_f32_i32(float value) { return (uint32_t)value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 20 | |
Jim Stichnoth | a67fc44 | 2015-03-03 16:13:11 -0800 | [diff] [blame] | 21 | uint32_t __Sz_fptoui_f64_i32(double value) { return (uint32_t)value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 22 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 23 | uint64_t __Sz_fptoui_f32_i64(float Value) { return (uint64_t)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 24 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 25 | uint64_t __Sz_fptoui_f64_i64(double Value) { return (uint64_t)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 26 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 27 | int64_t __Sz_fptosi_f32_i64(float Value) { return (int64_t)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 28 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 29 | int64_t __Sz_fptosi_f64_i64(double Value) { return (int64_t)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 30 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 31 | float __Sz_uitofp_i32_f32(uint32_t Value) { return (float)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 32 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 33 | float __Sz_uitofp_i64_f32(uint64_t Value) { return (float)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 34 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 35 | double __Sz_uitofp_i32_f64(uint32_t Value) { return (double)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 36 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 37 | double __Sz_uitofp_i64_f64(uint64_t Value) { return (double)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 38 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 39 | float __Sz_sitofp_i64_f32(int64_t Value) { return (float)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 40 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 41 | double __Sz_sitofp_i64_f64(int64_t Value) { return (double)Value; } |
Jim Stichnoth | 10ea698 | 2014-09-09 11:19:12 -0700 | [diff] [blame] | 42 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 43 | // Other helper calls emitted by Subzero but not implemented here: |
| 44 | // Compiler-rt: |
Jan Voung | 6ec369e | 2015-06-30 11:03:15 -0700 | [diff] [blame] | 45 | // __udivsi3 - udiv i32 |
| 46 | // __divsi3 - sdiv i32 |
| 47 | // __umodsi3 - urem i32 |
| 48 | // __modsi3 - srem i32 |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 49 | // __udivdi3 - udiv i64 |
| 50 | // __divdi3 - sdiv i64 |
| 51 | // __umoddi3 - urem i64 |
| 52 | // __moddi3 - srem i64 |
| 53 | // __popcountsi2 - call @llvm.ctpop.i32 |
| 54 | // __popcountdi2 - call @llvm.ctpop.i64 |
| 55 | // libm: |
| 56 | // fmodf - frem f32 |
| 57 | // fmod - frem f64 |
| 58 | // libc: |
| 59 | // setjmp - call @llvm.nacl.setjmp |
| 60 | // longjmp - call @llvm.nacl.longjmp |
| 61 | // memcpy - call @llvm.memcpy.p0i8.p0i8.i32 |
| 62 | // memmove - call @llvm.memmove.p0i8.p0i8.i32 |
| 63 | // memset - call @llvm.memset.p0i8.i32 |
| 64 | // unsandboxed_irt: |
| 65 | // __nacl_read_tp |
John Porto | dc61925 | 2016-02-10 15:57:16 -0800 | [diff] [blame] | 66 | // __aeabi_read_tp [arm32 only] |
Jaydeep Patil | 71f6c8d | 2017-02-10 06:45:40 -0800 | [diff] [blame] | 67 | // MIPS runtime library: |
| 68 | // __sync_fetch_and_add_8 |
| 69 | // __sync_fetch_and_and_8 |
| 70 | // __sync_fetch_and_or_8 |
| 71 | // __sync_fetch_and_sub_8 |
| 72 | // __sync_fetch_and_xor_8 |
| 73 | // __sync_lock_test_and_set_8 |
| 74 | // __sync_val_compare_and_swap_8 |