This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to start reading gcc source code.


I have posted my message here:

http://sourceforge.net/forum/forum.php?thread_id=1185705&forum_id=7134

a resposer of the messate

START----------------------------------------------------------------
Hi people.



I will like to know how gcc select the compiler, I can trace a little in the code, also I need download flex and bison.


I will like to analise the output of the parsing, like I have understand for this moment the output is a AST, I will like to know how to detect when the AST is complete and let my analise it, and dont go more far than that.


Specifically I whant to identify:


structs/unions typedefs #defines (and sure almost all the preprocessing done) and functions

- Actually I can pass the switch -save-temps

And this one show me:

Functions and structures (I am running it in a .h file) I have renamed the file to extension .cpp, because when I pass the .h warn me about this...


Anyway, any help posible for undertand the AST, and for stop in this place for let me analise (or find), or put out the AST, if both are posible I will like to see the drawbacks...





----------------


Only a final thing, altought not necesary, I will like to know wich file are part of X pass, for example parsing, generation of AST, generation of RTL /(IR)?, optimizing, if you know about this, should be nice to share :D.

Have a nice dy or night.

END-----------------------------------------------------------------------


Anyway I havent specificated that I only whant specially for interfacing porpuoses , ie, I only whant to process headers files for get: structs/unions and typedefs, numeric definitions (#define XTHING 3) , after I can recognogize that, pheraphs but not necesary, get a list of functions in each file.



What I whant to do?


I use nasm (not much at all), but if something is left is have a good and easy to put up to date include files.

A struct like:

struct X{
  int a,b;
};
typedef struct X OTHER1, *OTHER2;

should be translated to:

struc X
.a resd
.b resd
endstruc

struc OTHER1
.a resd
.b resd
endstruc

%define OTHER2 dd (because the size of a pointer is double word)

Also I will like at less a little about handle unicode for choice between A or U

Pheraphs group all the names that are repeated and the only character that is diferent is the one, and the last should be A or U, then I can group them.

And do

%if UNICODE
%define MessageBox MessageBoxU
........
%else
%define MessageBox MessageBoxA
......
%endif




I also whant to be distributed, ie not in a single include file, I whant that for each h file referenced in a file, there would be one in file produced (for maintaing this a little modularitized).




And that is what I whant to do at the end, a importer of headers structs, unions, flag defines and prototypes of functions for use them with nasm, I in fact only whant the info, not whant to generate actually machine code, optimization, etc, only the declarations.






Like you see I dont whant to go more far (for the moment) than the AST if Im correct for get this working.




Hope you have understood ;).




Have a nice day or night,



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]