Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(ir_SOURCES
ExpressionAnalyzer.cpp
ExpressionManipulator.cpp
drop.cpp
effects.cpp
eh-utils.cpp
export-utils.cpp
intrinsics.cpp
Expand Down
142 changes: 142 additions & 0 deletions src/ir/effects.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* Copyright 2024 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.
*/

#include "ir/effects.h"
#include "wasm.h"

namespace std {

std::ostream& operator<<(std::ostream& o, wasm::EffectAnalyzer& effects) {
o << "EffectAnalyzer {\n";
if (effects.branchesOut) {
o << "branchesOut\n";
}
if (effects.calls) {
o << "calls\n";
}
if (effects.localsRead.size()) {
o << "localsRead\n";
}
if (effects.localsWritten.size()) {
o << "localsWritten\n";
}
if (effects.mutableGlobalsRead.size()) {
o << "mutableGlobalsRead\n";
}
if (effects.globalsWritten.size()) {
o << "globalsWritten\n";
}
if (effects.readsMemory) {
o << "readsMemory\n";
}
if (effects.writesMemory) {
o << "writesMemory\n";
}
if (effects.readsTable) {
o << "readsTable\n";
}
if (effects.writesTable) {
o << "writesTable\n";
}
if (effects.readsMutableStruct) {
o << "readsMutableStruct\n";
}
if (effects.writesStruct) {
o << "writesStruct\n";
}
if (effects.readsArray) {
o << "readsArray\n";
}
if (effects.writesArray) {
o << "writesArray\n";
}
if (effects.trap) {
o << "trap\n";
}
if (effects.implicitTrap) {
o << "implicitTrap\n";
}
if (effects.isAtomic) {
o << "isAtomic\n";
}
if (effects.throws_) {
o << "throws_\n";
}
if (effects.tryDepth) {
o << "tryDepth\n";
}
if (effects.catchDepth) {
o << "catchDepth\n";
}
if (effects.danglingPop) {
o << "danglingPop\n";
}
if (effects.mayNotReturn) {
o << "mayNotReturn\n";
}
if (effects.hasReturnCallThrow) {
o << "hasReturnCallThrow\n";
}
if (effects.accessesLocal()) {
o << "accessesLocal\n";
}
if (effects.accessesMutableGlobal()) {
o << "accessesMutableGlobal\n";
}
if (effects.accessesMemory()) {
o << "accessesMemory\n";
}
if (effects.accessesTable()) {
o << "accessesTable\n";
}
if (effects.accessesMutableStruct()) {
o << "accessesMutableStruct\n";
}
if (effects.accessesArray()) {
o << "accessesArray\n";
}
if (effects.throws()) {
o << "throws\n";
}
if (effects.transfersControlFlow()) {
o << "transfersControlFlow\n";
}
if (effects.writesGlobalState()) {
o << "writesGlobalState\n";
}
if (effects.readsMutableGlobalState()) {
o << "readsMutableGlobalState\n";
}
if (effects.hasNonTrapSideEffects()) {
o << "hasNonTrapSideEffects\n";
}
if (effects.hasSideEffects()) {
o << "hasSideEffects\n";
}
if (effects.hasUnremovableSideEffects()) {
o << "hasUnremovableSideEffects\n";
}
if (effects.hasAnything()) {
o << "hasAnything\n";
}
if (effects.hasExternalBreakTargets()) {
o << "hasExternalBreakTargets\n";
}
o << "}";
return o;
}

} // namespace std
4 changes: 4 additions & 0 deletions src/ir/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -1193,4 +1193,8 @@ class ShallowEffectAnalyzer : public EffectAnalyzer {

} // namespace wasm

namespace std {
std::ostream& operator<<(std::ostream& o, wasm::EffectAnalyzer& effects);
} // namespace std

#endif // wasm_ir_effects_h