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/mips/emit/mipsAsm.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/mips/emit/mipsAsm.sml

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

revision 1327, Fri May 16 16:59:31 2003 UTC revision 1328, Fri May 16 19:23:19 2003 UTC
# Line 5  Line 5 
5   *)   *)
6    
7    
8  functor MIPSAsmEmitter(structure Instr : MIPSINSTR  functor MIPSAsmEmitter(structure S : INSTRUCTION_STREAM
9                           structure Instr : MIPSINSTR
10                              where T = S.P.T
11                         structure Shuffle : MIPSSHUFFLE                         structure Shuffle : MIPSSHUFFLE
12                            where I = Instr                            where I = Instr
13                           structure MLTreeEval : MLTREE_EVAL
14                              where T = Instr.T
15                        ) : INSTRUCTION_EMITTER =                        ) : INSTRUCTION_EMITTER =
16  struct  struct
17     structure I  = Instr     structure I  = Instr
18     structure C  = I.C     structure C  = I.C
19     structure T  = I.T     structure T  = I.T
20     structure S  = T.Stream     structure S  = S
21     structure P  = S.P     structure P  = S.P
    structure LabelExp = I.LabelExp  
22     structure Constant = I.Constant     structure Constant = I.Constant
23    
24     val show_cellset = MLRiscControl.getFlag "asm-show-cellset"     open AsmFlags
    val show_region  = MLRiscControl.getFlag "asm-show-region"  
    val show_cutsTo = MLRiscControl.getFlag "asm-show-cutsto"  
    val indent_copies = MLRiscControl.getFlag "asm-indent-copies"  
25    
26     fun error msg = MLRiscErrorMsg.error("MIPSAsmEmitter",msg)     fun error msg = MLRiscErrorMsg.error("MIPSAsmEmitter",msg)
27    
# Line 41  Line 41 
41                    in  if n<0 then "-"^String.substring(s,1,size s-1)                    in  if n<0 then "-"^String.substring(s,1,size s-1)
42                        else s                        else s
43                    end                    end
44         fun emit_label lab = emit(Label.nameOf lab)         fun emit_label lab = emit(P.Client.AsmPseudoOps.lexpToString(T.LABEL lab))
45         fun emit_labexp le = emit(LabelExp.toString le)         fun emit_labexp le = emit(P.Client.AsmPseudoOps.lexpToString (T.LABEXP le))
46         fun emit_const c = emit(Constant.toString c)         fun emit_const c = emit(Constant.toString c)
47         fun emit_int i = emit(ms i)         fun emit_int i = emit(ms i)
48         fun paren f = (emit "("; f(); emit ")")         fun paren f = (emit "("; f(); emit ")")
49         fun defineLabel lab = emit(Label.nameOf lab^":\n")         fun defineLabel lab = emit(P.Client.AsmPseudoOps.defineLabel lab^"\n")
50         fun entryLabel lab = defineLabel lab         fun entryLabel lab = defineLabel lab
51         fun comment msg = (tab(); emit("/* " ^ msg ^ " */"))         fun comment msg = (tab(); emit("/* " ^ msg ^ " */"); nl())
52         fun annotation a = (comment(Annotations.toString a); nl())         fun annotation a = comment(Annotations.toString a)
53         fun getAnnotations() = error "getAnnotations"         fun getAnnotations() = error "getAnnotations"
54         fun doNothing _ = ()         fun doNothing _ = ()
55           fun fail _ = raise Fail "AsmEmitter"
56         fun emit_region mem = comment(I.Region.toString mem)         fun emit_region mem = comment(I.Region.toString mem)
57         val emit_region =         val emit_region =
58            if !show_region then emit_region else doNothing            if !show_region then emit_region else doNothing
59         fun pseudoOp pOp = emit(P.toString pOp)         fun pseudoOp pOp = (emit(P.toString pOp); emit "\n")
60         fun init size = (comment("Code Size = " ^ ms size); nl())         fun init size = (comment("Code Size = " ^ ms size); nl())
61         val emitCellInfo = AsmFormatUtil.reginfo         val emitCellInfo = AsmFormatUtil.reginfo
62                                  (emit,formatAnnotations)                                  (emit,formatAnnotations)
63         fun emitCell r = (emit(C.toString r); emitCellInfo r)         fun emitCell r = (emit(CellsBasis.toString r); emitCellInfo r)
64         fun emit_cellset(title,cellset) =         fun emit_cellset(title,cellset) =
65           (nl(); comment(title^C.CellSet.toString cellset))           (nl(); comment(title^CellsBasis.CellSet.toString cellset))
66         val emit_cellset =         val emit_cellset =
67           if !show_cellset then emit_cellset else doNothing           if !show_cellset then emit_cellset else doNothing
68         fun emit_defs cellset = emit_cellset("defs: ",cellset)         fun emit_defs cellset = emit_cellset("defs: ",cellset)
# Line 548  Line 549 
549         | I.SOURCE{} => emit "source"         | I.SOURCE{} => emit "source"
550         | I.SINK{} => emit "sink"         | I.SINK{} => emit "sink"
551         )         )
552            and emitInstr i = (tab(); emitInstr' i; nl())        in  tab(); emitInstr' instr; nl()
553            and emitInstrIndented i = (indent(); emitInstr' i; nl())        end (* emitter *)
554          and emitInstrIndented i = (indent(); emitInstr i; nl())
555            and emitInstrs instrs =            and emitInstrs instrs =
556             app (if !indent_copies then emitInstrIndented             app (if !indent_copies then emitInstrIndented
557                  else emitInstr) instrs                  else emitInstr) instrs
558        in  emitInstr instr end  
559          and emitInstr(I.ANNOTATION{i,a}) =
560               ( comment(Annotations.toString a);
561                  nl();
562                  emitInstr i )
563            | emitInstr(I.LIVE{regs, spilled})  =
564                comment("live= " ^ CellsBasis.CellSet.toString regs ^
565                        "spilled= " ^ CellsBasis.CellSet.toString spilled)
566            | emitInstr(I.KILL{regs, spilled})  =
567                comment("killed:: " ^ CellsBasis.CellSet.toString regs ^
568                        "spilled:: " ^ CellsBasis.CellSet.toString spilled)
569            | emitInstr(I.INSTR i) = emitter i
570            | emitInstr(I.COPY{k=CellsBasis.GP, sz, src, dst, tmp}) =
571               emitInstrs(Shuffle.shuffle{tmp=tmp, src=src, dst=dst})
572            | emitInstr(I.COPY{k=CellsBasis.FP, sz, src, dst, tmp}) =
573               emitInstrs(Shuffle.shufflefp{tmp=tmp, src=src, dst=dst})
574            | emitInstr _ = error "emitInstr"
575    
576     in  S.STREAM{beginCluster=init,     in  S.STREAM{beginCluster=init,
577                  pseudoOp=pseudoOp,                  pseudoOp=pseudoOp,
578                  emit=emitter,                  emit=emitInstr,
579                  endCluster=doNothing,                  endCluster=fail,
580                  defineLabel=defineLabel,                  defineLabel=defineLabel,
581                  entryLabel=entryLabel,                  entryLabel=entryLabel,
582                  comment=comment,                  comment=comment,

Legend:
Removed from v.1327  
changed lines
  Added in v.1328

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