MeteoSwiss-APN / HIR

MIT License
2 stars 3 forks source link

Feedback/Review #2

Closed clementval closed 6 years ago

clementval commented 6 years ago

This is a placeholder for my feedback/review. If any changes are simple, I'll directly issue a PR.

1) - [x] named element: As a general comment, I would remove the notion of named elements as it appears now. I think this is quite confusing and it would be more straightforward to have the element with the correct name directly. The elements can then share their internal specification but it would be clear from the beginning. This is the case for example of lhs/rhs. This would remove also the ambiguity with the actual name (in fact identifier) of variables in the IR. Another example can be found in the example. The vararg name for VarDecl is used directly as element name can imply directly the attribute isarg=true.

2) - [x] id instead of name: Following the previous comment, I would change the name in VarDecl and other element representing the variable in id which is more representative of what the information in the IR is.

3) - [x] Literal: Wouldn't it make sense to have the differentiation between String literal and integer/real constant? How do you make the difference otherwise between a string "1.0" and an actual real 1.0?

4) - [x] binary op: Similar to named elements, I would directly have the operation as the name of the element and not as an attribute. DivOp, MulOp, AddOp, SubOp, PowerOp ... Doesn^t matter then if they are all derived from a single BinaryOp. This would make the IR more readable.

5) - [x] VarAccess: How can we access a var with i+1 for example. The current specification accepts Literal elements only. I guess it should accept a restricted set of ExprModel.

6) - [x] GridDimension: I think this element is not well defined. It as no content model but should have something like (Literal+) or (Var+) ...

7) - [x] Program: The content model is referencing Dimensionbut should be GridDimension. Can be related with 1.

WORK IN PROGRESS...

Open PRs: Removal of Stmt and ExprStmt as elements #1

cosunae commented 6 years ago

thanks for the feedback @clementval , some comments from my side:

clementval commented 6 years ago
  1. I think as we discussed, a position wise deduction is often what is used in IR. We can wrap list-like node in super nodes like ParallelDimensions (Dimension+) et GridDimensions (Dimension+) nothing
  2. Then if literal are actually constant why not naming the node what it is representing. Here it is confusing.
  3. BinaryOp is more like a model and does not really represent what is the op and its precedence. I would have BinaryOpModel for example and have plusExpr, minusExpr ... We are not limited in the numebr of element so for me this is not a reason to not have a precise IR.
  4. Ok but then do we cover every usage of VarAccess? Not sure we don't need more flexibility
  5. (6) Maybe but in the specification this element as no content... If it has really no content shouldn't it be defined differently? Or should it contains the upper/lower bounds?
clementval commented 6 years ago

The root node Program should also have several other attributes like the version of the HIR. It will probably evolve over time and front-end will generate a specific version. With an attribute, the toolchain can check whether the version is supported or outdated.

cosunae commented 6 years ago

I agree with 1, 3 and the Program element, but I didnt understand your comment on 2 & 5 (we can discuss it) And for 4, I dont see what else we might need.

clementval commented 6 years ago

I think we are ok then for the small changes. I'll prepare a PR with these changes.

clementval commented 6 years ago

@cosunae I think we should move forward with the changes we agreed after discussion. I can make them and make a PR for review... Would that be fine with you?

cosunae commented 6 years ago

that would be great @clementval

thanks for pushing this

clementval commented 6 years ago

Done with #7