OLD | NEW |
1 | 1 |
2 // Copyright 2012 the V8 project authors. All rights reserved. | 2 // Copyright 2012 the V8 project authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include <limits.h> // For LONG_MIN, LONG_MAX. | 6 #include <limits.h> // For LONG_MIN, LONG_MAX. |
7 | 7 |
8 #if V8_TARGET_ARCH_MIPS | 8 #if V8_TARGET_ARCH_MIPS |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 srl(scratch, scratch, 16); | 1874 srl(scratch, scratch, 16); |
1875 andi(scratch, scratch, 0x0080); | 1875 andi(scratch, scratch, 0x0080); |
1876 Branch(&done, ne, scratch, Operand(zero_reg)); | 1876 Branch(&done, ne, scratch, Operand(zero_reg)); |
1877 mov(rd, rs); | 1877 mov(rd, rs); |
1878 bind(&done); | 1878 bind(&done); |
1879 } else { | 1879 } else { |
1880 movf(rd, rs, cc); | 1880 movf(rd, rs, cc); |
1881 } | 1881 } |
1882 } | 1882 } |
1883 | 1883 |
| 1884 #define __ masm-> |
| 1885 |
| 1886 static bool ZeroHelper_d(MacroAssembler* masm, MaxMinKind kind, FPURegister dst, |
| 1887 FPURegister src1, FPURegister src2, Label* equal) { |
| 1888 if (src1.is(src2)) { |
| 1889 __ Move(dst, src1); |
| 1890 return true; |
| 1891 } |
| 1892 |
| 1893 Label other, compare_not_equal; |
| 1894 FPURegister left, right; |
| 1895 if (kind == MaxMinKind::kMin) { |
| 1896 left = src1; |
| 1897 right = src2; |
| 1898 } else { |
| 1899 left = src2; |
| 1900 right = src1; |
| 1901 } |
| 1902 |
| 1903 __ BranchF64(&compare_not_equal, nullptr, ne, src1, src2); |
| 1904 // Left and right hand side are equal, check for -0 vs. +0. |
| 1905 __ FmoveHigh(t8, src1); |
| 1906 __ Branch(&other, eq, t8, Operand(0x80000000)); |
| 1907 __ Move_d(dst, right); |
| 1908 __ Branch(equal); |
| 1909 __ bind(&other); |
| 1910 __ Move_d(dst, left); |
| 1911 __ Branch(equal); |
| 1912 __ bind(&compare_not_equal); |
| 1913 return false; |
| 1914 } |
| 1915 |
| 1916 static bool ZeroHelper_s(MacroAssembler* masm, MaxMinKind kind, FPURegister dst, |
| 1917 FPURegister src1, FPURegister src2, Label* equal) { |
| 1918 if (src1.is(src2)) { |
| 1919 __ Move(dst, src1); |
| 1920 return true; |
| 1921 } |
| 1922 |
| 1923 Label other, compare_not_equal; |
| 1924 FPURegister left, right; |
| 1925 if (kind == MaxMinKind::kMin) { |
| 1926 left = src1; |
| 1927 right = src2; |
| 1928 } else { |
| 1929 left = src2; |
| 1930 right = src1; |
| 1931 } |
| 1932 |
| 1933 __ BranchF32(&compare_not_equal, nullptr, ne, src1, src2); |
| 1934 // Left and right hand side are equal, check for -0 vs. +0. |
| 1935 __ FmoveLow(t8, src1); |
| 1936 __ Branch(&other, eq, t8, Operand(0x80000000)); |
| 1937 __ Move_s(dst, right); |
| 1938 __ Branch(equal); |
| 1939 __ bind(&other); |
| 1940 __ Move_s(dst, left); |
| 1941 __ Branch(equal); |
| 1942 __ bind(&compare_not_equal); |
| 1943 return false; |
| 1944 } |
| 1945 |
| 1946 #undef __ |
| 1947 |
| 1948 void MacroAssembler::MinNaNCheck_d(FPURegister dst, FPURegister src1, |
| 1949 FPURegister src2, Label* nan) { |
| 1950 if (nan) { |
| 1951 BranchF64(nullptr, nan, eq, src1, src2); |
| 1952 } |
| 1953 if (IsMipsArchVariant(kMips32r6)) { |
| 1954 min_d(dst, src1, src2); |
| 1955 } else { |
| 1956 Label skip; |
| 1957 if (!ZeroHelper_d(this, MaxMinKind::kMin, dst, src1, src2, &skip)) { |
| 1958 if (dst.is(src1)) { |
| 1959 BranchF64(&skip, nullptr, le, src1, src2); |
| 1960 Move_d(dst, src2); |
| 1961 } else if (dst.is(src2)) { |
| 1962 BranchF64(&skip, nullptr, ge, src1, src2); |
| 1963 Move_d(dst, src1); |
| 1964 } else { |
| 1965 Label right; |
| 1966 BranchF64(&right, nullptr, gt, src1, src2); |
| 1967 Move_d(dst, src1); |
| 1968 Branch(&skip); |
| 1969 bind(&right); |
| 1970 Move_d(dst, src2); |
| 1971 } |
| 1972 } |
| 1973 bind(&skip); |
| 1974 } |
| 1975 } |
| 1976 |
| 1977 void MacroAssembler::MaxNaNCheck_d(FPURegister dst, FPURegister src1, |
| 1978 FPURegister src2, Label* nan) { |
| 1979 if (nan) { |
| 1980 BranchF64(nullptr, nan, eq, src1, src2); |
| 1981 } |
| 1982 if (IsMipsArchVariant(kMips32r6)) { |
| 1983 max_d(dst, src1, src2); |
| 1984 } else { |
| 1985 Label skip; |
| 1986 if (!ZeroHelper_d(this, MaxMinKind::kMax, dst, src1, src2, &skip)) { |
| 1987 if (dst.is(src1)) { |
| 1988 BranchF64(&skip, nullptr, ge, src1, src2); |
| 1989 Move_d(dst, src2); |
| 1990 } else if (dst.is(src2)) { |
| 1991 BranchF64(&skip, nullptr, le, src1, src2); |
| 1992 Move_d(dst, src1); |
| 1993 } else { |
| 1994 Label right; |
| 1995 BranchF64(&right, nullptr, lt, src1, src2); |
| 1996 Move_d(dst, src1); |
| 1997 Branch(&skip); |
| 1998 bind(&right); |
| 1999 Move_d(dst, src2); |
| 2000 } |
| 2001 } |
| 2002 bind(&skip); |
| 2003 } |
| 2004 } |
| 2005 |
| 2006 void MacroAssembler::MinNaNCheck_s(FPURegister dst, FPURegister src1, |
| 2007 FPURegister src2, Label* nan) { |
| 2008 if (nan) { |
| 2009 BranchF32(nullptr, nan, eq, src1, src2); |
| 2010 } |
| 2011 if (IsMipsArchVariant(kMips32r6)) { |
| 2012 min_s(dst, src1, src2); |
| 2013 } else { |
| 2014 Label skip; |
| 2015 if (!ZeroHelper_s(this, MaxMinKind::kMin, dst, src1, src2, &skip)) { |
| 2016 if (dst.is(src1)) { |
| 2017 BranchF32(&skip, nullptr, le, src1, src2); |
| 2018 Move_s(dst, src2); |
| 2019 } else if (dst.is(src2)) { |
| 2020 BranchF32(&skip, nullptr, ge, src1, src2); |
| 2021 Move_s(dst, src1); |
| 2022 } else { |
| 2023 Label right; |
| 2024 BranchF32(&right, nullptr, gt, src1, src2); |
| 2025 Move_s(dst, src1); |
| 2026 Branch(&skip); |
| 2027 bind(&right); |
| 2028 Move_s(dst, src2); |
| 2029 } |
| 2030 } |
| 2031 bind(&skip); |
| 2032 } |
| 2033 } |
| 2034 |
| 2035 void MacroAssembler::MaxNaNCheck_s(FPURegister dst, FPURegister src1, |
| 2036 FPURegister src2, Label* nan) { |
| 2037 if (nan) { |
| 2038 BranchF32(nullptr, nan, eq, src1, src2); |
| 2039 } |
| 2040 if (IsMipsArchVariant(kMips32r6)) { |
| 2041 max_s(dst, src1, src2); |
| 2042 } else { |
| 2043 Label skip; |
| 2044 if (!ZeroHelper_s(this, MaxMinKind::kMax, dst, src1, src2, &skip)) { |
| 2045 if (dst.is(src1)) { |
| 2046 BranchF32(&skip, nullptr, ge, src1, src2); |
| 2047 Move_s(dst, src2); |
| 2048 } else if (dst.is(src2)) { |
| 2049 BranchF32(&skip, nullptr, le, src1, src2); |
| 2050 Move_s(dst, src1); |
| 2051 } else { |
| 2052 Label right; |
| 2053 BranchF32(&right, nullptr, lt, src1, src2); |
| 2054 Move_s(dst, src1); |
| 2055 Branch(&skip); |
| 2056 bind(&right); |
| 2057 Move_s(dst, src2); |
| 2058 } |
| 2059 } |
| 2060 bind(&skip); |
| 2061 } |
| 2062 } |
1884 | 2063 |
1885 void MacroAssembler::Clz(Register rd, Register rs) { | 2064 void MacroAssembler::Clz(Register rd, Register rs) { |
1886 if (IsMipsArchVariant(kLoongson)) { | 2065 if (IsMipsArchVariant(kLoongson)) { |
1887 DCHECK(!(rd.is(t8) || rd.is(t9)) && !(rs.is(t8) || rs.is(t9))); | 2066 DCHECK(!(rd.is(t8) || rd.is(t9)) && !(rs.is(t8) || rs.is(t9))); |
1888 Register mask = t8; | 2067 Register mask = t8; |
1889 Register scratch = t9; | 2068 Register scratch = t9; |
1890 Label loop, end; | 2069 Label loop, end; |
1891 mov(at, rs); | 2070 mov(at, rs); |
1892 mov(rd, zero_reg); | 2071 mov(rd, zero_reg); |
1893 lui(mask, 0x8000); | 2072 lui(mask, 0x8000); |
(...skipping 4156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6050 if (mag.shift > 0) sra(result, result, mag.shift); | 6229 if (mag.shift > 0) sra(result, result, mag.shift); |
6051 srl(at, dividend, 31); | 6230 srl(at, dividend, 31); |
6052 Addu(result, result, Operand(at)); | 6231 Addu(result, result, Operand(at)); |
6053 } | 6232 } |
6054 | 6233 |
6055 | 6234 |
6056 } // namespace internal | 6235 } // namespace internal |
6057 } // namespace v8 | 6236 } // namespace v8 |
6058 | 6237 |
6059 #endif // V8_TARGET_ARCH_MIPS | 6238 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |