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 744 - (view) (download)

1 : monnier 245 functor HppaLabelComp
2 :     (structure MLTree : MLTREE
3 :     structure Instr : HPPAINSTR
4 : monnier 411 sharing Instr.Region = MLTree.Region
5 : leunga 744 sharing Instr.LabelExp = MLTree.LabelExp) : LABEL_COMP =
6 : monnier 245 struct
7 :     structure T = MLTree
8 :     structure I = Instr
9 :     structure C = I.C
10 : george 546 structure LE = I.LabelExp
11 : monnier 245
12 : george 555 type reduce =
13 :     { stm: T.stm -> unit,
14 : leunga 744 rexp: T.rexp -> C.cell,
15 : monnier 245 emit: I.instruction -> unit }
16 :    
17 :     fun error msg = ErrorMsg.impossible("HppaLabelComp." ^ msg)
18 :    
19 : george 546 fun ldLabelOpnd emit {label, pref} = I.LabExp(label,I.T)
20 : leunga 744 fun ldLabelEA emit lexp = (C.r0, I.LabExp(lexp, I.T))
21 : monnier 245
22 :     (* should change the return pointer to 2 to follow HPUX conventions *)
23 : george 555 fun doCall({stm,rexp,emit}:reduce,
24 : leunga 744 T.CALL{funct, targets, defs, uses, region, ...}) =
25 : george 546 let
26 : leunga 744 val addCCreg = C.CellSet.add
27 : monnier 245 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 : george 546 | live(T.CCR(T.CC(_,c))::regs, acc) = live(regs, addCCreg(c, acc))
31 :     | live(T.CCR(T.FCC(_,c))::regs, acc) = live(regs, addCCreg(c, acc))
32 : monnier 245 | live(_::regs, acc) = live(regs, acc)
33 : leunga 744 val returnPtr = C.GPReg 31
34 : leunga 591 val defs = C.addReg(returnPtr, live(defs, C.empty))
35 :     val uses = live(uses, C.empty)
36 :     in emit(I.BLE{b=rexp funct, d=I.IMMED 0, sr=5, t=returnPtr,
37 :     defs=defs, uses=uses, mem=region})
38 : monnier 245 end
39 :     | doCall _ = error "doCall"
40 :    
41 : leunga 744 fun doJmp({stm,rexp,emit}:reduce, T.JMP(exp, labs)) =
42 : monnier 245 (case exp
43 :     of T.LABEL(LE.LABEL lab) => emit(I.B{lab=lab,n=true})
44 :     | T.LABEL _ => error "doJmp: LABEL"
45 : leunga 744 | _ => emit(I.BV{b=rexp(exp), x=C.GPReg 0, labs=labs, n=true})
46 : monnier 245 (*esac*))
47 :    
48 :     end
49 :    

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