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-rtlprops.sml
ViewVC logotype

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

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

revision 774, Wed Jan 10 12:50:56 2001 UTC revision 775, Fri Jan 12 01:17:51 2001 UTC
# Line 9  Line 9 
9    
10     structure RTLComp = RTLComp     structure RTLComp = RTLComp
11     structure Comp    = RTLComp.Comp     structure Comp    = RTLComp.Comp
12       structure M       = RTLComp.MLRiscTypes
13     structure Consts  = Comp.Consts     structure Consts  = Comp.Consts
14     structure Ast     = Comp.Ast     structure Ast     = Comp.Ast
15     structure Env     = Comp.Env     structure Env     = Comp.Env
# Line 96  Line 97 
97      * Create the function defUse : instruction -> cell list * cell list      * Create the function defUse : instruction -> cell list * cell list
98      *      *
99      *------------------------------------------------------------------------*)      *------------------------------------------------------------------------*)
100     fun mkDefUseQueryFun compiled_rtls name user =     fun mkDefUseQueryFun compiled_rtls name =
101     let val md = RTLComp.md compiled_rtls     let val {get, decl} = M.getOpnd
102                [("int",     M.CONV("CELL(int x)")),
103         fun cellOf(k,r) =               ("int32",   M.CONV("CELL(int32 x)")),
104         let val CELLdecl{from,...} =               ("intinf",  M.CONV("CELL(intinf x)")),
105                 Comp.lookupCellKind md (C.cellkindToString k)               ("word",    M.CONV("CELL(word x)")),
106         in  INTexp(!from + r)               ("word32",  M.CONV("CELL(word32 x)")),
107         end               ("cell",    M.CONV("CELL x")),
108                 ("label",   M.IGNORE),
109         fun join("::",x,y) = cons(x,y)               ("cellset", M.MULTI("map CELL (C.CellSet.toCellList x)")),
110           | join(typ,x,y)  = APP(typ,TUPLEexp[x,y])               ("operand", M.CONV("OPERAND x"))
111                ]
112         fun body{instr, rtl=RTLComp.RTLDEF{id,rtl,...}, const} =          val decl0 =
113         let val (d, u) = RTL.defUse rtl              $["(* methods for computing value numbers *)",
114                  "val OT.VALUE_NUMBERING",
115             fun arg(k,x) = user(IDexp(IDENT(["C"],C.cellkindToString k)),x)                "   {int, int32, intinf, word, word32, operand, ...} =",
116                  "      valueNumberingMethods",
117             fun collect(T.ARG(_,ref(T.REP k),x), e) =                "(* methods for type conversion *)"
118                    join("get"^k,arg(C.GP,ID x),e)               ]
119               | collect(T.$(_,C.MEM,_),e) = e (* XXX *)         fun gen x = SOME(get x)
120               | collect(T.$(_,k,T.ARG(_,_,x)), e) = join("::", arg(k,ID x), e)     in  RTLComp.mkDefUseQuery
121               | collect(T.$(_,k,T.LI r), e) = join("::",arg(k, cellOf(k,r)), e)            compiled_rtls
              | collect(t,e) = fail("collect "^RTL.Util.rexpToString t)  
   
            val def = foldr collect (LISTexp([],NONE)) d  
            val use = foldr collect (LISTexp([],NONE)) u  
            val exp = TUPLEexp[def,use]  
        in  {exp=exp, casePats=[]}  
        end  
    in  RTLComp.mkQuery compiled_rtls  
122            {name          = name,            {name          = name,
123             namedArguments= true,             args           = [["valueNumberingMethods"], ["instr"]],
124             args          = [["instr"]],             namedArguments = false,
125             decls         = [RTLComp.complexErrorHandler name],             decls          = [RTLComp.complexErrorHandler name, decl0, decl],
126             caseArgs      = [],             def            = gen,
127             body          = body             use            = gen
128            }            }
129     end     end
130    
   
131     (*------------------------------------------------------------------------     (*------------------------------------------------------------------------
132      *      *
133      * Main routine      * Main routine
# Line 154  Line 146 
146             ["structure Instr : "^Comp.signame md "INSTR",             ["structure Instr : "^Comp.signame md "INSTR",
147              "structure RegionProps : REGION_PROPERTIES",              "structure RegionProps : REGION_PROPERTIES",
148              "structure RTL : MLTREE_RTL",              "structure RTL : MLTREE_RTL",
149                "structure OperandTable : OPERAND_TABLE where I = Instr",
150              "structure Asm : INSTRUCTION_EMITTER where I = Instr",              "structure Asm : INSTRUCTION_EMITTER where I = Instr",
151              "  sharing Instr.Region = RegionProps.Region",              "  sharing Instr.T = RTL.T"
             "  sharing type Instr.C.cellkind = RTL.T.CellsBasis.cellkind"  
152             ]             ]
153    
154         (* The functor *)         (* The functor *)
# Line 165  Line 157 
157                 "structure C   = I.C",                 "structure C   = I.C",
158                 "structure RTL = RTL",                 "structure RTL = RTL",
159                 "structure T   = RTL.T",                 "structure T   = RTL.T",
160                   "structure OT  = OperandTable",
161                 "",                 "",
162                 "datatype opnkind =",                 "datatype value = CELL of C.cell",
163                 "  IMM     (* a constant operand *)",                 "               | OPERAND of I.operand",
                "| REG     (* can be renamed *)",  
                "| FIX     (* cannot be renamed *)",  
                "| MEM     (* memory *)",  
                "| CTRL    (* control dependence *)",  
164                 ""                 ""
165                ],                ],
166              Comp.errorHandler md "RTLProps",              Comp.errorHandler md "RTLProps",
167              RTLComp.complexErrorHandlerDef (),              RTLComp.complexErrorHandlerDef (),
168              STRUCTUREdecl(Comp.strname md "RTL",[],NONE,              STRUCTUREdecl(Comp.strname md "RTL",[],NONE,
169                 APPsexp(IDENT([],Comp.strname md "RTL"),                 APPsexp(IDsexp(IDENT([],Comp.strname md "RTL")),
170                    DECLsexp[                    DECLsexp[
171                    $[ "structure RTL = RTL",                    $[ "structure RTL = RTL",
172                       "structure C   = C"                       "structure C   = C"
# Line 186  Line 175 
175              ),              ),
176              genRTLTable compiled_rtls,              genRTLTable compiled_rtls,
177              mkRtlQueryFun compiled_rtls,              mkRtlQueryFun compiled_rtls,
178              mkDefUseQueryFun compiled_rtls "defUse" (fn (k,x) => x),              mkDefUseQueryFun compiled_rtls "defUse"
             mkDefUseQueryFun compiled_rtls "defUseWithCellKind"  
                   (fn (k,x) => TUPLEexp[k,x])  
179             ]             ]
180    
181     in  Comp.codegen md "mltree/RTLProps"     in  Comp.codegen md "mltree/RTLProps"

Legend:
Removed from v.774  
changed lines
  Added in v.775

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