From b5b40c9ab0c35ed74e97a6491e15651382091b2e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 13 Jun 2017 16:05:01 -0700 Subject: SSA pass (#1049) * Add SSA pass which ensures a single assign for each local, except for merged locals where we ensure exactly a single assign from one of the paths leading to that use * Also add InstrumentLocals pass, useful for debugging locals (similar to InstrumentMemory but for locals) * Fix a PickLoadSigns bug with tees not being ignored, which was not noticed until now because we ran it on flatter output by default, but the ssa pass uncovered the bug --- src/support/permutations.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/support/permutations.h (limited to 'src/support/permutations.h') diff --git a/src/support/permutations.h b/src/support/permutations.h new file mode 100644 index 000000000..214063058 --- /dev/null +++ b/src/support/permutations.h @@ -0,0 +1,55 @@ +/* + * Copyright 2016 WebAssembly Community Group participants + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Utilities for operating on permutation vectors + +#ifndef wasm_support_permutations_h +#define wasm_support_permutations_h + +#include "wasm.h" + +namespace wasm { + +inline std::vector makeIdentity(Index num) { + std::vector ret; + ret.resize(num); + for (Index i = 0; i < num; i++) { + ret[i] = i; + } + return ret; +} + +inline void setIdentity(std::vector& ret) { + auto num = ret.size(); + assert(num > 0); // must already be of the right size + for (Index i = 0; i < num; i++) { + ret[i] = i; + } +} + +inline std::vector makeReversed(std::vector& original) { + std::vector ret; + auto num = original.size(); + ret.resize(num); + for (Index i = 0; i < num; i++) { + ret[original[i]] = i; + } + return ret; +} + +} // namespace wasm + +#endif // permutations -- cgit v1.2.3