Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | # ========== Copyright Header Begin ========================================== |
2 | # | |
3 | # OpenSPARC T2 Processor File: SS_InstrFpop.py | |
4 | # Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
5 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
6 | # | |
7 | # The above named program is free software; you can redistribute it and/or | |
8 | # modify it under the terms of the GNU General Public | |
9 | # License version 2 as published by the Free Software Foundation. | |
10 | # | |
11 | # The above named program is distributed in the hope that it will be | |
12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | # General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public | |
17 | # License along with this work; if not, write to the Free Software | |
18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | # | |
20 | # ========== Copyright Header End ============================================ | |
21 | from SS_Instr import * | |
22 | ||
23 | #============================================================================ | |
24 | # SS_fpop base for the floating point operations | |
25 | #============================================================================ | |
26 | ||
27 | class SS_fpop(SS_InstrAsm): | |
28 | def __init__(self,opc): | |
29 | SS_InstrAsm.__init__(self,opc) | |
30 | self.opc = opc | |
31 | ||
32 | def fpop_init(self,file): | |
33 | self.s_code(file,'run_exe_') | |
34 | self.ld_sim(file,'%g5') | |
35 | self.st_fsr_cpu(file,'%fsr') | |
36 | self.ld_fsr_run(file,'%fsr') | |
37 | self.ld_gsr(file,'%g1') | |
38 | self.andcc(file,'%g5','F_FP_DISABLED','%g0') | |
39 | self.branch(file,'ne','%xcc','fpop_disabled_trap_fsr') | |
40 | self.rd_gsr(file,'%g5') | |
41 | self.wr_gsr(file,'%g1') | |
42 | ||
43 | def fpop_fini_d(self,file): | |
44 | self.branch(file,'a,a','%xcc','fpop_retl_d') | |
45 | self.nop(file) | |
46 | ||
47 | def fpop_fini_f(self,file): | |
48 | self.branch(file,'a,a','%xcc','fpop_retl_f') | |
49 | self.nop(file) | |
50 | ||
51 | def fpop_fini_cc_d(self,file,cc,ccr): | |
52 | global inv_rcond | |
53 | # brcc have 16bit offset only which is killing us, so for brcc we | |
54 | # do the opposite and branch over if not(cc) and ba,a to fpop_retl_d | |
55 | if cc[0] == 'r': | |
56 | self.branch(file,'r'+inv_rcond[cc[1:]]+',a','%'+ccr,'1f') | |
57 | self.nop(file) | |
58 | self.branch(file,'a,a','%xcc','fpop_retl_d') | |
59 | self.nop(file) | |
60 | file.write('1:\n') | |
61 | self.fpop_fini(file) | |
62 | else: | |
63 | self.branch(file,cc+',a','%'+ccr,'fpop_retl_d') | |
64 | self.nop(file) | |
65 | self.fpop_fini(file) | |
66 | ||
67 | def fpop_fini_cc_f(self,file,cc,ccr): | |
68 | global inv_rcond | |
69 | # brcc have 16bit offset only which is killing us, so for brcc we | |
70 | # do the opposite and branch over if not(cc) and ba,a to fpop_retl_d | |
71 | if cc[0] == 'r': | |
72 | self.branch(file,'r'+inv_rcond[cc[1:]]+',a','%'+ccr,'1f') | |
73 | self.nop(file) | |
74 | self.branch(file,'a,a','%xcc','fpop_retl_f') | |
75 | self.nop(file) | |
76 | file.write('1:\n') | |
77 | self.fpop_fini(file) | |
78 | else: | |
79 | self.branch(file,cc+',a','%'+ccr,'fpop_retl_f') | |
80 | self.nop(file) | |
81 | self.fpop_fini(file) | |
82 | ||
83 | def fpop_fini(self,file): | |
84 | self.branch(file,'a,a','%xcc','fpop_retl') | |
85 | self.nop(file) | |
86 | ||
87 | def gen_exe_tbl(self,file,mode): | |
88 | if mode == 'v8_run': | |
89 | mode = 'run' | |
90 | if mode == 'run' or mode == 'trc': | |
91 | file.write(' %s_exe_%s,\n' % (setup.product.lower(),self.name)) | |
92 | else: | |
93 | file.write(' %s_exe_%s,\n' % (mode,self.name)) | |
94 | ||
95 | ||
96 | #============================================================================ | |
97 | # SS_fp_f0f | |
98 | #============================================================================ | |
99 | ||
100 | class SS_fp_f0f(SS_fpop): | |
101 | def __init__(self,opc): | |
102 | SS_fpop.__init__(self,opc) | |
103 | ||
104 | def run_exe_c(self,file,product='run'): | |
105 | SS_fpop.run_exe_c(self,file,setup.product.lower()) | |
106 | ||
107 | def run_dec_c(self,file): | |
108 | self.c_code_dec_beg_name(file,'run_dec_'+self.opc) | |
109 | file.write(' i->flg = SS_Instr::NON_LSU;\n') | |
110 | file.write(' if (o.get_rs1() != 0)\n') | |
111 | file.write(' return (s->trap)(pc,npc,s,i,SS_Trap::ILLEGAL_INSTRUCTION);\n') | |
112 | file.write(' else\n') | |
113 | file.write(' {\n') | |
114 | self.ill_ibe(file) | |
115 | self.dec_f0f(file,' ','idx_exe_'+self.opc) | |
116 | file.write(' }\n') | |
117 | self.c_code_end(file) | |
118 | ||
119 | def gen_exe_tbl(self,file,mode): | |
120 | if mode == 'trc': | |
121 | file.write(' trc_exe_f0f, /* '+self.name+' */\n') | |
122 | else: | |
123 | SS_fpop.gen_exe_tbl(self,file,mode) | |
124 | ||
125 | ||
126 | #============================================================================ | |
127 | # SS_fp_f0d | |
128 | #============================================================================ | |
129 | ||
130 | class SS_fp_f0d(SS_fpop): | |
131 | def __init__(self,opc): | |
132 | SS_fpop.__init__(self,opc) | |
133 | ||
134 | def run_exe_c(self,file,product='run'): | |
135 | SS_fpop.run_exe_c(self,file,setup.product.lower()) | |
136 | ||
137 | def run_dec_c(self,file): | |
138 | self.c_code_dec_beg_name(file,'run_dec_'+self.opc) | |
139 | file.write(' i->flg = SS_Instr::NON_LSU;\n') | |
140 | file.write(' if (o.get_rs1() != 0)\n') | |
141 | file.write(' return (s->trap)(pc,npc,s,i,SS_Trap::ILLEGAL_INSTRUCTION);\n') | |
142 | file.write(' else\n') | |
143 | file.write(' {\n') | |
144 | self.ill_ibe(file) | |
145 | self.dec_f0d(file,' ','idx_exe_'+self.opc) | |
146 | file.write(' }\n') | |
147 | self.c_code_end(file) | |
148 | ||
149 | def gen_exe_tbl(self,file,mode): | |
150 | if mode == 'trc': | |
151 | file.write(' trc_exe_f0d, /* '+self.name+' */\n') | |
152 | else: | |
153 | SS_fpop.gen_exe_tbl(self,file,mode) | |
154 | ||
155 | ||
156 | #============================================================================ | |
157 | # SS_fp_d0d | |
158 | #============================================================================ | |
159 | ||
160 | class SS_fp_d0d(SS_fpop): | |
161 | def __init__(self,opc): | |
162 | SS_fpop.__init__(self,opc) | |
163 | ||
164 | def run_exe_c(self,file,product='run'): | |
165 | SS_fpop.run_exe_c(self,file,setup.product.lower()) | |
166 | ||
167 | def run_dec_c(self,file): | |
168 | self.c_code_dec_beg_name(file,'run_dec_'+self.opc) | |
169 | file.write(' i->flg = SS_Instr::NON_LSU;\n') | |
170 | file.write(' if (o.get_rs1() != 0)\n') | |
171 | file.write(' return (s->trap)(pc,npc,s,i,SS_Trap::ILLEGAL_INSTRUCTION);\n') | |
172 | file.write(' else\n') | |
173 | file.write(' {\n') | |
174 | self.ill_ibe(file) | |
175 | self.dec_d0d(file,' ','idx_exe_'+self.opc) | |
176 | file.write(' }\n') | |
177 | self.c_code_end(file) | |
178 | ||
179 | def gen_exe_tbl(self,file,mode): | |
180 | if mode == 'trc': | |
181 | file.write(' trc_exe_d0d, /* '+self.name+' */\n') | |
182 | else: | |
183 | SS_fpop.gen_exe_tbl(self,file,mode) | |
184 | ||
185 | ||
186 | #============================================================================ | |
187 | # SS_fp_d0f | |
188 | #============================================================================ | |
189 | ||
190 | class SS_fp_d0f(SS_fpop): | |
191 | def __init__(self,opc): | |
192 | SS_fpop.__init__(self,opc) | |
193 | ||
194 | def run_exe_c(self,file,product='run'): | |
195 | SS_fpop.run_exe_c(self,file,setup.product.lower()) | |
196 | ||
197 | def run_dec_c(self,file): | |
198 | self.c_code_dec_beg_name(file,'run_dec_'+self.opc) | |
199 | file.write(' i->flg = SS_Instr::NON_LSU;\n') | |
200 | file.write(' if (o.get_rs1() != 0)\n') | |
201 | file.write(' return (s->trap)(pc,npc,s,i,SS_Trap::ILLEGAL_INSTRUCTION);\n') | |
202 | file.write(' else\n') | |
203 | file.write(' {\n') | |
204 | self.ill_ibe(file) | |
205 | self.dec_d0f(file,' ','idx_exe_'+self.opc) | |
206 | file.write(' }\n') | |
207 | self.c_code_end(file) | |
208 | ||
209 | def gen_exe_tbl(self,file,mode): | |
210 | if mode == 'trc': | |
211 | file.write(' trc_exe_d0f, /* '+self.name+' */\n') | |
212 | else: | |
213 | SS_fpop.gen_exe_tbl(self,file,mode) | |
214 | ||
215 | ||
216 | #============================================================================ | |
217 | # SS_fp_fff | |
218 | #============================================================================ | |
219 | ||
220 | class SS_fp_fff(SS_fpop): | |
221 | def __init__(self,opc): | |
222 | SS_fpop.__init__(self,opc) | |
223 | ||
224 | def run_exe_c(self,file,product='run'): | |
225 | SS_fpop.run_exe_c(self,file,setup.product.lower()) | |
226 | ||
227 | def run_dec_c(self,file): | |
228 | self.c_code_dec_beg_name(file,'run_dec_'+self.opc) | |
229 | file.write(' i->flg = SS_Instr::NON_LSU;\n') | |
230 | self.ill_ibe(file) | |
231 | self.dec_fff(file,'','idx_exe_'+self.opc) | |
232 | self.c_code_end(file) | |
233 | ||
234 | def gen_exe_tbl(self,file,mode): | |
235 | if mode == 'trc': | |
236 | file.write(' trc_exe_fff, /* '+self.name+' */\n') | |
237 | else: | |
238 | SS_fpop.gen_exe_tbl(self,file,mode) | |
239 | ||
240 | ||
241 | #============================================================================ | |
242 | # SS_fp_ddd | |
243 | #============================================================================ | |
244 | ||
245 | class SS_fp_ddd(SS_fpop): | |
246 | def __init__(self,opc): | |
247 | SS_fpop.__init__(self,opc) | |
248 | ||
249 | def run_exe_c(self,file,product='run'): | |
250 | SS_fpop.run_exe_c(self,file,setup.product.lower()) | |
251 | ||
252 | def run_dec_c(self,file): | |
253 | self.c_code_dec_beg_name(file,'run_dec_'+self.opc) | |
254 | file.write(' i->flg = SS_Instr::NON_LSU;\n') | |
255 | self.ill_ibe(file) | |
256 | self.dec_ddd(file,'','idx_exe_'+self.opc) | |
257 | self.c_code_end(file) | |
258 | ||
259 | def gen_exe_tbl(self,file,mode): | |
260 | if mode == 'trc': | |
261 | file.write(' trc_exe_ddd, /* '+self.name+' */\n') | |
262 | else: | |
263 | SS_fpop.gen_exe_tbl(self,file,mode) | |
264 | ||
265 | ||
266 | #============================================================================ | |
267 | # SS_fp_dff | |
268 | #============================================================================ | |
269 | ||
270 | class SS_fp_dff(SS_fpop): | |
271 | def __init__(self,opc): | |
272 | SS_fpop.__init__(self,opc) | |
273 | ||
274 | def run_exe_c(self,file,product='run'): | |
275 | SS_fpop.run_exe_c(self,file,setup.product.lower()) | |
276 | ||
277 | def run_dec_c(self,file): | |
278 | self.c_code_dec_beg_name(file,'run_dec_'+self.opc) | |
279 | file.write(' i->flg = SS_Instr::NON_LSU;\n') | |
280 | self.ill_ibe(file) | |
281 | self.dec_dff(file,'','idx_exe_'+self.opc) | |
282 | self.c_code_end(file) | |
283 | ||
284 | def gen_exe_tbl(self,file,mode): | |
285 | if mode == 'trc': | |
286 | file.write(' trc_exe_dff, /* '+self.name+' */\n') | |
287 | else: | |
288 | SS_fpop.gen_exe_tbl(self,file,mode) | |
289 | ||
290 | ||
291 | #============================================================================ | |
292 | # SS_fp_ffff | |
293 | #============================================================================ | |
294 | ||
295 | class SS_fp_ffff(SS_fpop): | |
296 | def __init__(self,opc): | |
297 | SS_fpop.__init__(self,opc) | |
298 | ||
299 | def run_exe_c(self,file,product='run'): | |
300 | SS_fpop.run_exe_c(self,file,setup.product.lower()) | |
301 | ||
302 | def run_dec_c(self,file): | |
303 | self.c_code_dec_beg_name(file,'run_dec_'+self.opc) | |
304 | file.write(' i->flg = SS_Instr::NON_LSU;\n') | |
305 | self.ill_ibe(file) | |
306 | self.dec_ffff(file,'','idx_exe_'+self.opc) | |
307 | self.c_code_end(file) | |
308 | ||
309 | def gen_exe_tbl(self,file,mode): | |
310 | if mode == 'trc': | |
311 | file.write(' trc_exe_ffff, /* '+self.name+' */\n') | |
312 | else: | |
313 | SS_fpop.gen_exe_tbl(self,file,mode) | |
314 | ||
315 | ||
316 | #============================================================================ | |
317 | # SS_fp_dddd | |
318 | #============================================================================ | |
319 | ||
320 | class SS_fp_dddd(SS_fpop): | |
321 | def __init__(self,opc): | |
322 | SS_fpop.__init__(self,opc) | |
323 | ||
324 | def run_exe_c(self,file,product='run'): | |
325 | SS_fpop.run_exe_c(self,file,setup.product.lower()) | |
326 | ||
327 | def run_dec_c(self,file): | |
328 | self.c_code_dec_beg_name(file,'run_dec_'+self.opc) | |
329 | file.write(' i->flg = SS_Instr::NON_LSU;\n') | |
330 | self.ill_ibe(file) | |
331 | self.dec_dddd(file,'','idx_exe_'+self.opc) | |
332 | self.c_code_end(file) | |
333 | ||
334 | def gen_exe_tbl(self,file,mode): | |
335 | if mode == 'trc': | |
336 | file.write(' trc_exe_dddd, /* '+self.name+' */\n') | |
337 | else: | |
338 | SS_fpop.gen_exe_tbl(self,file,mode) |