regop.isa (11320:42ecb523c64a) | regop.isa (12025:fbfb3dd3f324) |
---|---|
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 --- 532 unchanged lines hidden (view full) --- 541 542 class Xor(LogicRegOp): 543 code = 'DestReg = merge(DestReg, result = (psrc1 ^ op2), dataSize)' 544 big_code = 'DestReg = result = (psrc1 ^ op2) & mask(dataSize * 8)' 545 546 class Mul1s(WrRegOp): 547 op_class = 'IntMultOp' 548 | 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 --- 532 unchanged lines hidden (view full) --- 541 542 class Xor(LogicRegOp): 543 code = 'DestReg = merge(DestReg, result = (psrc1 ^ op2), dataSize)' 544 big_code = 'DestReg = result = (psrc1 ^ op2) & mask(dataSize * 8)' 545 546 class Mul1s(WrRegOp): 547 op_class = 'IntMultOp' 548 |
549 # Multiply two values Aa and Bb where Aa = A << p + a, then correct for 550 # negative operands. 551 # Aa * Bb 552 # = (A << p + a) * (B << p + b) 553 # = (A * B) << 2p + (A * b + a * B) << p + a * b |
|
549 code = ''' 550 ProdLow = psrc1 * op2; | 554 code = ''' 555 ProdLow = psrc1 * op2; |
551 int halfSize = (dataSize * 8) / 2; 552 uint64_t shifter = (ULL(1) << halfSize); 553 uint64_t hiResult; 554 uint64_t psrc1_h = psrc1 / shifter; 555 uint64_t psrc1_l = psrc1 & mask(halfSize); 556 uint64_t psrc2_h = (op2 / shifter) & mask(halfSize); 557 uint64_t psrc2_l = op2 & mask(halfSize); 558 hiResult = ((psrc1_l * psrc2_h + psrc1_h * psrc2_l + 559 ((psrc1_l * psrc2_l) / shifter)) /shifter) + 560 psrc1_h * psrc2_h; | 556 557 int p = (dataSize * 8) / 2; 558 uint64_t A = bits(psrc1, 2 * p - 1, p); 559 uint64_t a = bits(psrc1, p - 1, 0); 560 uint64_t B = bits<uint64_t>(op2, 2 * p - 1, p); 561 uint64_t b = bits<uint64_t>(op2, p - 1, 0); 562 563 uint64_t c1, c2; // Carry between place values. 564 uint64_t ab = a * b, Ab = A * b, aB = a * B, AB = A * B; 565 566 c1 = ab >> p; 567 568 // Be careful to avoid overflow if p is large. 569 if (p == 32) { 570 c2 = (c1 >> 1) + (Ab >> 1) + (aB >> 1); 571 c2 += ((c1 & 0x1) + (Ab & 0x1) + (aB & 0x1)) >> 1; 572 c2 >>= (p - 1); 573 } else { 574 c2 = (c1 + Ab + aB) >> p; 575 } 576 577 uint64_t hi = AB + c2; 578 |
561 if (bits(psrc1, dataSize * 8 - 1)) | 579 if (bits(psrc1, dataSize * 8 - 1)) |
562 hiResult -= op2; | 580 hi -= op2; |
563 if (bits(op2, dataSize * 8 - 1)) | 581 if (bits(op2, dataSize * 8 - 1)) |
564 hiResult -= psrc1; 565 ProdHi = hiResult; | 582 hi -= psrc1; 583 584 ProdHi = hi; |
566 ''' 567 flag_code = ''' 568 if ((-ProdHi & mask(dataSize * 8)) != 569 bits(ProdLow, dataSize * 8 - 1)) { 570 PredcfofBits = PredcfofBits | (ext & (CFBit | OFBit)); 571 PredecfBit = PredecfBit | (ext & ECFBit); 572 } else { 573 PredcfofBits = PredcfofBits & ~(ext & (CFBit | OFBit)); 574 PredecfBit = PredecfBit & ~(ext & ECFBit); 575 } 576 ''' 577 578 class Mul1u(WrRegOp): 579 op_class = 'IntMultOp' 580 | 585 ''' 586 flag_code = ''' 587 if ((-ProdHi & mask(dataSize * 8)) != 588 bits(ProdLow, dataSize * 8 - 1)) { 589 PredcfofBits = PredcfofBits | (ext & (CFBit | OFBit)); 590 PredecfBit = PredecfBit | (ext & ECFBit); 591 } else { 592 PredcfofBits = PredcfofBits & ~(ext & (CFBit | OFBit)); 593 PredecfBit = PredecfBit & ~(ext & ECFBit); 594 } 595 ''' 596 597 class Mul1u(WrRegOp): 598 op_class = 'IntMultOp' 599 |
600 # Multiply two values Aa and Bb where Aa = A << p + a. 601 # Aa * Bb 602 # = (A << p + a) * (B << p + b) 603 # = (A * B) << 2p + (A * b + a * B) << p + a * b |
|
581 code = ''' 582 ProdLow = psrc1 * op2; | 604 code = ''' 605 ProdLow = psrc1 * op2; |
583 int halfSize = (dataSize * 8) / 2; 584 uint64_t shifter = (ULL(1) << halfSize); 585 uint64_t psrc1_h = psrc1 / shifter; 586 uint64_t psrc1_l = psrc1 & mask(halfSize); 587 uint64_t psrc2_h = (op2 / shifter) & mask(halfSize); 588 uint64_t psrc2_l = op2 & mask(halfSize); 589 ProdHi = ((psrc1_l * psrc2_h + psrc1_h * psrc2_l + 590 ((psrc1_l * psrc2_l) / shifter)) / shifter) + 591 psrc1_h * psrc2_h; | 606 607 int p = (dataSize * 8) / 2; 608 uint64_t A = bits(psrc1, 2 * p - 1, p); 609 uint64_t a = bits(psrc1, p - 1, 0); 610 uint64_t B = bits<uint64_t>(op2, 2 * p - 1, p); 611 uint64_t b = bits<uint64_t>(op2, p - 1, 0); 612 613 uint64_t c1, c2; // Carry between place values. 614 uint64_t ab = a * b, Ab = A * b, aB = a * B, AB = A * B; 615 616 c1 = ab >> p; 617 618 // Be careful to avoid overflow if p is large. 619 if (p == 32) { 620 c2 = (c1 >> 1) + (Ab >> 1) + (aB >> 1); 621 c2 += ((c1 & 0x1) + (Ab & 0x1) + (aB & 0x1)) >> 1; 622 c2 >>= (p - 1); 623 } else { 624 c2 = (c1 + Ab + aB) >> p; 625 } 626 627 ProdHi = AB + c2; |
592 ''' 593 flag_code = ''' 594 if (ProdHi) { 595 PredcfofBits = PredcfofBits | (ext & (CFBit | OFBit)); 596 PredecfBit = PredecfBit | (ext & ECFBit); 597 } else { 598 PredcfofBits = PredcfofBits & ~(ext & (CFBit | OFBit)); 599 PredecfBit = PredecfBit & ~(ext & ECFBit); --- 1099 unchanged lines hidden --- | 628 ''' 629 flag_code = ''' 630 if (ProdHi) { 631 PredcfofBits = PredcfofBits | (ext & (CFBit | OFBit)); 632 PredecfBit = PredecfBit | (ext & ECFBit); 633 } else { 634 PredcfofBits = PredcfofBits & ~(ext & (CFBit | OFBit)); 635 PredecfBit = PredecfBit & ~(ext & ECFBit); --- 1099 unchanged lines hidden --- |