r/Compilers • • Oct 13 '26

Do compilers necessarily need to generate assembly from IR before producing object code?

I am new to the world of compilers so pardon my ignorance. Is there a need for compilers to generate assembly or can they just skip and direcly produce object code from IR?

22 Upvotes

25 comments sorted by

View all comments

21

u/GoblinsGym Oct 13 '26

Assembly code would be an extra step. No need to use a text representation, normally a compiler will just generate binary code directly.

18

u/dacydergoth Oct 13 '26

Assembly output is often useful, even if compilers don't emit it as standard they almost all support that for debugging and other reasons

3

u/SetKaung Oct 13 '26 edited Oct 13 '26

I might have phrased it wrong a bit here. I mean in the process, is it necessary to generate or emit assembly in anyway, not just "doesn't write to a file" but like skip it entirely? Does it have some benefit in generating assembly internally even though it is not written to a file?

5

u/GoblinsGym Oct 13 '26

There is no need to generate text form internally. Typically there will be some functions to emit various instructions.