diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-18 11:15:11 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-18 13:00:50 -0700 |
commit | 023707026d9ce16e570c0297058aa71dda9c164b (patch) | |
tree | 5410f78ae6aed85bab6f03279c70e7b23abe5b8c | |
parent | 634513d0c75e7d09a9c9055d4077d631e443ecb4 (diff) |
extractelement
-rw-r--r-- | src/intertyper.js | 13 | ||||
-rw-r--r-- | src/jsifier.js | 8 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 4c842b18..1272f569 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -314,6 +314,8 @@ function intertyper(lines, sidePass, baseLineNums) { return landingpadHandler(item); if (token0Text === 'insertelement') return insertElementHandler(item); + if (token0Text === 'extractelement') + return extractElementHandler(item); if (token0Text === 'shufflevector') return shuffleVectorHandler(item); if (token0Text == 'fence') @@ -759,14 +761,21 @@ function intertyper(lines, sidePass, baseLineNums) { function insertElementHandler(item) { var last = getTokenIndexByText(item.tokens, ';'); item.intertype = 'insertelement'; - item.type = item.tokens[1].text; // Of the origin aggregate, as well as the result - Types.needAnalysis[item.type] = 0; + item.type = item.tokens[1].text; item.ident = toNiceIdent(item.tokens[2].text); var segments = splitTokenList(item.tokens.slice(4, last)); item.value = parseLLVMSegment(segments[0]); item.index = parseLLVMSegment(segments[1]); return item; } + function extractElementHandler(item) { + var last = getTokenIndexByText(item.tokens, ';'); + item.intertype = 'extracttelement'; + item.type = item.tokens[1].text; + item.ident = toNiceIdent(item.tokens[2].text); + item.value = parseLLVMSegment(item.tokens.slice(4)); + return item; + } function shuffleVectorHandler(item) { var last = getTokenIndexByText(item.tokens, ';'); item.intertype = 'shufflevector'; diff --git a/src/jsifier.js b/src/jsifier.js index ce3a8eb4..6dc7058c 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -523,6 +523,7 @@ function JSify(data, functionsOnly, givenFunctions) { case 'extractvalue': line.JS = extractvalueHandler(line); break; case 'insertvalue': line.JS = insertvalueHandler(line); break; case 'insertelement': line.JS = insertelementHandler(line); break; + case 'extracttelement': line.JS = extractelementHandler(line); break; case 'shufflevector': line.JS = shufflevectorHandler(line); break; case 'indirectbr': line.JS = indirectbrHandler(line); break; case 'alloca': line.JS = allocaHandler(line); break; @@ -1366,6 +1367,13 @@ function JSify(data, functionsOnly, givenFunctions) { //return ident + '.with' + SIMDLane[finalizeLLVMParameter(item.index)] + '(' + finalizeLLVMParameter(item.value) + ')'; return 'SIMD.with' + SIMDLane[finalizeLLVMParameter(item.index)] + '(' + ident + ',' + finalizeLLVMParameter(item.value) + ')'; } + function extractelementHandler(item) { + var base = getVectorBaseType(item.type); + var ident = ensureVector(item.ident, base); + var index = finalizeLLVMParameter(item.value); + assert(isNumber(index)); + return ident + '.' + simdLane[index]; + } function shufflevectorHandler(item) { var base = getVectorBaseType(item.type); var first = ensureVector(item.ident, base); |