1// Copyright (c) 2007-2008 The Hewlett-Packard Development Company 2// Copyright (c) 2015 Advanced Micro Devices, Inc. 3// All rights reserved. 4// 5// The license below extends only to copyright in the software and shall 6// not be construed as granting a license to any other intellectual 7// property including but not limited to intellectual property relating 8// to a hardware implementation of the functionality of the software --- 301 unchanged lines hidden (view full) --- 310 { 311 %(constructor)s; 312 } 313}}; 314 315let {{ 316 class LdStOp(X86Microop): 317 def __init__(self, data, segment, addr, disp, |
318 dataSize, addressSize, baseFlags, atCPL0, prefetch, nonSpec, 319 implicitStack): |
320 self.data = data 321 [self.scale, self.index, self.base] = addr 322 self.disp = disp 323 self.segment = segment 324 self.dataSize = dataSize 325 self.addressSize = addressSize 326 self.memFlags = baseFlags 327 if atCPL0: 328 self.memFlags += " | (CPL0FlagBit << FlagShift)" 329 self.instFlags = "" 330 if prefetch: 331 self.memFlags += " | Request::PREFETCH" 332 self.instFlags += " | (1ULL << StaticInst::IsDataPrefetch)" 333 if nonSpec: 334 self.instFlags += " | (1ULL << StaticInst::IsNonSpeculative)" |
335 # For implicit stack operations, we should use *not* use the 336 # alternative addressing mode for loads/stores if the prefix is set 337 if not implicitStack: 338 self.memFlags += " | (machInst.legacy.addr ? " + \ 339 "(AddrSizeFlagBit << FlagShift) : 0)" |
340 341 def getAllocator(self, microFlags): 342 allocator = '''new %(class_name)s(machInst, macrocodeBlock, 343 %(flags)s, %(scale)s, %(index)s, %(base)s, 344 %(disp)s, %(segment)s, %(data)s, 345 %(dataSize)s, %(addressSize)s, %(memFlags)s)''' % { 346 "class_name" : self.className, 347 "flags" : self.microFlagsText(microFlags) + self.instFlags, 348 "scale" : self.scale, "index" : self.index, 349 "base" : self.base, 350 "disp" : self.disp, 351 "segment" : self.segment, "data" : self.data, 352 "dataSize" : self.dataSize, "addressSize" : self.addressSize, 353 "memFlags" : self.memFlags} 354 return allocator 355 356 class BigLdStOp(X86Microop): 357 def __init__(self, data, segment, addr, disp, |
358 dataSize, addressSize, baseFlags, atCPL0, prefetch, nonSpec, 359 implicitStack): |
360 self.data = data 361 [self.scale, self.index, self.base] = addr 362 self.disp = disp 363 self.segment = segment 364 self.dataSize = dataSize 365 self.addressSize = addressSize 366 self.memFlags = baseFlags 367 if atCPL0: 368 self.memFlags += " | (CPL0FlagBit << FlagShift)" 369 self.instFlags = "" 370 if prefetch: 371 self.memFlags += " | Request::PREFETCH" 372 self.instFlags += " | (1ULL << StaticInst::IsDataPrefetch)" 373 if nonSpec: 374 self.instFlags += " | (1ULL << StaticInst::IsNonSpeculative)" |
375 # For implicit stack operations, we should use *not* use the 376 # alternative addressing mode for loads/stores if the prefix is set 377 if not implicitStack: 378 self.memFlags += " | (machInst.legacy.addr ? " + \ 379 "(AddrSizeFlagBit << FlagShift) : 0)" |
380 381 def getAllocator(self, microFlags): 382 allocString = ''' 383 (%(dataSize)s >= 4) ? 384 (StaticInstPtr)(new %(class_name)sBig(machInst, 385 macrocodeBlock, %(flags)s, %(scale)s, %(index)s, 386 %(base)s, %(disp)s, %(segment)s, %(data)s, 387 %(dataSize)s, %(addressSize)s, %(memFlags)s)) : --- 10 unchanged lines hidden (view full) --- 398 "disp" : self.disp, 399 "segment" : self.segment, "data" : self.data, 400 "dataSize" : self.dataSize, "addressSize" : self.addressSize, 401 "memFlags" : self.memFlags} 402 return allocator 403 404 class LdStSplitOp(LdStOp): 405 def __init__(self, data, segment, addr, disp, |
406 dataSize, addressSize, baseFlags, atCPL0, prefetch, nonSpec, 407 implicitStack): |
408 super(LdStSplitOp, self).__init__(0, segment, addr, disp, |
409 dataSize, addressSize, baseFlags, atCPL0, prefetch, nonSpec, 410 implicitStack) |
411 (self.dataLow, self.dataHi) = data 412 413 def getAllocator(self, microFlags): 414 allocString = '''(StaticInstPtr)(new %(class_name)s(machInst, 415 macrocodeBlock, %(flags)s, %(scale)s, %(index)s, 416 %(base)s, %(disp)s, %(segment)s, 417 %(dataLow)s, %(dataHi)s, 418 %(dataSize)s, %(addressSize)s, %(memFlags)s)) --- 21 unchanged lines hidden (view full) --- 440 exec_output = "" 441 442 segmentEAExpr = \ 443 'bits(scale * Index + Base + disp, addressSize * 8 - 1, 0);' 444 445 calculateEA = 'EA = SegBase + ' + segmentEAExpr 446 447 def defineMicroLoadOp(mnemonic, code, bigCode='', |
448 mem_flags="0", big=True, nonSpec=False, 449 implicitStack=False): |
450 global header_output 451 global decoder_output 452 global exec_output 453 global microopClasses 454 Name = mnemonic 455 name = mnemonic.lower() 456 457 # Build up the all register version of this micro op --- 8 unchanged lines hidden (view full) --- 466 "memDataSize": "dataSize" })] 467 for iop in iops: 468 header_output += MicroLdStOpDeclare.subst(iop) 469 decoder_output += MicroLdStOpConstructor.subst(iop) 470 exec_output += MicroLoadExecute.subst(iop) 471 exec_output += MicroLoadInitiateAcc.subst(iop) 472 exec_output += MicroLoadCompleteAcc.subst(iop) 473 |
474 if implicitStack: 475 # For instructions that implicitly access the stack, the address 476 # size is the same as the stack segment pointer size, not the 477 # address size if specified by the instruction prefix 478 addressSize = "env.stackSize" 479 else: 480 addressSize = "env.addressSize" 481 |
482 base = LdStOp 483 if big: 484 base = BigLdStOp 485 class LoadOp(base): 486 def __init__(self, data, segment, addr, disp = 0, 487 dataSize="env.dataSize", |
488 addressSize=addressSize, 489 atCPL0=False, prefetch=False, nonSpec=nonSpec, 490 implicitStack=implicitStack): |
491 super(LoadOp, self).__init__(data, segment, addr, 492 disp, dataSize, addressSize, mem_flags, |
493 atCPL0, prefetch, nonSpec, implicitStack) |
494 self.className = Name 495 self.mnemonic = name 496 497 microopClasses[name] = LoadOp 498 499 defineMicroLoadOp('Ld', 'Data = merge(Data, Mem, dataSize);', 500 'Data = Mem & mask(dataSize * 8);') |
501 defineMicroLoadOp('Ldis', 'Data = merge(Data, Mem, dataSize);', 502 'Data = Mem & mask(dataSize * 8);', 503 implicitStack=True) |
504 defineMicroLoadOp('Ldst', 'Data = merge(Data, Mem, dataSize);', 505 'Data = Mem & mask(dataSize * 8);', 506 '(StoreCheck << FlagShift)') 507 defineMicroLoadOp('Ldstl', 'Data = merge(Data, Mem, dataSize);', 508 'Data = Mem & mask(dataSize * 8);', 509 '(StoreCheck << FlagShift) | Request::LOCKED_RMW', 510 nonSpec=True) 511 --- 50 unchanged lines hidden (view full) --- 562 exec_output += MicroLoadExecute.subst(iop) 563 exec_output += MicroLoadInitiateAcc.subst(iop) 564 exec_output += MicroLoadCompleteAcc.subst(iop) 565 566 class LoadOp(LdStSplitOp): 567 def __init__(self, data, segment, addr, disp = 0, 568 dataSize="env.dataSize", 569 addressSize="env.addressSize", |
570 atCPL0=False, prefetch=False, nonSpec=nonSpec, 571 implicitStack=False): |
572 super(LoadOp, self).__init__(data, segment, addr, 573 disp, dataSize, addressSize, mem_flags, |
574 atCPL0, prefetch, nonSpec, implicitStack) |
575 self.className = Name 576 self.mnemonic = name 577 578 microopClasses[name] = LoadOp 579 580 code = ''' 581 switch (dataSize) { 582 case 4: --- 10 unchanged lines hidden (view full) --- 593 594 defineMicroLoadSplitOp('LdSplit', code, 595 '(StoreCheck << FlagShift)') 596 597 defineMicroLoadSplitOp('LdSplitl', code, 598 '(StoreCheck << FlagShift) | Request::LOCKED_RMW', 599 nonSpec=True) 600 |
601 def defineMicroStoreOp(mnemonic, code, completeCode="", mem_flags="0", 602 implicitStack=False): |
603 global header_output 604 global decoder_output 605 global exec_output 606 global microopClasses 607 Name = mnemonic 608 name = mnemonic.lower() 609 610 # Build up the all register version of this micro op 611 iop = InstObjParams(name, Name, 'X86ISA::LdStOp', 612 { "code": code, 613 "complete_code": completeCode, 614 "ea_code": calculateEA, 615 "memDataSize": "dataSize" }) 616 header_output += MicroLdStOpDeclare.subst(iop) 617 decoder_output += MicroLdStOpConstructor.subst(iop) 618 exec_output += MicroStoreExecute.subst(iop) 619 exec_output += MicroStoreInitiateAcc.subst(iop) 620 exec_output += MicroStoreCompleteAcc.subst(iop) 621 |
622 if implicitStack: 623 # For instructions that implicitly access the stack, the address 624 # size is the same as the stack segment pointer size, not the 625 # address size if specified by the instruction prefix 626 addressSize = "env.stackSize" 627 else: 628 addressSize = "env.addressSize" 629 |
630 class StoreOp(LdStOp): 631 def __init__(self, data, segment, addr, disp = 0, 632 dataSize="env.dataSize", |
633 addressSize=addressSize, 634 atCPL0=False, nonSpec=False, implicitStack=implicitStack): |
635 super(StoreOp, self).__init__(data, segment, addr, disp, 636 dataSize, addressSize, mem_flags, atCPL0, False, |
637 nonSpec, implicitStack) |
638 self.className = Name 639 self.mnemonic = name 640 641 microopClasses[name] = StoreOp 642 643 defineMicroStoreOp('St', 'Mem = pick(Data, 2, dataSize);') |
644 defineMicroStoreOp('Stis', 'Mem = pick(Data, 2, dataSize);', 645 implicitStack=True) |
646 defineMicroStoreOp('Stul', 'Mem = pick(Data, 2, dataSize);', 647 mem_flags="Request::LOCKED_RMW") 648 649 defineMicroStoreOp('Stfp', code='Mem = FpData_uqw;') 650 651 defineMicroStoreOp('Stfp87', code=''' 652 switch (dataSize) 653 { --- 31 unchanged lines hidden (view full) --- 685 exec_output += MicroStoreExecute.subst(iop) 686 exec_output += MicroStoreInitiateAcc.subst(iop) 687 exec_output += MicroStoreCompleteAcc.subst(iop) 688 689 class StoreOp(LdStSplitOp): 690 def __init__(self, data, segment, addr, disp = 0, 691 dataSize="env.dataSize", 692 addressSize="env.addressSize", |
693 atCPL0=False, nonSpec=False, implicitStack=False): |
694 super(StoreOp, self).__init__(data, segment, addr, disp, 695 dataSize, addressSize, mem_flags, atCPL0, False, |
696 nonSpec, implicitStack) |
697 self.className = Name 698 self.mnemonic = name 699 700 microopClasses[name] = StoreOp 701 702 code = ''' 703 switch (dataSize) { 704 case 4: --- 19 unchanged lines hidden (view full) --- 724 header_output += MicroLeaDeclare.subst(iop) 725 decoder_output += MicroLdStOpConstructor.subst(iop) 726 exec_output += MicroLeaExecute.subst(iop) 727 728 class LeaOp(LdStOp): 729 def __init__(self, data, segment, addr, disp = 0, 730 dataSize="env.dataSize", addressSize="env.addressSize"): 731 super(LeaOp, self).__init__(data, segment, addr, disp, |
732 dataSize, addressSize, "0", False, False, False, False) |
733 self.className = "Lea" 734 self.mnemonic = "lea" 735 736 microopClasses["lea"] = LeaOp 737 738 739 iop = InstObjParams("tia", "Tia", 'X86ISA::LdStOp', 740 { "code": "xc->demapPage(EA, 0);", --- 4 unchanged lines hidden (view full) --- 745 exec_output += MicroLeaExecute.subst(iop) 746 747 class TiaOp(LdStOp): 748 def __init__(self, segment, addr, disp = 0, 749 dataSize="env.dataSize", 750 addressSize="env.addressSize"): 751 super(TiaOp, self).__init__("InstRegIndex(NUM_INTREGS)", segment, 752 addr, disp, dataSize, addressSize, "0", False, False, |
753 False, False) |
754 self.className = "Tia" 755 self.mnemonic = "tia" 756 757 microopClasses["tia"] = TiaOp 758 759 class CdaOp(LdStOp): 760 def __init__(self, segment, addr, disp = 0, 761 dataSize="env.dataSize", 762 addressSize="env.addressSize", atCPL0=False): 763 super(CdaOp, self).__init__("InstRegIndex(NUM_INTREGS)", segment, 764 addr, disp, dataSize, addressSize, "Request::NO_ACCESS", |
765 atCPL0, False, False, False) |
766 self.className = "Cda" 767 self.mnemonic = "cda" 768 769 microopClasses["cda"] = CdaOp 770}}; |