regop.isa (7789:f455790bcd47) | regop.isa (7894:48d31b577847) |
---|---|
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; | 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; |
|
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; | 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; |
|
151 } 152}}; 153 154output header {{ 155 void 156 divide(uint64_t dividend, uint64_t divisor, 157 uint64_t "ient, 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, \ | 153 } 154}}; 155 156output header {{ 157 void 158 divide(uint64_t dividend, uint64_t divisor, 159 uint64_t "ient, 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, \ |
226 code, flag_code, cond_check, else_code): | 228 code, flag_code, cond_check, else_code, cond_control_flag_init): |
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 | 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 |
234 allCode = "|".join((code, flag_code, cond_check, else_code)) | 236 allCode = "|".join((code, flag_code, cond_check, else_code, 237 cond_control_flag_init)) |
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), | 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), |
249 matcher.sub(src2_name, else_code)) | 252 matcher.sub(src2_name, else_code), 253 matcher.sub(src2_name, cond_control_flag_init)) |
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), | 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), |
255 matcher.sub(imm_name, else_code)) | 259 matcher.sub(imm_name, else_code), 260 matcher.sub(imm_name, cond_control_flag_init)) |
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, | 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, |
262 code, "", "true", else_code) | 267 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, | 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, |
299 "else_code" : else_code}) | 304 "else_code" : else_code, 305 "cond_control_flag_init": cond_control_flag_init}) |
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 | 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 |
|
322 323 # Set up the C++ classes | 329 330 # Set up the C++ classes |
324 mcls.buildCppClasses(cls, name, Name, "", 325 code, flag_code, cond_check, else_code) | 331 mcls.buildCppClasses(cls, name, Name, "", code, flag_code, 332 cond_check, else_code, cond_control_flag_init) |
326 327 # Hook into the microassembler dict 328 global microopClasses 329 microopClasses[name] = cls 330 | 333 334 # Hook into the microassembler dict 335 global microopClasses 336 microopClasses[name] = cls 337 |
331 allCode = "|".join((code, flag_code, cond_check, else_code)) | 338 allCode = "|".join((code, flag_code, cond_check, else_code, 339 cond_control_flag_init)) |
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 = ";" | 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 = "" |
|
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)" | 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];" |
|
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 --- | 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 --- |