coderkalyan / coderkalyan/femtoc
ast, hir, llvm: implement remaining unary and binary operators
- Dominant language
- Zig
- Stars
- 2
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
A variety of operators are missing support the parser, hir, and/or codegen. For example, negative integers aren't allowed (passes the lexer, but `-(expression)` is rejected by the parser). Similarly, bitwise logic, shifting, unary bitwise negation, and boolean logic. We should more generally do a pass over all stages of the compiler pipeline and test that everything is working everywhere (write a sample program that tests everything).
Reminder that boolean logic requires short-circuit logic. That is, when emitting a boolean `and`, the following is incorrect:
1) emit left operand
2) emit right operand
3) emit left && right
Instead, do the following:
1) alloca bool
2) emit left operand
3) if (!left) bool = false
4) emit right operand
5) bool &= right
Similar for `or`. Whether to do this in HIR or have a special hir instruction and emit this in codegen is up to the author's discretion. It would be nice to not have an alloca, and instead use branch expressions in HIR/phi in llvm. If this ends up being difficult, its not the end of the world since opt's `mem2reg` pass will probably clean it up.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.