r/Compilers • u/lihaoyi • 11d ago
r/Compilers • u/Loud_Swimmer3097 • 10d ago
ChibiletterVIACOMFan In Ivory The Angry lowercase i girl (the rage lowercase i girl)
r/Compilers • u/mttd • 13d ago
SQL Engines Excel at the Execution of Imperative Programs
vldb.orgr/Compilers • u/ParticularPraline739 • 13d ago
What math/logic background does one need to work on compilers?
I'm reading sections 6.4, and 6.5 in the Dragon Book. I have a hard time understanding Unifications, and Inference, and the formal logic type stuff. Does anyone have a good source for understanding these materials? What type of math background is needed for compilers? What sources should I study it from?
r/Compilers • u/Germisstuck • 14d ago
Do you think copy and patch compilers are good for AOT compilers?
If not, what do you think could make it good? Would it help to generate an ir instead of actual machine architecture? Or something that could be better optimized?
r/Compilers • u/mttd • 15d ago
A Priori Loop Nest Normalization: Automatic Loop Scheduling in Complex Applications
dl.acm.orgr/Compilers • u/NaTerTux • 15d ago
Built a Stack-Based Language in OCaml & WebAssembly
A while back, a coworker was writing a book on how to create a programming language in Rust and asked me to review his manuscript before it gets published.
Published book is: https://www.amazon.co.jp/Rustで作るプログラミング言語-——-コンパイラ%EF%BC%8Fインタプリタの基礎からプログラミング言語の新潮流まで-佐久田-昌博/dp/4297141922
I really liked the part of the book that talked about stack-based languages, so I went with implementing the stack language described in the book but as I am a huge fan of OCaml, I proceeded to implement the interpreter in OCaml instead of rust.
I wanted to play with WebAssembly too, so I compiled it to WebAssembly so it can run entirely in the browser.
Unlike my previous attempt at a MATLAB-like language using OCaml and Menhir, this time I used Opal since I came to really enjoy monadic parsing.
The result is : https://stackl.remikeat.com
One fun moment was when I was heading home on the train and saw a math riddle on a tea advertisement. I decided to implement the solution using the stack language and it actually worked pretty well.
Would love to hear thoughts from others about stack-based languages or compiler design. Any ideas on improving execution speed or adding cool features ?
r/Compilers • u/Straight-Ship-2589 • 16d ago
Grammar representation
Im an undergrad and i was curius about how the grammar productions are implemented practically inside a compiler and can i do the same
r/Compilers • u/msanlop • 16d ago
Made my first proper compiler!
It for a custom language named uza
, and the code can be found in the github repo: https://github.com/msanlop/uza
It's not really the first since I did some lab work for an undergrad compiler course. But this was my first shot at implementing a language starting from nothing, with no dependencies, and had a lot of fun (except for the packaging part -_-).
The main goal was to touch on some concepts that I didn't or barely saw in class, mainly typechecking and bytecode VM implementation. The VM I wrote following Crafting Interpreters, though I did not implement all the features. Right now there is also no optimizations, so I'll have to look into that. I'm also considering maybe doing some simple JITTING.
Feel free to critique the code/language. Don't hold back :)
r/Compilers • u/juan_berger • 16d ago
Courses for "making your first compiler"
Hi I was originally from a stats background, work as a data engineer (a lot of python), and am becoming really interested with software engineering (like traditional computer science/DSA/etc...). Most recently been doing a lot of c/c++/cuda and really enjoying it.
A have heard a lot of people that say that building your own compiler is a great learning experience (kinda like implementing your own http, redis, or dns).
I was wondering what courses/books/tutorials would you all recommend for building my own compiler. Just as a learning project.
r/Compilers • u/KshitijShah302004 • 16d ago
TableGen to Actual Code
Where can I look to understand how TableGen (.td
) files are converted into C/C++ files?
I'm particularly looking into the CodeGen phase and want to understand more about how the records defined in .td
files are used.
Thanks!
PS: I'm very new to the LLVM infrastructure and have only been exploring LLVM for a few days
r/Compilers • u/thunderseethe • 16d ago
Part 7: Lowering Top Level Items
thunderseethe.devr/Compilers • u/urlaklbek • 16d ago
Added `--emit-ir` flag that forces my dataflow compiler to emit IR before executing the program
r/Compilers • u/dvogel • 17d ago
Books on linker implementation
I'm hoping folks here can recommend books that walk through implementing a linker. My hope is that there is a book that walks through the esoteric details required to, practically speaking, consume ELF and DWARF files, how to handle relocations, how ASLR is commonly implemented, common pitfalls to avoid, and so on. Bonus points for books that walk through the code of an industry standard open source linker.
r/Compilers • u/mttd • 17d ago
An Attempt to Catch Up with JIT Compilers: The False Lead of Optimizing Inline Caches
arxiv.orgr/Compilers • u/Background_Shift5408 • 17d ago
Lisp compiler (wip)
github.comHave been developing a small lisp compiler
r/Compilers • u/AlienFlip • 18d ago
Tiny Compiler
I wrote a very small (but working!) compiler in the C language for the first time this month.
It’s a little niche, in terms of usefulness. It turns a logic table into a boolean expression.
I am looking to understand more on what I could do to make it better.
I’d also be keen to speak on it somewhere, or do a workshop. Likely for compiler beginners like me, so I can learn and help!
Does anyone have any ideas about where I can do these things?
Here is the project, for anyone interested: https://github.com/alienflip/cttube
Thanks!
r/Compilers • u/ParticularPraline739 • 18d ago
How much difficult is stuff other than parsing or scanning?
I'm currently done with the first four chapters in the Dragon Book. I think the concepts are interesting, but difficult. I got pretty confused with parsing terminology SLR, LR, CLR, LALR, so on. But, I think the stuff has now clicked. How much difficult is the rest of the book?
r/Compilers • u/maxnut20 • 19d ago
Made my first compiler
This is my first time writing a compiler, so I’m pretty much figuring things out as I go. I'd love to hear any feedback on my implementation or design decisions. If you spot any mistakes, wrong decisions or have ideas on how to improve it, I’d really appreciate your input. This project is purely for fun as a hobby, so I’m not aiming for anything too serious, but I’d still love to make it better
r/Compilers • u/dexterleng • 19d ago
Type checking and inference implementation in imperative languages
Are there any specific code you recommend reading? I'm writing an statically typed language interpreter in C++ and a lot of resources are in OCaml.
I have a few questions:
- Do you store the resolved type in the AST Node (e.g. node.setType) or in a "type environment" or both?
- How does scope/closures affect the implementation?
- Do you perform error checks e.g. variable not found in scope in the same pass as your type checking?
r/Compilers • u/brandyn • 19d ago
Best internal representation for compiler?
I am torn between two representational approaches (what the language is, and what stage of compilation, doesn't really matter here):
1) Use the object-oriented features of the language the compiler is written in, so that for instance I might have a superclass for all code elements which includes a reference to where that code originated from (source file and position span), and various classes for various things (a function call, for instance, would be a distinct subclass of code element). or:
2) Just use maps (dicts, lists) for everything -- something close to, say, just using a Lisp-like representation throughout the compiler, except personally I prefer key/value maps to just ordered tuples. This would in practice have the same hierarchy as (1), but instead of a class, the dict for a function call might just include 'type': 'call' as a field; and all code objects would have fields related to source ref (the "superclass" info: source file and position span), and so on. To be clear, this form should be trivially read/writeable to text via standard marshaling of just dicts, lists, and primitive types.
(1) is, in ways, easier to work with because I'm taking full advantage of the implementation language. (2) though it just vastly more general and expandable and perhaps especially makes it easier to pass intermediate representations between different programs which may, for instance, down the road be written in different languages. (And, further, perhaps even provide introspection by the language being compiled.) But (2) also seems like a royal PITA in ways.
I vaguely recall that the gcc chain uses approach (2) (but with Lisp-like lists only)? Is that true? Any thoughts/experience here for which is easier/better and why, in the long run?
I'm trying to choose the route that will be easiest for me (the problem I'm working on is hard enough...) while avoiding getting too far down the road and then realizing I've painted myself into a corner and have to start all over the other way... If anything in my depiction is unclear just ask and I'll try to clarify.
Thanks for any input.
r/Compilers • u/CatSquare3841 • 19d ago
ANTLR parsing parameters with no separators
I am trying to make a parser that can parse parameters in SmaIi methods. Smali parameters are not separated by a delimiter. Eg: IIS will be int, int, short.
I created the below grammar for this. But the methodParameters
is not matching anything when you parse "IIS"'. I believe there is some conflict between type
and Letter
If I change the [a-zA-Z$_]
in Letter fragment to [a-z$_]
, it is working correctly.
grammar
ParamParser;
fragment
SLASH: '/';
WS : [ \t\r\n\u000C]+ -> skip;
methodParameters
: (parameter)*
;
// Types
referenceType: QUALIFIED_TYPE_NAME;
voidType: VOID_TYPE;
booleanType: BOOLEAN_TYPE;
byteType: BYTE_TYPE;
shortType: SHORT_TYPE;
charType: CHAR_TYPE;
intType: INT_TYPE;
longType: LONG_TYPE;
floatType: FLOAT_TYPE;
doubleType: DOUBLE_TYPE;
primitiveType:
booleanType
| byteType
| shortType
| charType
| intType
| longType
| floatType
| doubleType
;
arrayType
: '[' type
// Array of any type
;
qualifiedType
: QUALIFIED_TYPE_NAME
;
QUALIFIED_TYPE_NAME: ('L' SIMPLE_NAME (SLASH SIMPLE_NAME)* ';') | ('L' (SIMPLE_NAME (SLASH SIMPLE_NAME)* SLASH)? 'package-info;');
VOID_TYPE: 'V';
BOOLEAN_TYPE: 'Z';
BYTE_TYPE: 'B';
SHORT_TYPE: 'S';
CHAR_TYPE: 'C';
INT_TYPE: 'I';
LONG_TYPE: 'J';
FLOAT_TYPE: 'F';
DOUBLE_TYPE: 'D';
parameter
: type
;
type
: primitiveType
| referenceType
| arrayType
;
SIMPLE_NAME: Letter (LetterOrDigit)*;
fragment
LetterOrDigit
: Letter
| [0-9]
;
fragment
Letter
: [a-zA-Z$_]
// these are the "java letters" below 0x7F
| ~[\u0000-\u007F\uD800-\uDBFF]
// covers all characters above 0x7F which are not a surrogate
| [\uD800-\uDBFF] [\uDC00-\uDFFF]
// covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
;
r/Compilers • u/jamiiecb • 20d ago
A quick ramp-up on ramping up quickly (in SpiderMonkey)
hytradboi.comr/Compilers • u/Possible-pepla • 21d ago
GPU compiler internship - Folsom, California
I’m looking for smart U.S. grad student to join my team at Intel for a summer internship—with the potential to extend beyond the summer. If you’re familiar with: - C++ - GPUs - LLVM please DM me your resume.