The tree-flow.h restructuring now brings us to the larger question of exactly how we want includes organized. All the remaining includes in tree-ssa.h are required by numerous other .c files. The actual number of .c files which will need to #include any given file is:

(roughly calculated by the number of .o file which don't compile when removed from tree-ssa.h)
19  bitmap.h
77  gimple.h
61  gimple-ssa.h
17   cgraph.h
72  tree-cfg.h
46  tree-phinodes.h
69  ssa-iterators.h
82  tree-ssanames.h
38  tree-ssa-loop.h
37  tree-into-ssa.h
35  tree-dfa.h


The question is... Do we allow a .h file like this to be an aggregator, meaning a file can just include tree-ssa.h and get all this, or do we push it all down to the .c file, and actually include what each one needs. Or do we pick a specific subset for tree-ssa.h...

So far I've removed the less commonly included files, ie, less than 10 or so .c files need it. That also gave me the opportunity to analyze and restructure the exports in those files a bit. That is a much larger job on these commonly included files, so I don't plan to do that sort of analysis. Yet anyway.

Current practice is that every .c file should start with
#include "config.h"
#include "system.h"
#include "coretypes.h"

I also think every .c file should also then have
#include "tree.h"
#include "gimple.h"    // Only assuming it is a gimple based file

These are basic implementation files and I think it's reasonable for each .c file to include them as a basis if they are to be used.

Beyond that I am a bit torn... It seems reasonable to have module aggregators like tree-ssa.h which a .c file can include can get all the "stuff" an ssa pass will commonly require. I can also see the argument for the "include what you use" paradigm.

At a minimum, I do think that if a .h file *requires* another .h file to compile, that it should include it. ie, if gimple-ssa.h is included, it wont compile unless tree-ssa-operands.h has already been included, so that seems reasonable to include directly in gimple-ssa.h. Otherwise ones needs to add the file, compile, and then figure out what other file you need. That seems silly to me.

Perhaps using that as the guideline, we should just push all includes down into the .c files? I think I favour that approach.

What are other thoughts?

Andrew

Reply via email to