OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compilation-info.h" | 7 #include "src/compilation-info.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 break; | 1927 break; |
1928 } | 1928 } |
1929 case kS390_ExtendSignWord8: | 1929 case kS390_ExtendSignWord8: |
1930 __ lbr(i.OutputRegister(), i.InputRegister(0)); | 1930 __ lbr(i.OutputRegister(), i.InputRegister(0)); |
1931 CHECK_AND_ZERO_EXT_OUTPUT(1); | 1931 CHECK_AND_ZERO_EXT_OUTPUT(1); |
1932 break; | 1932 break; |
1933 case kS390_ExtendSignWord16: | 1933 case kS390_ExtendSignWord16: |
1934 __ lhr(i.OutputRegister(), i.InputRegister(0)); | 1934 __ lhr(i.OutputRegister(), i.InputRegister(0)); |
1935 CHECK_AND_ZERO_EXT_OUTPUT(1); | 1935 CHECK_AND_ZERO_EXT_OUTPUT(1); |
1936 break; | 1936 break; |
1937 #if V8_TARGET_ARCH_S390X | |
1938 case kS390_ExtendSignWord32: | 1937 case kS390_ExtendSignWord32: |
1939 __ lgfr(i.OutputRegister(), i.InputRegister(0)); | 1938 __ lgfr(i.OutputRegister(), i.InputRegister(0)); |
1940 break; | 1939 break; |
1941 case kS390_Uint32ToUint64: | 1940 case kS390_Uint32ToUint64: |
1942 // Zero extend | 1941 // Zero extend |
1943 __ llgfr(i.OutputRegister(), i.InputRegister(0)); | 1942 __ llgfr(i.OutputRegister(), i.InputRegister(0)); |
1944 break; | 1943 break; |
1945 case kS390_Int64ToInt32: | 1944 case kS390_Int64ToInt32: |
1946 // sign extend | 1945 // sign extend |
1947 __ lgfr(i.OutputRegister(), i.InputRegister(0)); | 1946 __ lgfr(i.OutputRegister(), i.InputRegister(0)); |
1948 break; | 1947 break; |
| 1948 // Convert Fixed to Floating Point |
1949 case kS390_Int64ToFloat32: | 1949 case kS390_Int64ToFloat32: |
1950 __ ConvertInt64ToFloat(i.InputRegister(0), i.OutputDoubleRegister()); | 1950 __ ConvertInt64ToFloat(i.OutputDoubleRegister(), i.InputRegister(0)); |
1951 break; | 1951 break; |
1952 case kS390_Int64ToDouble: | 1952 case kS390_Int64ToDouble: |
1953 __ ConvertInt64ToDouble(i.InputRegister(0), i.OutputDoubleRegister()); | 1953 __ ConvertInt64ToDouble(i.OutputDoubleRegister(), i.InputRegister(0)); |
1954 break; | 1954 break; |
1955 case kS390_Uint64ToFloat32: | 1955 case kS390_Uint64ToFloat32: |
1956 __ ConvertUnsignedInt64ToFloat(i.InputRegister(0), | 1956 __ ConvertUnsignedInt64ToFloat(i.OutputDoubleRegister(), |
1957 i.OutputDoubleRegister()); | 1957 i.InputRegister(0)); |
1958 break; | 1958 break; |
1959 case kS390_Uint64ToDouble: | 1959 case kS390_Uint64ToDouble: |
1960 __ ConvertUnsignedInt64ToDouble(i.InputRegister(0), | 1960 __ ConvertUnsignedInt64ToDouble(i.OutputDoubleRegister(), |
1961 i.OutputDoubleRegister()); | 1961 i.InputRegister(0)); |
1962 break; | 1962 break; |
1963 #endif | |
1964 case kS390_Int32ToFloat32: | 1963 case kS390_Int32ToFloat32: |
1965 __ ConvertIntToFloat(i.InputRegister(0), i.OutputDoubleRegister()); | 1964 __ ConvertIntToFloat(i.OutputDoubleRegister(), i.InputRegister(0)); |
1966 break; | 1965 break; |
1967 case kS390_Int32ToDouble: | 1966 case kS390_Int32ToDouble: |
1968 __ ConvertIntToDouble(i.InputRegister(0), i.OutputDoubleRegister()); | 1967 __ ConvertIntToDouble(i.OutputDoubleRegister(), i.InputRegister(0)); |
1969 break; | 1968 break; |
1970 case kS390_Uint32ToFloat32: | 1969 case kS390_Uint32ToFloat32: |
1971 __ ConvertUnsignedIntToFloat(i.InputRegister(0), | 1970 __ ConvertUnsignedIntToFloat(i.OutputDoubleRegister(), |
1972 i.OutputDoubleRegister()); | 1971 i.InputRegister(0)); |
1973 break; | 1972 break; |
1974 case kS390_Uint32ToDouble: | 1973 case kS390_Uint32ToDouble: |
1975 __ ConvertUnsignedIntToDouble(i.InputRegister(0), | 1974 __ ConvertUnsignedIntToDouble(i.OutputDoubleRegister(), |
1976 i.OutputDoubleRegister()); | 1975 i.InputRegister(0)); |
1977 break; | 1976 break; |
1978 case kS390_DoubleToInt32: | 1977 case kS390_DoubleToInt32: { |
1979 case kS390_DoubleToUint32: | 1978 Label done; |
| 1979 __ ConvertDoubleToInt32(i.OutputRegister(0), i.InputDoubleRegister(0), |
| 1980 kRoundToNearest); |
| 1981 __ b(Condition(0xe), &done, Label::kNear); // normal case |
| 1982 __ lghi(i.OutputRegister(0), Operand::Zero()); |
| 1983 __ bind(&done); |
| 1984 break; |
| 1985 } |
| 1986 case kS390_DoubleToUint32: { |
| 1987 Label done; |
| 1988 __ ConvertDoubleToUnsignedInt32(i.OutputRegister(0), |
| 1989 i.InputDoubleRegister(0)); |
| 1990 __ b(Condition(0xe), &done, Label::kNear); // normal case |
| 1991 __ lghi(i.OutputRegister(0), Operand::Zero()); |
| 1992 __ bind(&done); |
| 1993 break; |
| 1994 } |
1980 case kS390_DoubleToInt64: { | 1995 case kS390_DoubleToInt64: { |
1981 #if V8_TARGET_ARCH_S390X | 1996 Label done; |
1982 bool check_conversion = | 1997 if (i.OutputCount() > 1) { |
1983 (opcode == kS390_DoubleToInt64 && i.OutputCount() > 1); | 1998 __ lghi(i.OutputRegister(1), Operand(1)); |
1984 #endif | |
1985 __ ConvertDoubleToInt64(i.InputDoubleRegister(0), | |
1986 #if !V8_TARGET_ARCH_S390X | |
1987 kScratchReg, | |
1988 #endif | |
1989 i.OutputRegister(0), kScratchDoubleReg); | |
1990 #if V8_TARGET_ARCH_S390X | |
1991 if (check_conversion) { | |
1992 Label conversion_done; | |
1993 __ LoadImmP(i.OutputRegister(1), Operand::Zero()); | |
1994 __ b(Condition(1), &conversion_done); // special case | |
1995 __ LoadImmP(i.OutputRegister(1), Operand(1)); | |
1996 __ bind(&conversion_done); | |
1997 } | 1999 } |
1998 #endif | 2000 __ ConvertDoubleToInt64(i.OutputRegister(0), i.InputDoubleRegister(0)); |
| 2001 __ b(Condition(0xe), &done, Label::kNear); // normal case |
| 2002 if (i.OutputCount() > 1) { |
| 2003 __ lghi(i.OutputRegister(1), Operand::Zero()); |
| 2004 } else { |
| 2005 __ lghi(i.OutputRegister(0), Operand::Zero()); |
| 2006 } |
| 2007 __ bind(&done); |
| 2008 break; |
| 2009 } |
| 2010 case kS390_DoubleToUint64: { |
| 2011 Label done; |
| 2012 if (i.OutputCount() > 1) { |
| 2013 __ lghi(i.OutputRegister(1), Operand(1)); |
| 2014 } |
| 2015 __ ConvertDoubleToUnsignedInt64(i.OutputRegister(0), |
| 2016 i.InputDoubleRegister(0)); |
| 2017 __ b(Condition(0xe), &done, Label::kNear); // normal case |
| 2018 if (i.OutputCount() > 1) { |
| 2019 __ lghi(i.OutputRegister(1), Operand::Zero()); |
| 2020 } else { |
| 2021 __ lghi(i.OutputRegister(0), Operand::Zero()); |
| 2022 } |
| 2023 __ bind(&done); |
1999 break; | 2024 break; |
2000 } | 2025 } |
2001 case kS390_Float32ToInt32: { | 2026 case kS390_Float32ToInt32: { |
2002 bool check_conversion = (i.OutputCount() > 1); | 2027 Label done; |
2003 __ ConvertFloat32ToInt32(i.InputDoubleRegister(0), i.OutputRegister(0), | 2028 __ ConvertFloat32ToInt32(i.OutputRegister(0), i.InputDoubleRegister(0), |
2004 kScratchDoubleReg, kRoundToZero); | 2029 kRoundToZero); |
2005 if (check_conversion) { | 2030 __ b(Condition(0xe), &done, Label::kNear); // normal case |
2006 Label conversion_done; | 2031 __ lghi(i.OutputRegister(0), Operand::Zero()); |
2007 __ LoadImmP(i.OutputRegister(1), Operand::Zero()); | 2032 __ bind(&done); |
2008 __ b(Condition(1), &conversion_done); // special case | |
2009 __ LoadImmP(i.OutputRegister(1), Operand(1)); | |
2010 __ bind(&conversion_done); | |
2011 } | |
2012 break; | 2033 break; |
2013 } | 2034 } |
2014 case kS390_Float32ToUint32: { | 2035 case kS390_Float32ToUint32: { |
2015 bool check_conversion = (i.OutputCount() > 1); | 2036 Label done; |
2016 __ ConvertFloat32ToUnsignedInt32(i.InputDoubleRegister(0), | 2037 __ ConvertFloat32ToUnsignedInt32(i.OutputRegister(0), |
2017 i.OutputRegister(0), kScratchDoubleReg); | 2038 i.InputDoubleRegister(0)); |
2018 if (check_conversion) { | 2039 __ b(Condition(0xe), &done, Label::kNear); // normal case |
2019 Label conversion_done; | 2040 __ lghi(i.OutputRegister(0), Operand::Zero()); |
2020 __ LoadImmP(i.OutputRegister(1), Operand::Zero()); | 2041 __ bind(&done); |
2021 __ b(Condition(1), &conversion_done); // special case | |
2022 __ LoadImmP(i.OutputRegister(1), Operand(1)); | |
2023 __ bind(&conversion_done); | |
2024 } | |
2025 break; | 2042 break; |
2026 } | 2043 } |
2027 #if V8_TARGET_ARCH_S390X | |
2028 case kS390_Float32ToUint64: { | 2044 case kS390_Float32ToUint64: { |
2029 bool check_conversion = (i.OutputCount() > 1); | 2045 Label done; |
2030 __ ConvertFloat32ToUnsignedInt64(i.InputDoubleRegister(0), | 2046 if (i.OutputCount() > 1) { |
2031 i.OutputRegister(0), kScratchDoubleReg); | 2047 __ lghi(i.OutputRegister(1), Operand(1)); |
2032 if (check_conversion) { | |
2033 Label conversion_done; | |
2034 __ LoadImmP(i.OutputRegister(1), Operand::Zero()); | |
2035 __ b(Condition(1), &conversion_done); // special case | |
2036 __ LoadImmP(i.OutputRegister(1), Operand(1)); | |
2037 __ bind(&conversion_done); | |
2038 } | 2048 } |
| 2049 __ ConvertFloat32ToUnsignedInt64(i.OutputRegister(0), |
| 2050 i.InputDoubleRegister(0)); |
| 2051 __ b(Condition(0xe), &done, Label::kNear); // normal case |
| 2052 if (i.OutputCount() > 1) { |
| 2053 __ lghi(i.OutputRegister(1), Operand::Zero()); |
| 2054 } else { |
| 2055 __ lghi(i.OutputRegister(0), Operand::Zero()); |
| 2056 } |
| 2057 __ bind(&done); |
2039 break; | 2058 break; |
2040 } | 2059 } |
2041 #endif | |
2042 case kS390_Float32ToInt64: { | 2060 case kS390_Float32ToInt64: { |
2043 #if V8_TARGET_ARCH_S390X | 2061 Label done; |
2044 bool check_conversion = | 2062 if (i.OutputCount() > 1) { |
2045 (opcode == kS390_Float32ToInt64 && i.OutputCount() > 1); | 2063 __ lghi(i.OutputRegister(1), Operand(1)); |
2046 #endif | |
2047 __ ConvertFloat32ToInt64(i.InputDoubleRegister(0), | |
2048 #if !V8_TARGET_ARCH_S390X | |
2049 kScratchReg, | |
2050 #endif | |
2051 i.OutputRegister(0), kScratchDoubleReg); | |
2052 #if V8_TARGET_ARCH_S390X | |
2053 if (check_conversion) { | |
2054 Label conversion_done; | |
2055 __ LoadImmP(i.OutputRegister(1), Operand::Zero()); | |
2056 __ b(Condition(1), &conversion_done); // special case | |
2057 __ LoadImmP(i.OutputRegister(1), Operand(1)); | |
2058 __ bind(&conversion_done); | |
2059 } | 2064 } |
2060 #endif | 2065 __ ConvertFloat32ToInt64(i.OutputRegister(0), i.InputDoubleRegister(0)); |
| 2066 __ b(Condition(0xe), &done, Label::kNear); // normal case |
| 2067 if (i.OutputCount() > 1) { |
| 2068 __ lghi(i.OutputRegister(1), Operand::Zero()); |
| 2069 } else { |
| 2070 __ lghi(i.OutputRegister(0), Operand::Zero()); |
| 2071 } |
| 2072 __ bind(&done); |
2061 break; | 2073 break; |
2062 } | 2074 } |
2063 #if V8_TARGET_ARCH_S390X | |
2064 case kS390_DoubleToUint64: { | |
2065 bool check_conversion = (i.OutputCount() > 1); | |
2066 __ ConvertDoubleToUnsignedInt64(i.InputDoubleRegister(0), | |
2067 i.OutputRegister(0), kScratchDoubleReg); | |
2068 if (check_conversion) { | |
2069 Label conversion_done; | |
2070 __ LoadImmP(i.OutputRegister(1), Operand::Zero()); | |
2071 __ b(Condition(1), &conversion_done); // special case | |
2072 __ LoadImmP(i.OutputRegister(1), Operand(1)); | |
2073 __ bind(&conversion_done); | |
2074 } | |
2075 break; | |
2076 } | |
2077 #endif | |
2078 case kS390_DoubleToFloat32: | 2075 case kS390_DoubleToFloat32: |
2079 ASSEMBLE_UNARY_OP(D_DInstr(ledbr), nullInstr, nullInstr); | 2076 ASSEMBLE_UNARY_OP(D_DInstr(ledbr), nullInstr, nullInstr); |
2080 break; | 2077 break; |
2081 case kS390_Float32ToDouble: | 2078 case kS390_Float32ToDouble: |
2082 ASSEMBLE_UNARY_OP(D_DInstr(ldebr), D_MTInstr(LoadFloat32ToDouble), | 2079 ASSEMBLE_UNARY_OP(D_DInstr(ldebr), D_MTInstr(LoadFloat32ToDouble), |
2083 nullInstr); | 2080 nullInstr); |
2084 break; | 2081 break; |
2085 case kS390_DoubleExtractLowWord32: | 2082 case kS390_DoubleExtractLowWord32: |
2086 __ lgdr(i.OutputRegister(), i.InputDoubleRegister(0)); | 2083 __ lgdr(i.OutputRegister(), i.InputDoubleRegister(0)); |
2087 __ llgfr(i.OutputRegister(), i.OutputRegister()); | 2084 __ llgfr(i.OutputRegister(), i.OutputRegister()); |
2088 break; | 2085 break; |
2089 case kS390_DoubleExtractHighWord32: | 2086 case kS390_DoubleExtractHighWord32: |
2090 __ lgdr(i.OutputRegister(), i.InputDoubleRegister(0)); | 2087 __ lgdr(i.OutputRegister(), i.InputDoubleRegister(0)); |
2091 __ srlg(i.OutputRegister(), i.OutputRegister(), Operand(32)); | 2088 __ srlg(i.OutputRegister(), i.OutputRegister(), Operand(32)); |
2092 break; | 2089 break; |
2093 case kS390_DoubleInsertLowWord32: | 2090 case kS390_DoubleInsertLowWord32: |
2094 __ lgdr(kScratchReg, i.OutputDoubleRegister()); | 2091 __ lgdr(kScratchReg, i.InputDoubleRegister(0)); |
2095 __ lr(kScratchReg, i.InputRegister(1)); | 2092 __ lr(kScratchReg, i.InputRegister(1)); |
2096 __ ldgr(i.OutputDoubleRegister(), kScratchReg); | 2093 __ ldgr(i.OutputDoubleRegister(), kScratchReg); |
2097 break; | 2094 break; |
2098 case kS390_DoubleInsertHighWord32: | 2095 case kS390_DoubleInsertHighWord32: |
2099 __ sllg(kScratchReg, i.InputRegister(1), Operand(32)); | 2096 __ sllg(kScratchReg, i.InputRegister(1), Operand(32)); |
2100 __ lgdr(r0, i.OutputDoubleRegister()); | 2097 __ lgdr(r0, i.InputDoubleRegister(0)); |
2101 __ lr(kScratchReg, r0); | 2098 __ lr(kScratchReg, r0); |
2102 __ ldgr(i.OutputDoubleRegister(), kScratchReg); | 2099 __ ldgr(i.OutputDoubleRegister(), kScratchReg); |
2103 break; | 2100 break; |
2104 case kS390_DoubleConstruct: | 2101 case kS390_DoubleConstruct: |
2105 __ sllg(kScratchReg, i.InputRegister(0), Operand(32)); | 2102 __ sllg(kScratchReg, i.InputRegister(0), Operand(32)); |
2106 __ lr(kScratchReg, i.InputRegister(1)); | 2103 __ lr(kScratchReg, i.InputRegister(1)); |
2107 | 2104 |
2108 // Bitwise convert from GPR to FPR | 2105 // Bitwise convert from GPR to FPR |
2109 __ ldgr(i.OutputDoubleRegister(), kScratchReg); | 2106 __ ldgr(i.OutputDoubleRegister(), kScratchReg); |
2110 break; | 2107 break; |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2962 padding_size -= 2; | 2959 padding_size -= 2; |
2963 } | 2960 } |
2964 } | 2961 } |
2965 } | 2962 } |
2966 | 2963 |
2967 #undef __ | 2964 #undef __ |
2968 | 2965 |
2969 } // namespace compiler | 2966 } // namespace compiler |
2970 } // namespace internal | 2967 } // namespace internal |
2971 } // namespace v8 | 2968 } // namespace v8 |
OLD | NEW |