diff options
author | Daniel Wirtz <dcode@dcode.io> | 2021-05-25 04:37:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-25 04:37:21 +0200 |
commit | 994757a6747793effc8e4bdda13c47ab7337afb8 (patch) | |
tree | 668aac8f4a91e6d59188d05cd3e5e6054cc9e5ef /src | |
parent | 24d71aa0146a6dacfce5d84a11c88195e66eee0a (diff) | |
download | binaryen-994757a6747793effc8e4bdda13c47ab7337afb8.tar.gz binaryen-994757a6747793effc8e4bdda13c47ab7337afb8.tar.bz2 binaryen-994757a6747793effc8e4bdda13c47ab7337afb8.zip |
Add SIMDLoadStoreLane get/setters to C/JS API (#3904)
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.cpp | 75 | ||||
-rw-r--r-- | src/binaryen-c.h | 44 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 54 |
3 files changed, 173 insertions, 0 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index d308d88e4..56bb94b50 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -2668,6 +2668,81 @@ void BinaryenSIMDLoadSetPtr(BinaryenExpressionRef expr, assert(ptrExpr); static_cast<SIMDLoad*>(expression)->ptr = (Expression*)ptrExpr; } +// SIMDLoadStoreLane +BinaryenOp BinaryenSIMDLoadStoreLaneGetOp(BinaryenExpressionRef expr) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + return static_cast<SIMDLoadStoreLane*>(expression)->op; +} +void BinaryenSIMDLoadStoreLaneSetOp(BinaryenExpressionRef expr, BinaryenOp op) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + static_cast<SIMDLoadStoreLane*>(expression)->op = SIMDLoadStoreLaneOp(op); +} +uint32_t BinaryenSIMDLoadStoreLaneGetOffset(BinaryenExpressionRef expr) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + return static_cast<SIMDLoadStoreLane*>(expression)->offset; +} +void BinaryenSIMDLoadStoreLaneSetOffset(BinaryenExpressionRef expr, + uint32_t offset) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + static_cast<SIMDLoadStoreLane*>(expression)->offset = offset; +} +uint32_t BinaryenSIMDLoadStoreLaneGetAlign(BinaryenExpressionRef expr) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + return static_cast<SIMDLoadStoreLane*>(expression)->align; +} +void BinaryenSIMDLoadStoreLaneSetAlign(BinaryenExpressionRef expr, + uint32_t align) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + static_cast<SIMDLoadStoreLane*>(expression)->align = align; +} +uint8_t BinaryenSIMDLoadStoreLaneGetIndex(BinaryenExpressionRef expr) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + return static_cast<SIMDLoadStoreLane*>(expression)->index; +} +void BinaryenSIMDLoadStoreLaneSetIndex(BinaryenExpressionRef expr, + uint8_t index) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + static_cast<SIMDLoadStoreLane*>(expression)->index = index; +} +BinaryenExpressionRef +BinaryenSIMDLoadStoreLaneGetPtr(BinaryenExpressionRef expr) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + return static_cast<SIMDLoadStoreLane*>(expression)->ptr; +} +void BinaryenSIMDLoadStoreLaneSetPtr(BinaryenExpressionRef expr, + BinaryenExpressionRef ptrExpr) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + assert(ptrExpr); + static_cast<SIMDLoadStoreLane*>(expression)->ptr = (Expression*)ptrExpr; +} +BinaryenExpressionRef +BinaryenSIMDLoadStoreLaneGetVec(BinaryenExpressionRef expr) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + return static_cast<SIMDLoadStoreLane*>(expression)->vec; +} +void BinaryenSIMDLoadStoreLaneSetVec(BinaryenExpressionRef expr, + BinaryenExpressionRef vecExpr) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + assert(vecExpr); + static_cast<SIMDLoadStoreLane*>(expression)->vec = (Expression*)vecExpr; +} +bool BinaryenSIMDLoadStoreLaneIsStore(BinaryenExpressionRef expr) { + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoadStoreLane>()); + return static_cast<SIMDLoadStoreLane*>(expression)->isStore(); +} // MemoryInit uint32_t BinaryenMemoryInitGetSegment(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 8e436de66..a4210a8db 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -1654,6 +1654,50 @@ BinaryenSIMDLoadGetPtr(BinaryenExpressionRef expr); BINARYEN_API void BinaryenSIMDLoadSetPtr(BinaryenExpressionRef expr, BinaryenExpressionRef ptrExpr); +// SIMDLoadStoreLane + +// Gets the operation being performed by a SIMD load/store lane expression. +BINARYEN_API BinaryenOp +BinaryenSIMDLoadStoreLaneGetOp(BinaryenExpressionRef expr); +// Sets the operation being performed by a SIMD load/store lane expression. +BINARYEN_API void BinaryenSIMDLoadStoreLaneSetOp(BinaryenExpressionRef expr, + BinaryenOp op); +// Gets the constant offset of a SIMD load/store lane expression. +BINARYEN_API uint32_t +BinaryenSIMDLoadStoreLaneGetOffset(BinaryenExpressionRef expr); +// Sets the constant offset of a SIMD load/store lane expression. +BINARYEN_API void BinaryenSIMDLoadStoreLaneSetOffset(BinaryenExpressionRef expr, + uint32_t offset); +// Gets the byte alignment of a SIMD load/store lane expression. +BINARYEN_API uint32_t +BinaryenSIMDLoadStoreLaneGetAlign(BinaryenExpressionRef expr); +// Sets the byte alignment of a SIMD load/store lane expression. +BINARYEN_API void BinaryenSIMDLoadStoreLaneSetAlign(BinaryenExpressionRef expr, + uint32_t align); +// Gets the lane index of a SIMD load/store lane expression. +BINARYEN_API uint8_t +BinaryenSIMDLoadStoreLaneGetIndex(BinaryenExpressionRef expr); +// Sets the lane index of a SIMD load/store lane expression. +BINARYEN_API void BinaryenSIMDLoadStoreLaneSetIndex(BinaryenExpressionRef expr, + uint8_t index); +// Gets the pointer expression of a SIMD load/store lane expression. +BINARYEN_API BinaryenExpressionRef +BinaryenSIMDLoadStoreLaneGetPtr(BinaryenExpressionRef expr); +// Sets the pointer expression of a SIMD load/store lane expression. +BINARYEN_API void +BinaryenSIMDLoadStoreLaneSetPtr(BinaryenExpressionRef expr, + BinaryenExpressionRef ptrExpr); +// Gets the vector expression of a SIMD load/store lane expression. +BINARYEN_API BinaryenExpressionRef +BinaryenSIMDLoadStoreLaneGetVec(BinaryenExpressionRef expr); +// Sets the vector expression of a SIMD load/store lane expression. +BINARYEN_API void +BinaryenSIMDLoadStoreLaneSetVec(BinaryenExpressionRef expr, + BinaryenExpressionRef vecExpr); +// Gets whether a SIMD load/store lane expression performs a store. Otherwise it +// performs a load. +BINARYEN_API bool BinaryenSIMDLoadStoreLaneIsStore(BinaryenExpressionRef expr); + // MemoryInit // Gets the index of the segment being initialized by a `memory.init` diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 96dad5e7b..8e0120e36 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -82,6 +82,7 @@ function initializeConstants() { 'SIMDTernary', 'SIMDShift', 'SIMDLoad', + 'SIMDLoadStoreLane', 'MemoryInit', 'DataDrop', 'MemoryCopy', @@ -2998,6 +2999,17 @@ Module['getExpressionInfo'] = function(expr) { 'align': Module['_BinaryenSIMDLoadGetAlign'](expr), 'ptr': Module['_BinaryenSIMDLoadGetPtr'](expr) }; + case Module['SIMDLoadStoreLaneId']: + return { + 'id': id, + 'type': type, + 'op': Module['_BinaryenSIMDLoadStoreLaneGetOp'](expr), + 'offset': Module['_BinaryenSIMDLoadStoreLaneGetOffset'](expr), + 'align': Module['_BinaryenSIMDLoadStoreLaneGetAlign'](expr), + 'index': Module['_BinaryenSIMDLoadStoreLaneGetIndex'](expr), + 'ptr': Module['_BinaryenSIMDLoadStoreLaneGetPtr'](expr), + 'vec': Module['_BinaryenSIMDLoadStoreLaneGetVec'](expr) + }; case Module['MemoryInitId']: return { 'id': id, @@ -4243,6 +4255,48 @@ Module['SIMDLoad'] = makeExpressionWrapper({ } }); +Module['SIMDLoadStoreLane'] = makeExpressionWrapper({ + 'getOp'(expr) { + return Module['_BinaryenSIMDLoadStoreLaneGetOp'](expr); + }, + 'setOp'(expr, op) { + Module['_BinaryenSIMDLoadStoreLaneSetOp'](expr, op); + }, + 'getOffset'(expr) { + return Module['_BinaryenSIMDLoadStoreLaneGetOffset'](expr); + }, + 'setOffset'(expr, offset) { + Module['_BinaryenSIMDLoadStoreLaneSetOffset'](expr, offset); + }, + 'getAlign'(expr) { + return Module['_BinaryenSIMDLoadStoreLaneGetAlign'](expr); + }, + 'setAlign'(expr, align) { + Module['_BinaryenSIMDLoadStoreLaneSetAlign'](expr, align); + }, + 'getIndex'(expr) { + return Module['_BinaryenSIMDLoadStoreLaneGetIndex'](expr); + }, + 'setIndex'(expr, align) { + Module['_BinaryenSIMDLoadStoreLaneSetIndex'](expr, align); + }, + 'getPtr'(expr) { + return Module['_BinaryenSIMDLoadStoreLaneGetPtr'](expr); + }, + 'setPtr'(expr, ptrExpr) { + Module['_BinaryenSIMDLoadStoreLaneSetPtr'](expr, ptrExpr); + }, + 'getVec'(expr) { + return Module['_BinaryenSIMDLoadStoreLaneGetVec'](expr); + }, + 'setVec'(expr, ptrExpr) { + Module['_BinaryenSIMDLoadStoreLaneSetVec'](expr, ptrExpr); + }, + 'isStore'(expr) { + return Boolean(Module['_BinaryenSIMDLoadStoreLaneIsStore'](expr)); + } +}); + Module['MemoryInit'] = makeExpressionWrapper({ 'getSegment'(expr) { return Module['_BinaryenMemoryInitGetSegment'](expr); |