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

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: 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.high(), dst);
1915 dst.set_offset(dst.offset() - 4);
1916 __ vstr(src.low(), 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);
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);
1932 } 1950 }
1933 } 1951 }
1934 } else { 1952 } else {
1935 UNREACHABLE(); 1953 UNREACHABLE();
1936 } 1954 }
1937 } 1955 }
1938 1956
1939
1940 void CodeGenerator::AssembleSwap(InstructionOperand* source, 1957 void CodeGenerator::AssembleSwap(InstructionOperand* source,
1941 InstructionOperand* destination) { 1958 InstructionOperand* destination) {
1942 ArmOperandConverter g(this, nullptr); 1959 ArmOperandConverter g(this, nullptr);
1943 // Dispatch on the source and destination operand kinds. Not all 1960 // Dispatch on the source and destination operand kinds. Not all
1944 // combinations are possible. 1961 // combinations are possible.
1945 if (source->IsRegister()) { 1962 if (source->IsRegister()) {
1946 // Register-register. 1963 // Register-register.
1947 Register temp = kScratchReg; 1964 Register temp = kScratchReg;
1948 Register src = g.ToRegister(source); 1965 Register src = g.ToRegister(source);
1949 if (destination->IsRegister()) { 1966 if (destination->IsRegister()) {
(...skipping 18 matching lines...) Expand all
1968 __ vldr(temp_1, dst); 1985 __ vldr(temp_1, dst);
1969 __ str(temp_0, dst); 1986 __ str(temp_0, dst);
1970 __ vstr(temp_1, src); 1987 __ vstr(temp_1, src);
1971 } else if (source->IsFPRegister()) { 1988 } else if (source->IsFPRegister()) {
1972 MachineRepresentation rep = LocationOperand::cast(source)->representation(); 1989 MachineRepresentation rep = LocationOperand::cast(source)->representation();
1973 LowDwVfpRegister temp = kScratchDoubleReg; 1990 LowDwVfpRegister temp = kScratchDoubleReg;
1974 if (rep == MachineRepresentation::kFloat64) { 1991 if (rep == MachineRepresentation::kFloat64) {
1975 DwVfpRegister src = g.ToDoubleRegister(source); 1992 DwVfpRegister src = g.ToDoubleRegister(source);
1976 if (destination->IsFPRegister()) { 1993 if (destination->IsFPRegister()) {
1977 DwVfpRegister dst = g.ToDoubleRegister(destination); 1994 DwVfpRegister dst = g.ToDoubleRegister(destination);
1978 __ vswp(src, dst); 1995 __ Swap(src, dst);
1979 } else { 1996 } else {
1980 DCHECK(destination->IsFPStackSlot()); 1997 DCHECK(destination->IsFPStackSlot());
1981 MemOperand dst = g.ToMemOperand(destination); 1998 MemOperand dst = g.ToMemOperand(destination);
1982 __ Move(temp, src); 1999 __ Move(temp, src);
1983 __ vldr(src, dst); 2000 __ vldr(src, dst);
1984 __ vstr(temp, dst); 2001 __ vstr(temp, dst);
1985 } 2002 }
1986 } else { 2003 } else if (rep == MachineRepresentation::kFloat32) {
1987 DCHECK_EQ(MachineRepresentation::kFloat32, rep);
1988 int src_code = LocationOperand::cast(source)->register_code(); 2004 int src_code = LocationOperand::cast(source)->register_code();
1989 if (destination->IsFPRegister()) { 2005 if (destination->IsFPRegister()) {
1990 int dst_code = LocationOperand::cast(destination)->register_code(); 2006 int dst_code = LocationOperand::cast(destination)->register_code();
1991 __ VmovExtended(temp.low().code(), src_code, kScratchReg); 2007 __ VmovExtended(temp.low().code(), src_code, kScratchReg);
1992 __ VmovExtended(src_code, dst_code, kScratchReg); 2008 __ VmovExtended(src_code, dst_code, kScratchReg);
1993 __ VmovExtended(dst_code, temp.low().code(), kScratchReg); 2009 __ VmovExtended(dst_code, temp.low().code(), kScratchReg);
1994 } else { 2010 } else {
1995 DCHECK(destination->IsFPStackSlot()); 2011 DCHECK(destination->IsFPStackSlot());
1996 MemOperand dst = g.ToMemOperand(destination); 2012 MemOperand dst = g.ToMemOperand(destination);
1997 __ VmovExtended(temp.low().code(), src_code, kScratchReg); 2013 __ VmovExtended(temp.low().code(), src_code, kScratchReg);
1998 __ VmovExtended(src_code, dst, kScratchReg); 2014 __ VmovExtended(src_code, dst, kScratchReg);
1999 __ vstr(temp.low(), dst); 2015 __ vstr(temp.low(), dst);
2000 } 2016 }
2017 } else {
2018 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2019 QwNeonRegister src = g.ToSimd128Register(source);
2020 if (destination->IsFPRegister()) {
2021 QwNeonRegister dst = g.ToSimd128Register(destination);
2022 __ Swap(src, dst);
2023 } else {
2024 DCHECK(destination->IsFPStackSlot());
2025 MemOperand dst = g.ToMemOperand(destination);
2026 QwNeonRegister temp = kScratchQuadReg;
2027 MemOperand dst2(dst.rn(), dst.offset() + kDoubleSize);
2028 __ Move(temp, src);
2029 __ vldr(src.low(), dst);
2030 __ vldr(src.high(), dst2);
2031 __ vstr(temp.low(), dst);
2032 __ vstr(temp.high(), dst2);
2033 __ vmov(kDoubleRegZero, 0); // Restore the 0 register.
2034 }
2001 } 2035 }
2002 } else if (source->IsFPStackSlot()) { 2036 } else if (source->IsFPStackSlot()) {
2003 DCHECK(destination->IsFPStackSlot()); 2037 DCHECK(destination->IsFPStackSlot());
2004 Register temp_0 = kScratchReg; 2038 LowDwVfpRegister temp = kScratchDoubleReg;
2005 LowDwVfpRegister temp_1 = kScratchDoubleReg; 2039 LowDwVfpRegister zero = kDoubleRegZero;
2006 MemOperand src0 = g.ToMemOperand(source); 2040 MemOperand src = g.ToMemOperand(source);
2007 MemOperand dst0 = g.ToMemOperand(destination); 2041 MemOperand dst = g.ToMemOperand(destination);
2008 MachineRepresentation rep = LocationOperand::cast(source)->representation(); 2042 MachineRepresentation rep = LocationOperand::cast(source)->representation();
2009 if (rep == MachineRepresentation::kFloat64) { 2043 if (rep == MachineRepresentation::kFloat64) {
2010 MemOperand src1(src0.rn(), src0.offset() + kPointerSize); 2044 __ vldr(temp, dst);
2011 MemOperand dst1(dst0.rn(), dst0.offset() + kPointerSize); 2045 __ vldr(zero, src);
2012 __ vldr(temp_1, dst0); // Save destination in temp_1. 2046 __ vstr(temp, src);
2013 __ ldr(temp_0, src0); // Then use temp_0 to copy source to destination. 2047 __ vstr(zero, dst);
2014 __ str(temp_0, dst0); 2048 __ vmov(kDoubleRegZero, 0); // Restore the 0 register.
2015 __ ldr(temp_0, src1); 2049 } else if (rep == MachineRepresentation::kFloat32) {
2016 __ str(temp_0, dst1); 2050 __ vldr(temp.low(), dst);
2017 __ vstr(temp_1, src0); 2051 __ vldr(temp.high(), src);
2052 __ vstr(temp.low(), src);
2053 __ vstr(temp.high(), dst);
2018 } else { 2054 } else {
2019 DCHECK_EQ(MachineRepresentation::kFloat32, rep); 2055 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2020 __ vldr(temp_1.low(), dst0); // Save destination in temp_1. 2056 MemOperand src2(src.rn(), src.offset() + kDoubleSize);
2021 __ ldr(temp_0, src0); // Then use temp_0 to copy source to destination. 2057 MemOperand dst2(dst.rn(), dst.offset() + kDoubleSize);
2022 __ str(temp_0, dst0); 2058 __ vldr(temp, dst);
2023 __ vstr(temp_1.low(), src0); 2059 __ vldr(zero, src);
2060 __ vstr(temp, src);
2061 __ vstr(zero, dst);
2062 __ vldr(temp, dst2);
2063 __ vldr(zero, src2);
2064 __ vstr(temp, src2);
2065 __ vstr(zero, dst2);
2066 __ vmov(kDoubleRegZero, 0); // Restore the 0 register.
2024 } 2067 }
2025 } else { 2068 } else {
2026 // No other combinations are possible. 2069 // No other combinations are possible.
2027 UNREACHABLE(); 2070 UNREACHABLE();
2028 } 2071 }
2029 } 2072 }
2030 2073
2031 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { 2074 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) {
2032 // On 32-bit ARM we emit the jump tables inline. 2075 // On 32-bit ARM we emit the jump tables inline.
2033 UNREACHABLE(); 2076 UNREACHABLE();
(...skipping 19 matching lines...) Expand all
2053 padding_size -= v8::internal::Assembler::kInstrSize; 2096 padding_size -= v8::internal::Assembler::kInstrSize;
2054 } 2097 }
2055 } 2098 }
2056 } 2099 }
2057 2100
2058 #undef __ 2101 #undef __
2059 2102
2060 } // namespace compiler 2103 } // namespace compiler
2061 } // namespace internal 2104 } // namespace internal
2062 } // namespace v8 2105 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698