Changes between Version 67 and Version 68 of Commentary/Compiler/StackAreas


Ignore:
Timestamp:
Feb 14, 2011 9:57:52 PM (3 years ago)
Author:
ezyang
Comment:

some notes about the new codegen

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/StackAreas

    v67 v68  
    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, 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: 
     13For example, for a variable `x`, the expression `SS(x)` is the address of the stack slot where we can spill `x`. (I don't think we output any C-- that uses SS anymore, but the new code generator marks its stack slots prior to layout with `young<k> + 4`, etc. -- Edward) 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: 
    1414{{{ 
    1515m[SS(x + 4)] := x; 
     
    4343data Area 
    4444  = RegSlot  LocalReg 
    45   | CallArea BlockId 
     45  | CallArea AreaId 
     46  deriving (Eq, Ord) 
     47 
     48data AreaId 
     49  = Old 
     50  | Young BlockId 
    4651  deriving (Eq, Ord) 
    4752 
     
    5358}}} 
    5459 
    55 An `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. Each `Area` grows down, with offset 0 pointing to the old end of the `Area`. 
     60An `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 young `CallArea`, the `BlockId` is the label of the function call's continuation. Each `Area` grows down, with offset 0 pointing to the old end of the `Area`. (TODO: Explain the old area.) 
    5661 
    5762To name a specific location on the stack, we represent its address with a new kind of `CmmExpr`: the `CmmStackSlot`.