#Compiler

Portable C compiler: a C99 compiler while still keeping it small, simple, fast and understandable:
http://pcc.ludd.ltu.se/ #free #compiler #C99
Compiler-Duo: Viele Verbesserungen für Clang 17 und LLVM 17
Neben einer Fülle an Details und Korrekturen verstärkt die neue Compiler-Generation von Clang und LLVM 17 die Sprachen C++20, C++23 und C++26.
#Compiler #LinuxundOpenSource #Programmierung #Softwareentwicklung #news

The Odd operator is beautifully easy after Inc and Dec. I've highlighted to two instructions for the Odd itself and the CPL for NOT. Ignore the references to temp0 which will get optimised away at some point.
Note how the allocator is smart enough to only load the low byte of the 16-bit variable.
I think I'll also add a version that targets a branch. It'll be a lot shorter if optimised.

Almost all the code generation is table driven. Inc and Dec are one of the exceptions that require code. In this case it's a loop to generate the INC or DEC instructions.
Only thing left to do is to generate add or subtract if the offset is too large. For now I'm stabbing at doing this for offset greater than four. Optimising here is much more complex than it might seem. For example you can INC any register whereas ADD requires A.

I'm working my way through 'intrinsics' in the #compiler. These are operations that look like functions or procedures to the programmer but are generated inline code. Examples are Write, Inc, Peek, Poke, Inp, Out, Sizeof and High.
Support for these includes adding an 'Enumerable' type set for the parameters and some flags. Inc and Dec can only accept a variable reference as the first parameter and a constant as the optional second parameter.

@lightning I just looked it up and #PCC is... 1mb. PCC wins smallest efficient #compiler infrastructure by a landslide, wow.
I've spent the day upgrading the error reporting in the #compiler. Previously it used simple error codes. It's been bugging me that I can't add more detailed messages, or include extra data such as a type name or variable name.
So here it is reporting the actual variable name it has an issue with.

@cfbolz Just for those who don’t get the joke: It’s a play on https://godbolt.org/ #compiler explorer
I'm adding typecasts to the #Quiche #compiler. This is the next step toward full function support. In #Pascal typecast syntax is the same as a function.
b := integer(a);
This gives me the hooks I need to call functions within expressions and handle the return value. But typecasts generate inline code so I don't have to do stack frames yet.
I know I posted already about this, but let me #gloat.
I started working on #Squarepants 3 years ago, when I didn't have a clue of how to write a #compiler.
When I finally managed to make the first version run (it was written in #elm ) it took seven minutes to compile.
Now it takes less than four seconds.
Fuck yeah.
This is so satisfying. _^
Is there a compiled programming language with a Python-like syntax?
#Compiler.nvim now support all the #programming #languages that were originally planned. That is:
* 22 programming languages
* 128 different ways of compiling
* 128 unit tests
* 100+ examples
* 1 test suite
Through the lapse of 75 days. That's... A lot of coding.
The #zig language is actually very cool. Its compiler has many aspects of #rust like:
* The #compiler knows how to find all the files of the programs just by passing it the entry point file. This makes unnecessary using a building system in most instances.
* more intelligent errors messages.
I'm just adding support for it to the #neovim #plugin compiler.nvim
This is mad 🤯
oxc - The Oxidation #Compiler is creating a suite of high-#performance tools for the #JavaScript / #TypeScript language re-written in #Rust - by Boshen:
https://github.com/web-infra-dev/oxc
It's linter is 50 - 100 times faster than #ESLint...
https://github.com/Boshen/bench-javascript-linter
...and its parser is even 2x faster than #swc
https://github.com/Boshen/bench-javascript-parser-written-in-rust
#JS tooling goes brrrrrrrrrrr! 🚀
Does anyone have any good #resources on learning #codegeneration?
I feel like everywhere I look for #compiler building resources it's just the trivial parsing and lexing parts
Anyone forming a team for this OSSF funded competition (2 yr $20M in prizes)?
Teams will need #NLP, #CyberSecurity, #StaticAnalysis and #Compiler expertise. Maybe #OpenSource project and community management experience would help too. This will likely hinge on #GOFAI algorithms like A* search, and graph querying (#AST walking). If you've written a linter you probably have the right stuff.
(Yes, for any other #compiler nerds in the audience, the goal is to fully self-host the SwitchBoard recipe technology.)
The Secret Life of C++: What Your #Compiler Doesn't Want You To Know
https://web.mit.edu/tibbetts/Public/inside-c/www/
“#CPP is filled with strange and wonderful features, with a few more added in C++11. We will explore in detail how these features are implemented under the covers, in terms of the #assembly #code generated.”

After a days thrashing in Delphi the #Quiche #compiler can now generate calls to Write and WriteLn.
Being able to make function calls has been my target for several months so it feel great to finally arrive.
Having said that, Write and WriteLn are special cases that sidestep a few steps required for full function calling. but I'm getting close now.

A new #blog post appears!
Can #mold be used as the #OpenBSD system #linker? Let's find out!
https://briancallahan.net/blog/20230813.html
#program #programming #unix #ld #linkers #compiler #compilers #programminglanguage #programminglanguages #freebsd #netbsd #dragonflybsd #linux #unix #toolchain #toolchains #llvm #lld #gnu #binutils
#EXP :
Le podcast #CosyCorner.
Du #RPG, du jeu vidéo, des sketchs, du small talk et autres avec Medoc et @Moguri.
https://www.patreon.com/lecosycorner
#TempsReel, #Compiler :
Via le compte de @fenarinarsa quelques messages sur la #demoscene et de la technique (plutôt sur des machines rétro).
I've spent the last week working on comparison operators in the #Quiche #Z80 #compiler. These either result in a branch or an assignment.
Branching is easy - just use the CPU flags. Assignment means converting to $00 or $ff (false or true).
Carry flag to boolean is just SBC A,A. If carry set we get -1 ($ff). If carry clear we get 0. To invert we can CCF (invert carry flag) before or CPL (bitwise invert A) after. 1/n
‘Computer language that anyone can read’ launches Aeternity compiler - Lexon now features a compiler that allows users to translate code... - https://cointelegraph.com/news/lexon-computer-language-that-anyone-can-read-launches-aeternity-compiler #smartcontracts #aeternity #compiler #lexon
Optimizing Rust programs with PGO and BOLT using cargo-pgo, https://kobzol.github.io/rust/cargo/2023/07/28/rust-cargo-pgo.html.
Feedback-directed optimisations made easy with `cargo-pgo`! Neat.
Schönen guten Morgen!
Bin dabei, unseren zentralen Steuerrechner am #Röntgen-#Mikroskop neu aufzusetzen. Das System an sich läuft, nur die Steuersoftware nicht. Also, die Software schon, und sie steuert auch, sogar unser Mikroskop.
Aber wir hijacken noch eine ganze #Beamline, und die Kommunikation dahin ist tot.
Später mal analysieren, *wo* das Problem liegt:
omniORB, Tango, C-Bindings, SPEC …
oder eine ungünstige #Compiler-Version …
Jetzt aber erstmal #Frühstück ☕.
Habt einen schönen Tag!
Arenas are super funny to me; folks suddinly rediscovering that array index operations are summa the most well studied and powerful #compiler optimizations out there
*Almos all* of the origimal #FORTRAN compiler from the 50s was around doing this!! (they actually considered normalous expressions trivial to codegen for, parsing 'em was harder)
@Angle @ddevine it would be fun to be able to feed the output from something like gprof into the compiler so it knows how the code paths are actually *used* and then let it do a better optimization as a result.
#compiler #optimization #coding #softwareDevelopment
@Angle my problem is that I'm not convinced "readability" is a teachable concept for a #compiler / #algorithm without doing it the hard (analyse samples, generate model) way. YMMV and maybe someone will do it in code, but it *feels* like the kind of problem humans are just more suited to than computers in the first place. Much like map route solving.
#programming #brainstorm
the weird thin about all me #compiler stuff over the last couple years is I cain't hardly use a language unless I've skimmed thru its offisal for-compiler-devs-only spec 🤔🤔🤔🤔🤔
Progress report on rustc_codegen_cranelift (July 2023), https://bjorn3.github.io/2023/07/29/progress-report-july-2023.html.
The goal of this project is to create an alternative codegen backend for the Rust compiler based on Cranelift. This is a progress report of the project.
A book on compilers. Free for personal use:
I would also like to share Compiling with Continuations, but it's not free available.
It's surprising how many different ways to break a compiler you can find in just 3 lines of code
A wild #blog post appears!
Teaching the Portable C Compiler (PCC) to use Yasm and the Sun assembler as its assembler (instead of the GNU assembler).
https://briancallahan.net/blog/20230723.html
#compiler #compilers #c #assembly #assembler #assemblers #unix #bsd #freebsd #netbsd #openbsd #dragonflybsd #linux #solaris #illumos #program #programming #programminglanguage #programminglanguages #opensource #freesoftware
Speculation in JavaScriptCore, https://webkit.org/blog/10308/speculation-in-javascriptcore/.
A long blog post explaining in details what a speculative compiler is, and how it is implemented in JavaScriptCore, the JavaScript engine of WebKit.
Optionally, if I have enough time and it proves to be really useful: use #symbolic #execution to determine if #decompiled code corresponds to original sources code. It doesn't look trivial at all, as codes written by humans tends to be much more verbose, logical, etc, than codes generated by compilers.
In summary: it's hard to compare, say, humans written Abstract Syntax Trees against the #AST given by an optimising #decompiler taking as input code optimised by a #compiler.
A wild #blog post appears!
The PCC compiler supports #Illumos now.
https://briancallahan.net/blog/20230705.html
#compiler #compilers #c #unix #linux #freebsd #openbsd #netbsd #dragonflybsd #solaris #openindiana #programming #bsd #sun #oracle #opensolaris
A new #blog post appears!
Installing Oracle Developer Studio 12.6 on OpenIndiana, a tale of lies.
Join me as I install Oracle's proprietary compiler suite on an open source Illumos distro, despite Oracle's best attempts to stop me.
https://briancallahan.net/blog/20230703.html
#programming #compiler #compilers #solaris #sun #oracle #c #linux #freebsd #openbsd #netbsd #dragonflybsd #bsd #unix #illumos #openindiana #opensolaris
Been a while since I posted here, but life has been super busy lately.
But today I'm happy to announce the first version of the eclair website: https://eclair-lang.org/ !
Here’s How To Build A Tiny Compiler From Scratch
A new #blog post appears!
Can we build all ten #GCC language frontends on #OpenBSD?
https://briancallahan.net/blog/20230626.html
#compiler #compilers #language #languages #unix #linux #freebsd #netbsd #dragonflybsd #llvm #clang #programming #programminglanguage #programminglanguages #ada #c #go #golang #fortran #rust #d #dlang
For the #GPU and #compiler folks, looks like the Arm Norway Mali (formerly Falanx) team is recruiting people to work on the Mali GPU and its compiler toolchain. But it seems there are more roles available as well.
Location: Trondheim, Norway
https://careers.arm.com/job/raanana/principal-software-architect/33099/43324206832
https://careers.arm.com/job/lund/senior-software-engineer-compiler-technology/33099/48756552336
Possibly interesting for some #GameDev folks as well.
The two hardest problems in #compiler development:
1. Escape analysis
2. Lexing float and string constants
#CLanguage « #SectorC is a #C #compiler written in x86-16 assembly that fits within the 512 byte boot sector of an x86 machine. It supports a subset of C that is large enough to write real and interesting programs. It is quite likely the smallest C compiler ever written. » https://xorvoid.com/sectorc.html
#SectorC: A #C #Compiler in 512 bytes
“Big Insight #2 is that atoi() behaves as a (bad) hash function on ordinary text. It consumes characters and updates a 16-bit integer. Hashes are perhaps the holy-grail of computer-science. With a good hash, we can just side-step all the hard problems by trading them for an even harder problem (hash collisions), and then we just ignore that harder problem. Brilliant. (sticks fingers in ears) 🤪”
Nice free course by Cornell university for learning a couple of things about compilers and programming languages implementations
https://cs.cornell.edu/courses/cs6120/2020fa/self-guided/
Github repo: https://github.com/sampsyo/cs6120
'As I can attest from personal experience, having a #compiler leads to hubris: you start to consider source languages like a hungry person looks at a restaurant menu. "Wouldn't it be nice to ingest that?" That's what we say at restaurants, right, fellow humans?'
from the latest @wingo/log
http://wingolog.org/archives/2023/05/02/structure-and-interpretation-of-ark
It's an unfortunate meme IMO that tech Reddit is low-quality. You just have to find interesting subreddits!
I've updated my list for 2023.
https://notes.eatonphil.com/high-quality-subreddits-you-should-be-following.html
#Development #Reviews
The JavaScript ecosystem is delightfully weird · The many ways people aren’t writing JavaScript anymore https://ilo.im/12w0an
“The JavaScript you write not only isn’t the JavaScript you run, but under closer examination, it isn’t even JavaScript at all.” —Sam Ruby
_____
#WebDevelopment #WebDev #Frontend #Backend #EcmaScript #JavaScript #Ecosystem #Framework #Library #Compiler #Bundler
I've revisited my #ruby #compiler for the first time in probably a couple of years (with far longer since I wrote an article) and implemented type tagging for integers. Amazingly it took only a couple of hours, and it reduces the memory allocation pressure dramatically to the point where I'm now tempted to try to fix the remaining bugs preventing it from being fully self-hosted and doing some work on it again...
Wasmer 3.3 - Running WebAssembly 2.5x faster with JavascriptCore, https://wasmer.io/posts/wasmer-3.3-and-javascriptcore.
Wasmer 3.3 has a new backend which uses JavaScriptCore. Interesting approach. It’s the 4th backend after SinglePass, Cranelift and LLVM.
Wasmer is still a great project but its CEO is a danger. Reminder: https://mnt.io/2021/10/04/i-leave-wasmer/. Its toxic behaviour is still very present.
But the project is great. Thanks to the contributors and the brave employees working there!
It's alive!🎉
I've built a #transpiler in #Rust, compiled it to #WASM and integrated it into a #Vue app! :awesome:
It's called selecuery.✨
It can transpile X++ select statements into query expressions. If you think "X++" is a typo and you don't have any idea of what I'm talking about, don't worry.😄
Have a look at the video below.
This project is dear to my heart! ❤️ I've started it 2019 for learning #RustLang.
I think, I've been transpiled during this project as well.🤪
If you thought #TypeScript had a crazy #TypeSystem then you probably haven't heard of #Ezno yet (by kaleidawave):
Introducing Ezno:
https://kaleidawave.github.io/posts/introducing-ezno/
"In short, it is a #JavaScript #compiler featuring checking, #correctness and #performance for building full-stack (rendering on the client and server) websites."
Ezno in '23:
https://kaleidawave.github.io/posts/ezno-23/
This type system is craaaazyyy!🤪
Can't wait for 1.0! :awesome: 🚀
Inventing software that can "understand" context-dependent, ambiguous natural language, so that we can let it generate software with a context-free, unambiguous language. ➰
What can go wrong!? :awesome:
#AI #ArtificialIntelligence #ChatGPT #LLM #SALAMI #ContextFree #ProgrammingLanguage #Compiler
This #compiler for the #RosettaCode Virtual Machine assembly language can now target any of #ATS, #C, #Mercury, or #Scheme --
https://sourceforge.net/p/chemoelectric/rosettacode-contributions/ci/default/tree/vmc.dats
The Scheme code runs very fast in #ChezScheme, so-so in all else I have tried. I wonder how they do it. Maybe a lot of C code (instead of Scheme) in the runtime is part of it?
The generated Mercury is not so fast, but such is life with Mercury. It’s fastish, considering.
I decided to keep going and have added "vmc", the virtual machine compiler: https://sourceforge.net/p/chemoelectric/rosettacode-contributions/ci/default/tree/vmc.dats
No guarantee it works at any given time--though, if I am good, I can work with Mercurial branches. Right now it can compile to #ATS and to #C
#Compiler #FunctionalProgramming #ATSlang
The ATS it makes does tail calls. The C uses goto--many more goto than are needed, but optimizers might clean that out. The generated code is in continuation-passing style.
I went ahead and wrote a Virtual Machine to #ATS translator for the #RosettaCode #compiler task series:
Compiler/virtual machine interpreter - Rosetta Code https://rosettacode.org/wiki/Compiler/virtual_machine_interpreter#Compiler
The thing’s designed to make it relatively easy to handle many other languages. Languages with #goto should be easy to do, for instance: convert the program to one procedure with a lot of goto in it. And #Scheme could be done easily. I have ideas for #ObjectIcon and co-expressions.
@Edent it may not be closed any more but #SunMicrosystem's #C #Compiler was a closed-source thing #cc (now #Oracle Developer Studio so chances of being #opensource are slim! https://en.wikipedia.org/wiki/Oracle_Developer_Studio)
#Development #Overviews
The most popular build tools for front-end developers in 2023 · Key features and benefits of the top build tools for web development https://ilo.im/11g6au
_____
#WebDevelopment #WebDev #Frontend #Workflow #Collaboration #Automation #Tool #BuildTool #Compiler #Bundler #TaskRunner #JavaScript #TypeScript #Esbuild #Lerna #Nx #Parcel #Rollup #Rome #SWC #Turbo #Vite #Webpack
define-compiler-macro:
🧷 http://www.lispworks.com/documentation/lw50/CLHS/Body/m_define.htm#define-compiler-macro
inline / notinline:
🧷 http://www.lispworks.com/documentation/lw50/CLHS/Body/d_inline.htm#inline
Ooops, wrong language ... 🙈
🌺
🏷️ #CommonLisp #Lisp #Compiler #CompilerExtension #CompilerOptimization #Inlining
I've been contacted by someone who's looking for a mentor in the #compiler area. They're new to compiler design, but they do seem very interested and they've taken a sabbatical to learn about it.
Is someone around here interested to become their mentor?
Boosts appreciated 🙏
A wild #blog post appeared!
Did you know that #GCC just added Modula-2 and #Rust frontends to mainline? Come with me as I explore how well they work on #OpenBSD. (Spoiler: excellently out-of-the-box.)
As an added bonus, there are instructions in the blog post for how you can get your own GCC with Modula-2 and Rust on your own OpenBSD machine. Just a quick pkg_add away!
https://briancallahan.net/blog/20221219.html
#compiler #compilers #opensource #freesoftware #FOSS #FLOSS #OSS #FreeBSD #NetBSD #DragonFlyBSD #BSD #Unix #Linux
Been spending some time in my evenings hacking on a TypeScript library to make it easy to build Wasm modules directly in the browser without needing to muck about with the binary encoding.
Could be useful for defining little DSLs that get compiled to Wasm and run directly in the user's browser.
Nuke the C++ implementation of Zig from orbit using WASI, https://github.com/ziglang/zig/pull/13560.
> The idea is to use a small WASI binary as a stage1 kernel that is committed to source control and therefore can be used to build any commit from source. We provide a minimal WASI interpreter implementation that is built from C source, and then used to translate the Zig self-hosted compiler source code into C code.
#Compiler: Okay, so I’m gonna need you to add these numbers and then multiply these numbers.
CPU: You’re saying you want me to…load an effective address?
I never thought to actually look into "what the #compiler actually does" and just took it as one of the difficult things that I didn't really need to understand.
However, given that I'm now spending more time with #Rust I figured it might be useful to actually take a closer look.
This excellent video is focussed on the Borrow Checker but gives a deeper dive into the various stages the Rust compiler goes through when building code:
https://www.youtube.com/watch?v=HG1fppexRMA
I have more projects than I can count. Several involve writing a #compiler or #interpreter; some can be classified as #algorithmicart or #creativecoding; several are math- and game- related; and some miscellaneous ones.
Avid #reader of #fanfiction, #scifi and #fantasy. Amateur #writer of the same, plus #nonfiction and #microfiction.
Devilish :blobcateyes:
I thought "#compiler is allowed to do anything under #UndefinedBehavior" was a bit of a meme, but it's shocking to see it in practice.
Do is a static (local to this file) function pointer and it's only ever set in NeverCalled. So even though NeverCalled never actually gets executed, the compiler performs the set at compile time as an optimization and this is allowed because there is undefined behavior.
Another #projects entry
I wrote a compiler that converts Winamp visualizer presets to Web Assembly so they can run efficiently and safely in the browser. The fun part is that the compiler itself runs in the browser.
Playground: https://eel.capt.dev/
Blog post: https://jordaneldredge.com/blog/speeding-up-winamps-music-visualizer-with-webassembly/
Talk: https://www.youtube.com/watch?v=hZzjrgZb-mw
I have more projects than I can count, and way more than I can advance! There's not enough lifetime for them all.
One of my bigger projects is to implement a #compiler or #interpreter for a programming language. I started several, left behind incomplete.
Several other projects can be classified as "algorithmic art" or "creative coding"; when I started some of these, I didn't even know these names.