by reidacdc · 5y ago · 0 comments
There are lots of practical issues, obviously, but the dream was that the LLVM intermediate representation would take the role of C in the author's description, with the major difference that nobody has to actually hand-write anything in it.
So from that point of view, isn't the robust, long-term solution to this and related issues to build LLVM back-ends for all the "weird" architectures?
I'm surprised it's not mentioned as a possible way forward.
There is no "compile to LLVM once, run anywhere with an LLVM backend". If your C frontend doesn't know that you want to compile for System/390, it will not be able to generate LLVM code that you can expect to turn into a working System/390 binary.
That would be enough to get it good on all of x86/ARM/RISCs I think, but to go further and support Alpha or VLIW machines well you'd need to include a lot of metadata in the IR to provide aliasing info, a problem I don't think anyone has taken seriously.
(Everyone always says "this language is good enough as long as you're not writing video codecs or something!". Well, I am writing video codecs or something.)
I think a reasonable portable bytecode would have stricter memory rules than C and so would be harder to optimize like this.
So that's why I proposed having variants, but you could also invent some abstract vector operations and then scalarize them if they're not available. That's how shader languages do it.