-
Notifications
You must be signed in to change notification settings - Fork 58
[DISCUSS] AST Related Discussion #52
Comments
P1. Since TVM has multiple IRs, I think it would be confusing to call the header file P3. Again, haven't looked at the AST in a while, but I would think that SeqExpr would inherit from Expr, and therefore would be allowed to be in the body of a function since the body of the function is an expression. Could you make a inheritance diagram of the current AST before we continue this discussion? I think that would make it much clearer what is going on structurally. Thanks! |
The above discussions contain three key questions with regards to AST/IR design: Let's take a look at previous compiler designs: D0. Functional language
D1. LLVM
D2. MLIR
As we can see, there are two major choices for each question: C0. Handling of binding blocks
C1. Handling of structured control flow
C2. Handling of unstructured control flow
Traditional functional compiler (C0a + C1a) allows us to handle everything with recursion and the rewriting is Right now in Relax, we followed a C0b + C1a approach, and we have already made the Visitor/Mutator handle this general case. Changing |
Hi @electriclilies , For question you proposed in P1: we have different header files since those expressions are defined for different submodules. For example, For question you proposed in P2 and P3, here(https://github.com/tlc-pack/relax/wiki/Relax-AST-Design) is the current AST design, you could take a look and get more context for the discussion. |
For P1, one possible proposal is we refine the header files: we keep the |
I feel there are several points worth discussion in the AST part. I list here for discussion:
P1. Rename
expr.h
toir.h
Since it also contains non-expression objects like Binding
P2. Change the type of
Function.body
fromExpr
toSeqExpr
.We already assumed that the body should be
SeqExpr
. And if we want to allow other expression type likeIf
to be here, we need to handle those cases everywhere. Instead, we could change the type toSeqExpr
and make theIf
nested in theSeqExpr
.P3. Change the name of
SeqExpr.body
toSeqExpr.result
.This is because the
blocks
field in theSeqExpr
is more like the content of the IR node, it is confused (at least for me) to have anotherbody
field but actually represents the value of the sequential expression. There is also some opposing opinion, for example:Let
expression. Some languages names this part as body also: https://docs.racket-lang.org/guide/let.htmlWelcome for discussion! cc @mbs-octoml @jroesch @electriclilies
The text was updated successfully, but these errors were encountered: