summaryrefslogtreecommitdiff
path: root/src/support/permutations.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-06-13 16:05:01 -0700
committerGitHub <noreply@github.com>2017-06-13 16:05:01 -0700
commitb5b40c9ab0c35ed74e97a6491e15651382091b2e (patch)
treed2ec6c2006089d8385b850a730af4be936874314 /src/support/permutations.h
parent61b409bc845f385f1d7ea7ac81d1649b63435828 (diff)
downloadbinaryen-b5b40c9ab0c35ed74e97a6491e15651382091b2e.tar.gz
binaryen-b5b40c9ab0c35ed74e97a6491e15651382091b2e.tar.bz2
binaryen-b5b40c9ab0c35ed74e97a6491e15651382091b2e.zip
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
Diffstat (limited to 'src/support/permutations.h')
-rw-r--r--src/support/permutations.h55
1 files changed, 55 insertions, 0 deletions
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<Index> makeIdentity(Index num) {
+ std::vector<Index> ret;
+ ret.resize(num);
+ for (Index i = 0; i < num; i++) {
+ ret[i] = i;
+ }
+ return ret;
+}
+
+inline void setIdentity(std::vector<Index>& 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<Index> makeReversed(std::vector<Index>& original) {
+ std::vector<Index> 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