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/MLRISC/ppc/instructions/ppcInstr.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/ppc/instructions/ppcInstr.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 233 - (view) (download)

1 : monnier 233 functor PPCInstr
2 :     (structure Const : CONSTANT
3 :     structure Region : REGION) : PPCINSTR =
4 :     struct
5 :     structure C = PPCCells
6 :     structure Constant = Const
7 :     structure Region = Region
8 :    
9 :     type gpr = int (* general purpose register *)
10 :     type fpr = int (* floating point register *)
11 :     type ccr = int (* condition code register *)
12 :     type crf = int (* condition register field *)
13 :    
14 :    
15 :     datatype spr = XER | LR | CTR
16 :    
17 :     datatype operand =
18 :     RegOp of int
19 :     | ImmedOp of int
20 :     | LabelOp of LabelExp.labexp
21 :     | ConstOp of Constant.const
22 :     (***
23 :     | HiLabelOp of LabelExp.labexp
24 :     | LoLabelOp of LabelExp.labexp
25 :     ***)
26 :    
27 :     datatype ea =
28 :     Direct of int
29 :     | FDirect of int
30 :     | Displace of {base:int, disp:operand} (* RegOp illegal as operand *)
31 :    
32 :     datatype size = Byte | Half | Word | Long | Single | Double
33 :    
34 :     datatype cmp = CMP | CMPL
35 :     datatype fcmp = FCMPO (* ordered *) | FCMPU (* unordered *)
36 :     datatype unary = NEG
37 :     datatype funary = FMR | FABS | FNEG
38 :     datatype farith = FADD | FSUB | FMUL | FDIV
39 :     datatype bo =
40 :     TRUE (* 011zy *)
41 :     | FALSE (* 001zy *)
42 :     | ALWAYS (* 1z1zz *)
43 :     | COUNTER of {eqZero:bool, cond:bool option}
44 :     (* operation ARITH ARITHI *)
45 :     datatype arith = (* --------- ----- ------ *)
46 :     ADD (* add add addi *)
47 :     | ADDS (* add-shifted - addis *)
48 :     | SUBF (* subtract from subf subfic *)
49 :     | MULL (* multiply mullw mulli *)
50 :     | DIVW (* divide word divw - *)
51 :     | DIVWU (* divide word unsigned divwu - *)
52 :     | AND (* and and andi *)
53 :     | OR (* or or ori *)
54 :     | XOR (* xor xor xori *)
55 :     | XORS (* xor shifted - xoris *)
56 :     | SLW (* shift left word slw rlwinm *)
57 :     | SRW (* shift right word srw rlwinm *)
58 :     | SRAW (* shift right algebrai word sraw srawi *)
59 :    
60 :     datatype rotate =
61 :     RLWNM (* rotate left word AND mask rlwnm rlwinm *)
62 :    
63 :     datatype ccarith =
64 :     CRAND (* cond. reg. AND *)
65 :     | CROR (* cond. reg. OR *)
66 :     | CRXOR (* cond. reg. XOR *)
67 :     | CRNAND (* cond. reg. NAND *)
68 :     | CRNOR (* cond. reg. NOR *)
69 :    
70 :     (* bits in condition code *)
71 :     datatype bit =
72 :     LT | GT | EQ | SO (* cr0 *)
73 :     | FL | FG | FE | FU (* cr1 *)
74 :     | FX | FEX | VX | OX
75 :    
76 :     type cr_bit = int * bit
77 :    
78 :     datatype instruction =
79 :     L of {sz:size, rt:int, ra:int, d:operand, mem:Region.region}
80 :     | ST of {sz:size, rs:int, ra:int, d:operand, mem:Region.region}
81 :     | UNARY of {oper:unary, rt:int, ra:int, Rc:bool, OE:bool}
82 :     | ARITH of {oper:arith, rt:int, ra:int, rb:int, Rc:bool, OE:bool}
83 :     | ARITHI of {oper:arith, rt:int, ra:int, im:operand}
84 :     | ROTATE of {oper:rotate, ra:int, rs:int, sh:operand, mb:int, me: int}
85 :     | COMPARE of {cmp:cmp, bf: int, ra:int, rb:operand}
86 :     | FCOMPARE of {cmp:fcmp, bf:int, fa:int, fb:int}
87 :    
88 :     | FUNARY of {oper:funary, ft:int, fb:int, Rc:bool}
89 :     | FARITH of {oper:farith, ft:int, fa:int, fb:int, Rc:bool}
90 :    
91 :     | CCARITH of {oper:ccarith, bt:cr_bit, ba:cr_bit, bb:cr_bit}
92 :     | MCRF of {bf:int, bfa:int}
93 :    
94 :     (* Special Purpose Registers *)
95 :     | MTSPR of {rs:int, spr:int}
96 :     | MFSPR of {rt:int, spr:int}
97 :    
98 :     (* Trapping Instructions *)
99 :     | TWI of {to:int, ra:int, si:operand}
100 :    
101 :     (* Control Instructions - AA is always assumed to be 0 *)
102 :     | BC of {bo:bo, bf:int, bit:bit, addr:operand, LK:bool, fall:operand}
103 :     | BCLR of {bo:bo, bf:int, bit:bit, LK:bool, labels:Label.label list}
104 :     | B of {addr:operand, LK:bool}
105 :    
106 :     (* CALL = BCLR {bo=ALWAYS, bf=0, bit=0, LK=true, labels=[] *)
107 :     | CALL of {def:C.cellset, use:C.cellset}
108 :    
109 :     | COPY of {dst:int list, src: int list, impl:instruction list option ref,
110 :     tmp: ea option}
111 :     | FCOPY of {dst: int list, src: int list, impl:instruction list option ref,
112 :     tmp: ea option}
113 :    
114 :     fun mtlr r = MTSPR{rs=r, spr=8}
115 :     fun ret() = BCLR{bo=ALWAYS, bf=0, bit=LT, LK=false, labels=[]}
116 :     end

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