diff options
-rw-r--r-- | src/intertyper.js | 8 | ||||
-rw-r--r-- | src/modules.js | 3 | ||||
-rw-r--r-- | src/parseTools.js | 16 |
3 files changed, 19 insertions, 8 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 069ef354..0f41f20f 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -757,7 +757,13 @@ function intertyper(data, parseFunctions, baseLineNum) { item.type = item.param1.type; } for (var i = 1; i <= 4; i++) { - if (item['param'+i]) item['param'+i].type = item.type; // All params have the same type + if (item['param'+i]) item['param'+i].type = item.type; // All params have the same type, normally + if (I64_MODE == 1) { + // Some specific corrections, since 'i64' is special + if (item.op in LLVM.SHIFTS) { + item.param2.type = 'i32'; + } + } } Types.needAnalysis[item.type] = 0; this.forwardItem(item, 'Reintegrator'); diff --git a/src/modules.js b/src/modules.js index f04731f8..75cf1ad2 100644 --- a/src/modules.js +++ b/src/modules.js @@ -10,7 +10,8 @@ var LLVM = { PARAM_ATTR: set('noalias', 'signext', 'zeroext', 'inreg', 'sret', 'nocapture', 'nest'), CALLING_CONVENTIONS: set('ccc', 'fastcc', 'coldcc', 'cc10', 'x86_fastcallcc', 'x86_stdcallcc'), ACCESS_OPTIONS: set('volatile', 'atomic'), - INVOKE_MODIFIERS: set('alignstack', 'alwaysinline', 'inlinehint', 'naked', 'noimplicitfloat', 'noinline', 'alwaysinline attribute.', 'noredzone', 'noreturn', 'nounwind', 'optsize', 'readnone', 'readonly', 'ssp', 'sspreq') + INVOKE_MODIFIERS: set('alignstack', 'alwaysinline', 'inlinehint', 'naked', 'noimplicitfloat', 'noinline', 'alwaysinline attribute.', 'noredzone', 'noreturn', 'nounwind', 'optsize', 'readnone', 'readonly', 'ssp', 'sspreq'), + SHIFTS: set('ashr', 'lshr', 'shl'), }; LLVM.GLOBAL_MODIFIERS = set(keys(LLVM.LINKAGES).concat(['constant', 'global', 'hidden'])); diff --git a/src/parseTools.js b/src/parseTools.js index b7ea28e1..40f845a3 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1255,7 +1255,11 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) { return '0'; } } else if (param.intertype == 'value') { - ret = parseNumerical(param.ident); + ret = param.ident; + if (param.type == 'i64' && I64_MODE == 1) { + ret = parseI64Constant(ret); + } + ret = parseNumerical(ret); } else if (param.intertype == 'structvalue') { ret = makeLLVMStruct(param.values.map(function(value) { return finalizeLLVMParameter(value, noIndexizeFunctions) })); } else if (param.intertype === 'blockaddress') { @@ -1371,14 +1375,14 @@ function processMathop(item) { with(item) { } case 'shl': { return '[' + ident1 + '[0] << ' + ident2 + ', ' + - '('+ident1 + '[1] << ' + ident2 + ') | (' + ident1 + '[0]&(Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + ') >> (32-' + ident2 + '))]'; + '('+ident1 + '[1] << ' + ident2 + ') | ((' + ident1 + '[0]&((Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + '))) >> (32-' + ident2 + '))]'; } case 'ashr': { - return '[('+ident1 + '[0] >> ' + ident2 + ') | (' + ident1 + '[1]&(Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + ') >> (32-' + ident2 + ')),' + + return '[('+ident1 + '[0] >> ' + ident2 + ') | ((' + ident1 + '[1]&((Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + '))) >> (32-' + ident2 + ')),' + ident1 + '[1] >> ' + ident2 + ']'; } case 'lshr': { - return '[('+ident1 + '[0] >>> ' + ident2 + ') | (' + ident1 + '[1]&(Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + ') >> (32-' + ident2 + ')),' + + return '[('+ident1 + '[0] >>> ' + ident2 + ') | ((' + ident1 + '[1]&((Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + '))) >> (32-' + ident2 + ')),' + ident1 + '[1] >>> ' + ident2 + ']'; } case 'uitofp': case 'sitofp': return ident1 + '[0] + ' + ident1 + '[1]*4294967296'; @@ -1388,9 +1392,9 @@ function processMathop(item) { with(item) { ident1 + '[0] >= ' + ident2 + '[0])'; case 'ule': case 'sle': return ident1 + '[1] <= ' + ident2 + '[1] && (' + ident1 + '[1] < ' + ident2 + '[1] || ' + ident1 + '[0] <= ' + ident2 + '[0])'; - case 'ugt': case 'sgt': return ident1 + '[1] > ' + ident2 + '[1] || (' + ident1 + '[1] = ' + ident2 + '[1] && ' + + case 'ugt': case 'sgt': return ident1 + '[1] > ' + ident2 + '[1] || (' + ident1 + '[1] == ' + ident2 + '[1] && ' + ident1 + '[0] > ' + ident2 + '[0])'; - case 'ult': case 'slt': return ident1 + '[1] < ' + ident2 + '[1] || (' + ident1 + '[1] = ' + ident2 + '[1] && ' + + case 'ult': case 'slt': return ident1 + '[1] < ' + ident2 + '[1] || (' + ident1 + '[1] == ' + ident2 + '[1] && ' + ident1 + '[0] < ' + ident2 + '[0])'; case 'ne': case 'eq': { // We must sign them, so we do not compare -1 to 255 (could have unsigned them both too) |