summaryrefslogtreecommitdiff
path: root/src/binary-reader-ir.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/binary-reader-ir.cc')
-rw-r--r--src/binary-reader-ir.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/binary-reader-ir.cc b/src/binary-reader-ir.cc
index 9eba058b..6bf35ce3 100644
--- a/src/binary-reader-ir.cc
+++ b/src/binary-reader-ir.cc
@@ -526,6 +526,15 @@ Result BinaryReaderIR::OnFuncType(Index index,
auto func_type = std::make_unique<FuncType>();
func_type->sig.param_types.assign(param_types, param_types + param_count);
func_type->sig.result_types.assign(result_types, result_types + result_count);
+
+ module_->features_used.simd |=
+ std::any_of(func_type->sig.param_types.begin(),
+ func_type->sig.param_types.end(),
+ [](auto x) { return x == Type::V128; }) |
+ std::any_of(func_type->sig.result_types.begin(),
+ func_type->sig.result_types.end(),
+ [](auto x) { return x == Type::V128; });
+
field->type = std::move(func_type);
module_->AppendField(std::move(field));
return Result::Ok;
@@ -540,6 +549,7 @@ Result BinaryReaderIR::OnStructType(Index index,
for (Index i = 0; i < field_count; ++i) {
struct_type->fields[i].type = fields[i].type;
struct_type->fields[i].mutable_ = fields[i].mutable_;
+ module_->features_used.simd |= (fields[i].type == Type::V128);
}
field->type = std::move(struct_type);
module_->AppendField(std::move(field));
@@ -551,6 +561,7 @@ Result BinaryReaderIR::OnArrayType(Index index, TypeMut type_mut) {
auto array_type = std::make_unique<ArrayType>();
array_type->field.type = type_mut.type;
array_type->field.mutable_ = type_mut.mutable_;
+ module_->features_used.simd |= (type_mut.type == Type::V128);
field->type = std::move(array_type);
module_->AppendField(std::move(field));
return Result::Ok;
@@ -620,6 +631,7 @@ Result BinaryReaderIR::OnImportGlobal(Index import_index,
import->global.mutable_ = mutable_;
module_->AppendField(
std::make_unique<ImportModuleField>(std::move(import), GetLocation()));
+ module_->features_used.simd |= (type == Type::V128);
return Result::Ok;
}
@@ -634,6 +646,7 @@ Result BinaryReaderIR::OnImportTag(Index import_index,
SetFuncDeclaration(&import->tag.decl, Var(sig_index, GetLocation()));
module_->AppendField(
std::make_unique<ImportModuleField>(std::move(import), GetLocation()));
+ module_->features_used.exceptions = true;
return Result::Ok;
}
@@ -698,6 +711,7 @@ Result BinaryReaderIR::BeginGlobal(Index index, Type type, bool mutable_) {
global.type = type;
global.mutable_ = mutable_;
module_->AppendField(std::move(field));
+ module_->features_used.simd |= (type == Type::V128);
return Result::Ok;
}
@@ -763,6 +777,7 @@ Result BinaryReaderIR::OnLocalDecl(Index decl_index, Index count, Type type) {
return Result::Error;
}
+ module_->features_used.simd |= (type == Type::V128);
return Result::Ok;
}
@@ -772,6 +787,7 @@ Result BinaryReaderIR::OnOpcode(Opcode opcode) {
if (metadata) {
return AppendExpr(std::move(metadata));
}
+ module_->features_used.simd |= (opcode.GetResultType() == Type::V128);
return Result::Ok;
}
@@ -1143,6 +1159,7 @@ Result BinaryReaderIR::OnTryExpr(Type sig_type) {
ExprList* expr_list = &expr->block.exprs;
SetBlockDeclaration(&expr->block.decl, sig_type);
CHECK_RESULT(AppendExpr(std::move(expr_ptr)));
+ module_->features_used.exceptions = true;
return PushLabel(LabelType::Try, expr_list, expr);
}
@@ -1647,6 +1664,7 @@ Result BinaryReaderIR::OnTagType(Index index, Index sig_index) {
Tag& tag = field->tag;
SetFuncDeclaration(&tag.decl, Var(sig_index, GetLocation()));
module_->AppendField(std::move(field));
+ module_->features_used.exceptions = true;
return Result::Ok;
}