llvm-mos / llvm-mos-sdk

SDK for developing with the llvm-mos compiler
https://www.llvm-mos.org
Other
266 stars 53 forks source link

Macros to set SDK linker script symbols #193

Closed mysterymath closed 11 months ago

mysterymath commented 12 months ago

Commonly symbol values are used to configure the linker scripts for a given platform. This is particularly widespread in the NES targets, since a given mapper target can usually support a wide variety of actual boards, each with slightly different physical hardware configurations. The usual syntax for this is to define the symbols either in an assembly file or in C, but the syntax for this is a little obtuse. We can make this easier by providing C preprocessor macros to set these values using module-level inline ASM. This was done in #191 for UNROM-512, but this issue is to generalize the pattern to the other targets.

asiekierka commented 12 months ago

nit: The PC Engine (pce) target is a better - more complex/powerful - example of this macro setup in action.

asiekierka commented 12 months ago

One question, though: how far should we go? Should we allow defining as many INES values from C as possible, not unlike the PC Engine target's approach to banking? (Think MAPPER_PRG_ROM_KB(128); and such.) Or should this just be about board configuration, like UNROM-512 currently?

mysterymath commented 11 months ago

One question, though: how far should we go? Should we allow defining as many INES values from C as possible, not unlike the PC Engine target's approach to banking? (Think MAPPER_PRG_ROM_KB(128); and such.) Or should this just be about board configuration, like UNROM-512 currently?

Honestly, I'd go all the way; the syntax for this was always obtuse in C, so providing a clear option would help pure C projects more than the enough to overcome the maintenance overhead. Might be worth considering basing this off a generic "symbol setting" macro we could maintain in common...

asiekierka commented 11 months ago

I don't think a generic "symbol setting" macro would save much, compared to the added complexity of nested C macros.

It could be a good idea to have a general ines.h, though.