aboutsummaryrefslogtreecommitdiff
path: root/src/analyzer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-01-28 12:18:28 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-01-28 12:18:28 -0800
commitc2f903c0f66ab2733aaaafeccb87b4e5253c421d (patch)
tree496ee6cccd90576c227b127227198502c8b4a2f6 /src/analyzer.js
parentb1931242e88943e14d733664628b475a4a6da12b (diff)
improve legalizer test and fix remaining pieces; test now passes
Diffstat (limited to 'src/analyzer.js')
-rw-r--r--src/analyzer.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 67c6aabf..7eca1d5a 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -257,9 +257,28 @@ function analyzer(data, sidePass) {
if (isIllegalType(value.type)) {
dprint('legalizer', 'Legalizing mathop at line ' + item.lineNum);
label.lines.splice(i, 1);
+ var toAdd = [];
assert(value.param1.intertype == 'value', 'TODO: unfolding');
var sourceBits = getBits(value.param1.type);
- var sourceElements = getLegalVars(value.param1.ident, sourceBits);
+ var sourceElements;
+ if (sourceBits <= 64) {
+ // The input is a legal type
+ if (sourceBits <= 32) {
+ sourceElements = [{ ident: value.param1.ident, bits: sourceBits }];
+ } else if (sourceBits == 64 && I64_MODE == 1) {
+ sourceElements = [{ ident: value.param1.ident + '[0]', bits: 32 },
+ { ident: value.param1.ident + '[1]', bits: 32 }];
+ // Add the source element as a param so that it is not eliminated as unneeded (the idents are not a simple ident here)
+ toAdd.push({
+ intertype: 'value', ident: ';', type: 'rawJS',
+ params: [{ intertype: 'value', ident: value.param1.ident, type: 'i32' }]
+ });
+ } else {
+ throw 'Invalid legal type as source of legalization ' + sourceBits;
+ }
+ } else {
+ sourceElements = getLegalVars(value.param1.ident, sourceBits);
+ }
// All mathops can be parametrized by how many shifts we do, and how big the source is
var shifts = 0;
var targetBits;
@@ -291,7 +310,6 @@ function analyzer(data, sidePass) {
var shiftOpReverse = shifts >= 0 ? 'lshr' : 'shl';
var whole = shifts >= 0 ? Math.floor(shifts/32) : Math.ceil(shifts/32);
var fraction = Math.abs(shifts % 32);
- var toAdd = [];
for (var j = 0; j < targetElements.length; j++) {
var result = {
intertype: 'value',