-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler refactor: replace Control Flow Graphs with builders #686
Conversation
Not gonna resolve all TODOs. This PR already deletes more TODOs than it adds. |
Don't know why the CI is failing now, and I cannot reproduce it locally. Maybe I'll fix finish this PR some other day :) |
I set up an awful Windows VM to debug this. (It is awful for various reasons.) This seems like a stack overflow bug. I am adding debug prints to But if I add a dummy variable I think the problem is that the new builder is allocating stack space in the loop, instead of doing it before the loop and then reusing the stack variables. I'm glad the test setup is good enough to catch this :) |
It is a stack overflow https://stackoverflow.com/a/76892354 I wonder if there's a way to better report this kind of errors to the Jou programmer when not using |
It worked!!!! :) |
A builder defines how to do somewhat elementary things, e.g. a function/method call, conditional branch, or an equals comparison. Then a new file
ast_to_builder.jou
recurses over the AST and calls methods of the builder accordingly.For now, there is only one builder, which builds LLVM IR. The idea is to later build a special, intentionally very limited "Jou IR" to solve #566.
Also, I really hated how the old CFG's worked. They were very similar to LLVM IR, but much shittier.
TODO:
# TODO: rename to AstToBuilder
# TODO: add error message for this, or dynamic size?
# TODO: https://github.com/Akuli/jou/issues/683
# TODO: tell llvm, if we know a function is noreturn ?
# TODO: useful, but doesn't belong here
# TODO: Everything named legacy_llvm14_cast can be removed once we drop LLVM 14 support
# TODO: which casts are necessary on LLVM 14 and which are not?
# TODO: method to find field
# TODO: do we need is_main_file?
# TODO: delete id
# TODO: delete double pointer