1cb93a386Sopenharmony_ci#!/bin/bash 2cb93a386Sopenharmony_ci# Copyright 2020 Google LLC 3cb93a386Sopenharmony_ci# 4cb93a386Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci# found in the LICENSE file. 6cb93a386Sopenharmony_ci 7cb93a386Sopenharmony_ci# This script takes a path to a .wasm file as input and outputs textual representations of all wasm 8cb93a386Sopenharmony_ci# SIMD operations present in the .wasm file. 9cb93a386Sopenharmony_ci# 10cb93a386Sopenharmony_ci# Example usage: ./simd_test.sh simd_float_capabilities.wasm 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_ci# Requires that emscripten and wasm2wat are added to your PATH. 13cb93a386Sopenharmony_ci# Requires, and is verified to work with 14cb93a386Sopenharmony_ci# - The output of `wasm2wat --version` should be `1.0.13 (1.0.17)` 15cb93a386Sopenharmony_ci# - install from here: https://github.com/WebAssembly/wabt 16cb93a386Sopenharmony_ci 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_ciwasm2wat --enable-simd $1 > output/simd_test.wat 19cb93a386Sopenharmony_ci 20cb93a386Sopenharmony_ci# The following lines output all SIMD operations produced in the output WASM. 21cb93a386Sopenharmony_ci# Useful for checking that SIMD instructions are actually being used. 22cb93a386Sopenharmony_ci# e.g. for the following C++ code: 23cb93a386Sopenharmony_ci# auto vec1 = skvx::Vec<2, double>({11.f, -22.f}) + skvx::Vec<2, double>({13.f, -1.f}); 24cb93a386Sopenharmony_ci# it is expected that the f64x2.add operation is present in the output WASM. 25cb93a386Sopenharmony_ciecho "The following WASM SIMD operations were used in the compiled code:" 26cb93a386Sopenharmony_cigrep -f wasm_simd_types.txt output/simd_test.wat 27