diff options
Diffstat (limited to 'src/analyzer.js')
-rw-r--r-- | src/analyzer.js | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 4bf2255e..163ff4a8 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -253,6 +253,7 @@ function analyzer(data, sidePass) { } // This is an illegal-containing line, and it is unfolded. Legalize it now dprint('legalizer', 'Legalizing ' + item.intertype + ' at line ' + item.lineNum); + var finalizer = null; switch (item.intertype) { case 'store': { var toAdd = []; @@ -486,12 +487,13 @@ function analyzer(data, sidePass) { }; break; } - case 'or': case 'and': case 'xor': { + case 'or': case 'and': case 'xor': case 'icmp': { var otherElements = getLegalVars(value.params[1].ident, sourceBits); processor = function(result, j) { return { intertype: 'mathop', op: value.op, + variant: value.variant, type: 'i' + otherElements[j].bits, params: [ result, @@ -499,10 +501,35 @@ function analyzer(data, sidePass) { ] }; }; + if (value.op == 'icmp') { + if (sourceBits == 64) { // handle the i64 case in processMathOp, where we handle full i64 math + i++; + continue; + } + finalizer = function() { + var ident = ''; + for (var i = 0; i < targetElements.length; i++) { + if (i > 0) { + switch(value.variant) { + case 'eq': ident += '&&'; break; + case 'ne': ident += '||'; break; + default: throw 'unhandleable illegal icmp: ' + value.variant; + } + } + ident += targetElements[i].ident; + } + return { + intertype: 'value', + ident: ident, + type: 'rawJS', + assignTo: item.assignTo + }; + } + } break; } case 'add': case 'sub': case 'sdiv': case 'udiv': case 'mul': case 'urem': case 'srem': - case 'icmp':case 'uitofp': case 'sitofp': { + case 'uitofp': case 'sitofp': { // We cannot do these in parallel chunks of 32-bit operations. We will handle these in processMathop i++; continue; @@ -611,6 +638,8 @@ function analyzer(data, sidePass) { }; legalValue.assignTo = item.assignTo; toAdd.push(legalValue); + } else if (finalizer) { + toAdd.push(finalizer()); } i += removeAndAdd(label.lines, i, toAdd); continue; |