[MLIR][Wasm] Extending Wasm binary to WasmSSA dialect importer (#154452)

This is a cherry pick of #154053 with a fix for bad handling of
endianess when loading float and double litteral from the binary.

---------

Co-authored-by: Ferdinand Lemaire <ferdinand.lemaire@woven-planet.global>
Co-authored-by: Jessica Paquette <jessica.paquette@woven-planet.global>
Co-authored-by: Luc Forget <luc.forget@woven.toyota>
This commit is contained in:
Luc Forget 2025-08-20 17:55:55 +09:00 committed by GitHub
parent c34cba0413
commit 95fbc18a70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
48 changed files with 2086 additions and 23 deletions

View File

@ -20,10 +20,79 @@ struct WasmBinaryEncoding {
/// Byte encodings for Wasm instructions.
struct OpCode {
// Locals, globals, constants.
static constexpr std::byte localGet{0x20};
static constexpr std::byte localSet{0x21};
static constexpr std::byte localTee{0x22};
static constexpr std::byte globalGet{0x23};
static constexpr std::byte constI32{0x41};
static constexpr std::byte constI64{0x42};
static constexpr std::byte constFP32{0x43};
static constexpr std::byte constFP64{0x44};
// Numeric operations.
static constexpr std::byte clzI32{0x67};
static constexpr std::byte ctzI32{0x68};
static constexpr std::byte popcntI32{0x69};
static constexpr std::byte addI32{0x6A};
static constexpr std::byte subI32{0x6B};
static constexpr std::byte mulI32{0x6C};
static constexpr std::byte divSI32{0x6d};
static constexpr std::byte divUI32{0x6e};
static constexpr std::byte remSI32{0x6f};
static constexpr std::byte remUI32{0x70};
static constexpr std::byte andI32{0x71};
static constexpr std::byte orI32{0x72};
static constexpr std::byte xorI32{0x73};
static constexpr std::byte shlI32{0x74};
static constexpr std::byte shrSI32{0x75};
static constexpr std::byte shrUI32{0x76};
static constexpr std::byte rotlI32{0x77};
static constexpr std::byte rotrI32{0x78};
static constexpr std::byte clzI64{0x79};
static constexpr std::byte ctzI64{0x7A};
static constexpr std::byte popcntI64{0x7B};
static constexpr std::byte addI64{0x7C};
static constexpr std::byte subI64{0x7D};
static constexpr std::byte mulI64{0x7E};
static constexpr std::byte divSI64{0x7F};
static constexpr std::byte divUI64{0x80};
static constexpr std::byte remSI64{0x81};
static constexpr std::byte remUI64{0x82};
static constexpr std::byte andI64{0x83};
static constexpr std::byte orI64{0x84};
static constexpr std::byte xorI64{0x85};
static constexpr std::byte shlI64{0x86};
static constexpr std::byte shrSI64{0x87};
static constexpr std::byte shrUI64{0x88};
static constexpr std::byte rotlI64{0x89};
static constexpr std::byte rotrI64{0x8A};
static constexpr std::byte absF32{0x8B};
static constexpr std::byte negF32{0x8C};
static constexpr std::byte ceilF32{0x8D};
static constexpr std::byte floorF32{0x8E};
static constexpr std::byte truncF32{0x8F};
static constexpr std::byte sqrtF32{0x91};
static constexpr std::byte addF32{0x92};
static constexpr std::byte subF32{0x93};
static constexpr std::byte mulF32{0x94};
static constexpr std::byte divF32{0x95};
static constexpr std::byte minF32{0x96};
static constexpr std::byte maxF32{0x97};
static constexpr std::byte copysignF32{0x98};
static constexpr std::byte absF64{0x99};
static constexpr std::byte negF64{0x9A};
static constexpr std::byte ceilF64{0x9B};
static constexpr std::byte floorF64{0x9C};
static constexpr std::byte truncF64{0x9D};
static constexpr std::byte sqrtF64{0x9F};
static constexpr std::byte addF64{0xA0};
static constexpr std::byte subF64{0xA1};
static constexpr std::byte mulF64{0xA2};
static constexpr std::byte divF64{0xA3};
static constexpr std::byte minF64{0xA4};
static constexpr std::byte maxF64{0xA5};
static constexpr std::byte copysignF64{0xA6};
static constexpr std::byte wrap{0xA7};
};
/// Byte encodings of types in Wasm binaries

View File

@ -16,15 +16,17 @@
#include "mlir/IR/BuiltinAttributeInterfaces.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Location.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Target/Wasm/WasmBinaryEncoding.h"
#include "mlir/Target/Wasm/WasmImporter.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugLog.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/LogicalResult.h"
#include <climits>
#include <cstddef>
#include <cstdint>
#include <variant>
@ -148,22 +150,22 @@ struct WasmModuleSymbolTables {
}
std::string getNewFuncSymbolName() const {
auto id = funcSymbols.size();
size_t id = funcSymbols.size();
return getNewSymbolName("func_", id);
}
std::string getNewGlobalSymbolName() const {
auto id = globalSymbols.size();
size_t id = globalSymbols.size();
return getNewSymbolName("global_", id);
}
std::string getNewMemorySymbolName() const {
auto id = memSymbols.size();
size_t id = memSymbols.size();
return getNewSymbolName("mem_", id);
}
std::string getNewTableSymbolName() const {
auto id = tableSymbols.size();
size_t id = tableSymbols.size();
return getNewSymbolName("table_", id);
}
};
@ -232,6 +234,20 @@ private:
parseConstInst(OpBuilder &builder,
std::enable_if_t<std::is_arithmetic_v<valueT>> * = nullptr);
/// Construct an operation with \p numOperands operands and a single result.
/// Each operand must have the same type. Suitable for e.g. binops, unary
/// ops, etc.
///
/// \p opcode - The WASM opcode to build.
/// \p valueType - The operand and result type for the built instruction.
/// \p numOperands - The number of operands for the built operation.
///
/// \returns The parsed instruction result, or failure.
template <typename opcode, typename valueType, unsigned int numOperands>
inline parsed_inst_t
buildNumericOp(OpBuilder &builder,
std::enable_if_t<std::is_arithmetic_v<valueType>> * = nullptr);
/// This function generates a dispatch tree to associate an opcode with a
/// parser. Parsers are registered by specialising the
/// `parseSpecificInstruction` function for the op code to handle.
@ -286,10 +302,16 @@ public:
return valueStack.pushResults(results, &currentOpLoc.value());
}
/// The local.set and local.tee operations behave similarly and only differ
/// on their return value. This function factorizes the behavior of the two
/// operations in one place.
template <typename OpToCreate>
parsed_inst_t parseSetOrTee(OpBuilder &);
private:
std::optional<Location> currentOpLoc;
ParserHead &parser;
[[maybe_unused]] WasmModuleSymbolTables const &symbols;
WasmModuleSymbolTables const &symbols;
locals_t locals;
ValueStack valueStack;
};
@ -322,7 +344,7 @@ public:
}
FailureOr<std::byte> consumeByte() {
auto res = consumeNBytes(1);
FailureOr<StringRef> res = consumeNBytes(1);
if (failed(res))
return failure();
return std::byte{*res->bytes_begin()};
@ -482,7 +504,7 @@ public:
FileLineColLoc importLoc = getLocation();
FailureOr<std::byte> importType = consumeByte();
auto packager = [](auto parseResult) -> FailureOr<ImportDesc> {
if (llvm::failed(parseResult))
if (failed(parseResult))
return failure();
return {*parseResult};
};
@ -510,6 +532,60 @@ public:
return eParser.parse(builder);
}
LogicalResult parseCodeFor(FuncOp func,
WasmModuleSymbolTables const &symbols) {
SmallVector<local_val_t> locals{};
// Populating locals with function argument
Block &block = func.getBody().front();
// Delete temporary return argument which was only created for IR validity
assert(func.getBody().getBlocks().size() == 1 &&
"Function should only have its default created block at this point");
assert(block.getOperations().size() == 1 &&
"Only the placeholder return op should be present at this point");
auto returnOp = cast<ReturnOp>(&block.back());
assert(returnOp);
FailureOr<uint32_t> codeSizeInBytes = parseUI32();
if (failed(codeSizeInBytes))
return failure();
FailureOr<StringRef> codeContent = consumeNBytes(*codeSizeInBytes);
if (failed(codeContent))
return failure();
auto name = StringAttr::get(func->getContext(),
locName.str() + "::" + func.getSymName());
auto cParser = ParserHead{*codeContent, name};
FailureOr<uint32_t> localVecSize = cParser.parseVectorSize();
if (failed(localVecSize))
return failure();
OpBuilder builder{&func.getBody().front().back()};
for (auto arg : block.getArguments())
locals.push_back(cast<TypedValue<LocalRefType>>(arg));
// Declare the local ops
uint32_t nVarVec = *localVecSize;
for (size_t i = 0; i < nVarVec; ++i) {
FileLineColLoc varLoc = cParser.getLocation();
FailureOr<uint32_t> nSubVar = cParser.parseUI32();
if (failed(nSubVar))
return failure();
FailureOr<Type> varT = cParser.parseValueType(func->getContext());
if (failed(varT))
return failure();
for (size_t j = 0; j < *nSubVar; ++j) {
auto local = builder.create<LocalOp>(varLoc, *varT);
locals.push_back(local.getResult());
}
}
parsed_inst_t res = cParser.parseExpression(builder, symbols, locals);
if (failed(res))
return failure();
if (!cParser.end())
return emitError(cParser.getLocation(),
"unparsed garbage remaining at end of code block");
builder.create<ReturnOp>(func->getLoc(), *res);
returnOp->erase();
return success();
}
bool end() const { return curHead().empty(); }
ParserHead copy() const { return *this; }
@ -535,22 +611,20 @@ private:
template <>
FailureOr<float> ParserHead::parseLiteral<float>() {
auto bytes = consumeNBytes(4);
FailureOr<StringRef> bytes = consumeNBytes(4);
if (failed(bytes))
return failure();
float result;
std::memcpy(&result, bytes->bytes_begin(), 4);
return result;
return llvm::support::endian::read<float>(bytes->bytes_begin(),
llvm::endianness::little);
}
template <>
FailureOr<double> ParserHead::parseLiteral<double>() {
auto bytes = consumeNBytes(8);
FailureOr<StringRef> bytes = consumeNBytes(8);
if (failed(bytes))
return failure();
double result;
std::memcpy(&result, bytes->bytes_begin(), 8);
return result;
return llvm::support::endian::read<double>(bytes->bytes_begin(),
llvm::endianness::little);
}
template <>
@ -650,7 +724,7 @@ parsed_inst_t ValueStack::popOperands(TypeRange operandTypes, Location *opLoc) {
<< " Current stack size: " << values.size();
if (operandTypes.size() > values.size())
return emitError(*opLoc,
"stack doesn't contain enough values. Trying to get ")
"stack doesn't contain enough values. trying to get ")
<< operandTypes.size() << " operands on a stack containing only "
<< values.size() << " values.";
size_t stackIdxOffset = values.size() - operandTypes.size();
@ -660,7 +734,7 @@ parsed_inst_t ValueStack::popOperands(TypeRange operandTypes, Location *opLoc) {
Value operand = values[i + stackIdxOffset];
Type stackType = operand.getType();
if (stackType != operandTypes[i])
return emitError(*opLoc, "invalid operand type on stack. Expecting ")
return emitError(*opLoc, "invalid operand type on stack. expecting ")
<< operandTypes[i] << ", value on stack is of type " << stackType
<< ".";
LDBG() << " POP: " << operand;
@ -718,6 +792,70 @@ ExpressionParser::parse(OpBuilder &builder,
}
}
template <>
inline parsed_inst_t ExpressionParser::parseSpecificInstruction<
WasmBinaryEncoding::OpCode::localGet>(OpBuilder &builder) {
FailureOr<uint32_t> id = parser.parseLiteral<uint32_t>();
Location instLoc = *currentOpLoc;
if (failed(id))
return failure();
if (*id >= locals.size())
return emitError(instLoc, "invalid local index. function has ")
<< locals.size() << " accessible locals, received index " << *id;
return {{builder.create<LocalGetOp>(instLoc, locals[*id]).getResult()}};
}
template <>
inline parsed_inst_t ExpressionParser::parseSpecificInstruction<
WasmBinaryEncoding::OpCode::globalGet>(OpBuilder &builder) {
FailureOr<uint32_t> id = parser.parseLiteral<uint32_t>();
Location instLoc = *currentOpLoc;
if (failed(id))
return failure();
if (*id >= symbols.globalSymbols.size())
return emitError(instLoc, "invalid global index. function has ")
<< symbols.globalSymbols.size()
<< " accessible globals, received index " << *id;
GlobalSymbolRefContainer globalVar = symbols.globalSymbols[*id];
auto globalOp = builder.create<GlobalGetOp>(instLoc, globalVar.globalType,
globalVar.symbol);
return {{globalOp.getResult()}};
}
template <typename OpToCreate>
parsed_inst_t ExpressionParser::parseSetOrTee(OpBuilder &builder) {
FailureOr<uint32_t> id = parser.parseLiteral<uint32_t>();
if (failed(id))
return failure();
if (*id >= locals.size())
return emitError(*currentOpLoc, "invalid local index. function has ")
<< locals.size() << " accessible locals, received index " << *id;
if (valueStack.empty())
return emitError(
*currentOpLoc,
"invalid stack access, trying to access a value on an empty stack.");
parsed_inst_t poppedOp = popOperands(locals[*id].getType().getElementType());
if (failed(poppedOp))
return failure();
return {
builder.create<OpToCreate>(*currentOpLoc, locals[*id], poppedOp->front())
->getResults()};
}
template <>
inline parsed_inst_t ExpressionParser::parseSpecificInstruction<
WasmBinaryEncoding::OpCode::localSet>(OpBuilder &builder) {
return parseSetOrTee<LocalSetOp>(builder);
}
template <>
inline parsed_inst_t ExpressionParser::parseSpecificInstruction<
WasmBinaryEncoding::OpCode::localTee>(OpBuilder &builder) {
return parseSetOrTee<LocalTeeOp>(builder);
}
template <typename T>
inline Type buildLiteralType(OpBuilder &);
@ -810,6 +948,94 @@ inline parsed_inst_t ExpressionParser::parseSpecificInstruction<
return parseConstInst<double>(builder);
}
template <typename opcode, typename valueType, unsigned int numOperands>
inline parsed_inst_t ExpressionParser::buildNumericOp(
OpBuilder &builder, std::enable_if_t<std::is_arithmetic_v<valueType>> *) {
auto ty = buildLiteralType<valueType>(builder);
LDBG() << "*** buildNumericOp: numOperands = " << numOperands
<< ", type = " << ty << " ***";
auto tysToPop = SmallVector<Type, numOperands>();
tysToPop.resize(numOperands);
std::fill(tysToPop.begin(), tysToPop.end(), ty);
auto operands = popOperands(tysToPop);
if (failed(operands))
return failure();
auto op = builder.create<opcode>(*currentOpLoc, *operands).getResult();
LDBG() << "Built operation: " << op;
return {{op}};
}
// Convenience macro for generating numerical operations.
#define BUILD_NUMERIC_OP(OP_NAME, N_ARGS, PREFIX, SUFFIX, TYPE) \
template <> \
inline parsed_inst_t ExpressionParser::parseSpecificInstruction< \
WasmBinaryEncoding::OpCode::PREFIX##SUFFIX>(OpBuilder & builder) { \
return buildNumericOp<OP_NAME, TYPE, N_ARGS>(builder); \
}
// Macro to define binops that only support integer types.
#define BUILD_NUMERIC_BINOP_INT(OP_NAME, PREFIX) \
BUILD_NUMERIC_OP(OP_NAME, 2, PREFIX, I32, int32_t) \
BUILD_NUMERIC_OP(OP_NAME, 2, PREFIX, I64, int64_t)
// Macro to define binops that only support floating point types.
#define BUILD_NUMERIC_BINOP_FP(OP_NAME, PREFIX) \
BUILD_NUMERIC_OP(OP_NAME, 2, PREFIX, F32, float) \
BUILD_NUMERIC_OP(OP_NAME, 2, PREFIX, F64, double)
// Macro to define binops that support both floating point and integer types.
#define BUILD_NUMERIC_BINOP_INTFP(OP_NAME, PREFIX) \
BUILD_NUMERIC_BINOP_INT(OP_NAME, PREFIX) \
BUILD_NUMERIC_BINOP_FP(OP_NAME, PREFIX)
// Macro to implement unary ops that only support integers.
#define BUILD_NUMERIC_UNARY_OP_INT(OP_NAME, PREFIX) \
BUILD_NUMERIC_OP(OP_NAME, 1, PREFIX, I32, int32_t) \
BUILD_NUMERIC_OP(OP_NAME, 1, PREFIX, I64, int64_t)
// Macro to implement unary ops that support integer and floating point types.
#define BUILD_NUMERIC_UNARY_OP_FP(OP_NAME, PREFIX) \
BUILD_NUMERIC_OP(OP_NAME, 1, PREFIX, F32, float) \
BUILD_NUMERIC_OP(OP_NAME, 1, PREFIX, F64, double)
BUILD_NUMERIC_BINOP_FP(CopySignOp, copysign)
BUILD_NUMERIC_BINOP_FP(DivOp, div)
BUILD_NUMERIC_BINOP_FP(MaxOp, max)
BUILD_NUMERIC_BINOP_FP(MinOp, min)
BUILD_NUMERIC_BINOP_INT(AndOp, and)
BUILD_NUMERIC_BINOP_INT(DivSIOp, divS)
BUILD_NUMERIC_BINOP_INT(DivUIOp, divU)
BUILD_NUMERIC_BINOP_INT(OrOp, or)
BUILD_NUMERIC_BINOP_INT(RemSIOp, remS)
BUILD_NUMERIC_BINOP_INT(RemUIOp, remU)
BUILD_NUMERIC_BINOP_INT(RotlOp, rotl)
BUILD_NUMERIC_BINOP_INT(RotrOp, rotr)
BUILD_NUMERIC_BINOP_INT(ShLOp, shl)
BUILD_NUMERIC_BINOP_INT(ShRSOp, shrS)
BUILD_NUMERIC_BINOP_INT(ShRUOp, shrU)
BUILD_NUMERIC_BINOP_INT(XOrOp, xor)
BUILD_NUMERIC_BINOP_INTFP(AddOp, add)
BUILD_NUMERIC_BINOP_INTFP(MulOp, mul)
BUILD_NUMERIC_BINOP_INTFP(SubOp, sub)
BUILD_NUMERIC_UNARY_OP_FP(AbsOp, abs)
BUILD_NUMERIC_UNARY_OP_FP(CeilOp, ceil)
BUILD_NUMERIC_UNARY_OP_FP(FloorOp, floor)
BUILD_NUMERIC_UNARY_OP_FP(NegOp, neg)
BUILD_NUMERIC_UNARY_OP_FP(SqrtOp, sqrt)
BUILD_NUMERIC_UNARY_OP_FP(TruncOp, trunc)
BUILD_NUMERIC_UNARY_OP_INT(ClzOp, clz)
BUILD_NUMERIC_UNARY_OP_INT(CtzOp, ctz)
BUILD_NUMERIC_UNARY_OP_INT(PopCntOp, popcnt)
// Don't need these anymore so let's undef them.
#undef BUILD_NUMERIC_BINOP_FP
#undef BUILD_NUMERIC_BINOP_INT
#undef BUILD_NUMERIC_BINOP_INTFP
#undef BUILD_NUMERIC_UNARY_OP_FP
#undef BUILD_NUMERIC_UNARY_OP_INT
#undef BUILD_NUMERIC_OP
#undef BUILD_NUMERIC_CAST_OP
class WasmBinaryParser {
private:
struct SectionRegistry {
@ -907,7 +1133,7 @@ private:
if (failed(nElemsParsed))
return failure();
uint32_t nElems = *nElemsParsed;
LDBG() << "Starting to parse " << nElems << " items for section "
LDBG() << "starting to parse " << nElems << " items for section "
<< secName;
for (size_t i = 0; i < nElems; ++i) {
if (failed(parseSectionItem<section>(ph, i)))
@ -1006,7 +1232,7 @@ public:
return;
if (version->compare(expectedVersionString)) {
emitError(versionLoc,
"unsupported Wasm version. Only version 1 is supported.");
"unsupported Wasm version. only version 1 is supported");
return;
}
LogicalResult fillRegistry = registry.populateFromBody(parser.copy());
@ -1037,6 +1263,14 @@ public:
if (failed(parsingMems))
return;
LogicalResult parsingGlobals = parseSection<WasmSectionType::GLOBAL>();
if (failed(parsingGlobals))
return;
LogicalResult parsingCode = parseSection<WasmSectionType::CODE>();
if (failed(parsingCode))
return;
LogicalResult parsingExports = parseSection<WasmSectionType::EXPORT>();
if (failed(parsingExports))
return;
@ -1193,10 +1427,9 @@ WasmBinaryParser::parseSectionItem<WasmSectionType::FUNCTION>(ParserHead &ph,
auto funcOp =
FuncOp::create(builder, opLoc, symbol, symbols.moduleFuncTypes[typeIdx]);
Block *block = funcOp.addEntryBlock();
auto ip = builder.saveInsertionPoint();
OpBuilder::InsertionGuard guard{builder};
builder.setInsertionPointToEnd(block);
ReturnOp::create(builder, opLoc);
builder.restoreInsertionPoint(ip);
symbols.funcSymbols.push_back(
{{FlatSymbolRefAttr::get(funcOp.getSymNameAttr())},
symbols.moduleFuncTypes[typeIdx]});
@ -1230,6 +1463,50 @@ WasmBinaryParser::parseSectionItem<WasmSectionType::MEMORY>(ParserHead &ph,
symbols.memSymbols.push_back({SymbolRefAttr::get(memOp)});
return success();
}
template <>
LogicalResult
WasmBinaryParser::parseSectionItem<WasmSectionType::GLOBAL>(ParserHead &ph,
size_t) {
FileLineColLoc globalLocation = ph.getLocation();
auto globalTypeParsed = ph.parseGlobalType(ctx);
if (failed(globalTypeParsed))
return failure();
GlobalTypeRecord globalType = *globalTypeParsed;
auto symbol = builder.getStringAttr(symbols.getNewGlobalSymbolName());
auto globalOp = builder.create<wasmssa::GlobalOp>(
globalLocation, symbol, globalType.type, globalType.isMutable);
symbols.globalSymbols.push_back(
{{FlatSymbolRefAttr::get(globalOp)}, globalOp.getType()});
OpBuilder::InsertionGuard guard{builder};
Block *block = builder.createBlock(&globalOp.getInitializer());
builder.setInsertionPointToStart(block);
parsed_inst_t expr = ph.parseExpression(builder, symbols);
if (failed(expr))
return failure();
if (block->empty())
return emitError(globalLocation, "global with empty initializer");
if (expr->size() != 1 && (*expr)[0].getType() != globalType.type)
return emitError(
globalLocation,
"initializer result type does not match global declaration type");
builder.create<ReturnOp>(globalLocation, *expr);
return success();
}
template <>
LogicalResult WasmBinaryParser::parseSectionItem<WasmSectionType::CODE>(
ParserHead &ph, size_t innerFunctionId) {
unsigned long funcId = innerFunctionId + firstInternalFuncID;
FunctionSymbolRefContainer symRef = symbols.funcSymbols[funcId];
auto funcOp =
dyn_cast<FuncOp>(SymbolTable::lookupSymbolIn(mOp, symRef.symbol));
assert(funcOp);
if (failed(ph.parseCodeFor(funcOp, symbols)))
return failure();
return success();
}
} // namespace
namespace mlir::wasm {

View File

@ -0,0 +1,23 @@
// RUN: yaml2obj %S/inputs/abs.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "abs_f32") (result f32)
f32.const 10
f32.abs)
(func (export "abs_f64") (result f64)
f64.const 10
f64.abs)
)
*/
// CHECK-LABEL: wasmssa.func @abs_f32() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f32
// CHECK: %[[VAL_1:.*]] = wasmssa.abs %[[VAL_0]] : f32
// CHECK: wasmssa.return %[[VAL_1]] : f32
// CHECK-LABEL: wasmssa.func @abs_f64() -> f64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f64
// CHECK: %[[VAL_1:.*]] = wasmssa.abs %[[VAL_0]] : f64
// CHECK: wasmssa.return %[[VAL_1]] : f64

View File

@ -0,0 +1,27 @@
// RUN: yaml2obj %S/inputs/and.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "and_i32") (result i32)
i32.const 10
i32.const 3
i32.and)
(func (export "and_i64") (result i64)
i64.const 10
i64.const 3
i64.and)
)
*/
// CHECK-LABEL: wasmssa.func @and_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.and %0 %1 : i32
// CHECK: wasmssa.return %2 : i32
// CHECK-LABEL: wasmssa.func @and_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.and %0 %1 : i64
// CHECK: wasmssa.return %2 : i64

View File

@ -0,0 +1,25 @@
// RUN: yaml2obj %S/inputs/clz.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "clz_i32") (result i32)
i32.const 10
i32.clz
)
(func (export "clz_i64") (result i64)
i64.const 10
i64.clz
)
)
*/
// CHECK-LABEL: wasmssa.func @clz_i32() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.clz %[[VAL_0]] : i32
// CHECK: wasmssa.return %[[VAL_1]] : i32
// CHECK-LABEL: wasmssa.func @clz_i64() -> i64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i64
// CHECK: %[[VAL_1:.*]] = wasmssa.clz %[[VAL_0]] : i64
// CHECK: wasmssa.return %[[VAL_1]] : i64

View File

@ -0,0 +1,37 @@
// RUN: yaml2obj %S/inputs/const.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to create this test:
(module
(func(result i32)
i32.const 1
)
(func (result i64)
i64.const 3
)
(func (result f32)
f32.const 4.0
)
(func (result f64)
f64.const 9.0
)
)
*/
// CHECK-LABEL: wasmssa.func nested @func_0() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1 : i32
// CHECK: wasmssa.return %[[VAL_0]] : i32
// CHECK: }
// CHECK-LABEL: wasmssa.func nested @func_1() -> i64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 3 : i64
// CHECK: wasmssa.return %[[VAL_0]] : i64
// CHECK: }
// CHECK-LABEL: wasmssa.func nested @func_2() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 4.000000e+00 : f32
// CHECK: wasmssa.return %[[VAL_0]] : f32
// CHECK: }
// CHECK-LABEL: wasmssa.func nested @func_3() -> f64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 9.000000e+00 : f64
// CHECK: wasmssa.return %[[VAL_0]] : f64
// CHECK: }

View File

@ -0,0 +1,31 @@
// RUN: yaml2obj %S/inputs/copysign.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "copysign_f32") (result f32)
f32.const 10
f32.const 1
f32.copysign
)
(func (export "copysign_f64") (result f64)
f64.const 10
f64.const 1
f64.copysign
)
)
*/
// CHECK-LABEL: wasmssa.func @copysign_f32() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 1.000000e+00 : f32
// CHECK: %[[VAL_2:.*]] = wasmssa.copysign %[[VAL_0]] %[[VAL_1]] : f32
// CHECK: wasmssa.return %[[VAL_2]] : f32
// CHECK: }
// CHECK-LABEL: wasmssa.func @copysign_f64() -> f64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 1.000000e+00 : f64
// CHECK: %[[VAL_2:.*]] = wasmssa.copysign %[[VAL_0]] %[[VAL_1]] : f64
// CHECK: wasmssa.return %[[VAL_2]] : f64
// CHECK: }

View File

@ -0,0 +1,25 @@
// RUN: yaml2obj %S/inputs/ctz.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "ctz_i32") (result i32)
i32.const 10
i32.ctz
)
(func (export "ctz_i64") (result i64)
i64.const 10
i64.ctz
)
)
*/
// CHECK-LABEL: wasmssa.func @ctz_i32() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.ctz %[[VAL_0]] : i32
// CHECK: wasmssa.return %[[VAL_1]] : i32
// CHECK-LABEL: wasmssa.func @ctz_i64() -> i64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i64
// CHECK: %[[VAL_1:.*]] = wasmssa.ctz %[[VAL_0]] : i64
// CHECK: wasmssa.return %[[VAL_1]] : i64

View File

@ -0,0 +1,127 @@
// RUN: yaml2obj %S/inputs/div.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to create this test:
(module
(func (export "div_u_i32") (result i32)
i32.const 10
i32.const 2
i32.div_u
)
(func (export "div_u_i32_zero") (result i32)
i32.const 10
i32.const 0
i32.div_u
)
(func (export "div_s_i32") (result i32)
i32.const 10
i32.const 2
i32.div_s
)
(func (export "div_s_i32_zero") (result i32)
i32.const 10
i32.const 0
i32.div_s
)
(func (export "div_u_i64") (result i64)
i64.const 10
i64.const 2
i64.div_u
)
;; explode
(func (export "div_u_i64_zero") (result i64)
i64.const 10
i64.const 0
i64.div_u
)
(func (export "div_s_i64") (result i64)
i64.const 10
i64.const 2
i64.div_s
)
;; explode
(func (export "div_s_i64_zero") (result i64)
i64.const 10
i64.const 0
i64.div_s
)
(func (export "div_f32") (result f32)
f32.const 10
f32.const 2
f32.div
)
(func (export "div_f64") (result f64)
f64.const 10
f64.const 2
f64.div
)
)
*/
// CHECK-LABEL: wasmssa.func @div_u_i32() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 2 : i32
// CHECK: %[[VAL_2:.*]] = wasmssa.div_ui %[[VAL_0]] %[[VAL_1]] : i32
// CHECK: wasmssa.return %[[VAL_2]] : i32
// CHECK-LABEL: wasmssa.func @div_u_i32_zero() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 0 : i32
// CHECK: %[[VAL_2:.*]] = wasmssa.div_ui %[[VAL_0]] %[[VAL_1]] : i32
// CHECK: wasmssa.return %[[VAL_2]] : i32
// CHECK-LABEL: wasmssa.func @div_s_i32() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 2 : i32
// CHECK: %[[VAL_2:.*]] = wasmssa.div_si %[[VAL_0]] %[[VAL_1]] : i32
// CHECK: wasmssa.return %[[VAL_2]] : i32
// CHECK-LABEL: wasmssa.func @div_s_i32_zero() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 0 : i32
// CHECK: %[[VAL_2:.*]] = wasmssa.div_si %[[VAL_0]] %[[VAL_1]] : i32
// CHECK: wasmssa.return %[[VAL_2]] : i32
// CHECK-LABEL: wasmssa.func @div_u_i64() -> i64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 2 : i64
// CHECK: %[[VAL_2:.*]] = wasmssa.div_ui %[[VAL_0]] %[[VAL_1]] : i64
// CHECK: wasmssa.return %[[VAL_2]] : i64
// CHECK-LABEL: wasmssa.func @div_u_i64_zero() -> i64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 0 : i64
// CHECK: %[[VAL_2:.*]] = wasmssa.div_ui %[[VAL_0]] %[[VAL_1]] : i64
// CHECK: wasmssa.return %[[VAL_2]] : i64
// CHECK-LABEL: wasmssa.func @div_s_i64() -> i64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 2 : i64
// CHECK: %[[VAL_2:.*]] = wasmssa.div_si %[[VAL_0]] %[[VAL_1]] : i64
// CHECK: wasmssa.return %[[VAL_2]] : i64
// CHECK-LABEL: wasmssa.func @div_s_i64_zero() -> i64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 0 : i64
// CHECK: %[[VAL_2:.*]] = wasmssa.div_si %[[VAL_0]] %[[VAL_1]] : i64
// CHECK: wasmssa.return %[[VAL_2]] : i64
// CHECK-LABEL: wasmssa.func @div_f32() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 2.000000e+00 : f32
// CHECK: %[[VAL_2:.*]] = wasmssa.div %[[VAL_0]] %[[VAL_1]] : f32
// CHECK: wasmssa.return %[[VAL_2]] : f32
// CHECK-LABEL: wasmssa.func @div_f64() -> f64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 2.000000e+00 : f64
// CHECK: %[[VAL_2:.*]] = wasmssa.div %[[VAL_0]] %[[VAL_1]] : f64
// CHECK: wasmssa.return %[[VAL_2]] : f64

View File

@ -0,0 +1,66 @@
// RUN: yaml2obj %S/inputs/global.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to create this test:
(module
;; import a global variable from js
(global $imported_glob (import "env" "from_js") i32)
;; create a global variable
(global $normal_glob i32(i32.const 10))
(global $glob_mut (mut i32) (i32.const 10))
(global $glob_mut_ext (mut i32) (i32.const 10))
(global $normal_glob_i64 i64(i64.const 11))
(global $normal_glob_f32 f32(f32.const 12))
(global $normal_glob_f64 f64(f64.const 13))
(func $main (result i32)
;; load both global variables onto the stack
global.get $imported_glob
global.get $normal_glob
i32.add ;; add up both globals
global.get $glob_mut
global.get $glob_mut_ext
i32.add
i32.add
)
)
*/
// CHECK-LABEL: wasmssa.import_global "from_js" from "env" as @global_0 nested : i32
// CHECK-LABEL: wasmssa.func nested @func_0() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.global_get @global_0 : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.global_get @global_1 : i32
// CHECK: %[[VAL_2:.*]] = wasmssa.add %[[VAL_0]] %[[VAL_1]] : i32
// CHECK: %[[VAL_3:.*]] = wasmssa.global_get @global_2 : i32
// CHECK: %[[VAL_4:.*]] = wasmssa.global_get @global_3 : i32
// CHECK: %[[VAL_5:.*]] = wasmssa.add %[[VAL_3]] %[[VAL_4]] : i32
// CHECK: %[[VAL_6:.*]] = wasmssa.add %[[VAL_2]] %[[VAL_5]] : i32
// CHECK: wasmssa.return %[[VAL_6]] : i32
// CHECK-LABEL: wasmssa.global @global_1 i32 nested : {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: wasmssa.return %[[VAL_0]] : i32
// CHECK-LABEL: wasmssa.global @global_2 i32 mutable nested : {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: wasmssa.return %[[VAL_0]] : i32
// CHECK-LABEL: wasmssa.global @global_3 i32 mutable nested : {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: wasmssa.return %[[VAL_0]] : i32
// CHECK-LABEL: wasmssa.global @global_4 i64 nested : {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 11 : i64
// CHECK: wasmssa.return %[[VAL_0]] : i64
// CHECK-LABEL: wasmssa.global @global_5 f32 nested : {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.200000e+01 : f32
// CHECK: wasmssa.return %[[VAL_0]] : f32
// CHECK-LABEL: wasmssa.global @global_6 f64 nested : {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.300000e+01 : f64
// CHECK: wasmssa.return %[[VAL_0]] : f64

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- F32
- Index: 1
ParamTypes: []
ReturnTypes:
- F64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: abs_f32
Kind: FUNCTION
Index: 0
- Name: abs_f64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 43000020418B0B
- Index: 1
Locals: []
Body: 440000000000002440990B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: and_i32
Kind: FUNCTION
Index: 0
- Name: and_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A4103710B
- Index: 1
Locals: []
Body: 420A4203830B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: clz_i32
Kind: FUNCTION
Index: 0
- Name: clz_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A670B
- Index: 1
Locals: []
Body: 420A790B
...

View File

@ -0,0 +1,39 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Index: 2
ParamTypes: []
ReturnTypes:
- F32
- Index: 3
ParamTypes: []
ReturnTypes:
- F64
- Type: FUNCTION
FunctionTypes: [ 0, 1, 2, 3 ]
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 41010B
- Index: 1
Locals: []
Body: 42030B
- Index: 2
Locals: []
Body: 43000080400B
- Index: 3
Locals: []
Body: 4400000000000022400B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- F32
- Index: 1
ParamTypes: []
ReturnTypes:
- F64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: copysign_f32
Kind: FUNCTION
Index: 0
- Name: copysign_f64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 4300002041430000803F980B
- Index: 1
Locals: []
Body: 44000000000000244044000000000000F03FA60B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: ctz_i32
Kind: FUNCTION
Index: 0
- Name: ctz_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A680B
- Index: 1
Locals: []
Body: 420A7A0B
...

View File

@ -0,0 +1,89 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Index: 2
ParamTypes: []
ReturnTypes:
- F32
- Index: 3
ParamTypes: []
ReturnTypes:
- F64
- Type: FUNCTION
FunctionTypes: [ 0, 0, 0, 0, 1, 1, 1, 1, 2, 3 ]
- Type: EXPORT
Exports:
- Name: div_u_i32
Kind: FUNCTION
Index: 0
- Name: div_u_i32_zero
Kind: FUNCTION
Index: 1
- Name: div_s_i32
Kind: FUNCTION
Index: 2
- Name: div_s_i32_zero
Kind: FUNCTION
Index: 3
- Name: div_u_i64
Kind: FUNCTION
Index: 4
- Name: div_u_i64_zero
Kind: FUNCTION
Index: 5
- Name: div_s_i64
Kind: FUNCTION
Index: 6
- Name: div_s_i64_zero
Kind: FUNCTION
Index: 7
- Name: div_f32
Kind: FUNCTION
Index: 8
- Name: div_f64
Kind: FUNCTION
Index: 9
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A41026E0B
- Index: 1
Locals: []
Body: 410A41006E0B
- Index: 2
Locals: []
Body: 410A41026D0B
- Index: 3
Locals: []
Body: 410A41006D0B
- Index: 4
Locals: []
Body: 420A4202800B
- Index: 5
Locals: []
Body: 420A4200800B
- Index: 6
Locals: []
Body: 420A42027F0B
- Index: 7
Locals: []
Body: 420A42007F0B
- Index: 8
Locals: []
Body: 43000020414300000040950B
- Index: 9
Locals: []
Body: 440000000000002440440000000000000040A30B
...

View File

@ -0,0 +1,63 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Type: IMPORT
Imports:
- Module: env
Field: from_js
Kind: GLOBAL
GlobalType: I32
GlobalMutable: false
- Type: FUNCTION
FunctionTypes: [ 0 ]
- Type: GLOBAL
Globals:
- Index: 1
Type: I32
Mutable: false
InitExpr:
Opcode: I32_CONST
Value: 10
- Index: 2
Type: I32
Mutable: true
InitExpr:
Opcode: I32_CONST
Value: 10
- Index: 3
Type: I32
Mutable: true
InitExpr:
Opcode: I32_CONST
Value: 10
- Index: 4
Type: I64
Mutable: false
InitExpr:
Opcode: I64_CONST
Value: 11
- Index: 5
Type: F32
Mutable: false
InitExpr:
Opcode: F32_CONST
Value: 1094713344
- Index: 6
Type: F64
Mutable: false
InitExpr:
Opcode: F64_CONST
Value: 4623507967449235456
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 230023016A230223036A6A0B
...

View File

@ -0,0 +1,37 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- F32
- Index: 1
ParamTypes: []
ReturnTypes:
- I32
- Index: 2
ParamTypes:
- I32
ReturnTypes:
- I32
- Type: FUNCTION
FunctionTypes: [ 0, 1, 2 ]
- Type: CODE
Functions:
- Index: 0
Locals:
- Type: F32
Count: 2
Body: 43000000412100200043000040412201920B
- Index: 1
Locals:
- Type: I32
Count: 2
Body: 410821002000410C22016A0B
- Index: 2
Locals: []
Body: 4103210020000B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- F32
- Index: 1
ParamTypes: []
ReturnTypes:
- F64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: min_f32
Kind: FUNCTION
Index: 0
- Name: min_f64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 4300002041430000803F970B
- Index: 1
Locals: []
Body: 44000000000000244044000000000000F03FA50B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- F32
- Index: 1
ParamTypes: []
ReturnTypes:
- F64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: min_f32
Kind: FUNCTION
Index: 0
- Name: min_f64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 4300002041430000803F960B
- Index: 1
Locals: []
Body: 44000000000000244044000000000000F03FA40B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- F32
- Index: 1
ParamTypes: []
ReturnTypes:
- F64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: neg_f32
Kind: FUNCTION
Index: 0
- Name: neg_f64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 43000020418C0B
- Index: 1
Locals: []
Body: 4400000000000024409A0B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: or_i32
Kind: FUNCTION
Index: 0
- Name: or_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A4103720B
- Index: 1
Locals: []
Body: 420A4203840B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: popcnt_i32
Kind: FUNCTION
Index: 0
- Name: popcnt_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A690B
- Index: 1
Locals: []
Body: 420A7B0B
...

View File

@ -0,0 +1,45 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1, 0, 1 ]
- Type: EXPORT
Exports:
- Name: rem_u_i32
Kind: FUNCTION
Index: 0
- Name: rem_u_i64
Kind: FUNCTION
Index: 1
- Name: rem_s_i32
Kind: FUNCTION
Index: 2
- Name: rem_s_i64
Kind: FUNCTION
Index: 3
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A4103700B
- Index: 1
Locals: []
Body: 420A4203820B
- Index: 2
Locals: []
Body: 410A41036F0B
- Index: 3
Locals: []
Body: 420A4203810B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: rotl_i32
Kind: FUNCTION
Index: 0
- Name: rotl_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A4103770B
- Index: 1
Locals: []
Body: 420A4203890B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: rotr_i32
Kind: FUNCTION
Index: 0
- Name: rotr_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A4103780B
- Index: 1
Locals: []
Body: 420A42038A0B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: shl_i32
Kind: FUNCTION
Index: 0
- Name: shl_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A4103740B
- Index: 1
Locals: []
Body: 420A4203860B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: shr_s_i32
Kind: FUNCTION
Index: 0
- Name: shr_s_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A4103750B
- Index: 1
Locals: []
Body: 420A4203870B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: shr_u_i32
Kind: FUNCTION
Index: 0
- Name: shr_u_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A4103760B
- Index: 1
Locals: []
Body: 420A4203880B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- F32
- Index: 1
ParamTypes: []
ReturnTypes:
- F64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: sqrt_f32
Kind: FUNCTION
Index: 0
- Name: sqrt_f64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 4300002041910B
- Index: 1
Locals: []
Body: 4400000000000024409F0B
...

View File

@ -0,0 +1,39 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Index: 2
ParamTypes: []
ReturnTypes:
- F32
- Index: 3
ParamTypes: []
ReturnTypes:
- F64
- Type: FUNCTION
FunctionTypes: [ 0, 1, 2, 3 ]
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410C41326B0B
- Index: 1
Locals: []
Body: 421442057D0B
- Index: 2
Locals: []
Body: 430000A0404300006041930B
- Index: 3
Locals: []
Body: 440000000000003140440000000000000000A10B
...

View File

@ -0,0 +1,33 @@
--- !WASM
FileHeader:
Version: 0x1
Sections:
- Type: TYPE
Signatures:
- Index: 0
ParamTypes: []
ReturnTypes:
- I32
- Index: 1
ParamTypes: []
ReturnTypes:
- I64
- Type: FUNCTION
FunctionTypes: [ 0, 1 ]
- Type: EXPORT
Exports:
- Name: xor_i32
Kind: FUNCTION
Index: 0
- Name: xor_i64
Kind: FUNCTION
Index: 1
- Type: CODE
Functions:
- Index: 0
Locals: []
Body: 410A4103730B
- Index: 1
Locals: []
Body: 420A4203850B
...

View File

@ -0,0 +1,59 @@
// RUN: yaml2obj %S/inputs/local.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to create this test:
(module
(func $local_f32 (result f32)
(local $var1 f32)
(local $var2 f32)
f32.const 8.0
local.set $var1
local.get $var1
f32.const 12.0
local.tee $var2
f32.add
)
(func $local_i32 (result i32)
(local $var1 i32)
(local $var2 i32)
i32.const 8
local.set $var1
local.get $var1
i32.const 12
local.tee $var2
i32.add
)
(func $local_arg (param $var i32) (result i32)
i32.const 3
local.set $var
local.get $var
)
)
*/
// CHECK-LABEL: wasmssa.func nested @func_0() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.local of type f32
// CHECK: %[[VAL_1:.*]] = wasmssa.local of type f32
// CHECK: %[[VAL_2:.*]] = wasmssa.const 8.000000e+00 : f32
// CHECK: wasmssa.local_set %[[VAL_0]] : ref to f32 to %[[VAL_2]] : f32
// CHECK: %[[VAL_3:.*]] = wasmssa.local_get %[[VAL_0]] : ref to f32
// CHECK: %[[VAL_4:.*]] = wasmssa.const 1.200000e+01 : f32
// CHECK: %[[VAL_5:.*]] = wasmssa.local_tee %[[VAL_1]] : ref to f32 to %[[VAL_4]] : f32
// CHECK: %[[VAL_6:.*]] = wasmssa.add %[[VAL_3]] %[[VAL_5]] : f32
// CHECK: wasmssa.return %[[VAL_6]] : f32
// CHECK-LABEL: wasmssa.func nested @func_1() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.local of type i32
// CHECK: %[[VAL_1:.*]] = wasmssa.local of type i32
// CHECK: %[[VAL_2:.*]] = wasmssa.const 8 : i32
// CHECK: wasmssa.local_set %[[VAL_0]] : ref to i32 to %[[VAL_2]] : i32
// CHECK: %[[VAL_3:.*]] = wasmssa.local_get %[[VAL_0]] : ref to i32
// CHECK: %[[VAL_4:.*]] = wasmssa.const 12 : i32
// CHECK: %[[VAL_5:.*]] = wasmssa.local_tee %[[VAL_1]] : ref to i32 to %[[VAL_4]] : i32
// CHECK: %[[VAL_6:.*]] = wasmssa.add %[[VAL_3]] %[[VAL_5]] : i32
// CHECK: wasmssa.return %[[VAL_6]] : i32
// CHECK-LABEL: wasmssa.func nested @func_2(
// CHECK-SAME: %[[ARG0:.*]]: !wasmssa<local ref to i32>) -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 3 : i32
// CHECK: wasmssa.local_set %[[ARG0]] : ref to i32 to %[[VAL_0]] : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.local_get %[[ARG0]] : ref to i32
// CHECK: wasmssa.return %[[VAL_1]] : i32

View File

@ -0,0 +1,30 @@
// RUN: yaml2obj %S/inputs/max.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "max_f32") (result f32)
f32.const 10
f32.const 1
f32.max
)
(func (export "max_f64") (result f64)
f64.const 10
f64.const 1
f64.max
)
)
*/
// CHECK-LABEL: wasmssa.func @min_f32() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 1.000000e+00 : f32
// CHECK: %[[VAL_2:.*]] = wasmssa.max %[[VAL_0]] %[[VAL_1]] : f32
// CHECK: wasmssa.return %[[VAL_2]] : f32
// CHECK-LABEL: wasmssa.func @min_f64() -> f64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 1.000000e+00 : f64
// CHECK: %[[VAL_2:.*]] = wasmssa.max %[[VAL_0]] %[[VAL_1]] : f64
// CHECK: wasmssa.return %[[VAL_2]] : f64

View File

@ -0,0 +1,29 @@
// RUN: yaml2obj %S/inputs/min.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "min_f32") (result f32)
f32.const 10
f32.const 1
f32.min
)
(func (export "min_f64") (result f64)
f64.const 10
f64.const 1
f64.min
)
)
*/
// CHECK-LABEL: wasmssa.func @min_f32() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 1.000000e+00 : f32
// CHECK: %[[VAL_2:.*]] = wasmssa.min %[[VAL_0]] %[[VAL_1]] : f32
// CHECK: wasmssa.return %[[VAL_2]] : f32
// CHECK-LABEL: wasmssa.func @min_f64() -> f64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 1.000000e+00 : f64
// CHECK: %[[VAL_2:.*]] = wasmssa.min %[[VAL_0]] %[[VAL_1]] : f64
// CHECK: wasmssa.return %[[VAL_2]] : f64

View File

@ -0,0 +1,23 @@
// RUN: yaml2obj %S/inputs/neg.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "neg_f32") (result f32)
f32.const 10
f32.neg)
(func (export "neg_f64") (result f64)
f64.const 10
f64.neg)
)
*/
// CHECK-LABEL: wasmssa.func @neg_f32() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f32
// CHECK: %[[VAL_1:.*]] = wasmssa.neg %[[VAL_0]] : f32
// CHECK: wasmssa.return %[[VAL_1]] : f32
// CHECK-LABEL: wasmssa.func @neg_f64() -> f64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f64
// CHECK: %[[VAL_1:.*]] = wasmssa.neg %[[VAL_0]] : f64
// CHECK: wasmssa.return %[[VAL_1]] : f64

View File

@ -0,0 +1,27 @@
// RUN: yaml2obj %S/inputs/or.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "or_i32") (result i32)
i32.const 10
i32.const 3
i32.or)
(func (export "or_i64") (result i64)
i64.const 10
i64.const 3
i64.or)
)
*/
// CHECK-LABEL: wasmssa.func @or_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.or %0 %1 : i32
// CHECK: wasmssa.return %2 : i32
// CHECK-LABEL: wasmssa.func @or_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.or %0 %1 : i64
// CHECK: wasmssa.return %2 : i64

View File

@ -0,0 +1,25 @@
// RUN: yaml2obj %S/inputs/popcnt.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "popcnt_i32") (result i32)
i32.const 10
i32.popcnt
)
(func (export "popcnt_i64") (result i64)
i64.const 10
i64.popcnt
)
)
*/
// CHECK-LABEL: wasmssa.func @popcnt_i32() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.popcnt %[[VAL_0]] : i32
// CHECK: wasmssa.return %[[VAL_1]] : i32
// CHECK-LABEL: wasmssa.func @popcnt_i64() -> i64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 10 : i64
// CHECK: %[[VAL_1:.*]] = wasmssa.popcnt %[[VAL_0]] : i64
// CHECK: wasmssa.return %[[VAL_1]] : i64

View File

@ -0,0 +1,53 @@
// RUN: yaml2obj %S/inputs/rem.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "rem_u_i32") (result i32)
i32.const 10
i32.const 3
i32.rem_u)
(func (export "rem_u_i64") (result i64)
i64.const 10
i64.const 3
i64.rem_u)
(func (export "rem_s_i32") (result i32)
i32.const 10
i32.const 3
i32.rem_s)
(func (export "rem_s_i64") (result i64)
i64.const 10
i64.const 3
i64.rem_s)
)
*/
// CHECK-LABEL: wasmssa.func @rem_u_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.rem_ui %0 %1 : i32
// CHECK: wasmssa.return %2 : i32
// CHECK: }
// CHECK-LABEL: wasmssa.func @rem_u_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.rem_ui %0 %1 : i64
// CHECK: wasmssa.return %2 : i64
// CHECK: }
// CHECK-LABEL: wasmssa.func @rem_s_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.rem_si %0 %1 : i32
// CHECK: wasmssa.return %2 : i32
// CHECK: }
// CHECK-LABEL: wasmssa.func @rem_s_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.rem_si %0 %1 : i64
// CHECK: wasmssa.return %2 : i64
// CHECK: }

View File

@ -0,0 +1,27 @@
// RUN: yaml2obj %S/inputs/rotl.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "rotl_i32") (result i32)
i32.const 10
i32.const 3
i32.rotl)
(func (export "rotl_i64") (result i64)
i64.const 10
i64.const 3
i64.rotl)
)
*/
// CHECK-LABEL: wasmssa.func @rotl_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.rotl %0 by %1 bits : i32
// CHECK: wasmssa.return %2 : i32
// CHECK-LABEL: wasmssa.func @rotl_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.rotl %0 by %1 bits : i64
// CHECK: wasmssa.return %2 : i64

View File

@ -0,0 +1,27 @@
// RUN: yaml2obj %S/inputs/rotr.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "rotr_i32") (result i32)
i32.const 10
i32.const 3
i32.rotr)
(func (export "rotr_i64") (result i64)
i64.const 10
i64.const 3
i64.rotr)
)
*/
// CHECK-LABEL: wasmssa.func @rotr_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.rotr %0 by %1 bits : i32
// CHECK: wasmssa.return %2 : i32
// CHECK-LABEL: wasmssa.func @rotr_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.rotr %0 by %1 bits : i64
// CHECK: wasmssa.return %2 : i64

View File

@ -0,0 +1,27 @@
// RUN: yaml2obj %S/inputs/shl.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "shl_i32") (result i32)
i32.const 10
i32.const 3
i32.shl)
(func (export "shl_i64") (result i64)
i64.const 10
i64.const 3
i64.shl)
)
*/
// CHECK-LABEL: wasmssa.func @shl_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.shl %0 by %1 bits : i32
// CHECK: wasmssa.return %2 : i32
// CHECK-LABEL: wasmssa.func @shl_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.shl %0 by %1 bits : i64
// CHECK: wasmssa.return %2 : i64

View File

@ -0,0 +1,27 @@
// RUN: yaml2obj %S/inputs/shr_s.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "shr_s_i32") (result i32)
i32.const 10
i32.const 3
i32.shr_s)
(func (export "shr_s_i64") (result i64)
i64.const 10
i64.const 3
i64.shr_s)
)
*/
// CHECK-LABEL: wasmssa.func @shr_s_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.shr_s %0 by %1 bits : i32
// CHECK: wasmssa.return %2 : i32
// CHECK-LABEL: wasmssa.func @shr_s_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.shr_s %0 by %1 bits : i64
// CHECK: wasmssa.return %2 : i64

View File

@ -0,0 +1,27 @@
// RUN: yaml2obj %S/inputs/shr_u.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "shr_u_i32") (result i32)
i32.const 10
i32.const 3
i32.shr_u)
(func (export "shr_u_i64") (result i64)
i64.const 10
i64.const 3
i64.shr_u)
)
*/
// CHECK-LABEL: wasmssa.func @shr_u_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.shr_u %0 by %1 bits : i32
// CHECK: wasmssa.return %2 : i32
// CHECK-LABEL: wasmssa.func @shr_u_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.shr_u %0 by %1 bits : i64
// CHECK: wasmssa.return %2 : i64

View File

@ -0,0 +1,23 @@
// RUN: yaml2obj %S/inputs/sqrt.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "sqrt_f32") (result f32)
f32.const 10
f32.sqrt)
(func (export "sqrt_f64") (result f64)
f64.const 10
f64.sqrt)
)
*/
// CHECK-LABEL: wasmssa.func @sqrt_f32() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f32
// CHECK: %[[VAL_1:.*]] = wasmssa.sqrt %[[VAL_0]] : f32
// CHECK: wasmssa.return %[[VAL_1]] : f32
// CHECK-LABEL: wasmssa.func @sqrt_f64() -> f64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.000000e+01 : f64
// CHECK: %[[VAL_1:.*]] = wasmssa.sqrt %[[VAL_0]] : f64
// CHECK: wasmssa.return %[[VAL_1]] : f64

View File

@ -0,0 +1,52 @@
// RUN: yaml2obj %S/inputs/sub.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to create this test:
(module
(func $sub_i32 (result i32)
i32.const 12
i32.const 50
i32.sub
)
(func $sub_i64 (result i64)
i64.const 20
i64.const 5
i64.sub
)
(func $sub_f32 (result f32)
f32.const 5
f32.const 14
f32.sub
)
(func $sub_f64 (result f64)
f64.const 17
f64.const 0
f64.sub
)
)
*/
// CHECK-LABEL: wasmssa.func nested @func_0() -> i32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 12 : i32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 50 : i32
// CHECK: %[[VAL_2:.*]] = wasmssa.sub %[[VAL_0]] %[[VAL_1]] : i32
// CHECK: wasmssa.return %[[VAL_2]] : i32
// CHECK-LABEL: wasmssa.func nested @func_1() -> i64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 20 : i64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 5 : i64
// CHECK: %[[VAL_2:.*]] = wasmssa.sub %[[VAL_0]] %[[VAL_1]] : i64
// CHECK: wasmssa.return %[[VAL_2]] : i64
// CHECK-LABEL: wasmssa.func nested @func_2() -> f32 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 5.000000e+00 : f32
// CHECK: %[[VAL_1:.*]] = wasmssa.const 1.400000e+01 : f32
// CHECK: %[[VAL_2:.*]] = wasmssa.sub %[[VAL_0]] %[[VAL_1]] : f32
// CHECK: wasmssa.return %[[VAL_2]] : f32
// CHECK-LABEL: wasmssa.func nested @func_3() -> f64 {
// CHECK: %[[VAL_0:.*]] = wasmssa.const 1.700000e+01 : f64
// CHECK: %[[VAL_1:.*]] = wasmssa.const 0.000000e+00 : f64
// CHECK: %[[VAL_2:.*]] = wasmssa.sub %[[VAL_0]] %[[VAL_1]] : f64
// CHECK: wasmssa.return %[[VAL_2]] : f64

View File

@ -0,0 +1,27 @@
// RUN: yaml2obj %S/inputs/xor.yaml.wasm -o - | mlir-translate --import-wasm | FileCheck %s
/* Source code used to generate this test:
(module
(func (export "xor_i32") (result i32)
i32.const 10
i32.const 3
i32.xor)
(func (export "xor_i64") (result i64)
i64.const 10
i64.const 3
i64.xor)
)
*/
// CHECK-LABEL: wasmssa.func @xor_i32() -> i32 {
// CHECK: %0 = wasmssa.const 10 : i32
// CHECK: %1 = wasmssa.const 3 : i32
// CHECK: %2 = wasmssa.xor %0 %1 : i32
// CHECK: wasmssa.return %2 : i32
// CHECK-LABEL: wasmssa.func @xor_i64() -> i64 {
// CHECK: %0 = wasmssa.const 10 : i64
// CHECK: %1 = wasmssa.const 3 : i64
// CHECK: %2 = wasmssa.xor %0 %1 : i64
// CHECK: wasmssa.return %2 : i64