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/hppaMillicode.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 418 - (view) (download)
Original Path: sml/branches/SMLNJ/src/compiler/CodeGen/hppa/hppaMillicode.sml

1 : monnier 245 functor HppaMillicode
2 :     (structure MLTree : MLTREE
3 :     structure Instr : HPPAINSTR
4 :     sharing MLTree.Constant = Instr.Constant) : HPPA_MILLICODE =
5 :     struct
6 :     structure T = MLTree
7 :     structure C = Instr.C
8 :     structure I = Instr
9 :     structure Region = I.Region
10 :    
11 :     val arg1 = 26
12 :     val arg2 = 25
13 :     val ra = 31 (* milli return address *)
14 :     val rv = 29 (* milli return value *)
15 :     val sp = C.stackptrR
16 :     val stack = Region.stack
17 :    
18 :     val udivOffset = ~16
19 :     val divOffset = ~20
20 :     val mulOffset = ~24
21 :     val muluOffset = ~112
22 :     val cvti2dOffset = ~4
23 :     fun copyTmp() = SOME(I.Direct(C.newReg()))
24 :    
25 :    
26 :     fun doMilliCall offset {rs, rt, rd} = let
27 :     fun addList([], cs) = cs
28 :     | addList(r::rs, cs) = addList(rs, C.addReg(r,cs))
29 :     val tmpR = C.newReg()
30 :     val defs = addList([rv,ra], C.empty)
31 :     val uses = C.addReg(arg1, C.addReg(arg2, C.empty))
32 :     in
33 :     [I.COPY{dst=[arg1, arg2], src=[rs, rt], impl=ref NONE, tmp=copyTmp()},
34 :     I.LOADI{li=I.LDW, r=C.stackptrR, i=I.IMMED offset, t=tmpR, mem=stack},
35 : monnier 411 I.BLE{t=31, b=tmpR, sr=5, d=I.IMMED 0, defs=defs, uses=uses, mem=stack},
36 : monnier 245 I.COPY{dst=[rd], src=[rv], impl=ref NONE, tmp=copyTmp()}]
37 :     end
38 :    
39 :     val divu = doMilliCall udivOffset
40 :     val divo = doMilliCall divOffset
41 :     val mulo = doMilliCall mulOffset
42 :     val mulu = doMilliCall muluOffset
43 :    
44 : monnier 411 fun cvti2real fcnv {rs,fd} =
45 :     let val tmpF = C.newFreg()
46 :     in [I.STORE{st=I.STW, b=C.stackptrR, d=I.IMMED cvti2dOffset,r=rs, mem=stack},
47 :     I.FLOAD{fl=I.FLDWS, b=C.stackptrR, d=cvti2dOffset, t=tmpF, mem=stack},
48 :     I.FCNV{fcnv=fcnv, f=tmpF, t=fd}
49 :     ]
50 :     end
51 : monnier 245
52 : monnier 411 val cvti2s = cvti2real I.FCNVXF_S
53 :     val cvti2d = cvti2real I.FCNVXF_D
54 :     val cvti2q = cvti2real I.FCNVXF_Q
55 :    
56 : monnier 245 end
57 :    

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