| OLD | NEW |
| 1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// | 1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// |
| 2 // | 2 // |
| 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
| 5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
| 6 // | 6 // |
| 7 // Modified by the Subzero authors. | 7 // Modified by the Subzero authors. |
| 8 // | 8 // |
| 9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
| 10 // | 10 // |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // Conditions of rule violated. | 375 // Conditions of rule violated. |
| 376 return setNeedsTextFixup(); | 376 return setNeedsTextFixup(); |
| 377 emitType01(Cond, kInstTypeDataRegister, Adc, SetFlags, Rn, Rd, Src1Value); | 377 emitType01(Cond, kInstTypeDataRegister, Adc, SetFlags, Rn, Rd, Src1Value); |
| 378 return; | 378 return; |
| 379 } | 379 } |
| 380 case DecodedAsRotatedImm8: { | 380 case DecodedAsRotatedImm8: { |
| 381 // ADC (Immediate) - ARM section A8.8.1, encoding A1: | 381 // ADC (Immediate) - ARM section A8.8.1, encoding A1: |
| 382 // adc{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 382 // adc{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
| 383 // | 383 // |
| 384 // cccc0010101snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 384 // cccc0010101snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 385 // s=SetFlags and iiiiiiiiiiii=Src1Value=RotatedImm8. | 385 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
| 386 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) | 386 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) |
| 387 // Conditions of rule violated. | 387 // Conditions of rule violated. |
| 388 return setNeedsTextFixup(); | 388 return setNeedsTextFixup(); |
| 389 emitType01(Cond, kInstTypeDataImmediate, Adc, SetFlags, Rn, Rd, Src1Value); | 389 emitType01(Cond, kInstTypeDataImmediate, Adc, SetFlags, Rn, Rd, Src1Value); |
| 390 return; | 390 return; |
| 391 } | 391 } |
| 392 }; | 392 }; |
| 393 } | 393 } |
| 394 | 394 |
| 395 void AssemblerARM32::add(const Operand *OpRd, const Operand *OpRn, | 395 void AssemblerARM32::add(const Operand *OpRd, const Operand *OpRn, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 423 emitType01(Cond, kInstTypeDataRegister, Add, SetFlags, Rn, Rd, Src1Value); | 423 emitType01(Cond, kInstTypeDataRegister, Add, SetFlags, Rn, Rd, Src1Value); |
| 424 return; | 424 return; |
| 425 } | 425 } |
| 426 case DecodedAsRotatedImm8: { | 426 case DecodedAsRotatedImm8: { |
| 427 // ADD (Immediate) - ARM section A8.8.5, encoding A1: | 427 // ADD (Immediate) - ARM section A8.8.5, encoding A1: |
| 428 // add{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 428 // add{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
| 429 // ADD (SP plus immediate) - ARM section A8.8.9, encoding A1. | 429 // ADD (SP plus immediate) - ARM section A8.8.9, encoding A1. |
| 430 // add{s}<c> <Rd>, sp, #<RotatedImm8> | 430 // add{s}<c> <Rd>, sp, #<RotatedImm8> |
| 431 // | 431 // |
| 432 // cccc0010100snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 432 // cccc0010100snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 433 // s=SetFlags and iiiiiiiiiiii=Src1Value=RotatedImm8. | 433 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
| 434 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) | 434 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) |
| 435 // Conditions of rule violated. | 435 // Conditions of rule violated. |
| 436 return setNeedsTextFixup(); | 436 return setNeedsTextFixup(); |
| 437 emitType01(Cond, kInstTypeDataImmediate, Add, SetFlags, Rn, Rd, Src1Value); | 437 emitType01(Cond, kInstTypeDataImmediate, Add, SetFlags, Rn, Rd, Src1Value); |
| 438 return; | 438 return; |
| 439 } | 439 } |
| 440 }; | 440 }; |
| 441 } | 441 } |
| 442 | 442 |
| 443 void AssemblerARM32::b(Label *L, CondARM32::Cond Cond) { | 443 void AssemblerARM32::b(Label *L, CondARM32::Cond Cond) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 // Conditions of rule violated. | 556 // Conditions of rule violated. |
| 557 return setNeedsTextFixup(); | 557 return setNeedsTextFixup(); |
| 558 emitType01(Cond, kInstTypeDataRegister, Sbc, SetFlags, Rn, Rd, Src1Value); | 558 emitType01(Cond, kInstTypeDataRegister, Sbc, SetFlags, Rn, Rd, Src1Value); |
| 559 return; | 559 return; |
| 560 } | 560 } |
| 561 case DecodedAsRotatedImm8: { | 561 case DecodedAsRotatedImm8: { |
| 562 // SBC (Immediate) - ARM section A8.8.161, encoding A1: | 562 // SBC (Immediate) - ARM section A8.8.161, encoding A1: |
| 563 // sbc{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 563 // sbc{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
| 564 // | 564 // |
| 565 // cccc0010110snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 565 // cccc0010110snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 566 // s=SetFlags and iiiiiiiiiiii=Src1Value=RotatedImm8. | 566 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
| 567 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) | 567 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) |
| 568 // Conditions of rule violated. | 568 // Conditions of rule violated. |
| 569 return setNeedsTextFixup(); | 569 return setNeedsTextFixup(); |
| 570 emitType01(Cond, kInstTypeDataImmediate, Sbc, SetFlags, Rn, Rd, Src1Value); | 570 emitType01(Cond, kInstTypeDataImmediate, Sbc, SetFlags, Rn, Rd, Src1Value); |
| 571 return; | 571 return; |
| 572 } | 572 } |
| 573 }; | 573 }; |
| 574 } | 574 } |
| 575 | 575 |
| 576 void AssemblerARM32::str(const Operand *OpRt, const Operand *OpAddress, | 576 void AssemblerARM32::str(const Operand *OpRt, const Operand *OpAddress, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 602 return setNeedsTextFixup(); | 602 return setNeedsTextFixup(); |
| 603 if (!isBitSet(P, Address) && isBitSet(W, Address)) | 603 if (!isBitSet(P, Address) && isBitSet(W, Address)) |
| 604 return setNeedsTextFixup(); | 604 return setNeedsTextFixup(); |
| 605 if (!IsByte && (getGPRReg(kRnShift, Address) == RegARM32::Encoded_Reg_sp) && | 605 if (!IsByte && (getGPRReg(kRnShift, Address) == RegARM32::Encoded_Reg_sp) && |
| 606 isBitSet(P, Address) && !isBitSet(U, Address) && isBitSet(W, Address) && | 606 isBitSet(P, Address) && !isBitSet(U, Address) && isBitSet(W, Address) && |
| 607 (mask(Address, kImm12Shift, kImmed12Bits) == 0x8 /* 000000000100 */)) | 607 (mask(Address, kImm12Shift, kImmed12Bits) == 0x8 /* 000000000100 */)) |
| 608 return setNeedsTextFixup(); | 608 return setNeedsTextFixup(); |
| 609 emitMemOp(Cond, kInstTypeMemImmediate, IsLoad, IsByte, Rt, Address); | 609 emitMemOp(Cond, kInstTypeMemImmediate, IsLoad, IsByte, Rt, Address); |
| 610 } | 610 } |
| 611 | 611 |
| 612 void AssemblerARM32::orr(const Operand *OpRd, const Operand *OpRn, |
| 613 const Operand *OpSrc1, bool SetFlags, |
| 614 CondARM32::Cond Cond) { |
| 615 IValueT Rd; |
| 616 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) |
| 617 return setNeedsTextFixup(); |
| 618 IValueT Rn; |
| 619 if (decodeOperand(OpRn, Rn) != DecodedAsRegister) |
| 620 return setNeedsTextFixup(); |
| 621 constexpr IValueT Orr = B3 | B2; // i.e. 1100 |
| 622 IValueT Src1Value; |
| 623 // TODO(kschimpf) Handle other possible decodings of orr. |
| 624 switch (decodeOperand(OpSrc1, Src1Value)) { |
| 625 default: |
| 626 return setNeedsTextFixup(); |
| 627 case DecodedAsRegister: { |
| 628 // ORR (register) - ARM Section A8.8.123, encoding A1: |
| 629 // orr{s}<c> <Rd>, <Rn>, <Rm> |
| 630 // |
| 631 // cccc0001100snnnnddddiiiiitt0mmmm where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 632 // mmmm=Rm, iiiii=shift, tt=ShiftKind,, and s=SetFlags. |
| 633 constexpr IValueT Shift = 0; |
| 634 Src1Value = encodeShiftRotateImm5(Src1Value, OperandARM32::kNoShift, Shift); |
| 635 if (((Rd == RegARM32::Encoded_Reg_pc) && SetFlags)) |
| 636 // Conditions of rule violated. |
| 637 return setNeedsTextFixup(); |
| 638 emitType01(Cond, kInstTypeDataRegister, Orr, SetFlags, Rn, Rd, Src1Value); |
| 639 return; |
| 640 } |
| 641 case DecodedAsRotatedImm8: { |
| 642 // ORR (register) - ARM Section A8.8.123, encoding A1: |
| 643 // orr{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
| 644 // |
| 645 // cccc0001100snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 646 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
| 647 if (Rd == RegARM32::Encoded_Reg_pc && SetFlags) |
| 648 // Conditions of rule violated. |
| 649 return setNeedsTextFixup(); |
| 650 emitType01(Cond, kInstTypeDataImmediate, Orr, SetFlags, Rn, Rd, Src1Value); |
| 651 return; |
| 652 } |
| 653 } |
| 654 } |
| 655 |
| 612 void AssemblerARM32::sub(const Operand *OpRd, const Operand *OpRn, | 656 void AssemblerARM32::sub(const Operand *OpRd, const Operand *OpRn, |
| 613 const Operand *OpSrc1, bool SetFlags, | 657 const Operand *OpSrc1, bool SetFlags, |
| 614 CondARM32::Cond Cond) { | 658 CondARM32::Cond Cond) { |
| 615 IValueT Rd; | 659 IValueT Rd; |
| 616 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) | 660 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) |
| 617 return setNeedsTextFixup(); | 661 return setNeedsTextFixup(); |
| 618 IValueT Rn; | 662 IValueT Rn; |
| 619 if (decodeOperand(OpRn, Rn) != DecodedAsRegister) | 663 if (decodeOperand(OpRn, Rn) != DecodedAsRegister) |
| 620 return setNeedsTextFixup(); | 664 return setNeedsTextFixup(); |
| 621 constexpr IValueT Sub = B1; // 0010 | 665 constexpr IValueT Sub = B1; // 0010 |
| 622 IValueT Src1Value; | 666 IValueT Src1Value; |
| 623 // TODO(kschimpf) Other possible decodings of sub. | 667 // TODO(kschimpf) Other possible decodings of sub. |
| 624 switch (decodeOperand(OpSrc1, Src1Value)) { | 668 switch (decodeOperand(OpSrc1, Src1Value)) { |
| 625 default: | 669 default: |
| 626 return setNeedsTextFixup(); | 670 return setNeedsTextFixup(); |
| 627 case DecodedAsRegister: { | 671 case DecodedAsRegister: { |
| 628 // SUB (register) - ARM section A8.8.223, encoding A1: | 672 // SUB (register) - ARM section A8.8.223, encoding A1: |
| 629 // sub{s}<c> <Rd>, <Rn>, <Rm>{, <shift>} | 673 // sub{s}<c> <Rd>, <Rn>, <Rm>{, <shift>} |
| 630 // SUB (SP minus register): See ARM section 8.8.226, encoding A1: | 674 // SUB (SP minus register): See ARM section 8.8.226, encoding A1: |
| 631 // sub{s}<c> <Rd>, sp, <Rm>{, <Shift>} | 675 // sub{s}<c> <Rd>, sp, <Rm>{, <Shift>} |
| 632 // | 676 // |
| 633 // cccc0000010snnnnddddiiiiitt0mmmm where cccc=Cond, dddd=Rd, nnnn=Rn, | 677 // cccc0000010snnnnddddiiiiitt0mmmm where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 634 // mmmm=Rm, iiiiii=shift, tt=ShiftKind, and s=SetFlags. | 678 // mmmm=Rm, iiiiii=shift, tt=ShiftKind, and s=SetFlags. |
| 635 Src1Value = encodeShiftRotateImm5(Src1Value, OperandARM32::kNoShift, 0); | 679 constexpr IValueT Shift = 0; |
| 680 Src1Value = encodeShiftRotateImm5(Src1Value, OperandARM32::kNoShift, Shift); |
| 636 if (((Rd == RegARM32::Encoded_Reg_pc) && SetFlags)) | 681 if (((Rd == RegARM32::Encoded_Reg_pc) && SetFlags)) |
| 637 // Conditions of rule violated. | 682 // Conditions of rule violated. |
| 638 return setNeedsTextFixup(); | 683 return setNeedsTextFixup(); |
| 639 emitType01(Cond, kInstTypeDataRegister, Sub, SetFlags, Rn, Rd, Src1Value); | 684 emitType01(Cond, kInstTypeDataRegister, Sub, SetFlags, Rn, Rd, Src1Value); |
| 640 return; | 685 return; |
| 641 } | 686 } |
| 642 case DecodedAsRotatedImm8: { | 687 case DecodedAsRotatedImm8: { |
| 643 // Sub (Immediate) - ARM section A8.8.222, encoding A1: | 688 // Sub (Immediate) - ARM section A8.8.222, encoding A1: |
| 644 // sub{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 689 // sub{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
| 645 // Sub (Sp minus immediate) - ARM section A8.*.225, encoding A1: | 690 // Sub (Sp minus immediate) - ARM section A8.*.225, encoding A1: |
| 646 // sub{s}<c> sp, <Rn>, #<RotatedImm8> | 691 // sub{s}<c> sp, <Rn>, #<RotatedImm8> |
| 647 // | 692 // |
| 648 // cccc0010010snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 693 // cccc0010010snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 649 // s=SetFlags and iiiiiiiiiiii=Src1Value=RotatedImm8 | 694 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
| 650 if (Rd == RegARM32::Encoded_Reg_pc) | 695 if (Rd == RegARM32::Encoded_Reg_pc) |
| 651 // Conditions of rule violated. | 696 // Conditions of rule violated. |
| 652 return setNeedsTextFixup(); | 697 return setNeedsTextFixup(); |
| 653 emitType01(Cond, kInstTypeDataImmediate, Sub, SetFlags, Rn, Rd, Src1Value); | 698 emitType01(Cond, kInstTypeDataImmediate, Sub, SetFlags, Rn, Rd, Src1Value); |
| 654 return; | 699 return; |
| 655 } | 700 } |
| 656 } | 701 } |
| 657 } | 702 } |
| 658 | 703 |
| 659 } // end of namespace ARM32 | 704 } // end of namespace ARM32 |
| 660 } // end of namespace Ice | 705 } // end of namespace Ice |
| OLD | NEW |