Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /MLRISC/trunk/staged-allocation/staged-allocation-sig.sml
ViewVC logotype

Diff of /MLRISC/trunk/staged-allocation/staged-allocation-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2344, Tue Feb 27 00:39:10 2007 UTC revision 2348, Wed Mar 7 19:32:18 2007 UTC
# Line 1  Line 1 
1  (* staged-allocation-sig.sml  (* staged-allocation-sig.sml
2   *   *
3   *   * This code implements the Staged Allocation technique for calling conventions.
4     * You can find the POPL06 paper describing this technique at
5     * http://www.eecs.harvard.edu/~nr/pubs/staged-abstract.html
6   *)   *)
7    
8    (* the target language, e.g., C, implements this signature *)
9  signature TARGET_LANG = sig  signature TARGET_LANG = sig
10        (* the type of values in the target language *)
11      type location_kind      type location_kind
   
12  end (* TARGET_LANG *)  end (* TARGET_LANG *)
13    
14  signature STAGED_ALLOCATION = sig  signature STAGED_ALLOCATION = sig
# Line 14  Line 16 
16      structure T : MLTREE      structure T : MLTREE
17      structure TL : TARGET_LANG      structure TL : TARGET_LANG
18    
19      type width = int      type width = int     (* bit width *)
20      type counter      type counter         (* abstract counter for a convention *)
21      type str      type str             (* counter -> "bit offset" *)
22      datatype block_direction = UP | DOWN      datatype block_direction = UP | DOWN
23                   (* bit width, location kind, bit alignment *)      (* A slot is a target-language argument. It contains bit width, location kind,
24         * and bit alignment. *)
25      type slot = (width * TL.location_kind * int)      type slot = (width * TL.location_kind * int)
26      type reg = (width * T.reg)      type reg = (width * T.reg)
27    
28      datatype location =      datatype location =
29               REG of reg         (* machine register *)               REG of reg         (* machine register *)
30             | BLOCK_OFFSET of int         (* slot in the overflow block *)             | BLOCK_OFFSET of int         (* slot in the overflow block *)
31             | COMBINE of (location * location)         (* a location that occupies two other locations*)             (* a location that occupies two other locations*)
32             | NARROW of (location * width * TL.location_kind) (* a location that loses bits *)             | COMBINE of (location * location)
33               (* a location that loses bits *)
34               | NARROW of (location * width * TL.location_kind)
35    
36        (* information about a location's width and target-language type *)
37      type location_info = (width * location * TL.location_kind)      type location_info = (width * location * TL.location_kind)
38    
39        (* mini language for defining calling conventions (see the paper for
40         * a explanations of the operators, and their formal semantics). *)
41      datatype stage =      datatype stage =
42               OVERFLOW of { counter : counter,               OVERFLOW of { counter : counter,
43                             blockDirection : block_direction,                             blockDirection : block_direction,
# Line 44  Line 52 
52             | PAD of counter             | PAD of counter
53             | ALIGN_TO of (width -> width)             | ALIGN_TO of (width -> width)
54    
55      type stepper_fn = (str * slot) -> (str * location_info list)      exception StagedAlloc
56    
57        (* A stepper function takes a store and a target-language argument,
58         * and returns a new store and a location for the argument. *)
59        type stepper_fn = (str * slot) -> (str * location_info)
60        (* Create a counter. *)
61      val freshCounter : unit -> counter      val freshCounter : unit -> counter
62        (* Helper function that creates a counter c, and returns the sequence:
63         * [BITCOUNTER c, REGS_BY_BITS (c, regs)] (this function is stolen from
64         * the paper). *)
65      val useRegs : reg list -> (counter * stage)      val useRegs : reg list -> (counter * stage)
66        (* Retrieve a counter value from the store. *)
67      val find : (str * counter) -> int      val find : (str * counter) -> int
68        (* Initialize a list of counters for a calling convention. *)
69      val init : counter list -> str      val init : counter list -> str
70        (* Take a calling convention, and return a stepper function for it. *)
71      val mkStep : stage list -> stepper_fn      val mkStep : stage list -> stepper_fn
72    
     val process : {counters : counter list, stages : stage list} -> slot list  
                   -> location_info list list  
   
73  end (* STAGED_ALLOCATION *)  end (* STAGED_ALLOCATION *)

Legend:
Removed from v.2344  
changed lines
  Added in v.2348

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0