aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
authorToadKing <toadking@toadking.com>2013-08-12 23:30:49 -0400
committerToadKing <toadking@toadking.com>2013-08-12 23:30:49 -0400
commit7466223864929d50d02407dde1da331133a0bef1 (patch)
tree60403b8061880e6aea503a20d9c45b3e678ec6ad /src/parseTools.js
parentc2b064eb49ea63eec59add5751c8a9c2b80dab92 (diff)
parent3090cdd713609a9d3f749d13002a898e03cbd5e3 (diff)
Merge branch 'incoming' of https://github.com/kripken/emscripten into fixed_openal_buffers
Conflicts: src/library_openal.js
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js17
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);