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

Unified Diff: runtime/szrt.c

Issue 944333002: Subzero: Update tests and build scripts for sandboxing. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: More code review changes Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pydir/szbuild_spec2k.py ('k') | runtime/szrt.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/szrt.c
diff --git a/runtime/szrt.c b/runtime/szrt.c
index 472175860b7bb1ea8c33f6c8973b7150038252b4..8e094bc58a19c556860aa047053a208bd6b5a74f 100644
--- a/runtime/szrt.c
+++ b/runtime/szrt.c
@@ -7,17 +7,37 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the runtime helper routines that are needed by
-// Subzero. This needs to be compiled by some non-Subzero compiler.
+// This file implements wrappers for particular bitcode instructions
+// that are too uncommon and complex for a particular target to bother
+// implementing directly in Subzero target lowering. This needs to be
+// compiled by some non-Subzero compiler.
//
//===----------------------------------------------------------------------===//
#include <stdint.h>
#include <stdlib.h>
-uint32_t cvtftoui32(float value) { return (uint32_t)value; }
+// TODO(stichnot): The various NaN cross tests try to map Subzero's
+// undefined behavior to the same as llc's undefined behavior, as
+// observed by the cross tests. This will have to be kept up to date
+// with any future changes to llc, and may also have to be different
+// for different targets. It would be better to find a more
+// appropriate set of llc options when building the Subzero runtime.
+//
+// We test for NaN using "value==value" instead of using isnan(value)
+// to avoid an external dependency on fpclassify().
+
+uint32_t cvtftoui32(float value) {
+ if (value == value) // NaNaN
+ return (uint32_t)value;
+ return 0x80000000;
+}
-uint32_t cvtdtoui32(double value) { return (uint32_t)value; }
+uint32_t cvtdtoui32(double value) {
+ if (value == value) // NaNaN
+ return (uint32_t)value;
+ return 0x80000000;
+}
int64_t cvtftosi64(float value) { return (int64_t)value; }
« no previous file with comments | « pydir/szbuild_spec2k.py ('k') | runtime/szrt.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698