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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/compiler/CodeGen/hppa/hppaLabelComp.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/CodeGen/hppa/hppaLabelComp.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 246 - (view) (download)

1 : monnier 245 functor HppaLabelComp
2 :     (structure MLTree : MLTREE
3 :     structure Instr : HPPAINSTR
4 :     sharing Instr.Constant = MLTree.Constant) =
5 :     struct
6 :     structure T = MLTree
7 :     structure I = Instr
8 :     structure C = I.C
9 :     structure LE = LabelExp
10 :    
11 :     type reduce =
12 :     { stm: T.stm -> unit,
13 :     rexp: T.rexp -> int,
14 :     emit: I.instruction -> unit }
15 :    
16 :     datatype lab_opnd = OPND of I.operand | REG of int
17 :    
18 :     fun error msg = ErrorMsg.impossible("HppaLabelComp." ^ msg)
19 :    
20 :     fun ldLabelOpnd emit {label, pref} = OPND(I.LabExp(label,I.T))
21 :     fun ldLabelEA emit lexp = (0, I.LabExp(lexp, I.T))
22 :    
23 :     (* should change the return pointer to 2 to follow HPUX conventions *)
24 :     fun doCall({stm,rexp,emit}:reduce, T.CALL(exp, def, use)) = let
25 :     val addCCreg = C.addCell C.CC
26 :     fun live([], acc) = acc
27 :     | live(T.GPR(T.REG r)::regs, acc) = live(regs, C.addReg(r, acc))
28 :     | live(T.FPR(T.FREG f)::regs, acc) = live(regs, C.addFreg(f, acc))
29 :     | live(T.CCR(T.CC c)::regs, acc) = live(regs, addCCreg(c, acc))
30 :     | live(_::regs, acc) = live(regs, acc)
31 :     val returnPtr = 31
32 :     val defs = C.addReg(returnPtr, live(def, C.empty))
33 :     val uses = live(use, C.empty)
34 :     in emit(I.BLE{b=rexp exp, d=I.IMMED 0, sr=5, t=returnPtr, defs=defs, uses=uses})
35 :     end
36 :     | doCall _ = error "doCall"
37 :    
38 :     fun doJmp({stm,rexp,emit}:reduce, T.JMP(exp, labs)) =
39 :     (case exp
40 :     of T.LABEL(LE.LABEL lab) => emit(I.B{lab=lab,n=true})
41 :     | T.LABEL _ => error "doJmp: LABEL"
42 :     | _ => emit(I.BV{b=rexp(exp), x=0, labs=labs, n=true})
43 :     (*esac*))
44 :    
45 :     end
46 :    
47 :    
48 :     (*
49 :     * $Log$
50 :     *)

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