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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ ENDIF()
# Current (partial) dependency structure is as follows:
# passes -> wasm -> asmjs -> support
# TODO: It's odd that wasm should depend on asmjs, maybe we should fix that.
ADD_SUBDIRECTORY(src/ast)
ADD_SUBDIRECTORY(src/ir)
ADD_SUBDIRECTORY(src/asmjs)
ADD_SUBDIRECTORY(src/cfg)
ADD_SUBDIRECTORY(src/emscripten-optimizer)
Expand All @@ -193,7 +193,7 @@ IF(BUILD_STATIC_LIB)
ELSE()
ADD_LIBRARY(binaryen SHARED ${binaryen_SOURCES})
ENDIF()
TARGET_LINK_LIBRARIES(binaryen passes wasm asmjs emscripten-optimizer ast cfg support)
TARGET_LINK_LIBRARIES(binaryen passes wasm asmjs emscripten-optimizer ir cfg support)
INSTALL(TARGETS binaryen DESTINATION ${CMAKE_INSTALL_LIBDIR})

INSTALL(FILES src/binaryen-c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
Expand All @@ -206,7 +206,7 @@ SET(wasm-shell_SOURCES
)
ADD_EXECUTABLE(wasm-shell
${wasm-shell_SOURCES})
TARGET_LINK_LIBRARIES(wasm-shell wasm asmjs emscripten-optimizer passes ast cfg support)
TARGET_LINK_LIBRARIES(wasm-shell wasm asmjs emscripten-optimizer passes ir cfg support)
SET_PROPERTY(TARGET wasm-shell PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm-shell PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm-shell DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand All @@ -217,7 +217,7 @@ SET(wasm-opt_SOURCES
)
ADD_EXECUTABLE(wasm-opt
${wasm-opt_SOURCES})
TARGET_LINK_LIBRARIES(wasm-opt wasm asmjs emscripten-optimizer passes ast cfg support)
TARGET_LINK_LIBRARIES(wasm-opt wasm asmjs emscripten-optimizer passes ir cfg support)
SET_PROPERTY(TARGET wasm-opt PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm-opt PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm-opt DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand All @@ -227,7 +227,7 @@ SET(wasm-merge_SOURCES
)
ADD_EXECUTABLE(wasm-merge
${wasm-merge_SOURCES})
TARGET_LINK_LIBRARIES(wasm-merge wasm asmjs emscripten-optimizer passes ast cfg support)
TARGET_LINK_LIBRARIES(wasm-merge wasm asmjs emscripten-optimizer passes ir cfg support)
SET_PROPERTY(TARGET wasm-merge PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm-merge PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm-merge DESTINATION bin)
Expand All @@ -238,7 +238,7 @@ SET(asm2wasm_SOURCES
)
ADD_EXECUTABLE(asm2wasm
${asm2wasm_SOURCES})
TARGET_LINK_LIBRARIES(asm2wasm emscripten-optimizer passes wasm asmjs ast cfg support)
TARGET_LINK_LIBRARIES(asm2wasm emscripten-optimizer passes wasm asmjs ir cfg support)
SET_PROPERTY(TARGET asm2wasm PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET asm2wasm PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS asm2wasm DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand All @@ -248,7 +248,7 @@ SET(wasm2asm_SOURCES
)
ADD_EXECUTABLE(wasm2asm
${wasm2asm_SOURCES})
TARGET_LINK_LIBRARIES(wasm2asm passes wasm asmjs emscripten-optimizer ast cfg support)
TARGET_LINK_LIBRARIES(wasm2asm passes wasm asmjs emscripten-optimizer ir cfg support)
SET_PROPERTY(TARGET wasm2asm PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm2asm PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm2asm DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand All @@ -260,7 +260,7 @@ SET(s2wasm_SOURCES
)
ADD_EXECUTABLE(s2wasm
${s2wasm_SOURCES})
TARGET_LINK_LIBRARIES(s2wasm passes wasm asmjs ast cfg support)
TARGET_LINK_LIBRARIES(s2wasm passes wasm asmjs ir cfg support)
SET_PROPERTY(TARGET s2wasm PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET s2wasm PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS s2wasm DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand All @@ -270,7 +270,7 @@ SET(wasm_as_SOURCES
)
ADD_EXECUTABLE(wasm-as
${wasm_as_SOURCES})
TARGET_LINK_LIBRARIES(wasm-as wasm asmjs passes ast cfg support)
TARGET_LINK_LIBRARIES(wasm-as wasm asmjs passes ir cfg support)
SET_PROPERTY(TARGET wasm-as PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm-as PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm-as DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand All @@ -280,7 +280,7 @@ SET(wasm_dis_SOURCES
)
ADD_EXECUTABLE(wasm-dis
${wasm_dis_SOURCES})
TARGET_LINK_LIBRARIES(wasm-dis passes wasm asmjs ast cfg support)
TARGET_LINK_LIBRARIES(wasm-dis passes wasm asmjs ir cfg support)
SET_PROPERTY(TARGET wasm-dis PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm-dis PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm-dis DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand All @@ -290,7 +290,7 @@ SET(wasm-ctor-eval_SOURCES
)
ADD_EXECUTABLE(wasm-ctor-eval
${wasm-ctor-eval_SOURCES})
TARGET_LINK_LIBRARIES(wasm-ctor-eval emscripten-optimizer passes wasm asmjs ast cfg support)
TARGET_LINK_LIBRARIES(wasm-ctor-eval emscripten-optimizer passes wasm asmjs ir cfg support)
SET_PROPERTY(TARGET wasm-ctor-eval PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm-ctor-eval PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm-ctor-eval DESTINATION bin)
Expand All @@ -303,7 +303,7 @@ IF (UNIX) # TODO: port to windows
)
ADD_EXECUTABLE(wasm-reduce
${wasm-reduce_SOURCES})
TARGET_LINK_LIBRARIES(wasm-reduce wasm asmjs passes wasm ast cfg support)
TARGET_LINK_LIBRARIES(wasm-reduce wasm asmjs passes wasm ir cfg support)
SET_PROPERTY(TARGET wasm-reduce PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm-reduce PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm-reduce DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ Consult the [contributing instructions](Contributing.md) if you're interested in

## Binaryen IR

Binaryen's internal IR is an AST, designed to be
Binaryen's internal IR is designed to be

* **Flexible and fast** for optimization.
* **As close as possible to WebAssembly** so it is simple and fast to convert it to and from WebAssembly.

There are a few differences between Binaryen IR and the WebAssembly language:

* AST structure
* Binaryen IR [is an AST](https://github.com/WebAssembly/binaryen/issues/663) (i.e. it has hierarchical structure), for convenience of optimization. This differs from the WebAssembly binary format which is a stack machine.
* Tree structure
* Binaryen IR [is an tree](https://github.com/WebAssembly/binaryen/issues/663), i.e., it has hierarchical structure, for convenience of optimization. This differs from the WebAssembly binary format which is a stack machine.
* Consequently Binaryen's text format allows only s-expressions. WebAssembly's official text format is primarily a linear instruction list (with s-expression extensions). Binaryen can't read the linear style, but it can read a wasm text file if it contains only s-expressions.
* Types and unreachable code
* WebAssembly limits block/if/loop types to none and the concrete value types (i32, i64, f32, f64). Binaryen IR has an unreachable type, and it allows block/if/loop to take it, allowing [local transforms that don't need to know the global context](https://github.com/WebAssembly/binaryen/issues/903).
Expand Down
10 changes: 5 additions & 5 deletions src/asm2wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#include "passes/passes.h"
#include "pass.h"
#include "parsing.h"
#include "ast_utils.h"
#include "ast/bits.h"
#include "ast/branch-utils.h"
#include "ast/literal-utils.h"
#include "ast/trapping.h"
#include "ir/bits.h"
#include "ir/branch-utils.h"
#include "ir/literal-utils.h"
#include "ir/trapping.h"
#include "ir/utils.h"
#include "wasm-builder.h"
#include "wasm-emscripten.h"
#include "wasm-module-building.h"
Expand Down
2 changes: 1 addition & 1 deletion src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "wasm-validator.h"
#include "wasm2asm.h"
#include "cfg/Relooper.h"
#include "ast_utils.h"
#include "ir/utils.h"
#include "shell-interface.h"

using namespace wasm;
Expand Down
2 changes: 1 addition & 1 deletion src/cfg/Relooper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <stack>
#include <string>

#include "ast_utils.h"
#include "ir/utils.h"
#include "parsing.h"

namespace CFG {
Expand Down
4 changes: 2 additions & 2 deletions src/ast/CMakeLists.txt → src/ir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SET(ast_SOURCES
SET(ir_SOURCES
ExpressionAnalyzer.cpp
ExpressionManipulator.cpp
LocalGraph.cpp
)
ADD_LIBRARY(ast STATIC ${ast_SOURCES})
ADD_LIBRARY(ir STATIC ${ir_SOURCES})
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

#include "support/hash.h"
#include "ast_utils.h"
#include "ast/load-utils.h"
#include "ir/utils.h"
#include "ir/load-utils.h"

namespace wasm {
// Given a stack of expressions, checks if the topmost is used as a result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "ast_utils.h"
#include "ir/utils.h"
#include "support/hash.h"

namespace wasm {
Expand Down
4 changes: 2 additions & 2 deletions src/ast/LocalGraph.cpp → src/ir/LocalGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#include <wasm-builder.h>
#include <wasm-printing.h>
#include <ast/find_all.h>
#include <ast/local-graph.h>
#include <ir/find_all.h>
#include <ir/local-graph.h>

namespace wasm {

Expand Down
8 changes: 4 additions & 4 deletions src/ast/bits.h → src/ir/bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

#ifndef wasm_ast_bits_h
#define wasm_ast_bits_h
#ifndef wasm_ir_bits_h
#define wasm_ir_bits_h

#include "support/bits.h"
#include "wasm-builder.h"
#include "ast/literal-utils.h"
#include "ir/literal-utils.h"

namespace wasm {

Expand Down Expand Up @@ -103,5 +103,5 @@ struct Bits {

} // namespace wasm

#endif // wasm_ast_bits_h
#endif // wasm_ir_bits_h

10 changes: 5 additions & 5 deletions src/ast/block-utils.h → src/ir/block-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

#ifndef wasm_ast_block_h
#define wasm_ast_block_h
#ifndef wasm_ir_block_h
#define wasm_ir_block_h

#include "literal.h"
#include "wasm.h"
#include "ast/branch-utils.h"
#include "ast/effects.h"
#include "ir/branch-utils.h"
#include "ir/effects.h"

namespace wasm {

Expand Down Expand Up @@ -63,5 +63,5 @@ namespace BlockUtils {

} // namespace wasm

#endif // wasm_ast_block_h
#endif // wasm_ir_block_h

6 changes: 3 additions & 3 deletions src/ast/branch-utils.h → src/ir/branch-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef wasm_ast_branch_h
#define wasm_ast_branch_h
#ifndef wasm_ir_branch_h
#define wasm_ir_branch_h

#include "wasm.h"
#include "wasm-traversal.h"
Expand Down Expand Up @@ -179,5 +179,5 @@ struct BranchSeeker : public PostWalker<BranchSeeker> {

} // namespace wasm

#endif // wasm_ast_branch_h
#endif // wasm_ir_branch_h

6 changes: 3 additions & 3 deletions src/ast/cost.h → src/ir/cost.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef wasm_ast_cost_h
#define wasm_ast_cost_h
#ifndef wasm_ir_cost_h
#define wasm_ir_cost_h

namespace wasm {

Expand Down Expand Up @@ -251,5 +251,5 @@ struct CostAnalyzer : public Visitor<CostAnalyzer, Index> {

} // namespace wasm

#endif // wasm_ast_cost_h
#endif // wasm_ir_cost_h

6 changes: 3 additions & 3 deletions src/ast/count.h → src/ir/count.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef wasm_ast_count_h
#define wasm_ast_count_h
#ifndef wasm_ir_count_h
#define wasm_ir_count_h

namespace wasm {

Expand Down Expand Up @@ -46,5 +46,5 @@ struct GetLocalCounter : public PostWalker<GetLocalCounter> {

} // namespace wasm

#endif // wasm_ast_count_h
#endif // wasm_ir_count_h

6 changes: 3 additions & 3 deletions src/ast/effects.h → src/ir/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef wasm_ast_effects_h
#define wasm_ast_effects_h
#ifndef wasm_ir_effects_h
#define wasm_ir_effects_h

namespace wasm {

Expand Down Expand Up @@ -275,4 +275,4 @@ struct EffectAnalyzer : public PostWalker<EffectAnalyzer> {

} // namespace wasm

#endif // wasm_ast_effects_h
#endif // wasm_ir_effects_h
6 changes: 3 additions & 3 deletions src/ast/find_all.h → src/ir/find_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef wasm_ast_find_all_h
#define wasm_ast_find_all_h
#ifndef wasm_ir_find_all_h
#define wasm_ir_find_all_h

#include <wasm-traversal.h>

Expand Down Expand Up @@ -44,5 +44,5 @@ struct FindAll {

} // namespace wasm

#endif // wasm_ast_find_all_h
#endif // wasm_ir_find_all_h

6 changes: 3 additions & 3 deletions src/ast/global-utils.h → src/ir/global-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef wasm_ast_global_h
#define wasm_ast_global_h
#ifndef wasm_ir_global_h
#define wasm_ir_global_h

#include <algorithm>
#include <vector>
Expand Down Expand Up @@ -51,5 +51,5 @@ namespace GlobalUtils {

} // namespace wasm

#endif // wasm_ast_global_h
#endif // wasm_ir_global_h

6 changes: 3 additions & 3 deletions src/ast/hashed.h → src/ir/hashed.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

#ifndef _wasm_ast_hashed_h
#ifndef _wasm_ir_hashed_h

#include "support/hash.h"
#include "wasm.h"
#include "ast_utils.h"
#include "ir/utils.h"

namespace wasm {

Expand Down Expand Up @@ -55,5 +55,5 @@ class HashedExpressionMap : public std::unordered_map<HashedExpression, T, Expre

} // namespace wasm

#endif // _wasm_ast_hashed_h
#endif // _wasm_ir_hashed_h

6 changes: 3 additions & 3 deletions src/ast/import-utils.h → src/ir/import-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef wasm_ast_import_h
#define wasm_ast_import_h
#ifndef wasm_ir_import_h
#define wasm_ir_import_h

#include "literal.h"
#include "wasm.h"
Expand All @@ -37,5 +37,5 @@ namespace ImportUtils {

} // namespace wasm

#endif // wasm_ast_import_h
#endif // wasm_ir_import_h

Loading