base.isa (4172:141705d83494) base.isa (4362:95e5f28ce484)
1// Copyright (c) 2006-2007 The Regents of The University of Michigan
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met: redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer;
8// redistributions in binary form must reproduce the above copyright

--- 140 unchanged lines hidden (view full) ---

149
150def template ROrImmDecode {{
151 {
152 return (I ? (SparcStaticInst *)(new %(class_name)sImm(machInst))
153 : (SparcStaticInst *)(new %(class_name)s(machInst)));
154 }
155}};
156
1// Copyright (c) 2006-2007 The Regents of The University of Michigan
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met: redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer;
8// redistributions in binary form must reproduce the above copyright

--- 140 unchanged lines hidden (view full) ---

149
150def template ROrImmDecode {{
151 {
152 return (I ? (SparcStaticInst *)(new %(class_name)sImm(machInst))
153 : (SparcStaticInst *)(new %(class_name)s(machInst)));
154 }
155}};
156
157output header {{
158 union DoubleSingle
159 {
160 double d;
161 uint64_t ui;
162 uint32_t s[2];
163 DoubleSingle(double _d) : d(_d)
164 {}
165 DoubleSingle(uint64_t _ui) : ui(_ui)
166 {}
167 DoubleSingle(uint32_t _s0, uint32_t _s1)
168 {
169 s[0] = _s0;
170 s[1] = _s1;
171 }
172 };
173}};
174
157let {{
175let {{
176 def filterDoubles(code):
177 assignRE = re.compile(r'\s*=(?!=)', re.MULTILINE)
178 for opName in ("Frd", "Frs1", "Frs2", "Frd_N"):
179 next_pos = 0
180 operandsREString = (r'''
181 (?<![\w\.]) # neg. lookbehind assertion: prevent partial matches
182 ((%s)(?:\.(\w+))?) # match: operand with optional '.' then suffix
183 (?![\w\.]) # neg. lookahead assertion: prevent partial matches
184 ''' % opName)
185 operandsRE = re.compile(operandsREString, re.MULTILINE|re.VERBOSE)
186 is_src = False
187 is_dest = False
188 extension = None
189 foundOne = False
190 while 1:
191 match = operandsRE.search(code, next_pos)
192 if not match:
193 break
194 foundOne = True
195 op = match.groups()
196 (op_full, op_base, op_ext) = op
197 is_dest_local = (assignRE.match(code, match.end()) != None)
198 is_dest = is_dest or is_dest_local
199 is_src = is_src or not is_dest_local
200 if extension and extension != op_ext:
201 raise Exception, "Inconsistent extensions in double filter."
202 extension = op_ext
203 next_pos = match.end()
204 if foundOne:
205 # Get rid of any unwanted extension
206 code = operandsRE.sub(op_base, code)
207 is_int = False
208 member = "d"
209 if extension in ("sb", "ub", "shw", "uhw", "sw", "uw", "sdw", "udw"):
210 is_int = True
211 member = "ui"
212 if is_src:
213 code = ("%s = DoubleSingle(%s_high, %s_low).%s;" % \
214 (opName, opName, opName, member)) + code
215 if is_dest:
216 code += '''
217 %s_low = DoubleSingle(%s).s[1];
218 %s_high = DoubleSingle(%s).s[0];''' % \
219 (opName, opName, opName, opName)
220 if is_int:
221 code = ("uint64_t %s;" % opName) + code
222 else:
223 code = ("double %s;" % opName) + code
224 return code
225}};
226
227let {{
158 def splitOutImm(code):
159 matcher = re.compile(r'Rs(?P<rNum>\d)_or_imm(?P<iNum>\d+)(?P<typeQual>\.\w+)?')
160 rOrImmMatch = matcher.search(code)
161 if (rOrImmMatch == None):
162 return (False, code, '', '', '')
163 rString = rOrImmMatch.group("rNum")
164 if (rOrImmMatch.group("typeQual") != None):
165 rString += rOrImmMatch.group("typeQual")

--- 344 unchanged lines hidden ---
228 def splitOutImm(code):
229 matcher = re.compile(r'Rs(?P<rNum>\d)_or_imm(?P<iNum>\d+)(?P<typeQual>\.\w+)?')
230 rOrImmMatch = matcher.search(code)
231 if (rOrImmMatch == None):
232 return (False, code, '', '', '')
233 rString = rOrImmMatch.group("rNum")
234 if (rOrImmMatch.group("typeQual") != None):
235 rString += rOrImmMatch.group("typeQual")

--- 344 unchanged lines hidden ---