aboutsummaryrefslogtreecommitdiff
path: root/src/intertyper.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/intertyper.js')
-rw-r--r--src/intertyper.js43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/intertyper.js b/src/intertyper.js
index 07f2020c..09bdaa33 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -850,6 +850,7 @@ function intertyper(lines, sidePass, baseLineNums) {
// TODO: also remove 2nd param?
} else if (item.op in LLVM.COMPS) {
item.type = 'i1';
+ if (item.params[1].intertype === 'type') item.params[1].intertype = 'value'; // parsed as type, but comparisons have just values there
}
if (USE_TYPED_ARRAYS == 2) {
// Some specific corrections, since 'i64' is special
@@ -1013,7 +1014,8 @@ function intertyper(lines, sidePass, baseLineNums) {
noteGlobalVariable(ret);
}
} else if (phase === 'funcs') {
- if (m = /^ (%[\w\d\._]+) = (getelementptr|load) ([%\w\d\._ ,\*\-@]+)$/.exec(line.lineText)) {
+ // TODO: (void)call, store
+ if (m = /^ (%[\w\d\._]+) = (getelementptr|load|icmp) ([%\w\d\._ ,\*\-@]+)$/.exec(line.lineText)) {
var assignTo = m[1];
var intertype = m[2];
var args = m[3];
@@ -1067,14 +1069,36 @@ function intertyper(lines, sidePass, baseLineNums) {
}
break;
}
+ case 'icmp': {
+ var parts = args.split(' ');
+ assert(parts.length === 4);
+ ret = {
+ intertype: 'mathop',
+ op: 'icmp',
+ variant: parts[0],
+ lineNum: line.lineNum,
+ assignTo: toNiceIdent(assignTo),
+ params: [{
+ intertype: 'value',
+ ident: toNiceIdent(parts[2].substr(0, parts[2].length-1)),
+ type: parts[1]
+ }, {
+ intertype: 'value',
+ ident: toNiceIdent(parts[3]),
+ type: parts[1]
+ }],
+ type: 'i1',
+ };
+ break;
+ }
default: throw 'unexpected fast path type ' + intertype;
}
- //else if (line.lineText.indexOf(' = load ') > 0) printErr('close: ' + JSON.stringify(line.lineText));
}
+ //else if (line.lineText.indexOf(' = icmp ') > 0) printErr('close: ' + JSON.stringify(line.lineText));
}
if (ret) {
if (COMPILER_ASSERTIONS) {
- //printErr(['\n', JSON.stringify(ret), '\n', JSON.stringify(triager(tokenizer(line)))]);
+ //printErr(['\n', dump(ret), '\n', dump(triager(tokenizer(line)))]);
var normal = triager(tokenizer(line));
delete normal.tokens;
delete normal.indent;
@@ -1087,11 +1111,14 @@ function intertyper(lines, sidePass, baseLineNums) {
// Input
lineSplitter().forEach(function(line) {
- var item = tryFastPaths(line);
- if (item) {
- finalResults.push(item);
- fastPaths++;
- return;
+ var item;
+ if (COMPILER_FASTPATHS) {
+ item = tryFastPaths(line);
+ if (item) {
+ finalResults.push(item);
+ fastPaths++;
+ return;
+ }
}
slowPaths++;