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

Side by Side Diff: src/arm/disasm-arm.cc

Issue 2579913002: [ARM] Add NEON instructions for implementing SIMD. (Closed)
Patch Set: Clean up. 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 // A Disassembler object is used to disassemble a block of code instruction by 5 // A Disassembler object is used to disassemble a block of code instruction by
6 // instruction. The default implementation of the NameConverter object can be 6 // instruction. The default implementation of the NameConverter object can be
7 // overriden to modify register names or to do symbol lookup on addresses. 7 // overriden to modify register names or to do symbol lookup on addresses.
8 // 8 //
9 // The example below will disassemble a block of code and print it to stdout. 9 // The example below will disassemble a block of code and print it to stdout.
10 // 10 //
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 size, Vd, Vn, Vm); 1876 size, Vd, Vn, Vm);
1877 } else if (instr->Bits(11, 8) == 0xd && instr->Bit(4) == 0) { 1877 } else if (instr->Bits(11, 8) == 0xd && instr->Bit(4) == 0) {
1878 const char* op = (instr->Bits(21, 20) == 0) ? "vadd" : "vsub"; 1878 const char* op = (instr->Bits(21, 20) == 0) ? "vadd" : "vsub";
1879 int size = kBitsPerByte * (1 << instr->Bits(21, 20)); 1879 int size = kBitsPerByte * (1 << instr->Bits(21, 20));
1880 int Vd = instr->VFPDRegValue(kSimd128Precision); 1880 int Vd = instr->VFPDRegValue(kSimd128Precision);
1881 int Vm = instr->VFPMRegValue(kSimd128Precision); 1881 int Vm = instr->VFPMRegValue(kSimd128Precision);
1882 int Vn = instr->VFPNRegValue(kSimd128Precision); 1882 int Vn = instr->VFPNRegValue(kSimd128Precision);
1883 // vadd/vsub.f32 Qd, Qm, Qn. 1883 // vadd/vsub.f32 Qd, Qm, Qn.
1884 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, 1884 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1885 "%s.f32 q%d, q%d, q%d", op, Vd, Vn, Vm); 1885 "%s.f32 q%d, q%d, q%d", op, Vd, Vn, Vm);
1886 } else if (instr->Bits(11, 8) == 0x9 && instr->Bit(6) == 1 &&
1887 instr->Bit(4) == 1) {
1888 int size = kBitsPerByte * (1 << instr->Bits(21, 20));
1889 int Vd = instr->VFPDRegValue(kSimd128Precision);
1890 int Vm = instr->VFPMRegValue(kSimd128Precision);
1891 int Vn = instr->VFPNRegValue(kSimd128Precision);
1892 // vmul.i<size> Qd, Qm, Qn.
1893 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1894 "vmul.i%d q%d, q%d, q%d", size, Vd, Vn, Vm);
1886 } else { 1895 } else {
1887 Unknown(instr); 1896 Unknown(instr);
1888 } 1897 }
1889 break; 1898 break;
1890 case 5: 1899 case 5:
1891 if ((instr->Bits(18, 16) == 0) && (instr->Bits(11, 6) == 0x28) && 1900 if ((instr->Bits(18, 16) == 0) && (instr->Bits(11, 6) == 0x28) &&
1892 (instr->Bit(4) == 1)) { 1901 (instr->Bit(4) == 1)) {
1893 // vmovl signed 1902 // vmovl signed
1894 if ((instr->VdValue() & 1) != 0) Unknown(instr); 1903 if ((instr->VdValue() & 1) != 0) Unknown(instr);
1895 int Vd = (instr->Bit(22) << 3) | (instr->VdValue() >> 1); 1904 int Vd = (instr->Bit(22) << 3) | (instr->VdValue() >> 1);
1896 int Vm = (instr->Bit(5) << 4) | instr->VmValue(); 1905 int Vm = (instr->Bit(5) << 4) | instr->VmValue();
1897 int imm3 = instr->Bits(21, 19); 1906 int imm3 = instr->Bits(21, 19);
1898 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, 1907 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1899 "vmovl.s%d q%d, d%d", imm3*8, Vd, Vm); 1908 "vmovl.s%d q%d, d%d", imm3*8, Vd, Vm);
1909 } else if (instr->Bits(21, 20) == 3 && instr->Bit(4) == 0) {
1910 // vext.8 Qd, Qm, Qn, imm4
1911 int imm4 = instr->Bits(11, 8);
1912 int Vd = instr->VFPDRegValue(kSimd128Precision);
1913 int Vm = instr->VFPMRegValue(kSimd128Precision);
1914 int Vn = instr->VFPNRegValue(kSimd128Precision);
1915 out_buffer_pos_ +=
1916 SNPrintF(out_buffer_ + out_buffer_pos_, "vext.8 q%d, q%d, q%d, #%d",
1917 Vd, Vn, Vm, imm4);
1900 } else { 1918 } else {
1901 Unknown(instr); 1919 Unknown(instr);
1902 } 1920 }
1903 break; 1921 break;
1904 case 6: 1922 case 6:
1905 if (instr->Bits(11, 8) == 8) { 1923 if (instr->Bits(11, 8) == 8) {
1906 int size = kBitsPerByte * (1 << instr->Bits(21, 20)); 1924 int size = kBitsPerByte * (1 << instr->Bits(21, 20));
1907 int Vd = instr->VFPDRegValue(kSimd128Precision); 1925 int Vd = instr->VFPDRegValue(kSimd128Precision);
1908 int Vm = instr->VFPMRegValue(kSimd128Precision); 1926 int Vm = instr->VFPMRegValue(kSimd128Precision);
1909 int Vn = instr->VFPNRegValue(kSimd128Precision); 1927 int Vn = instr->VFPNRegValue(kSimd128Precision);
(...skipping 24 matching lines...) Expand all
1934 "veor d%d, d%d, d%d", Vd, Vn, Vm); 1952 "veor d%d, d%d, d%d", Vd, Vn, Vm);
1935 1953
1936 } else { 1954 } else {
1937 // veor Qd, Qn, Qm 1955 // veor Qd, Qn, Qm
1938 int Vd = instr->VFPDRegValue(kSimd128Precision); 1956 int Vd = instr->VFPDRegValue(kSimd128Precision);
1939 int Vn = instr->VFPNRegValue(kSimd128Precision); 1957 int Vn = instr->VFPNRegValue(kSimd128Precision);
1940 int Vm = instr->VFPMRegValue(kSimd128Precision); 1958 int Vm = instr->VFPMRegValue(kSimd128Precision);
1941 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, 1959 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1942 "veor q%d, q%d, q%d", Vd, Vn, Vm); 1960 "veor q%d, q%d, q%d", Vd, Vn, Vm);
1943 } 1961 }
1962 } else if (instr->Bit(21) == 0 && instr->Bits(11, 8) == 0xd &&
1963 instr->Bit(6) == 1 && instr->Bit(4) == 1) {
1964 // vmul.f32 Qd, Qn, Qm
1965 int Vd = instr->VFPDRegValue(kSimd128Precision);
1966 int Vn = instr->VFPNRegValue(kSimd128Precision);
1967 int Vm = instr->VFPMRegValue(kSimd128Precision);
1968 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1969 "vmul.f32 q%d, q%d, q%d", Vd, Vn, Vm);
1944 } else { 1970 } else {
1945 Unknown(instr); 1971 Unknown(instr);
1946 } 1972 }
1947 break; 1973 break;
1948 case 7: 1974 case 7:
1949 if ((instr->Bits(18, 16) == 0) && (instr->Bits(11, 6) == 0x28) && 1975 if ((instr->Bits(18, 16) == 0) && (instr->Bits(11, 6) == 0x28) &&
1950 (instr->Bit(4) == 1)) { 1976 (instr->Bit(4) == 1)) {
1951 // vmovl unsigned 1977 // vmovl unsigned
1952 if ((instr->VdValue() & 1) != 0) Unknown(instr); 1978 if ((instr->VdValue() & 1) != 0) Unknown(instr);
1953 int Vd = (instr->Bit(22) << 3) | (instr->VdValue() >> 1); 1979 int Vd = (instr->Bit(22) << 3) | (instr->VdValue() >> 1);
1954 int Vm = (instr->Bit(5) << 4) | instr->VmValue(); 1980 int Vm = (instr->Bit(5) << 4) | instr->VmValue();
1955 int imm3 = instr->Bits(21, 19); 1981 int imm3 = instr->Bits(21, 19);
1956 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, 1982 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1957 "vmovl.u%d q%d, d%d", imm3*8, Vd, Vm); 1983 "vmovl.u%d q%d, d%d", imm3*8, Vd, Vm);
1958 } else if (instr->Opc1Value() == 7 && instr->Bits(19, 16) == 0 && 1984 } else if (instr->Opc1Value() == 7 && instr->Bits(21, 20) == 0x3 &&
1959 instr->Bits(11, 6) == 0x17 && instr->Bit(4) == 0) {
1960 int Vd = instr->VFPDRegValue(kSimd128Precision);
1961 int Vm = instr->VFPMRegValue(kSimd128Precision);
1962 out_buffer_pos_ +=
1963 SNPrintF(out_buffer_ + out_buffer_pos_, "vmvn q%d, q%d", Vd, Vm);
1964 } else if (instr->Opc1Value() == 7 && instr->Bits(19, 16) == 0xB &&
1965 instr->Bits(11, 9) == 0x3 && instr->Bit(6) == 1 &&
1966 instr->Bit(4) == 0) { 1985 instr->Bit(4) == 0) {
1967 int Vd = instr->VFPDRegValue(kSimd128Precision); 1986 if (instr->Bits(17, 16) == 0x2 && instr->Bits(11, 7) == 0) {
1968 int Vm = instr->VFPMRegValue(kSimd128Precision); 1987 if (instr->Bit(6) == 0) {
1969 const char* suffix = nullptr; 1988 int Vd = instr->VFPDRegValue(kDoublePrecision);
1970 int op = instr->Bits(8, 7); 1989 int Vm = instr->VFPMRegValue(kDoublePrecision);
1971 switch (op) { 1990 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1972 case 0: 1991 "vswp d%d, d%d", Vd, Vm);
1973 suffix = "f32.s32"; 1992 } else {
1974 break; 1993 int Vd = instr->VFPDRegValue(kSimd128Precision);
1975 case 1: 1994 int Vm = instr->VFPMRegValue(kSimd128Precision);
1976 suffix = "f32.u32"; 1995 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1977 break; 1996 "vswp q%d, q%d", Vd, Vm);
1978 case 2: 1997 }
1979 suffix = "s32.f32"; 1998 } else if (instr->Bits(11, 7) == 0x18) {
1980 break; 1999 int Vd = instr->VFPDRegValue(kSimd128Precision);
1981 case 3:
1982 suffix = "u32.f32";
1983 break;
1984 }
1985 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1986 "vcvt.%s q%d, q%d", suffix, Vd, Vm);
1987 } else if ((instr->Bits(21, 16) == 0x32) && (instr->Bits(11, 7) == 0) &&
1988 (instr->Bit(4) == 0)) {
1989 if (instr->Bit(6) == 0) {
1990 int Vd = instr->VFPDRegValue(kDoublePrecision);
1991 int Vm = instr->VFPMRegValue(kDoublePrecision); 2000 int Vm = instr->VFPMRegValue(kDoublePrecision);
1992 out_buffer_pos_ += 2001 int index = instr->Bit(19);
1993 SNPrintF(out_buffer_ + out_buffer_pos_, "vswp d%d, d%d", Vd, Vm); 2002 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
1994 } else { 2003 "vdup q%d, d%d[%d]", Vd, Vm, index);
2004 } else if (instr->Bits(19, 16) == 0 && instr->Bits(11, 6) == 0x17) {
1995 int Vd = instr->VFPDRegValue(kSimd128Precision); 2005 int Vd = instr->VFPDRegValue(kSimd128Precision);
1996 int Vm = instr->VFPMRegValue(kSimd128Precision); 2006 int Vm = instr->VFPMRegValue(kSimd128Precision);
1997 out_buffer_pos_ += 2007 out_buffer_pos_ +=
1998 SNPrintF(out_buffer_ + out_buffer_pos_, "vswp q%d, q%d", Vd, Vm); 2008 SNPrintF(out_buffer_ + out_buffer_pos_, "vmvn q%d, q%d", Vd, Vm);
2009 } else if (instr->Bits(19, 16) == 0xB && instr->Bits(11, 9) == 0x3 &&
2010 instr->Bit(6) == 1) {
2011 int Vd = instr->VFPDRegValue(kSimd128Precision);
2012 int Vm = instr->VFPMRegValue(kSimd128Precision);
2013 const char* suffix = nullptr;
2014 int op = instr->Bits(8, 7);
2015 switch (op) {
2016 case 0:
2017 suffix = "f32.s32";
2018 break;
2019 case 1:
2020 suffix = "f32.u32";
2021 break;
2022 case 2:
2023 suffix = "s32.f32";
2024 break;
2025 case 3:
2026 suffix = "u32.f32";
2027 break;
2028 }
2029 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
2030 "vcvt.%s q%d, q%d", suffix, Vd, Vm);
2031 } else if (instr->Bits(11, 10) == 0x2) {
2032 int Vd = instr->VFPDRegValue(kDoublePrecision);
2033 int Vn = instr->VFPNRegValue(kDoublePrecision);
2034 int Vm = instr->VFPMRegValue(kDoublePrecision);
2035 int len = instr->Bits(9, 8);
2036 NeonListOperand list(DwVfpRegister::from_code(Vn), len + 1);
2037 out_buffer_pos_ +=
2038 SNPrintF(out_buffer_ + out_buffer_pos_, "%s d%d, ",
2039 instr->Bit(6) == 0 ? "vtbl.8" : "vtbx.8", Vd);
2040 FormatNeonList(Vn, list.type());
2041 Print(", ");
2042 PrintDRegister(Vm);
2043 } else if (instr->Bits(17, 16) == 0x2 && instr->Bits(11, 6) == 0x7) {
2044 int Vd = instr->VFPDRegValue(kSimd128Precision);
2045 int Vm = instr->VFPMRegValue(kSimd128Precision);
2046 int size = kBitsPerByte * (1 << instr->Bits(19, 18));
2047 // vzip.<size> Qd, Qm.
2048 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
2049 "vzip.%d q%d, q%d", size, Vd, Vm);
2050 } else if (instr->Bits(17, 16) == 0 && instr->Bits(11, 9) == 0) {
2051 int Vd = instr->VFPDRegValue(kSimd128Precision);
2052 int Vm = instr->VFPMRegValue(kSimd128Precision);
2053 int size = kBitsPerByte * (1 << instr->Bits(19, 18));
2054 int op = kBitsPerByte
2055 << (static_cast<int>(Neon64) - instr->Bits(8, 7));
2056 // vrev<op>.<size> Qd, Qm.
2057 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
2058 "vrev%d.%d q%d, q%d", op, size, Vd, Vm);
2059 } else if (instr->Bits(17, 16) == 0x1 && instr->Bit(11) == 0) {
2060 int Vd = instr->VFPDRegValue(kSimd128Precision);
2061 int Vm = instr->VFPMRegValue(kSimd128Precision);
2062 int size = kBitsPerByte * (1 << instr->Bits(19, 18));
2063 const char* type = instr->Bit(10) != 0 ? "f" : "s";
2064 if (instr->Bits(9, 6) == 0xd) {
2065 // vabs<type>.<size> Qd, Qm.
2066 out_buffer_pos_ +=
2067 SNPrintF(out_buffer_ + out_buffer_pos_, "vabs.%s%d q%d, q%d",
2068 type, size, Vd, Vm);
2069 } else if (instr->Bits(9, 6) == 0xf) {
2070 // vneg<type>.<size> Qd, Qm.
2071 out_buffer_pos_ +=
2072 SNPrintF(out_buffer_ + out_buffer_pos_, "vneg.%s%d q%d, q%d",
2073 type, size, Vd, Vm);
2074 } else {
2075 Unknown(instr);
2076 }
2077 } else {
2078 Unknown(instr);
1999 } 2079 }
2000 } else if (instr->Opc1Value() == 0x7 && instr->Bits(11, 7) == 0x18 && 2080 } else if (instr->Opc1Value() == 0x7 && instr->Bits(11, 7) == 0x18 &&
Rodolph Perfetta (ARM) 2016/12/16 20:50:11 this case has already been handled line 1998
bbudge 2016/12/17 01:08:32 Another nice catch, I had a bad merge somewhere. D
2001 instr->Bit(4) == 0x0) { 2081 instr->Bit(4) == 0x0) {
2002 int Vd = instr->VFPDRegValue(kSimd128Precision); 2082 int Vd = instr->VFPDRegValue(kSimd128Precision);
2003 int Vm = instr->VFPMRegValue(kDoublePrecision); 2083 int Vm = instr->VFPMRegValue(kDoublePrecision);
2004 int index = instr->Bit(19); 2084 int index = instr->Bit(19);
2005 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, 2085 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
2006 "vdup q%d, d%d[%d]", Vd, Vm, index); 2086 "vdup q%d, d%d[%d]", Vd, Vm, index);
2007 } else if (instr->Opc1Value() == 0x7 && instr->Bits(11, 10) == 0x2 && 2087 } else if (instr->Opc1Value() == 0x7 && instr->Bits(11, 10) == 0x2 &&
Rodolph Perfetta (ARM) 2016/12/16 20:50:11 already handled line 2031
bbudge 2016/12/17 01:08:32 Done.
2008 instr->Bit(4) == 0x0) { 2088 instr->Bit(4) == 0x0) {
2009 int Vd = instr->VFPDRegValue(kDoublePrecision); 2089 int Vd = instr->VFPDRegValue(kDoublePrecision);
2010 int Vn = instr->VFPNRegValue(kDoublePrecision); 2090 int Vn = instr->VFPNRegValue(kDoublePrecision);
2011 int Vm = instr->VFPMRegValue(kDoublePrecision); 2091 int Vm = instr->VFPMRegValue(kDoublePrecision);
2012 int len = instr->Bits(9, 8); 2092 int len = instr->Bits(9, 8);
2013 NeonListOperand list(DwVfpRegister::from_code(Vn), len + 1); 2093 NeonListOperand list(DwVfpRegister::from_code(Vn), len + 1);
2014 out_buffer_pos_ += 2094 out_buffer_pos_ +=
2015 SNPrintF(out_buffer_ + out_buffer_pos_, "%s d%d, ", 2095 SNPrintF(out_buffer_ + out_buffer_pos_, "%s d%d, ",
2016 instr->Bit(6) == 0 ? "vtbl.8" : "vtbx.8", Vd); 2096 instr->Bit(6) == 0 ? "vtbl.8" : "vtbx.8", Vd);
2017 FormatNeonList(Vn, list.type()); 2097 FormatNeonList(Vn, list.type());
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 pc += d.InstructionDecode(buffer, pc); 2435 pc += d.InstructionDecode(buffer, pc);
2356 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), 2436 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc),
2357 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); 2437 *reinterpret_cast<int32_t*>(prev_pc), buffer.start());
2358 } 2438 }
2359 } 2439 }
2360 2440
2361 2441
2362 } // namespace disasm 2442 } // namespace disasm
2363 2443
2364 #endif // V8_TARGET_ARCH_ARM 2444 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698