How do languages in GCC map to hardware? Could I, for instance, write in Rust and compile for GCC-MSP430, or a 68k architecture?
Rust has support for many embedded targets. I can personally vouch for the MSP430. Rust compiles down to an intermediate language which can then use the same compilers and linkers as C. For instance when compiling Rust for the MSP430, GCC-MSP430 is actually part of the toolchain.
Thanks. What is this intermediate language you speak of? That sounds curious if it could be approached casually.
Probably a silly question, but why isn’t this intermediate representation of LLVM created in hardware, or is it?
The IR is designed to be easy to optimize, not easy for a real machine to execute. Among other things, it assumes it has access to an infinite number of registers so that it never needs to (and in fact is not allowed to) write a new value into a previously used register.
I don’t understand your question.
I think both gcc and clang are roughly build around the C memory model.
If you want to interface with hardware you probably do volatile reads and writes to specific memory addresses.
You should be able to compile for most gcc supported platforms.LLVM compiles C, C++, Rust, etc. into an intermediate language and then compiles that language into assembly for the target platform. I’m not sure if gcc uses an intermediate language or not. Either way, the compiler can compile any of its supported languages into any of its target platforms. For Rust, you will probably need to look into “no_std” for systems that don’t have a typical libc setup.