aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-01-30 16:09:45 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-01-30 16:09:45 -0800
commit991649f01d1c32a6be57e77be64dd83c8787b59f (patch)
tree0e6a2dc633d1d1257ad7feafea8fff5cd58931fc
parentc707fc8a860649099ba475a61aa1f8c8203774f4 (diff)
support bitcasts of doubles to i64s in i64 mode 1
-rw-r--r--src/parseTools.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index cc59f150..38467270 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1687,7 +1687,20 @@ function processMathop(item) {
case 'sdiv': case 'udiv': warnI64_1(); return splitI64(makeRounding(mergeI64(ident1) + '/' + mergeI64(ident2), bits, op[0] === 's'));
case 'mul': warnI64_1(); return handleOverflow(splitI64(mergeI64(ident1) + '*' + mergeI64(ident2)), bits);
case 'urem': case 'srem': warnI64_1(); return splitI64(mergeI64(ident1) + '%' + mergeI64(ident2));
- default: throw 'Unsupported i64 mode 1 op: ' + item.op;
+ case 'bitcast': {
+ // Pointers are not 64-bit, so there is really only one possible type of bitcast here, int to float or vice versa
+ assert(USE_TYPED_ARRAYS == 2, 'Can only bitcast ints <-> floats with typed arrays mode 2');
+ var inType = item.param1.type;
+ var outType = item.type;
+ if (inType in Runtime.INT_TYPES && outType in Runtime.FLOAT_TYPES) {
+ return makeInlineCalculation('tempDoubleI32[0]=VALUE[0],tempDoubleI32[1]=VALUE[1],tempDoubleF64[0]', ident1, 'tempI64');
+ } else if (inType in Runtime.FLOAT_TYPES && outType in Runtime.INT_TYPES) {
+ return '(tempDoubleF64[0]=' + ident1 + ',[tempDoubleI32[0],tempDoubleI32[1]])';
+ } else {
+ throw 'Invalid I64_MODE1 bitcast: ' + dump(item) + ' : ' + item.param1.type;
+ }
+ }
+ default: throw 'Unsupported i64 mode 1 op: ' + item.op + ' : ' + dump(item);
}
}
@@ -1822,7 +1835,7 @@ function processMathop(item) {
if ((inType in Runtime.INT_TYPES && outType in Runtime.FLOAT_TYPES) ||
(inType in Runtime.FLOAT_TYPES && outType in Runtime.INT_TYPES)) {
assert(USE_TYPED_ARRAYS == 2, 'Can only bitcast ints <-> floats with typed arrays mode 2');
- assert(inType == 'i32' || inType == 'float', 'Can only bitcast ints <-> floats with 32 bits, for now');
+ assert(inType == 'i32' || inType == 'float', 'Can only bitcast ints <-> floats with 32 bits (try I64_MODE=1)');
if (inType in Runtime.INT_TYPES) {
return '(tempDoubleI32[0] = ' + ident1 + ',tempDoubleF32[0])';
} else {