/r/Compilers
This subreddit is all about the theory and development of compilers.
For similar sub-reddits see:
Popular mainstream compilers:
/r/Compilers
1.4x as fast as FlashAttention (hand-written/optimized) in several cases, and at 85% geomean of its performance, while being completely automatically generated by a compiler (PolyBlocks)!
A more scalable, lasting, adaptable, and reusable approach!
Hi everyone! 👋
I’m working on a new programming language called Synapse , which combines the memory safety of Rust, the simplicity of Python, and the efficiency of C. I’d love to get your feedback on its syntax and design!
Here’s a quick example of what Synapse looks like:
let x: Int = 5;
func sum(a: Int, b: Int) -> Int {
return a + b;
}
more examples:
https://github.com/synapse-lang/synapse
I’ve created a short survey (takes ~5 minutes) to gather your thoughts on the readability, intuitiveness, and overall design of the language. Your feedback will directly help us improve Synapse!
Link: https://form.typeform.com/to/S3iAo9hL
If you have any questions or suggestions, feel free to comment below. Thanks in advance for your help! 🚀
Hi everyone, so I’ve recently started work on a compiler for python as well as a compiler for c, separate projects ones for a class, and was wondering if that alone would be enough to qualify me for any jobs, and if so what entry level jobs I should be looking for, im a computer science student and am graduating in may with no luck on any internships and not a single interview in like 2 years.
So hypothetically speaking, let's say we have a compiler than can detect when there are cyclic references at compile time (keep in mind this is a compile time referencing counting algorithm), and it transforms it into a weak reference. Would there ever be a scenario that the weak reference points to freed memory? My idea is that the compiler would insert deletion calls for them at the same time, and that there would never be invalid memory without compiler intervention, since the programmer wrote it using strong references, and the weak references is just an optimization. What are your thoughts? I'm just a stupid 9th grader and would love other people's input on this.
Hi everyone,
I wanted to share a small side project I’ve been hacking on: an automatic loop-parallelization tool for Java bytecode (not the source). It detects simple loops, proves thread safety, generates a parallel version, and picks between sequential/parallel at runtime based on loop size.
I know it’s super early and a bit rough around the edges, but it was a fun exploration. I would love feedback from folks here:
If this is too tangential or not the right kind of topic for r/compiler, let me know (DM is fine), and I can remove it! Otherwise, I’d love your thoughts on where to go from here or what to investigate next. If you’d like to see code snippets/implementation details, I posted them on my blog:
Thanks in advance for any guidance or critiques!
Miranda2 is a pure, lazy functional language and compiler, based on the Miranda language by David Turner, with additional features from Haskell and other functional languages. I wrote it part time over the past year as a vehicle for learning more about the efficient implementation of functional languages, and to have a fun language to write Advent of Code solutions in ;-)
Features
Many more examples of Miranda2 can be found in my 10 years of Advent of Code solutions:
Why did I write this? To learn more about how functional languages are implemented. To have a fun project to work on that can provide a nearly endless list of ToDos (see doc/TODO!). To have a fun language to write Advent Of Code solutions in. Maybe it can be useful for someone else interested in these things.
Hello, I've been working as a "compilers" engineer for about 3.5 years now at a big company. My official title is "software engineer" but I got hired for and work primarily on their legacy and product compilers as well as LLVM projects.
But... I can't pass a "compilers" interview for the life of me, I'm not even too interested in continuing my experience in compilers, but that is what recruiters come to me for as I have the experience for it. I get asked strange questions on optimizations, or low-level instruction flows, designing machine learning compilers, parallelism, and other niche topics that I've never come across in my job (besides optimizations which I don't really deal with).
I've actually had better experience interviewing for general software dev roles than compiler ones, I get further along in them.
So, I wanted to ask, where should I start to learn about stuff for passing a compilers interview, books on backend, codegen, optimizations, data-flow, instruction selection, pipelining, etc?
I like my job, but hate interviewing for compilers related roles.
Hey guys, So I've been interested in this field for quite a while and from reading some posts one of the things that I gathered (correct me if I'm wrong) is that one the best ways to get notoriety to be able to get a compiler engineer job would be to contribute to opensource projects like LLVM.
1- One thing that I think that applies to other opensource projects it how me as a new developer in low level engineering am supposed to find ideas / features of things to add to projects like this?
Most of the time that I've asked this question about find ideas of features (although more in more back-end development focused circles) the answer I get is to find something that it would improve my work, life, etc... Not sure if this answer applies to this but in general I've always found a weak answer, someone inexperienced like me wouldn't even know what I could improve.
I've been hoarding books, papers and videos to watch as soon that I have the time, that will give me more insight into the field but is still not clear how does one find things to add into on going projects.
Also a another question:
2- Is the compilers development field "developed" enough or are there still things to be discovered?
I understand that as hardware evolve and other subfields like AI compilers grow, there will always be things to be added and fixed into existing projects. But in general this things are complex / big things or just minor adjustment that are added over time? Like for example has the field always getting new innovations? Or is most of the ground work already made by past engineers?
Thanks in advance, all help is welcomed! Love you guys.
Hello everyone, I am a first year Masters student currently looking for a thesis topic to start on. I want to write my thesis in this domain and have started to look for topics inside conference papers like CC or CGO. But I thought I'd ask here too to check if there're some ideas you don't mind sharing,
Thank you!
Hello everyone i'm a university student and i've been given a project which is building a compiler using LLVM but am unable to compile IR code and don't know how to use LLVM so i'd love to know where to learn how to code LLVM
Dear Redditors,
The International Symposium on Code Generation and Optimization (CGO) is offering student travel grants. The application deadline is February 14th. You can submit your application through this link.
Recently I've taken interest in assembly and custom languages so I've started writing my own. One of the things i would like to do is not rely on external IR to assembly/machine code generation (like LLVM) because that doesn't really feel like I am fully writing my own language, can't really explain it.
I'm at a stage in my custom language where the code is fully analyzed and the AST is converted into my own IR (assembly-like with removed limitations etc...)
I now obviously want to turn my IR into an object file, but struggling to understand how to approach the task. I've tried manually outputting assembly instructions to a file, and while i did get the basics working, it rapidly turned messy and I didn't really like it.
Are there libraries or some other thing to assist in assembly or object file generation? Should i stick with outputting assembly manually? If so, what are some good ways to handle it? Or should i just abandon the idea because of the complexity and stick with something like LLVM?
In a previous post I mentioned that I had implemented SCCP analysis. I have now implemented the application of this to the program, so this is my first real optimizer pass on SSA.
Here is an example output of the results:
func bar(data: [Int]) {
var j = 1
if (j) j = 10
else j = data[0]
data[0] = j * 21 + data[1]
}
L0:
arg data
j = 1
if j goto L2 else goto L3
L2:
j = 10
goto L4
L4:
%t3 = j*21
%t4 = data[1]
%t5 = %t3+%t4
data[0] = %t5
goto L1
L1:
L3:
%t2 = data[0]
j = %t2
goto L4
L0:
arg data_0
goto L2
L2:
goto L4
L4:
%t4_0 = data_0[1]
%t5_0 = 210+%t4_0
data_0[0] = %t5_0
goto L1
L1:
The implementation is here: https://github.com/CompilerProgramming/ez-lang/blob/main/optvm/src/main/java/com/compilerprogramming/ezlang/compiler/SparseConditionalConstantPropagation.java
(Or lack of optimisations - blog post)
A few months ago I created a new IR backend, and used it for my two main compiler programs: one for my 'M' language, and one for a C subset.
This naturally generated memory-based code. I've now improved it to keep more stuff in registers and generally produce smaller code. But it doesn't do anything normally considered 'optimising' and that so many here consider essential.
My code might run 1-3 times as slow as highly optimised C code. My own M programs, or C code I write or generate, tends to fare better than other people's more chaotic C programs. There's a lot of variance.
I decided to show benchmarks for one class of program: interpreters for smaller languages:
Lua Interpreter (C) running fib.lua (D)
gcc 1.0 (0.8 seconds)
bcc 1.9
tcc 2.5
Clox interpreter (C) running fib.clox (D)
gcc 1.0 (1.2 seconds)
bcc 2.5
tcc 3.0
Pico C Interpreter (C) running fib.c (S)
gcc 1.0 (27 seconds)
bcc 1.8
Toy Pascal Interpreter (C) running fib.pas (S)
gcc 1.0 (0.8 seconds)
bcc 1.1
DMC 1.3
tcc 1.9
Toy Pascal Interpreter (M) running fib.pas (S)
mm 0.7 (using special computed-goto looping 'switch')
gcc 1.0 (0.7 seconds, via C transpiler)
mm 1.3 (using normal 'switch')
bcc 1.3 (via C)
tcc 1.7 (via C)
'PCL' Interpreter (M) running fib.pcl (S)
mm 0.9 (uses special 'switch')
gcc 1.0 (0.8 seconds, via C)
bcc 1.1 (via C)
tcc 2.2 (via C)
Q Interpreter (M) running fib.q (D)
mm 0.3 (uses acceleration via inline assembly and threaded code)
gcc 1.0 (1.1 seconds, via C)
mm 1.1
bcc 1.3 (via C)
tcc 2.0 (via C)
(The fastest absolute timing is my accelerated Q/mm version at 0.34 seconds. This is only beaten on my machine by PyPy running fib.py at 0.27 seconds, and LuaJIT running fib.py at 0.1 seconds.
However both of those are JIT products which might be executing dedicated native code; mine is still interpreting a bytecode at a time, using pre-compiled interpreter code.)
Conclusions:
Note that 27 seconds timing for the Pico C interpreter: gcc-O3 gives a useful speedup, but it is still 30 times slower than the others. So the answer here isn't just to pile on more optimisations: you need to write more efficient programs!
Oh, here's the benchmark that is run; there are variations on this so it is important to use the same version when comparing:
func fib(n) = # Q syntax
if n<3 then
1
else
fib(n-1) + fib(n-2)
fi
end
for i to 33 do # ie. 1 to 33 inclusive
println i, fib(i)
od
Hi folks,
im a final yr computer engineering student from Ireland and im interested in persuing this brewing interest I have in compilers, interpreters etc... specically in the domain for AI-Acceleration. It's a niche that i think is valuable but also weirdly really stupid cool that i've been enjoying learning about.
I signed an offer last month with IBM for when i graduate where i'll be working on OSS Mainframe Containerization sw to support hw+compiler integration, to support it's on board AI-Accelerator.
While not striclt compiler engineering, it helped drive my interest.
I wanted to ask folks how they what would suggest I learn about compiler development?
I pruchased Dmitry Soshnikov's compiler engineer bundle on teachable and been thoroughly enjoying it, and finding it very useful. However I find myself at a cross road where if I went to go make a simple project myself (say an s-expressive python interpreter or something) I would be reliant on AI resources, neglecting core components of learning.
I havent touched LLVM/MLIR yet, mostly just raw fundementals with C++ and a basic interpreter abstracted from JS for learning.
Nevalang is a programming language where you express computation in forms of message-passing graphs - no functions, no variables, just nodes that exchange data as immutable messages, and everything runs in parallel by default. It has strong static typing and compiles to machine code. In 2025 we aim for visual programming and Go-interop.
New version just shipped. It's a patch-release that fixes compilation (and cross-compilation) for Windows 🙏
I know nothing about compilers, I know that compilers nowadays are practically optimized as they can be, but however sometimes two functions that do the same written slightly different can be compiled to a different instruction size subroutine.
Do you think that AI could potentially help squeeze more the code?
C/C++ program will be compiled into binary executable(original code -> assembly code ---link with some system level code---> binary executable), then machine CPU will directly operate on the binary executable
Ruby program will be parsed by MRI(interpreter) into AST(syntax/structure checking), then convert to byte code, then YARV(Ruby's VM) will run these byte code. These byte code are not the same as the native binary executable that directly run on the mahine.
Ruby's bytecode are as dynamic as its original form. For example, the method definition are dynamic. One Ruby program can redefine a class's method several time. While this is not supported by C/C++, this is supported by Ruby. But because of this, Ruby cannot be compiled into a fixed executable like C. Things like method definition are determined at runtime inside of YARV.
JIT(just in time compiler): at run-time, inside of YARV, we can determine there are some hot code and compile them to be binary executable to the native OS instance(where YARV is hosted in)
Around almost half a year ago, I came up with the idea to write a compiler in C, with the purpose being to compile source code very similar to the C programming language.
Writing the scanner seemed like a hard task, but I eventually got the hang of it. Eventually, I finished writing a stable scanner, and wanted to move on by writing the parser.
I found this Backus-Naur Form of the C programming language's syntax here, and spent a few days attempting to implement all of the different rules. Eventually, I'd finish implementing the rules, but then I quickly found out that I ran into a new, much larger issue; this Backus-Naur Form syntax of the C programming language that I implemented requires a little more in order to implement an actual functional parser. I'd find out the hard way that basic identifiers would always be treated as types due to the fact that they're automatically assumed to be `typedef`-defined types.
I did some more research, and found out that I'd have to use a symbol table in order to resolve my obstacle here, however I've been having trouble finding out which specific handler of the parser's rules I should actually read & write to the symbol table from.
For now, I have my parser print out each rule that it attempts to parse, each rule that it fails to parse, and each rule that it successfully parses. A single statement like:
typedef byte type;
Gives us a seemingly-broken parsing log:
debug: Status for parsing rule `rule_translation_unit ` (status: `started`, level: `0`).
debug: Status for parsing rule `rule_external_declaration ` (status: `started`, level: `1`).
debug: Status for parsing rule `rule_function_definition ` (status: `started`, level: `2`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `started`, level: `3`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_auto ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_auto ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `success`, level: `5`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `success`, level: `4`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `success`, level: `3`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `started`, level: `3`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_auto ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_auto ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_type_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_void ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_void ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_byte ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_byte ` (status: `success`, level: `5`).
debug: Status for parsing rule `rule_type_specifier ` (status: `success`, level: `4`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `success`, level: `3`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `started`, level: `3`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_auto ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_auto ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_type_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_void ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_void ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_byte ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_byte ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_signed ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_signed ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_unsigned ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_unsigned ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_struct_or_union_specifier ` (status: `started`, level: `5`).
debug: Status for parsing rule `rule_struct_or_union ` (status: `started`, level: `6`).
debug: Status for parsing rule `keyword_struct ` (status: `started`, level: `7`).
debug: Status for parsing rule `keyword_struct ` (status: `failure`, level: `7`).
debug: Status for parsing rule `keyword_union ` (status: `started`, level: `7`).
debug: Status for parsing rule `keyword_union ` (status: `failure`, level: `7`).
debug: Status for parsing rule `rule_struct_or_union ` (status: `failure`, level: `6`).
debug: Status for parsing rule `rule_struct_or_union_specifier ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_enum_specifier ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_enum ` (status: `started`, level: `6`).
debug: Status for parsing rule `keyword_enum ` (status: `failure`, level: `6`).
debug: Status for parsing rule `rule_enum_specifier ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_typedef_name ` (status: `started`, level: `5`).
debug: Status for parsing rule `identifier ` (status: `started`, level: `6`).
debug: Status for parsing rule `identifier ` (status: `failure`, level: `6`).
debug: Status for parsing rule `rule_typedef_name ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_type_specifier ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_type_qualifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_const ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_const ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_volatile ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_volatile ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_type_qualifier ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `failure`, level: `3`).
debug: Status for parsing rule `rule_declarator ` (status: `started`, level: `3`).
debug: Status for parsing rule `rule_pointer ` (status: `started`, level: `4`).
debug: Status for parsing rule `symbol_multiply ` (status: `started`, level: `5`).
debug: Status for parsing rule `symbol_multiply ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_pointer ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_direct_declarator ` (status: `started`, level: `4`).
debug: Status for parsing rule `identifier ` (status: `started`, level: `5`).
debug: Status for parsing rule `identifier ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_direct_declarator ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_declarator ` (status: `failure`, level: `3`).
debug: Status for parsing rule `rule_function_definition ` (status: `failure`, level: `2`).
debug: Status for parsing rule `rule_declaration ` (status: `started`, level: `2`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `started`, level: `3`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_auto ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_auto ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `success`, level: `5`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `success`, level: `4`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `success`, level: `3`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `started`, level: `3`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_auto ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_auto ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_type_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_void ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_void ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_byte ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_byte ` (status: `success`, level: `5`).
debug: Status for parsing rule `rule_type_specifier ` (status: `success`, level: `4`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `success`, level: `3`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `started`, level: `3`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_auto ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_auto ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_register ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_static ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_extern ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_typedef ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_storage_class_specifier ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_type_specifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_void ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_void ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_byte ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_byte ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_signed ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_signed ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_unsigned ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_unsigned ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_struct_or_union_specifier ` (status: `started`, level: `5`).
debug: Status for parsing rule `rule_struct_or_union ` (status: `started`, level: `6`).
debug: Status for parsing rule `keyword_struct ` (status: `started`, level: `7`).
debug: Status for parsing rule `keyword_struct ` (status: `failure`, level: `7`).
debug: Status for parsing rule `keyword_union ` (status: `started`, level: `7`).
debug: Status for parsing rule `keyword_union ` (status: `failure`, level: `7`).
debug: Status for parsing rule `rule_struct_or_union ` (status: `failure`, level: `6`).
debug: Status for parsing rule `rule_struct_or_union_specifier ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_enum_specifier ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_enum ` (status: `started`, level: `6`).
debug: Status for parsing rule `keyword_enum ` (status: `failure`, level: `6`).
debug: Status for parsing rule `rule_enum_specifier ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_typedef_name ` (status: `started`, level: `5`).
debug: Status for parsing rule `identifier ` (status: `started`, level: `6`).
debug: Status for parsing rule `identifier ` (status: `failure`, level: `6`).
debug: Status for parsing rule `rule_typedef_name ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_type_specifier ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_type_qualifier ` (status: `started`, level: `4`).
debug: Status for parsing rule `keyword_const ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_const ` (status: `failure`, level: `5`).
debug: Status for parsing rule `keyword_volatile ` (status: `started`, level: `5`).
debug: Status for parsing rule `keyword_volatile ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_type_qualifier ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_declaration_specifier ` (status: `failure`, level: `3`).
debug: Status for parsing rule `rule_init_declarator ` (status: `started`, level: `3`).
debug: Status for parsing rule `rule_declarator ` (status: `started`, level: `4`).
debug: Status for parsing rule `rule_pointer ` (status: `started`, level: `5`).
debug: Status for parsing rule `symbol_multiply ` (status: `started`, level: `6`).
debug: Status for parsing rule `symbol_multiply ` (status: `failure`, level: `6`).
debug: Status for parsing rule `rule_pointer ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_direct_declarator ` (status: `started`, level: `5`).
debug: Status for parsing rule `identifier ` (status: `started`, level: `6`).
debug: Status for parsing rule `identifier ` (status: `failure`, level: `6`).
debug: Status for parsing rule `rule_direct_declarator ` (status: `failure`, level: `5`).
debug: Status for parsing rule `rule_declarator ` (status: `failure`, level: `4`).
debug: Status for parsing rule `rule_init_declarator ` (status: `failure`, level: `3`).
debug: Status for parsing rule `symbol_semicolon ` (status: `started`, level: `3`).
debug: Status for parsing rule `symbol_semicolon ` (status: `failure`, level: `3`).
debug: Status for parsing rule `rule_declaration ` (status: `failure`, level: `2`).
debug: Status for parsing rule `rule_external_declaration ` (status: `failure`, level: `1`).
debug: Status for parsing rule `rule_translation_unit ` (status: `success`, level: `0`).
I've realized that my brain is still too small in order to actually grasp this entire thought, and I think a second pair of eyes could really help out. If anyone is willing to help, I'd gladly appreciate it! The source code for my compiler can be found here.
I have MLIR/LLVM version 14.0.6 installed. I have also successfully installed torch-mlir according to instructions in the official repository. But I can't seem to find how to convert a Pytorch/ONNX model to MLIR IR (Torch dialect).
Help 😭
Hi everyone,
I'm current writing my first compiler in C, and I'm already done writing the lexer and parser.
Now I'm writing the semantic analyzer and code generator.
I know my compiler needs a symboltable, so it can:
1: lookup the address of a variable during code generation
2: do semantic checking (eg: using a variable that hasn't been declared)
Right now I'm implementing the symboltable as stack of hashtables where the key is the name of the variable, and the value is the type + address (rbp-offset).
When traversing the AST, whenever I enter a new scope I push a new symboltable onto the stack, and when I leave I pop the last table.
However, the problem is that after traversing the AST, all symboltables have been poped from the stack.
That means that I'd have to construct the symboltable twice, for semantic analysis and code generation.
And while I don't particularly care about performance or efficiency in this implementation, I still wonder if there's a cleaner solution.
btw: I've done research on the internet, and I'm kinda confused, because there aren't a lot of resources for this, and the ones there are, are all kind of different from one another.
EDIT:
What I'd like to do, is build the symboltable datastructure in the semantic analysis phase, but don't fill in the actual addresses of the variables, then fill in the missing address in code generation - in the same datastructure.
In my language implementation I model exception flow in the IR. Initially I thought this was a novel approach, but then I found that it had been thought of before.
Although not exactly the same, the basic idea is similar.
My impression though is that this is not common, most IRs do not show control flow for exceptions directly in the IR. I am curious if any other projects did/do this.
Pretty much what the title says. As far as I'm aware, there shouldn't strictly be a reason that JIT compiled languages (.e.g. C#, Kotlin, etc) -- when stripped of their higher level abstractions -- couldn't be used at a lower level. Why not even a JIT compiler for a pre-existing low level language like C? Is there something in theory that just inhibits JIT compilation from competing near the levels of AOT compilation?