Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/ast/scopes.h" | 7 #include "src/ast/scopes.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 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2005 } | 2005 } |
| 2006 } | 2006 } |
| 2007 } else if (source->IsFPRegister()) { | 2007 } else if (source->IsFPRegister()) { |
| 2008 XMMRegister src = g.ToDoubleRegister(source); | 2008 XMMRegister src = g.ToDoubleRegister(source); |
| 2009 if (destination->IsFPRegister()) { | 2009 if (destination->IsFPRegister()) { |
| 2010 XMMRegister dst = g.ToDoubleRegister(destination); | 2010 XMMRegister dst = g.ToDoubleRegister(destination); |
| 2011 __ movaps(dst, src); | 2011 __ movaps(dst, src); |
| 2012 } else { | 2012 } else { |
| 2013 DCHECK(destination->IsFPStackSlot()); | 2013 DCHECK(destination->IsFPStackSlot()); |
| 2014 Operand dst = g.ToOperand(destination); | 2014 Operand dst = g.ToOperand(destination); |
| 2015 __ movsd(dst, src); | 2015 MachineRepresentation rep = |
| 2016 LocationOperand::cast(source)->representation(); | |
| 2017 if (rep == MachineRepresentation::kFloat64) { | |
| 2018 __ movsd(dst, src); | |
| 2019 } else if (rep == MachineRepresentation::kFloat32) { | |
| 2020 __ movss(dst, src); | |
| 2021 } else { | |
| 2022 DCHECK_EQ(MachineRepresentation::kSimd128, rep); | |
| 2023 __ movdqu(dst, src); | |
|
Benedikt Meurer
2016/07/12 17:41:49
Why don't we also use movupd here, similar to x64?
bbudge
2016/07/12 17:50:29
It's funny but I did that first, then noticed that
| |
| 2024 } | |
| 2016 } | 2025 } |
| 2017 } else if (source->IsFPStackSlot()) { | 2026 } else if (source->IsFPStackSlot()) { |
| 2018 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); | 2027 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); |
| 2019 Operand src = g.ToOperand(source); | 2028 Operand src = g.ToOperand(source); |
| 2029 MachineRepresentation rep = LocationOperand::cast(source)->representation(); | |
| 2020 if (destination->IsFPRegister()) { | 2030 if (destination->IsFPRegister()) { |
| 2021 XMMRegister dst = g.ToDoubleRegister(destination); | 2031 XMMRegister dst = g.ToDoubleRegister(destination); |
| 2022 __ movsd(dst, src); | 2032 if (rep == MachineRepresentation::kFloat64) { |
| 2033 __ movsd(dst, src); | |
| 2034 } else if (rep == MachineRepresentation::kFloat32) { | |
| 2035 __ movss(dst, src); | |
| 2036 } else { | |
| 2037 DCHECK_EQ(MachineRepresentation::kSimd128, rep); | |
| 2038 __ movdqu(dst, src); | |
|
Benedikt Meurer
2016/07/12 17:41:49
See above.
bbudge
2016/07/12 17:50:29
Done.
| |
| 2039 } | |
| 2023 } else { | 2040 } else { |
| 2024 Operand dst = g.ToOperand(destination); | 2041 Operand dst = g.ToOperand(destination); |
| 2025 __ movsd(kScratchDoubleReg, src); | 2042 if (rep == MachineRepresentation::kFloat64) { |
| 2026 __ movsd(dst, kScratchDoubleReg); | 2043 __ movsd(kScratchDoubleReg, src); |
| 2044 __ movsd(dst, kScratchDoubleReg); | |
| 2045 } else if (rep == MachineRepresentation::kFloat32) { | |
| 2046 __ movss(kScratchDoubleReg, src); | |
| 2047 __ movss(dst, kScratchDoubleReg); | |
| 2048 } else { | |
| 2049 DCHECK_EQ(MachineRepresentation::kSimd128, rep); | |
| 2050 __ movdqu(kScratchDoubleReg, src); | |
|
Benedikt Meurer
2016/07/12 17:41:49
See above.
bbudge
2016/07/12 17:50:29
Done.
| |
| 2051 __ movdqu(dst, kScratchDoubleReg); | |
| 2052 } | |
| 2027 } | 2053 } |
| 2028 } else { | 2054 } else { |
| 2029 UNREACHABLE(); | 2055 UNREACHABLE(); |
| 2030 } | 2056 } |
| 2031 } | 2057 } |
| 2032 | 2058 |
| 2033 | 2059 |
| 2034 void CodeGenerator::AssembleSwap(InstructionOperand* source, | 2060 void CodeGenerator::AssembleSwap(InstructionOperand* source, |
| 2035 InstructionOperand* destination) { | 2061 InstructionOperand* destination) { |
| 2036 IA32OperandConverter g(this, nullptr); | 2062 IA32OperandConverter g(this, nullptr); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2069 // XMM register-register swap. | 2095 // XMM register-register swap. |
| 2070 XMMRegister src = g.ToDoubleRegister(source); | 2096 XMMRegister src = g.ToDoubleRegister(source); |
| 2071 XMMRegister dst = g.ToDoubleRegister(destination); | 2097 XMMRegister dst = g.ToDoubleRegister(destination); |
| 2072 __ movaps(kScratchDoubleReg, src); | 2098 __ movaps(kScratchDoubleReg, src); |
| 2073 __ movaps(src, dst); | 2099 __ movaps(src, dst); |
| 2074 __ movaps(dst, kScratchDoubleReg); | 2100 __ movaps(dst, kScratchDoubleReg); |
| 2075 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) { | 2101 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) { |
| 2076 // XMM register-memory swap. | 2102 // XMM register-memory swap. |
| 2077 XMMRegister reg = g.ToDoubleRegister(source); | 2103 XMMRegister reg = g.ToDoubleRegister(source); |
| 2078 Operand other = g.ToOperand(destination); | 2104 Operand other = g.ToOperand(destination); |
| 2079 __ movsd(kScratchDoubleReg, other); | 2105 MachineRepresentation rep = LocationOperand::cast(source)->representation(); |
| 2080 __ movsd(other, reg); | 2106 if (rep == MachineRepresentation::kFloat64) { |
| 2081 __ movaps(reg, kScratchDoubleReg); | 2107 __ movsd(kScratchDoubleReg, other); |
| 2108 __ movsd(other, reg); | |
| 2109 __ movaps(reg, kScratchDoubleReg); | |
| 2110 } else if (rep == MachineRepresentation::kFloat32) { | |
| 2111 __ movss(kScratchDoubleReg, other); | |
| 2112 __ movss(other, reg); | |
| 2113 __ movaps(reg, kScratchDoubleReg); | |
| 2114 } else { | |
| 2115 DCHECK_EQ(MachineRepresentation::kSimd128, rep); | |
| 2116 __ movdqu(kScratchDoubleReg, other); | |
| 2117 __ movdqu(other, reg); | |
| 2118 __ movaps(reg, kScratchDoubleReg); | |
| 2119 } | |
| 2082 } else if (source->IsFPStackSlot() && destination->IsFPStackSlot()) { | 2120 } else if (source->IsFPStackSlot() && destination->IsFPStackSlot()) { |
| 2083 // Double-width memory-to-memory. | 2121 // Double-width memory-to-memory. |
| 2084 Operand src0 = g.ToOperand(source); | 2122 Operand src0 = g.ToOperand(source); |
| 2085 Operand src1 = g.HighOperand(source); | |
| 2086 Operand dst0 = g.ToOperand(destination); | 2123 Operand dst0 = g.ToOperand(destination); |
| 2087 Operand dst1 = g.HighOperand(destination); | 2124 MachineRepresentation rep = LocationOperand::cast(source)->representation(); |
| 2088 __ movsd(kScratchDoubleReg, dst0); // Save destination in scratch register. | 2125 if (rep == MachineRepresentation::kFloat64) { |
| 2089 __ push(src0); // Then use stack to copy source to destination. | 2126 Operand src1 = g.HighOperand(source); |
| 2090 __ pop(dst0); | 2127 Operand dst1 = g.HighOperand(destination); |
| 2091 __ push(src1); | 2128 __ movsd(kScratchDoubleReg, dst0); // Save dst in scratch register. |
| 2092 __ pop(dst1); | 2129 __ push(src0); // Then use stack to copy src to destination. |
| 2093 __ movsd(src0, kScratchDoubleReg); | 2130 __ pop(dst0); |
| 2131 __ push(src1); | |
| 2132 __ pop(dst1); | |
| 2133 __ movsd(src0, kScratchDoubleReg); | |
| 2134 } else if (rep == MachineRepresentation::kFloat32) { | |
| 2135 __ movss(kScratchDoubleReg, dst0); // Save dst in scratch register. | |
| 2136 __ push(src0); // Then use stack to copy src to destination. | |
| 2137 __ pop(dst0); | |
| 2138 __ movss(src0, kScratchDoubleReg); | |
| 2139 } else { | |
| 2140 DCHECK_EQ(MachineRepresentation::kSimd128, rep); | |
| 2141 // Use the XOR trick to swap without a temporary. | |
| 2142 __ movdqu(kScratchDoubleReg, src0); | |
| 2143 __ xorps(kScratchDoubleReg, dst0); // scratch contains src ^ dst. | |
| 2144 __ movdqu(src0, kScratchDoubleReg); | |
| 2145 __ xorps(kScratchDoubleReg, dst0); // scratch contains src. | |
| 2146 __ movdqu(dst0, kScratchDoubleReg); | |
| 2147 __ xorps(kScratchDoubleReg, src0); // scratch contains dst. | |
| 2148 __ movdqu(src0, kScratchDoubleReg); | |
| 2149 } | |
| 2094 } else { | 2150 } else { |
| 2095 // No other combinations are possible. | 2151 // No other combinations are possible. |
| 2096 UNREACHABLE(); | 2152 UNREACHABLE(); |
| 2097 } | 2153 } |
| 2098 } | 2154 } |
| 2099 | 2155 |
| 2100 | 2156 |
| 2101 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { | 2157 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { |
| 2102 for (size_t index = 0; index < target_count; ++index) { | 2158 for (size_t index = 0; index < target_count; ++index) { |
| 2103 __ dd(targets[index]); | 2159 __ dd(targets[index]); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2118 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2174 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 2119 __ Nop(padding_size); | 2175 __ Nop(padding_size); |
| 2120 } | 2176 } |
| 2121 } | 2177 } |
| 2122 | 2178 |
| 2123 #undef __ | 2179 #undef __ |
| 2124 | 2180 |
| 2125 } // namespace compiler | 2181 } // namespace compiler |
| 2126 } // namespace internal | 2182 } // namespace internal |
| 2127 } // namespace v8 | 2183 } // namespace v8 |
| OLD | NEW |