diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2019-09-23 18:15:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-23 18:15:14 -0700 |
commit | 835581f58eb5040656243f7345ebcacf6d7deee5 (patch) | |
tree | d5f8878015be2edcdf3d69306c0a8bc20ecd9bf6 /src/binaryen-c.cpp | |
parent | fb217c80c6d9c4b52d90571c435fc52dc868df47 (diff) | |
download | binaryen-835581f58eb5040656243f7345ebcacf6d7deee5.tar.gz binaryen-835581f58eb5040656243f7345ebcacf6d7deee5.tar.bz2 binaryen-835581f58eb5040656243f7345ebcacf6d7deee5.zip |
vNxM.load_splat instructions (#2350)
Introduces a new instruction class, `SIMDLoad`. Implements encoding,
decoding, parsing, printing, and interpretation of the load and splat
instructions, including in the C and JS APIs. `v128.load` remains in
the `Load` instruction class for now because the interpreter code
expects a `Load` to be able to load any memory value type.
Diffstat (limited to 'src/binaryen-c.cpp')
-rw-r--r-- | src/binaryen-c.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 0b2ff3b78..5a32737e4 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -349,6 +349,9 @@ BinaryenExpressionId BinaryenSIMDTernaryId(void) { BinaryenExpressionId BinaryenSIMDShiftId(void) { return Expression::Id::SIMDShiftId; } +BinaryenExpressionId BinaryenSIMDLoadId(void) { + return Expression::Id::SIMDLoadId; +} BinaryenExpressionId BinaryenMemoryInitId(void) { return Expression::Id::MemoryInitId; } @@ -880,6 +883,10 @@ BinaryenOp BinaryenConvertSVecI64x2ToVecF64x2(void) { BinaryenOp BinaryenConvertUVecI64x2ToVecF64x2(void) { return ConvertUVecI64x2ToVecF64x2; } +BinaryenOp BinaryenLoadSplatVec8x16(void) { return LoadSplatVec8x16; } +BinaryenOp BinaryenLoadSplatVec16x8(void) { return LoadSplatVec16x8; } +BinaryenOp BinaryenLoadSplatVec32x4(void) { return LoadSplatVec32x4; } +BinaryenOp BinaryenLoadSplatVec64x2(void) { return LoadSplatVec64x2; } BinaryenOp BinaryenNarrowSVecI16x8ToVecI8x16(void) { return NarrowSVecI16x8ToVecI8x16; } @@ -1599,6 +1606,20 @@ BinaryenExpressionRef BinaryenSIMDShift(BinaryenModuleRef module, } return static_cast<Expression*>(ret); } +BinaryenExpressionRef BinaryenSIMDLoad(BinaryenModuleRef module, + BinaryenOp op, + uint32_t offset, + uint32_t align, + BinaryenExpressionRef ptr) { + auto* ret = + Builder(*(Module*)module) + .makeSIMDLoad( + SIMDLoadOp(op), Address(offset), Address(align), (Expression*)ptr); + if (tracing) { + traceExpression(ret, "BinaryenSIMDLoad", op, offset, align, ptr); + } + return static_cast<Expression*>(ret); +} BinaryenExpressionRef BinaryenMemoryInit(BinaryenModuleRef module, uint32_t segment, BinaryenExpressionRef dest, @@ -2767,6 +2788,47 @@ BinaryenExpressionRef BinaryenSIMDShiftGetShift(BinaryenExpressionRef expr) { assert(expression->is<SIMDShift>()); return static_cast<SIMDShift*>(expression)->shift; } +// SIMDLoad +BinaryenOp BinaryenSIMDLoadGetOp(BinaryenExpressionRef expr) { + if (tracing) { + std::cout << " BinaryenSIMDLoadGetOp(expressions[" << expressions[expr] + << "])\n"; + } + + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoad>()); + return static_cast<SIMDLoad*>(expression)->op; +} +uint32_t BinaryenSIMDLoadGetOffset(BinaryenExpressionRef expr) { + if (tracing) { + std::cout << " BinaryenSIMDLoadGetOffset(expressions[" << expressions[expr] + << "])\n"; + } + + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoad>()); + return static_cast<SIMDLoad*>(expression)->offset; +} +uint32_t BinaryenSIMDLoadGetAlign(BinaryenExpressionRef expr) { + if (tracing) { + std::cout << " BinaryenSIMDLoadGetAlign(expressions[" << expressions[expr] + << "])\n"; + } + + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoad>()); + return static_cast<SIMDLoad*>(expression)->align; +} +BinaryenExpressionRef BinaryenSIMDLoadGetPtr(BinaryenExpressionRef expr) { + if (tracing) { + std::cout << " BinaryenSIMDLoadGetPtr(expressions[" << expressions[expr] + << "])\n"; + } + + auto* expression = (Expression*)expr; + assert(expression->is<SIMDLoad>()); + return static_cast<SIMDLoad*>(expression)->ptr; +} // MemoryInit uint32_t BinaryenMemoryInitGetSegment(BinaryenExpressionRef expr) { if (tracing) { |