Changes between Version 43 and Version 44 of Commentary/Compiler/StackAreas


Ignore:
Timestamp:
Jun 26, 2008 5:02:51 PM (6 years ago)
Author:
dias
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/StackAreas

    v43 v44  
    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 {{{stack<x>}}}: 
     13For example, if we want to spill a variable `x`, we use a regular store instruction to a stack slot at address `SS(x)`: 
    1414 
    1515{{{ 
    16 m[stack<x>] := x; 
     16m[SS(x)] := x; 
    1717}}} 
    1818 
     
    2828 
    2929{{{ 
    30   sp := stack<k + 4>; 
    31   m[stack<k + 1>] := k_info_table; 
    32   m[stack<k + 2>] := a; 
    33   m[stack<k + 3>] := b; 
    34   m[stack<k + 4>] := c; 
     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; 
    3535  call f returns to k; 
    3636k:  // on entry to k, sp == stack<k+3> 
    37   x := m[stack<k + 2>] 
    38   y := m[stack<k + 3>] 
     37  x := m[SS(k + 2)] 
     38  y := m[SS(k + 3)] 
    3939}}} 
    4040 
     
    5656An `Area` represents space on the stack; it may use either the `RegSlot` constructor to represent a single stack slot for a register or the `CallArea` constructor to represent parameters passed to/from a function call/return. In a `CallArea`, the `BlockId` is the label of the function call's continuation, and the two integers are the sizes of the outgoing and incoming parameter-passing areas. 
    5757 
    58 To name a specific location on the stack, we represent its address with a new kind of `CmmExpr`: the `CmmStackSlot`. A `CmmStackSlot` is just an integer offset into an `Area`. If the `Area` is a `RegSlot`, we might still use a non-zero offset: for example, we might want to load the low word from a long integer. 
     58To name a specific location on the stack, we represent its address with a new kind of `CmmExpr`: the `CmmStackSlot`. A `CmmStackSlot` is just an integer offset into an `Area`. Each stack area grows down, with offset 0 pointing to the old end of the area. If we wanted to place a 4-byte object at the old end of the area, we would address it using the offset 4. 
     59 
     60```STACK PICTURE HERE.``` 
     61 
     62Note: If the `Area` is a `RegSlot`, we might still use a non-zero offset: for example, we might want to load the low word from a long integer. 
    5963 
    6064Notice that a `CmmStackSlot` is an ''address'', so we can say