diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-11-26 18:04:56 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-11-26 18:04:56 -0800 |
commit | 11552c29713ee2a04470accd652d1f842060a33f (patch) | |
tree | 3202346b4b177bec610e3e1d5d30bc1b83c96262 | |
parent | 096a45f92f2bd56eeb762424de3b3feb904b7641 (diff) |
inline calculations for sign/unsigning of >32 bits
-rw-r--r-- | src/parseTools.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index c3917e37..aa1c37b1 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1461,6 +1461,7 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) { } function makeSignOp(value, type, op, force) { + // XXX this is not quite right. both parts should always be unsigned (or, perhaps always signed, we should move to that - separate issue though) if (I64_MODE == 1 && type == 'i64') { return '(tempPair=' + value + ',[' + makeSignOp('tempPair[0]', 'i32', op, force) + ',' + makeSignOp('tempPair[1]', 'i32', op, force) + '])'; } @@ -1497,6 +1498,12 @@ function makeSignOp(value, type, op, force) { } else { return '((' + value + ')&' + (Math.pow(2, bits)-1) + ')'; } + } else { // bits > 32 + if (op === 're') { + return makeInlineCalculation('VALUE >= ' + Math.pow(2, bits-1) + ' ? VALUE-' + Math.pow(2, bits) + ' : VALUE', value, 'tempBigInt'); + } else { + return makeInlineCalculation('VALUE >= 0 ? VALUE : ' + Math.pow(2, bits) + '+VALUE', value, 'tempBigInt'); + } } } return full; |