Deleted Added
sdiff udiff text old ( 7789:f455790bcd47 ) new ( 7894:48d31b577847 )
full compact
1// Copyright (c) 2007-2008 The Hewlett-Packard Development Company
2// All rights reserved.
3//
4// The license below extends only to copyright in the software and shall
5// not be construed as granting a license to any other intellectual
6// property including but not limited to intellectual property relating
7// to a hardware implementation of the functionality of the software
8// licensed hereunder. You may use the software subject to the license

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

130 ExtMachInst machInst, const char * instMnem, uint64_t setFlags,
131 InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
132 uint8_t _dataSize, uint16_t _ext) :
133 %(base_class)s(machInst, "%(mnemonic)s", instMnem, setFlags,
134 _src1, _src2, _dest, _dataSize, _ext,
135 %(op_class)s)
136 {
137 %(constructor)s;
138 %(cond_control_flag_init)s;
139 }
140}};
141
142def template MicroRegOpImmConstructor {{
143 inline %(class_name)s::%(class_name)s(
144 ExtMachInst machInst, const char * instMnem, uint64_t setFlags,
145 InstRegIndex _src1, uint8_t _imm8, InstRegIndex _dest,
146 uint8_t _dataSize, uint16_t _ext) :
147 %(base_class)s(machInst, "%(mnemonic)s", instMnem, setFlags,
148 _src1, _imm8, _dest, _dataSize, _ext,
149 %(op_class)s)
150 {
151 %(constructor)s;
152 %(cond_control_flag_init)s;
153 }
154}};
155
156output header {{
157 void
158 divide(uint64_t dividend, uint64_t divisor,
159 uint64_t &quotient, uint64_t &remainder);
160

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

220
221 regTemplates = (
222 MicroRegOpDeclare,
223 MicroRegOpConstructor,
224 MicroRegOpExecute)
225
226 class RegOpMeta(type):
227 def buildCppClasses(self, name, Name, suffix, \
228 code, flag_code, cond_check, else_code, cond_control_flag_init):
229
230 # Globals to stick the output in
231 global header_output
232 global decoder_output
233 global exec_output
234
235 # Stick all the code together so it can be searched at once
236 allCode = "|".join((code, flag_code, cond_check, else_code,
237 cond_control_flag_init))
238
239 # If op2 is used anywhere, make register and immediate versions
240 # of this code.
241 matcher = re.compile("(?<!\\w)(?P<prefix>s?)op2(?P<typeQual>\\.\\w+)?")
242 match = matcher.search(allCode)
243 if match:
244 typeQual = ""
245 if match.group("typeQual"):
246 typeQual = match.group("typeQual")
247 src2_name = "%spsrc2%s" % (match.group("prefix"), typeQual)
248 self.buildCppClasses(name, Name, suffix,
249 matcher.sub(src2_name, code),
250 matcher.sub(src2_name, flag_code),
251 matcher.sub(src2_name, cond_check),
252 matcher.sub(src2_name, else_code),
253 matcher.sub(src2_name, cond_control_flag_init))
254 imm_name = "%simm8" % match.group("prefix")
255 self.buildCppClasses(name + "i", Name, suffix + "Imm",
256 matcher.sub(imm_name, code),
257 matcher.sub(imm_name, flag_code),
258 matcher.sub(imm_name, cond_check),
259 matcher.sub(imm_name, else_code),
260 matcher.sub(imm_name, cond_control_flag_init))
261 return
262
263 # If there's something optional to do with flags, generate
264 # a version without it and fix up this version to use it.
265 if flag_code != "" or cond_check != "true":
266 self.buildCppClasses(name, Name, suffix,
267 code, "", "true", else_code, "")
268 suffix = "Flags" + suffix
269
270 # If psrc1 or psrc2 is used, we need to actually insert code to
271 # compute it.
272 matcher = re.compile("(?<!\w)psrc1(?!\w)")
273 if matcher.search(allCode):
274 code = "uint64_t psrc1 = pick(SrcReg1, 0, dataSize);" + code
275 matcher = re.compile("(?<!\w)psrc2(?!\w)")

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

296 base += "Imm"
297 templates = immTemplates
298
299 # Get everything ready for the substitution
300 iop = InstObjParams(name, Name + suffix, base,
301 {"code" : code,
302 "flag_code" : flag_code,
303 "cond_check" : cond_check,
304 "else_code" : else_code,
305 "cond_control_flag_init": cond_control_flag_init})
306
307 # Generate the actual code (finally!)
308 header_output += templates[0].subst(iop)
309 decoder_output += templates[1].subst(iop)
310 exec_output += templates[2].subst(iop)
311
312
313 def __new__(mcls, Name, bases, dict):

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

320 cls = super(RegOpMeta, mcls).__new__(mcls, Name, bases, dict)
321 if not abstract:
322 cls.className = Name
323 cls.base_mnemonic = name
324 code = cls.code
325 flag_code = cls.flag_code
326 cond_check = cls.cond_check
327 else_code = cls.else_code
328 cond_control_flag_init = cls.cond_control_flag_init
329
330 # Set up the C++ classes
331 mcls.buildCppClasses(cls, name, Name, "", code, flag_code,
332 cond_check, else_code, cond_control_flag_init)
333
334 # Hook into the microassembler dict
335 global microopClasses
336 microopClasses[name] = cls
337
338 allCode = "|".join((code, flag_code, cond_check, else_code,
339 cond_control_flag_init))
340
341 # If op2 is used anywhere, make register and immediate versions
342 # of this code.
343 matcher = re.compile("op2(?P<typeQual>\\.\\w+)?")
344 if matcher.search(allCode):
345 microopClasses[name + 'i'] = cls
346 return cls
347
348
349 class RegOp(X86Microop):
350 __metaclass__ = RegOpMeta
351 # This class itself doesn't act as a microop
352 abstract = True
353
354 # Default template parameter values
355 flag_code = ""
356 cond_check = "true"
357 else_code = ";"
358 cond_control_flag_init = ""
359
360 def __init__(self, dest, src1, op2, flags = None, dataSize = "env.dataSize"):
361 self.dest = dest
362 self.src1 = src1
363 self.op2 = op2
364 self.flags = flags
365 self.dataSize = dataSize
366 if flags is None:

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

406 class SubRegOp(RegOp):
407 abstract = True
408 flag_code = \
409 "ccFlagBits = genFlags(ccFlagBits, ext, DestReg, psrc1, ~op2, true);"
410
411 class CondRegOp(RegOp):
412 abstract = True
413 cond_check = "checkCondition(ccFlagBits, ext)"
414 cond_control_flag_init = "flags[IsCondControl] = flags[IsControl];"
415
416 class RdRegOp(RegOp):
417 abstract = True
418 def __init__(self, dest, src1=None, dataSize="env.dataSize"):
419 if not src1:
420 src1 = dest
421 super(RdRegOp, self).__init__(dest, src1, \
422 "InstRegIndex(NUM_INTREGS)", None, dataSize)

--- 975 unchanged lines hidden ---