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/branches/SMLNJ/src/compiler/CodeGen/hppa/hppaLabelComp.sml
ViewVC logotype

Annotation of /sml/branches/SMLNJ/src/compiler/CodeGen/hppa/hppaLabelComp.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 469 - (view) (download)

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

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