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

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

Issue 605693003: [turbofan] ARM64 support for multiply-accumulate (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 const MachineType type = dpi.machine_type; 792 const MachineType type = dpi.machine_type;
793 StreamBuilder m(this, type, type, type); 793 StreamBuilder m(this, type, type, type);
794 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); 794 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)));
795 Stream s = m.Build(); 795 Stream s = m.Build();
796 ASSERT_EQ(1U, s.size()); 796 ASSERT_EQ(1U, s.size());
797 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); 797 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode());
798 EXPECT_EQ(2U, s[0]->InputCount()); 798 EXPECT_EQ(2U, s[0]->InputCount());
799 EXPECT_EQ(1U, s[0]->OutputCount()); 799 EXPECT_EQ(1U, s[0]->OutputCount());
800 } 800 }
801 801
802
802 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorMulDivTest, 803 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorMulDivTest,
803 ::testing::ValuesIn(kMulDivInstructions)); 804 ::testing::ValuesIn(kMulDivInstructions));
804 805
805 806
807 namespace {
808
809 struct MulDPInst {
810 const char* mul_constructor_name;
811 Node* (RawMachineAssembler::*mul_constructor)(Node*, Node*);
812 Node* (RawMachineAssembler::*add_constructor)(Node*, Node*);
813 Node* (RawMachineAssembler::*sub_constructor)(Node*, Node*);
814 ArchOpcode add_arch_opcode;
815 ArchOpcode sub_arch_opcode;
816 ArchOpcode neg_arch_opcode;
817 MachineType machine_type;
818 };
819
820
821 std::ostream& operator<<(std::ostream& os, const MulDPInst& inst) {
822 return os << inst.mul_constructor_name;
823 }
824
825 } // namespace
826
827
828 static const MulDPInst kMulDPInstructions[] = {
829 {"Int32Mul", &RawMachineAssembler::Int32Mul, &RawMachineAssembler::Int32Add,
830 &RawMachineAssembler::Int32Sub, kArm64Madd32, kArm64Msub32, kArm64Mneg32,
831 kMachInt32},
832 {"Int64Mul", &RawMachineAssembler::Int64Mul, &RawMachineAssembler::Int64Add,
833 &RawMachineAssembler::Int64Sub, kArm64Madd, kArm64Msub, kArm64Mneg,
834 kMachInt64}};
835
836
837 typedef InstructionSelectorTestWithParam<MulDPInst>
838 InstructionSelectorIntDPWithIntMulTest;
839
840
841 TEST_P(InstructionSelectorIntDPWithIntMulTest, AddWithMul) {
842 const MulDPInst mdpi = GetParam();
843 const MachineType type = mdpi.machine_type;
844 {
845 StreamBuilder m(this, type, type, type, type);
846 Node* n = (m.*mdpi.mul_constructor)(m.Parameter(1), m.Parameter(2));
847 m.Return((m.*mdpi.add_constructor)(m.Parameter(0), n));
848 Stream s = m.Build();
849 ASSERT_EQ(1U, s.size());
850 EXPECT_EQ(mdpi.add_arch_opcode, s[0]->arch_opcode());
851 EXPECT_EQ(3U, s[0]->InputCount());
852 EXPECT_EQ(1U, s[0]->OutputCount());
853 }
854 {
855 StreamBuilder m(this, type, type, type, type);
856 Node* n = (m.*mdpi.mul_constructor)(m.Parameter(0), m.Parameter(1));
857 m.Return((m.*mdpi.add_constructor)(n, m.Parameter(2)));
858 Stream s = m.Build();
859 ASSERT_EQ(1U, s.size());
860 EXPECT_EQ(mdpi.add_arch_opcode, s[0]->arch_opcode());
861 EXPECT_EQ(3U, s[0]->InputCount());
862 EXPECT_EQ(1U, s[0]->OutputCount());
863 }
864 }
865
866
867 TEST_P(InstructionSelectorIntDPWithIntMulTest, SubWithMul) {
868 const MulDPInst mdpi = GetParam();
869 const MachineType type = mdpi.machine_type;
870 {
871 StreamBuilder m(this, type, type, type, type);
872 Node* n = (m.*mdpi.mul_constructor)(m.Parameter(1), m.Parameter(2));
873 m.Return((m.*mdpi.sub_constructor)(m.Parameter(0), n));
874 Stream s = m.Build();
875 ASSERT_EQ(1U, s.size());
876 EXPECT_EQ(mdpi.sub_arch_opcode, s[0]->arch_opcode());
877 EXPECT_EQ(3U, s[0]->InputCount());
878 EXPECT_EQ(1U, s[0]->OutputCount());
879 }
880 }
881
882
883 TEST_P(InstructionSelectorIntDPWithIntMulTest, NegativeMul) {
884 const MulDPInst mdpi = GetParam();
885 const MachineType type = mdpi.machine_type;
886 {
887 StreamBuilder m(this, type, type, type);
888 Node* n =
889 (m.*mdpi.sub_constructor)(BuildConstant(m, type, 0), m.Parameter(0));
890 m.Return((m.*mdpi.mul_constructor)(n, m.Parameter(1)));
891 Stream s = m.Build();
892 ASSERT_EQ(1U, s.size());
893 EXPECT_EQ(mdpi.neg_arch_opcode, s[0]->arch_opcode());
894 EXPECT_EQ(2U, s[0]->InputCount());
895 EXPECT_EQ(1U, s[0]->OutputCount());
896 }
897 {
898 StreamBuilder m(this, type, type, type);
899 Node* n =
900 (m.*mdpi.sub_constructor)(BuildConstant(m, type, 0), m.Parameter(1));
901 m.Return((m.*mdpi.mul_constructor)(m.Parameter(0), n));
902 Stream s = m.Build();
903 ASSERT_EQ(1U, s.size());
904 EXPECT_EQ(mdpi.neg_arch_opcode, s[0]->arch_opcode());
905 EXPECT_EQ(2U, s[0]->InputCount());
906 EXPECT_EQ(1U, s[0]->OutputCount());
907 }
908 }
909
910
911 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
912 InstructionSelectorIntDPWithIntMulTest,
913 ::testing::ValuesIn(kMulDPInstructions));
914
915
806 // ----------------------------------------------------------------------------- 916 // -----------------------------------------------------------------------------
807 // Floating point instructions. 917 // Floating point instructions.
808 918
809 typedef InstructionSelectorTestWithParam<MachInst2> 919 typedef InstructionSelectorTestWithParam<MachInst2>
810 InstructionSelectorFPArithTest; 920 InstructionSelectorFPArithTest;
811 921
812 922
813 TEST_P(InstructionSelectorFPArithTest, Parameter) { 923 TEST_P(InstructionSelectorFPArithTest, Parameter) {
814 const MachInst2 fpa = GetParam(); 924 const MachInst2 fpa = GetParam();
815 StreamBuilder m(this, fpa.machine_type, fpa.machine_type, fpa.machine_type); 925 StreamBuilder m(this, fpa.machine_type, fpa.machine_type, fpa.machine_type);
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 ASSERT_EQ(1U, s.size()); 1388 ASSERT_EQ(1U, s.size());
1279 EXPECT_EQ(kArm64Not, s[0]->arch_opcode()); 1389 EXPECT_EQ(kArm64Not, s[0]->arch_opcode());
1280 EXPECT_EQ(1U, s[0]->InputCount()); 1390 EXPECT_EQ(1U, s[0]->InputCount());
1281 EXPECT_EQ(1U, s[0]->OutputCount()); 1391 EXPECT_EQ(1U, s[0]->OutputCount());
1282 } 1392 }
1283 } 1393 }
1284 1394
1285 } // namespace compiler 1395 } // namespace compiler
1286 } // namespace internal 1396 } // namespace internal
1287 } // namespace v8 1397 } // 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