diff options
author | Alon Zakai <azakai@mozilla.com> | 2010-12-18 17:29:24 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2010-12-18 17:29:24 -0800 |
commit | 5bbf8a976bdb547a6e6801dc4dcd9da8bb1fefb3 (patch) | |
tree | 3169c999ead4db65048fb2cf5b13cd64e995dd37 /src | |
parent | 2890aa49d7d26cef710f994f7a3f838ca3466356 (diff) |
fixes for llvm optimized code in 2 tests
Diffstat (limited to 'src')
-rw-r--r-- | src/intertyper.js | 2 | ||||
-rw-r--r-- | src/jsifier.js | 22 | ||||
-rw-r--r-- | src/parseTools.js | 11 |
3 files changed, 28 insertions, 7 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 9b7ebe06..7e071935 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -609,7 +609,7 @@ function intertyper(data, parseFunctions, baseLineNum) { item.intertype = 'mathop'; item.op = item.tokens[0].text; item.variant = null; - if (item.tokens[1].text == 'nsw') item.tokens.splice(1, 1); + while (item.tokens[1].text in set('nsw', 'nuw')) item.tokens.splice(1, 1); if (['icmp', 'fcmp'].indexOf(item.op) != -1) { item.variant = item.tokens[1].text; item.tokens.splice(1, 1); diff --git a/src/jsifier.js b/src/jsifier.js index 4a65d927..f4565bcc 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -515,7 +515,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { // Function lines function makeFuncLineActor(intertype, func) { - substrate.addActor('Intertype:' + intertype, { + return substrate.addActor('Intertype:' + intertype, { processItem: function(item) { item.JS = func(item); if (!item.JS) throw "XXX - no JS generated for " + dump(item); @@ -697,7 +697,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { } } - makeFuncLineActor('mathop', function(item) { with(item) { + var mathop = makeFuncLineActor('mathop', function(item) { with(item) { for (var i = 1; i <= 4; i++) { if (item['param'+i]) { item['ident'+i] = indexizeFunctions(finalizeLLVMParameter(item['param'+i])); @@ -878,14 +878,28 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { case 'inttoptr': case 'ptrtoint': return finalizeLLVMParameter(item.params[0]); + case 'icmp': case 'mul': case 'zext': // TODO: Other mathops + var temp = { + op: item.intertype, + variant: item.variant + }; + for (var i = 1; i <= 4; i++) { + if (item.params[i-1]) { + temp['param' + i] = finalizeLLVMParameter(item.params[i-1]); + } + } + mathop.processItem(temp); + return temp.JS; default: - throw 'Invalid function to finalize: ' + dump(item); + throw 'Invalid function to finalize: ' + dump(item.intertype); } } // From parseLLVMSegment function finalizeLLVMParameter(param) { - if (param.intertype in PARSABLE_LLVM_FUNCTIONS) { + if (isNumber(param) || typeof param === 'string') { + return param; + } else if (param.intertype in PARSABLE_LLVM_FUNCTIONS) { return finalizeLLVMFunctionCall(param); } else if (param.intertype == 'value') { return parseNumerical(param.ident); diff --git a/src/parseTools.js b/src/parseTools.js index fa8b6ac6..58b1ed71 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -317,7 +317,7 @@ function cleanSegment(segment) { return segment; } -PARSABLE_LLVM_FUNCTIONS = searchable('getelementptr', 'bitcast', 'inttoptr', 'ptrtoint'); +PARSABLE_LLVM_FUNCTIONS = searchable('getelementptr', 'bitcast', 'inttoptr', 'ptrtoint', 'mul', 'icmp', 'zext'); // Parses a function call of form // TYPE functionname MODIFIERS (...) @@ -327,13 +327,20 @@ function parseLLVMFunctionCall(segment) { segment = segment.slice(0); segment = cleanSegment(segment); // Remove additional modifiers + var variant = null; if (!segment[2] || !segment[2].item) { - segment.splice(2, 1); + variant = segment.splice(2, 1)[0]; + if (variant && variant.text) variant = variant.text; // needed for mathops } assertTrue(['inreg', 'byval'].indexOf(segment[1].text) == -1); assert(segment[1].text in PARSABLE_LLVM_FUNCTIONS); + while (!segment[2].item) { + segment.splice(2, 1); // XXX Remove modifiers - should look into them some day + if (!segment[2]) throw 'Invalid segment!'; + } var ret = { intertype: segment[1].text, + variant: variant, type: segment[0].text, params: parseParamTokens(segment[2].item.tokens) }; |