On 02/15/2017 06:59 PM, yin liu wrote:
Hi all, If I understand correctly, the compilation of cc1 is based on the concept of function. i.e. The first function is parsed and its AST is built. Then, the function is transformed into RTL and finally it is translated into assembler code. Once the assembler code is produced for the first function, the second function is parsed and the same path is followed for generating the assembler source. My question is, how about the cc1plus? Since the C++ use class as the unit of source code, would it also based on the function?
Yes, the only difference between the two programs is that one uses the C front end and the other the C++ front end. Each of these translates either C or C++ code into an AST representation of a program a function at a time. The AST is then worked on by the language-independent middle-end to generate the GIMPLE representation of the program, still one function at a time. The GIMPLE representation is then transformed and optimized, one function at a time (with inlining integrating some functions into others), and then eventually translated into the RTL. Classes don't change any of this. They are basically just a scoping mechanism. Martin