lunes, 7 de septiembre de 2020

Internals of GCC

 

What makes compilers interesting? This is how podcast begins, in short words they are interesting because they make programs run smoothly and fast in your system. So, we already know what a compiler does, they translate a source file and it will produce a representation in order to make an object code for the desire language.

There is a new “gnu compiler collection” that is very useful because while it works in many OS it is very flexible and portable for different systems and languages, which makes it reliable to may programmers out there. It is composed of a language frontend that can be swapped for whatever you need, a middle end that manipulates the source and a backend that produces specific architecture.

The language frontend makes sure to understand the lexical and semantic parts of the language and checks for mistakes. One thing that I think I understood form the podcast is that this compiler tries to simplify as much as possible in order to be able to be as flexible and portable. The idea is to be able to boot it very simply with minimal set. This is why the front end is mostly written in C. I really liked how the host described the frontend “The frontend is basically a black box that take the input a return a tree”. Then we have the middle end here the program tries to fine the most optimal way to run through the architectural tree, it creates an equivalent tree representation from high level to low level such as the RTL which is a linear sequel of codes that are very simple that will be translated to the assembly language so that many low level optimizations can be made.  Something interesting that I never thought about is that the actual optimizations are easier to do while doing the registers and then tried to store the most optimal trees so that they don’t overlap and overworks the memory. In the backend according to the machine description the GCC makes like a template that will work with the machine and the code.  

At this point the basic architectural program that compare to the original source program is done and the driver program to run it. So, everything is done automatically. How nice I wish all programs were as friendly.

No hay comentarios:

Publicar un comentario

Lin Clark on WebAssembly

  This time we got to listen to a podcast for our Compiler Design Class. We listen to Lin Clark, a programmer that makes cartoons to simpl...