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 /sml/trunk/src/MLRISC/Tools/MDL/mdl-gen-instr.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/Tools/MDL/mdl-gen-instr.sml

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

revision 1002, Fri Nov 30 17:11:33 2001 UTC revision 1003, Fri Dec 7 02:45:32 2001 UTC
# Line 1  Line 1 
1    
2  (*  (*
3   * Generate the <arch>Instr signature and functor.   * Generate the <arch>Instr signature and functor.
4   * This structure contains the definition of the instruction set.   * This structure contains the definition of the instruction set.
# Line 11  Line 12 
12    
13     open Ast Comp.Util     open Ast Comp.Util
14    
15       val toLower = String.map Char.toLower
16    
17       val instructionDatatype =
18       $["and instruction =",
19         "  LIVE of {regs: C.cellset, spilled: C.cellset}",
20         "| KILL of {regs: C.cellset, spilled: C.cellset}",
21         "| COPYXXX of {k: CB.cellkind, dst: CB.cell list, src: CB.cell list}",
22         "| ANNOTATION of {i:instruction, a:Annotations.annotation}",
23         "| INSTR of instr"
24        ]
25    
26     fun gen md =     fun gen md =
27     let (* name of the structure/signature *)     let (* name of the structure/signature *)
28         val strName = Comp.strname md "Instr"         val strName = Comp.strname md "Instr"
29         val sigName = Comp.signame md "INSTR"         val sigName = Comp.signame md "INSTR"
30    
31         (* The datatype that defines the instruction set *)         (* The datatype that defines the instruction set *)
32           val instructions = Comp.instructions md
33         val instrDatatype =         val instrDatatype =
34             DATATYPEdecl             DATATYPEdecl([DATATYPE("instr",[],instructions)],[])
              ([DATATYPE("instruction",[],Comp.instructions md)],[])  
35    
36         (* Arguments to the instruction functor *)         (* Arguments to the instruction functor *)
37         val args = ["T: MLTREE"]         val args = ["T: MLTREE"]
38    
39           (* the shorthand functions *)
40           val instrTy = IDty(IDENT([],"instruction"))
41           val shortHandSig =
42               map (fn CONSbind{id,ty=NONE,...} =>
43                        VALSIGdecl([toLower id],instrTy)
44                     | CONSbind{id,ty=SOME ty, ...} =>
45                        VALSIGdecl([toLower id],FUNty(ty,instrTy)))
46                   instructions
47           val shortHandFuns =
48               VALdecl(
49               map (fn CONSbind{id,ty=NONE,...} =>
50                         VALbind(IDpat(toLower id), APP("INSTR",ID id))
51                     | CONSbind{id,ty=SOME _,...} =>
52                         VALbind(IDpat(toLower id),
53                             APP("o",TUPLEexp[ID "INSTR",ID id])))
54                   instructions)
55    
56         (* The signature *)         (* The signature *)
57         val sigBody =         val sigBody =
58            [$ ["structure C : "^Comp.signame md "CELLS",            [$ ["structure C : "^Comp.signame md "CELLS",
59                  "structure CB : CELLS_BASIS",
60                "structure T : MLTREE",                "structure T : MLTREE",
61                "structure Constant: CONSTANT",                "structure Constant: CONSTANT",
62                "structure Region : REGION",                "structure Region : REGION",
# Line 34  Line 64 
64                "   sharing Region = T.Region"                "   sharing Region = T.Region"
65                ],                ],
66             Comp.typeOf md "Instruction",             Comp.typeOf md "Instruction",
67             instrDatatype             instrDatatype,
68            ]             instructionDatatype
69              ] @ shortHandSig
70    
71         (* The functor *)         (* The functor *)
72         val strBody =         val strBody =
73             [$ ["structure C = "^Comp.strname md "Cells",             [$ ["structure C = "^Comp.strname md "Cells",
74                   "structure CB = CellsBasis",
75                 "structure T = T",                 "structure T = T",
76                 "structure Region = T.Region",                 "structure Region = T.Region",
77                 "structure Constant = T.Constant"                 "structure Constant = T.Constant"
78                ],                ],
79              Comp.declOf md "Instruction",              Comp.declOf md "Instruction",
80              instrDatatype              instrDatatype,
81                instructionDatatype,
82                shortHandFuns
83             ]             ]
84    
85         val _ = Comp.require md "Instruction"         val _ = Comp.require md "Instruction"

Legend:
Removed from v.1002  
changed lines
  Added in v.1003

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