11cb0ef41Sopenharmony_ci// Copyright 2016 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#include "src/compiler/machine-graph-verifier.h" 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci#include "src/compiler/common-operator.h" 81cb0ef41Sopenharmony_ci#include "src/compiler/graph.h" 91cb0ef41Sopenharmony_ci#include "src/compiler/linkage.h" 101cb0ef41Sopenharmony_ci#include "src/compiler/machine-operator.h" 111cb0ef41Sopenharmony_ci#include "src/compiler/node-properties.h" 121cb0ef41Sopenharmony_ci#include "src/compiler/node.h" 131cb0ef41Sopenharmony_ci#include "src/compiler/schedule.h" 141cb0ef41Sopenharmony_ci#include "src/zone/zone.h" 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cinamespace v8 { 171cb0ef41Sopenharmony_cinamespace internal { 181cb0ef41Sopenharmony_cinamespace compiler { 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_cinamespace { 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciclass MachineRepresentationInferrer { 231cb0ef41Sopenharmony_ci public: 241cb0ef41Sopenharmony_ci MachineRepresentationInferrer(Schedule const* schedule, Graph const* graph, 251cb0ef41Sopenharmony_ci Linkage* linkage, Zone* zone) 261cb0ef41Sopenharmony_ci : schedule_(schedule), 271cb0ef41Sopenharmony_ci linkage_(linkage), 281cb0ef41Sopenharmony_ci representation_vector_(graph->NodeCount(), MachineRepresentation::kNone, 291cb0ef41Sopenharmony_ci zone) { 301cb0ef41Sopenharmony_ci Run(); 311cb0ef41Sopenharmony_ci } 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci CallDescriptor* call_descriptor() const { 341cb0ef41Sopenharmony_ci return linkage_->GetIncomingDescriptor(); 351cb0ef41Sopenharmony_ci } 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci MachineRepresentation GetRepresentation(Node const* node) const { 381cb0ef41Sopenharmony_ci return representation_vector_.at(node->id()); 391cb0ef41Sopenharmony_ci } 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci private: 421cb0ef41Sopenharmony_ci MachineRepresentation GetProjectionType(Node const* projection) { 431cb0ef41Sopenharmony_ci size_t index = ProjectionIndexOf(projection->op()); 441cb0ef41Sopenharmony_ci Node* input = projection->InputAt(0); 451cb0ef41Sopenharmony_ci switch (input->opcode()) { 461cb0ef41Sopenharmony_ci case IrOpcode::kInt32AddWithOverflow: 471cb0ef41Sopenharmony_ci case IrOpcode::kInt32SubWithOverflow: 481cb0ef41Sopenharmony_ci case IrOpcode::kInt32MulWithOverflow: 491cb0ef41Sopenharmony_ci CHECK_LE(index, static_cast<size_t>(1)); 501cb0ef41Sopenharmony_ci return index == 0 ? MachineRepresentation::kWord32 511cb0ef41Sopenharmony_ci : MachineRepresentation::kBit; 521cb0ef41Sopenharmony_ci case IrOpcode::kInt64AddWithOverflow: 531cb0ef41Sopenharmony_ci case IrOpcode::kInt64SubWithOverflow: 541cb0ef41Sopenharmony_ci CHECK_LE(index, static_cast<size_t>(1)); 551cb0ef41Sopenharmony_ci return index == 0 ? MachineRepresentation::kWord64 561cb0ef41Sopenharmony_ci : MachineRepresentation::kBit; 571cb0ef41Sopenharmony_ci case IrOpcode::kTryTruncateFloat32ToInt64: 581cb0ef41Sopenharmony_ci case IrOpcode::kTryTruncateFloat64ToInt64: 591cb0ef41Sopenharmony_ci case IrOpcode::kTryTruncateFloat32ToUint64: 601cb0ef41Sopenharmony_ci CHECK_LE(index, static_cast<size_t>(1)); 611cb0ef41Sopenharmony_ci return index == 0 ? MachineRepresentation::kWord64 621cb0ef41Sopenharmony_ci : MachineRepresentation::kBit; 631cb0ef41Sopenharmony_ci case IrOpcode::kCall: { 641cb0ef41Sopenharmony_ci auto call_descriptor = CallDescriptorOf(input->op()); 651cb0ef41Sopenharmony_ci return call_descriptor->GetReturnType(index).representation(); 661cb0ef41Sopenharmony_ci } 671cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairLoad: 681cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairAdd: 691cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairSub: 701cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairAnd: 711cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairOr: 721cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairXor: 731cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairExchange: 741cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairCompareExchange: 751cb0ef41Sopenharmony_ci CHECK_LE(index, static_cast<size_t>(1)); 761cb0ef41Sopenharmony_ci return MachineRepresentation::kWord32; 771cb0ef41Sopenharmony_ci default: 781cb0ef41Sopenharmony_ci return MachineRepresentation::kNone; 791cb0ef41Sopenharmony_ci } 801cb0ef41Sopenharmony_ci } 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci MachineRepresentation PromoteRepresentation(MachineRepresentation rep) { 831cb0ef41Sopenharmony_ci switch (rep) { 841cb0ef41Sopenharmony_ci case MachineRepresentation::kWord8: 851cb0ef41Sopenharmony_ci case MachineRepresentation::kWord16: 861cb0ef41Sopenharmony_ci case MachineRepresentation::kWord32: 871cb0ef41Sopenharmony_ci return MachineRepresentation::kWord32; 881cb0ef41Sopenharmony_ci case MachineRepresentation::kSandboxedPointer: 891cb0ef41Sopenharmony_ci // A sandboxed pointer is a Word64 that uses an encoded representation 901cb0ef41Sopenharmony_ci // when stored on the heap. 911cb0ef41Sopenharmony_ci return MachineRepresentation::kWord64; 921cb0ef41Sopenharmony_ci default: 931cb0ef41Sopenharmony_ci break; 941cb0ef41Sopenharmony_ci } 951cb0ef41Sopenharmony_ci return rep; 961cb0ef41Sopenharmony_ci } 971cb0ef41Sopenharmony_ci 981cb0ef41Sopenharmony_ci void Run() { 991cb0ef41Sopenharmony_ci auto blocks = schedule_->all_blocks(); 1001cb0ef41Sopenharmony_ci for (BasicBlock* block : *blocks) { 1011cb0ef41Sopenharmony_ci current_block_ = block; 1021cb0ef41Sopenharmony_ci for (size_t i = 0; i <= block->NodeCount(); ++i) { 1031cb0ef41Sopenharmony_ci Node const* node = 1041cb0ef41Sopenharmony_ci i < block->NodeCount() ? block->NodeAt(i) : block->control_input(); 1051cb0ef41Sopenharmony_ci if (node == nullptr) { 1061cb0ef41Sopenharmony_ci DCHECK_EQ(block->NodeCount(), i); 1071cb0ef41Sopenharmony_ci break; 1081cb0ef41Sopenharmony_ci } 1091cb0ef41Sopenharmony_ci switch (node->opcode()) { 1101cb0ef41Sopenharmony_ci case IrOpcode::kParameter: 1111cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 1121cb0ef41Sopenharmony_ci linkage_->GetParameterType(ParameterIndexOf(node->op())) 1131cb0ef41Sopenharmony_ci .representation(); 1141cb0ef41Sopenharmony_ci break; 1151cb0ef41Sopenharmony_ci case IrOpcode::kReturn: { 1161cb0ef41Sopenharmony_ci representation_vector_[node->id()] = PromoteRepresentation( 1171cb0ef41Sopenharmony_ci linkage_->GetReturnType().representation()); 1181cb0ef41Sopenharmony_ci break; 1191cb0ef41Sopenharmony_ci } 1201cb0ef41Sopenharmony_ci case IrOpcode::kProjection: { 1211cb0ef41Sopenharmony_ci representation_vector_[node->id()] = GetProjectionType(node); 1221cb0ef41Sopenharmony_ci } break; 1231cb0ef41Sopenharmony_ci case IrOpcode::kTypedStateValues: 1241cb0ef41Sopenharmony_ci representation_vector_[node->id()] = MachineRepresentation::kNone; 1251cb0ef41Sopenharmony_ci break; 1261cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicLoad: 1271cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicLoad: 1281cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 1291cb0ef41Sopenharmony_ci PromoteRepresentation(AtomicLoadParametersOf(node->op()) 1301cb0ef41Sopenharmony_ci .representation() 1311cb0ef41Sopenharmony_ci .representation()); 1321cb0ef41Sopenharmony_ci break; 1331cb0ef41Sopenharmony_ci case IrOpcode::kLoad: 1341cb0ef41Sopenharmony_ci case IrOpcode::kLoadImmutable: 1351cb0ef41Sopenharmony_ci case IrOpcode::kProtectedLoad: 1361cb0ef41Sopenharmony_ci representation_vector_[node->id()] = PromoteRepresentation( 1371cb0ef41Sopenharmony_ci LoadRepresentationOf(node->op()).representation()); 1381cb0ef41Sopenharmony_ci break; 1391cb0ef41Sopenharmony_ci case IrOpcode::kLoadFramePointer: 1401cb0ef41Sopenharmony_ci case IrOpcode::kLoadParentFramePointer: 1411cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 1421cb0ef41Sopenharmony_ci MachineType::PointerRepresentation(); 1431cb0ef41Sopenharmony_ci break; 1441cb0ef41Sopenharmony_ci case IrOpcode::kUnalignedLoad: 1451cb0ef41Sopenharmony_ci representation_vector_[node->id()] = PromoteRepresentation( 1461cb0ef41Sopenharmony_ci LoadRepresentationOf(node->op()).representation()); 1471cb0ef41Sopenharmony_ci break; 1481cb0ef41Sopenharmony_ci case IrOpcode::kPhi: 1491cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 1501cb0ef41Sopenharmony_ci PhiRepresentationOf(node->op()); 1511cb0ef41Sopenharmony_ci break; 1521cb0ef41Sopenharmony_ci case IrOpcode::kCall: { 1531cb0ef41Sopenharmony_ci auto call_descriptor = CallDescriptorOf(node->op()); 1541cb0ef41Sopenharmony_ci if (call_descriptor->ReturnCount() > 0) { 1551cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 1561cb0ef41Sopenharmony_ci call_descriptor->GetReturnType(0).representation(); 1571cb0ef41Sopenharmony_ci } else { 1581cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 1591cb0ef41Sopenharmony_ci MachineRepresentation::kTagged; 1601cb0ef41Sopenharmony_ci } 1611cb0ef41Sopenharmony_ci break; 1621cb0ef41Sopenharmony_ci } 1631cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicStore: 1641cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicStore: 1651cb0ef41Sopenharmony_ci representation_vector_[node->id()] = PromoteRepresentation( 1661cb0ef41Sopenharmony_ci AtomicStoreParametersOf(node->op()).representation()); 1671cb0ef41Sopenharmony_ci break; 1681cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairLoad: 1691cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairStore: 1701cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairAdd: 1711cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairSub: 1721cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairAnd: 1731cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairOr: 1741cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairXor: 1751cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairExchange: 1761cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairCompareExchange: 1771cb0ef41Sopenharmony_ci representation_vector_[node->id()] = MachineRepresentation::kWord32; 1781cb0ef41Sopenharmony_ci break; 1791cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicExchange: 1801cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicCompareExchange: 1811cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicAdd: 1821cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicSub: 1831cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicAnd: 1841cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicOr: 1851cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicXor: 1861cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicExchange: 1871cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicCompareExchange: 1881cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicAdd: 1891cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicSub: 1901cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicAnd: 1911cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicOr: 1921cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicXor: 1931cb0ef41Sopenharmony_ci representation_vector_[node->id()] = PromoteRepresentation( 1941cb0ef41Sopenharmony_ci AtomicOpType(node->op()).representation()); 1951cb0ef41Sopenharmony_ci break; 1961cb0ef41Sopenharmony_ci case IrOpcode::kStore: 1971cb0ef41Sopenharmony_ci case IrOpcode::kProtectedStore: 1981cb0ef41Sopenharmony_ci representation_vector_[node->id()] = PromoteRepresentation( 1991cb0ef41Sopenharmony_ci StoreRepresentationOf(node->op()).representation()); 2001cb0ef41Sopenharmony_ci break; 2011cb0ef41Sopenharmony_ci case IrOpcode::kUnalignedStore: 2021cb0ef41Sopenharmony_ci representation_vector_[node->id()] = PromoteRepresentation( 2031cb0ef41Sopenharmony_ci UnalignedStoreRepresentationOf(node->op())); 2041cb0ef41Sopenharmony_ci break; 2051cb0ef41Sopenharmony_ci case IrOpcode::kHeapConstant: 2061cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 2071cb0ef41Sopenharmony_ci MachineRepresentation::kTaggedPointer; 2081cb0ef41Sopenharmony_ci break; 2091cb0ef41Sopenharmony_ci case IrOpcode::kNumberConstant: 2101cb0ef41Sopenharmony_ci case IrOpcode::kDelayedStringConstant: 2111cb0ef41Sopenharmony_ci case IrOpcode::kChangeBitToTagged: 2121cb0ef41Sopenharmony_ci case IrOpcode::kIfException: 2131cb0ef41Sopenharmony_ci case IrOpcode::kOsrValue: 2141cb0ef41Sopenharmony_ci case IrOpcode::kChangeInt32ToTagged: 2151cb0ef41Sopenharmony_ci case IrOpcode::kChangeUint32ToTagged: 2161cb0ef41Sopenharmony_ci case IrOpcode::kBitcastWordToTagged: 2171cb0ef41Sopenharmony_ci representation_vector_[node->id()] = MachineRepresentation::kTagged; 2181cb0ef41Sopenharmony_ci break; 2191cb0ef41Sopenharmony_ci case IrOpcode::kCompressedHeapConstant: 2201cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 2211cb0ef41Sopenharmony_ci MachineRepresentation::kCompressedPointer; 2221cb0ef41Sopenharmony_ci break; 2231cb0ef41Sopenharmony_ci case IrOpcode::kExternalConstant: 2241cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 2251cb0ef41Sopenharmony_ci MachineType::PointerRepresentation(); 2261cb0ef41Sopenharmony_ci break; 2271cb0ef41Sopenharmony_ci case IrOpcode::kBitcastTaggedToWord: 2281cb0ef41Sopenharmony_ci case IrOpcode::kBitcastTaggedToWordForTagAndSmiBits: 2291cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 2301cb0ef41Sopenharmony_ci MachineType::PointerRepresentation(); 2311cb0ef41Sopenharmony_ci break; 2321cb0ef41Sopenharmony_ci case IrOpcode::kBitcastWordToTaggedSigned: 2331cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 2341cb0ef41Sopenharmony_ci MachineRepresentation::kTaggedSigned; 2351cb0ef41Sopenharmony_ci break; 2361cb0ef41Sopenharmony_ci case IrOpcode::kWord32Equal: 2371cb0ef41Sopenharmony_ci case IrOpcode::kInt32LessThan: 2381cb0ef41Sopenharmony_ci case IrOpcode::kInt32LessThanOrEqual: 2391cb0ef41Sopenharmony_ci case IrOpcode::kUint32LessThan: 2401cb0ef41Sopenharmony_ci case IrOpcode::kUint32LessThanOrEqual: 2411cb0ef41Sopenharmony_ci case IrOpcode::kWord64Equal: 2421cb0ef41Sopenharmony_ci case IrOpcode::kInt64LessThan: 2431cb0ef41Sopenharmony_ci case IrOpcode::kInt64LessThanOrEqual: 2441cb0ef41Sopenharmony_ci case IrOpcode::kUint64LessThan: 2451cb0ef41Sopenharmony_ci case IrOpcode::kUint64LessThanOrEqual: 2461cb0ef41Sopenharmony_ci case IrOpcode::kFloat32Equal: 2471cb0ef41Sopenharmony_ci case IrOpcode::kFloat32LessThan: 2481cb0ef41Sopenharmony_ci case IrOpcode::kFloat32LessThanOrEqual: 2491cb0ef41Sopenharmony_ci case IrOpcode::kFloat64Equal: 2501cb0ef41Sopenharmony_ci case IrOpcode::kFloat64LessThan: 2511cb0ef41Sopenharmony_ci case IrOpcode::kFloat64LessThanOrEqual: 2521cb0ef41Sopenharmony_ci case IrOpcode::kChangeTaggedToBit: 2531cb0ef41Sopenharmony_ci case IrOpcode::kStackPointerGreaterThan: 2541cb0ef41Sopenharmony_ci representation_vector_[node->id()] = MachineRepresentation::kBit; 2551cb0ef41Sopenharmony_ci break; 2561cb0ef41Sopenharmony_ci#define LABEL(opcode) case IrOpcode::k##opcode: 2571cb0ef41Sopenharmony_ci case IrOpcode::kTruncateInt64ToInt32: 2581cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat32ToInt32: 2591cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat32ToUint32: 2601cb0ef41Sopenharmony_ci case IrOpcode::kBitcastFloat32ToInt32: 2611cb0ef41Sopenharmony_ci case IrOpcode::kI32x4ExtractLane: 2621cb0ef41Sopenharmony_ci case IrOpcode::kI16x8ExtractLaneU: 2631cb0ef41Sopenharmony_ci case IrOpcode::kI16x8ExtractLaneS: 2641cb0ef41Sopenharmony_ci case IrOpcode::kI8x16ExtractLaneU: 2651cb0ef41Sopenharmony_ci case IrOpcode::kI8x16ExtractLaneS: 2661cb0ef41Sopenharmony_ci case IrOpcode::kInt32Constant: 2671cb0ef41Sopenharmony_ci case IrOpcode::kRelocatableInt32Constant: 2681cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat64ToWord32: 2691cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat64ToUint32: 2701cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat64ToInt32: 2711cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat64ToUint32: 2721cb0ef41Sopenharmony_ci case IrOpcode::kRoundFloat64ToInt32: 2731cb0ef41Sopenharmony_ci case IrOpcode::kFloat64ExtractLowWord32: 2741cb0ef41Sopenharmony_ci case IrOpcode::kFloat64ExtractHighWord32: 2751cb0ef41Sopenharmony_ci case IrOpcode::kWord32Popcnt: 2761cb0ef41Sopenharmony_ci case IrOpcode::kI8x16BitMask: 2771cb0ef41Sopenharmony_ci MACHINE_UNOP_32_LIST(LABEL) 2781cb0ef41Sopenharmony_ci MACHINE_BINOP_32_LIST(LABEL) { 2791cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 2801cb0ef41Sopenharmony_ci MachineRepresentation::kWord32; 2811cb0ef41Sopenharmony_ci } 2821cb0ef41Sopenharmony_ci break; 2831cb0ef41Sopenharmony_ci case IrOpcode::kChangeInt32ToInt64: 2841cb0ef41Sopenharmony_ci case IrOpcode::kChangeUint32ToUint64: 2851cb0ef41Sopenharmony_ci case IrOpcode::kInt64Constant: 2861cb0ef41Sopenharmony_ci case IrOpcode::kRelocatableInt64Constant: 2871cb0ef41Sopenharmony_ci case IrOpcode::kBitcastFloat64ToInt64: 2881cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat64ToInt64: 2891cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat64ToUint64: 2901cb0ef41Sopenharmony_ci case IrOpcode::kWord64Popcnt: 2911cb0ef41Sopenharmony_ci case IrOpcode::kWord64Ctz: 2921cb0ef41Sopenharmony_ci case IrOpcode::kWord64Clz: 2931cb0ef41Sopenharmony_ci MACHINE_BINOP_64_LIST(LABEL) { 2941cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 2951cb0ef41Sopenharmony_ci MachineRepresentation::kWord64; 2961cb0ef41Sopenharmony_ci } 2971cb0ef41Sopenharmony_ci break; 2981cb0ef41Sopenharmony_ci case IrOpcode::kRoundInt32ToFloat32: 2991cb0ef41Sopenharmony_ci case IrOpcode::kRoundUint32ToFloat32: 3001cb0ef41Sopenharmony_ci case IrOpcode::kRoundInt64ToFloat32: 3011cb0ef41Sopenharmony_ci case IrOpcode::kRoundUint64ToFloat32: 3021cb0ef41Sopenharmony_ci case IrOpcode::kBitcastInt32ToFloat32: 3031cb0ef41Sopenharmony_ci case IrOpcode::kFloat32Constant: 3041cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat64ToFloat32: 3051cb0ef41Sopenharmony_ci MACHINE_FLOAT32_BINOP_LIST(LABEL) 3061cb0ef41Sopenharmony_ci MACHINE_FLOAT32_UNOP_LIST(LABEL) { 3071cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 3081cb0ef41Sopenharmony_ci MachineRepresentation::kFloat32; 3091cb0ef41Sopenharmony_ci } 3101cb0ef41Sopenharmony_ci break; 3111cb0ef41Sopenharmony_ci case IrOpcode::kRoundInt64ToFloat64: 3121cb0ef41Sopenharmony_ci case IrOpcode::kRoundUint64ToFloat64: 3131cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat32ToFloat64: 3141cb0ef41Sopenharmony_ci case IrOpcode::kChangeInt32ToFloat64: 3151cb0ef41Sopenharmony_ci case IrOpcode::kChangeUint32ToFloat64: 3161cb0ef41Sopenharmony_ci case IrOpcode::kFloat64InsertLowWord32: 3171cb0ef41Sopenharmony_ci case IrOpcode::kFloat64InsertHighWord32: 3181cb0ef41Sopenharmony_ci case IrOpcode::kFloat64Constant: 3191cb0ef41Sopenharmony_ci case IrOpcode::kFloat64SilenceNaN: 3201cb0ef41Sopenharmony_ci MACHINE_FLOAT64_BINOP_LIST(LABEL) 3211cb0ef41Sopenharmony_ci MACHINE_FLOAT64_UNOP_LIST(LABEL) { 3221cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 3231cb0ef41Sopenharmony_ci MachineRepresentation::kFloat64; 3241cb0ef41Sopenharmony_ci } 3251cb0ef41Sopenharmony_ci break; 3261cb0ef41Sopenharmony_ci case IrOpcode::kI32x4ReplaceLane: 3271cb0ef41Sopenharmony_ci case IrOpcode::kI32x4Splat: 3281cb0ef41Sopenharmony_ci case IrOpcode::kI8x16Splat: 3291cb0ef41Sopenharmony_ci case IrOpcode::kI8x16Eq: 3301cb0ef41Sopenharmony_ci representation_vector_[node->id()] = 3311cb0ef41Sopenharmony_ci MachineRepresentation::kSimd128; 3321cb0ef41Sopenharmony_ci break; 3331cb0ef41Sopenharmony_ci#undef LABEL 3341cb0ef41Sopenharmony_ci default: 3351cb0ef41Sopenharmony_ci break; 3361cb0ef41Sopenharmony_ci } 3371cb0ef41Sopenharmony_ci } 3381cb0ef41Sopenharmony_ci } 3391cb0ef41Sopenharmony_ci } 3401cb0ef41Sopenharmony_ci 3411cb0ef41Sopenharmony_ci Schedule const* const schedule_; 3421cb0ef41Sopenharmony_ci Linkage const* const linkage_; 3431cb0ef41Sopenharmony_ci ZoneVector<MachineRepresentation> representation_vector_; 3441cb0ef41Sopenharmony_ci BasicBlock* current_block_; 3451cb0ef41Sopenharmony_ci}; 3461cb0ef41Sopenharmony_ci 3471cb0ef41Sopenharmony_ciclass MachineRepresentationChecker { 3481cb0ef41Sopenharmony_ci public: 3491cb0ef41Sopenharmony_ci MachineRepresentationChecker( 3501cb0ef41Sopenharmony_ci Schedule const* const schedule, 3511cb0ef41Sopenharmony_ci MachineRepresentationInferrer const* const inferrer, bool is_stub, 3521cb0ef41Sopenharmony_ci const char* name) 3531cb0ef41Sopenharmony_ci : schedule_(schedule), 3541cb0ef41Sopenharmony_ci inferrer_(inferrer), 3551cb0ef41Sopenharmony_ci is_stub_(is_stub), 3561cb0ef41Sopenharmony_ci name_(name), 3571cb0ef41Sopenharmony_ci current_block_(nullptr) {} 3581cb0ef41Sopenharmony_ci 3591cb0ef41Sopenharmony_ci void Run() { 3601cb0ef41Sopenharmony_ci BasicBlockVector const* blocks = schedule_->all_blocks(); 3611cb0ef41Sopenharmony_ci for (BasicBlock* block : *blocks) { 3621cb0ef41Sopenharmony_ci current_block_ = block; 3631cb0ef41Sopenharmony_ci for (size_t i = 0; i <= block->NodeCount(); ++i) { 3641cb0ef41Sopenharmony_ci Node const* node = 3651cb0ef41Sopenharmony_ci i < block->NodeCount() ? block->NodeAt(i) : block->control_input(); 3661cb0ef41Sopenharmony_ci if (node == nullptr) { 3671cb0ef41Sopenharmony_ci DCHECK_EQ(block->NodeCount(), i); 3681cb0ef41Sopenharmony_ci break; 3691cb0ef41Sopenharmony_ci } 3701cb0ef41Sopenharmony_ci switch (node->opcode()) { 3711cb0ef41Sopenharmony_ci case IrOpcode::kCall: 3721cb0ef41Sopenharmony_ci case IrOpcode::kTailCall: 3731cb0ef41Sopenharmony_ci CheckCallInputs(node); 3741cb0ef41Sopenharmony_ci break; 3751cb0ef41Sopenharmony_ci case IrOpcode::kChangeBitToTagged: 3761cb0ef41Sopenharmony_ci CHECK_EQ(MachineRepresentation::kBit, 3771cb0ef41Sopenharmony_ci inferrer_->GetRepresentation(node->InputAt(0))); 3781cb0ef41Sopenharmony_ci break; 3791cb0ef41Sopenharmony_ci case IrOpcode::kChangeTaggedToBit: 3801cb0ef41Sopenharmony_ci CHECK_EQ(MachineRepresentation::kTagged, 3811cb0ef41Sopenharmony_ci inferrer_->GetRepresentation(node->InputAt(0))); 3821cb0ef41Sopenharmony_ci break; 3831cb0ef41Sopenharmony_ci case IrOpcode::kRoundInt64ToFloat64: 3841cb0ef41Sopenharmony_ci case IrOpcode::kRoundUint64ToFloat64: 3851cb0ef41Sopenharmony_ci case IrOpcode::kRoundInt64ToFloat32: 3861cb0ef41Sopenharmony_ci case IrOpcode::kRoundUint64ToFloat32: 3871cb0ef41Sopenharmony_ci case IrOpcode::kTruncateInt64ToInt32: 3881cb0ef41Sopenharmony_ci case IrOpcode::kWord64Ctz: 3891cb0ef41Sopenharmony_ci case IrOpcode::kWord64Clz: 3901cb0ef41Sopenharmony_ci case IrOpcode::kWord64Popcnt: 3911cb0ef41Sopenharmony_ci CheckValueInputForInt64Op(node, 0); 3921cb0ef41Sopenharmony_ci break; 3931cb0ef41Sopenharmony_ci case IrOpcode::kBitcastWordToTagged: 3941cb0ef41Sopenharmony_ci case IrOpcode::kBitcastWordToTaggedSigned: 3951cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 3961cb0ef41Sopenharmony_ci node, 0, MachineType::PointerRepresentation()); 3971cb0ef41Sopenharmony_ci break; 3981cb0ef41Sopenharmony_ci case IrOpcode::kBitcastTaggedToWord: 3991cb0ef41Sopenharmony_ci case IrOpcode::kBitcastTaggedToWordForTagAndSmiBits: 4001cb0ef41Sopenharmony_ci if (COMPRESS_POINTERS_BOOL) { 4011cb0ef41Sopenharmony_ci CheckValueInputIsCompressedOrTagged(node, 0); 4021cb0ef41Sopenharmony_ci } else { 4031cb0ef41Sopenharmony_ci CheckValueInputIsTagged(node, 0); 4041cb0ef41Sopenharmony_ci } 4051cb0ef41Sopenharmony_ci break; 4061cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat64ToWord32: 4071cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat64ToUint32: 4081cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat64ToFloat32: 4091cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat64ToInt32: 4101cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat64ToUint32: 4111cb0ef41Sopenharmony_ci case IrOpcode::kRoundFloat64ToInt32: 4121cb0ef41Sopenharmony_ci case IrOpcode::kFloat64ExtractLowWord32: 4131cb0ef41Sopenharmony_ci case IrOpcode::kFloat64ExtractHighWord32: 4141cb0ef41Sopenharmony_ci case IrOpcode::kBitcastFloat64ToInt64: 4151cb0ef41Sopenharmony_ci case IrOpcode::kTryTruncateFloat64ToInt64: 4161cb0ef41Sopenharmony_ci CheckValueInputForFloat64Op(node, 0); 4171cb0ef41Sopenharmony_ci break; 4181cb0ef41Sopenharmony_ci case IrOpcode::kWord64Equal: 4191cb0ef41Sopenharmony_ci if (Is64() && !COMPRESS_POINTERS_BOOL) { 4201cb0ef41Sopenharmony_ci CheckValueInputIsTaggedOrPointer(node, 0); 4211cb0ef41Sopenharmony_ci CheckValueInputIsTaggedOrPointer(node, 1); 4221cb0ef41Sopenharmony_ci if (!is_stub_) { 4231cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 4241cb0ef41Sopenharmony_ci node, 1, inferrer_->GetRepresentation(node->InputAt(0))); 4251cb0ef41Sopenharmony_ci } 4261cb0ef41Sopenharmony_ci } else { 4271cb0ef41Sopenharmony_ci CheckValueInputForInt64Op(node, 0); 4281cb0ef41Sopenharmony_ci CheckValueInputForInt64Op(node, 1); 4291cb0ef41Sopenharmony_ci } 4301cb0ef41Sopenharmony_ci break; 4311cb0ef41Sopenharmony_ci case IrOpcode::kInt64LessThan: 4321cb0ef41Sopenharmony_ci case IrOpcode::kInt64LessThanOrEqual: 4331cb0ef41Sopenharmony_ci case IrOpcode::kUint64LessThan: 4341cb0ef41Sopenharmony_ci case IrOpcode::kUint64LessThanOrEqual: 4351cb0ef41Sopenharmony_ci CheckValueInputForInt64Op(node, 0); 4361cb0ef41Sopenharmony_ci CheckValueInputForInt64Op(node, 1); 4371cb0ef41Sopenharmony_ci break; 4381cb0ef41Sopenharmony_ci case IrOpcode::kI32x4ExtractLane: 4391cb0ef41Sopenharmony_ci case IrOpcode::kI16x8ExtractLaneU: 4401cb0ef41Sopenharmony_ci case IrOpcode::kI16x8ExtractLaneS: 4411cb0ef41Sopenharmony_ci case IrOpcode::kI8x16BitMask: 4421cb0ef41Sopenharmony_ci case IrOpcode::kI8x16ExtractLaneU: 4431cb0ef41Sopenharmony_ci case IrOpcode::kI8x16ExtractLaneS: 4441cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs(node, 0, 4451cb0ef41Sopenharmony_ci MachineRepresentation::kSimd128); 4461cb0ef41Sopenharmony_ci break; 4471cb0ef41Sopenharmony_ci case IrOpcode::kI32x4ReplaceLane: 4481cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs(node, 0, 4491cb0ef41Sopenharmony_ci MachineRepresentation::kSimd128); 4501cb0ef41Sopenharmony_ci CheckValueInputForInt32Op(node, 1); 4511cb0ef41Sopenharmony_ci break; 4521cb0ef41Sopenharmony_ci case IrOpcode::kI32x4Splat: 4531cb0ef41Sopenharmony_ci case IrOpcode::kI8x16Splat: 4541cb0ef41Sopenharmony_ci CheckValueInputForInt32Op(node, 0); 4551cb0ef41Sopenharmony_ci break; 4561cb0ef41Sopenharmony_ci case IrOpcode::kI8x16Eq: 4571cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs(node, 0, 4581cb0ef41Sopenharmony_ci MachineRepresentation::kSimd128); 4591cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs(node, 1, 4601cb0ef41Sopenharmony_ci MachineRepresentation::kSimd128); 4611cb0ef41Sopenharmony_ci break; 4621cb0ef41Sopenharmony_ci 4631cb0ef41Sopenharmony_ci#define LABEL(opcode) case IrOpcode::k##opcode: 4641cb0ef41Sopenharmony_ci case IrOpcode::kChangeInt32ToTagged: 4651cb0ef41Sopenharmony_ci case IrOpcode::kChangeUint32ToTagged: 4661cb0ef41Sopenharmony_ci case IrOpcode::kChangeInt32ToFloat64: 4671cb0ef41Sopenharmony_ci case IrOpcode::kChangeUint32ToFloat64: 4681cb0ef41Sopenharmony_ci case IrOpcode::kRoundInt32ToFloat32: 4691cb0ef41Sopenharmony_ci case IrOpcode::kRoundUint32ToFloat32: 4701cb0ef41Sopenharmony_ci case IrOpcode::kBitcastInt32ToFloat32: 4711cb0ef41Sopenharmony_ci case IrOpcode::kBitcastWord32ToWord64: 4721cb0ef41Sopenharmony_ci case IrOpcode::kChangeInt32ToInt64: 4731cb0ef41Sopenharmony_ci case IrOpcode::kChangeUint32ToUint64: 4741cb0ef41Sopenharmony_ci case IrOpcode::kWord32Popcnt: 4751cb0ef41Sopenharmony_ci MACHINE_UNOP_32_LIST(LABEL) { CheckValueInputForInt32Op(node, 0); } 4761cb0ef41Sopenharmony_ci break; 4771cb0ef41Sopenharmony_ci case IrOpcode::kWord32Equal: 4781cb0ef41Sopenharmony_ci if (Is32()) { 4791cb0ef41Sopenharmony_ci CheckValueInputIsTaggedOrPointer(node, 0); 4801cb0ef41Sopenharmony_ci CheckValueInputIsTaggedOrPointer(node, 1); 4811cb0ef41Sopenharmony_ci if (!is_stub_) { 4821cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 4831cb0ef41Sopenharmony_ci node, 1, inferrer_->GetRepresentation(node->InputAt(0))); 4841cb0ef41Sopenharmony_ci } 4851cb0ef41Sopenharmony_ci } else { 4861cb0ef41Sopenharmony_ci if (COMPRESS_POINTERS_BOOL) { 4871cb0ef41Sopenharmony_ci CheckValueInputIsCompressedOrTaggedOrInt32(node, 0); 4881cb0ef41Sopenharmony_ci CheckValueInputIsCompressedOrTaggedOrInt32(node, 1); 4891cb0ef41Sopenharmony_ci } else { 4901cb0ef41Sopenharmony_ci CheckValueIsTaggedOrInt32(node, 0); 4911cb0ef41Sopenharmony_ci CheckValueIsTaggedOrInt32(node, 1); 4921cb0ef41Sopenharmony_ci } 4931cb0ef41Sopenharmony_ci } 4941cb0ef41Sopenharmony_ci break; 4951cb0ef41Sopenharmony_ci 4961cb0ef41Sopenharmony_ci case IrOpcode::kInt32LessThan: 4971cb0ef41Sopenharmony_ci case IrOpcode::kInt32LessThanOrEqual: 4981cb0ef41Sopenharmony_ci case IrOpcode::kUint32LessThan: 4991cb0ef41Sopenharmony_ci case IrOpcode::kUint32LessThanOrEqual: 5001cb0ef41Sopenharmony_ci MACHINE_BINOP_32_LIST(LABEL) { 5011cb0ef41Sopenharmony_ci CheckValueInputForInt32Op(node, 0); 5021cb0ef41Sopenharmony_ci CheckValueInputForInt32Op(node, 1); 5031cb0ef41Sopenharmony_ci } 5041cb0ef41Sopenharmony_ci break; 5051cb0ef41Sopenharmony_ci MACHINE_BINOP_64_LIST(LABEL) { 5061cb0ef41Sopenharmony_ci CheckValueInputForInt64Op(node, 0); 5071cb0ef41Sopenharmony_ci CheckValueInputForInt64Op(node, 1); 5081cb0ef41Sopenharmony_ci } 5091cb0ef41Sopenharmony_ci break; 5101cb0ef41Sopenharmony_ci case IrOpcode::kFloat32Equal: 5111cb0ef41Sopenharmony_ci case IrOpcode::kFloat32LessThan: 5121cb0ef41Sopenharmony_ci case IrOpcode::kFloat32LessThanOrEqual: 5131cb0ef41Sopenharmony_ci MACHINE_FLOAT32_BINOP_LIST(LABEL) { 5141cb0ef41Sopenharmony_ci CheckValueInputForFloat32Op(node, 0); 5151cb0ef41Sopenharmony_ci CheckValueInputForFloat32Op(node, 1); 5161cb0ef41Sopenharmony_ci } 5171cb0ef41Sopenharmony_ci break; 5181cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat32ToFloat64: 5191cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat32ToInt32: 5201cb0ef41Sopenharmony_ci case IrOpcode::kTruncateFloat32ToUint32: 5211cb0ef41Sopenharmony_ci case IrOpcode::kBitcastFloat32ToInt32: 5221cb0ef41Sopenharmony_ci MACHINE_FLOAT32_UNOP_LIST(LABEL) { 5231cb0ef41Sopenharmony_ci CheckValueInputForFloat32Op(node, 0); 5241cb0ef41Sopenharmony_ci } 5251cb0ef41Sopenharmony_ci break; 5261cb0ef41Sopenharmony_ci case IrOpcode::kFloat64Equal: 5271cb0ef41Sopenharmony_ci case IrOpcode::kFloat64LessThan: 5281cb0ef41Sopenharmony_ci case IrOpcode::kFloat64LessThanOrEqual: 5291cb0ef41Sopenharmony_ci MACHINE_FLOAT64_BINOP_LIST(LABEL) { 5301cb0ef41Sopenharmony_ci CheckValueInputForFloat64Op(node, 0); 5311cb0ef41Sopenharmony_ci CheckValueInputForFloat64Op(node, 1); 5321cb0ef41Sopenharmony_ci } 5331cb0ef41Sopenharmony_ci break; 5341cb0ef41Sopenharmony_ci case IrOpcode::kFloat64SilenceNaN: 5351cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat64ToInt64: 5361cb0ef41Sopenharmony_ci case IrOpcode::kChangeFloat64ToUint64: 5371cb0ef41Sopenharmony_ci MACHINE_FLOAT64_UNOP_LIST(LABEL) { 5381cb0ef41Sopenharmony_ci CheckValueInputForFloat64Op(node, 0); 5391cb0ef41Sopenharmony_ci } 5401cb0ef41Sopenharmony_ci break; 5411cb0ef41Sopenharmony_ci#undef LABEL 5421cb0ef41Sopenharmony_ci case IrOpcode::kFloat64InsertLowWord32: 5431cb0ef41Sopenharmony_ci case IrOpcode::kFloat64InsertHighWord32: 5441cb0ef41Sopenharmony_ci CheckValueInputForFloat64Op(node, 0); 5451cb0ef41Sopenharmony_ci CheckValueInputForInt32Op(node, 1); 5461cb0ef41Sopenharmony_ci break; 5471cb0ef41Sopenharmony_ci case IrOpcode::kParameter: 5481cb0ef41Sopenharmony_ci case IrOpcode::kProjection: 5491cb0ef41Sopenharmony_ci break; 5501cb0ef41Sopenharmony_ci case IrOpcode::kAbortCSADcheck: 5511cb0ef41Sopenharmony_ci CheckValueInputIsTagged(node, 0); 5521cb0ef41Sopenharmony_ci break; 5531cb0ef41Sopenharmony_ci case IrOpcode::kLoad: 5541cb0ef41Sopenharmony_ci case IrOpcode::kUnalignedLoad: 5551cb0ef41Sopenharmony_ci case IrOpcode::kLoadImmutable: 5561cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicLoad: 5571cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairLoad: 5581cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicLoad: 5591cb0ef41Sopenharmony_ci CheckValueInputIsTaggedOrPointer(node, 0); 5601cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 5611cb0ef41Sopenharmony_ci node, 1, MachineType::PointerRepresentation()); 5621cb0ef41Sopenharmony_ci break; 5631cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairAdd: 5641cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairSub: 5651cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairAnd: 5661cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairOr: 5671cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairXor: 5681cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairStore: 5691cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairExchange: 5701cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs(node, 3, 5711cb0ef41Sopenharmony_ci MachineRepresentation::kWord32); 5721cb0ef41Sopenharmony_ci V8_FALLTHROUGH; 5731cb0ef41Sopenharmony_ci case IrOpcode::kStore: 5741cb0ef41Sopenharmony_ci case IrOpcode::kUnalignedStore: 5751cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicStore: 5761cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicExchange: 5771cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicAdd: 5781cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicSub: 5791cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicAnd: 5801cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicOr: 5811cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicXor: 5821cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicStore: 5831cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicExchange: 5841cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicAdd: 5851cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicSub: 5861cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicAnd: 5871cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicOr: 5881cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicXor: 5891cb0ef41Sopenharmony_ci CheckValueInputIsTaggedOrPointer(node, 0); 5901cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 5911cb0ef41Sopenharmony_ci node, 1, MachineType::PointerRepresentation()); 5921cb0ef41Sopenharmony_ci switch (inferrer_->GetRepresentation(node)) { 5931cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 5941cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 5951cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedSigned: 5961cb0ef41Sopenharmony_ci if (COMPRESS_POINTERS_BOOL && 5971cb0ef41Sopenharmony_ci ((node->opcode() == IrOpcode::kStore && 5981cb0ef41Sopenharmony_ci IsAnyTagged(StoreRepresentationOf(node->op()) 5991cb0ef41Sopenharmony_ci .representation())) || 6001cb0ef41Sopenharmony_ci (node->opcode() == IrOpcode::kWord32AtomicStore && 6011cb0ef41Sopenharmony_ci IsAnyTagged(AtomicStoreParametersOf(node->op()) 6021cb0ef41Sopenharmony_ci .representation())))) { 6031cb0ef41Sopenharmony_ci CheckValueInputIsCompressedOrTagged(node, 2); 6041cb0ef41Sopenharmony_ci } else { 6051cb0ef41Sopenharmony_ci CheckValueInputIsTagged(node, 2); 6061cb0ef41Sopenharmony_ci } 6071cb0ef41Sopenharmony_ci break; 6081cb0ef41Sopenharmony_ci default: 6091cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 6101cb0ef41Sopenharmony_ci node, 2, inferrer_->GetRepresentation(node)); 6111cb0ef41Sopenharmony_ci } 6121cb0ef41Sopenharmony_ci break; 6131cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicPairCompareExchange: 6141cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs(node, 4, 6151cb0ef41Sopenharmony_ci MachineRepresentation::kWord32); 6161cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs(node, 5, 6171cb0ef41Sopenharmony_ci MachineRepresentation::kWord32); 6181cb0ef41Sopenharmony_ci V8_FALLTHROUGH; 6191cb0ef41Sopenharmony_ci case IrOpcode::kWord32AtomicCompareExchange: 6201cb0ef41Sopenharmony_ci case IrOpcode::kWord64AtomicCompareExchange: 6211cb0ef41Sopenharmony_ci CheckValueInputIsTaggedOrPointer(node, 0); 6221cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 6231cb0ef41Sopenharmony_ci node, 1, MachineType::PointerRepresentation()); 6241cb0ef41Sopenharmony_ci switch (inferrer_->GetRepresentation(node)) { 6251cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 6261cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 6271cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedSigned: 6281cb0ef41Sopenharmony_ci CheckValueInputIsTagged(node, 2); 6291cb0ef41Sopenharmony_ci CheckValueInputIsTagged(node, 3); 6301cb0ef41Sopenharmony_ci break; 6311cb0ef41Sopenharmony_ci default: 6321cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 6331cb0ef41Sopenharmony_ci node, 2, inferrer_->GetRepresentation(node)); 6341cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 6351cb0ef41Sopenharmony_ci node, 3, inferrer_->GetRepresentation(node)); 6361cb0ef41Sopenharmony_ci } 6371cb0ef41Sopenharmony_ci break; 6381cb0ef41Sopenharmony_ci case IrOpcode::kPhi: 6391cb0ef41Sopenharmony_ci switch (inferrer_->GetRepresentation(node)) { 6401cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 6411cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 6421cb0ef41Sopenharmony_ci for (int j = 0; j < node->op()->ValueInputCount(); ++j) { 6431cb0ef41Sopenharmony_ci CheckValueInputIsTagged(node, j); 6441cb0ef41Sopenharmony_ci } 6451cb0ef41Sopenharmony_ci break; 6461cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedSigned: 6471cb0ef41Sopenharmony_ci for (int j = 0; j < node->op()->ValueInputCount(); ++j) { 6481cb0ef41Sopenharmony_ci if (COMPRESS_POINTERS_BOOL) { 6491cb0ef41Sopenharmony_ci CheckValueInputIsCompressedOrTagged(node, j); 6501cb0ef41Sopenharmony_ci } else { 6511cb0ef41Sopenharmony_ci CheckValueInputIsTagged(node, j); 6521cb0ef41Sopenharmony_ci } 6531cb0ef41Sopenharmony_ci } 6541cb0ef41Sopenharmony_ci break; 6551cb0ef41Sopenharmony_ci case MachineRepresentation::kCompressed: 6561cb0ef41Sopenharmony_ci case MachineRepresentation::kCompressedPointer: 6571cb0ef41Sopenharmony_ci for (int j = 0; j < node->op()->ValueInputCount(); ++j) { 6581cb0ef41Sopenharmony_ci CheckValueInputIsCompressedOrTagged(node, j); 6591cb0ef41Sopenharmony_ci } 6601cb0ef41Sopenharmony_ci break; 6611cb0ef41Sopenharmony_ci case MachineRepresentation::kWord32: 6621cb0ef41Sopenharmony_ci for (int j = 0; j < node->op()->ValueInputCount(); ++j) { 6631cb0ef41Sopenharmony_ci CheckValueInputForInt32Op(node, j); 6641cb0ef41Sopenharmony_ci } 6651cb0ef41Sopenharmony_ci break; 6661cb0ef41Sopenharmony_ci default: 6671cb0ef41Sopenharmony_ci for (int j = 0; j < node->op()->ValueInputCount(); ++j) { 6681cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 6691cb0ef41Sopenharmony_ci node, j, inferrer_->GetRepresentation(node)); 6701cb0ef41Sopenharmony_ci } 6711cb0ef41Sopenharmony_ci break; 6721cb0ef41Sopenharmony_ci } 6731cb0ef41Sopenharmony_ci break; 6741cb0ef41Sopenharmony_ci case IrOpcode::kBranch: 6751cb0ef41Sopenharmony_ci case IrOpcode::kSwitch: 6761cb0ef41Sopenharmony_ci CheckValueInputForInt32Op(node, 0); 6771cb0ef41Sopenharmony_ci break; 6781cb0ef41Sopenharmony_ci case IrOpcode::kReturn: { 6791cb0ef41Sopenharmony_ci // TODO(ishell): enable once the pop count parameter type becomes 6801cb0ef41Sopenharmony_ci // MachineType::PointerRepresentation(). Currently it's int32 or 6811cb0ef41Sopenharmony_ci // word-size. 6821cb0ef41Sopenharmony_ci // CheckValueInputRepresentationIs( 6831cb0ef41Sopenharmony_ci // node, 0, MachineType::PointerRepresentation()); // Pop count 6841cb0ef41Sopenharmony_ci size_t return_count = inferrer_->call_descriptor()->ReturnCount(); 6851cb0ef41Sopenharmony_ci for (size_t j = 0; j < return_count; j++) { 6861cb0ef41Sopenharmony_ci MachineType type = inferrer_->call_descriptor()->GetReturnType(j); 6871cb0ef41Sopenharmony_ci int input_index = static_cast<int>(j + 1); 6881cb0ef41Sopenharmony_ci switch (type.representation()) { 6891cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 6901cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 6911cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedSigned: 6921cb0ef41Sopenharmony_ci CheckValueInputIsTagged(node, input_index); 6931cb0ef41Sopenharmony_ci break; 6941cb0ef41Sopenharmony_ci case MachineRepresentation::kWord32: 6951cb0ef41Sopenharmony_ci CheckValueInputForInt32Op(node, input_index); 6961cb0ef41Sopenharmony_ci break; 6971cb0ef41Sopenharmony_ci default: 6981cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs(node, input_index, 6991cb0ef41Sopenharmony_ci type.representation()); 7001cb0ef41Sopenharmony_ci break; 7011cb0ef41Sopenharmony_ci } 7021cb0ef41Sopenharmony_ci } 7031cb0ef41Sopenharmony_ci break; 7041cb0ef41Sopenharmony_ci } 7051cb0ef41Sopenharmony_ci case IrOpcode::kStackPointerGreaterThan: 7061cb0ef41Sopenharmony_ci CheckValueInputRepresentationIs( 7071cb0ef41Sopenharmony_ci node, 0, MachineType::PointerRepresentation()); 7081cb0ef41Sopenharmony_ci break; 7091cb0ef41Sopenharmony_ci case IrOpcode::kThrow: 7101cb0ef41Sopenharmony_ci case IrOpcode::kTypedStateValues: 7111cb0ef41Sopenharmony_ci case IrOpcode::kFrameState: 7121cb0ef41Sopenharmony_ci case IrOpcode::kStaticAssert: 7131cb0ef41Sopenharmony_ci break; 7141cb0ef41Sopenharmony_ci default: 7151cb0ef41Sopenharmony_ci if (node->op()->ValueInputCount() != 0) { 7161cb0ef41Sopenharmony_ci std::stringstream str; 7171cb0ef41Sopenharmony_ci str << "Node #" << node->id() << ":" << *node->op() 7181cb0ef41Sopenharmony_ci << " in the machine graph is not being checked."; 7191cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 7201cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 7211cb0ef41Sopenharmony_ci } 7221cb0ef41Sopenharmony_ci break; 7231cb0ef41Sopenharmony_ci } 7241cb0ef41Sopenharmony_ci } 7251cb0ef41Sopenharmony_ci } 7261cb0ef41Sopenharmony_ci } 7271cb0ef41Sopenharmony_ci 7281cb0ef41Sopenharmony_ci private: 7291cb0ef41Sopenharmony_ci static bool Is32() { 7301cb0ef41Sopenharmony_ci return MachineType::PointerRepresentation() == 7311cb0ef41Sopenharmony_ci MachineRepresentation::kWord32; 7321cb0ef41Sopenharmony_ci } 7331cb0ef41Sopenharmony_ci static bool Is64() { 7341cb0ef41Sopenharmony_ci return MachineType::PointerRepresentation() == 7351cb0ef41Sopenharmony_ci MachineRepresentation::kWord64; 7361cb0ef41Sopenharmony_ci } 7371cb0ef41Sopenharmony_ci 7381cb0ef41Sopenharmony_ci void CheckValueInputRepresentationIs(Node const* node, int index, 7391cb0ef41Sopenharmony_ci MachineRepresentation representation) { 7401cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 7411cb0ef41Sopenharmony_ci MachineRepresentation input_representation = 7421cb0ef41Sopenharmony_ci inferrer_->GetRepresentation(input); 7431cb0ef41Sopenharmony_ci if (input_representation != representation) { 7441cb0ef41Sopenharmony_ci std::stringstream str; 7451cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 7461cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() << ":" 7471cb0ef41Sopenharmony_ci << input_representation << " which doesn't have a " << representation 7481cb0ef41Sopenharmony_ci << " representation."; 7491cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 7501cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 7511cb0ef41Sopenharmony_ci } 7521cb0ef41Sopenharmony_ci } 7531cb0ef41Sopenharmony_ci 7541cb0ef41Sopenharmony_ci void CheckValueInputIsTagged(Node const* node, int index) { 7551cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 7561cb0ef41Sopenharmony_ci switch (inferrer_->GetRepresentation(input)) { 7571cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 7581cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 7591cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedSigned: 7601cb0ef41Sopenharmony_ci return; 7611cb0ef41Sopenharmony_ci default: 7621cb0ef41Sopenharmony_ci break; 7631cb0ef41Sopenharmony_ci } 7641cb0ef41Sopenharmony_ci std::ostringstream str; 7651cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 7661cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() 7671cb0ef41Sopenharmony_ci << " which doesn't have a tagged representation."; 7681cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 7691cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 7701cb0ef41Sopenharmony_ci } 7711cb0ef41Sopenharmony_ci 7721cb0ef41Sopenharmony_ci void CheckValueInputIsCompressedOrTagged(Node const* node, int index) { 7731cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 7741cb0ef41Sopenharmony_ci switch (inferrer_->GetRepresentation(input)) { 7751cb0ef41Sopenharmony_ci case MachineRepresentation::kCompressed: 7761cb0ef41Sopenharmony_ci case MachineRepresentation::kCompressedPointer: 7771cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 7781cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 7791cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedSigned: 7801cb0ef41Sopenharmony_ci return; 7811cb0ef41Sopenharmony_ci default: 7821cb0ef41Sopenharmony_ci break; 7831cb0ef41Sopenharmony_ci } 7841cb0ef41Sopenharmony_ci std::ostringstream str; 7851cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 7861cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() 7871cb0ef41Sopenharmony_ci << " which doesn't have a compressed or tagged representation."; 7881cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 7891cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 7901cb0ef41Sopenharmony_ci } 7911cb0ef41Sopenharmony_ci 7921cb0ef41Sopenharmony_ci void CheckValueInputIsCompressedOrTaggedOrInt32(Node const* node, int index) { 7931cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 7941cb0ef41Sopenharmony_ci switch (inferrer_->GetRepresentation(input)) { 7951cb0ef41Sopenharmony_ci case MachineRepresentation::kCompressed: 7961cb0ef41Sopenharmony_ci case MachineRepresentation::kCompressedPointer: 7971cb0ef41Sopenharmony_ci return; 7981cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 7991cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 8001cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedSigned: 8011cb0ef41Sopenharmony_ci return; 8021cb0ef41Sopenharmony_ci case MachineRepresentation::kBit: 8031cb0ef41Sopenharmony_ci case MachineRepresentation::kWord8: 8041cb0ef41Sopenharmony_ci case MachineRepresentation::kWord16: 8051cb0ef41Sopenharmony_ci case MachineRepresentation::kWord32: 8061cb0ef41Sopenharmony_ci return; 8071cb0ef41Sopenharmony_ci default: 8081cb0ef41Sopenharmony_ci break; 8091cb0ef41Sopenharmony_ci } 8101cb0ef41Sopenharmony_ci std::ostringstream str; 8111cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 8121cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() 8131cb0ef41Sopenharmony_ci << " which doesn't have a compressed, tagged, or int32 representation."; 8141cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 8151cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 8161cb0ef41Sopenharmony_ci } 8171cb0ef41Sopenharmony_ci 8181cb0ef41Sopenharmony_ci void CheckValueInputIsTaggedOrPointer(Node const* node, int index) { 8191cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 8201cb0ef41Sopenharmony_ci switch (inferrer_->GetRepresentation(input)) { 8211cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 8221cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 8231cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedSigned: 8241cb0ef41Sopenharmony_ci return; 8251cb0ef41Sopenharmony_ci case MachineRepresentation::kBit: 8261cb0ef41Sopenharmony_ci case MachineRepresentation::kWord8: 8271cb0ef41Sopenharmony_ci case MachineRepresentation::kWord16: 8281cb0ef41Sopenharmony_ci case MachineRepresentation::kWord32: 8291cb0ef41Sopenharmony_ci if (Is32()) { 8301cb0ef41Sopenharmony_ci return; 8311cb0ef41Sopenharmony_ci } 8321cb0ef41Sopenharmony_ci break; 8331cb0ef41Sopenharmony_ci case MachineRepresentation::kWord64: 8341cb0ef41Sopenharmony_ci if (Is64()) { 8351cb0ef41Sopenharmony_ci return; 8361cb0ef41Sopenharmony_ci } 8371cb0ef41Sopenharmony_ci break; 8381cb0ef41Sopenharmony_ci default: 8391cb0ef41Sopenharmony_ci break; 8401cb0ef41Sopenharmony_ci } 8411cb0ef41Sopenharmony_ci if (inferrer_->GetRepresentation(input) != 8421cb0ef41Sopenharmony_ci MachineType::PointerRepresentation()) { 8431cb0ef41Sopenharmony_ci std::ostringstream str; 8441cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 8451cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() 8461cb0ef41Sopenharmony_ci << " which doesn't have a tagged or pointer representation."; 8471cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 8481cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 8491cb0ef41Sopenharmony_ci } 8501cb0ef41Sopenharmony_ci } 8511cb0ef41Sopenharmony_ci 8521cb0ef41Sopenharmony_ci void CheckValueInputForInt32Op(Node const* node, int index) { 8531cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 8541cb0ef41Sopenharmony_ci switch (inferrer_->GetRepresentation(input)) { 8551cb0ef41Sopenharmony_ci case MachineRepresentation::kBit: 8561cb0ef41Sopenharmony_ci case MachineRepresentation::kWord8: 8571cb0ef41Sopenharmony_ci case MachineRepresentation::kWord16: 8581cb0ef41Sopenharmony_ci case MachineRepresentation::kWord32: 8591cb0ef41Sopenharmony_ci return; 8601cb0ef41Sopenharmony_ci case MachineRepresentation::kNone: { 8611cb0ef41Sopenharmony_ci std::ostringstream str; 8621cb0ef41Sopenharmony_ci str << "TypeError: node #" << input->id() << ":" << *input->op() 8631cb0ef41Sopenharmony_ci << " is untyped."; 8641cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 8651cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 8661cb0ef41Sopenharmony_ci } 8671cb0ef41Sopenharmony_ci default: 8681cb0ef41Sopenharmony_ci break; 8691cb0ef41Sopenharmony_ci } 8701cb0ef41Sopenharmony_ci std::ostringstream str; 8711cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 8721cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() 8731cb0ef41Sopenharmony_ci << " which doesn't have an int32-compatible representation."; 8741cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 8751cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 8761cb0ef41Sopenharmony_ci } 8771cb0ef41Sopenharmony_ci 8781cb0ef41Sopenharmony_ci void CheckValueIsTaggedOrInt32(Node const* node, int index) { 8791cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 8801cb0ef41Sopenharmony_ci switch (inferrer_->GetRepresentation(input)) { 8811cb0ef41Sopenharmony_ci case MachineRepresentation::kBit: 8821cb0ef41Sopenharmony_ci case MachineRepresentation::kWord8: 8831cb0ef41Sopenharmony_ci case MachineRepresentation::kWord16: 8841cb0ef41Sopenharmony_ci case MachineRepresentation::kWord32: 8851cb0ef41Sopenharmony_ci return; 8861cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 8871cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 8881cb0ef41Sopenharmony_ci return; 8891cb0ef41Sopenharmony_ci default: 8901cb0ef41Sopenharmony_ci break; 8911cb0ef41Sopenharmony_ci } 8921cb0ef41Sopenharmony_ci std::ostringstream str; 8931cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 8941cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() 8951cb0ef41Sopenharmony_ci << " which doesn't have a tagged or int32-compatible " 8961cb0ef41Sopenharmony_ci "representation."; 8971cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 8981cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 8991cb0ef41Sopenharmony_ci } 9001cb0ef41Sopenharmony_ci 9011cb0ef41Sopenharmony_ci void CheckValueInputForInt64Op(Node const* node, int index) { 9021cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 9031cb0ef41Sopenharmony_ci MachineRepresentation input_representation = 9041cb0ef41Sopenharmony_ci inferrer_->GetRepresentation(input); 9051cb0ef41Sopenharmony_ci switch (input_representation) { 9061cb0ef41Sopenharmony_ci case MachineRepresentation::kWord64: 9071cb0ef41Sopenharmony_ci return; 9081cb0ef41Sopenharmony_ci case MachineRepresentation::kNone: { 9091cb0ef41Sopenharmony_ci std::ostringstream str; 9101cb0ef41Sopenharmony_ci str << "TypeError: node #" << input->id() << ":" << *input->op() 9111cb0ef41Sopenharmony_ci << " is untyped."; 9121cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 9131cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 9141cb0ef41Sopenharmony_ci } 9151cb0ef41Sopenharmony_ci 9161cb0ef41Sopenharmony_ci default: 9171cb0ef41Sopenharmony_ci break; 9181cb0ef41Sopenharmony_ci } 9191cb0ef41Sopenharmony_ci std::ostringstream str; 9201cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 9211cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() << ":" 9221cb0ef41Sopenharmony_ci << input_representation 9231cb0ef41Sopenharmony_ci << " which doesn't have a kWord64 representation."; 9241cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 9251cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 9261cb0ef41Sopenharmony_ci } 9271cb0ef41Sopenharmony_ci 9281cb0ef41Sopenharmony_ci void CheckValueInputForFloat32Op(Node const* node, int index) { 9291cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 9301cb0ef41Sopenharmony_ci if (MachineRepresentation::kFloat32 == 9311cb0ef41Sopenharmony_ci inferrer_->GetRepresentation(input)) { 9321cb0ef41Sopenharmony_ci return; 9331cb0ef41Sopenharmony_ci } 9341cb0ef41Sopenharmony_ci std::ostringstream str; 9351cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 9361cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() 9371cb0ef41Sopenharmony_ci << " which doesn't have a kFloat32 representation."; 9381cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 9391cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 9401cb0ef41Sopenharmony_ci } 9411cb0ef41Sopenharmony_ci 9421cb0ef41Sopenharmony_ci void CheckValueInputForFloat64Op(Node const* node, int index) { 9431cb0ef41Sopenharmony_ci Node const* input = node->InputAt(index); 9441cb0ef41Sopenharmony_ci if (MachineRepresentation::kFloat64 == 9451cb0ef41Sopenharmony_ci inferrer_->GetRepresentation(input)) { 9461cb0ef41Sopenharmony_ci return; 9471cb0ef41Sopenharmony_ci } 9481cb0ef41Sopenharmony_ci std::ostringstream str; 9491cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 9501cb0ef41Sopenharmony_ci << " uses node #" << input->id() << ":" << *input->op() 9511cb0ef41Sopenharmony_ci << " which doesn't have a kFloat64 representation."; 9521cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 9531cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 9541cb0ef41Sopenharmony_ci } 9551cb0ef41Sopenharmony_ci 9561cb0ef41Sopenharmony_ci void CheckCallInputs(Node const* node) { 9571cb0ef41Sopenharmony_ci auto call_descriptor = CallDescriptorOf(node->op()); 9581cb0ef41Sopenharmony_ci std::ostringstream str; 9591cb0ef41Sopenharmony_ci bool should_log_error = false; 9601cb0ef41Sopenharmony_ci for (size_t i = 0; i < call_descriptor->InputCount(); ++i) { 9611cb0ef41Sopenharmony_ci Node const* input = node->InputAt(static_cast<int>(i)); 9621cb0ef41Sopenharmony_ci MachineRepresentation const input_type = 9631cb0ef41Sopenharmony_ci inferrer_->GetRepresentation(input); 9641cb0ef41Sopenharmony_ci MachineRepresentation const expected_input_type = 9651cb0ef41Sopenharmony_ci call_descriptor->GetInputType(i).representation(); 9661cb0ef41Sopenharmony_ci if (!IsCompatible(expected_input_type, input_type)) { 9671cb0ef41Sopenharmony_ci if (!should_log_error) { 9681cb0ef41Sopenharmony_ci should_log_error = true; 9691cb0ef41Sopenharmony_ci str << "TypeError: node #" << node->id() << ":" << *node->op() 9701cb0ef41Sopenharmony_ci << " has wrong type for:" << std::endl; 9711cb0ef41Sopenharmony_ci } else { 9721cb0ef41Sopenharmony_ci str << std::endl; 9731cb0ef41Sopenharmony_ci } 9741cb0ef41Sopenharmony_ci str << " * input " << i << " (" << input->id() << ":" << *input->op() 9751cb0ef41Sopenharmony_ci << ") has a " << input_type 9761cb0ef41Sopenharmony_ci << " representation (expected: " << expected_input_type << ")."; 9771cb0ef41Sopenharmony_ci } 9781cb0ef41Sopenharmony_ci } 9791cb0ef41Sopenharmony_ci if (should_log_error) { 9801cb0ef41Sopenharmony_ci PrintDebugHelp(str, node); 9811cb0ef41Sopenharmony_ci FATAL("%s", str.str().c_str()); 9821cb0ef41Sopenharmony_ci } 9831cb0ef41Sopenharmony_ci } 9841cb0ef41Sopenharmony_ci 9851cb0ef41Sopenharmony_ci bool IsCompatible(MachineRepresentation expected, 9861cb0ef41Sopenharmony_ci MachineRepresentation actual) { 9871cb0ef41Sopenharmony_ci switch (expected) { 9881cb0ef41Sopenharmony_ci case MachineRepresentation::kTagged: 9891cb0ef41Sopenharmony_ci return IsAnyTagged(actual); 9901cb0ef41Sopenharmony_ci case MachineRepresentation::kCompressed: 9911cb0ef41Sopenharmony_ci return IsAnyCompressed(actual); 9921cb0ef41Sopenharmony_ci case MachineRepresentation::kMapWord: 9931cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedSigned: 9941cb0ef41Sopenharmony_ci case MachineRepresentation::kTaggedPointer: 9951cb0ef41Sopenharmony_ci // TODO(turbofan): At the moment, the machine graph doesn't contain 9961cb0ef41Sopenharmony_ci // reliable information if a node is kTaggedSigned, kTaggedPointer or 9971cb0ef41Sopenharmony_ci // kTagged, and often this is context-dependent. We should at least 9981cb0ef41Sopenharmony_ci // check for obvious violations: kTaggedSigned where we expect 9991cb0ef41Sopenharmony_ci // kTaggedPointer and the other way around, but at the moment, this 10001cb0ef41Sopenharmony_ci // happens in dead code. 10011cb0ef41Sopenharmony_ci return IsAnyTagged(actual); 10021cb0ef41Sopenharmony_ci case MachineRepresentation::kCompressedPointer: 10031cb0ef41Sopenharmony_ci case MachineRepresentation::kSandboxedPointer: 10041cb0ef41Sopenharmony_ci case MachineRepresentation::kFloat32: 10051cb0ef41Sopenharmony_ci case MachineRepresentation::kFloat64: 10061cb0ef41Sopenharmony_ci case MachineRepresentation::kSimd128: 10071cb0ef41Sopenharmony_ci case MachineRepresentation::kBit: 10081cb0ef41Sopenharmony_ci case MachineRepresentation::kWord8: 10091cb0ef41Sopenharmony_ci case MachineRepresentation::kWord16: 10101cb0ef41Sopenharmony_ci case MachineRepresentation::kWord64: 10111cb0ef41Sopenharmony_ci return expected == actual; 10121cb0ef41Sopenharmony_ci case MachineRepresentation::kWord32: 10131cb0ef41Sopenharmony_ci return (actual == MachineRepresentation::kBit || 10141cb0ef41Sopenharmony_ci actual == MachineRepresentation::kWord8 || 10151cb0ef41Sopenharmony_ci actual == MachineRepresentation::kWord16 || 10161cb0ef41Sopenharmony_ci actual == MachineRepresentation::kWord32); 10171cb0ef41Sopenharmony_ci case MachineRepresentation::kNone: 10181cb0ef41Sopenharmony_ci UNREACHABLE(); 10191cb0ef41Sopenharmony_ci } 10201cb0ef41Sopenharmony_ci return false; 10211cb0ef41Sopenharmony_ci } 10221cb0ef41Sopenharmony_ci 10231cb0ef41Sopenharmony_ci void PrintDebugHelp(std::ostream& out, Node const* node) { 10241cb0ef41Sopenharmony_ci if (DEBUG_BOOL) { 10251cb0ef41Sopenharmony_ci out << "\n# Current block: " << *current_block_; 10261cb0ef41Sopenharmony_ci out << "\n#\n# Specify option --csa-trap-on-node=" << name_ << "," 10271cb0ef41Sopenharmony_ci << node->id() << " for debugging."; 10281cb0ef41Sopenharmony_ci } 10291cb0ef41Sopenharmony_ci } 10301cb0ef41Sopenharmony_ci 10311cb0ef41Sopenharmony_ci Schedule const* const schedule_; 10321cb0ef41Sopenharmony_ci MachineRepresentationInferrer const* const inferrer_; 10331cb0ef41Sopenharmony_ci bool is_stub_; 10341cb0ef41Sopenharmony_ci const char* name_; 10351cb0ef41Sopenharmony_ci BasicBlock* current_block_; 10361cb0ef41Sopenharmony_ci}; 10371cb0ef41Sopenharmony_ci 10381cb0ef41Sopenharmony_ci} // namespace 10391cb0ef41Sopenharmony_ci 10401cb0ef41Sopenharmony_civoid MachineGraphVerifier::Run(Graph* graph, Schedule const* const schedule, 10411cb0ef41Sopenharmony_ci Linkage* linkage, bool is_stub, const char* name, 10421cb0ef41Sopenharmony_ci Zone* temp_zone) { 10431cb0ef41Sopenharmony_ci MachineRepresentationInferrer representation_inferrer(schedule, graph, 10441cb0ef41Sopenharmony_ci linkage, temp_zone); 10451cb0ef41Sopenharmony_ci MachineRepresentationChecker checker(schedule, &representation_inferrer, 10461cb0ef41Sopenharmony_ci is_stub, name); 10471cb0ef41Sopenharmony_ci checker.Run(); 10481cb0ef41Sopenharmony_ci} 10491cb0ef41Sopenharmony_ci 10501cb0ef41Sopenharmony_ci} // namespace compiler 10511cb0ef41Sopenharmony_ci} // namespace internal 10521cb0ef41Sopenharmony_ci} // namespace v8 1053