2 ms·
int a() { return sizeof(void *); } Obviously a trivial example, but it's illustrative: the front-end compiler knows a bunch of things about your target and bak
by bodyfour 13y ago
int a() { return sizeof(void *); }
Obviously a trivial example, but it's illustrative: the front-end compiler knows a bunch of things about your target and bakes that information into the IL. If you took IL generated by the compiler with "-arch i386" and then compiled the IL using "-arch x86_64" it's quite possible to get a non-working executable.
It's possible to carefully write IL that will work on multiple platforms as done in this blog post, but I'm not sure how useful that really is. You're still giving up the exact control that assembly gives you, so I don't know how much better you'd get than clang-produced IR. In other words, if you want "portable assembly language" use C.
Still, its an interesting blog post. It's good to show people how the compiler works behind the curtain.