Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: runtime/szrt.c

Issue 961413002: Subzero: Clean up the runtime implementation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Change static helper strings to be char* instead of IceString Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pydir/build-runtime.py ('k') | runtime/szrt_ll.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <stdlib.h>
19 18
20 // TODO(stichnot): The various NaN cross tests try to map Subzero's 19 // TODO(stichnot): The various NaN cross tests try to map Subzero's
21 // undefined behavior to the same as llc's undefined behavior, as 20 // undefined behavior to the same as llc's undefined behavior, as
22 // observed by the cross tests. This will have to be kept up to date 21 // observed by the cross tests. This will have to be kept up to date
23 // with any future changes to llc, and may also have to be different 22 // with any future changes to llc, and may also have to be different
24 // for different targets. It would be better to find a more 23 // for different targets. It would be better to find a more
25 // appropriate set of llc options when building the Subzero runtime. 24 // appropriate set of llc options when building the Subzero runtime.
26 // 25 //
27 // We test for NaN using "value==value" instead of using isnan(value) 26 // We test for NaN using "Value==Value" instead of using isnan(Value)
28 // to avoid an external dependency on fpclassify(). 27 // to avoid an external dependency on fpclassify().
29 28
30 uint32_t cvtftoui32(float value) { 29 uint32_t __Sz_fptoui_f32_i32(float Value) {
31 if (value == value) // NaNaN 30 if (Value == Value) // NaNaN
32 return (uint32_t)value; 31 return (uint32_t)Value;
33 return 0x80000000; 32 return 0x80000000;
34 } 33 }
35 34
36 uint32_t cvtdtoui32(double value) { 35 uint32_t __Sz_fptoui_f64_i32(double Value) {
37 if (value == value) // NaNaN 36 if (Value == Value) // NaNaN
38 return (uint32_t)value; 37 return (uint32_t)Value;
39 return 0x80000000; 38 return 0x80000000;
40 } 39 }
41 40
42 int64_t cvtftosi64(float value) { return (int64_t)value; } 41 uint64_t __Sz_fptoui_f32_i64(float Value) { return (uint64_t)Value; }
43 42
44 int64_t cvtdtosi64(double value) { return (int64_t)value; } 43 uint64_t __Sz_fptoui_f64_i64(double Value) { return (uint64_t)Value; }
45 44
46 uint64_t cvtftoui64(float value) { return (uint64_t)value; } 45 int64_t __Sz_fptosi_f32_i64(float Value) { return (int64_t)Value; }
47 46
48 uint64_t cvtdtoui64(double value) { return (uint64_t)value; } 47 int64_t __Sz_fptosi_f64_i64(double Value) { return (int64_t)Value; }
49 48
50 float cvtui32tof(uint32_t value) { return (float)value; } 49 float __Sz_uitofp_i32_f32(uint32_t Value) { return (float)Value; }
51 50
52 float cvtsi64tof(int64_t value) { return (float)value; } 51 float __Sz_uitofp_i64_f32(uint64_t Value) { return (float)Value; }
53 52
54 float cvtui64tof(uint64_t value) { return (float)value; } 53 double __Sz_uitofp_i32_f64(uint32_t Value) { return (double)Value; }
55 54
56 double cvtui32tod(uint32_t value) { return (double)value; } 55 double __Sz_uitofp_i64_f64(uint64_t Value) { return (double)Value; }
57 56
58 double cvtsi64tod(int64_t value) { return (double)value; } 57 float __Sz_sitofp_i64_f32(int64_t Value) { return (float)Value; }
59 58
60 double cvtui64tod(uint64_t value) { return (double)value; } 59 double __Sz_sitofp_i64_f64(int64_t Value) { return (double)Value; }
61 60
62 /* TODO(stichnot): 61 // Other helper calls emitted by Subzero but not implemented here:
63 Sz_bitcast_v8i1_to_i8 62 // Compiler-rt:
64 Sz_bitcast_v16i1_to_i16 63 // __udivdi3 - udiv i64
65 Sz_bitcast_i8_to_v8i1 64 // __divdi3 - sdiv i64
66 Sz_bitcast_i16_to_v16i1 65 // __umoddi3 - urem i64
67 */ 66 // __moddi3 - srem i64
67 // __popcountsi2 - call @llvm.ctpop.i32
68 // __popcountdi2 - call @llvm.ctpop.i64
69 // libm:
70 // fmodf - frem f32
71 // fmod - frem f64
72 // libc:
73 // setjmp - call @llvm.nacl.setjmp
74 // longjmp - call @llvm.nacl.longjmp
75 // memcpy - call @llvm.memcpy.p0i8.p0i8.i32
76 // memmove - call @llvm.memmove.p0i8.p0i8.i32
77 // memset - call @llvm.memset.p0i8.i32
78 // unsandboxed_irt:
79 // __nacl_read_tp
OLDNEW
« no previous file with comments | « pydir/build-runtime.py ('k') | runtime/szrt_ll.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698