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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 // Conditions of rule violated. | 435 // Conditions of rule violated. |
436 return setNeedsTextFixup(); | 436 return setNeedsTextFixup(); |
437 emitType01(Cond, kInstTypeDataRegister, Adc, SetFlags, Rn, Rd, Src1Value); | 437 emitType01(Cond, kInstTypeDataRegister, Adc, SetFlags, Rn, Rd, Src1Value); |
438 return; | 438 return; |
439 } | 439 } |
440 case DecodedAsRotatedImm8: { | 440 case DecodedAsRotatedImm8: { |
441 // ADC (Immediate) - ARM section A8.8.1, encoding A1: | 441 // ADC (Immediate) - ARM section A8.8.1, encoding A1: |
442 // adc{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 442 // adc{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
443 // | 443 // |
444 // cccc0010101snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 444 // cccc0010101snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
445 // s=SetFlags and iiiiiiiiiiii=Src1Value=RotatedImm8. | 445 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
446 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) | 446 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) |
447 // Conditions of rule violated. | 447 // Conditions of rule violated. |
448 return setNeedsTextFixup(); | 448 return setNeedsTextFixup(); |
449 emitType01(Cond, kInstTypeDataImmediate, Adc, SetFlags, Rn, Rd, Src1Value); | 449 emitType01(Cond, kInstTypeDataImmediate, Adc, SetFlags, Rn, Rd, Src1Value); |
450 return; | 450 return; |
451 } | 451 } |
452 }; | 452 }; |
453 } | 453 } |
454 | 454 |
455 void AssemblerARM32::add(const Operand *OpRd, const Operand *OpRn, | 455 void AssemblerARM32::add(const Operand *OpRd, const Operand *OpRn, |
(...skipping 27 matching lines...) Expand all Loading... |
483 emitType01(Cond, kInstTypeDataRegister, Add, SetFlags, Rn, Rd, Src1Value); | 483 emitType01(Cond, kInstTypeDataRegister, Add, SetFlags, Rn, Rd, Src1Value); |
484 return; | 484 return; |
485 } | 485 } |
486 case DecodedAsRotatedImm8: { | 486 case DecodedAsRotatedImm8: { |
487 // ADD (Immediate) - ARM section A8.8.5, encoding A1: | 487 // ADD (Immediate) - ARM section A8.8.5, encoding A1: |
488 // add{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 488 // add{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
489 // ADD (SP plus immediate) - ARM section A8.8.9, encoding A1. | 489 // ADD (SP plus immediate) - ARM section A8.8.9, encoding A1. |
490 // add{s}<c> <Rd>, sp, #<RotatedImm8> | 490 // add{s}<c> <Rd>, sp, #<RotatedImm8> |
491 // | 491 // |
492 // cccc0010100snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 492 // cccc0010100snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
493 // s=SetFlags and iiiiiiiiiiii=Src1Value=RotatedImm8. | 493 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
494 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) | 494 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) |
495 // Conditions of rule violated. | 495 // Conditions of rule violated. |
496 return setNeedsTextFixup(); | 496 return setNeedsTextFixup(); |
497 emitType01(Cond, kInstTypeDataImmediate, Add, SetFlags, Rn, Rd, Src1Value); | 497 emitType01(Cond, kInstTypeDataImmediate, Add, SetFlags, Rn, Rd, Src1Value); |
498 return; | 498 return; |
499 } | 499 } |
500 } | 500 } |
501 } | 501 } |
502 | 502 |
503 void AssemblerARM32::and_(const Operand *OpRd, const Operand *OpRn, | 503 void AssemblerARM32::and_(const Operand *OpRd, const Operand *OpRn, |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 // Conditions of rule violated. | 715 // Conditions of rule violated. |
716 return setNeedsTextFixup(); | 716 return setNeedsTextFixup(); |
717 emitType01(Cond, kInstTypeDataRegister, Sbc, SetFlags, Rn, Rd, Src1Value); | 717 emitType01(Cond, kInstTypeDataRegister, Sbc, SetFlags, Rn, Rd, Src1Value); |
718 return; | 718 return; |
719 } | 719 } |
720 case DecodedAsRotatedImm8: { | 720 case DecodedAsRotatedImm8: { |
721 // SBC (Immediate) - ARM section A8.8.161, encoding A1: | 721 // SBC (Immediate) - ARM section A8.8.161, encoding A1: |
722 // sbc{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 722 // sbc{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
723 // | 723 // |
724 // cccc0010110snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 724 // cccc0010110snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
725 // s=SetFlags and iiiiiiiiiiii=Src1Value=RotatedImm8. | 725 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
726 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) | 726 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags)) |
727 // Conditions of rule violated. | 727 // Conditions of rule violated. |
728 return setNeedsTextFixup(); | 728 return setNeedsTextFixup(); |
729 emitType01(Cond, kInstTypeDataImmediate, Sbc, SetFlags, Rn, Rd, Src1Value); | 729 emitType01(Cond, kInstTypeDataImmediate, Sbc, SetFlags, Rn, Rd, Src1Value); |
730 return; | 730 return; |
731 } | 731 } |
732 }; | 732 }; |
733 } | 733 } |
734 | 734 |
735 void AssemblerARM32::str(const Operand *OpRt, const Operand *OpAddress, | 735 void AssemblerARM32::str(const Operand *OpRt, const Operand *OpAddress, |
(...skipping 25 matching lines...) Expand all Loading... |
761 return setNeedsTextFixup(); | 761 return setNeedsTextFixup(); |
762 if (!isBitSet(P, Address) && isBitSet(W, Address)) | 762 if (!isBitSet(P, Address) && isBitSet(W, Address)) |
763 return setNeedsTextFixup(); | 763 return setNeedsTextFixup(); |
764 if (!IsByte && (getGPRReg(kRnShift, Address) == RegARM32::Encoded_Reg_sp) && | 764 if (!IsByte && (getGPRReg(kRnShift, Address) == RegARM32::Encoded_Reg_sp) && |
765 isBitSet(P, Address) && !isBitSet(U, Address) && isBitSet(W, Address) && | 765 isBitSet(P, Address) && !isBitSet(U, Address) && isBitSet(W, Address) && |
766 (mask(Address, kImm12Shift, kImmed12Bits) == 0x8 /* 000000000100 */)) | 766 (mask(Address, kImm12Shift, kImmed12Bits) == 0x8 /* 000000000100 */)) |
767 return setNeedsTextFixup(); | 767 return setNeedsTextFixup(); |
768 emitMemOp(Cond, kInstTypeMemImmediate, IsLoad, IsByte, Rt, Address); | 768 emitMemOp(Cond, kInstTypeMemImmediate, IsLoad, IsByte, Rt, Address); |
769 } | 769 } |
770 | 770 |
| 771 void AssemblerARM32::orr(const Operand *OpRd, const Operand *OpRn, |
| 772 const Operand *OpSrc1, bool SetFlags, |
| 773 CondARM32::Cond Cond) { |
| 774 IValueT Rd; |
| 775 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) |
| 776 return setNeedsTextFixup(); |
| 777 IValueT Rn; |
| 778 if (decodeOperand(OpRn, Rn) != DecodedAsRegister) |
| 779 return setNeedsTextFixup(); |
| 780 constexpr IValueT Orr = B3 | B2; // i.e. 1100 |
| 781 IValueT Src1Value; |
| 782 // TODO(kschimpf) Handle other possible decodings of orr. |
| 783 switch (decodeOperand(OpSrc1, Src1Value)) { |
| 784 default: |
| 785 return setNeedsTextFixup(); |
| 786 case DecodedAsRegister: { |
| 787 // ORR (register) - ARM Section A8.8.123, encoding A1: |
| 788 // orr{s}<c> <Rd>, <Rn>, <Rm> |
| 789 // |
| 790 // cccc0001100snnnnddddiiiiitt0mmmm where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 791 // mmmm=Rm, iiiii=shift, tt=ShiftKind,, and s=SetFlags. |
| 792 constexpr IValueT Shift = 0; |
| 793 Src1Value = encodeShiftRotateImm5(Src1Value, OperandARM32::kNoShift, Shift); |
| 794 if (((Rd == RegARM32::Encoded_Reg_pc) && SetFlags)) |
| 795 // Conditions of rule violated. |
| 796 return setNeedsTextFixup(); |
| 797 emitType01(Cond, kInstTypeDataRegister, Orr, SetFlags, Rn, Rd, Src1Value); |
| 798 return; |
| 799 } |
| 800 case DecodedAsRotatedImm8: { |
| 801 // ORR (register) - ARM Section A8.8.123, encoding A1: |
| 802 // orr{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
| 803 // |
| 804 // cccc0001100snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 805 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
| 806 if (Rd == RegARM32::Encoded_Reg_pc && SetFlags) |
| 807 // Conditions of rule violated. |
| 808 return setNeedsTextFixup(); |
| 809 emitType01(Cond, kInstTypeDataImmediate, Orr, SetFlags, Rn, Rd, Src1Value); |
| 810 return; |
| 811 } |
| 812 } |
| 813 } |
| 814 |
771 void AssemblerARM32::mul(const Operand *OpRd, const Operand *OpRn, | 815 void AssemblerARM32::mul(const Operand *OpRd, const Operand *OpRn, |
772 const Operand *OpSrc1, bool SetFlags, | 816 const Operand *OpSrc1, bool SetFlags, |
773 CondARM32::Cond Cond) { | 817 CondARM32::Cond Cond) { |
774 IValueT Rd; | 818 IValueT Rd; |
775 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) | 819 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) |
776 return setNeedsTextFixup(); | 820 return setNeedsTextFixup(); |
777 IValueT Rn; | 821 IValueT Rn; |
778 if (decodeOperand(OpRn, Rn) != DecodedAsRegister) | 822 if (decodeOperand(OpRn, Rn) != DecodedAsRegister) |
779 return setNeedsTextFixup(); | 823 return setNeedsTextFixup(); |
780 IValueT Rm; | 824 IValueT Rm; |
(...skipping 28 matching lines...) Expand all Loading... |
809 default: | 853 default: |
810 return setNeedsTextFixup(); | 854 return setNeedsTextFixup(); |
811 case DecodedAsRegister: { | 855 case DecodedAsRegister: { |
812 // SUB (register) - ARM section A8.8.223, encoding A1: | 856 // SUB (register) - ARM section A8.8.223, encoding A1: |
813 // sub{s}<c> <Rd>, <Rn>, <Rm>{, <shift>} | 857 // sub{s}<c> <Rd>, <Rn>, <Rm>{, <shift>} |
814 // SUB (SP minus register): See ARM section 8.8.226, encoding A1: | 858 // SUB (SP minus register): See ARM section 8.8.226, encoding A1: |
815 // sub{s}<c> <Rd>, sp, <Rm>{, <Shift>} | 859 // sub{s}<c> <Rd>, sp, <Rm>{, <Shift>} |
816 // | 860 // |
817 // cccc0000010snnnnddddiiiiitt0mmmm where cccc=Cond, dddd=Rd, nnnn=Rn, | 861 // cccc0000010snnnnddddiiiiitt0mmmm where cccc=Cond, dddd=Rd, nnnn=Rn, |
818 // mmmm=Rm, iiiiii=shift, tt=ShiftKind, and s=SetFlags. | 862 // mmmm=Rm, iiiiii=shift, tt=ShiftKind, and s=SetFlags. |
819 Src1Value = encodeShiftRotateImm5(Src1Value, OperandARM32::kNoShift, 0); | 863 constexpr IValueT Shift = 0; |
| 864 Src1Value = encodeShiftRotateImm5(Src1Value, OperandARM32::kNoShift, Shift); |
820 if (((Rd == RegARM32::Encoded_Reg_pc) && SetFlags)) | 865 if (((Rd == RegARM32::Encoded_Reg_pc) && SetFlags)) |
821 // Conditions of rule violated. | 866 // Conditions of rule violated. |
822 return setNeedsTextFixup(); | 867 return setNeedsTextFixup(); |
823 emitType01(Cond, kInstTypeDataRegister, Sub, SetFlags, Rn, Rd, Src1Value); | 868 emitType01(Cond, kInstTypeDataRegister, Sub, SetFlags, Rn, Rd, Src1Value); |
824 return; | 869 return; |
825 } | 870 } |
826 case DecodedAsRotatedImm8: { | 871 case DecodedAsRotatedImm8: { |
827 // Sub (Immediate) - ARM section A8.8.222, encoding A1: | 872 // Sub (Immediate) - ARM section A8.8.222, encoding A1: |
828 // sub{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 873 // sub{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
829 // Sub (Sp minus immediate) - ARM section A8.*.225, encoding A1: | 874 // Sub (Sp minus immediate) - ARM section A8.*.225, encoding A1: |
830 // sub{s}<c> sp, <Rn>, #<RotatedImm8> | 875 // sub{s}<c> sp, <Rn>, #<RotatedImm8> |
831 // | 876 // |
832 // cccc0010010snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 877 // cccc0010010snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
833 // s=SetFlags and iiiiiiiiiiii=Src1Value=RotatedImm8 | 878 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
834 if (Rd == RegARM32::Encoded_Reg_pc) | 879 if (Rd == RegARM32::Encoded_Reg_pc) |
835 // Conditions of rule violated. | 880 // Conditions of rule violated. |
836 return setNeedsTextFixup(); | 881 return setNeedsTextFixup(); |
837 emitType01(Cond, kInstTypeDataImmediate, Sub, SetFlags, Rn, Rd, Src1Value); | 882 emitType01(Cond, kInstTypeDataImmediate, Sub, SetFlags, Rn, Rd, Src1Value); |
838 return; | 883 return; |
839 } | 884 } |
840 } | 885 } |
841 } | 886 } |
842 | 887 |
843 } // end of namespace ARM32 | 888 } // end of namespace ARM32 |
844 } // end of namespace Ice | 889 } // end of namespace Ice |
OLD | NEW |