Skip to content

Commit 47c9021

Browse files
authored
notation change: AST => IR (#1245)
The IR is indeed a tree, but not an "abstract syntax tree" since there is no language for which it is the syntax (except in the most trivial and meaningless sense).
1 parent 93f5f16 commit 47c9021

69 files changed

Lines changed: 172 additions & 171 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ ENDIF()
174174
# Current (partial) dependency structure is as follows:
175175
# passes -> wasm -> asmjs -> support
176176
# TODO: It's odd that wasm should depend on asmjs, maybe we should fix that.
177-
ADD_SUBDIRECTORY(src/ast)
177+
ADD_SUBDIRECTORY(src/ir)
178178
ADD_SUBDIRECTORY(src/asmjs)
179179
ADD_SUBDIRECTORY(src/cfg)
180180
ADD_SUBDIRECTORY(src/emscripten-optimizer)
@@ -193,7 +193,7 @@ IF(BUILD_STATIC_LIB)
193193
ELSE()
194194
ADD_LIBRARY(binaryen SHARED ${binaryen_SOURCES})
195195
ENDIF()
196-
TARGET_LINK_LIBRARIES(binaryen passes wasm asmjs emscripten-optimizer ast cfg support)
196+
TARGET_LINK_LIBRARIES(binaryen passes wasm asmjs emscripten-optimizer ir cfg support)
197197
INSTALL(TARGETS binaryen DESTINATION ${CMAKE_INSTALL_LIBDIR})
198198

199199
INSTALL(FILES src/binaryen-c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
@@ -206,7 +206,7 @@ SET(wasm-shell_SOURCES
206206
)
207207
ADD_EXECUTABLE(wasm-shell
208208
${wasm-shell_SOURCES})
209-
TARGET_LINK_LIBRARIES(wasm-shell wasm asmjs emscripten-optimizer passes ast cfg support)
209+
TARGET_LINK_LIBRARIES(wasm-shell wasm asmjs emscripten-optimizer passes ir cfg support)
210210
SET_PROPERTY(TARGET wasm-shell PROPERTY CXX_STANDARD 11)
211211
SET_PROPERTY(TARGET wasm-shell PROPERTY CXX_STANDARD_REQUIRED ON)
212212
INSTALL(TARGETS wasm-shell DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -217,7 +217,7 @@ SET(wasm-opt_SOURCES
217217
)
218218
ADD_EXECUTABLE(wasm-opt
219219
${wasm-opt_SOURCES})
220-
TARGET_LINK_LIBRARIES(wasm-opt wasm asmjs emscripten-optimizer passes ast cfg support)
220+
TARGET_LINK_LIBRARIES(wasm-opt wasm asmjs emscripten-optimizer passes ir cfg support)
221221
SET_PROPERTY(TARGET wasm-opt PROPERTY CXX_STANDARD 11)
222222
SET_PROPERTY(TARGET wasm-opt PROPERTY CXX_STANDARD_REQUIRED ON)
223223
INSTALL(TARGETS wasm-opt DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -227,7 +227,7 @@ SET(wasm-merge_SOURCES
227227
)
228228
ADD_EXECUTABLE(wasm-merge
229229
${wasm-merge_SOURCES})
230-
TARGET_LINK_LIBRARIES(wasm-merge wasm asmjs emscripten-optimizer passes ast cfg support)
230+
TARGET_LINK_LIBRARIES(wasm-merge wasm asmjs emscripten-optimizer passes ir cfg support)
231231
SET_PROPERTY(TARGET wasm-merge PROPERTY CXX_STANDARD 11)
232232
SET_PROPERTY(TARGET wasm-merge PROPERTY CXX_STANDARD_REQUIRED ON)
233233
INSTALL(TARGETS wasm-merge DESTINATION bin)
@@ -238,7 +238,7 @@ SET(asm2wasm_SOURCES
238238
)
239239
ADD_EXECUTABLE(asm2wasm
240240
${asm2wasm_SOURCES})
241-
TARGET_LINK_LIBRARIES(asm2wasm emscripten-optimizer passes wasm asmjs ast cfg support)
241+
TARGET_LINK_LIBRARIES(asm2wasm emscripten-optimizer passes wasm asmjs ir cfg support)
242242
SET_PROPERTY(TARGET asm2wasm PROPERTY CXX_STANDARD 11)
243243
SET_PROPERTY(TARGET asm2wasm PROPERTY CXX_STANDARD_REQUIRED ON)
244244
INSTALL(TARGETS asm2wasm DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -248,7 +248,7 @@ SET(wasm2asm_SOURCES
248248
)
249249
ADD_EXECUTABLE(wasm2asm
250250
${wasm2asm_SOURCES})
251-
TARGET_LINK_LIBRARIES(wasm2asm passes wasm asmjs emscripten-optimizer ast cfg support)
251+
TARGET_LINK_LIBRARIES(wasm2asm passes wasm asmjs emscripten-optimizer ir cfg support)
252252
SET_PROPERTY(TARGET wasm2asm PROPERTY CXX_STANDARD 11)
253253
SET_PROPERTY(TARGET wasm2asm PROPERTY CXX_STANDARD_REQUIRED ON)
254254
INSTALL(TARGETS wasm2asm DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -260,7 +260,7 @@ SET(s2wasm_SOURCES
260260
)
261261
ADD_EXECUTABLE(s2wasm
262262
${s2wasm_SOURCES})
263-
TARGET_LINK_LIBRARIES(s2wasm passes wasm asmjs ast cfg support)
263+
TARGET_LINK_LIBRARIES(s2wasm passes wasm asmjs ir cfg support)
264264
SET_PROPERTY(TARGET s2wasm PROPERTY CXX_STANDARD 11)
265265
SET_PROPERTY(TARGET s2wasm PROPERTY CXX_STANDARD_REQUIRED ON)
266266
INSTALL(TARGETS s2wasm DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -270,7 +270,7 @@ SET(wasm_as_SOURCES
270270
)
271271
ADD_EXECUTABLE(wasm-as
272272
${wasm_as_SOURCES})
273-
TARGET_LINK_LIBRARIES(wasm-as wasm asmjs passes ast cfg support)
273+
TARGET_LINK_LIBRARIES(wasm-as wasm asmjs passes ir cfg support)
274274
SET_PROPERTY(TARGET wasm-as PROPERTY CXX_STANDARD 11)
275275
SET_PROPERTY(TARGET wasm-as PROPERTY CXX_STANDARD_REQUIRED ON)
276276
INSTALL(TARGETS wasm-as DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -280,7 +280,7 @@ SET(wasm_dis_SOURCES
280280
)
281281
ADD_EXECUTABLE(wasm-dis
282282
${wasm_dis_SOURCES})
283-
TARGET_LINK_LIBRARIES(wasm-dis passes wasm asmjs ast cfg support)
283+
TARGET_LINK_LIBRARIES(wasm-dis passes wasm asmjs ir cfg support)
284284
SET_PROPERTY(TARGET wasm-dis PROPERTY CXX_STANDARD 11)
285285
SET_PROPERTY(TARGET wasm-dis PROPERTY CXX_STANDARD_REQUIRED ON)
286286
INSTALL(TARGETS wasm-dis DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -290,7 +290,7 @@ SET(wasm-ctor-eval_SOURCES
290290
)
291291
ADD_EXECUTABLE(wasm-ctor-eval
292292
${wasm-ctor-eval_SOURCES})
293-
TARGET_LINK_LIBRARIES(wasm-ctor-eval emscripten-optimizer passes wasm asmjs ast cfg support)
293+
TARGET_LINK_LIBRARIES(wasm-ctor-eval emscripten-optimizer passes wasm asmjs ir cfg support)
294294
SET_PROPERTY(TARGET wasm-ctor-eval PROPERTY CXX_STANDARD 11)
295295
SET_PROPERTY(TARGET wasm-ctor-eval PROPERTY CXX_STANDARD_REQUIRED ON)
296296
INSTALL(TARGETS wasm-ctor-eval DESTINATION bin)
@@ -303,7 +303,7 @@ IF (UNIX) # TODO: port to windows
303303
)
304304
ADD_EXECUTABLE(wasm-reduce
305305
${wasm-reduce_SOURCES})
306-
TARGET_LINK_LIBRARIES(wasm-reduce wasm asmjs passes wasm ast cfg support)
306+
TARGET_LINK_LIBRARIES(wasm-reduce wasm asmjs passes wasm ir cfg support)
307307
SET_PROPERTY(TARGET wasm-reduce PROPERTY CXX_STANDARD 11)
308308
SET_PROPERTY(TARGET wasm-reduce PROPERTY CXX_STANDARD_REQUIRED ON)
309309
INSTALL(TARGETS wasm-reduce DESTINATION ${CMAKE_INSTALL_BINDIR})

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ Consult the [contributing instructions](Contributing.md) if you're interested in
2727

2828
## Binaryen IR
2929

30-
Binaryen's internal IR is an AST, designed to be
30+
Binaryen's internal IR is designed to be
3131

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

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

37-
* AST structure
38-
* 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.
37+
* Tree structure
38+
* 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.
3939
* 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.
4040
* Types and unreachable code
4141
* 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).

src/asm2wasm.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
#include "passes/passes.h"
3232
#include "pass.h"
3333
#include "parsing.h"
34-
#include "ast_utils.h"
35-
#include "ast/bits.h"
36-
#include "ast/branch-utils.h"
37-
#include "ast/literal-utils.h"
38-
#include "ast/trapping.h"
34+
#include "ir/bits.h"
35+
#include "ir/branch-utils.h"
36+
#include "ir/literal-utils.h"
37+
#include "ir/trapping.h"
38+
#include "ir/utils.h"
3939
#include "wasm-builder.h"
4040
#include "wasm-emscripten.h"
4141
#include "wasm-module-building.h"

src/binaryen-c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "wasm-validator.h"
3232
#include "wasm2asm.h"
3333
#include "cfg/Relooper.h"
34-
#include "ast_utils.h"
34+
#include "ir/utils.h"
3535
#include "shell-interface.h"
3636

3737
using namespace wasm;

src/cfg/Relooper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <stack>
2424
#include <string>
2525

26-
#include "ast_utils.h"
26+
#include "ir/utils.h"
2727
#include "parsing.h"
2828

2929
namespace CFG {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
SET(ast_SOURCES
1+
SET(ir_SOURCES
22
ExpressionAnalyzer.cpp
33
ExpressionManipulator.cpp
44
LocalGraph.cpp
55
)
6-
ADD_LIBRARY(ast STATIC ${ast_SOURCES})
6+
ADD_LIBRARY(ir STATIC ${ir_SOURCES})
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616

1717
#include "support/hash.h"
18-
#include "ast_utils.h"
19-
#include "ast/load-utils.h"
18+
#include "ir/utils.h"
19+
#include "ir/load-utils.h"
2020

2121
namespace wasm {
2222
// Given a stack of expressions, checks if the topmost is used as a result.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "ast_utils.h"
17+
#include "ir/utils.h"
1818
#include "support/hash.h"
1919

2020
namespace wasm {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
#include <wasm-builder.h>
2020
#include <wasm-printing.h>
21-
#include <ast/find_all.h>
22-
#include <ast/local-graph.h>
21+
#include <ir/find_all.h>
22+
#include <ir/local-graph.h>
2323

2424
namespace wasm {
2525

src/ast/bits.h renamed to src/ir/bits.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef wasm_ast_bits_h
18-
#define wasm_ast_bits_h
17+
#ifndef wasm_ir_bits_h
18+
#define wasm_ir_bits_h
1919

2020
#include "support/bits.h"
2121
#include "wasm-builder.h"
22-
#include "ast/literal-utils.h"
22+
#include "ir/literal-utils.h"
2323

2424
namespace wasm {
2525

@@ -103,5 +103,5 @@ struct Bits {
103103

104104
} // namespace wasm
105105

106-
#endif // wasm_ast_bits_h
106+
#endif // wasm_ir_bits_h
107107

0 commit comments

Comments
 (0)