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 }
139}};
140
141def template MicroRegOpImmConstructor {{
142 inline %(class_name)s::%(class_name)s(
143 ExtMachInst machInst, const char * instMnem, uint64_t setFlags,
144 InstRegIndex _src1, uint8_t _imm8, InstRegIndex _dest,
145 uint8_t _dataSize, uint16_t _ext) :
146 %(base_class)s(machInst, "%(mnemonic)s", instMnem, setFlags,
147 _src1, _imm8, _dest, _dataSize, _ext,
148 %(op_class)s)
149 {
150 %(constructor)s;
151 }
152}};
153
154output header {{
155 void
156 divide(uint64_t dividend, uint64_t divisor,
157 uint64_t &quotient, uint64_t &remainder);
158

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

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

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

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

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

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

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

397 class SubRegOp(RegOp):
398 abstract = True
399 flag_code = \
400 "ccFlagBits = genFlags(ccFlagBits, ext, DestReg, psrc1, ~op2, true);"
401
402 class CondRegOp(RegOp):
403 abstract = True
404 cond_check = "checkCondition(ccFlagBits, ext)"
405
406 class RdRegOp(RegOp):
407 abstract = True
408 def __init__(self, dest, src1=None, dataSize="env.dataSize"):
409 if not src1:
410 src1 = dest
411 super(RdRegOp, self).__init__(dest, src1, \
412 "InstRegIndex(NUM_INTREGS)", None, dataSize)

--- 975 unchanged lines hidden ---