OLD | NEW |
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 "test/unittests/compiler/instruction-selector-unittest.h" | 5 #include "test/unittests/compiler/instruction-selector-unittest.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 m.Bind(&b); | 889 m.Bind(&b); |
890 m.Return(m.Int32Constant(0)); | 890 m.Return(m.Int32Constant(0)); |
891 Stream s = m.Build(); | 891 Stream s = m.Build(); |
892 ASSERT_EQ(1U, s.size()); | 892 ASSERT_EQ(1U, s.size()); |
893 EXPECT_EQ(kArm64TestAndBranch, s[0]->arch_opcode()); | 893 EXPECT_EQ(kArm64TestAndBranch, s[0]->arch_opcode()); |
894 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 894 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
895 EXPECT_EQ(4U, s[0]->InputCount()); | 895 EXPECT_EQ(4U, s[0]->InputCount()); |
896 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 896 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
897 EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1))); | 897 EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1))); |
898 } | 898 } |
899 | |
900 TRACED_FORRANGE(int, bit, 0, 63) { | |
901 uint64_t mask = 1L << bit; | |
902 StreamBuilder m(this, kMachInt64, kMachInt64); | |
903 MLabel a, b; | |
904 m.Branch( | |
905 m.Word64BinaryNot(m.Word64And(m.Parameter(0), m.Int64Constant(mask))), | |
906 &a, &b); | |
907 m.Bind(&a); | |
908 m.Return(m.Int32Constant(1)); | |
909 m.Bind(&b); | |
910 m.Return(m.Int32Constant(0)); | |
911 Stream s = m.Build(); | |
912 ASSERT_EQ(1U, s.size()); | |
913 EXPECT_EQ(kArm64TestAndBranch, s[0]->arch_opcode()); | |
914 EXPECT_EQ(kEqual, s[0]->flags_condition()); | |
915 EXPECT_EQ(4U, s[0]->InputCount()); | |
916 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | |
917 EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1))); | |
918 } | |
919 } | 899 } |
920 | 900 |
921 | 901 |
922 TEST_F(InstructionSelectorTest, Word64AndBranchWithOneBitMaskOnLeft) { | 902 TEST_F(InstructionSelectorTest, Word64AndBranchWithOneBitMaskOnLeft) { |
923 TRACED_FORRANGE(int, bit, 0, 63) { | 903 TRACED_FORRANGE(int, bit, 0, 63) { |
924 uint64_t mask = 1L << bit; | 904 uint64_t mask = 1L << bit; |
925 StreamBuilder m(this, kMachInt64, kMachInt64); | 905 StreamBuilder m(this, kMachInt64, kMachInt64); |
926 MLabel a, b; | 906 MLabel a, b; |
927 m.Branch(m.Word64And(m.Int64Constant(mask), m.Parameter(0)), &a, &b); | 907 m.Branch(m.Word64And(m.Int64Constant(mask), m.Parameter(0)), &a, &b); |
928 m.Bind(&a); | 908 m.Bind(&a); |
929 m.Return(m.Int32Constant(1)); | 909 m.Return(m.Int32Constant(1)); |
930 m.Bind(&b); | 910 m.Bind(&b); |
931 m.Return(m.Int32Constant(0)); | 911 m.Return(m.Int32Constant(0)); |
932 Stream s = m.Build(); | 912 Stream s = m.Build(); |
933 ASSERT_EQ(1U, s.size()); | 913 ASSERT_EQ(1U, s.size()); |
934 EXPECT_EQ(kArm64TestAndBranch, s[0]->arch_opcode()); | 914 EXPECT_EQ(kArm64TestAndBranch, s[0]->arch_opcode()); |
935 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 915 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
936 EXPECT_EQ(4U, s[0]->InputCount()); | 916 EXPECT_EQ(4U, s[0]->InputCount()); |
937 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 917 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
938 EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1))); | 918 EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1))); |
939 } | 919 } |
940 | |
941 TRACED_FORRANGE(int, bit, 0, 63) { | |
942 uint64_t mask = 1L << bit; | |
943 StreamBuilder m(this, kMachInt64, kMachInt64); | |
944 MLabel a, b; | |
945 m.Branch( | |
946 m.Word64BinaryNot(m.Word64And(m.Int64Constant(mask), m.Parameter(0))), | |
947 &a, &b); | |
948 m.Bind(&a); | |
949 m.Return(m.Int32Constant(1)); | |
950 m.Bind(&b); | |
951 m.Return(m.Int32Constant(0)); | |
952 Stream s = m.Build(); | |
953 ASSERT_EQ(1U, s.size()); | |
954 EXPECT_EQ(kArm64TestAndBranch, s[0]->arch_opcode()); | |
955 EXPECT_EQ(kEqual, s[0]->flags_condition()); | |
956 EXPECT_EQ(4U, s[0]->InputCount()); | |
957 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | |
958 EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1))); | |
959 } | |
960 } | 920 } |
961 | 921 |
962 | 922 |
963 TEST_F(InstructionSelectorTest, CompareAgainstZeroAndBranch) { | 923 TEST_F(InstructionSelectorTest, CompareAgainstZeroAndBranch) { |
964 { | 924 { |
965 StreamBuilder m(this, kMachInt32, kMachInt32); | 925 StreamBuilder m(this, kMachInt32, kMachInt32); |
966 MLabel a, b; | 926 MLabel a, b; |
967 Node* p0 = m.Parameter(0); | 927 Node* p0 = m.Parameter(0); |
968 m.Branch(p0, &a, &b); | 928 m.Branch(p0, &a, &b); |
969 m.Bind(&a); | 929 m.Bind(&a); |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 ASSERT_EQ(1U, s[0]->InputCount()); | 2156 ASSERT_EQ(1U, s[0]->InputCount()); |
2197 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2157 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
2198 ASSERT_EQ(1U, s[0]->OutputCount()); | 2158 ASSERT_EQ(1U, s[0]->OutputCount()); |
2199 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2159 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
2200 } | 2160 } |
2201 } | 2161 } |
2202 | 2162 |
2203 } // namespace compiler | 2163 } // namespace compiler |
2204 } // namespace internal | 2164 } // namespace internal |
2205 } // namespace v8 | 2165 } // namespace v8 |
OLD | NEW |