Subzero: Update tests and build scripts for sandboxing.

Spec2k now runs sandboxed, using all filetypes (asm, iasm, obj).

The new build-runtime.py script builds the native and sandboxed runtimes in build/runtime/ .  The various Subzero driver scripts are updated to use that.

Fixes a stack frame bug in sandboxed mode when the integrated assembler is used.  The stack adjustment for setting up a function call wasn't being rolled back for the second emitIAS() pass, so stack variables passed as arguments to the callee were being copied from the wrong stack slot.

Notes:

1. The hybrid Subzero/llc bisection debugging builds probably do not work as intended for -filetype=obj since the ELF emitter doesn't yet support -ffunction-sections.  (This was also true for non-sandboxed hybrid builds.)

2. The cross tests have not yet been adapted for testing sandboxing.  I'd prefer to first make progress on https://code.google.com/p/nativeclient/issues/detail?id=4085 in order to avoid blindly doubling the number of tests.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4079
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/944333002
diff --git a/runtime/szrt.c b/runtime/szrt.c
index 4721758..8e094bc 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 cvtdtoui32(double value) { return (uint32_t)value; }
+uint32_t cvtftoui32(float value) {
+  if (value == value) // NaNaN
+    return (uint32_t)value;
+  return 0x80000000;
+}
+
+uint32_t cvtdtoui32(double value) {
+  if (value == value) // NaNaN
+    return (uint32_t)value;
+  return 0x80000000;
+}
 
 int64_t cvtftosi64(float value) { return (int64_t)value; }