| 7 | | In the old code generator, most of the pipeline refers to variables by name. In fact, we have a phase ordering problem: no compiler phase can name a stack slot until stack layout has been fixed. But stack layout can only be fixed at the end of the pipeline. The consequence of this approach is that we have to provide special treatment for code that must refer to stack slots (e.g. parameter passing in calling conventions, or spills and reloads). In particular, we defined special instructions for !CopyIn and !CopyOut of function arguments, which implicitly stand for an adjustment to the stack pointer and some parallel assignments to the function parameters or return results. Every stage of the back end must cope with these special cases. |
| | 7 | In the old code generator, most of the pipeline refers to variables by name. In fact, we have a phase ordering problem: no compiler phase can name a stack slot until stack layout has been fixed. But stack layout can only be fixed at the end of the pipeline. The consequence of this approach is that we have to provide special treatment for code that must refer to stack slots (e.g. parameter passing in calling conventions, or spills and reloads). In particular, we defined special instructions for !CopyIn and !CopyOut of function arguments, which implicitly stand for an adjustment to the stack pointer and some parallel assignments to the function parameters or return results. |
| | 8 | |
| | 9 | For example, we compile a function call |
| | 10 | |
| | 11 | {{{ |
| | 12 | x, y = f(a, b, c) |
| | 13 | }}} |
| | 14 | |
| | 15 | into the following C--: |
| | 16 | |
| | 17 | {{{ |
| | 18 | CopyOut(a, b, c); |
| | 19 | call f returns to k; |
| | 20 | k: |
| | 21 | CopyIn (x, y) |
| | 22 | }}} |
| | 23 | |
| | 24 | Every stage of the back end must cope with the !CopyIn and !CopyOut pseudoinstructions. |