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/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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return MemOperand(r0); | 82 return MemOperand(r0); |
83 } | 83 } |
84 | 84 |
85 MemOperand MemoryOperand(AddressingMode* mode = NULL, | 85 MemOperand MemoryOperand(AddressingMode* mode = NULL, |
86 size_t first_index = 0) { | 86 size_t first_index = 0) { |
87 return MemoryOperand(mode, &first_index); | 87 return MemoryOperand(mode, &first_index); |
88 } | 88 } |
89 | 89 |
90 MemOperand ToMemOperand(InstructionOperand* op) const { | 90 MemOperand ToMemOperand(InstructionOperand* op) const { |
91 DCHECK_NOT_NULL(op); | 91 DCHECK_NOT_NULL(op); |
92 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 92 DCHECK(op->IsStackSlot() || op->IsFPStackSlot()); |
93 return SlotToMemOperand(AllocatedOperand::cast(op)->index()); | 93 return SlotToMemOperand(AllocatedOperand::cast(op)->index()); |
94 } | 94 } |
95 | 95 |
96 MemOperand SlotToMemOperand(int slot) const { | 96 MemOperand SlotToMemOperand(int slot) const { |
97 FrameOffset offset = frame_access_state()->GetFrameOffset(slot); | 97 FrameOffset offset = frame_access_state()->GetFrameOffset(slot); |
98 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); | 98 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); |
99 } | 99 } |
100 }; | 100 }; |
101 | 101 |
102 static inline bool HasRegisterInput(Instruction* instr, int index) { | 102 static inline bool HasRegisterInput(Instruction* instr, int index) { |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 #if V8_TARGET_ARCH_S390X | 1295 #if V8_TARGET_ARCH_S390X |
1296 case kS390_Tst64: | 1296 case kS390_Tst64: |
1297 if (HasRegisterInput(instr, 1)) { | 1297 if (HasRegisterInput(instr, 1)) { |
1298 __ AndP(r0, i.InputRegister(0), i.InputRegister(1)); | 1298 __ AndP(r0, i.InputRegister(0), i.InputRegister(1)); |
1299 } else { | 1299 } else { |
1300 __ AndP(r0, i.InputRegister(0), i.InputImmediate(1)); | 1300 __ AndP(r0, i.InputRegister(0), i.InputImmediate(1)); |
1301 } | 1301 } |
1302 break; | 1302 break; |
1303 #endif | 1303 #endif |
1304 case kS390_Push: | 1304 case kS390_Push: |
1305 if (instr->InputAt(0)->IsDoubleRegister()) { | 1305 if (instr->InputAt(0)->IsFPRegister()) { |
1306 __ lay(sp, MemOperand(sp, -kDoubleSize)); | 1306 __ lay(sp, MemOperand(sp, -kDoubleSize)); |
1307 __ StoreDouble(i.InputDoubleRegister(0), MemOperand(sp)); | 1307 __ StoreDouble(i.InputDoubleRegister(0), MemOperand(sp)); |
1308 frame_access_state()->IncreaseSPDelta(kDoubleSize / kPointerSize); | 1308 frame_access_state()->IncreaseSPDelta(kDoubleSize / kPointerSize); |
1309 } else { | 1309 } else { |
1310 __ Push(i.InputRegister(0)); | 1310 __ Push(i.InputRegister(0)); |
1311 frame_access_state()->IncreaseSPDelta(1); | 1311 frame_access_state()->IncreaseSPDelta(1); |
1312 } | 1312 } |
1313 break; | 1313 break; |
1314 case kS390_PushFrame: { | 1314 case kS390_PushFrame: { |
1315 int num_slots = i.InputInt32(1); | 1315 int num_slots = i.InputInt32(1); |
1316 __ lay(sp, MemOperand(sp, -num_slots * kPointerSize)); | 1316 __ lay(sp, MemOperand(sp, -num_slots * kPointerSize)); |
1317 if (instr->InputAt(0)->IsDoubleRegister()) { | 1317 if (instr->InputAt(0)->IsFPRegister()) { |
1318 __ StoreDouble(i.InputDoubleRegister(0), | 1318 __ StoreDouble(i.InputDoubleRegister(0), |
1319 MemOperand(sp)); | 1319 MemOperand(sp)); |
1320 } else { | 1320 } else { |
1321 __ StoreP(i.InputRegister(0), | 1321 __ StoreP(i.InputRegister(0), |
1322 MemOperand(sp)); | 1322 MemOperand(sp)); |
1323 } | 1323 } |
1324 break; | 1324 break; |
1325 } | 1325 } |
1326 case kS390_StoreToStackSlot: { | 1326 case kS390_StoreToStackSlot: { |
1327 int slot = i.InputInt32(1); | 1327 int slot = i.InputInt32(1); |
1328 if (instr->InputAt(0)->IsDoubleRegister()) { | 1328 if (instr->InputAt(0)->IsFPRegister()) { |
1329 __ StoreDouble(i.InputDoubleRegister(0), | 1329 __ StoreDouble(i.InputDoubleRegister(0), |
1330 MemOperand(sp, slot * kPointerSize)); | 1330 MemOperand(sp, slot * kPointerSize)); |
1331 } else { | 1331 } else { |
1332 __ StoreP(i.InputRegister(0), MemOperand(sp, slot * kPointerSize)); | 1332 __ StoreP(i.InputRegister(0), MemOperand(sp, slot * kPointerSize)); |
1333 } | 1333 } |
1334 break; | 1334 break; |
1335 } | 1335 } |
1336 case kS390_ExtendSignWord8: | 1336 case kS390_ExtendSignWord8: |
1337 #if V8_TARGET_ARCH_S390X | 1337 #if V8_TARGET_ARCH_S390X |
1338 __ lgbr(i.OutputRegister(), i.InputRegister(0)); | 1338 __ lgbr(i.OutputRegister(), i.InputRegister(0)); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1985 break; | 1985 break; |
1986 } | 1986 } |
1987 case Constant::kRpoNumber: | 1987 case Constant::kRpoNumber: |
1988 UNREACHABLE(); // TODO(dcarney): loading RPO constants on S390. | 1988 UNREACHABLE(); // TODO(dcarney): loading RPO constants on S390. |
1989 break; | 1989 break; |
1990 } | 1990 } |
1991 if (destination->IsStackSlot()) { | 1991 if (destination->IsStackSlot()) { |
1992 __ StoreP(dst, g.ToMemOperand(destination), r0); | 1992 __ StoreP(dst, g.ToMemOperand(destination), r0); |
1993 } | 1993 } |
1994 } else { | 1994 } else { |
1995 DoubleRegister dst = destination->IsDoubleRegister() | 1995 DoubleRegister dst = destination->IsFPRegister() |
1996 ? g.ToDoubleRegister(destination) | 1996 ? g.ToDoubleRegister(destination) |
1997 : kScratchDoubleReg; | 1997 : kScratchDoubleReg; |
1998 double value = (src.type() == Constant::kFloat32) ? src.ToFloat32() | 1998 double value = (src.type() == Constant::kFloat32) ? src.ToFloat32() |
1999 : src.ToFloat64(); | 1999 : src.ToFloat64(); |
2000 if (src.type() == Constant::kFloat32) { | 2000 if (src.type() == Constant::kFloat32) { |
2001 __ LoadFloat32Literal(dst, src.ToFloat32(), kScratchReg); | 2001 __ LoadFloat32Literal(dst, src.ToFloat32(), kScratchReg); |
2002 } else { | 2002 } else { |
2003 __ LoadDoubleLiteral(dst, value, kScratchReg); | 2003 __ LoadDoubleLiteral(dst, value, kScratchReg); |
2004 } | 2004 } |
2005 | 2005 |
2006 if (destination->IsDoubleStackSlot()) { | 2006 if (destination->IsFPStackSlot()) { |
2007 __ StoreDouble(dst, g.ToMemOperand(destination)); | 2007 __ StoreDouble(dst, g.ToMemOperand(destination)); |
2008 } | 2008 } |
2009 } | 2009 } |
2010 } else if (source->IsDoubleRegister()) { | 2010 } else if (source->IsFPRegister()) { |
2011 DoubleRegister src = g.ToDoubleRegister(source); | 2011 DoubleRegister src = g.ToDoubleRegister(source); |
2012 if (destination->IsDoubleRegister()) { | 2012 if (destination->IsFPRegister()) { |
2013 DoubleRegister dst = g.ToDoubleRegister(destination); | 2013 DoubleRegister dst = g.ToDoubleRegister(destination); |
2014 __ Move(dst, src); | 2014 __ Move(dst, src); |
2015 } else { | 2015 } else { |
2016 DCHECK(destination->IsDoubleStackSlot()); | 2016 DCHECK(destination->IsFPStackSlot()); |
2017 __ StoreDouble(src, g.ToMemOperand(destination)); | 2017 __ StoreDouble(src, g.ToMemOperand(destination)); |
2018 } | 2018 } |
2019 } else if (source->IsDoubleStackSlot()) { | 2019 } else if (source->IsFPStackSlot()) { |
2020 DCHECK(destination->IsDoubleRegister() || destination->IsDoubleStackSlot()); | 2020 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); |
2021 MemOperand src = g.ToMemOperand(source); | 2021 MemOperand src = g.ToMemOperand(source); |
2022 if (destination->IsDoubleRegister()) { | 2022 if (destination->IsFPRegister()) { |
2023 __ LoadDouble(g.ToDoubleRegister(destination), src); | 2023 __ LoadDouble(g.ToDoubleRegister(destination), src); |
2024 } else { | 2024 } else { |
2025 DoubleRegister temp = kScratchDoubleReg; | 2025 DoubleRegister temp = kScratchDoubleReg; |
2026 __ LoadDouble(temp, src); | 2026 __ LoadDouble(temp, src); |
2027 __ StoreDouble(temp, g.ToMemOperand(destination)); | 2027 __ StoreDouble(temp, g.ToMemOperand(destination)); |
2028 } | 2028 } |
2029 } else { | 2029 } else { |
2030 UNREACHABLE(); | 2030 UNREACHABLE(); |
2031 } | 2031 } |
2032 } | 2032 } |
(...skipping 13 matching lines...) Expand all Loading... |
2046 __ LoadRR(src, dst); | 2046 __ LoadRR(src, dst); |
2047 __ LoadRR(dst, temp); | 2047 __ LoadRR(dst, temp); |
2048 } else { | 2048 } else { |
2049 DCHECK(destination->IsStackSlot()); | 2049 DCHECK(destination->IsStackSlot()); |
2050 MemOperand dst = g.ToMemOperand(destination); | 2050 MemOperand dst = g.ToMemOperand(destination); |
2051 __ LoadRR(temp, src); | 2051 __ LoadRR(temp, src); |
2052 __ LoadP(src, dst); | 2052 __ LoadP(src, dst); |
2053 __ StoreP(temp, dst); | 2053 __ StoreP(temp, dst); |
2054 } | 2054 } |
2055 #if V8_TARGET_ARCH_S390X | 2055 #if V8_TARGET_ARCH_S390X |
2056 } else if (source->IsStackSlot() || source->IsDoubleStackSlot()) { | 2056 } else if (source->IsStackSlot() || source->IsFPStackSlot()) { |
2057 #else | 2057 #else |
2058 } else if (source->IsStackSlot()) { | 2058 } else if (source->IsStackSlot()) { |
2059 DCHECK(destination->IsStackSlot()); | 2059 DCHECK(destination->IsStackSlot()); |
2060 #endif | 2060 #endif |
2061 Register temp_0 = kScratchReg; | 2061 Register temp_0 = kScratchReg; |
2062 Register temp_1 = r0; | 2062 Register temp_1 = r0; |
2063 MemOperand src = g.ToMemOperand(source); | 2063 MemOperand src = g.ToMemOperand(source); |
2064 MemOperand dst = g.ToMemOperand(destination); | 2064 MemOperand dst = g.ToMemOperand(destination); |
2065 __ LoadP(temp_0, src); | 2065 __ LoadP(temp_0, src); |
2066 __ LoadP(temp_1, dst); | 2066 __ LoadP(temp_1, dst); |
2067 __ StoreP(temp_0, dst); | 2067 __ StoreP(temp_0, dst); |
2068 __ StoreP(temp_1, src); | 2068 __ StoreP(temp_1, src); |
2069 } else if (source->IsDoubleRegister()) { | 2069 } else if (source->IsFPRegister()) { |
2070 DoubleRegister temp = kScratchDoubleReg; | 2070 DoubleRegister temp = kScratchDoubleReg; |
2071 DoubleRegister src = g.ToDoubleRegister(source); | 2071 DoubleRegister src = g.ToDoubleRegister(source); |
2072 if (destination->IsDoubleRegister()) { | 2072 if (destination->IsFPRegister()) { |
2073 DoubleRegister dst = g.ToDoubleRegister(destination); | 2073 DoubleRegister dst = g.ToDoubleRegister(destination); |
2074 __ ldr(temp, src); | 2074 __ ldr(temp, src); |
2075 __ ldr(src, dst); | 2075 __ ldr(src, dst); |
2076 __ ldr(dst, temp); | 2076 __ ldr(dst, temp); |
2077 } else { | 2077 } else { |
2078 DCHECK(destination->IsDoubleStackSlot()); | 2078 DCHECK(destination->IsFPStackSlot()); |
2079 MemOperand dst = g.ToMemOperand(destination); | 2079 MemOperand dst = g.ToMemOperand(destination); |
2080 __ ldr(temp, src); | 2080 __ ldr(temp, src); |
2081 __ LoadDouble(src, dst); | 2081 __ LoadDouble(src, dst); |
2082 __ StoreDouble(temp, dst); | 2082 __ StoreDouble(temp, dst); |
2083 } | 2083 } |
2084 #if !V8_TARGET_ARCH_S390X | 2084 #if !V8_TARGET_ARCH_S390X |
2085 } else if (source->IsDoubleStackSlot()) { | 2085 } else if (source->IsFPStackSlot()) { |
2086 DCHECK(destination->IsDoubleStackSlot()); | 2086 DCHECK(destination->IsFPStackSlot()); |
2087 DoubleRegister temp_0 = kScratchDoubleReg; | 2087 DoubleRegister temp_0 = kScratchDoubleReg; |
2088 DoubleRegister temp_1 = d0; | 2088 DoubleRegister temp_1 = d0; |
2089 MemOperand src = g.ToMemOperand(source); | 2089 MemOperand src = g.ToMemOperand(source); |
2090 MemOperand dst = g.ToMemOperand(destination); | 2090 MemOperand dst = g.ToMemOperand(destination); |
2091 // TODO(joransiu): MVC opportunity | 2091 // TODO(joransiu): MVC opportunity |
2092 __ LoadDouble(temp_0, src); | 2092 __ LoadDouble(temp_0, src); |
2093 __ LoadDouble(temp_1, dst); | 2093 __ LoadDouble(temp_1, dst); |
2094 __ StoreDouble(temp_0, dst); | 2094 __ StoreDouble(temp_0, dst); |
2095 __ StoreDouble(temp_1, src); | 2095 __ StoreDouble(temp_1, src); |
2096 #endif | 2096 #endif |
(...skipping 26 matching lines...) Expand all Loading... |
2123 padding_size -= 2; | 2123 padding_size -= 2; |
2124 } | 2124 } |
2125 } | 2125 } |
2126 } | 2126 } |
2127 | 2127 |
2128 #undef __ | 2128 #undef __ |
2129 | 2129 |
2130 } // namespace compiler | 2130 } // namespace compiler |
2131 } // namespace internal | 2131 } // namespace internal |
2132 } // namespace v8 | 2132 } // namespace v8 |
OLD | NEW |