Changes between Version 63 and Version 64 of Commentary/Compiler/StackAreas


Ignore:
Timestamp:
Jul 2, 2008 11:43:59 AM (6 years ago)
Author:
dias
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/StackAreas

    v63 v64  
    1111For each stack slot, we introduce a new name, then treat the name as the addressing expression for the slot. At the end of the pipeline, we choose a stack layout, then replace each stack slot with its offset from the stack pointer. The benefit is that we break the phase-ordering problem: any phase of the compiler can name a stack slot. 
    1212 
    13 For example, if we want to spill a variable `x`, we use a regular store instruction to a stack slot at address `SS(x)`: 
    14  
     13For example, for a variable `x`, the expression `SS(x)` is the address of the stack slot where we can spill `x`. The stack is assumed to grow down, and we assume that the address `SS(x)` points to the old end of the slot. Therefore, to address the low address of a 4-byte slot, we would use the expression `SS(x + 4)`. And we would spill `x` using the following instruction: 
    1514{{{ 
    16 m[SS(x)] := x; 
     15m[SS(x + 4)] := x; 
    1716}}} 
    1817 
     
    2827 
    2928{{{ 
    30   sp := SS(k + 4); 
    31   m[SS(k + 1)] := k_info_table; 
    32   m[SS(k + 2)] := a; 
    33   m[SS(k + 3)] := b; 
    34   m[SS(k + 4)] := c; 
     29  sp := SS(k + 16); 
     30  m[SS(k + 4)] := k_info_table; 
     31  m[SS(k + 8)] := a; 
     32  m[SS(k + 12)] := b; 
     33  m[SS(k + 16)] := c; 
    3534  call f returns to k; 
    36 k:  // on entry to k, sp == stack<k+3> 
    37   x := m[SS(k + 2)] 
    38   y := m[SS(k + 3)] 
     35k:  // on entry to k, sp == stack<k+12> 
     36  x := m[SS(k + 8)] 
     37  y := m[SS(k + 12)] 
    3938}}} 
    4039