@@ -1687,7 +1687,20 @@ function processMathop(item) {
1687
1687
case 'sdiv' : case 'udiv' : warnI64_1 ( ) ; return splitI64 ( makeRounding ( mergeI64 ( ident1 ) + '/' + mergeI64 ( ident2 ) , bits , op [ 0 ] === 's' ) ) ;
1688
1688
case 'mul' : warnI64_1 ( ) ; return handleOverflow ( splitI64 ( mergeI64 ( ident1 ) + '*' + mergeI64 ( ident2 ) ) , bits ) ;
1689
1689
case 'urem' : case 'srem' : warnI64_1 ( ) ; return splitI64 ( mergeI64 ( ident1 ) + '%' + mergeI64 ( ident2 ) ) ;
1690
- default : throw 'Unsupported i64 mode 1 op: ' + item . op ;
1690
+ case 'bitcast' : {
1691
+ // Pointers are not 64-bit, so there is really only one possible type of bitcast here, int to float or vice versa
1692
+ assert ( USE_TYPED_ARRAYS == 2 , 'Can only bitcast ints <-> floats with typed arrays mode 2' ) ;
1693
+ var inType = item . param1 . type ;
1694
+ var outType = item . type ;
1695
+ if ( inType in Runtime . INT_TYPES && outType in Runtime . FLOAT_TYPES ) {
1696
+ return makeInlineCalculation ( 'tempDoubleI32[0]=VALUE[0],tempDoubleI32[1]=VALUE[1],tempDoubleF64[0]' , ident1 , 'tempI64' ) ;
1697
+ } else if ( inType in Runtime . FLOAT_TYPES && outType in Runtime . INT_TYPES ) {
1698
+ return '(tempDoubleF64[0]=' + ident1 + ',[tempDoubleI32[0],tempDoubleI32[1]])' ;
1699
+ } else {
1700
+ throw 'Invalid I64_MODE1 bitcast: ' + dump ( item ) + ' : ' + item . param1 . type ;
1701
+ }
1702
+ }
1703
+ default : throw 'Unsupported i64 mode 1 op: ' + item . op + ' : ' + dump ( item ) ;
1691
1704
}
1692
1705
}
1693
1706
@@ -1822,7 +1835,7 @@ function processMathop(item) {
1822
1835
if ( ( inType in Runtime . INT_TYPES && outType in Runtime . FLOAT_TYPES ) ||
1823
1836
( inType in Runtime . FLOAT_TYPES && outType in Runtime . INT_TYPES ) ) {
1824
1837
assert ( USE_TYPED_ARRAYS == 2 , 'Can only bitcast ints <-> floats with typed arrays mode 2' ) ;
1825
- assert ( inType == 'i32' || inType == 'float' , 'Can only bitcast ints <-> floats with 32 bits, for now ' ) ;
1838
+ assert ( inType == 'i32' || inType == 'float' , 'Can only bitcast ints <-> floats with 32 bits (try I64_MODE=1) ' ) ;
1826
1839
if ( inType in Runtime . INT_TYPES ) {
1827
1840
return '(tempDoubleI32[0] = ' + ident1 + ',tempDoubleF32[0])' ;
1828
1841
} else {
0 commit comments