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

Side by Side Diff: src/compiler/arm64/instruction-selector-arm64-unittest.cc

Issue 550113002: [turbofan] Tests and fixes for ARM64 load/store with immediate offset. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated patch after changes arround ptrdiff_t. Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <list> 5 #include <list>
6 6
7 #include "src/compiler/instruction-selector-unittest.h" 7 #include "src/compiler/instruction-selector-unittest.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 // ----------------------------------------------------------------------------- 848 // -----------------------------------------------------------------------------
849 // Memory access instructions. 849 // Memory access instructions.
850 850
851 851
852 namespace { 852 namespace {
853 853
854 struct MemoryAccess { 854 struct MemoryAccess {
855 MachineType type; 855 MachineType type;
856 ArchOpcode ldr_opcode; 856 ArchOpcode ldr_opcode;
857 ArchOpcode str_opcode; 857 ArchOpcode str_opcode;
858 const int32_t immediates[20];
858 }; 859 };
859 860
860 861
861 std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) { 862 std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) {
862 OStringStream ost; 863 OStringStream ost;
863 ost << memacc.type; 864 ost << memacc.type;
864 return os << ost.c_str(); 865 return os << ost.c_str();
865 } 866 }
866 867
867 } // namespace 868 } // namespace
868 869
869 870
870 static const MemoryAccess kMemoryAccesses[] = { 871 static const MemoryAccess kMemoryAccesses[] = {
871 {kMachInt8, kArm64Ldrsb, kArm64Strb}, 872 {kMachInt8, kArm64Ldrsb, kArm64Strb,
872 {kMachUint8, kArm64Ldrb, kArm64Strb}, 873 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 257, 258, 1000, 1001,
873 {kMachInt16, kArm64Ldrsh, kArm64Strh}, 874 2121, 2442, 4093, 4094, 4095}},
874 {kMachUint16, kArm64Ldrh, kArm64Strh}, 875 {kMachUint8, kArm64Ldrb, kArm64Strb,
875 {kMachInt32, kArm64LdrW, kArm64StrW}, 876 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 257, 258, 1000, 1001,
876 {kMachUint32, kArm64LdrW, kArm64StrW}, 877 2121, 2442, 4093, 4094, 4095}},
877 {kMachInt64, kArm64Ldr, kArm64Str}, 878 {kMachInt16, kArm64Ldrsh, kArm64Strh,
878 {kMachUint64, kArm64Ldr, kArm64Str}, 879 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 258, 260, 4096, 4098,
879 {kMachFloat32, kArm64LdrS, kArm64StrS}, 880 4100, 4242, 6786, 8188, 8190}},
880 {kMachFloat64, kArm64LdrD, kArm64StrD}}; 881 {kMachUint16, kArm64Ldrh, kArm64Strh,
882 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 258, 260, 4096, 4098,
883 4100, 4242, 6786, 8188, 8190}},
884 {kMachInt32, kArm64LdrW, kArm64StrW,
885 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 260, 4096, 4100, 8192,
886 8196, 3276, 3280, 16376, 16380}},
887 {kMachUint32, kArm64LdrW, kArm64StrW,
888 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 260, 4096, 4100, 8192,
889 8196, 3276, 3280, 16376, 16380}},
890 {kMachInt64, kArm64Ldr, kArm64Str,
891 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 264, 4096, 4104, 8192,
892 8200, 16384, 16392, 32752, 32760}},
893 {kMachUint64, kArm64Ldr, kArm64Str,
894 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 264, 4096, 4104, 8192,
895 8200, 16384, 16392, 32752, 32760}},
896 {kMachFloat32, kArm64LdrS, kArm64StrS,
897 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 260, 4096, 4100, 8192,
898 8196, 3276, 3280, 16376, 16380}},
899 {kMachFloat64, kArm64LdrD, kArm64StrD,
900 {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 264, 4096, 4104, 8192,
901 8200, 16384, 16392, 32752, 32760}}};
881 902
882 903
883 typedef InstructionSelectorTestWithParam<MemoryAccess> 904 typedef InstructionSelectorTestWithParam<MemoryAccess>
884 InstructionSelectorMemoryAccessTest; 905 InstructionSelectorMemoryAccessTest;
885 906
886 907
887 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { 908 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) {
888 const MemoryAccess memacc = GetParam(); 909 const MemoryAccess memacc = GetParam();
889 StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32); 910 StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32);
890 m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1))); 911 m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1)));
891 Stream s = m.Build(); 912 Stream s = m.Build();
892 ASSERT_EQ(1U, s.size()); 913 ASSERT_EQ(1U, s.size());
893 EXPECT_EQ(memacc.ldr_opcode, s[0]->arch_opcode()); 914 EXPECT_EQ(memacc.ldr_opcode, s[0]->arch_opcode());
894 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); 915 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode());
895 EXPECT_EQ(2U, s[0]->InputCount()); 916 EXPECT_EQ(2U, s[0]->InputCount());
896 EXPECT_EQ(1U, s[0]->OutputCount()); 917 EXPECT_EQ(1U, s[0]->OutputCount());
897 } 918 }
898 919
899 920
921 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) {
922 const MemoryAccess memacc = GetParam();
923 TRACED_FOREACH(int32_t, index, memacc.immediates) {
924 StreamBuilder m(this, memacc.type, kMachPtr);
925 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index)));
926 Stream s = m.Build();
927 ASSERT_EQ(1U, s.size());
928 EXPECT_EQ(memacc.ldr_opcode, s[0]->arch_opcode());
929 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode());
930 EXPECT_EQ(2U, s[0]->InputCount());
931 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
932 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
933 ASSERT_EQ(1U, s[0]->OutputCount());
934 }
935 }
936
937
900 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { 938 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) {
901 const MemoryAccess memacc = GetParam(); 939 const MemoryAccess memacc = GetParam();
902 StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type); 940 StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type);
903 m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2)); 941 m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2));
904 m.Return(m.Int32Constant(0)); 942 m.Return(m.Int32Constant(0));
905 Stream s = m.Build(); 943 Stream s = m.Build();
906 ASSERT_EQ(1U, s.size()); 944 ASSERT_EQ(1U, s.size());
907 EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode()); 945 EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode());
908 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); 946 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode());
909 EXPECT_EQ(3U, s[0]->InputCount()); 947 EXPECT_EQ(3U, s[0]->InputCount());
910 EXPECT_EQ(0U, s[0]->OutputCount()); 948 EXPECT_EQ(0U, s[0]->OutputCount());
911 } 949 }
912 950
913 951
952 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) {
953 const MemoryAccess memacc = GetParam();
954 TRACED_FOREACH(int32_t, index, memacc.immediates) {
955 StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type);
956 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index),
957 m.Parameter(1));
958 m.Return(m.Int32Constant(0));
959 Stream s = m.Build();
960 ASSERT_EQ(1U, s.size());
961 EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode());
962 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode());
963 ASSERT_EQ(3U, s[0]->InputCount());
964 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
965 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
966 EXPECT_EQ(0U, s[0]->OutputCount());
967 }
968 }
969
970
914 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, 971 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
915 InstructionSelectorMemoryAccessTest, 972 InstructionSelectorMemoryAccessTest,
916 ::testing::ValuesIn(kMemoryAccesses)); 973 ::testing::ValuesIn(kMemoryAccesses));
917 974
918 } // namespace compiler 975 } // namespace compiler
919 } // namespace internal 976 } // namespace internal
920 } // namespace v8 977 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698