On 4/26/2019 5:04 PM, Jesse Thompson wrote:
Ultimately what I am trying to research is how to begin building a simple compilation system of my own, so how do the *makers* of compilers deal with these differences in calling convention?
They make parts of the compilers conditional on the overall platform. For example, if a compiler is written in C / C++, they use #define and #if tests, and may include different modules in a build, etc. They also try to code various algorithms, such a register allocation, to be parameterized by a description of how things work on a given platform. There are whole swaths that are essentially target independent, especially those having to do with higher level optimizations. However, even there, platform differences may lead to different parameter settings (e.g., default number of times to unroll a loop) or strategies (presence / absence of vector units and of predicated instructions (as on the ARM) affect how you want to generate even the high-level target-independent code). In the case that you are talking about, most of the code generation and optimization strategies are the same -- there are just some fine points different about calling sequences, register usage conventions, etc. I think those are mostly addressed by the kind of parameterization-by-descriptions (or by #defines) that I have described. You may still see somewhat different code from different compilers, even for the same platform, simply because the different designers chose different base code sequences - which may be equivalent. For example, to move a constant into a register, add-immediate (adding to zero) and or-immediate (again, ORing with zero) give the same result for many arguments, to the choice is arbitrary. One can come up with many such examples. Supporting multiple target instruction sets, or even the range of models of the x86 line, requires some amount of platform-specific work, of course, and lot of attention to how to build components that are either independent of the ISA or retargetable in some way. Regards - Eliot Moss -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple