Having big-endian and little-endian data types is an interesting idea.
A CPU can similarly have BE/LE load/store instructions instead of having endianness either set in stone or as a global setting.
The reason I added it to myC was to support mac-parts in all my bootloaders
If you recall, I talked about how Allwinner decided to set the endianess of its SoCs to LE-only and how FriendlyArm & Co. decided to support uboot.
When I talked about the Neo and NeoAir board what I didn't mention, however, was that they REMOVED all endianess support for anything they deemed unnecessary, including mac-parts support!
Why? Because they thought MBR and GUID Partition Table (GPT) were sufficient partitioning systems.
- MBR is strongly LE because it was born on x86, which is only LE
- GPT... I've never understood why it has to be LE, but really, if you have a LE SoC... GPT is LE and has no other support
- mac-part was born on PowerMacs, which are BE... so they removed all the code!
I spent 4 hours/day for 3 days restoring everything in uboot and I'm glad it works because it's the only way I like to manage partitions!
Supporting mac-parts' endianess wasn't particularly complicated, as they're almost all uint32 and uint16, but then I also started writing the rb532 network driver from scratch, and here we have a problem: where the (MIPS32R") CPU is LE, many registers in the network SoC subgroup are BE... and it's a mix of uint8, uint16, and uint32...
So I kept that feature of the language because it really made the difference between risking bugs by forgetting to mention a macro that fixes endianess (like with C99 in uboot), and compiling the structs specifying the endianess and size of each field, and then letting the myC compiler do all the work!
So for instance, instead of just lw, sw, you can have lw.le, lw.be, sw.le, sw.be.
The R18K MIPS5++ SoC actually have a full bi-endian load/store implementation.
Nice tricks!
I haven't used it yet in myC's machine layer because I don't know if this feature is also present in other ISAs...
I don't know how much it's worth.
Sure I could add this feature to the ISA of my softcore toy, but the MIPS5++ is a completely dead and abandoned ISA prototype ...
... so
