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

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

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