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

Side by Side Diff: src/compiler/arm/code-generator-arm.cc

Issue 2523933002: [Turbofan] Add ARM support for simd128 moves and swaps. (Closed)
Patch Set: Fix AssembleMove, AssembleSwap. Created 4 years 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
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 "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/arm/macro-assembler-arm.h" 7 #include "src/arm/macro-assembler-arm.h"
8 #include "src/compilation-info.h" 8 #include "src/compilation-info.h"
9 #include "src/compiler/code-generator-impl.h" 9 #include "src/compiler/code-generator-impl.h"
10 #include "src/compiler/gap-resolver.h" 10 #include "src/compiler/gap-resolver.h"
(...skipping 1873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 MachineRepresentation rep = LocationOperand::cast(source)->representation(); 1884 MachineRepresentation rep = LocationOperand::cast(source)->representation();
1885 if (rep == MachineRepresentation::kFloat64) { 1885 if (rep == MachineRepresentation::kFloat64) {
1886 DwVfpRegister src = g.ToDoubleRegister(source); 1886 DwVfpRegister src = g.ToDoubleRegister(source);
1887 if (destination->IsDoubleRegister()) { 1887 if (destination->IsDoubleRegister()) {
1888 DwVfpRegister dst = g.ToDoubleRegister(destination); 1888 DwVfpRegister dst = g.ToDoubleRegister(destination);
1889 __ Move(dst, src); 1889 __ Move(dst, src);
1890 } else { 1890 } else {
1891 DCHECK(destination->IsDoubleStackSlot()); 1891 DCHECK(destination->IsDoubleStackSlot());
1892 __ vstr(src, g.ToMemOperand(destination)); 1892 __ vstr(src, g.ToMemOperand(destination));
1893 } 1893 }
1894 } else { 1894 } else if (rep == MachineRepresentation::kFloat32) {
1895 DCHECK_EQ(MachineRepresentation::kFloat32, rep);
1896 // GapResolver may give us reg codes that don't map to actual s-registers. 1895 // GapResolver may give us reg codes that don't map to actual s-registers.
1897 // Generate code to work around those cases. 1896 // Generate code to work around those cases.
1898 int src_code = LocationOperand::cast(source)->register_code(); 1897 int src_code = LocationOperand::cast(source)->register_code();
1899 if (destination->IsFloatRegister()) { 1898 if (destination->IsFloatRegister()) {
1900 int dst_code = LocationOperand::cast(destination)->register_code(); 1899 int dst_code = LocationOperand::cast(destination)->register_code();
1901 __ VmovExtended(dst_code, src_code, kScratchReg); 1900 __ VmovExtended(dst_code, src_code, kScratchReg);
1902 } else { 1901 } else {
1903 DCHECK(destination->IsFloatStackSlot()); 1902 DCHECK(destination->IsFloatStackSlot());
1904 __ VmovExtended(g.ToMemOperand(destination), src_code, kScratchReg); 1903 __ VmovExtended(g.ToMemOperand(destination), src_code, kScratchReg);
1905 } 1904 }
1905 } else {
1906 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
1907 QwNeonRegister src = g.ToSimd128Register(source);
1908 if (destination->IsSimd128Register()) {
1909 QwNeonRegister dst = g.ToSimd128Register(destination);
1910 __ Move(dst, src);
1911 } else {
1912 DCHECK(destination->IsSimd128StackSlot());
1913 MemOperand dst = g.ToMemOperand(destination);
1914 __ vstr(src.low(), dst);
martyn.capewell 2016/11/23 20:08:46 TODO here to implement this using vst1, when the i
bbudge 2016/11/24 02:22:53 I switched to vst1.
1915 dst.set_offset(dst.offset() + kDoubleSize);
1916 __ vstr(src.high(), dst);
1917 }
1906 } 1918 }
1907 } else if (source->IsFPStackSlot()) { 1919 } else if (source->IsFPStackSlot()) {
1908 MemOperand src = g.ToMemOperand(source); 1920 MemOperand src = g.ToMemOperand(source);
1909 MachineRepresentation rep = 1921 MachineRepresentation rep =
1910 LocationOperand::cast(destination)->representation(); 1922 LocationOperand::cast(destination)->representation();
1911 if (destination->IsFPRegister()) { 1923 if (destination->IsFPRegister()) {
1912 if (rep == MachineRepresentation::kFloat64) { 1924 if (rep == MachineRepresentation::kFloat64) {
1913 __ vldr(g.ToDoubleRegister(destination), src); 1925 __ vldr(g.ToDoubleRegister(destination), src);
1914 } else { 1926 } else if (rep == MachineRepresentation::kFloat32) {
1915 DCHECK_EQ(MachineRepresentation::kFloat32, rep);
1916 // GapResolver may give us reg codes that don't map to actual 1927 // GapResolver may give us reg codes that don't map to actual
1917 // s-registers. Generate code to work around those cases. 1928 // s-registers. Generate code to work around those cases.
1918 int dst_code = LocationOperand::cast(destination)->register_code(); 1929 int dst_code = LocationOperand::cast(destination)->register_code();
1919 __ VmovExtended(dst_code, src, kScratchReg); 1930 __ VmovExtended(dst_code, src, kScratchReg);
1931 } else {
1932 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
1933 QwNeonRegister dst = g.ToSimd128Register(destination);
1934 __ vldr(dst.high(), src);
martyn.capewell 2016/11/23 20:08:46 TODO here to implement this using vld1, when the i
bbudge 2016/11/24 02:22:53 Switched to vld1.
1935 src.set_offset(src.offset() - 4);
1936 __ vldr(dst.low(), src);
1920 } 1937 }
1921 } else { 1938 } else if (rep == MachineRepresentation::kFloat64) {
1922 DCHECK(destination->IsFPStackSlot()); 1939 DCHECK(destination->IsFPStackSlot());
1923 if (rep == MachineRepresentation::kFloat64) { 1940 if (rep == MachineRepresentation::kFloat64) {
1924 DwVfpRegister temp = kScratchDoubleReg; 1941 DwVfpRegister temp = kScratchDoubleReg;
1925 __ vldr(temp, src); 1942 __ vldr(temp, src);
1926 __ vstr(temp, g.ToMemOperand(destination)); 1943 __ vstr(temp, g.ToMemOperand(destination));
1927 } else { 1944 } else if (rep == MachineRepresentation::kFloat32) {
1928 DCHECK_EQ(MachineRepresentation::kFloat32, rep);
1929 SwVfpRegister temp = kScratchDoubleReg.low(); 1945 SwVfpRegister temp = kScratchDoubleReg.low();
1930 __ vldr(temp, src); 1946 __ vldr(temp, src);
1931 __ vstr(temp, g.ToMemOperand(destination)); 1947 __ vstr(temp, g.ToMemOperand(destination));
1948 } else {
1949 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
1950 MemOperand dst = g.ToMemOperand(destination);
1951 __ vldr(kScratchDoubleReg, src);
martyn.capewell 2016/11/23 20:08:46 TODO here to implement this using vld1/vst1 and re
bbudge 2016/11/24 02:22:53 Switched to vld1/vst1.
1952 __ vstr(kScratchDoubleReg, dst);
1953 src.set_offset(src.offset() + kDoubleSize);
1954 dst.set_offset(dst.offset() + kDoubleSize);
1955 __ vldr(kScratchDoubleReg, src);
1956 __ vstr(kScratchDoubleReg, dst);
1932 } 1957 }
1933 } 1958 }
1934 } else { 1959 } else {
1935 UNREACHABLE(); 1960 UNREACHABLE();
1936 } 1961 }
1937 } 1962 }
1938 1963
1939
1940 void CodeGenerator::AssembleSwap(InstructionOperand* source, 1964 void CodeGenerator::AssembleSwap(InstructionOperand* source,
1941 InstructionOperand* destination) { 1965 InstructionOperand* destination) {
1942 ArmOperandConverter g(this, nullptr); 1966 ArmOperandConverter g(this, nullptr);
1943 // Dispatch on the source and destination operand kinds. Not all 1967 // Dispatch on the source and destination operand kinds. Not all
1944 // combinations are possible. 1968 // combinations are possible.
1945 if (source->IsRegister()) { 1969 if (source->IsRegister()) {
1946 // Register-register. 1970 // Register-register.
1947 Register temp = kScratchReg; 1971 Register temp = kScratchReg;
1948 Register src = g.ToRegister(source); 1972 Register src = g.ToRegister(source);
1949 if (destination->IsRegister()) { 1973 if (destination->IsRegister()) {
(...skipping 18 matching lines...) Expand all
1968 __ vldr(temp_1, dst); 1992 __ vldr(temp_1, dst);
1969 __ str(temp_0, dst); 1993 __ str(temp_0, dst);
1970 __ vstr(temp_1, src); 1994 __ vstr(temp_1, src);
1971 } else if (source->IsFPRegister()) { 1995 } else if (source->IsFPRegister()) {
1972 MachineRepresentation rep = LocationOperand::cast(source)->representation(); 1996 MachineRepresentation rep = LocationOperand::cast(source)->representation();
1973 LowDwVfpRegister temp = kScratchDoubleReg; 1997 LowDwVfpRegister temp = kScratchDoubleReg;
1974 if (rep == MachineRepresentation::kFloat64) { 1998 if (rep == MachineRepresentation::kFloat64) {
1975 DwVfpRegister src = g.ToDoubleRegister(source); 1999 DwVfpRegister src = g.ToDoubleRegister(source);
1976 if (destination->IsFPRegister()) { 2000 if (destination->IsFPRegister()) {
1977 DwVfpRegister dst = g.ToDoubleRegister(destination); 2001 DwVfpRegister dst = g.ToDoubleRegister(destination);
1978 __ vswp(src, dst); 2002 __ Swap(src, dst);
1979 } else { 2003 } else {
1980 DCHECK(destination->IsFPStackSlot()); 2004 DCHECK(destination->IsFPStackSlot());
1981 MemOperand dst = g.ToMemOperand(destination); 2005 MemOperand dst = g.ToMemOperand(destination);
1982 __ Move(temp, src); 2006 __ Move(temp, src);
1983 __ vldr(src, dst); 2007 __ vldr(src, dst);
1984 __ vstr(temp, dst); 2008 __ vstr(temp, dst);
1985 } 2009 }
1986 } else { 2010 } else if (rep == MachineRepresentation::kFloat32) {
1987 DCHECK_EQ(MachineRepresentation::kFloat32, rep);
1988 int src_code = LocationOperand::cast(source)->register_code(); 2011 int src_code = LocationOperand::cast(source)->register_code();
1989 if (destination->IsFPRegister()) { 2012 if (destination->IsFPRegister()) {
1990 int dst_code = LocationOperand::cast(destination)->register_code(); 2013 int dst_code = LocationOperand::cast(destination)->register_code();
1991 __ VmovExtended(temp.low().code(), src_code, kScratchReg); 2014 __ VmovExtended(temp.low().code(), src_code, kScratchReg);
1992 __ VmovExtended(src_code, dst_code, kScratchReg); 2015 __ VmovExtended(src_code, dst_code, kScratchReg);
1993 __ VmovExtended(dst_code, temp.low().code(), kScratchReg); 2016 __ VmovExtended(dst_code, temp.low().code(), kScratchReg);
1994 } else { 2017 } else {
1995 DCHECK(destination->IsFPStackSlot()); 2018 DCHECK(destination->IsFPStackSlot());
1996 MemOperand dst = g.ToMemOperand(destination); 2019 MemOperand dst = g.ToMemOperand(destination);
1997 __ VmovExtended(temp.low().code(), src_code, kScratchReg); 2020 __ VmovExtended(temp.low().code(), src_code, kScratchReg);
1998 __ VmovExtended(src_code, dst, kScratchReg); 2021 __ VmovExtended(src_code, dst, kScratchReg);
1999 __ vstr(temp.low(), dst); 2022 __ vstr(temp.low(), dst);
2000 } 2023 }
2024 } else {
2025 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2026 QwNeonRegister src = g.ToSimd128Register(source);
2027 if (destination->IsFPRegister()) {
2028 QwNeonRegister dst = g.ToSimd128Register(destination);
2029 __ Swap(src, dst);
2030 } else {
2031 DCHECK(destination->IsFPStackSlot());
2032 MemOperand dst = g.ToMemOperand(destination);
2033 QwNeonRegister temp = kScratchQuadReg;
2034 MemOperand dst2(dst.rn(), dst.offset() + kDoubleSize);
2035 __ Move(temp, src);
2036 __ vldr(src.low(), dst);
2037 __ vldr(src.high(), dst2);
2038 __ vstr(temp.low(), dst);
2039 __ vstr(temp.high(), dst2);
2040 __ vmov(kDoubleRegZero, 0); // Restore the 0 register.
martyn.capewell 2016/11/23 20:08:46 This is relatively expensive, which is why we stat
bbudge 2016/11/24 02:22:53 Added veor for d- and q- registers.
2041 }
2001 } 2042 }
2002 } else if (source->IsFPStackSlot()) { 2043 } else if (source->IsFPStackSlot()) {
2003 DCHECK(destination->IsFPStackSlot()); 2044 DCHECK(destination->IsFPStackSlot());
2004 Register temp_0 = kScratchReg; 2045 LowDwVfpRegister temp = kScratchDoubleReg;
2005 LowDwVfpRegister temp_1 = kScratchDoubleReg; 2046 LowDwVfpRegister zero = kDoubleRegZero;
2006 MemOperand src0 = g.ToMemOperand(source); 2047 MemOperand src = g.ToMemOperand(source);
2007 MemOperand dst0 = g.ToMemOperand(destination); 2048 MemOperand dst = g.ToMemOperand(destination);
2008 MachineRepresentation rep = LocationOperand::cast(source)->representation(); 2049 MachineRepresentation rep = LocationOperand::cast(source)->representation();
2009 if (rep == MachineRepresentation::kFloat64) { 2050 if (rep == MachineRepresentation::kFloat64) {
2010 MemOperand src1(src0.rn(), src0.offset() + kPointerSize); 2051 __ vldr(temp, dst);
2011 MemOperand dst1(dst0.rn(), dst0.offset() + kPointerSize); 2052 __ vldr(zero, src);
2012 __ vldr(temp_1, dst0); // Save destination in temp_1. 2053 __ vstr(temp, src);
2013 __ ldr(temp_0, src0); // Then use temp_0 to copy source to destination. 2054 __ vstr(zero, dst);
2014 __ str(temp_0, dst0); 2055 __ vmov(kDoubleRegZero, 0); // Restore the 0 register.
2015 __ ldr(temp_0, src1); 2056 } else if (rep == MachineRepresentation::kFloat32) {
2016 __ str(temp_0, dst1); 2057 __ vldr(temp.low(), dst);
2017 __ vstr(temp_1, src0); 2058 __ vldr(temp.high(), src);
2059 __ vstr(temp.low(), src);
2060 __ vstr(temp.high(), dst);
2018 } else { 2061 } else {
2019 DCHECK_EQ(MachineRepresentation::kFloat32, rep); 2062 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2020 __ vldr(temp_1.low(), dst0); // Save destination in temp_1. 2063 __ vldr(temp, dst);
2021 __ ldr(temp_0, src0); // Then use temp_0 to copy source to destination. 2064 __ vldr(zero, src);
2022 __ str(temp_0, dst0); 2065 __ vstr(temp, src);
2023 __ vstr(temp_1.low(), src0); 2066 __ vstr(zero, dst);
2067 src.set_offset(src.offset() + kDoubleSize);
2068 dst.set_offset(dst.offset() + kDoubleSize);
2069 __ vldr(temp, dst);
2070 __ vldr(zero, src);
2071 __ vstr(temp, src);
2072 __ vstr(zero, dst);
2073 __ vmov(kDoubleRegZero, 0); // Restore the 0 register.
2024 } 2074 }
2025 } else { 2075 } else {
2026 // No other combinations are possible. 2076 // No other combinations are possible.
2027 UNREACHABLE(); 2077 UNREACHABLE();
2028 } 2078 }
2029 } 2079 }
2030 2080
2031 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { 2081 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) {
2032 // On 32-bit ARM we emit the jump tables inline. 2082 // On 32-bit ARM we emit the jump tables inline.
2033 UNREACHABLE(); 2083 UNREACHABLE();
(...skipping 19 matching lines...) Expand all
2053 padding_size -= v8::internal::Assembler::kInstrSize; 2103 padding_size -= v8::internal::Assembler::kInstrSize;
2054 } 2104 }
2055 } 2105 }
2056 } 2106 }
2057 2107
2058 #undef __ 2108 #undef __
2059 2109
2060 } // namespace compiler 2110 } // namespace compiler
2061 } // namespace internal 2111 } // namespace internal
2062 } // namespace v8 2112 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698