Chapter 3: GCC Anatomy
When writing code, people don´t
usually bother to think about the compiler or whatever lies inside, but instead
just codes. However, everything that happens inside a compiler (for example,
GCC) is interesting. Conformed of three main parts (which are Front End, Middle
End, and Back End) the compiler aims towards performance thanks to everything
that those parts make. The Front End, which is language specific, outputs to
the front end, which is considered like a “neutral” zone, and finally the Back
End works to produce specific architecture code.
Morgan Deters explains us the
portability of GCC in the podcast; is one of the most widely used, for example,
on Windows or Mac OS. It accepts many languages, such as C, C++, Java, Fortran,
etc. The main output from the compiler is an object code for the aimed
platform.
The compiler works with a simple
input, a plain text, and the compiler has to understand what the plain text has
and what everything inside it means, usually by parsing it into a tree-like
representation. Whenever a variable is declared in the text file, the compiler
should assign it to a variable and know how and when to access it. The compiler
has to recognize the semantics of the language. Then, with all this
information, produce an internal representation for the compiler to understand
it easier. At the end, compiler programmers take a look at small details for
low level optimizations, where simple instructions are refactored to either
compacted versions or faster instructions.
Taking all this into
consideration, I hope I can apply it to my course and the project we are
currently working on. The part in semantic and lexical analysis sounds really
interesting and I hope I can deepen that knowledge either by reading more about
it or applying it practically (or why not, both).
References:
SER (2007) Episode 61: Internals
of GCC, available on: http://www.se-radio.net/2007/07/episode-61-internals-of-gcc/
Comments
Post a Comment