Andrew MacLeod

Recent Posts

An upside-down approach to GCC optimizations

An upside-down approach to GCC optimizations

Many traditional optimizations in the compiler work from a top-down approach, which starts at the beginning of the program and works toward the bottom. This allows the optimization to see the definition of something before any uses of it, which simplifies most evaluations. It’s also the natural way we process things. In this article, we’ll look at a different approach and a new project called Ranger, which attempts to turn this problem upside down.

Continue reading “An upside-down approach to GCC optimizations”

Share
Curing a legacy header-ache.

Curing a legacy header-ache.

To the best of my knowledge the Gnu Compiler Collection (GCC) never enforced a formal organization for header files. They were created as desired to export elements of a source file, and over time became convenient places to put lots of miscellaneous things. No one seemed to think we needed to dictate what they should contain, nor how they should be included.  For the most part it never really mattered… A source file included whatever list of headers it required to compile, and reorganization was rare.

So why does it matter now? The header file “tree.h” defines the most ubiquitous data structure in GCC… the tree_node. Most core objects are a tree_node of some sort… identifiers, expressions, types, variables, lists… you name it, it’s rooted in a tree_node.  As part of a project to help modernize the code base, I wanted to split this tree_node so that types became a new type_node. Then I wanted to create a type_node for the compiler’s optimizers that did not share the implementation used by the language parsers. I needed to be able to pull a few of these data structures apart.

I also knew the header files were quite unorganized, and when I went to prototype my changes I discovered the terrible truth… There were so many unrelated header files intertwined with tree.h that it was virtually impossible to separate anything, let alone the significant parts I wanted. I could feel the header-ache beginning…

Continue reading “Curing a legacy header-ache.”

Share