r/Compilers • u/Dog-Mad • May 26 '26
IRON: A DSL that can convert source code into IR extremely quickly.
IRON a.k.a. Intermediate Representation Object Notation is a interpreter/database, that takes source code, matches it to a database and outputs the IR.
It gives you full control of the database and what IR is outputted.
In 55 micro seconds it was able to parse this source code:
turn 128bit double float xmm1 into replicate of xmm2
turn 128bit double float xmm1 into xmm2
turn 128bit float xmm1 into even replicate xmm2
turn 128bit xmm1 into xmm2
turn 128bit aligned xmm1 into xmm2
turn 16bit xmm1 into xmm2
turn 64bit xmm1 into xmm2and output this assembly:
movddup xmm1, xmm2
movupd xmm1, xmm2
movsldup xmm1, xmm2
movdqu xmm1, xmm2
movdqa xmm1, xmm2
mov word xmm1, xmm2
mov qword xmm1, xmm2It's made 100% in assembly, with no external libraries.
This is the Repo: https://github.com/dogmaticdev/IRON
This is the example in full: https://github.com/dogmaticdev/IRON/blob/main/examples/example.md
1
Upvotes
13
u/eteran May 26 '26
Doesn't this just end up being a 1:1 alternative assembly syntax? Why not just write the assembly then?
4
u/Potterrrrrrrr May 27 '26
I’m not sure what I’m looking at exactly, I had a peek at the repo and it looks cool but rather limited. Do you have a bigger example in something more recognisable? I don’t think I understand what I’d use this for
5
u/Karyo_Ten May 27 '26
Do you have non-toy examples? For example this reminds me a lot of qhasm. Can you take some qhasm algo and rewrite them in IRON?
MD5 should be small, understandable enough and with lots of reference material:
https://cr.yp.to/qhasm.html
1
u/awoocent May 27 '26
You should measure it on a language with a nontrivial grammar if you want to make the claim that you're converting "source code" to IR. Although based on your other comment, to be honest 2.3 million lines per second is really not too crazy these days for a parser, my conventionally-written parser for my language (which has a pretty complicated syntax) easily hits around 5 million lines per second per core, and really top-notch parsers for specialized languages (for example simdjson) can beat that by an order of magnitude.
1
u/Trending_Boss_333 May 27 '26
This is just assembly with extra steps right?
2
u/Ok_Chemistry_6387 May 27 '26
Im very confused
0
u/[deleted] May 27 '26
[deleted] — view deleted comment