130 karma · joined Feb 19, 2020 (6y ago) · 44 submissions
comment 8mo ago · link · parent
comment 8mo ago · link · parent
As for Claude, honestly, as a partner. We bounced ideas off each other, while I provided overall direction for the project. It was finishing up a design I had started and aborted last year, but we did build this from scratch. I had some good ideas, Claude had some good ideas, but Claude did almost all of the actual grunt work. Looking back, Claude's tactical decisionmaking was often better than mine, but my strategic decisionmaking was far superior. I would also occasionally have to interject when it was "freaking out" and offer a sounding board to help it solve whatever problem it was working through.
comment 9mo ago · link · parent
Best I could do was an A/B comparison on a modern process: a clean Verilog model of RISCY-V02, and a clean Verilog model of a 6502, both run through a modern synthesis process for TinyTapeout. Same slosh, inoptimality, and behavior. So, this is a static CMOS design, like the 65C02, on a modernish process node. That being said, the 65C02 had around 11K transistors, so we're not too far off.
This establishes horseshoes and hand grenades plausibility, but basically nothing else. But, it's also a pretty nifty CPU design if I do say so myself!
5.
Show HN: RISCY-V02: A 16-bit 2-cycle RISC-V-ish CPU in the 6502 footprint(github.com ↗)
7 points · by mysterymath · 9mo ago · 4 comments
comment 1y ago · link · parent
Also, maintaining a fork is difficult, but doable. I work on LLVM a ton, so it's pretty easy for it to fold in to my work week-to-week. And quite surprisingly, I used AI to help last time, and it actually helped quite a lot!
comment 1y ago · link · parent
comment 2y ago · link · parent
There's a lot of discussion about this; practically changing the execution character set isn't trivial, and it's not necessarily even a desirable feature. Even with full -fexec-charset support, it still makes sense to provide compile-time translation from Unicode to target strings. For example, Commodore PETSCII makes vastly more sense as an execution character set than a source character set.
comment 2y ago · link · parent
comment 2y ago · link · parent
comment 2y ago · link · parent
comment 2y ago · link · parent
- Soundness of their semantics at a conceptual level
- Correct implementation of the semantics in rustc (in Rust)
- Correct translation of those semantics to LLVM IR targeting OS syscalls in rustc (in Rust)
- Correct translation of LLVM IR to native code in LLVM (written in C++)
- Correct implementation of OS syscalls (typically in C)
Python's safety guarantees typically depend on:
- Soundness of their semantics at a conceptual level
- Correct implementation of the semantics in CPython (in C)
- Correct translation of C to LLVM IR targeting OS syscalls in Clang (in C++)
- Correct translation of LLVM IR to native code in LLVM (written in C++)
- Correct implementation of OS syscalls (typically in C)
Both are typically contingent on correct implementation of a huge swath of C/C++ and Rust code. Even if the entire stack were written in Rust, it still wouldn't be sufficient to guarantee memory safety, since bugs anywhere in the stack could introduce memory unsafety into compiled Rust code.
Rust's guarantees come entirely at the first two layers of the stack: If the semantics are sound, and the semantics are implemented correctly in rustc, then the generated LLVM IR (treated abstractly) has memory safety. Python has similar guarantees: if its semantics are sound, and the semantics are implemented correctly in CPython compiler/interpreter, then the resulting execution of the interpreter has memory safety.
comment 2y ago · link · parent
The overall complaint is one of structure; prose flows from one point to another without my being able to build a model of where the argument is going, where it came from, what's an essential detail, what's an interesting aside, etc.
It's a common fault in technical writing, maybe the most common in my experience. IMO, well-organized writing is a "parasocial" endeavor: there's a bit of mind-reading involved. One needs to get inside the head of their audience and try to predict their mental states. Why did they click on this? What questions do they have? What preconceptions would cause them to immediately close out? How can you answer those concerns as quickly as possible, and lead gradually into a more nuanced discussion (if they so desire). If they're not likely to desire it, can you convince them to?
The answers to these kinds of questions about a brand new reader should suggest a thesis. Similar reasoning about a reader who has read the thesis should suggest the content of an abstract. And so forth, for an introduction, a guide to contents, etc. After that, presuming some skimming helps too.
comment 2y ago · link · parent
In college, I successfully took apart the arguments of the peers who tried to dissuade me from my beliefs. They weren't good arguments; they had no idea why what they believed was true, but I did. This reinforced my views more than anything.
But, this earnest searching for the truth also led me to take philosophy of science and religion courses at my university, and that was the first time that I actually learned the mechanics of what went into the scientific method, and particularly why that method tends to achieve its goal of arriving at the truth. My entire primary and secondary education had never contained an discussion of this, nor had anyone I'd ever spoken to known it.
I also came across the talk.origins pages (https://www.talkorigins.org/faqs/faq-welcome.html), which contained the first full exposition I'd seen of not just the theory of evolution, but also the tremendous host of failed falsification opportunities that support it. I was pulled into a more correct view of the world kicking and screaming, by the same forces that had kept me away from it for my entire life.
I can't speak to how common my experiences are, but I'm endlessly grateful to those who didn't presume that there wasn't anyone like me out there. Admittedly I do have a stick up my butt about this, since it's a refrain I hear often. But I suspect that many of the flat-earthers out there are budding scientists in disguise, poorly served by their environment, and waiting to be freed.
comment 2y ago · link · parent
https://fabiensanglard.net/duke3d/build_engine_internals.php
comment 3y ago · link · parent
The old semantics also matched GCC's actual behavior; when we brought this up in a GCC issue, those present decided that GCC's behavior was wrong, but the appropriate maintainer couldn't be reached for a final say. The issue is still hung like that.
There were also a few other folks trying to do the same kinds of whole-program call graph analysis this enables, IIRC for GPU purposes. So, there was a lot of conflicting opinions about how this should work, a lot of uncertainty, all the recipe for a big long endless thread.
EDIT: This is of course my extremely biased take on the proceedings. This was also the first and only "open source kerfluffle" I've so far been direct party to; I've seen these come and go on mailing lists before, but I was surprised how different it felt to actually be inside one.
comment 3y ago · link · parent
Now that this has come up again as the stock reason "you can't do C well on the 6502", replacing the stack, the zero page, and the register set, I'm probably going to reprioritize it and put the register allocator on pause.
comment 3y ago · link · parent
The "Greedy register allocator" in LLVM is a just finely tuned priority allocator with nice live-range splitting. It works great for zero page cache locations, but it's just not tuned very well for tight register classes like those involving the processor's three architectural registers. I've half a mind to implement Hack's SSA-based register allocator in LLVM to use on A, X, and Y; this would clean up the oodles of spurious copies LLVM-MOS spits out in the worst cases.
comment 4y ago · link · parent
I love compilers, and I work on LLVM full time at my day job. I love bringing modern tooling and techniques to an older environment where they very much don't belong; the juxtaposition of the two is very satisfying to me.
comment 4y ago · link · parent
The prevalence of self-modifying code also heavily depends on what community of 6502 developers you're part of. It's relatively niche on platforms where most code is in ROM, e.g. most game consoles. For example, the NES only has 2KiB of RAM, but can support upwards of 512KiB of ROM, so it's downright wasteful to place code in RAM.
As for 2 and 3, LLVM-MOS lifts local variables to global memory or the zero page wherever possible, and is able to use function aliasing information to allow the globalised versions of local variables in different functions to share the same memory.
comment 4y ago · link · parent
Still, I'm not ruling it out, it just never seems to be very high on the TODO list. I've also started to do more work upstream whenever the situation calls for it; quite a few of the improvements we've done to LLVM do generalize to other targets, so much of that can and should be upstreamed indepenently.
comment 4y ago · link · parent
The only real 6502-specific C caveat left for llvm-mos is that you should strongly prefer structs of arrays to arrays of structs; and that's not even that 6502-specific. Otherwise, standard C gives fairly tight assembly.
That being said, every couple hundred lines of generated assembly for any reasonably-sized C program will contain at least one WTF, from a human point of view. Removing those WTFs one at a time is the long tail of a compiler engineer. Still, I'm not going anywhere!
29.
EuroLLVM 2022: LLVM-MOS 6502 Back end: Having a Blast in the Past [video](youtube.com ↗)
5 points · by mysterymath · 4y ago · 1 comment