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

Side by Side Diff: src/compiler/s390/instruction-selector-s390.cc

Issue 2761953002: s390: improve floating point and integer convertion (Closed)
Patch Set: Created 3 years, 9 months 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
« no previous file with comments | « src/compiler/s390/code-generator-s390.cc ('k') | src/crankshaft/s390/lithium-codegen-s390.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/compiler/instruction-selector-impl.h" 6 #include "src/compiler/instruction-selector-impl.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "src/s390/frames-s390.h" 9 #include "src/s390/frames-s390.h"
10 10
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 /* V(TruncateFloat64ToWord32) */ \ 323 /* V(TruncateFloat64ToWord32) */ \
324 /* V(RoundFloat64ToInt32) */ \ 324 /* V(RoundFloat64ToInt32) */ \
325 /* V(TruncateFloat32ToInt32) */ \ 325 /* V(TruncateFloat32ToInt32) */ \
326 /* V(TruncateFloat32ToUint32) */ \ 326 /* V(TruncateFloat32ToUint32) */ \
327 /* V(TruncateFloat64ToUint32) */ \ 327 /* V(TruncateFloat64ToUint32) */ \
328 /* V(ChangeFloat64ToInt32) */ \ 328 /* V(ChangeFloat64ToInt32) */ \
329 /* V(ChangeFloat64ToUint32) */ \ 329 /* V(ChangeFloat64ToUint32) */ \
330 /* Word32 unary op */ \ 330 /* Word32 unary op */ \
331 V(Word32Clz) \ 331 V(Word32Clz) \
332 V(Word32Popcnt) \ 332 V(Word32Popcnt) \
333 V(Float64ExtractLowWord32) \
334 V(Float64ExtractHighWord32) \
333 /* Word32 bin op */ \ 335 /* Word32 bin op */ \
334 V(Int32Add) \ 336 V(Int32Add) \
335 V(Int32Sub) \ 337 V(Int32Sub) \
336 V(Int32Mul) \ 338 V(Int32Mul) \
337 V(Int32AddWithOverflow) \ 339 V(Int32AddWithOverflow) \
338 V(Int32SubWithOverflow) \ 340 V(Int32SubWithOverflow) \
339 V(Int32MulWithOverflow) \ 341 V(Int32MulWithOverflow) \
340 V(Int32MulHigh) \ 342 V(Int32MulHigh) \
341 V(Uint32MulHigh) \ 343 V(Uint32MulHigh) \
342 V(Int32Div) \ 344 V(Int32Div) \
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 AddOperandMode); 1374 AddOperandMode);
1373 } 1375 }
1374 1376
1375 static inline bool TryMatchInt64SubWithOverflow(InstructionSelector* selector, 1377 static inline bool TryMatchInt64SubWithOverflow(InstructionSelector* selector,
1376 Node* node) { 1378 Node* node) {
1377 return TryMatchInt64OpWithOverflow<kS390_Sub64>(selector, node, 1379 return TryMatchInt64OpWithOverflow<kS390_Sub64>(selector, node,
1378 SubOperandMode); 1380 SubOperandMode);
1379 } 1381 }
1380 #endif 1382 #endif
1381 1383
1384 static inline bool TryMatchDoubleConstructFromInsert(
1385 InstructionSelector* selector, Node* node) {
1386 S390OperandGenerator g(selector);
1387 Node* left = node->InputAt(0);
1388 Node* right = node->InputAt(1);
1389 Node* lo32 = NULL;
1390 Node* hi32 = NULL;
1391
1392 if (node->opcode() == IrOpcode::kFloat64InsertLowWord32) {
1393 lo32 = right;
1394 } else if (node->opcode() == IrOpcode::kFloat64InsertHighWord32) {
1395 hi32 = right;
1396 } else {
1397 return false; // doesn't match
1398 }
1399
1400 if (left->opcode() == IrOpcode::kFloat64InsertLowWord32) {
1401 lo32 = left->InputAt(1);
1402 } else if (left->opcode() == IrOpcode::kFloat64InsertHighWord32) {
1403 hi32 = left->InputAt(1);
1404 } else {
1405 return false; // doesn't match
1406 }
1407
1408 if (!lo32 || !hi32) return false; // doesn't match
1409
1410 selector->Emit(kS390_DoubleConstruct, g.DefineAsRegister(node),
1411 g.UseRegister(hi32), g.UseRegister(lo32));
1412 return true;
1413 }
1414
1382 #define null ([]() { return false; }) 1415 #define null ([]() { return false; })
1383 // TODO(john.yan): place kAllowRM where available 1416 // TODO(john.yan): place kAllowRM where available
1384 #define FLOAT_UNARY_OP_LIST_32(V) \ 1417 #define FLOAT_UNARY_OP_LIST_32(V) \
1385 V(Float32, ChangeFloat32ToFloat64, kS390_Float32ToDouble, \ 1418 V(Float32, ChangeFloat32ToFloat64, kS390_Float32ToDouble, \
1386 OperandMode::kAllowRM, null) \ 1419 OperandMode::kAllowRM, null) \
1387 V(Float32, BitcastFloat32ToInt32, kS390_BitcastFloat32ToInt32, \ 1420 V(Float32, BitcastFloat32ToInt32, kS390_BitcastFloat32ToInt32, \
1388 OperandMode::kNone, null) \ 1421 OperandMode::kAllowRM, null) \
1389 V(Float64, TruncateFloat64ToFloat32, kS390_DoubleToFloat32, \ 1422 V(Float64, TruncateFloat64ToFloat32, kS390_DoubleToFloat32, \
1390 OperandMode::kNone, null) \ 1423 OperandMode::kNone, null) \
1391 V(Float64, TruncateFloat64ToWord32, kArchTruncateDoubleToI, \ 1424 V(Float64, TruncateFloat64ToWord32, kArchTruncateDoubleToI, \
1392 OperandMode::kNone, null) \ 1425 OperandMode::kNone, null) \
1393 V(Float64, RoundFloat64ToInt32, kS390_DoubleToInt32, OperandMode::kNone, \ 1426 V(Float64, RoundFloat64ToInt32, kS390_DoubleToInt32, OperandMode::kNone, \
1394 null) \ 1427 null) \
1395 V(Float32, TruncateFloat32ToInt32, kS390_Float32ToInt32, OperandMode::kNone, \ 1428 V(Float32, TruncateFloat32ToInt32, kS390_Float32ToInt32, OperandMode::kNone, \
1396 null) \ 1429 null) \
1397 V(Float32, TruncateFloat32ToUint32, kS390_Float32ToUint32, \ 1430 V(Float32, TruncateFloat32ToUint32, kS390_Float32ToUint32, \
1398 OperandMode::kNone, null) \ 1431 OperandMode::kNone, null) \
(...skipping 13 matching lines...) Expand all
1412 V(Float64, Float64RoundDown, kS390_FloorDouble, OperandMode::kNone, null) \ 1445 V(Float64, Float64RoundDown, kS390_FloorDouble, OperandMode::kNone, null) \
1413 V(Float32, Float32RoundUp, kS390_CeilFloat, OperandMode::kNone, null) \ 1446 V(Float32, Float32RoundUp, kS390_CeilFloat, OperandMode::kNone, null) \
1414 V(Float64, Float64RoundUp, kS390_CeilDouble, OperandMode::kNone, null) \ 1447 V(Float64, Float64RoundUp, kS390_CeilDouble, OperandMode::kNone, null) \
1415 V(Float32, Float32RoundTruncate, kS390_TruncateFloat, OperandMode::kNone, \ 1448 V(Float32, Float32RoundTruncate, kS390_TruncateFloat, OperandMode::kNone, \
1416 null) \ 1449 null) \
1417 V(Float64, Float64RoundTruncate, kS390_TruncateDouble, OperandMode::kNone, \ 1450 V(Float64, Float64RoundTruncate, kS390_TruncateDouble, OperandMode::kNone, \
1418 null) \ 1451 null) \
1419 V(Float64, Float64RoundTiesAway, kS390_RoundDouble, OperandMode::kNone, \ 1452 V(Float64, Float64RoundTiesAway, kS390_RoundDouble, OperandMode::kNone, \
1420 null) \ 1453 null) \
1421 V(Float32, Float32Neg, kS390_NegFloat, OperandMode::kNone, null) \ 1454 V(Float32, Float32Neg, kS390_NegFloat, OperandMode::kNone, null) \
1422 V(Float64, Float64Neg, kS390_NegDouble, OperandMode::kNone, null) 1455 V(Float64, Float64Neg, kS390_NegDouble, OperandMode::kNone, null) \
1456 /* TODO(john.yan): can use kAllowRM */ \
1457 V(Word32, Float64ExtractLowWord32, kS390_DoubleExtractLowWord32, \
1458 OperandMode::kNone, null) \
1459 V(Word32, Float64ExtractHighWord32, kS390_DoubleExtractHighWord32, \
1460 OperandMode::kNone, null)
1423 1461
1424 #define FLOAT_BIN_OP_LIST(V) \ 1462 #define FLOAT_BIN_OP_LIST(V) \
1425 V(Float32, Float32Add, kS390_AddFloat, OperandMode::kAllowRM, null) \ 1463 V(Float32, Float32Add, kS390_AddFloat, OperandMode::kAllowRM, null) \
1426 V(Float64, Float64Add, kS390_AddDouble, OperandMode::kAllowRM, null) \ 1464 V(Float64, Float64Add, kS390_AddDouble, OperandMode::kAllowRM, null) \
1427 V(Float32, Float32Sub, kS390_SubFloat, OperandMode::kAllowRM, null) \ 1465 V(Float32, Float32Sub, kS390_SubFloat, OperandMode::kAllowRM, null) \
1428 V(Float64, Float64Sub, kS390_SubDouble, OperandMode::kAllowRM, null) \ 1466 V(Float64, Float64Sub, kS390_SubDouble, OperandMode::kAllowRM, null) \
1429 V(Float32, Float32Mul, kS390_MulFloat, OperandMode::kAllowRM, null) \ 1467 V(Float32, Float32Mul, kS390_MulFloat, OperandMode::kAllowRM, null) \
1430 V(Float64, Float64Mul, kS390_MulDouble, OperandMode::kAllowRM, null) \ 1468 V(Float64, Float64Mul, kS390_MulDouble, OperandMode::kAllowRM, null) \
1431 V(Float32, Float32Div, kS390_DivFloat, OperandMode::kAllowRM, null) \ 1469 V(Float32, Float32Div, kS390_DivFloat, OperandMode::kAllowRM, null) \
1432 V(Float64, Float64Div, kS390_DivDouble, OperandMode::kAllowRM, null) \ 1470 V(Float64, Float64Div, kS390_DivDouble, OperandMode::kAllowRM, null) \
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 V(Word32, Word32Ror, kS390_RotRight32, \ 1542 V(Word32, Word32Ror, kS390_RotRight32, \
1505 OperandMode::kAllowRI | OperandMode::kAllowRRR | OperandMode::kAllowRRI | \ 1543 OperandMode::kAllowRI | OperandMode::kAllowRRR | OperandMode::kAllowRRI | \
1506 OperandMode::kShift32Imm, \ 1544 OperandMode::kShift32Imm, \
1507 null) \ 1545 null) \
1508 V(Word32, Word32And, kS390_And32, And32OperandMode, null) \ 1546 V(Word32, Word32And, kS390_And32, And32OperandMode, null) \
1509 V(Word32, Word32Or, kS390_Or32, Or32OperandMode, null) \ 1547 V(Word32, Word32Or, kS390_Or32, Or32OperandMode, null) \
1510 V(Word32, Word32Xor, kS390_Xor32, Xor32OperandMode, null) \ 1548 V(Word32, Word32Xor, kS390_Xor32, Xor32OperandMode, null) \
1511 V(Word32, Word32Shl, kS390_ShiftLeft32, Shift32OperandMode, null) \ 1549 V(Word32, Word32Shl, kS390_ShiftLeft32, Shift32OperandMode, null) \
1512 V(Word32, Word32Shr, kS390_ShiftRight32, Shift32OperandMode, null) \ 1550 V(Word32, Word32Shr, kS390_ShiftRight32, Shift32OperandMode, null) \
1513 V(Word32, Word32Sar, kS390_ShiftRightArith32, Shift32OperandMode, \ 1551 V(Word32, Word32Sar, kS390_ShiftRightArith32, Shift32OperandMode, \
1514 [&]() { return TryMatchSignExtInt16OrInt8FromWord32Sar(this, node); }) 1552 [&]() { return TryMatchSignExtInt16OrInt8FromWord32Sar(this, node); }) \
1553 V(Word32, Float64InsertLowWord32, kS390_DoubleInsertLowWord32, \
1554 OperandMode::kAllowRRR, \
1555 [&]() -> bool { return TryMatchDoubleConstructFromInsert(this, node); }) \
1556 V(Word32, Float64InsertHighWord32, kS390_DoubleInsertHighWord32, \
1557 OperandMode::kAllowRRR, \
1558 [&]() -> bool { return TryMatchDoubleConstructFromInsert(this, node); })
1515 1559
1516 #define WORD64_UNARY_OP_LIST(V) \ 1560 #define WORD64_UNARY_OP_LIST(V) \
1517 V(Word64, Word64Popcnt, kS390_Popcnt64, OperandMode::kNone, null) \ 1561 V(Word64, Word64Popcnt, kS390_Popcnt64, OperandMode::kNone, null) \
1518 V(Word64, Word64Clz, kS390_Cntlz64, OperandMode::kNone, null) \ 1562 V(Word64, Word64Clz, kS390_Cntlz64, OperandMode::kNone, null) \
1519 V(Word64, TruncateInt64ToInt32, kS390_Int64ToInt32, OperandMode::kNone, \ 1563 V(Word64, TruncateInt64ToInt32, kS390_Int64ToInt32, OperandMode::kNone, \
1520 null) \ 1564 null) \
1521 V(Word64, RoundInt64ToFloat32, kS390_Int64ToFloat32, OperandMode::kNone, \ 1565 V(Word64, RoundInt64ToFloat32, kS390_Int64ToFloat32, OperandMode::kNone, \
1522 null) \ 1566 null) \
1523 V(Word64, RoundInt64ToFloat64, kS390_Int64ToDouble, OperandMode::kNone, \ 1567 V(Word64, RoundInt64ToFloat64, kS390_Int64ToDouble, OperandMode::kNone, \
1524 null) \ 1568 null) \
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 } 2337 }
2294 ++slot; 2338 ++slot;
2295 } 2339 }
2296 } 2340 }
2297 } 2341 }
2298 2342
2299 bool InstructionSelector::IsTailCallAddressImmediate() { return false; } 2343 bool InstructionSelector::IsTailCallAddressImmediate() { return false; }
2300 2344
2301 int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; } 2345 int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; }
2302 2346
2303 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) {
2304 S390OperandGenerator g(this);
2305 Emit(kS390_DoubleExtractLowWord32, g.DefineAsRegister(node),
2306 g.UseRegister(node->InputAt(0)));
2307 }
2308
2309 void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) {
2310 S390OperandGenerator g(this);
2311 Emit(kS390_DoubleExtractHighWord32, g.DefineAsRegister(node),
2312 g.UseRegister(node->InputAt(0)));
2313 }
2314
2315 void InstructionSelector::VisitFloat64InsertLowWord32(Node* node) {
2316 S390OperandGenerator g(this);
2317 Node* left = node->InputAt(0);
2318 Node* right = node->InputAt(1);
2319 if (left->opcode() == IrOpcode::kFloat64InsertHighWord32 &&
2320 CanCover(node, left)) {
2321 left = left->InputAt(1);
2322 Emit(kS390_DoubleConstruct, g.DefineAsRegister(node), g.UseRegister(left),
2323 g.UseRegister(right));
2324 return;
2325 }
2326 Emit(kS390_DoubleInsertLowWord32, g.DefineSameAsFirst(node),
2327 g.UseRegister(left), g.UseRegister(right));
2328 }
2329
2330 void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
2331 S390OperandGenerator g(this);
2332 Node* left = node->InputAt(0);
2333 Node* right = node->InputAt(1);
2334 if (left->opcode() == IrOpcode::kFloat64InsertLowWord32 &&
2335 CanCover(node, left)) {
2336 left = left->InputAt(1);
2337 Emit(kS390_DoubleConstruct, g.DefineAsRegister(node), g.UseRegister(right),
2338 g.UseRegister(left));
2339 return;
2340 }
2341 Emit(kS390_DoubleInsertHighWord32, g.DefineSameAsFirst(node),
2342 g.UseRegister(left), g.UseRegister(right));
2343 }
2344
2345 void InstructionSelector::VisitAtomicLoad(Node* node) { 2347 void InstructionSelector::VisitAtomicLoad(Node* node) {
2346 LoadRepresentation load_rep = LoadRepresentationOf(node->op()); 2348 LoadRepresentation load_rep = LoadRepresentationOf(node->op());
2347 S390OperandGenerator g(this); 2349 S390OperandGenerator g(this);
2348 Node* base = node->InputAt(0); 2350 Node* base = node->InputAt(0);
2349 Node* index = node->InputAt(1); 2351 Node* index = node->InputAt(1);
2350 ArchOpcode opcode = kArchNop; 2352 ArchOpcode opcode = kArchNop;
2351 switch (load_rep.representation()) { 2353 switch (load_rep.representation()) {
2352 case MachineRepresentation::kWord8: 2354 case MachineRepresentation::kWord8:
2353 opcode = load_rep.IsSigned() ? kAtomicLoadInt8 : kAtomicLoadUint8; 2355 opcode = load_rep.IsSigned() ? kAtomicLoadInt8 : kAtomicLoadUint8;
2354 break; 2356 break;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 // static 2456 // static
2455 MachineOperatorBuilder::AlignmentRequirements 2457 MachineOperatorBuilder::AlignmentRequirements
2456 InstructionSelector::AlignmentRequirements() { 2458 InstructionSelector::AlignmentRequirements() {
2457 return MachineOperatorBuilder::AlignmentRequirements:: 2459 return MachineOperatorBuilder::AlignmentRequirements::
2458 FullUnalignedAccessSupport(); 2460 FullUnalignedAccessSupport();
2459 } 2461 }
2460 2462
2461 } // namespace compiler 2463 } // namespace compiler
2462 } // namespace internal 2464 } // namespace internal
2463 } // namespace v8 2465 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/s390/code-generator-s390.cc ('k') | src/crankshaft/s390/lithium-codegen-s390.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698