diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-24 10:22:13 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-24 10:22:38 -0700 |
commit | f4cff4862c66c24d5fd39f1bfdbcd129cb4da738 (patch) | |
tree | 233ec185b72d5ea9e5539e81a51e36db02c5a020 /src/analyzer.js | |
parent | 099f970ee705dd2e45cc59388ad3642bf93fea7d (diff) |
properly handle loads of i24s and similar illegal values
Diffstat (limited to 'src/analyzer.js')
-rw-r--r-- | src/analyzer.js | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 1d32d7fc..b1f0b585 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -502,18 +502,38 @@ function analyzer(data, sidePass) { { intertype: 'value', ident: j.toString(), type: 'i32' } ] }); - var actualSizeType = 'i' + element.bits; // The last one may be smaller than 32 bits - toAdd.push({ + var newItem = { intertype: 'load', assignTo: element.ident, - pointerType: actualSizeType + '*', - valueType: actualSizeType, - type: actualSizeType, // XXX why is this missing from intertyper? - pointer: { intertype: 'value', ident: tempVar, type: actualSizeType + '*' }, + pointerType: 'i32*', + valueType: 'i32', + type: 'i32', + pointer: { intertype: 'value', ident: tempVar, type: 'i32*' }, ident: tempVar, - pointerType: actualSizeType + '*', align: value.align - }); + }; + var newItem2 = null; + // The last one may be smaller than 32 bits + if (element.bits < 32) { + newItem.assignTo += '$preadd$'; + newItem2 = { + intertype: 'mathop', + op: 'and', + assignTo: element.ident, + type: 'i32', + params: [{ + intertype: 'value', + type: 'i32', + ident: newItem.assignTo + }, { + intertype: 'value', + type: 'i32', + ident: (0xffffffff >>> (32 - element.bits)).toString() + }], + }; + } + toAdd.push(newItem); + if (newItem2) toAdd.push(newItem2); j++; }); Types.needAnalysis['[0 x i32]'] = 0; |