Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(798)

Side by Side Diff: src/IceAssemblerARM32.cpp

Issue 1636513002: Clean up emitInst() in the integrated ARM assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix master merge. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceAssemblerARM32.h ('k') | tests_lit/assembler/arm32/vmrs.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 EmitChecks RuleChecks, const char *InstName) { 654 EmitChecks RuleChecks, const char *InstName) {
655 switch (RuleChecks) { 655 switch (RuleChecks) {
656 case NoChecks: 656 case NoChecks:
657 break; 657 break;
658 case RdIsPcAndSetFlags: 658 case RdIsPcAndSetFlags:
659 verifyRegNotPcWhenSetFlags(Rd, SetFlags, InstName); 659 verifyRegNotPcWhenSetFlags(Rd, SetFlags, InstName);
660 break; 660 break;
661 } 661 }
662 assert(Rd < RegARM32::getNumGPRegs()); 662 assert(Rd < RegARM32::getNumGPRegs());
663 assert(CondARM32::isDefined(Cond)); 663 assert(CondARM32::isDefined(Cond));
664 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
665 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | 664 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) |
666 (InstType << kTypeShift) | (Opcode << kOpcodeShift) | 665 (InstType << kTypeShift) | (Opcode << kOpcodeShift) |
667 (encodeBool(SetFlags) << kSShift) | 666 (encodeBool(SetFlags) << kSShift) |
668 (Rn << kRnShift) | (Rd << kRdShift) | Imm12; 667 (Rn << kRnShift) | (Rd << kRdShift) | Imm12;
669 emitInst(Encoding); 668 emitInst(Encoding);
670 } 669 }
671 670
672 void AssemblerARM32::emitType01(CondARM32::Cond Cond, IValueT Opcode, 671 void AssemblerARM32::emitType01(CondARM32::Cond Cond, IValueT Opcode,
673 const Operand *OpRd, const Operand *OpRn, 672 const Operand *OpRd, const Operand *OpRn,
674 const Operand *OpSrc1, bool SetFlags, 673 const Operand *OpSrc1, bool SetFlags,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 } 739 }
741 } 740 }
742 } 741 }
743 742
744 void AssemblerARM32::emitType05(CondARM32::Cond Cond, IOffsetT Offset, 743 void AssemblerARM32::emitType05(CondARM32::Cond Cond, IOffsetT Offset,
745 bool Link) { 744 bool Link) {
746 // cccc101liiiiiiiiiiiiiiiiiiiiiiii where cccc=Cond, l=Link, and 745 // cccc101liiiiiiiiiiiiiiiiiiiiiiii where cccc=Cond, l=Link, and
747 // iiiiiiiiiiiiiiiiiiiiiiii= 746 // iiiiiiiiiiiiiiiiiiiiiiii=
748 // EncodedBranchOffset(cccc101l000000000000000000000000, Offset); 747 // EncodedBranchOffset(cccc101l000000000000000000000000, Offset);
749 assert(CondARM32::isDefined(Cond)); 748 assert(CondARM32::isDefined(Cond));
750 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
751 IValueT Encoding = static_cast<int32_t>(Cond) << kConditionShift | 749 IValueT Encoding = static_cast<int32_t>(Cond) << kConditionShift |
752 5 << kTypeShift | (Link ? 1 : 0) << kLinkShift; 750 5 << kTypeShift | (Link ? 1 : 0) << kLinkShift;
753 Encoding = encodeBranchOffset(Offset, Encoding); 751 Encoding = encodeBranchOffset(Offset, Encoding);
754 emitInst(Encoding); 752 emitInst(Encoding);
755 } 753 }
756 754
757 void AssemblerARM32::emitBranch(Label *L, CondARM32::Cond Cond, bool Link) { 755 void AssemblerARM32::emitBranch(Label *L, CondARM32::Cond Cond, bool Link) {
758 // TODO(kschimpf): Handle far jumps. 756 // TODO(kschimpf): Handle far jumps.
759 if (L->isBound()) { 757 if (L->isBound()) {
760 const int32_t Dest = L->getPosition() - Buffer.size(); 758 const int32_t Dest = L->getPosition() - Buffer.size();
(...skipping 26 matching lines...) Expand all
787 constexpr IValueT Rd = RegARM32::Encoded_Reg_r0; 785 constexpr IValueT Rd = RegARM32::Encoded_Reg_r0;
788 IValueT Rn = encodeGPRegister(OpRn, "Rn", InstName); 786 IValueT Rn = encodeGPRegister(OpRn, "Rn", InstName);
789 emitType01(Cond, Opcode, Rd, Rn, OpSrc1, SetFlags, NoChecks, InstName); 787 emitType01(Cond, Opcode, Rd, Rn, OpSrc1, SetFlags, NoChecks, InstName);
790 } 788 }
791 789
792 void AssemblerARM32::emitMemOp(CondARM32::Cond Cond, IValueT InstType, 790 void AssemblerARM32::emitMemOp(CondARM32::Cond Cond, IValueT InstType,
793 bool IsLoad, bool IsByte, IValueT Rt, 791 bool IsLoad, bool IsByte, IValueT Rt,
794 IValueT Address) { 792 IValueT Address) {
795 assert(Rt < RegARM32::getNumGPRegs()); 793 assert(Rt < RegARM32::getNumGPRegs());
796 assert(CondARM32::isDefined(Cond)); 794 assert(CondARM32::isDefined(Cond));
797 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
798 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | 795 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) |
799 (InstType << kTypeShift) | (IsLoad ? L : 0) | 796 (InstType << kTypeShift) | (IsLoad ? L : 0) |
800 (IsByte ? B : 0) | (Rt << kRdShift) | Address; 797 (IsByte ? B : 0) | (Rt << kRdShift) | Address;
801 emitInst(Encoding); 798 emitInst(Encoding);
802 } 799 }
803 800
804 void AssemblerARM32::emitMemOp(CondARM32::Cond Cond, bool IsLoad, bool IsByte, 801 void AssemblerARM32::emitMemOp(CondARM32::Cond Cond, bool IsLoad, bool IsByte,
805 IValueT Rt, const Operand *OpAddress, 802 IValueT Rt, const Operand *OpAddress,
806 const TargetInfo &TInfo, const char *InstName) { 803 const TargetInfo &TInfo, const char *InstName) {
807 IValueT Address; 804 IValueT Address;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 // iiiijjjj=Imm8, pu0w<<21 is a BlockAddr, x000000000000yyyy0000=Opcode, 874 // iiiijjjj=Imm8, pu0w<<21 is a BlockAddr, x000000000000yyyy0000=Opcode,
878 // and pu0w0nnnn0000iiii0000jjjj=Address. 875 // and pu0w0nnnn0000iiii0000jjjj=Address.
879 assert(Rt < RegARM32::getNumGPRegs()); 876 assert(Rt < RegARM32::getNumGPRegs());
880 assert(CondARM32::isDefined(Cond)); 877 assert(CondARM32::isDefined(Cond));
881 verifyPOrNotW(Address, InstName); 878 verifyPOrNotW(Address, InstName);
882 verifyRegNotPc(Rt, "Rt", InstName); 879 verifyRegNotPc(Rt, "Rt", InstName);
883 if (isBitSet(W, Address)) 880 if (isBitSet(W, Address))
884 verifyRegsNotEq(getGPRReg(kRnShift, Address), "Rn", Rt, "Rt", InstName); 881 verifyRegsNotEq(getGPRReg(kRnShift, Address), "Rn", Rt, "Rt", InstName);
885 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | 882 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) |
886 Opcode | (Rt << kRdShift) | Address; 883 Opcode | (Rt << kRdShift) | Address;
887 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
888 emitInst(Encoding); 884 emitInst(Encoding);
889 return; 885 return;
890 } 886 }
891 case EncodedAsShiftRotateImm5: { 887 case EncodedAsShiftRotateImm5: {
892 // XXXH (register) 888 // XXXH (register)
893 // xxxh<c> <Rt>, [<Rn>, +/-<Rm>]{!} 889 // xxxh<c> <Rt>, [<Rn>, +/-<Rm>]{!}
894 // xxxh<c> <Rt>, [<Rn>], +/-<Rm> 890 // xxxh<c> <Rt>, [<Rn>], +/-<Rm>
895 // 891 //
896 // cccc000pu0wxnnnntttt00001011mmmm where cccc=Cond, tttt=Rt, nnnn=Rn, 892 // cccc000pu0wxnnnntttt00001011mmmm where cccc=Cond, tttt=Rt, nnnn=Rn,
897 // mmmm=Rm, pu0w<<21 is a BlockAddr, x000000000000yyyy0000=Opcode, and 893 // mmmm=Rm, pu0w<<21 is a BlockAddr, x000000000000yyyy0000=Opcode, and
898 // pu0w0nnnn000000000000mmmm=Address. 894 // pu0w0nnnn000000000000mmmm=Address.
899 assert(Rt < RegARM32::getNumGPRegs()); 895 assert(Rt < RegARM32::getNumGPRegs());
900 assert(CondARM32::isDefined(Cond)); 896 assert(CondARM32::isDefined(Cond));
901 verifyPOrNotW(Address, InstName); 897 verifyPOrNotW(Address, InstName);
902 verifyRegNotPc(Rt, "Rt", InstName); 898 verifyRegNotPc(Rt, "Rt", InstName);
903 verifyAddrRegNotPc(kRmShift, Address, "Rm", InstName); 899 verifyAddrRegNotPc(kRmShift, Address, "Rm", InstName);
904 const RegARM32::GPRRegister Rn = getGPRReg(kRnShift, Address); 900 const RegARM32::GPRRegister Rn = getGPRReg(kRnShift, Address);
905 if (isBitSet(W, Address)) { 901 if (isBitSet(W, Address)) {
906 verifyRegNotPc(Rn, "Rn", InstName); 902 verifyRegNotPc(Rn, "Rn", InstName);
907 verifyRegsNotEq(Rn, "Rn", Rt, "Rt", InstName); 903 verifyRegsNotEq(Rn, "Rn", Rt, "Rt", InstName);
908 } 904 }
909 if (mask(Address, kShiftImmShift, 5) != 0) 905 if (mask(Address, kShiftImmShift, 5) != 0)
910 // For encoding 3, no shift is allowed. 906 // For encoding 3, no shift is allowed.
911 llvm::report_fatal_error(std::string(InstName) + 907 llvm::report_fatal_error(std::string(InstName) +
912 ": Shift constant not allowed"); 908 ": Shift constant not allowed");
913 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | 909 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) |
914 Opcode | (Rt << kRdShift) | Address; 910 Opcode | (Rt << kRdShift) | Address;
915 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
916 emitInst(Encoding); 911 emitInst(Encoding);
917 return; 912 return;
918 } 913 }
919 } 914 }
920 } 915 }
921 916
922 void AssemblerARM32::emitDivOp(CondARM32::Cond Cond, IValueT Opcode, IValueT Rd, 917 void AssemblerARM32::emitDivOp(CondARM32::Cond Cond, IValueT Opcode, IValueT Rd,
923 IValueT Rn, IValueT Rm) { 918 IValueT Rn, IValueT Rm) {
924 assert(Rd < RegARM32::getNumGPRegs()); 919 assert(Rd < RegARM32::getNumGPRegs());
925 assert(Rn < RegARM32::getNumGPRegs()); 920 assert(Rn < RegARM32::getNumGPRegs());
926 assert(Rm < RegARM32::getNumGPRegs()); 921 assert(Rm < RegARM32::getNumGPRegs());
927 assert(CondARM32::isDefined(Cond)); 922 assert(CondARM32::isDefined(Cond));
928 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
929 const IValueT Encoding = Opcode | (encodeCondition(Cond) << kConditionShift) | 923 const IValueT Encoding = Opcode | (encodeCondition(Cond) << kConditionShift) |
930 (Rn << kDivRnShift) | (Rd << kDivRdShift) | B26 | 924 (Rn << kDivRnShift) | (Rd << kDivRdShift) | B26 |
931 B25 | B24 | B20 | B15 | B14 | B13 | B12 | B4 | 925 B25 | B24 | B20 | B15 | B14 | B13 | B12 | B4 |
932 (Rm << kDivRmShift); 926 (Rm << kDivRmShift);
933 emitInst(Encoding); 927 emitInst(Encoding);
934 } 928 }
935 929
936 void AssemblerARM32::emitMulOp(CondARM32::Cond Cond, IValueT Opcode, IValueT Rd, 930 void AssemblerARM32::emitMulOp(CondARM32::Cond Cond, IValueT Opcode, IValueT Rd,
937 IValueT Rn, IValueT Rm, IValueT Rs, 931 IValueT Rn, IValueT Rm, IValueT Rs,
938 bool SetFlags) { 932 bool SetFlags) {
939 assert(Rd < RegARM32::getNumGPRegs()); 933 assert(Rd < RegARM32::getNumGPRegs());
940 assert(Rn < RegARM32::getNumGPRegs()); 934 assert(Rn < RegARM32::getNumGPRegs());
941 assert(Rm < RegARM32::getNumGPRegs()); 935 assert(Rm < RegARM32::getNumGPRegs());
942 assert(Rs < RegARM32::getNumGPRegs()); 936 assert(Rs < RegARM32::getNumGPRegs());
943 assert(CondARM32::isDefined(Cond)); 937 assert(CondARM32::isDefined(Cond));
944 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
945 IValueT Encoding = Opcode | (encodeCondition(Cond) << kConditionShift) | 938 IValueT Encoding = Opcode | (encodeCondition(Cond) << kConditionShift) |
946 (encodeBool(SetFlags) << kSShift) | (Rn << kRnShift) | 939 (encodeBool(SetFlags) << kSShift) | (Rn << kRnShift) |
947 (Rd << kRdShift) | (Rs << kRsShift) | B7 | B4 | 940 (Rd << kRdShift) | (Rs << kRsShift) | B7 | B4 |
948 (Rm << kRmShift); 941 (Rm << kRmShift);
949 emitInst(Encoding); 942 emitInst(Encoding);
950 } 943 }
951 944
952 void AssemblerARM32::emitMultiMemOp(CondARM32::Cond Cond, 945 void AssemblerARM32::emitMultiMemOp(CondARM32::Cond Cond,
953 BlockAddressMode AddressMode, bool IsLoad, 946 BlockAddressMode AddressMode, bool IsLoad,
954 IValueT BaseReg, IValueT Registers) { 947 IValueT BaseReg, IValueT Registers) {
955 assert(CondARM32::isDefined(Cond)); 948 assert(CondARM32::isDefined(Cond));
956 assert(BaseReg < RegARM32::getNumGPRegs()); 949 assert(BaseReg < RegARM32::getNumGPRegs());
957 assert(Registers < (1 << RegARM32::getNumGPRegs())); 950 assert(Registers < (1 << RegARM32::getNumGPRegs()));
958 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
959 IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B27 | 951 IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B27 |
960 AddressMode | (IsLoad ? L : 0) | (BaseReg << kRnShift) | 952 AddressMode | (IsLoad ? L : 0) | (BaseReg << kRnShift) |
961 Registers; 953 Registers;
962 emitInst(Encoding); 954 emitInst(Encoding);
963 } 955 }
964 956
965 void AssemblerARM32::emitSignExtend(CondARM32::Cond Cond, IValueT Opcode, 957 void AssemblerARM32::emitSignExtend(CondARM32::Cond Cond, IValueT Opcode,
966 const Operand *OpRd, const Operand *OpSrc0, 958 const Operand *OpRd, const Operand *OpSrc0,
967 const char *InstName) { 959 const char *InstName) {
968 IValueT Rd = encodeGPRegister(OpRd, "Rd", InstName); 960 IValueT Rd = encodeGPRegister(OpRd, "Rd", InstName);
(...skipping 26 matching lines...) Expand all
995 Opcode |= B20; 987 Opcode |= B20;
996 break; 988 break;
997 } 989 }
998 } 990 }
999 991
1000 assert(CondARM32::isDefined(Cond)); 992 assert(CondARM32::isDefined(Cond));
1001 IValueT Rot = encodeRotation(Rotation); 993 IValueT Rot = encodeRotation(Rotation);
1002 if (!Utils::IsUint(2, Rot)) 994 if (!Utils::IsUint(2, Rot))
1003 llvm::report_fatal_error(std::string(InstName) + 995 llvm::report_fatal_error(std::string(InstName) +
1004 ": Illegal rotation value"); 996 ": Illegal rotation value");
1005 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1006 IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | Opcode | 997 IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | Opcode |
1007 (Rn << kRnShift) | (Rd << kRdShift) | 998 (Rn << kRnShift) | (Rd << kRdShift) |
1008 (Rot << kRotationShift) | B6 | B5 | B4 | (Rm << kRmShift); 999 (Rot << kRotationShift) | B6 | B5 | B4 | (Rm << kRmShift);
1009 emitInst(Encoding); 1000 emitInst(Encoding);
1010 } 1001 }
1011 1002
1012 void AssemblerARM32::emitVFPddd(CondARM32::Cond Cond, IValueT Opcode, 1003 void AssemblerARM32::emitVFPddd(CondARM32::Cond Cond, IValueT Opcode,
1013 IValueT Dd, IValueT Dn, IValueT Dm) { 1004 IValueT Dd, IValueT Dn, IValueT Dm) {
1014 assert(Dd < RegARM32::getNumDRegs()); 1005 assert(Dd < RegARM32::getNumDRegs());
1015 assert(Dn < RegARM32::getNumDRegs()); 1006 assert(Dn < RegARM32::getNumDRegs());
1016 assert(Dm < RegARM32::getNumDRegs()); 1007 assert(Dm < RegARM32::getNumDRegs());
1017 assert(CondARM32::isDefined(Cond)); 1008 assert(CondARM32::isDefined(Cond));
1018 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1019 constexpr IValueT VFPOpcode = B27 | B26 | B25 | B11 | B9 | B8; 1009 constexpr IValueT VFPOpcode = B27 | B26 | B25 | B11 | B9 | B8;
1020 const IValueT Encoding = 1010 const IValueT Encoding =
1021 Opcode | VFPOpcode | (encodeCondition(Cond) << kConditionShift) | 1011 Opcode | VFPOpcode | (encodeCondition(Cond) << kConditionShift) |
1022 (getYInRegYXXXX(Dd) << 22) | (getXXXXInRegYXXXX(Dn) << 16) | 1012 (getYInRegYXXXX(Dd) << 22) | (getXXXXInRegYXXXX(Dn) << 16) |
1023 (getXXXXInRegYXXXX(Dd) << 12) | (getYInRegYXXXX(Dn) << 7) | 1013 (getXXXXInRegYXXXX(Dd) << 12) | (getYInRegYXXXX(Dn) << 7) |
1024 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm); 1014 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm);
1025 emitInst(Encoding); 1015 emitInst(Encoding);
1026 } 1016 }
1027 1017
1028 void AssemblerARM32::emitVFPsss(CondARM32::Cond Cond, IValueT Opcode, 1018 void AssemblerARM32::emitVFPsss(CondARM32::Cond Cond, IValueT Opcode,
1029 IValueT Sd, IValueT Sn, IValueT Sm) { 1019 IValueT Sd, IValueT Sn, IValueT Sm) {
1030 assert(Sd < RegARM32::getNumSRegs()); 1020 assert(Sd < RegARM32::getNumSRegs());
1031 assert(Sn < RegARM32::getNumSRegs()); 1021 assert(Sn < RegARM32::getNumSRegs());
1032 assert(Sm < RegARM32::getNumSRegs()); 1022 assert(Sm < RegARM32::getNumSRegs());
1033 assert(CondARM32::isDefined(Cond)); 1023 assert(CondARM32::isDefined(Cond));
1034 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1035 constexpr IValueT VFPOpcode = B27 | B26 | B25 | B11 | B9; 1024 constexpr IValueT VFPOpcode = B27 | B26 | B25 | B11 | B9;
1036 const IValueT Encoding = 1025 const IValueT Encoding =
1037 Opcode | VFPOpcode | (encodeCondition(Cond) << kConditionShift) | 1026 Opcode | VFPOpcode | (encodeCondition(Cond) << kConditionShift) |
1038 (getYInRegXXXXY(Sd) << 22) | (getXXXXInRegXXXXY(Sn) << 16) | 1027 (getYInRegXXXXY(Sd) << 22) | (getXXXXInRegXXXXY(Sn) << 16) |
1039 (getXXXXInRegXXXXY(Sd) << 12) | (getYInRegXXXXY(Sn) << 7) | 1028 (getXXXXInRegXXXXY(Sd) << 12) | (getYInRegXXXXY(Sn) << 7) |
1040 (getYInRegXXXXY(Sm) << 5) | getXXXXInRegXXXXY(Sm); 1029 (getYInRegXXXXY(Sm) << 5) | getXXXXInRegXXXXY(Sm);
1041 emitInst(Encoding); 1030 emitInst(Encoding);
1042 } 1031 }
1043 1032
1044 void AssemblerARM32::adc(const Operand *OpRd, const Operand *OpRn, 1033 void AssemblerARM32::adc(const Operand *OpRd, const Operand *OpRn,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1096
1108 void AssemblerARM32::b(Label *L, CondARM32::Cond Cond) { 1097 void AssemblerARM32::b(Label *L, CondARM32::Cond Cond) {
1109 emitBranch(L, Cond, false); 1098 emitBranch(L, Cond, false);
1110 } 1099 }
1111 1100
1112 void AssemblerARM32::bkpt(uint16_t Imm16) { 1101 void AssemblerARM32::bkpt(uint16_t Imm16) {
1113 // BKPT - ARM section A*.8.24 - encoding A1: 1102 // BKPT - ARM section A*.8.24 - encoding A1:
1114 // bkpt #<Imm16> 1103 // bkpt #<Imm16>
1115 // 1104 //
1116 // cccc00010010iiiiiiiiiiii0111iiii where cccc=AL and iiiiiiiiiiiiiiii=Imm16 1105 // cccc00010010iiiiiiiiiiii0111iiii where cccc=AL and iiiiiiiiiiiiiiii=Imm16
1117 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1118 const IValueT Encoding = (CondARM32::AL << kConditionShift) | B24 | B21 | 1106 const IValueT Encoding = (CondARM32::AL << kConditionShift) | B24 | B21 |
1119 ((Imm16 >> 4) << 8) | B6 | B5 | B4 | (Imm16 & 0xf); 1107 ((Imm16 >> 4) << 8) | B6 | B5 | B4 | (Imm16 & 0xf);
1120 emitInst(Encoding); 1108 emitInst(Encoding);
1121 } 1109 }
1122 1110
1123 void AssemblerARM32::bic(const Operand *OpRd, const Operand *OpRn, 1111 void AssemblerARM32::bic(const Operand *OpRd, const Operand *OpRn,
1124 const Operand *OpSrc1, bool SetFlags, 1112 const Operand *OpSrc1, bool SetFlags,
1125 CondARM32::Cond Cond) { 1113 CondARM32::Cond Cond) {
1126 // BIC (register) - ARM section A8.8.22, encoding A1: 1114 // BIC (register) - ARM section A8.8.22, encoding A1:
1127 // bic{s}<c> <Rd>, <Rn>, <Rm>{, <shift>} 1115 // bic{s}<c> <Rd>, <Rn>, <Rm>{, <shift>}
(...skipping 27 matching lines...) Expand all
1155 1143
1156 void AssemblerARM32::blx(const Operand *Target) { 1144 void AssemblerARM32::blx(const Operand *Target) {
1157 // BLX (register) - ARM section A8.8.26, encoding A1: 1145 // BLX (register) - ARM section A8.8.26, encoding A1:
1158 // blx<c> <Rm> 1146 // blx<c> <Rm>
1159 // 1147 //
1160 // cccc000100101111111111110011mmmm where cccc=Cond (not currently allowed) 1148 // cccc000100101111111111110011mmmm where cccc=Cond (not currently allowed)
1161 // and mmmm=Rm. 1149 // and mmmm=Rm.
1162 constexpr const char *BlxName = "Blx"; 1150 constexpr const char *BlxName = "Blx";
1163 IValueT Rm = encodeGPRegister(Target, "Rm", BlxName); 1151 IValueT Rm = encodeGPRegister(Target, "Rm", BlxName);
1164 verifyRegNotPc(Rm, "Rm", BlxName); 1152 verifyRegNotPc(Rm, "Rm", BlxName);
1165 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1166 constexpr CondARM32::Cond Cond = CondARM32::AL; 1153 constexpr CondARM32::Cond Cond = CondARM32::AL;
1167 int32_t Encoding = (encodeCondition(Cond) << kConditionShift) | B24 | B21 | 1154 int32_t Encoding = (encodeCondition(Cond) << kConditionShift) | B24 | B21 |
1168 (0xfff << 8) | B5 | B4 | (Rm << kRmShift); 1155 (0xfff << 8) | B5 | B4 | (Rm << kRmShift);
1169 emitInst(Encoding); 1156 emitInst(Encoding);
1170 } 1157 }
1171 1158
1172 void AssemblerARM32::bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond) { 1159 void AssemblerARM32::bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond) {
1173 // BX - ARM section A8.8.27, encoding A1: 1160 // BX - ARM section A8.8.27, encoding A1:
1174 // bx<c> <Rm> 1161 // bx<c> <Rm>
1175 // 1162 //
1176 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond. 1163 // cccc000100101111111111110001mmmm where mmmm=rm and cccc=Cond.
1177 assert(CondARM32::isDefined(Cond)); 1164 assert(CondARM32::isDefined(Cond));
1178 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1179 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B24 | 1165 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B24 |
1180 B21 | (0xfff << 8) | B4 | 1166 B21 | (0xfff << 8) | B4 |
1181 (encodeGPRRegister(Rm) << kRmShift); 1167 (encodeGPRRegister(Rm) << kRmShift);
1182 emitInst(Encoding); 1168 emitInst(Encoding);
1183 } 1169 }
1184 1170
1185 void AssemblerARM32::clz(const Operand *OpRd, const Operand *OpSrc, 1171 void AssemblerARM32::clz(const Operand *OpRd, const Operand *OpSrc,
1186 CondARM32::Cond Cond) { 1172 CondARM32::Cond Cond) {
1187 // CLZ - ARM section A8.8.33, encoding A1: 1173 // CLZ - ARM section A8.8.33, encoding A1:
1188 // clz<c> <Rd> <Rm> 1174 // clz<c> <Rd> <Rm>
1189 // 1175 //
1190 // cccc000101101111dddd11110001mmmm where cccc=Cond, dddd=Rd, and mmmm=Rm. 1176 // cccc000101101111dddd11110001mmmm where cccc=Cond, dddd=Rd, and mmmm=Rm.
1191 constexpr const char *ClzName = "clz"; 1177 constexpr const char *ClzName = "clz";
1192 constexpr const char *RdName = "Rd"; 1178 constexpr const char *RdName = "Rd";
1193 constexpr const char *RmName = "Rm"; 1179 constexpr const char *RmName = "Rm";
1194 IValueT Rd = encodeGPRegister(OpRd, RdName, ClzName); 1180 IValueT Rd = encodeGPRegister(OpRd, RdName, ClzName);
1195 assert(Rd < RegARM32::getNumGPRegs()); 1181 assert(Rd < RegARM32::getNumGPRegs());
1196 verifyRegNotPc(Rd, RdName, ClzName); 1182 verifyRegNotPc(Rd, RdName, ClzName);
1197 IValueT Rm = encodeGPRegister(OpSrc, RmName, ClzName); 1183 IValueT Rm = encodeGPRegister(OpSrc, RmName, ClzName);
1198 assert(Rm < RegARM32::getNumGPRegs()); 1184 assert(Rm < RegARM32::getNumGPRegs());
1199 verifyRegNotPc(Rm, RmName, ClzName); 1185 verifyRegNotPc(Rm, RmName, ClzName);
1200 assert(CondARM32::isDefined(Cond)); 1186 assert(CondARM32::isDefined(Cond));
1201 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1202 constexpr IValueT PredefinedBits = 1187 constexpr IValueT PredefinedBits =
1203 B24 | B22 | B21 | (0xF << 16) | (0xf << 8) | B4; 1188 B24 | B22 | B21 | (0xF << 16) | (0xf << 8) | B4;
1204 const IValueT Encoding = PredefinedBits | (Cond << kConditionShift) | 1189 const IValueT Encoding = PredefinedBits | (Cond << kConditionShift) |
1205 (Rd << kRdShift) | (Rm << kRmShift); 1190 (Rd << kRdShift) | (Rm << kRmShift);
1206 emitInst(Encoding); 1191 emitInst(Encoding);
1207 } 1192 }
1208 1193
1209 void AssemblerARM32::cmn(const Operand *OpRn, const Operand *OpSrc1, 1194 void AssemblerARM32::cmn(const Operand *OpRn, const Operand *OpSrc1,
1210 CondARM32::Cond Cond) { 1195 CondARM32::Cond Cond) {
1211 // CMN (immediate) - ARM section A8.8.34, encoding A1: 1196 // CMN (immediate) - ARM section A8.8.34, encoding A1:
(...skipping 29 matching lines...) Expand all
1241 constexpr IValueT CmpOpcode = B3 | B1; // ie. 1010 1226 constexpr IValueT CmpOpcode = B3 | B1; // ie. 1010
1242 emitCompareOp(Cond, CmpOpcode, OpRn, OpSrc1, CmpName); 1227 emitCompareOp(Cond, CmpOpcode, OpRn, OpSrc1, CmpName);
1243 } 1228 }
1244 1229
1245 void AssemblerARM32::dmb(IValueT Option) { 1230 void AssemblerARM32::dmb(IValueT Option) {
1246 // DMB - ARM section A8.8.43, encoding A1: 1231 // DMB - ARM section A8.8.43, encoding A1:
1247 // dmb <option> 1232 // dmb <option>
1248 // 1233 //
1249 // 1111010101111111111100000101xxxx where xxxx=Option. 1234 // 1111010101111111111100000101xxxx where xxxx=Option.
1250 assert(Utils::IsUint(4, Option) && "Bad dmb option"); 1235 assert(Utils::IsUint(4, Option) && "Bad dmb option");
1251 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1252 const IValueT Encoding = 1236 const IValueT Encoding =
1253 (encodeCondition(CondARM32::kNone) << kConditionShift) | B26 | B24 | B22 | 1237 (encodeCondition(CondARM32::kNone) << kConditionShift) | B26 | B24 | B22 |
1254 B21 | B20 | B19 | B18 | B17 | B16 | B15 | B14 | B13 | B12 | B6 | B4 | 1238 B21 | B20 | B19 | B18 | B17 | B16 | B15 | B14 | B13 | B12 | B6 | B4 |
1255 Option; 1239 Option;
1256 emitInst(Encoding); 1240 emitInst(Encoding);
1257 } 1241 }
1258 1242
1259 void AssemblerARM32::eor(const Operand *OpRd, const Operand *OpRn, 1243 void AssemblerARM32::eor(const Operand *OpRd, const Operand *OpRn,
1260 const Operand *OpSrc1, bool SetFlags, 1244 const Operand *OpSrc1, bool SetFlags,
1261 CondARM32::Cond Cond) { 1245 CondARM32::Cond Cond) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 } 1357 }
1374 IValueT AddressRn; 1358 IValueT AddressRn;
1375 if (encodeAddress(OpAddress, AddressRn, TInfo, OpEncodingMemEx) != 1359 if (encodeAddress(OpAddress, AddressRn, TInfo, OpEncodingMemEx) !=
1376 EncodedAsImmRegOffset) 1360 EncodedAsImmRegOffset)
1377 llvm::report_fatal_error(std::string(InstName) + 1361 llvm::report_fatal_error(std::string(InstName) +
1378 ": Can't extract Rn from address"); 1362 ": Can't extract Rn from address");
1379 assert(Utils::IsAbsoluteUint(3, MemExOpcode)); 1363 assert(Utils::IsAbsoluteUint(3, MemExOpcode));
1380 assert(Rd < RegARM32::getNumGPRegs()); 1364 assert(Rd < RegARM32::getNumGPRegs());
1381 assert(Rt < RegARM32::getNumGPRegs()); 1365 assert(Rt < RegARM32::getNumGPRegs());
1382 assert(CondARM32::isDefined(Cond)); 1366 assert(CondARM32::isDefined(Cond));
1383 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1384 IValueT Encoding = (Cond << kConditionShift) | B24 | B23 | B11 | B10 | B9 | 1367 IValueT Encoding = (Cond << kConditionShift) | B24 | B23 | B11 | B10 | B9 |
1385 B8 | B7 | B4 | (MemExOpcode << kMemExOpcodeShift) | 1368 B8 | B7 | B4 | (MemExOpcode << kMemExOpcodeShift) |
1386 AddressRn | (Rd << kRdShift) | (Rt << kRmShift); 1369 AddressRn | (Rd << kRdShift) | (Rt << kRmShift);
1387 emitInst(Encoding); 1370 emitInst(Encoding);
1388 return; 1371 return;
1389 } 1372 }
1390 1373
1391 void AssemblerARM32::ldrex(const Operand *OpRt, const Operand *OpAddress, 1374 void AssemblerARM32::ldrex(const Operand *OpRt, const Operand *OpAddress,
1392 CondARM32::Cond Cond, const TargetInfo &TInfo) { 1375 CondARM32::Cond Cond, const TargetInfo &TInfo) {
1393 // LDREXB - ARM section A8.8.76, encoding A1: 1376 // LDREXB - ARM section A8.8.76, encoding A1:
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 emitFixup(createMoveFixup(IsMovW, Src)); 1496 emitFixup(createMoveFixup(IsMovW, Src));
1514 // Use 0 for the lower 16 bits of the relocatable, and add a fixup to 1497 // Use 0 for the lower 16 bits of the relocatable, and add a fixup to
1515 // install the correct bits. 1498 // install the correct bits.
1516 Imm16 = 0; 1499 Imm16 = 0;
1517 } else if (encodeOperand(OpSrc, Imm16, WantGPRegs) != EncodedAsConstI32) { 1500 } else if (encodeOperand(OpSrc, Imm16, WantGPRegs) != EncodedAsConstI32) {
1518 llvm::report_fatal_error(std::string(MovName) + ": Not i32 constant"); 1501 llvm::report_fatal_error(std::string(MovName) + ": Not i32 constant");
1519 } 1502 }
1520 assert(CondARM32::isDefined(Cond)); 1503 assert(CondARM32::isDefined(Cond));
1521 if (!Utils::IsAbsoluteUint(16, Imm16)) 1504 if (!Utils::IsAbsoluteUint(16, Imm16))
1522 llvm::report_fatal_error(std::string(MovName) + ": Constant not i16"); 1505 llvm::report_fatal_error(std::string(MovName) + ": Constant not i16");
1523 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1524 const IValueT Encoding = encodeCondition(Cond) << kConditionShift | Opcode | 1506 const IValueT Encoding = encodeCondition(Cond) << kConditionShift | Opcode |
1525 ((Imm16 >> 12) << 16) | Rd << kRdShift | 1507 ((Imm16 >> 12) << 16) | Rd << kRdShift |
1526 (Imm16 & 0xfff); 1508 (Imm16 & 0xfff);
1527 emitInst(Encoding); 1509 emitInst(Encoding);
1528 } 1510 }
1529 1511
1530 void AssemblerARM32::movw(const Operand *OpRd, const Operand *OpSrc, 1512 void AssemblerARM32::movw(const Operand *OpRd, const Operand *OpSrc,
1531 CondARM32::Cond Cond) { 1513 CondARM32::Cond Cond) {
1532 // MOV (immediate) - ARM section A8.8.102, encoding A2: 1514 // MOV (immediate) - ARM section A8.8.102, encoding A2:
1533 // movw<c> <Rd>, #<imm16> 1515 // movw<c> <Rd>, #<imm16>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 constexpr bool SetFlags = false; 1553 constexpr bool SetFlags = false;
1572 emitType01(Cond, MvnOpcode, Rd, Rn, OpSrc, SetFlags, RdIsPcAndSetFlags, 1554 emitType01(Cond, MvnOpcode, Rd, Rn, OpSrc, SetFlags, RdIsPcAndSetFlags,
1573 MvnName); 1555 MvnName);
1574 } 1556 }
1575 1557
1576 void AssemblerARM32::nop() { 1558 void AssemblerARM32::nop() {
1577 // NOP - Section A8.8.119, encoding A1: 1559 // NOP - Section A8.8.119, encoding A1:
1578 // nop<c> 1560 // nop<c>
1579 // 1561 //
1580 // cccc0011001000001111000000000000 where cccc=Cond. 1562 // cccc0011001000001111000000000000 where cccc=Cond.
1581 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1582 constexpr CondARM32::Cond Cond = CondARM32::AL; 1563 constexpr CondARM32::Cond Cond = CondARM32::AL;
1583 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B25 | 1564 const IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B25 |
1584 B24 | B21 | B15 | B14 | B13 | B12; 1565 B24 | B21 | B15 | B14 | B13 | B12;
1585 emitInst(Encoding); 1566 emitInst(Encoding);
1586 } 1567 }
1587 1568
1588 void AssemblerARM32::sbc(const Operand *OpRd, const Operand *OpRn, 1569 void AssemblerARM32::sbc(const Operand *OpRd, const Operand *OpRn,
1589 const Operand *OpSrc1, bool SetFlags, 1570 const Operand *OpSrc1, bool SetFlags,
1590 CondARM32::Cond Cond) { 1571 CondARM32::Cond Cond) {
1591 // SBC (register) - ARM section 18.8.162, encoding A1: 1572 // SBC (register) - ARM section 18.8.162, encoding A1:
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 // Assembler registers rd, rn, rm are encoded as rn, rm, rs. 1830 // Assembler registers rd, rn, rm are encoded as rn, rm, rs.
1850 constexpr IValueT MulOpcode = 0; 1831 constexpr IValueT MulOpcode = 0;
1851 emitMulOp(Cond, MulOpcode, RegARM32::Encoded_Reg_r0, Rd, Rn, Rm, SetFlags); 1832 emitMulOp(Cond, MulOpcode, RegARM32::Encoded_Reg_r0, Rd, Rn, Rm, SetFlags);
1852 } 1833 }
1853 1834
1854 void AssemblerARM32::emitRdRm(CondARM32::Cond Cond, IValueT Opcode, 1835 void AssemblerARM32::emitRdRm(CondARM32::Cond Cond, IValueT Opcode,
1855 const Operand *OpRd, const Operand *OpRm, 1836 const Operand *OpRd, const Operand *OpRm,
1856 const char *InstName) { 1837 const char *InstName) {
1857 IValueT Rd = encodeGPRegister(OpRd, "Rd", InstName); 1838 IValueT Rd = encodeGPRegister(OpRd, "Rd", InstName);
1858 IValueT Rm = encodeGPRegister(OpRm, "Rm", InstName); 1839 IValueT Rm = encodeGPRegister(OpRm, "Rm", InstName);
1859 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
1860 IValueT Encoding = 1840 IValueT Encoding =
1861 (Cond << kConditionShift) | Opcode | (Rd << kRdShift) | (Rm << kRmShift); 1841 (Cond << kConditionShift) | Opcode | (Rd << kRdShift) | (Rm << kRmShift);
1862 emitInst(Encoding); 1842 emitInst(Encoding);
1863 } 1843 }
1864 1844
1865 void AssemblerARM32::rbit(const Operand *OpRd, const Operand *OpRm, 1845 void AssemblerARM32::rbit(const Operand *OpRd, const Operand *OpRm,
1866 CondARM32::Cond Cond) { 1846 CondARM32::Cond Cond) {
1867 // RBIT - ARM section A8.8.144, encoding A1: 1847 // RBIT - ARM section A8.8.144, encoding A1:
1868 // rbit<c> <Rd>, <Rm> 1848 // rbit<c> <Rd>, <Rm>
1869 // 1849 //
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 constexpr IValueT Sn = 0; 2097 constexpr IValueT Sn = 0;
2118 constexpr IValueT Sm = 0; 2098 constexpr IValueT Sm = 0;
2119 emitVFPsss(Cond, VcmpszOpcode, Sd, Sn, Sm); 2099 emitVFPsss(Cond, VcmpszOpcode, Sd, Sn, Sm);
2120 } 2100 }
2121 2101
2122 void AssemblerARM32::emitVFPsd(CondARM32::Cond Cond, IValueT Opcode, IValueT Sd, 2102 void AssemblerARM32::emitVFPsd(CondARM32::Cond Cond, IValueT Opcode, IValueT Sd,
2123 IValueT Dm) { 2103 IValueT Dm) {
2124 assert(Sd < RegARM32::getNumSRegs()); 2104 assert(Sd < RegARM32::getNumSRegs());
2125 assert(Dm < RegARM32::getNumDRegs()); 2105 assert(Dm < RegARM32::getNumDRegs());
2126 assert(CondARM32::isDefined(Cond)); 2106 assert(CondARM32::isDefined(Cond));
2127 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2128 constexpr IValueT VFPOpcode = B27 | B26 | B25 | B11 | B9; 2107 constexpr IValueT VFPOpcode = B27 | B26 | B25 | B11 | B9;
2129 const IValueT Encoding = 2108 const IValueT Encoding =
2130 Opcode | VFPOpcode | (encodeCondition(Cond) << kConditionShift) | 2109 Opcode | VFPOpcode | (encodeCondition(Cond) << kConditionShift) |
2131 (getYInRegXXXXY(Sd) << 22) | (getXXXXInRegXXXXY(Sd) << 12) | 2110 (getYInRegXXXXY(Sd) << 22) | (getXXXXInRegXXXXY(Sd) << 12) |
2132 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm); 2111 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm);
2133 emitInst(Encoding); 2112 emitInst(Encoding);
2134 } 2113 }
2135 2114
2136 void AssemblerARM32::vcvtdi(const Operand *OpDd, const Operand *OpSm, 2115 void AssemblerARM32::vcvtdi(const Operand *OpDd, const Operand *OpSm,
2137 CondARM32::Cond Cond) { 2116 CondARM32::Cond Cond) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 constexpr IValueT VcvtsiOpcode = B23 | B21 | B20 | B19 | B18 | B7 | B6; 2237 constexpr IValueT VcvtsiOpcode = B23 | B21 | B20 | B19 | B18 | B7 | B6;
2259 constexpr IValueT S0 = 0; 2238 constexpr IValueT S0 = 0;
2260 emitVFPsss(Cond, VcvtsiOpcode, Sd, S0, Sm); 2239 emitVFPsss(Cond, VcvtsiOpcode, Sd, S0, Sm);
2261 } 2240 }
2262 2241
2263 void AssemblerARM32::emitVFPds(CondARM32::Cond Cond, IValueT Opcode, IValueT Dd, 2242 void AssemblerARM32::emitVFPds(CondARM32::Cond Cond, IValueT Opcode, IValueT Dd,
2264 IValueT Sm) { 2243 IValueT Sm) {
2265 assert(Dd < RegARM32::getNumDRegs()); 2244 assert(Dd < RegARM32::getNumDRegs());
2266 assert(Sm < RegARM32::getNumSRegs()); 2245 assert(Sm < RegARM32::getNumSRegs());
2267 assert(CondARM32::isDefined(Cond)); 2246 assert(CondARM32::isDefined(Cond));
2268 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2269 constexpr IValueT VFPOpcode = B27 | B26 | B25 | B11 | B9; 2247 constexpr IValueT VFPOpcode = B27 | B26 | B25 | B11 | B9;
2270 const IValueT Encoding = 2248 const IValueT Encoding =
2271 Opcode | VFPOpcode | (encodeCondition(Cond) << kConditionShift) | 2249 Opcode | VFPOpcode | (encodeCondition(Cond) << kConditionShift) |
2272 (getYInRegYXXXX(Dd) << 22) | (getXXXXInRegYXXXX(Dd) << 12) | 2250 (getYInRegYXXXX(Dd) << 22) | (getXXXXInRegYXXXX(Dd) << 12) |
2273 (getYInRegXXXXY(Sm) << 5) | getXXXXInRegXXXXY(Sm); 2251 (getYInRegXXXXY(Sm) << 5) | getXXXXInRegXXXXY(Sm);
2274 emitInst(Encoding); 2252 emitInst(Encoding);
2275 } 2253 }
2276 2254
2277 void AssemblerARM32::vcvtds(const Operand *OpDd, const Operand *OpSm, 2255 void AssemblerARM32::vcvtds(const Operand *OpDd, const Operand *OpSm,
2278 CondARM32::Cond Cond) { 2256 CondARM32::Cond Cond) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 void AssemblerARM32::veord(const Operand *OpDd, const Operand *OpDn, 2294 void AssemblerARM32::veord(const Operand *OpDd, const Operand *OpDn,
2317 const Operand *OpDm) { 2295 const Operand *OpDm) {
2318 // VEOR - ARM secdtion A8.8.315, encoding A1: 2296 // VEOR - ARM secdtion A8.8.315, encoding A1:
2319 // veor<c> <Dd>, <Dn>, <Dm> 2297 // veor<c> <Dd>, <Dn>, <Dm>
2320 // 2298 //
2321 // 111100110D00nnnndddd0001N0M1mmmm where Ddddd=Dd, Nnnnn=Dn, and Mmmmm=Dm. 2299 // 111100110D00nnnndddd0001N0M1mmmm where Ddddd=Dd, Nnnnn=Dn, and Mmmmm=Dm.
2322 constexpr const char *Veord = "veord"; 2300 constexpr const char *Veord = "veord";
2323 IValueT Dd = encodeDRegister(OpDd, "Dd", Veord); 2301 IValueT Dd = encodeDRegister(OpDd, "Dd", Veord);
2324 IValueT Dn = encodeDRegister(OpDn, "Dn", Veord); 2302 IValueT Dn = encodeDRegister(OpDn, "Dn", Veord);
2325 IValueT Dm = encodeDRegister(OpDm, "Dm", Veord); 2303 IValueT Dm = encodeDRegister(OpDm, "Dm", Veord);
2326 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2327 const IValueT Encoding = 2304 const IValueT Encoding =
2328 B25 | B24 | B8 | B4 | 2305 B25 | B24 | B8 | B4 |
2329 (encodeCondition(CondARM32::Cond::kNone) << kConditionShift) | 2306 (encodeCondition(CondARM32::Cond::kNone) << kConditionShift) |
2330 (getYInRegYXXXX(Dd) << 22) | (getXXXXInRegYXXXX(Dn) << 16) | 2307 (getYInRegYXXXX(Dd) << 22) | (getXXXXInRegYXXXX(Dn) << 16) |
2331 (getXXXXInRegYXXXX(Dd) << 12) | (getYInRegYXXXX(Dn) << 7) | 2308 (getXXXXInRegYXXXX(Dd) << 12) | (getYInRegYXXXX(Dn) << 7) |
2332 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm); 2309 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm);
2333 emitInst(Encoding); 2310 emitInst(Encoding);
2334 } 2311 }
2335 2312
2336 void AssemblerARM32::vldrd(const Operand *OpDd, const Operand *OpAddress, 2313 void AssemblerARM32::vldrd(const Operand *OpDd, const Operand *OpAddress,
2337 CondARM32::Cond Cond, const TargetInfo &TInfo) { 2314 CondARM32::Cond Cond, const TargetInfo &TInfo) {
2338 // VLDR - ARM section A8.8.333, encoding A1. 2315 // VLDR - ARM section A8.8.333, encoding A1.
2339 // vldr<c> <Dd>, [<Rn>{, #+/-<imm>}] 2316 // vldr<c> <Dd>, [<Rn>{, #+/-<imm>}]
2340 // 2317 //
2341 // cccc1101UD01nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd, 2318 // cccc1101UD01nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd,
2342 // iiiiiiii=abs(Imm >> 2), and U=1 if Opcode>=0. 2319 // iiiiiiii=abs(Imm >> 2), and U=1 if Opcode>=0.
2343 constexpr const char *Vldrd = "vldrd"; 2320 constexpr const char *Vldrd = "vldrd";
2344 IValueT Dd = encodeDRegister(OpDd, "Dd", Vldrd); 2321 IValueT Dd = encodeDRegister(OpDd, "Dd", Vldrd);
2345 assert(CondARM32::isDefined(Cond)); 2322 assert(CondARM32::isDefined(Cond));
2346 IValueT Address; 2323 IValueT Address;
2347 EncodedOperand AddressEncoding = 2324 EncodedOperand AddressEncoding =
2348 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4); 2325 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4);
2349 (void)AddressEncoding; 2326 (void)AddressEncoding;
2350 assert(AddressEncoding == EncodedAsImmRegOffset); 2327 assert(AddressEncoding == EncodedAsImmRegOffset);
2351 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2352 IValueT Encoding = B27 | B26 | B24 | B20 | B11 | B9 | B8 | 2328 IValueT Encoding = B27 | B26 | B24 | B20 | B11 | B9 | B8 |
2353 (encodeCondition(Cond) << kConditionShift) | 2329 (encodeCondition(Cond) << kConditionShift) |
2354 (getYInRegYXXXX(Dd) << 22) | 2330 (getYInRegYXXXX(Dd) << 22) |
2355 (getXXXXInRegYXXXX(Dd) << 12) | Address; 2331 (getXXXXInRegYXXXX(Dd) << 12) | Address;
2356 emitInst(Encoding); 2332 emitInst(Encoding);
2357 } 2333 }
2358 2334
2359 void AssemblerARM32::vldrs(const Operand *OpSd, const Operand *OpAddress, 2335 void AssemblerARM32::vldrs(const Operand *OpSd, const Operand *OpAddress,
2360 CondARM32::Cond Cond, const TargetInfo &TInfo) { 2336 CondARM32::Cond Cond, const TargetInfo &TInfo) {
2361 // VDLR - ARM section A8.8.333, encoding A2. 2337 // VDLR - ARM section A8.8.333, encoding A2.
2362 // vldr<c> <Sd>, [<Rn>{, #+/-<imm>]] 2338 // vldr<c> <Sd>, [<Rn>{, #+/-<imm>]]
2363 // 2339 //
2364 // cccc1101UD01nnnndddd1010iiiiiiii where cccc=Cond, nnnn=Rn, ddddD=Sd, 2340 // cccc1101UD01nnnndddd1010iiiiiiii where cccc=Cond, nnnn=Rn, ddddD=Sd,
2365 // iiiiiiii=abs(Opcode), and U=1 if Opcode >= 0; 2341 // iiiiiiii=abs(Opcode), and U=1 if Opcode >= 0;
2366 constexpr const char *Vldrs = "vldrs"; 2342 constexpr const char *Vldrs = "vldrs";
2367 IValueT Sd = encodeSRegister(OpSd, "Sd", Vldrs); 2343 IValueT Sd = encodeSRegister(OpSd, "Sd", Vldrs);
2368 assert(CondARM32::isDefined(Cond)); 2344 assert(CondARM32::isDefined(Cond));
2369 IValueT Address; 2345 IValueT Address;
2370 EncodedOperand AddressEncoding = 2346 EncodedOperand AddressEncoding =
2371 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4); 2347 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4);
2372 (void)AddressEncoding; 2348 (void)AddressEncoding;
2373 assert(AddressEncoding == EncodedAsImmRegOffset); 2349 assert(AddressEncoding == EncodedAsImmRegOffset);
2374 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2375 IValueT Encoding = B27 | B26 | B24 | B20 | B11 | B9 | 2350 IValueT Encoding = B27 | B26 | B24 | B20 | B11 | B9 |
2376 (encodeCondition(Cond) << kConditionShift) | 2351 (encodeCondition(Cond) << kConditionShift) |
2377 (getYInRegXXXXY(Sd) << 22) | 2352 (getYInRegXXXXY(Sd) << 22) |
2378 (getXXXXInRegXXXXY(Sd) << 12) | Address; 2353 (getXXXXInRegXXXXY(Sd) << 12) | Address;
2379 emitInst(Encoding); 2354 emitInst(Encoding);
2380 } 2355 }
2381 2356
2382 void AssemblerARM32::vmovsr(const Operand *OpSn, const Operand *OpRt, 2357 void AssemblerARM32::vmovsr(const Operand *OpSn, const Operand *OpRt,
2383 CondARM32::Cond Cond) { 2358 CondARM32::Cond Cond) {
2384 // VMOV (between ARM core register and single-precision register) 2359 // VMOV (between ARM core register and single-precision register)
2385 // ARM section A8.8.343, encoding A1. 2360 // ARM section A8.8.343, encoding A1.
2386 // 2361 //
2387 // vmov<c> <Sn>, <Rt> 2362 // vmov<c> <Sn>, <Rt>
2388 // 2363 //
2389 // cccc1110000onnnntttt1010N0010000 where cccc=Cond, nnnnN = Sn, and tttt=Rt. 2364 // cccc1110000onnnntttt1010N0010000 where cccc=Cond, nnnnN = Sn, and tttt=Rt.
2390 constexpr const char *Vmovsr = "vmovsr"; 2365 constexpr const char *Vmovsr = "vmovsr";
2391 IValueT Sn = encodeSRegister(OpSn, "Sn", Vmovsr); 2366 IValueT Sn = encodeSRegister(OpSn, "Sn", Vmovsr);
2392 IValueT Rt = encodeGPRegister(OpRt, "Rt", Vmovsr); 2367 IValueT Rt = encodeGPRegister(OpRt, "Rt", Vmovsr);
2393 assert(Sn < RegARM32::getNumSRegs()); 2368 assert(Sn < RegARM32::getNumSRegs());
2394 assert(Rt < RegARM32::getNumGPRegs()); 2369 assert(Rt < RegARM32::getNumGPRegs());
2395 assert(CondARM32::isDefined(Cond)); 2370 assert(CondARM32::isDefined(Cond));
2396 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2397 IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B27 | B26 | 2371 IValueT Encoding = (encodeCondition(Cond) << kConditionShift) | B27 | B26 |
2398 B25 | B11 | B9 | B4 | (getXXXXInRegXXXXY(Sn) << 16) | 2372 B25 | B11 | B9 | B4 | (getXXXXInRegXXXXY(Sn) << 16) |
2399 (Rt << kRdShift) | (getYInRegXXXXY(Sn) << 7); 2373 (Rt << kRdShift) | (getYInRegXXXXY(Sn) << 7);
2400 emitInst(Encoding); 2374 emitInst(Encoding);
2401 } 2375 }
2402 2376
2403 void AssemblerARM32::vmrsAPSR_nzcv(CondARM32::Cond Cond) { 2377 void AssemblerARM32::vmrsAPSR_nzcv(CondARM32::Cond Cond) {
2404 // MVRS - ARM section A*.8.348, encoding A1: 2378 // MVRS - ARM section A*.8.348, encoding A1:
2405 // vmrs<c> APSR_nzcv, FPSCR 2379 // vmrs<c> APSR_nzcv, FPSCR
2406 // 2380 //
2407 // cccc111011110001tttt101000010000 where tttt=0x15 (i.e. when Rt=pc, use 2381 // cccc111011110001tttt101000010000 where tttt=0x15 (i.e. when Rt=pc, use
2408 // APSR_nzcv instead). 2382 // APSR_nzcv instead).
2409 assert(CondARM32::isDefined(Cond)); 2383 assert(CondARM32::isDefined(Cond));
2410 IValueT Encoding = B27 | B26 | B25 | B23 | B22 | B21 | B20 | B16 | B15 | B14 | 2384 IValueT Encoding = B27 | B26 | B25 | B23 | B22 | B21 | B20 | B16 | B15 | B14 |
2411 B13 | B12 | B11 | B9 | B4 | 2385 B13 | B12 | B11 | B9 | B4 |
2412 (encodeCondition(Cond) << kConditionShift); 2386 (encodeCondition(Cond) << kConditionShift);
2413 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2414 emitInst(Encoding); 2387 emitInst(Encoding);
2415 } 2388 }
2416 2389
2417 void AssemblerARM32::vmuls(const Operand *OpSd, const Operand *OpSn, 2390 void AssemblerARM32::vmuls(const Operand *OpSd, const Operand *OpSn,
2418 const Operand *OpSm, CondARM32::Cond Cond) { 2391 const Operand *OpSm, CondARM32::Cond Cond) {
2419 // VMUL (floating-point) - ARM section A8.8.351, encoding A2: 2392 // VMUL (floating-point) - ARM section A8.8.351, encoding A2:
2420 // vmul<c>.f32 <Sd>, <Sn>, <Sm> 2393 // vmul<c>.f32 <Sd>, <Sn>, <Sm>
2421 // 2394 //
2422 // cccc11100D10nnnndddd101sN0M0mmmm where cccc=Cond, s=0, ddddD=Rd, nnnnN=Rn, 2395 // cccc11100D10nnnndddd101sN0M0mmmm where cccc=Cond, s=0, ddddD=Rd, nnnnN=Rn,
2423 // and mmmmM=Rm. 2396 // and mmmmM=Rm.
(...skipping 28 matching lines...) Expand all
2452 // cccc1101UD00nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd, 2425 // cccc1101UD00nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd,
2453 // iiiiiiii=abs(Imm >> 2), and U=1 if Imm>=0. 2426 // iiiiiiii=abs(Imm >> 2), and U=1 if Imm>=0.
2454 constexpr const char *Vstrd = "vstrd"; 2427 constexpr const char *Vstrd = "vstrd";
2455 IValueT Dd = encodeDRegister(OpDd, "Dd", Vstrd); 2428 IValueT Dd = encodeDRegister(OpDd, "Dd", Vstrd);
2456 assert(CondARM32::isDefined(Cond)); 2429 assert(CondARM32::isDefined(Cond));
2457 IValueT Address; 2430 IValueT Address;
2458 IValueT AddressEncoding = 2431 IValueT AddressEncoding =
2459 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4); 2432 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4);
2460 (void)AddressEncoding; 2433 (void)AddressEncoding;
2461 assert(AddressEncoding == EncodedAsImmRegOffset); 2434 assert(AddressEncoding == EncodedAsImmRegOffset);
2462 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2463 IValueT Encoding = B27 | B26 | B24 | B11 | B9 | B8 | 2435 IValueT Encoding = B27 | B26 | B24 | B11 | B9 | B8 |
2464 (encodeCondition(Cond) << kConditionShift) | 2436 (encodeCondition(Cond) << kConditionShift) |
2465 (getYInRegYXXXX(Dd) << 22) | 2437 (getYInRegYXXXX(Dd) << 22) |
2466 (getXXXXInRegYXXXX(Dd) << 12) | Address; 2438 (getXXXXInRegYXXXX(Dd) << 12) | Address;
2467 emitInst(Encoding); 2439 emitInst(Encoding);
2468 } 2440 }
2469 2441
2470 void AssemblerARM32::vstrs(const Operand *OpSd, const Operand *OpAddress, 2442 void AssemblerARM32::vstrs(const Operand *OpSd, const Operand *OpAddress,
2471 CondARM32::Cond Cond, const TargetInfo &TInfo) { 2443 CondARM32::Cond Cond, const TargetInfo &TInfo) {
2472 // VSTR - ARM section A8.8.413, encoding A2: 2444 // VSTR - ARM section A8.8.413, encoding A2:
2473 // vstr<c> <Sd>, [<Rn>{, #+/-<imm>]] 2445 // vstr<c> <Sd>, [<Rn>{, #+/-<imm>]]
2474 // 2446 //
2475 // cccc1101UD01nnnndddd1010iiiiiiii where cccc=Cond, nnnn=Rn, ddddD=Sd, 2447 // cccc1101UD01nnnndddd1010iiiiiiii where cccc=Cond, nnnn=Rn, ddddD=Sd,
2476 // iiiiiiii=abs(Opcode), and U=1 if Opcode >= 0; 2448 // iiiiiiii=abs(Opcode), and U=1 if Opcode >= 0;
2477 constexpr const char *Vstrs = "vstrs"; 2449 constexpr const char *Vstrs = "vstrs";
2478 IValueT Sd = encodeSRegister(OpSd, "Sd", Vstrs); 2450 IValueT Sd = encodeSRegister(OpSd, "Sd", Vstrs);
2479 assert(CondARM32::isDefined(Cond)); 2451 assert(CondARM32::isDefined(Cond));
2480 IValueT Address; 2452 IValueT Address;
2481 IValueT AddressEncoding = 2453 IValueT AddressEncoding =
2482 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4); 2454 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4);
2483 (void)AddressEncoding; 2455 (void)AddressEncoding;
2484 assert(AddressEncoding == EncodedAsImmRegOffset); 2456 assert(AddressEncoding == EncodedAsImmRegOffset);
2485 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2486 IValueT Encoding = 2457 IValueT Encoding =
2487 B27 | B26 | B24 | B11 | B9 | (encodeCondition(Cond) << kConditionShift) | 2458 B27 | B26 | B24 | B11 | B9 | (encodeCondition(Cond) << kConditionShift) |
2488 (getYInRegXXXXY(Sd) << 22) | (getXXXXInRegXXXXY(Sd) << 12) | Address; 2459 (getYInRegXXXXY(Sd) << 22) | (getXXXXInRegXXXXY(Sd) << 12) | Address;
2489 emitInst(Encoding); 2460 emitInst(Encoding);
2490 } 2461 }
2491 2462
2492 void AssemblerARM32::vsubs(const Operand *OpSd, const Operand *OpSn, 2463 void AssemblerARM32::vsubs(const Operand *OpSd, const Operand *OpSn,
2493 const Operand *OpSm, CondARM32::Cond Cond) { 2464 const Operand *OpSm, CondARM32::Cond Cond) {
2494 // VSUB (floating-point) - ARM section A8.8.415, encoding A2: 2465 // VSUB (floating-point) - ARM section A8.8.415, encoding A2:
2495 // vsub<c>.f32 <Sd>, <Sn>, <Sm> 2466 // vsub<c>.f32 <Sd>, <Sn>, <Sm>
(...skipping 27 matching lines...) Expand all
2523 const Variable *OpBaseReg, 2494 const Variable *OpBaseReg,
2524 SizeT NumConsecRegs) { 2495 SizeT NumConsecRegs) {
2525 const IValueT BaseReg = getEncodedSRegNum(OpBaseReg); 2496 const IValueT BaseReg = getEncodedSRegNum(OpBaseReg);
2526 const IValueT DLastBit = mask(BaseReg, 0, 1); // Last bit of base register. 2497 const IValueT DLastBit = mask(BaseReg, 0, 1); // Last bit of base register.
2527 const IValueT Rd = mask(BaseReg, 1, 4); // Top 4 bits of base register. 2498 const IValueT Rd = mask(BaseReg, 1, 4); // Top 4 bits of base register.
2528 assert(0 < NumConsecRegs); 2499 assert(0 < NumConsecRegs);
2529 (void)VpushVpopMaxConsecRegs; 2500 (void)VpushVpopMaxConsecRegs;
2530 assert(NumConsecRegs <= VpushVpopMaxConsecRegs); 2501 assert(NumConsecRegs <= VpushVpopMaxConsecRegs);
2531 assert((BaseReg + NumConsecRegs) <= RegARM32::getNumSRegs()); 2502 assert((BaseReg + NumConsecRegs) <= RegARM32::getNumSRegs());
2532 assert(CondARM32::isDefined(Cond)); 2503 assert(CondARM32::isDefined(Cond));
2533 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2534 const IValueT Encoding = Opcode | (Cond << kConditionShift) | DLastBit | 2504 const IValueT Encoding = Opcode | (Cond << kConditionShift) | DLastBit |
2535 (Rd << kRdShift) | NumConsecRegs; 2505 (Rd << kRdShift) | NumConsecRegs;
2536 emitInst(Encoding); 2506 emitInst(Encoding);
2537 } 2507 }
2538 2508
2539 void AssemblerARM32::vpop(const Variable *OpBaseReg, SizeT NumConsecRegs, 2509 void AssemblerARM32::vpop(const Variable *OpBaseReg, SizeT NumConsecRegs,
2540 CondARM32::Cond Cond) { 2510 CondARM32::Cond Cond) {
2541 // Note: Current implementation assumes that OpBaseReg is defined using S 2511 // Note: Current implementation assumes that OpBaseReg is defined using S
2542 // registers. It doesn't implement the D register form. 2512 // registers. It doesn't implement the D register form.
2543 // 2513 //
(...skipping 17 matching lines...) Expand all
2561 // 2531 //
2562 // cccc11010D101101dddd1010iiiiiiii where cccc=Cond, ddddD=BaseReg, and 2532 // cccc11010D101101dddd1010iiiiiiii where cccc=Cond, ddddD=BaseReg, and
2563 // iiiiiiii=NumConsecRegs. 2533 // iiiiiiii=NumConsecRegs.
2564 constexpr IValueT VpushOpcode = 2534 constexpr IValueT VpushOpcode =
2565 B27 | B26 | B24 | B21 | B19 | B18 | B16 | B11 | B9; 2535 B27 | B26 | B24 | B21 | B19 | B18 | B16 | B11 | B9;
2566 emitVStackOp(Cond, VpushOpcode, OpBaseReg, NumConsecRegs); 2536 emitVStackOp(Cond, VpushOpcode, OpBaseReg, NumConsecRegs);
2567 } 2537 }
2568 2538
2569 } // end of namespace ARM32 2539 } // end of namespace ARM32
2570 } // end of namespace Ice 2540 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceAssemblerARM32.h ('k') | tests_lit/assembler/arm32/vmrs.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698