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 245 - (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 :     I.BLE{t=31, b=tmpR, sr=5, d=I.IMMED 0, defs=defs, uses=uses},
36 :     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 :     fun cvti2d{rs, fd} =
45 :     [I.STORE{st=I.STW, b=sp, d=I.IMMED cvti2dOffset, r=rs, mem=stack},
46 :     I.FLOAD{fl=I.FLDWS, b=sp, d=cvti2dOffset, t=fd, mem=Region.stack},
47 :     I.FUNARY{fu=I.FCNVXF, f=fd, t=fd}]
48 :    
49 :     end
50 :    
51 :     (*
52 :     * $Log$
53 :     *)

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