Internals of GCC
I never stopped to look at GCC as something so robust and complete,
and definitely helped me understand and map better how does a compiler work. I
also think that Morgan Deters and Arno made quite an awesome job explaining how
GCC works in easy simple terms and guiding the conversation.
It had not come to my mind the structure needed by this
compiler to be used in order to be able to interpret several languages in
several architectures was so similar to several apps and programs we develop
nowadays with a back end a middle and a front end. It is how it was explained
in past articles, to have that flexibility you need to add these layers, to
make it more convenient. The power of GCC I think that stands on the idea of portability
that they managed to achieve.
All the work done to make it this portable its out of my
mind. I consider that an essential step to achieve this portability resides in
the way the front ends process the code in order to adapt certain features
unique to the language and resolve them in the tree representation, so the tree
can be handled off to the middle end. Another pretty interesting feature is how
the compiler and passes to the tree are entitled to change features of your
program to make it more efficient or remove code that is not used without
changing the code behavior, like a refactoring.
An aspect I do not conceive is how they came up with the
mapping of limitless registers that the programs believe to have during the middle
end passes and then when they are converted to the low level representation
manage to map it to the correct number and order of registers without the program
crashing. Deters mentions that the optimizations that the compiler is allowed
to make, help this process but I quite not grasp the idea of how this could be
implemented. I hope by the end of the course this process does not seem
something so whimsical to me and to be able to understand it more clearly.
Comentarios
Publicar un comentario