Aviv · @springogeek
108 followers · 557 posts · Server mastodon.gamedev.place

Enthusiasm on has been fading somewhat over the past couple weeks (plus I've been busy with some life events).

Code generation is definitely the hardest part to do.

#fanglang #PLdev

Last updated 2 years ago

Aviv · @springogeek
105 followers · 532 posts · Server mastodon.gamedev.place

Puzzling my way through code generation, one step at a time.

For the minimal language subset I'm putting together, I've got some basic live range calculation going on, and I'm hoping to use that for register allocation.and spilling.

It's tricky, because the allocator needs to handle a fixed accumulator register, and also the constraints around 8 and 16-bit data registers and operations.

I'm a bit daunted by it all, really :(

#fanglang

Last updated 2 years ago

Aviv · @springogeek
105 followers · 532 posts · Server mastodon.gamedev.place

It's early days, but I have simple arithmetic and control flow generating TAC in now.

I want to solve the issue of going from TAC to assembly now, before I go too deep on supporting Fang's featureset, but that has some tough problems involved in it.

I'd like to start generating game boy ROMs from it, although that will make testing harder as I can't automate it, but it'd be cool!

#fanglang

Last updated 2 years ago

Aviv · @springogeek
105 followers · 526 posts · Server mastodon.gamedev.place

After a little break, I've been making some progress generating TAC code for

The point of this is taking the AST and making it into a linear representation, and this can then be used for certain optimisations, before emitting assembly code.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
103 followers · 512 posts · Server mastodon.gamedev.place

Progress on slowed down quite a bit, but I'm slowly chipping away at the TAC/SSA work. I'll get there eventually.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
101 followers · 507 posts · Server mastodon.gamedev.place

Been a bit unfocused the last couple days, so not much to say on at the moment. Making a little progress on TAC encoding, but I stumbled into a couple bugs with my type checker/static resolution pass, and I should really fix that first.

It tries to do all the static resolution in two passes, and that was working fine, but then I introduced banking and that added some complexity, so now I need to reconsider how things work.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
101 followers · 500 posts · Server mastodon.gamedev.place

Been sorta dilly-dallying on implementing the TAC/SSA system for , finally broke ground on it today. Definitely going to take me a while, but starting is better than not

#fanglang

Last updated 2 years ago

Aviv · @springogeek
99 followers · 498 posts · Server mastodon.gamedev.place

So... went from having no unions to having tagged unions with type-matching syntax! Pretty cool, although I'm worried it'll have a performance impact

#fanglang

Last updated 2 years ago

Aviv · @springogeek
99 followers · 498 posts · Server mastodon.gamedev.place

It's not battle-tested yet, but has unions now! I need to decide on how to initialise the data in a union, at the moment you have to do it manually, which is asymmetric when compared to records and arrays.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
98 followers · 477 posts · Server mastodon.gamedev.place

Alrighty, memory leaks mostly squashed, ISR syntax supported, banking handled.

Time to puzzle out how to convert my AST into a linear representation for future optimizations, and then game boy output.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
98 followers · 474 posts · Server mastodon.gamedev.place

Been rooting out some memory leaks in the compiler today. Got a bunch of them, but Valgrind is picking up one in the hashmap library I'm using, and I use it almost everywhere, so I really don't want to have to change it out. Frustrating.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
96 followers · 463 posts · Server mastodon.gamedev.place

Not a lot of time for today, when you try to access something in the wrong bank, we can now provide a more informative error message.

I realised today that the scanner and parser I have written (based on the crafting interpreters design) doesn't allow keywords to be used in identifiers, which does mean I have to be careful adding new keywords.

I wanted to use "section" as the keyword, but that seemed like a more common and reasonable thing to want as an identifier, so "bank" stays.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
96 followers · 457 posts · Server mastodon.gamedev.place

Good day for : String interning is all working now. Makes everything so much easier to work with, and strings are easier to pass around when you don't have to.

I also made a good amount of progress on the banking semantics, so I think that's all ready to go.

Back to testing and trying to break things for a bit so I can put in better error messages.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
96 followers · 453 posts · Server mastodon.gamedev.place

Compiling the compiler on Linux has been interesting. For some reason GCC has problems with the data structure library I'm using for dynamic arrays and hash maps, so I have to use clang.

And then I forgot that valgrind on Linux is actually useful, so it helpfully pointed out I've done basically no memory management and I am leaking everywhere xD

#fanglang

Last updated 2 years ago

Aviv · @springogeek
96 followers · 451 posts · Server mastodon.gamedev.place

Types in can now be namespaced within a particular module, which is pretty neat.

Now to implement bank scoping, which I'll need for Game Boy and NES. This will be tricky because it up-ends Fang's existing rules.

Fang has been lexically scoped. Deeper scopes see shallow scope. Banking needs to be the reverse. Unbanked code can see all banks, but each bank only sees its own and the unbanked scope (this was suggested by evie github.com/eievui5 on the gbdev discord, thank you!!)

#fanglang

Last updated 2 years ago

Aviv · @springogeek
95 followers · 441 posts · Server mastodon.gamedev.place

I started a really gnarly rewrite of 's type table today, so everything is broken again.

But it should allow for a couple things going forward: types scoped to modules, and the possibility of union types in the future.

I also did some initial research and consultation into how Fang can best support the Game Boy, so I'll be making more changes later for sure.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
95 followers · 439 posts · Server mastodon.gamedev.place

If I want to target lower end systems (GB and NES), the implementation needs to handle bank-switching. I'm not exactly sure that it's possible to defer the handling of that to the compiler, but it'd be nice if it could be.

Adapting the language has other challenges too, so I may need to redesign the semantics to fit somewhat.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
94 followers · 431 posts · Server mastodon.gamedev.place

won't have any heap-allocation support, but I'm stuck on how record types could work across modules.

It can't do what C does, where a composite type can be opaque, because the origin of the type can do the allocation to heap and return a pointer. The type declaration could be extracted into a shared header, but then there's no privacy on the implementation details, even if you enforce a public interface. There's just no way to convey the struct size for compile time otherwise

#fanglang

Last updated 2 years ago

Aviv · @springogeek
94 followers · 428 posts · Server mastodon.gamedev.place

Okay! I'm about 90% sure that my compiler is MVP-feature complete now (I'm going to write a blog-post about what that means later in time)

There's definitely some rough edges, lurking bugs, uncaught errors, poorly designed error messages and more to sort out, but, on ARM64 at least, I have all the constructs I need to write reasonable programs.

The last bit I solved today was global record initialization, returning arrays and records from functions, copying mem-objects and nesting.

#fanglang

Last updated 2 years ago

Aviv · @springogeek
94 followers · 427 posts · Server mastodon.gamedev.place

I'm so bad at the "let's keep my blog updated" thing. Every time I think about something to write, I slide back to working on instead, so the "debt" of feature updates there just grows.

#fanglang

Last updated 2 years ago