The method of GCC source code Analysis "Summary"

Source: Internet
Author: User

See gcc-1.40 for a while, 14 years or so to see a period of time, 15 years or so to see a period of time.

It is now possible to say that most of GCC's code is understood.

If you can quickly understand the principles, summarize the way I look at the code shortcut I listed the following several.

First, the GCC version is low, which is the premise of success, but also a shortcut.

Second, the analysis of the most basic hello.c file, just a function call, but enough.

Thirdly, the DEBUG_RTX () function and the Debug_tree () function are found. These two functions can be said to be the only two keys to understand GCC!

Four, the idea is correct, expand_call () How to produce all kinds of rtx? The idea is to use the DEBUG_RTX () function.

Expand_call () The parameter of the function is how to get the tree?

How are the parameters of the expand_expr_stmt () function obtained?

Image can be said that the formation of the tree can be seen as a model of the baby ,

The most basic small set of dolls first formed, and then various operations of the tree function layer of the set up,

The function of the Print_node () function of our debug_tree () function is to separate the set of dolls!

The general idea is: How to get from the source code to the tree, above can say how from the tree to the RTX!

Concerned about how the tree that is related to printf is formed? How does the tree that is related to "hello,world!\n" form?

Five, the principle of grammatical analysis bison is very familiar.

Judging whether a person understands GCC can be divided into 3 levels:

Beginner: hello.c to Hello.I to Hello.s to hello.o to A.out

Intermediate: gcc frontend, from source code to RTL intermediate language, back end from RTL to assembly language.

Advanced: C File source code to Tree,tree to Rtx,rtx to assembly language.

The method of GCC source code Analysis "Summary"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.