3 ms·
LLVM converts your input language into the intermediate representation (LLVM IR) with a frontend. Then, a backend takes IR and spits out code for an ISA. IR is
by HappyTypist 11y ago
LLVM converts your input language into the intermediate representation (LLVM IR) with a frontend. Then, a backend takes IR and spits out code for an ISA.
IR is ISA agnostic. Compiling the same code to x86 and ARM will have the same IR, it's only the backend step that's different. Thus, of course you can take IR "meant for ARM" and compile it to "x86" and get full optimisation. The IR isn't meant for ARM anyway, IR is just IR.
- gchadwick 11y ago> Compiling the same code to x86 and ARM will have the same IR This is incorrect. Clang has specific code paths (producing different IR) for x86 and ARM, specifically around calling conventions but I'm sure there are more.
- riscy 11y ago> IR is ISA agnostic It's absolutely ISA specific and this target independence pipe dream keeps being repeated on HN. Just search the LLVM documentation for "target specific."