Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do C/C++ compilers work?

After over a decade of C/C++ coding, I've noticed the following pattern - very good programmers tend to have detailed knowledge of the innards of the compiler.

I'm a reasonably good programmer, and I have an ad-hoc collection of compiler "superstitions", so I'd like to reboot my knowledge and start from the basics.

Can anyone recommend links to online resources or favorite books? I'm particularly interested in C/C++ compiling, optimization, GCC and LLVM.

like image 309
Justicle Avatar asked Jul 06 '09 05:07

Justicle


2 Answers

Start with the dragon book....(stress more on code optimization and code generation)

Go onto write a toy compiler for an educational programming language like Decaf or Cool.., you may use parser generators (lex and yacc) for your front end(to make life easier and focus on more imp stuff)....

Then read gcc internals book along with browsing gcc source code.

like image 136
sourabh jaiswal Avatar answered Sep 28 '22 02:09

sourabh jaiswal


  • GCC Internals Manual.
  • CPP Internals Manual
  • LLVM Documentation
like image 41
Brandon E Taylor Avatar answered Sep 28 '22 03:09

Brandon E Taylor