diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-05 17:56:14 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:23 -0800 |
commit | 67f423ed8e38e76b11bac0347d4713e349d6b1b9 (patch) | |
tree | 3c8a64b1355bc7d0c508f89b77a64e6c978ed295 | |
parent | 5c7a624b2d60c021f4d27f40272fca0c16dfa535 (diff) |
legalize loads and stores of entire structures
-rw-r--r-- | src/analyzer.js | 3 | ||||
-rw-r--r-- | src/parseTools.js | 17 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 6b5fa499..83f4317a 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -227,6 +227,9 @@ function analyzer(data, sidePass) { if (isIllegalType(item.valueType) || isIllegalType(item.type)) { isIllegal = true; } + if ((item.intertype == 'load' || item.intertype == 'store') && isStructType(item.valueType)) { + isIllegal = true; // storing an entire structure is illegal + } }); if (!isIllegal) { i++; diff --git a/src/parseTools.js b/src/parseTools.js index c1428353..132e6e96 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -140,13 +140,20 @@ function isIntImplemented(type) { return type[0] == 'i' || isPointerType(type); } -// Note: works for iX types, not pointers (even though they are implemented as ints) +// Note: works for iX types and structure types, not pointers (even though they are implemented as ints) function getBits(type) { + if (!type) return 0; + if (type[0] == 'i') { + var left = type.substr(1); + if (!isNumber(left)) return 0; + return parseInt(left); + } if (isStructuralType(type)) return getStructuralTypeParts(type).length*32; // 32 bits per part in { i32, i1, i8, i32 } etc - if (!type || type[0] != 'i') return 0; - var left = type.substr(1); - if (!isNumber(left)) return 0; - return parseInt(left); + if (isStructType(type)) { + var typeData = Types.types[type]; + return typeData.flatSize*8; + } + return 0; } function isIllegalType(type) { |