diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 78057877031..98a5407d013 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -464,6 +464,8 @@ class TranslateToFuzzReader { Expression* makeGlobalGet(Type type); Expression* makeGlobalSet(Type type); Expression* makeTupleMake(Type type); + Expression* makeWideIntAddSub(Type type); + Expression* makeWideIntMul(Type type); Expression* makeTupleExtract(Type type); Expression* makePointer(); Expression* makeNonAtomicLoad(Type type); diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index e7696532472..c607d9c77d4 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -2564,6 +2564,10 @@ Expression* TranslateToFuzzReader::_makeConcrete(Type type) { } if (type.isTuple()) { options.add(FeatureSet::Multivalue, &Self::makeTupleMake); + if (type == Types::getI64Pair()) { + options.add(FeatureSet::WideArithmetic, &Self::makeWideIntAddSub); + options.add(FeatureSet::WideArithmetic, &Self::makeWideIntMul); + } } if (type.isRef()) { auto heapType = type.getHeapType(); @@ -3246,6 +3250,26 @@ Expression* TranslateToFuzzReader::makeTupleMake(Type type) { return builder.makeTupleMake(std::move(elements)); } +Expression* TranslateToFuzzReader::makeWideIntAddSub(Type type) { + assert(wasm.features.hasWideArithmetic()); + assert(type == Types::getI64Pair()); + auto op = upTo(2) == 0 ? AddInt128 : SubInt128; + auto* leftLow = make(Type::i64); + auto* leftHigh = make(Type::i64); + auto* rightLow = make(Type::i64); + auto* rightHigh = make(Type::i64); + return builder.makeWideIntAddSub(op, leftLow, leftHigh, rightLow, rightHigh); +} + +Expression* TranslateToFuzzReader::makeWideIntMul(Type type) { + assert(wasm.features.hasWideArithmetic()); + assert(type == Types::getI64Pair()); + auto op = upTo(2) == 0 ? MulWideSInt64 : MulWideUInt64; + auto* left = make(Type::i64); + auto* right = make(Type::i64); + return builder.makeWideIntMul(op, left, right); +} + Expression* TranslateToFuzzReader::makeTupleExtract(Type type) { // Tuples can require locals in binary format conversions. if (!type.isDefaultable()) {