diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-08-11 21:57:15 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-08-11 21:57:15 -0700 |
commit | 8cb83003709aa90a3410b6352552342ec97d5116 (patch) | |
tree | 1b8cb216f7f9bc3b2bba5799e1d8261b28b6513b /src/parseTools.js | |
parent | 5bb74d2c5ed57a7b52e1a3d01404edfb7a9945ea (diff) |
experimental toFloat32 option
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index b655d13e..f11c867a 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -2020,6 +2020,13 @@ function makeIsNaN(value) { return 'isNaN(' + value + ')'; } +function makeFloat(value, type) { + if (TO_FLOAT32 && type == 'float') { + return 'Math.toFloat32(' + value + ')'; + } + return value; +} + // fptoui and fptosi are not in these, because we need to be careful about what we do there. We can't // just sign/unsign the input first. var UNSIGNED_OP = set('udiv', 'urem', 'uitofp', 'zext', 'lshr'); @@ -2275,11 +2282,11 @@ function processMathop(item) { return idents[0] + ' >>> ' + idents[1]; } // basic float ops - case 'fadd': return getFastValue(idents[0], '+', idents[1], item.type); - case 'fsub': return getFastValue(idents[0], '-', idents[1], item.type); - case 'fdiv': return getFastValue(idents[0], '/', idents[1], item.type); - case 'fmul': return getFastValue(idents[0], '*', idents[1], item.type); - case 'frem': return getFastValue(idents[0], '%', idents[1], item.type); + case 'fadd': return makeFloat(getFastValue(idents[0], '+', idents[1], item.type), item.type); + case 'fsub': return makeFloat(getFastValue(idents[0], '-', idents[1], item.type), item.type); + case 'fdiv': return makeFloat(getFastValue(idents[0], '/', idents[1], item.type), item.type); + case 'fmul': return makeFloat(getFastValue(idents[0], '*', idents[1], item.type), item.type); + case 'frem': return makeFloat(getFastValue(idents[0], '%', idents[1], item.type), item.type); case 'uitofp': case 'sitofp': return asmCoercion(idents[0], 'double', op[0]); case 'fptoui': case 'fptosi': return makeRounding(idents[0], bitsLeft, op === 'fptosi', true); |