From bb2a830debbff19cf5a510c920ff9ac88d41355c Mon Sep 17 00:00:00 2001 From: jarin Date: Thu, 10 Dec 2015 01:03:30 -0800 Subject: [PATCH] [turbofan] Make MachineType a pair of enums. MachineType is now a class with two enum fields: - MachineRepresentation - MachineSemantic Both enums are usable on their own, and this change switches some places from using MachineType to use just MachineRepresentation. Most notably: - register allocator now uses just the representation. - Phi and Select nodes only refer to representations. Review URL: https://codereview.chromium.org/1513543003 Cr-Commit-Position: refs/heads/master@{#32738} --- src/compiler/access-builder.cc | 111 +-- src/compiler/arm/instruction-selector-arm.cc | 73 +- .../arm64/instruction-selector-arm64.cc | 81 +- src/compiler/ast-graph-builder.cc | 17 +- src/compiler/basic-block-instrumentor.cc | 9 +- src/compiler/bytecode-graph-builder.cc | 7 +- src/compiler/c-linkage.cc | 2 +- src/compiler/change-lowering.cc | 57 +- src/compiler/code-generator.cc | 44 +- src/compiler/code-stub-assembler.cc | 2 +- src/compiler/common-operator.cc | 69 +- src/compiler/common-operator.h | 15 +- src/compiler/diamond.h | 4 +- src/compiler/escape-analysis.cc | 15 +- .../ia32/instruction-selector-ia32.cc | 85 ++- src/compiler/instruction-selector-impl.h | 33 +- src/compiler/instruction-selector.cc | 50 +- src/compiler/instruction-selector.h | 25 +- src/compiler/instruction.cc | 54 +- src/compiler/instruction.h | 80 +- src/compiler/interpreter-assembler.cc | 49 +- src/compiler/js-builtin-reducer.cc | 2 +- src/compiler/js-generic-lowering.cc | 67 +- src/compiler/js-inlining.cc | 5 +- src/compiler/js-intrinsic-lowering.cc | 16 +- .../js-native-context-specialization.cc | 33 +- src/compiler/js-typed-lowering.cc | 75 +- src/compiler/linkage.cc | 64 +- src/compiler/linkage.h | 2 +- src/compiler/live-range-separator.cc | 3 +- src/compiler/loop-peeling.cc | 5 +- src/compiler/machine-operator-reducer.cc | 36 +- src/compiler/machine-operator.cc | 91 ++- src/compiler/machine-operator.h | 15 +- .../mips/instruction-selector-mips.cc | 73 +- .../mips64/instruction-selector-mips64.cc | 81 +- src/compiler/pipeline.cc | 2 +- src/compiler/raw-machine-assembler.cc | 2 +- src/compiler/raw-machine-assembler.h | 22 +- src/compiler/register-allocator-verifier.cc | 4 +- src/compiler/register-allocator.cc | 94 ++- src/compiler/register-allocator.h | 16 +- src/compiler/representation-change.cc | 185 ++--- src/compiler/representation-change.h | 28 +- src/compiler/select-lowering.cc | 2 +- src/compiler/simplified-lowering.cc | 447 ++++++----- src/compiler/simplified-operator.cc | 18 +- src/compiler/state-values-utils.cc | 2 +- src/compiler/x64/instruction-selector-x64.cc | 81 +- src/machine-type.cc | 83 +- src/machine-type.h | 244 ++++-- test/cctest/compiler/c-signature.h | 61 +- test/cctest/compiler/codegen-tester.cc | 49 +- test/cctest/compiler/codegen-tester.h | 149 ++-- test/cctest/compiler/graph-builder-tester.h | 12 +- .../compiler/test-basic-block-profiler.cc | 5 +- test/cctest/compiler/test-branch-combine.cc | 28 +- test/cctest/compiler/test-changes-lowering.cc | 28 +- test/cctest/compiler/test-gap-resolver.cc | 37 +- test/cctest/compiler/test-graph-visualizer.cc | 9 +- test/cctest/compiler/test-jump-threading.cc | 10 +- test/cctest/compiler/test-loop-analysis.cc | 36 +- .../compiler/test-machine-operator-reducer.cc | 12 +- test/cctest/compiler/test-multiple-return.cc | 8 +- test/cctest/compiler/test-osr.cc | 17 +- .../compiler/test-representation-change.cc | 314 ++++---- test/cctest/compiler/test-run-machops.cc | 716 ++++++++++-------- test/cctest/compiler/test-run-native-calls.cc | 80 +- .../compiler/test-simplified-lowering.cc | 276 +++---- .../arm/instruction-selector-arm-unittest.cc | 408 ++++++---- .../instruction-selector-arm64-unittest.cc | 547 +++++++------ .../compiler/branch-elimination-unittest.cc | 39 +- .../compiler/change-lowering-unittest.cc | 153 ++-- .../common-operator-reducer-unittest.cc | 102 +-- .../compiler/common-operator-unittest.cc | 17 +- .../control-flow-optimizer-unittest.cc | 4 +- .../dead-code-elimination-unittest.cc | 36 +- test/unittests/compiler/diamond-unittest.cc | 3 +- .../compiler/escape-analysis-unittest.cc | 2 +- .../instruction-selector-ia32-unittest.cc | 98 +-- .../compiler/instruction-selector-unittest.cc | 107 +-- .../compiler/instruction-selector-unittest.h | 18 +- .../interpreter-assembler-unittest.cc | 108 +-- .../compiler/js-builtin-reducer-unittest.cc | 6 +- .../js-context-relaxation-unittest.cc | 3 +- .../js-intrinsic-lowering-unittest.cc | 22 +- .../compiler/js-typed-lowering-unittest.cc | 10 +- .../compiler/linkage-tail-call-unittest.cc | 30 +- test/unittests/compiler/live-range-builder.h | 2 +- .../unittests/compiler/live-range-unittest.cc | 8 +- .../compiler/liveness-analyzer-unittest.cc | 2 +- .../compiler/loop-peeling-unittest.cc | 50 +- .../machine-operator-reducer-unittest.cc | 32 +- .../compiler/machine-operator-unittest.cc | 62 +- .../instruction-selector-mips-unittest.cc | 254 ++++--- .../instruction-selector-mips64-unittest.cc | 312 ++++---- .../compiler/move-optimizer-unittest.cc | 12 +- test/unittests/compiler/node-test-utils.cc | 51 +- test/unittests/compiler/node-test-utils.h | 6 +- test/unittests/compiler/scheduler-unittest.cc | 76 +- .../compiler/select-lowering-unittest.cc | 20 +- .../compiler/simplified-operator-unittest.cc | 49 +- .../tail-call-optimization-unittest.cc | 30 +- .../x64/instruction-selector-x64-unittest.cc | 204 +++-- 104 files changed, 4140 insertions(+), 3270 deletions(-) diff --git a/src/compiler/access-builder.cc b/src/compiler/access-builder.cc index a20ef70550..3b4ef5b471 100644 --- a/src/compiler/access-builder.cc +++ b/src/compiler/access-builder.cc @@ -17,7 +17,8 @@ namespace compiler { // static FieldAccess AccessBuilder::ForMap() { FieldAccess access = {kTaggedBase, HeapObject::kMapOffset, - MaybeHandle(), Type::Any(), kMachAnyTagged}; + MaybeHandle(), Type::Any(), + MachineType::AnyTagged()}; return access; } @@ -26,7 +27,7 @@ FieldAccess AccessBuilder::ForMap() { FieldAccess AccessBuilder::ForHeapNumberValue() { FieldAccess access = {kTaggedBase, HeapNumber::kValueOffset, MaybeHandle(), TypeCache().Get().kFloat64, - kMachFloat64}; + MachineType::Float64()}; return access; } @@ -34,7 +35,8 @@ FieldAccess AccessBuilder::ForHeapNumberValue() { // static FieldAccess AccessBuilder::ForJSObjectProperties() { FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset, - MaybeHandle(), Type::Internal(), kMachAnyTagged}; + MaybeHandle(), Type::Internal(), + MachineType::AnyTagged()}; return access; } @@ -42,7 +44,8 @@ FieldAccess AccessBuilder::ForJSObjectProperties() { // static FieldAccess AccessBuilder::ForJSObjectElements() { FieldAccess access = {kTaggedBase, JSObject::kElementsOffset, - MaybeHandle(), Type::Internal(), kMachAnyTagged}; + MaybeHandle(), Type::Internal(), + MachineType::AnyTagged()}; return access; } @@ -52,7 +55,7 @@ FieldAccess AccessBuilder::ForJSObjectInObjectProperty(Handle map, int index) { int const offset = map->GetInObjectPropertyOffset(index); FieldAccess access = {kTaggedBase, offset, MaybeHandle(), - Type::Tagged(), kMachAnyTagged}; + Type::Tagged(), MachineType::AnyTagged()}; return access; } @@ -60,7 +63,8 @@ FieldAccess AccessBuilder::ForJSObjectInObjectProperty(Handle map, // static FieldAccess AccessBuilder::ForJSFunctionContext() { FieldAccess access = {kTaggedBase, JSFunction::kContextOffset, - MaybeHandle(), Type::Internal(), kMachAnyTagged}; + MaybeHandle(), Type::Internal(), + MachineType::AnyTagged()}; return access; } @@ -68,7 +72,7 @@ FieldAccess AccessBuilder::ForJSFunctionContext() { // static FieldAccess AccessBuilder::ForJSFunctionSharedFunctionInfo() { FieldAccess access = {kTaggedBase, JSFunction::kSharedFunctionInfoOffset, - Handle(), Type::Any(), kMachAnyTagged}; + Handle(), Type::Any(), MachineType::AnyTagged()}; return access; } @@ -77,7 +81,8 @@ FieldAccess AccessBuilder::ForJSFunctionSharedFunctionInfo() { FieldAccess AccessBuilder::ForJSArrayLength(ElementsKind elements_kind) { TypeCache const& type_cache = TypeCache::Get(); FieldAccess access = {kTaggedBase, JSArray::kLengthOffset, Handle(), - type_cache.kJSArrayLengthType, kMachAnyTagged}; + type_cache.kJSArrayLengthType, + MachineType::AnyTagged()}; if (IsFastDoubleElementsKind(elements_kind)) { access.type = type_cache.kFixedDoubleArrayLengthType; } else if (IsFastElementsKind(elements_kind)) { @@ -90,7 +95,8 @@ FieldAccess AccessBuilder::ForJSArrayLength(ElementsKind elements_kind) { // static FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() { FieldAccess access = {kTaggedBase, JSArrayBuffer::kBackingStoreOffset, - MaybeHandle(), Type::UntaggedPointer(), kMachPtr}; + MaybeHandle(), Type::UntaggedPointer(), + MachineType::Pointer()}; return access; } @@ -98,7 +104,8 @@ FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() { // static FieldAccess AccessBuilder::ForJSArrayBufferBitField() { FieldAccess access = {kTaggedBase, JSArrayBuffer::kBitFieldOffset, - MaybeHandle(), TypeCache::Get().kInt8, kMachInt8}; + MaybeHandle(), TypeCache::Get().kInt8, + MachineType::Int8()}; return access; } @@ -107,25 +114,25 @@ FieldAccess AccessBuilder::ForJSArrayBufferBitField() { FieldAccess AccessBuilder::ForJSArrayBufferViewBuffer() { FieldAccess access = {kTaggedBase, JSArrayBufferView::kBufferOffset, MaybeHandle(), Type::TaggedPointer(), - kMachAnyTagged}; + MachineType::AnyTagged()}; return access; } // static FieldAccess AccessBuilder::ForJSDateField(JSDate::FieldIndex index) { - FieldAccess access = {kTaggedBase, - JSDate::kValueOffset + index * kPointerSize, - MaybeHandle(), Type::Number(), kMachAnyTagged}; + FieldAccess access = { + kTaggedBase, JSDate::kValueOffset + index * kPointerSize, + MaybeHandle(), Type::Number(), MachineType::AnyTagged()}; return access; } // static FieldAccess AccessBuilder::ForFixedArrayLength() { - FieldAccess access = {kTaggedBase, FixedArray::kLengthOffset, - MaybeHandle(), - TypeCache::Get().kFixedArrayLengthType, kMachAnyTagged}; + FieldAccess access = { + kTaggedBase, FixedArray::kLengthOffset, MaybeHandle(), + TypeCache::Get().kFixedArrayLengthType, MachineType::AnyTagged()}; return access; } @@ -133,16 +140,17 @@ FieldAccess AccessBuilder::ForFixedArrayLength() { // static FieldAccess AccessBuilder::ForDescriptorArrayEnumCache() { FieldAccess access = {kTaggedBase, DescriptorArray::kEnumCacheOffset, - Handle(), Type::TaggedPointer(), kMachAnyTagged}; + Handle(), Type::TaggedPointer(), + MachineType::AnyTagged()}; return access; } // static FieldAccess AccessBuilder::ForDescriptorArrayEnumCacheBridgeCache() { - FieldAccess access = {kTaggedBase, - DescriptorArray::kEnumCacheBridgeCacheOffset, - Handle(), Type::TaggedPointer(), kMachAnyTagged}; + FieldAccess access = { + kTaggedBase, DescriptorArray::kEnumCacheBridgeCacheOffset, Handle(), + Type::TaggedPointer(), MachineType::AnyTagged()}; return access; } @@ -150,7 +158,7 @@ FieldAccess AccessBuilder::ForDescriptorArrayEnumCacheBridgeCache() { // static FieldAccess AccessBuilder::ForMapBitField3() { FieldAccess access = {kTaggedBase, Map::kBitField3Offset, Handle(), - TypeCache::Get().kInt32, kMachInt32}; + TypeCache::Get().kInt32, MachineType::Int32()}; return access; } @@ -158,7 +166,7 @@ FieldAccess AccessBuilder::ForMapBitField3() { // static FieldAccess AccessBuilder::ForMapDescriptors() { FieldAccess access = {kTaggedBase, Map::kDescriptorsOffset, Handle(), - Type::TaggedPointer(), kMachAnyTagged}; + Type::TaggedPointer(), MachineType::AnyTagged()}; return access; } @@ -166,7 +174,7 @@ FieldAccess AccessBuilder::ForMapDescriptors() { // static FieldAccess AccessBuilder::ForMapInstanceType() { FieldAccess access = {kTaggedBase, Map::kInstanceTypeOffset, Handle(), - TypeCache::Get().kUint8, kMachUint8}; + TypeCache::Get().kUint8, MachineType::Uint8()}; return access; } @@ -174,7 +182,7 @@ FieldAccess AccessBuilder::ForMapInstanceType() { // static FieldAccess AccessBuilder::ForMapPrototype() { FieldAccess access = {kTaggedBase, Map::kPrototypeOffset, Handle(), - Type::TaggedPointer(), kMachAnyTagged}; + Type::TaggedPointer(), MachineType::AnyTagged()}; return access; } @@ -182,7 +190,8 @@ FieldAccess AccessBuilder::ForMapPrototype() { // static FieldAccess AccessBuilder::ForStringLength() { FieldAccess access = {kTaggedBase, String::kLengthOffset, Handle(), - TypeCache::Get().kStringLengthType, kMachAnyTagged}; + TypeCache::Get().kStringLengthType, + MachineType::AnyTagged()}; return access; } @@ -190,7 +199,8 @@ FieldAccess AccessBuilder::ForStringLength() { // static FieldAccess AccessBuilder::ForJSGlobalObjectGlobalProxy() { FieldAccess access = {kTaggedBase, JSGlobalObject::kGlobalProxyOffset, - Handle(), Type::Receiver(), kMachAnyTagged}; + Handle(), Type::Receiver(), + MachineType::AnyTagged()}; return access; } @@ -198,7 +208,8 @@ FieldAccess AccessBuilder::ForJSGlobalObjectGlobalProxy() { // static FieldAccess AccessBuilder::ForJSGlobalObjectNativeContext() { FieldAccess access = {kTaggedBase, JSGlobalObject::kNativeContextOffset, - Handle(), Type::Internal(), kMachAnyTagged}; + Handle(), Type::Internal(), + MachineType::AnyTagged()}; return access; } @@ -206,7 +217,7 @@ FieldAccess AccessBuilder::ForJSGlobalObjectNativeContext() { // static FieldAccess AccessBuilder::ForValue() { FieldAccess access = {kTaggedBase, JSValue::kValueOffset, Handle(), - Type::Any(), kMachAnyTagged}; + Type::Any(), MachineType::AnyTagged()}; return access; } @@ -216,7 +227,7 @@ FieldAccess AccessBuilder::ForArgumentsLength() { int offset = JSObject::kHeaderSize + Heap::kArgumentsLengthIndex * kPointerSize; FieldAccess access = {kTaggedBase, offset, Handle(), Type::Any(), - kMachAnyTagged}; + MachineType::AnyTagged()}; return access; } @@ -226,7 +237,7 @@ FieldAccess AccessBuilder::ForArgumentsCallee() { int offset = JSObject::kHeaderSize + Heap::kArgumentsCalleeIndex * kPointerSize; FieldAccess access = {kTaggedBase, offset, Handle(), Type::Any(), - kMachAnyTagged}; + MachineType::AnyTagged()}; return access; } @@ -235,7 +246,7 @@ FieldAccess AccessBuilder::ForArgumentsCallee() { FieldAccess AccessBuilder::ForFixedArraySlot(size_t index) { int offset = FixedArray::OffsetOfElementAt(static_cast(index)); FieldAccess access = {kTaggedBase, offset, Handle(), Type::Any(), - kMachAnyTagged}; + MachineType::AnyTagged()}; return access; } @@ -246,7 +257,7 @@ FieldAccess AccessBuilder::ForContextSlot(size_t index) { DCHECK_EQ(offset, Context::SlotOffset(static_cast(index)) + kHeapObjectTag); FieldAccess access = {kTaggedBase, offset, Handle(), Type::Any(), - kMachAnyTagged}; + MachineType::AnyTagged()}; return access; } @@ -260,7 +271,7 @@ FieldAccess AccessBuilder::ForPropertyCellValue() { // static FieldAccess AccessBuilder::ForPropertyCellValue(Type* type) { FieldAccess access = {kTaggedBase, PropertyCell::kValueOffset, Handle(), - type, kMachAnyTagged}; + type, MachineType::AnyTagged()}; return access; } @@ -268,7 +279,7 @@ FieldAccess AccessBuilder::ForPropertyCellValue(Type* type) { // static FieldAccess AccessBuilder::ForSharedFunctionInfoTypeFeedbackVector() { FieldAccess access = {kTaggedBase, SharedFunctionInfo::kFeedbackVectorOffset, - Handle(), Type::Any(), kMachAnyTagged}; + Handle(), Type::Any(), MachineType::AnyTagged()}; return access; } @@ -276,7 +287,7 @@ FieldAccess AccessBuilder::ForSharedFunctionInfoTypeFeedbackVector() { // static ElementAccess AccessBuilder::ForFixedArrayElement() { ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Tagged(), - kMachAnyTagged}; + MachineType::AnyTagged()}; return access; } @@ -284,7 +295,7 @@ ElementAccess AccessBuilder::ForFixedArrayElement() { // static ElementAccess AccessBuilder::ForFixedDoubleArrayElement() { ElementAccess access = {kTaggedBase, FixedDoubleArray::kHeaderSize, - TypeCache::Get().kFloat64, kMachFloat64}; + TypeCache::Get().kFloat64, MachineType::Float64()}; return access; } @@ -297,48 +308,48 @@ ElementAccess AccessBuilder::ForTypedArrayElement(ExternalArrayType type, switch (type) { case kExternalInt8Array: { ElementAccess access = {taggedness, header_size, Type::Signed32(), - kMachInt8}; + MachineType::Int8()}; return access; } case kExternalUint8Array: case kExternalUint8ClampedArray: { ElementAccess access = {taggedness, header_size, Type::Unsigned32(), - kMachUint8}; + MachineType::Uint8()}; return access; } case kExternalInt16Array: { ElementAccess access = {taggedness, header_size, Type::Signed32(), - kMachInt16}; + MachineType::Int16()}; return access; } case kExternalUint16Array: { ElementAccess access = {taggedness, header_size, Type::Unsigned32(), - kMachUint16}; + MachineType::Uint16()}; return access; } case kExternalInt32Array: { ElementAccess access = {taggedness, header_size, Type::Signed32(), - kMachInt32}; + MachineType::Int32()}; return access; } case kExternalUint32Array: { ElementAccess access = {taggedness, header_size, Type::Unsigned32(), - kMachUint32}; + MachineType::Uint32()}; return access; } case kExternalFloat32Array: { ElementAccess access = {taggedness, header_size, Type::Number(), - kMachFloat32}; + MachineType::Float32()}; return access; } case kExternalFloat64Array: { ElementAccess access = {taggedness, header_size, Type::Number(), - kMachFloat64}; + MachineType::Float64()}; return access; } } UNREACHABLE(); - ElementAccess access = {kUntaggedBase, 0, Type::None(), kMachNone}; + ElementAccess access = {kUntaggedBase, 0, Type::None(), MachineType::None()}; return access; } @@ -346,7 +357,7 @@ ElementAccess AccessBuilder::ForTypedArrayElement(ExternalArrayType type, // static FieldAccess AccessBuilder::ForStatsCounter() { FieldAccess access = {kUntaggedBase, 0, MaybeHandle(), - TypeCache::Get().kInt32, kMachInt32}; + TypeCache::Get().kInt32, MachineType::Int32()}; return access; } @@ -354,7 +365,8 @@ FieldAccess AccessBuilder::ForStatsCounter() { // static FieldAccess AccessBuilder::ForFrameCallerFramePtr() { FieldAccess access = {kUntaggedBase, StandardFrameConstants::kCallerFPOffset, - MaybeHandle(), Type::Internal(), kMachPtr}; + MaybeHandle(), Type::Internal(), + MachineType::Pointer()}; return access; } @@ -362,7 +374,8 @@ FieldAccess AccessBuilder::ForFrameCallerFramePtr() { // static FieldAccess AccessBuilder::ForFrameMarker() { FieldAccess access = {kUntaggedBase, StandardFrameConstants::kMarkerOffset, - MaybeHandle(), Type::Tagged(), kMachAnyTagged}; + MaybeHandle(), Type::Tagged(), + MachineType::AnyTagged()}; return access; } diff --git a/src/compiler/arm/instruction-selector-arm.cc b/src/compiler/arm/instruction-selector-arm.cc index 777819a6dc..43acaa027d 100644 --- a/src/compiler/arm/instruction-selector-arm.cc +++ b/src/compiler/arm/instruction-selector-arm.cc @@ -303,29 +303,28 @@ void VisitMod(InstructionSelector* selector, Node* node, ArchOpcode div_opcode, void InstructionSelector::VisitLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ArmOperandGenerator g(this); Node* base = node->InputAt(0); Node* index = node->InputAt(1); ArchOpcode opcode; - switch (rep) { - case kRepFloat32: + switch (load_rep.representation()) { + case MachineRepresentation::kFloat32: opcode = kArmVldrF32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kArmVldrF64; break; - case kRepBit: // Fall through. - case kRepWord8: - opcode = typ == kTypeUint32 ? kArmLdrb : kArmLdrsb; + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: + opcode = load_rep.IsUnsigned() ? kArmLdrb : kArmLdrsb; break; - case kRepWord16: - opcode = typ == kTypeUint32 ? kArmLdrh : kArmLdrsh; + case MachineRepresentation::kWord16: + opcode = load_rep.IsUnsigned() ? kArmLdrh : kArmLdrsh; break; - case kRepTagged: // Fall through. - case kRepWord32: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord32: opcode = kArmLdr; break; default: @@ -351,10 +350,10 @@ void InstructionSelector::VisitStore(Node* node) { StoreRepresentation store_rep = OpParameter(node); WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); - MachineType rep = RepresentationOf(store_rep.machine_type()); + MachineRepresentation rep = store_rep.machine_type().representation(); if (write_barrier_kind != kNoWriteBarrier) { - DCHECK_EQ(kRepTagged, rep); + DCHECK_EQ(MachineRepresentation::kTagged, rep); InstructionOperand inputs[3]; size_t input_count = 0; inputs[input_count++] = g.UseUniqueRegister(base); @@ -385,21 +384,21 @@ void InstructionSelector::VisitStore(Node* node) { } else { ArchOpcode opcode; switch (rep) { - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kArmVstrF32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kArmVstrF64; break; - case kRepBit: // Fall through. - case kRepWord8: + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: opcode = kArmStrb; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kArmStrh; break; - case kRepTagged: // Fall through. - case kRepWord32: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord32: opcode = kArmStr; break; default: @@ -419,27 +418,26 @@ void InstructionSelector::VisitStore(Node* node) { void InstructionSelector::VisitCheckedLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); ArmOperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); Node* const length = node->InputAt(2); ArchOpcode opcode; - switch (rep) { - case kRepWord8: - opcode = typ == kTypeInt32 ? kCheckedLoadInt8 : kCheckedLoadUint8; + switch (load_rep.representation()) { + case MachineRepresentation::kWord8: + opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; break; - case kRepWord16: - opcode = typ == kTypeInt32 ? kCheckedLoadInt16 : kCheckedLoadUint16; + case MachineRepresentation::kWord16: + opcode = load_rep.IsSigned() ? kCheckedLoadInt16 : kCheckedLoadUint16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedLoadWord32; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedLoadFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedLoadFloat64; break; default: @@ -457,7 +455,8 @@ void InstructionSelector::VisitCheckedLoad(Node* node) { void InstructionSelector::VisitCheckedStore(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); + MachineRepresentation rep = + CheckedStoreRepresentationOf(node->op()).representation(); ArmOperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); @@ -465,19 +464,19 @@ void InstructionSelector::VisitCheckedStore(Node* node) { Node* const value = node->InputAt(3); ArchOpcode opcode; switch (rep) { - case kRepWord8: + case MachineRepresentation::kWord8: opcode = kCheckedStoreWord8; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kCheckedStoreWord16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedStoreWord32; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedStoreFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedStoreFloat64; break; default: diff --git a/src/compiler/arm64/instruction-selector-arm64.cc b/src/compiler/arm64/instruction-selector-arm64.cc index 7e47632d4f..982142b8e0 100644 --- a/src/compiler/arm64/instruction-selector-arm64.cc +++ b/src/compiler/arm64/instruction-selector-arm64.cc @@ -338,37 +338,36 @@ int32_t LeftShiftForReducedMultiply(Matcher* m) { void InstructionSelector::VisitLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + LoadRepresentation load_rep = LoadRepresentationOf(node->op()); Arm64OperandGenerator g(this); Node* base = node->InputAt(0); Node* index = node->InputAt(1); ArchOpcode opcode; ImmediateMode immediate_mode = kNoImmediate; - switch (rep) { - case kRepFloat32: + switch (load_rep.representation()) { + case MachineRepresentation::kFloat32: opcode = kArm64LdrS; immediate_mode = kLoadStoreImm32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kArm64LdrD; immediate_mode = kLoadStoreImm64; break; - case kRepBit: // Fall through. - case kRepWord8: - opcode = typ == kTypeInt32 ? kArm64Ldrsb : kArm64Ldrb; + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: + opcode = load_rep.IsSigned() ? kArm64Ldrsb : kArm64Ldrb; immediate_mode = kLoadStoreImm8; break; - case kRepWord16: - opcode = typ == kTypeInt32 ? kArm64Ldrsh : kArm64Ldrh; + case MachineRepresentation::kWord16: + opcode = load_rep.IsSigned() ? kArm64Ldrsh : kArm64Ldrh; immediate_mode = kLoadStoreImm16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kArm64LdrW; immediate_mode = kLoadStoreImm32; break; - case kRepTagged: // Fall through. - case kRepWord64: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord64: opcode = kArm64Ldr; immediate_mode = kLoadStoreImm64; break; @@ -394,11 +393,11 @@ void InstructionSelector::VisitStore(Node* node) { StoreRepresentation store_rep = OpParameter(node); WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); - MachineType rep = RepresentationOf(store_rep.machine_type()); + MachineRepresentation rep = store_rep.machine_type().representation(); // TODO(arm64): I guess this could be done in a better way. if (write_barrier_kind != kNoWriteBarrier) { - DCHECK_EQ(kRepTagged, rep); + DCHECK_EQ(MachineRepresentation::kTagged, rep); InstructionOperand inputs[3]; size_t input_count = 0; inputs[input_count++] = g.UseUniqueRegister(base); @@ -430,29 +429,29 @@ void InstructionSelector::VisitStore(Node* node) { ArchOpcode opcode; ImmediateMode immediate_mode = kNoImmediate; switch (rep) { - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kArm64StrS; immediate_mode = kLoadStoreImm32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kArm64StrD; immediate_mode = kLoadStoreImm64; break; - case kRepBit: // Fall through. - case kRepWord8: + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: opcode = kArm64Strb; immediate_mode = kLoadStoreImm8; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kArm64Strh; immediate_mode = kLoadStoreImm16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kArm64StrW; immediate_mode = kLoadStoreImm32; break; - case kRepTagged: // Fall through. - case kRepWord64: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord64: opcode = kArm64Str; immediate_mode = kLoadStoreImm64; break; @@ -472,30 +471,29 @@ void InstructionSelector::VisitStore(Node* node) { void InstructionSelector::VisitCheckedLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); Arm64OperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); Node* const length = node->InputAt(2); ArchOpcode opcode; - switch (rep) { - case kRepWord8: - opcode = typ == kTypeInt32 ? kCheckedLoadInt8 : kCheckedLoadUint8; + switch (load_rep.representation()) { + case MachineRepresentation::kWord8: + opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; break; - case kRepWord16: - opcode = typ == kTypeInt32 ? kCheckedLoadInt16 : kCheckedLoadUint16; + case MachineRepresentation::kWord16: + opcode = load_rep.IsSigned() ? kCheckedLoadInt16 : kCheckedLoadUint16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedLoadWord32; break; - case kRepWord64: + case MachineRepresentation::kWord64: opcode = kCheckedLoadWord64; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedLoadFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedLoadFloat64; break; default: @@ -508,7 +506,8 @@ void InstructionSelector::VisitCheckedLoad(Node* node) { void InstructionSelector::VisitCheckedStore(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); + MachineRepresentation rep = + CheckedStoreRepresentationOf(node->op()).representation(); Arm64OperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); @@ -516,22 +515,22 @@ void InstructionSelector::VisitCheckedStore(Node* node) { Node* const value = node->InputAt(3); ArchOpcode opcode; switch (rep) { - case kRepWord8: + case MachineRepresentation::kWord8: opcode = kCheckedStoreWord8; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kCheckedStoreWord16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedStoreWord32; break; - case kRepWord64: + case MachineRepresentation::kWord64: opcode = kCheckedStoreWord64; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedStoreFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedStoreFloat64; break; default: diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index e59323eff0..2e594c21c7 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -3015,7 +3015,7 @@ void AstGraphBuilder::VisitNot(UnaryOperation* expr) { VisitForValue(expr->expression()); Node* operand = environment()->Pop(); Node* input = BuildToBoolean(operand, expr->expression()->test_id()); - Node* value = NewNode(common()->Select(kMachAnyTagged), input, + Node* value = NewNode(common()->Select(MachineRepresentation::kTagged), input, jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); ast_context()->ProduceValue(value); } @@ -3257,8 +3257,9 @@ Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole, Node* not_hole) { Node* the_hole = jsgraph()->TheHoleConstant(); Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); - return NewNode(common()->Select(kMachAnyTagged, BranchHint::kFalse), check, - for_hole, not_hole); + return NewNode( + common()->Select(MachineRepresentation::kTagged, BranchHint::kFalse), + check, for_hole, not_hole); } @@ -3653,13 +3654,14 @@ Node* AstGraphBuilder::BuildGlobalStore(Handle name, Node* value, Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { - return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, + return NewNode(jsgraph()->machine()->Load(MachineType::AnyTagged()), object, jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); } Node* AstGraphBuilder::BuildLoadImmutableObjectField(Node* object, int offset) { - return graph()->NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, + return graph()->NewNode(jsgraph()->machine()->Load(MachineType::AnyTagged()), + object, jsgraph()->IntPtrConstant(offset - kHeapObjectTag), graph()->start(), graph()->start()); } @@ -4264,7 +4266,7 @@ void AstGraphBuilder::Environment::PrepareForLoop(BitVector* assigned, Node* AstGraphBuilder::NewPhi(int count, Node* input, Node* control) { - const Operator* phi_op = common()->Phi(kMachAnyTagged, count); + const Operator* phi_op = common()->Phi(MachineRepresentation::kTagged, count); Node** buffer = EnsureInputBufferSize(count + 1); MemsetPointer(buffer, input, count); buffer[count] = control; @@ -4326,7 +4328,8 @@ Node* AstGraphBuilder::MergeValue(Node* value, Node* other, Node* control) { NodeProperties::GetControlInput(value) == control) { // Phi already exists, add input. value->InsertInput(graph_zone(), inputs - 1, other); - NodeProperties::ChangeOp(value, common()->Phi(kMachAnyTagged, inputs)); + NodeProperties::ChangeOp( + value, common()->Phi(MachineRepresentation::kTagged, inputs)); } else if (value != other) { // Phi does not exist yet, introduce one. value = NewPhi(inputs, value, control); diff --git a/src/compiler/basic-block-instrumentor.cc b/src/compiler/basic-block-instrumentor.cc index 23170e701b..7b3c76ac6d 100644 --- a/src/compiler/basic-block-instrumentor.cc +++ b/src/compiler/basic-block-instrumentor.cc @@ -81,12 +81,13 @@ BasicBlockProfiler::Data* BasicBlockInstrumentor::Instrument( // Construct increment operation. Node* base = graph->NewNode( PointerConstant(&common, data->GetCounterAddress(block_number))); - Node* load = graph->NewNode(machine.Load(kMachUint32), base, zero, + Node* load = graph->NewNode(machine.Load(MachineType::Uint32()), base, zero, graph->start(), graph->start()); Node* inc = graph->NewNode(machine.Int32Add(), load, one); - Node* store = graph->NewNode( - machine.Store(StoreRepresentation(kMachUint32, kNoWriteBarrier)), base, - zero, inc, graph->start(), graph->start()); + Node* store = + graph->NewNode(machine.Store(StoreRepresentation(MachineType::Uint32(), + kNoWriteBarrier)), + base, zero, inc, graph->start(), graph->start()); // Insert the new nodes. static const int kArraySize = 6; Node* to_insert[kArraySize] = {zero, one, base, load, inc, store}; diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc index 41344d0c6a..96c1415c5f 100644 --- a/src/compiler/bytecode-graph-builder.cc +++ b/src/compiler/bytecode-graph-builder.cc @@ -156,14 +156,15 @@ Node* BytecodeGraphBuilder::GetFunctionClosure() { Node* BytecodeGraphBuilder::BuildLoadObjectField(Node* object, int offset) { - return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, + return NewNode(jsgraph()->machine()->Load(MachineType::AnyTagged()), object, jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); } Node* BytecodeGraphBuilder::BuildLoadImmutableObjectField(Node* object, int offset) { - return graph()->NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, + return graph()->NewNode(jsgraph()->machine()->Load(MachineType::AnyTagged()), + object, jsgraph()->IntPtrConstant(offset - kHeapObjectTag), graph()->start(), graph()->start()); } @@ -1034,7 +1035,7 @@ void BytecodeGraphBuilder::VisitLogicalNot( const interpreter::BytecodeArrayIterator& iterator) { Node* value = NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), environment()->LookupAccumulator()); - Node* node = NewNode(common()->Select(kMachAnyTagged), value, + Node* node = NewNode(common()->Select(MachineRepresentation::kTagged), value, jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); environment()->BindAccumulator(node); } diff --git a/src/compiler/c-linkage.cc b/src/compiler/c-linkage.cc index 1c91f7c118..44e0bf1672 100644 --- a/src/compiler/c-linkage.cc +++ b/src/compiler/c-linkage.cc @@ -208,7 +208,7 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor( #endif // The target for C calls is always an address (i.e. machine pointer). - MachineType target_type = kMachPtr; + MachineType target_type = MachineType::Pointer(); LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); return new (zone) CallDescriptor( // -- CallDescriptor::kCallAddress, // kind diff --git a/src/compiler/change-lowering.cc b/src/compiler/change-lowering.cc index c77ecf01c1..88631f9e68 100644 --- a/src/compiler/change-lowering.cc +++ b/src/compiler/change-lowering.cc @@ -87,9 +87,10 @@ Node* ChangeLowering::AllocateHeapNumberWithValue(Node* value, Node* control) { } Node* heap_number = graph()->NewNode(allocate_heap_number_operator_.get(), target, context, effect, control); - Node* store = graph()->NewNode( - machine()->Store(StoreRepresentation(kMachFloat64, kNoWriteBarrier)), - heap_number, HeapNumberValueIndexConstant(), value, heap_number, control); + Node* store = graph()->NewNode(machine()->Store(StoreRepresentation( + MachineType::Float64(), kNoWriteBarrier)), + heap_number, HeapNumberValueIndexConstant(), + value, heap_number, control); return graph()->NewNode(common()->FinishRegion(), heap_number, store); } @@ -135,7 +136,7 @@ Node* ChangeLowering::ChangeUint32ToSmi(Node* value) { Node* ChangeLowering::LoadHeapNumberValue(Node* value, Node* control) { - return graph()->NewNode(machine()->Load(kMachFloat64), value, + return graph()->NewNode(machine()->Load(MachineType::Float64()), value, HeapNumberValueIndexConstant(), graph()->start(), control); } @@ -150,9 +151,9 @@ Node* ChangeLowering::TestNotSmi(Node* value) { Reduction ChangeLowering::ChangeBitToBool(Node* value, Node* control) { - return Replace(graph()->NewNode(common()->Select(kMachAnyTagged), value, - jsgraph()->TrueConstant(), - jsgraph()->FalseConstant())); + return Replace( + graph()->NewNode(common()->Select(MachineRepresentation::kTagged), value, + jsgraph()->TrueConstant(), jsgraph()->FalseConstant())); } @@ -232,8 +233,8 @@ Reduction ChangeLowering::ChangeFloat64ToTagged(Node* value, Node* control) { vbox = AllocateHeapNumberWithValue(value, if_box); control = graph()->NewNode(common()->Merge(2), if_smi, if_box); - value = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vsmi, vbox, control); + value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + vsmi, vbox, control); return Replace(value); } @@ -258,8 +259,8 @@ Reduction ChangeLowering::ChangeInt32ToTagged(Node* value, Node* control) { Node* vfalse = graph()->NewNode(common()->Projection(0), add); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vtrue, vfalse, merge); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + vtrue, vfalse, merge); return Replace(phi); } @@ -271,7 +272,6 @@ Reduction ChangeLowering::ChangeTaggedToUI32(Node* value, Node* control, return Replace(ChangeSmiToInt32(value)); } - const MachineType type = (signedness == kSigned) ? kMachInt32 : kMachUint32; const Operator* op = (signedness == kSigned) ? machine()->ChangeFloat64ToInt32() : machine()->ChangeFloat64ToUint32(); @@ -291,7 +291,8 @@ Reduction ChangeLowering::ChangeTaggedToUI32(Node* value, Node* control, Node* vfalse = ChangeSmiToInt32(value); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = graph()->NewNode(common()->Phi(type, 2), vtrue, vfalse, merge); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), + vtrue, vfalse, merge); return Replace(phi); } @@ -330,7 +331,7 @@ Reduction ChangeLowering::ChangeTaggedToFloat64(Node* value, Node* control) { const Operator* merge_op = common()->Merge(2); const Operator* ephi_op = common()->EffectPhi(2); - const Operator* phi_op = common()->Phi(kMachFloat64, 2); + const Operator* phi_op = common()->Phi(MachineRepresentation::kFloat64, 2); Node* check1 = TestNotSmi(object); Node* branch1 = @@ -387,8 +388,8 @@ Reduction ChangeLowering::ChangeTaggedToFloat64(Node* value, Node* control) { Node* vfalse = ChangeSmiToFloat64(value); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = - graph()->NewNode(common()->Phi(kMachFloat64, 2), vtrue, vfalse, merge); + Node* phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kFloat64, 2), vtrue, vfalse, merge); return Replace(phi); } @@ -412,8 +413,8 @@ Reduction ChangeLowering::ChangeUint32ToTagged(Node* value, Node* control) { AllocateHeapNumberWithValue(ChangeUint32ToFloat64(value), if_false); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vtrue, vfalse, merge); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + vtrue, vfalse, merge); return Replace(phi); } @@ -422,7 +423,7 @@ Reduction ChangeLowering::ChangeUint32ToTagged(Node* value, Node* control) { namespace { WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, - MachineType representation, + MachineRepresentation representation, Type* field_type, Type* input_type) { if (field_type->Is(Type::TaggedSigned()) || input_type->Is(Type::TaggedSigned())) { @@ -435,7 +436,7 @@ WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, return kNoWriteBarrier; } if (base_is_tagged == kTaggedBase && - RepresentationOf(representation) == kRepTagged) { + representation == MachineRepresentation::kTagged) { if (input_type->IsConstant() && input_type->AsConstant()->Value()->IsHeapObject()) { Handle input = @@ -480,7 +481,8 @@ Reduction ChangeLowering::StoreField(Node* node) { const FieldAccess& access = FieldAccessOf(node->op()); Type* type = NodeProperties::GetType(node->InputAt(1)); WriteBarrierKind kind = ComputeWriteBarrierKind( - access.base_is_tagged, access.machine_type, access.type, type); + access.base_is_tagged, access.machine_type.representation(), access.type, + type); Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); node->InsertInput(graph()->zone(), 1, offset); NodeProperties::ChangeOp( @@ -492,7 +494,8 @@ Reduction ChangeLowering::StoreField(Node* node) { Node* ChangeLowering::ComputeIndex(const ElementAccess& access, Node* const key) { Node* index = key; - const int element_size_shift = ElementSizeLog2Of(access.machine_type); + const int element_size_shift = + ElementSizeLog2Of(access.machine_type.representation()); if (element_size_shift) { index = graph()->NewNode(machine()->Word32Shl(), index, jsgraph()->Int32Constant(element_size_shift)); @@ -525,11 +528,11 @@ Reduction ChangeLowering::StoreElement(Node* node) { Type* type = NodeProperties::GetType(node->InputAt(2)); node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); NodeProperties::ChangeOp( - node, - machine()->Store(StoreRepresentation( - access.machine_type, - ComputeWriteBarrierKind(access.base_is_tagged, access.machine_type, - access.type, type)))); + node, machine()->Store(StoreRepresentation( + access.machine_type, + ComputeWriteBarrierKind(access.base_is_tagged, + access.machine_type.representation(), + access.type, type)))); return Changed(node); } diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc index 800002eda8..9ca4f5fafb 100644 --- a/src/compiler/code-generator.cc +++ b/src/compiler/code-generator.cc @@ -510,7 +510,8 @@ OperandAndType TypedOperandForFrameState(FrameStateDescriptor* descriptor, descriptor->GetSize(OutputFrameStateCombine::Ignore()); // If the index is past the existing stack items, return the output. if (index >= size_without_output) { - return {instr->OutputAt(index - size_without_output), kMachAnyTagged}; + return {instr->OutputAt(index - size_without_output), + MachineType::AnyTagged()}; } break; } @@ -519,7 +520,8 @@ OperandAndType TypedOperandForFrameState(FrameStateDescriptor* descriptor, descriptor->GetSize(combine) - 1 - combine.GetOffsetToPokeAt(); if (index >= index_from_top && index < index_from_top + instr->OutputCount()) { - return {instr->OutputAt(index - index_from_top), kMachAnyTagged}; + return {instr->OutputAt(index - index_from_top), + MachineType::AnyTagged()}; } break; } @@ -603,37 +605,39 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation, InstructionOperand* op, MachineType type) { if (op->IsStackSlot()) { - if (type == kMachBool || type == kRepBit) { + if (type.representation() == MachineRepresentation::kBit) { translation->StoreBoolStackSlot(LocationOperand::cast(op)->index()); - } else if (type == kMachInt32 || type == kMachInt8 || type == kMachInt16) { + } else if (type == MachineType::Int8() || type == MachineType::Int16() || + type == MachineType::Int32()) { translation->StoreInt32StackSlot(LocationOperand::cast(op)->index()); - } else if (type == kMachUint32 || type == kMachUint16 || - type == kMachUint8) { + } else if (type == MachineType::Uint8() || type == MachineType::Uint16() || + type == MachineType::Uint32()) { translation->StoreUint32StackSlot(LocationOperand::cast(op)->index()); - } else if ((type & kRepMask) == kRepTagged) { + } else if (type.representation() == MachineRepresentation::kTagged) { translation->StoreStackSlot(LocationOperand::cast(op)->index()); } else { CHECK(false); } } else if (op->IsDoubleStackSlot()) { - DCHECK((type & (kRepFloat32 | kRepFloat64)) != 0); + DCHECK(IsFloatingPoint(type.representation())); translation->StoreDoubleStackSlot(LocationOperand::cast(op)->index()); } else if (op->IsRegister()) { InstructionOperandConverter converter(this, instr); - if (type == kMachBool || type == kRepBit) { + if (type.representation() == MachineRepresentation::kBit) { translation->StoreBoolRegister(converter.ToRegister(op)); - } else if (type == kMachInt32 || type == kMachInt8 || type == kMachInt16) { + } else if (type == MachineType::Int8() || type == MachineType::Int16() || + type == MachineType::Int32()) { translation->StoreInt32Register(converter.ToRegister(op)); - } else if (type == kMachUint32 || type == kMachUint16 || - type == kMachUint8) { + } else if (type == MachineType::Uint8() || type == MachineType::Uint16() || + type == MachineType::Uint32()) { translation->StoreUint32Register(converter.ToRegister(op)); - } else if ((type & kRepMask) == kRepTagged) { + } else if (type.representation() == MachineRepresentation::kTagged) { translation->StoreRegister(converter.ToRegister(op)); } else { CHECK(false); } } else if (op->IsDoubleRegister()) { - DCHECK((type & (kRepFloat32 | kRepFloat64)) != 0); + DCHECK(IsFloatingPoint(type.representation())); InstructionOperandConverter converter(this, instr); translation->StoreDoubleRegister(converter.ToDoubleRegister(op)); } else if (op->IsImmediate()) { @@ -642,21 +646,23 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation, Handle constant_object; switch (constant.type()) { case Constant::kInt32: - DCHECK(type == kMachInt32 || type == kMachUint32 || type == kMachBool || - type == kRepBit); + DCHECK(type == MachineType::Int32() || type == MachineType::Uint32() || + type.representation() == MachineRepresentation::kBit); constant_object = isolate()->factory()->NewNumberFromInt(constant.ToInt32()); break; case Constant::kFloat32: - DCHECK((type & (kRepFloat32 | kRepTagged)) != 0); + DCHECK(type.representation() == MachineRepresentation::kFloat32 || + type.representation() == MachineRepresentation::kTagged); constant_object = isolate()->factory()->NewNumber(constant.ToFloat32()); break; case Constant::kFloat64: - DCHECK((type & (kRepFloat64 | kRepTagged)) != 0); + DCHECK(type.representation() == MachineRepresentation::kFloat64 || + type.representation() == MachineRepresentation::kTagged); constant_object = isolate()->factory()->NewNumber(constant.ToFloat64()); break; case Constant::kHeapObject: - DCHECK((type & kRepMask) == kRepTagged); + DCHECK(type.representation() == MachineRepresentation::kTagged); constant_object = constant.ToHeapObject(); break; default: diff --git a/src/compiler/code-stub-assembler.cc b/src/compiler/code-stub-assembler.cc index f7d5992809..b2a05b64f8 100644 --- a/src/compiler/code-stub-assembler.cc +++ b/src/compiler/code-stub-assembler.cc @@ -119,7 +119,7 @@ Node* CodeStubAssembler::WordShl(Node* value, int shift) { Node* CodeStubAssembler::LoadObjectField(Node* object, int offset) { - return raw_assembler_->Load(kMachAnyTagged, object, + return raw_assembler_->Load(MachineType::AnyTagged(), object, IntPtrConstant(offset - kHeapObjectTag)); } diff --git a/src/compiler/common-operator.cc b/src/compiler/common-operator.cc index 011bd2e683..4246e5b60b 100644 --- a/src/compiler/common-operator.cc +++ b/src/compiler/common-operator.cc @@ -73,7 +73,8 @@ std::ostream& operator<<(std::ostream& os, IfExceptionHint hint) { bool operator==(SelectParameters const& lhs, SelectParameters const& rhs) { - return lhs.type() == rhs.type() && lhs.hint() == rhs.hint(); + return lhs.representation() == rhs.representation() && + lhs.hint() == rhs.hint(); } @@ -83,12 +84,12 @@ bool operator!=(SelectParameters const& lhs, SelectParameters const& rhs) { size_t hash_value(SelectParameters const& p) { - return base::hash_combine(p.type(), p.hint()); + return base::hash_combine(p.representation(), p.hint()); } std::ostream& operator<<(std::ostream& os, SelectParameters const& p) { - return os << p.type() << "|" << p.hint(); + return os << p.representation() << "|" << p.hint(); } @@ -104,6 +105,12 @@ size_t ProjectionIndexOf(const Operator* const op) { } +MachineRepresentation PhiRepresentationOf(const Operator* const op) { + DCHECK_EQ(IrOpcode::kPhi, op->opcode()); + return OpParameter(op); +} + + int ParameterIndexOf(const Operator* const op) { DCHECK_EQ(IrOpcode::kParameter, op->opcode()); return OpParameter(op).index(); @@ -203,15 +210,15 @@ std::ostream& operator<<(std::ostream& os, ParameterInfo const& i) { #define CACHED_PHI_LIST(V) \ - V(kMachAnyTagged, 1) \ - V(kMachAnyTagged, 2) \ - V(kMachAnyTagged, 3) \ - V(kMachAnyTagged, 4) \ - V(kMachAnyTagged, 5) \ - V(kMachAnyTagged, 6) \ - V(kMachBool, 2) \ - V(kMachFloat64, 2) \ - V(kMachInt32, 2) + V(kTagged, 1) \ + V(kTagged, 2) \ + V(kTagged, 3) \ + V(kTagged, 4) \ + V(kTagged, 5) \ + V(kTagged, 6) \ + V(kBit, 2) \ + V(kFloat64, 2) \ + V(kWord32, 2) #define CACHED_PROJECTION_LIST(V) \ @@ -353,17 +360,18 @@ struct CommonOperatorGlobalCache final { CACHED_MERGE_LIST(CACHED_MERGE) #undef CACHED_MERGE - template - struct PhiOperator final : public Operator1 { + template + struct PhiOperator final : public Operator1 { PhiOperator() - : Operator1( //-- + : Operator1( //-- IrOpcode::kPhi, Operator::kPure, // opcode "Phi", // name kInputCount, 0, 1, 1, 0, 0, // counts - kType) {} // parameter + kRep) {} // parameter }; -#define CACHED_PHI(type, input_count) \ - PhiOperator kPhi##type##input_count##Operator; +#define CACHED_PHI(rep, input_count) \ + PhiOperator \ + kPhi##rep##input_count##Operator; CACHED_PHI_LIST(CACHED_PHI) #undef CACHED_PHI @@ -661,31 +669,32 @@ const Operator* CommonOperatorBuilder::HeapConstant( } -const Operator* CommonOperatorBuilder::Select(MachineType type, +const Operator* CommonOperatorBuilder::Select(MachineRepresentation rep, BranchHint hint) { return new (zone()) Operator1( // -- IrOpcode::kSelect, Operator::kPure, // opcode "Select", // name 3, 0, 0, 1, 0, 0, // counts - SelectParameters(type, hint)); // parameter + SelectParameters(rep, hint)); // parameter } -const Operator* CommonOperatorBuilder::Phi(MachineType type, +const Operator* CommonOperatorBuilder::Phi(MachineRepresentation rep, int value_input_count) { DCHECK(value_input_count > 0); // Disallow empty phis. -#define CACHED_PHI(kType, kValueInputCount) \ - if (kType == type && kValueInputCount == value_input_count) { \ - return &cache_.kPhi##kType##kValueInputCount##Operator; \ +#define CACHED_PHI(kRep, kValueInputCount) \ + if (MachineRepresentation::kRep == rep && \ + kValueInputCount == value_input_count) { \ + return &cache_.kPhi##kRep##kValueInputCount##Operator; \ } CACHED_PHI_LIST(CACHED_PHI) #undef CACHED_PHI // Uncached. - return new (zone()) Operator1( // -- - IrOpcode::kPhi, Operator::kPure, // opcode - "Phi", // name - value_input_count, 0, 1, 1, 0, 0, // counts - type); // parameter + return new (zone()) Operator1( // -- + IrOpcode::kPhi, Operator::kPure, // opcode + "Phi", // name + value_input_count, 0, 1, 1, 0, 0, // counts + rep); // parameter } @@ -832,7 +841,7 @@ const Operator* CommonOperatorBuilder::Projection(size_t index) { const Operator* CommonOperatorBuilder::ResizeMergeOrPhi(const Operator* op, int size) { if (op->opcode() == IrOpcode::kPhi) { - return Phi(OpParameter(op), size); + return Phi(PhiRepresentationOf(op), size); } else if (op->opcode() == IrOpcode::kEffectPhi) { return EffectPhi(size); } else if (op->opcode() == IrOpcode::kMerge) { diff --git a/src/compiler/common-operator.h b/src/compiler/common-operator.h index 8c7d26608c..211e4e4843 100644 --- a/src/compiler/common-operator.h +++ b/src/compiler/common-operator.h @@ -71,15 +71,15 @@ std::ostream& operator<<(std::ostream&, IfExceptionHint); class SelectParameters final { public: - explicit SelectParameters(MachineType type, + explicit SelectParameters(MachineRepresentation representation, BranchHint hint = BranchHint::kNone) - : type_(type), hint_(hint) {} + : representation_(representation), hint_(hint) {} - MachineType type() const { return type_; } + MachineRepresentation representation() const { return representation_; } BranchHint hint() const { return hint_; } private: - const MachineType type_; + const MachineRepresentation representation_; const BranchHint hint_; }; @@ -95,6 +95,8 @@ SelectParameters const& SelectParametersOf(const Operator* const); size_t ProjectionIndexOf(const Operator* const); +MachineRepresentation PhiRepresentationOf(const Operator* const); + // The {IrOpcode::kParameter} opcode represents an incoming parameter to the // function. This class bundles the index and a debug name for such operators. @@ -155,8 +157,9 @@ class CommonOperatorBuilder final : public ZoneObject { const Operator* NumberConstant(volatile double); const Operator* HeapConstant(const Handle&); - const Operator* Select(MachineType, BranchHint = BranchHint::kNone); - const Operator* Phi(MachineType type, int value_input_count); + const Operator* Select(MachineRepresentation, BranchHint = BranchHint::kNone); + const Operator* Phi(MachineRepresentation representation, + int value_input_count); const Operator* EffectPhi(int effect_input_count); const Operator* EffectSet(int arguments); const Operator* Guard(Type* type); diff --git a/src/compiler/diamond.h b/src/compiler/diamond.h index f562092a8a..e1333052d7 100644 --- a/src/compiler/diamond.h +++ b/src/compiler/diamond.h @@ -49,8 +49,8 @@ struct Diamond { } } - Node* Phi(MachineType machine_type, Node* tv, Node* fv) { - return graph->NewNode(common->Phi(machine_type, 2), tv, fv, merge); + Node* Phi(MachineRepresentation rep, Node* tv, Node* fv) { + return graph->NewNode(common->Phi(rep, 2), tv, fv, merge); } }; diff --git a/src/compiler/escape-analysis.cc b/src/compiler/escape-analysis.cc index 7fc8fbfced..c7c451ce06 100644 --- a/src/compiler/escape-analysis.cc +++ b/src/compiler/escape-analysis.cc @@ -285,8 +285,8 @@ bool VirtualState::MergeFrom(VirtualState* left, VirtualState* right, NodeProperties::GetValueInput(rep, 0) != ls->GetField(i) || NodeProperties::GetValueInput(rep, 1) != rs->GetField(i)) { Node* phi = - graph->NewNode(common->Phi(kMachAnyTagged, 2), ls->GetField(i), - rs->GetField(i), control); + graph->NewNode(common->Phi(MachineRepresentation::kTagged, 2), + ls->GetField(i), rs->GetField(i), control); if (mergeObject->SetField(i, phi)) { if (FLAG_trace_turbo_escape) { PrintF(" Creating Phi #%d as merge of #%d and #%d\n", @@ -952,8 +952,9 @@ void EscapeAnalysis::ProcessLoadFromPhi(int offset, Node* from, Node* node, if (!rep || rep->opcode() != IrOpcode::kPhi || NodeProperties::GetValueInput(rep, 0) != lv || NodeProperties::GetValueInput(rep, 1) != rv) { - Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), lv, rv, - NodeProperties::GetControlInput(from)); + Node* phi = + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + lv, rv, NodeProperties::GetControlInput(from)); state->GetVirtualObject(node)->SetReplacement(phi); state->LastChangedAt(node); if (FLAG_trace_turbo_escape) { @@ -1008,7 +1009,8 @@ void EscapeAnalysis::ProcessLoadElement(Node* node) { NumberMatcher index(node->InputAt(1)); ElementAccess access = OpParameter(node); if (index.HasValue()) { - CHECK_EQ(ElementSizeLog2Of(access.machine_type), kPointerSizeLog2); + CHECK_EQ(ElementSizeLog2Of(access.machine_type.representation()), + kPointerSizeLog2); CHECK_EQ(access.header_size % kPointerSize, 0); int offset = index.Value() + access.header_size / kPointerSize; if (!object->IsTracked()) return; @@ -1058,7 +1060,8 @@ void EscapeAnalysis::ProcessStoreElement(Node* node) { ElementAccess access = OpParameter(node); Node* val = NodeProperties::GetValueInput(node, 2); if (index.HasValue()) { - CHECK_EQ(ElementSizeLog2Of(access.machine_type), kPointerSizeLog2); + CHECK_EQ(ElementSizeLog2Of(access.machine_type.representation()), + kPointerSizeLog2); CHECK_EQ(access.header_size % kPointerSize, 0); int offset = index.Value() + access.header_size / kPointerSize; VirtualState* states = virtual_states_[node->id()]; diff --git a/src/compiler/ia32/instruction-selector-ia32.cc b/src/compiler/ia32/instruction-selector-ia32.cc index db50c776ee..e1926169f4 100644 --- a/src/compiler/ia32/instruction-selector-ia32.cc +++ b/src/compiler/ia32/instruction-selector-ia32.cc @@ -169,26 +169,25 @@ void VisitFloatUnop(InstructionSelector* selector, Node* node, Node* input, void InstructionSelector::VisitLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ArchOpcode opcode; - switch (rep) { - case kRepFloat32: + switch (load_rep.representation()) { + case MachineRepresentation::kFloat32: opcode = kIA32Movss; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kIA32Movsd; break; - case kRepBit: // Fall through. - case kRepWord8: - opcode = typ == kTypeInt32 ? kIA32Movsxbl : kIA32Movzxbl; + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: + opcode = load_rep.IsSigned() ? kIA32Movsxbl : kIA32Movzxbl; break; - case kRepWord16: - opcode = typ == kTypeInt32 ? kIA32Movsxwl : kIA32Movzxwl; + case MachineRepresentation::kWord16: + opcode = load_rep.IsSigned() ? kIA32Movsxwl : kIA32Movzxwl; break; - case kRepTagged: // Fall through. - case kRepWord32: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord32: opcode = kIA32Movl; break; default: @@ -216,10 +215,10 @@ void InstructionSelector::VisitStore(Node* node) { StoreRepresentation store_rep = OpParameter(node); WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); - MachineType rep = RepresentationOf(store_rep.machine_type()); + MachineRepresentation rep = store_rep.machine_type().representation(); if (write_barrier_kind != kNoWriteBarrier) { - DCHECK_EQ(kRepTagged, rep); + DCHECK_EQ(MachineRepresentation::kTagged, rep); AddressingMode addressing_mode; InstructionOperand inputs[3]; size_t input_count = 0; @@ -258,21 +257,21 @@ void InstructionSelector::VisitStore(Node* node) { } else { ArchOpcode opcode; switch (rep) { - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kIA32Movss; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kIA32Movsd; break; - case kRepBit: // Fall through. - case kRepWord8: + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: opcode = kIA32Movb; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kIA32Movw; break; - case kRepTagged: // Fall through. - case kRepWord32: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord32: opcode = kIA32Movl; break; default: @@ -283,7 +282,8 @@ void InstructionSelector::VisitStore(Node* node) { InstructionOperand val; if (g.CanBeImmediate(value)) { val = g.UseImmediate(value); - } else if (rep == kRepWord8 || rep == kRepBit) { + } else if (rep == MachineRepresentation::kWord8 || + rep == MachineRepresentation::kBit) { val = g.UseByteRegister(value); } else { val = g.UseRegister(value); @@ -302,27 +302,26 @@ void InstructionSelector::VisitStore(Node* node) { void InstructionSelector::VisitCheckedLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); IA32OperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); Node* const length = node->InputAt(2); ArchOpcode opcode; - switch (rep) { - case kRepWord8: - opcode = typ == kTypeInt32 ? kCheckedLoadInt8 : kCheckedLoadUint8; + switch (load_rep.representation()) { + case MachineRepresentation::kWord8: + opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; break; - case kRepWord16: - opcode = typ == kTypeInt32 ? kCheckedLoadInt16 : kCheckedLoadUint16; + case MachineRepresentation::kWord16: + opcode = load_rep.IsSigned() ? kCheckedLoadInt16 : kCheckedLoadUint16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedLoadWord32; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedLoadFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedLoadFloat64; break; default: @@ -345,7 +344,8 @@ void InstructionSelector::VisitCheckedLoad(Node* node) { void InstructionSelector::VisitCheckedStore(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); + MachineRepresentation rep = + CheckedStoreRepresentationOf(node->op()).representation(); IA32OperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); @@ -353,19 +353,19 @@ void InstructionSelector::VisitCheckedStore(Node* node) { Node* const value = node->InputAt(3); ArchOpcode opcode; switch (rep) { - case kRepWord8: + case MachineRepresentation::kWord8: opcode = kCheckedStoreWord8; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kCheckedStoreWord16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedStoreWord32; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedStoreFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedStoreFloat64; break; default: @@ -373,10 +373,11 @@ void InstructionSelector::VisitCheckedStore(Node* node) { return; } InstructionOperand value_operand = - g.CanBeImmediate(value) - ? g.UseImmediate(value) - : ((rep == kRepWord8 || rep == kRepBit) ? g.UseByteRegister(value) - : g.UseRegister(value)); + g.CanBeImmediate(value) ? g.UseImmediate(value) + : ((rep == MachineRepresentation::kWord8 || + rep == MachineRepresentation::kBit) + ? g.UseByteRegister(value) + : g.UseRegister(value)); InstructionOperand offset_operand = g.UseRegister(offset); InstructionOperand length_operand = g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length); diff --git a/src/compiler/instruction-selector-impl.h b/src/compiler/instruction-selector-impl.h index 7136de96b1..5cca8880d5 100644 --- a/src/compiler/instruction-selector-impl.h +++ b/src/compiler/instruction-selector-impl.h @@ -68,8 +68,8 @@ class OperandGenerator { } InstructionOperand DefineAsLocation(Node* node, LinkageLocation location, - MachineType type) { - return Define(node, ToUnallocatedOperand(location, type, GetVReg(node))); + MachineRepresentation rep) { + return Define(node, ToUnallocatedOperand(location, rep, GetVReg(node))); } InstructionOperand DefineAsDualLocation(Node* node, @@ -129,12 +129,12 @@ class OperandGenerator { } InstructionOperand UseExplicit(LinkageLocation location) { - MachineType machine_type = InstructionSequence::DefaultRepresentation(); + MachineRepresentation rep = InstructionSequence::DefaultRepresentation(); if (location.IsRegister()) { - return ExplicitOperand(LocationOperand::REGISTER, machine_type, + return ExplicitOperand(LocationOperand::REGISTER, rep, location.AsRegister()); } else { - return ExplicitOperand(LocationOperand::STACK_SLOT, machine_type, + return ExplicitOperand(LocationOperand::STACK_SLOT, rep, location.GetLocation()); } } @@ -144,19 +144,19 @@ class OperandGenerator { } InstructionOperand UseLocation(Node* node, LinkageLocation location, - MachineType type) { - return Use(node, ToUnallocatedOperand(location, type, GetVReg(node))); + MachineRepresentation rep) { + return Use(node, ToUnallocatedOperand(location, rep, GetVReg(node))); } // Used to force gap moves from the from_location to the to_location // immediately before an instruction. InstructionOperand UsePointerLocation(LinkageLocation to_location, LinkageLocation from_location) { - MachineType type = static_cast(kTypeAny | kMachPtr); + MachineRepresentation rep = MachineType::PointerRepresentation(); UnallocatedOperand casted_from_operand = - UnallocatedOperand::cast(TempLocation(from_location, type)); + UnallocatedOperand::cast(TempLocation(from_location, rep)); selector_->Emit(kArchNop, casted_from_operand); - return ToUnallocatedOperand(to_location, type, + return ToUnallocatedOperand(to_location, rep, casted_from_operand.virtual_register()); } @@ -170,7 +170,8 @@ class OperandGenerator { UnallocatedOperand op = UnallocatedOperand( UnallocatedOperand::MUST_HAVE_REGISTER, UnallocatedOperand::USED_AT_START, sequence()->NextVirtualRegister()); - sequence()->MarkAsRepresentation(kRepFloat64, op.virtual_register()); + sequence()->MarkAsRepresentation(MachineRepresentation::kFloat64, + op.virtual_register()); return op; } @@ -183,8 +184,9 @@ class OperandGenerator { return sequence()->AddImmediate(Constant(imm)); } - InstructionOperand TempLocation(LinkageLocation location, MachineType type) { - return ToUnallocatedOperand(location, type, + InstructionOperand TempLocation(LinkageLocation location, + MachineRepresentation rep) { + return ToUnallocatedOperand(location, rep, sequence()->NextVirtualRegister()); } @@ -250,7 +252,7 @@ class OperandGenerator { } UnallocatedOperand ToUnallocatedOperand(LinkageLocation location, - MachineType type, + MachineRepresentation rep, int virtual_register) { if (location.IsAnyRegister()) { // any machine register. @@ -268,8 +270,7 @@ class OperandGenerator { location.AsCalleeFrameSlot(), virtual_register); } // a fixed register. - MachineType rep = RepresentationOf(type); - if (rep == kRepFloat64 || rep == kRepFloat32) { + if (IsFloatingPoint(rep)) { return UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, location.AsRegister(), virtual_register); } diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc index 6baba281fb..66c9d8c233 100644 --- a/src/compiler/instruction-selector.cc +++ b/src/compiler/instruction-selector.cc @@ -241,16 +241,15 @@ void InstructionSelector::MarkAsUsed(Node* node) { } -void InstructionSelector::MarkAsRepresentation(MachineType rep, +void InstructionSelector::MarkAsRepresentation(MachineRepresentation rep, const InstructionOperand& op) { UnallocatedOperand unalloc = UnallocatedOperand::cast(op); - rep = RepresentationOf(rep); sequence()->MarkAsRepresentation(rep, unalloc.virtual_register()); } -void InstructionSelector::MarkAsRepresentation(MachineType rep, Node* node) { - rep = RepresentationOf(rep); +void InstructionSelector::MarkAsRepresentation(MachineRepresentation rep, + Node* node) { sequence()->MarkAsRepresentation(rep, GetVirtualRegister(node)); } @@ -310,7 +309,7 @@ void AddFrameStateInputs(Node* state, OperandGenerator* g, size_t value_index = 0; inputs->push_back( OperandForDeopt(g, function, FrameStateInputKind::kStackSlot)); - descriptor->SetType(value_index++, kMachAnyTagged); + descriptor->SetType(value_index++, MachineType::AnyTagged()); for (StateValuesAccess::TypedNode input_node : StateValuesAccess(parameters)) { inputs->push_back(OperandForDeopt(g, input_node.node, kind)); @@ -319,7 +318,7 @@ void AddFrameStateInputs(Node* state, OperandGenerator* g, if (descriptor->HasContext()) { inputs->push_back( OperandForDeopt(g, context, FrameStateInputKind::kStackSlot)); - descriptor->SetType(value_index++, kMachAnyTagged); + descriptor->SetType(value_index++, MachineType::AnyTagged()); } for (StateValuesAccess::TypedNode input_node : StateValuesAccess(locals)) { inputs->push_back(OperandForDeopt(g, input_node.node, kind)); @@ -418,9 +417,10 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, Node* output = buffer->output_nodes[i]; InstructionOperand op = - output == NULL ? g.TempLocation(location, type) - : g.DefineAsLocation(output, location, type); - MarkAsRepresentation(type, op); + output == NULL + ? g.TempLocation(location, type.representation()) + : g.DefineAsLocation(output, location, type.representation()); + MarkAsRepresentation(type.representation(), op); buffer->outputs.push_back(op); } @@ -448,7 +448,7 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, case CallDescriptor::kCallJSFunction: buffer->instruction_args.push_back( g.UseLocation(callee, buffer->descriptor->GetInputLocation(0), - buffer->descriptor->GetInputType(0))); + buffer->descriptor->GetInputType(0).representation())); break; case CallDescriptor::kLazyBailout: // The target is ignored, but we still need to pass a value here. @@ -495,7 +495,8 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, location, stack_param_delta); } InstructionOperand op = - g.UseLocation(*iter, location, buffer->descriptor->GetInputType(index)); + g.UseLocation(*iter, location, + buffer->descriptor->GetInputType(index).representation()); if (UnallocatedOperand::cast(op).HasFixedSlotPolicy() && !call_tail) { int stack_index = -UnallocatedOperand::cast(op).fixed_slot_index() - 1; if (static_cast(stack_index) >= buffer->pushed_nodes.size()) { @@ -681,14 +682,14 @@ void InstructionSelector::VisitNode(Node* node) { case IrOpcode::kParameter: { MachineType type = linkage()->GetParameterType(ParameterIndexOf(node->op())); - MarkAsRepresentation(type, node); + MarkAsRepresentation(type.representation(), node); return VisitParameter(node); } case IrOpcode::kOsrValue: return MarkAsReference(node), VisitOsrValue(node); case IrOpcode::kPhi: { - MachineType type = OpParameter(node); - MarkAsRepresentation(type, node); + MachineRepresentation rep = PhiRepresentationOf(node->op()); + MarkAsRepresentation(rep, node); return VisitPhi(node); } case IrOpcode::kProjection: @@ -714,8 +715,8 @@ void InstructionSelector::VisitNode(Node* node) { case IrOpcode::kStateValues: return; case IrOpcode::kLoad: { - LoadRepresentation rep = OpParameter(node); - MarkAsRepresentation(rep, node); + LoadRepresentation type = LoadRepresentationOf(node->op()); + MarkAsRepresentation(type.representation(), node); return VisitLoad(node); } case IrOpcode::kStore: @@ -937,7 +938,8 @@ void InstructionSelector::VisitNode(Node* node) { case IrOpcode::kLoadFramePointer: return VisitLoadFramePointer(node); case IrOpcode::kCheckedLoad: { - MachineType rep = OpParameter(node); + MachineRepresentation rep = + CheckedLoadRepresentationOf(node->op()).representation(); MarkAsRepresentation(rep, node); return VisitCheckedLoad(node); } @@ -1161,8 +1163,9 @@ void InstructionSelector::VisitParameter(Node* node) { ? g.DefineAsDualLocation( node, linkage()->GetParameterLocation(index), linkage()->GetParameterSecondaryLocation(index)) - : g.DefineAsLocation(node, linkage()->GetParameterLocation(index), - linkage()->GetParameterType(index)); + : g.DefineAsLocation( + node, linkage()->GetParameterLocation(index), + linkage()->GetParameterType(index).representation()); Emit(kArchNop, op); } @@ -1173,8 +1176,9 @@ void InstructionSelector::VisitIfException(Node* node) { Node* call = node->InputAt(1); DCHECK_EQ(IrOpcode::kCall, call->opcode()); const CallDescriptor* descriptor = OpParameter(call); - Emit(kArchNop, g.DefineAsLocation(node, descriptor->GetReturnLocation(0), - descriptor->GetReturnType(0))); + Emit(kArchNop, + g.DefineAsLocation(node, descriptor->GetReturnLocation(0), + descriptor->GetReturnType(0).representation())); } @@ -1182,7 +1186,7 @@ void InstructionSelector::VisitOsrValue(Node* node) { OperandGenerator g(this); int index = OpParameter(node); Emit(kArchNop, g.DefineAsLocation(node, linkage()->GetOsrValueLocation(index), - kMachAnyTagged)); + MachineRepresentation::kTagged)); } @@ -1399,7 +1403,7 @@ void InstructionSelector::VisitReturn(Node* ret) { for (int i = 0; i < ret_count; ++i) { value_locations[i] = g.UseLocation(ret->InputAt(i), linkage()->GetReturnLocation(i), - linkage()->GetReturnType(i)); + linkage()->GetReturnType(i).representation()); } Emit(kArchRet, 0, nullptr, ret_count, value_locations); } diff --git a/src/compiler/instruction-selector.h b/src/compiler/instruction-selector.h index 0333de89c3..f5aed714cb 100644 --- a/src/compiler/instruction-selector.h +++ b/src/compiler/instruction-selector.h @@ -153,16 +153,27 @@ class InstructionSelector final { // Inform the register allocation of the representation of the value produced // by {node}. - void MarkAsRepresentation(MachineType rep, Node* node); - void MarkAsWord32(Node* node) { MarkAsRepresentation(kRepWord32, node); } - void MarkAsWord64(Node* node) { MarkAsRepresentation(kRepWord64, node); } - void MarkAsFloat32(Node* node) { MarkAsRepresentation(kRepFloat32, node); } - void MarkAsFloat64(Node* node) { MarkAsRepresentation(kRepFloat64, node); } - void MarkAsReference(Node* node) { MarkAsRepresentation(kRepTagged, node); } + void MarkAsRepresentation(MachineRepresentation rep, Node* node); + void MarkAsWord32(Node* node) { + MarkAsRepresentation(MachineRepresentation::kWord32, node); + } + void MarkAsWord64(Node* node) { + MarkAsRepresentation(MachineRepresentation::kWord64, node); + } + void MarkAsFloat32(Node* node) { + MarkAsRepresentation(MachineRepresentation::kFloat32, node); + } + void MarkAsFloat64(Node* node) { + MarkAsRepresentation(MachineRepresentation::kFloat64, node); + } + void MarkAsReference(Node* node) { + MarkAsRepresentation(MachineRepresentation::kTagged, node); + } // Inform the register allocation of the representation of the unallocated // operand {op}. - void MarkAsRepresentation(MachineType rep, const InstructionOperand& op); + void MarkAsRepresentation(MachineRepresentation rep, + const InstructionOperand& op); enum CallBufferFlag { kCallCodeImmediate = 1u << 0, diff --git a/src/compiler/instruction.cc b/src/compiler/instruction.cc index 1f9543a635..e3aa1e797a 100644 --- a/src/compiler/instruction.cc +++ b/src/compiler/instruction.cc @@ -122,20 +122,20 @@ std::ostream& operator<<(std::ostream& os, if (allocated.IsExplicit()) { os << "|E"; } - switch (allocated.machine_type()) { - case kRepWord32: + switch (allocated.representation()) { + case MachineRepresentation::kWord32: os << "|w32"; break; - case kRepWord64: + case MachineRepresentation::kWord64: os << "|w64"; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: os << "|f32"; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: os << "|f64"; break; - case kRepTagged: + case MachineRepresentation::kTagged: os << "|t"; break; default: @@ -195,12 +195,12 @@ MoveOperands* ParallelMove::PrepareInsertAfter(MoveOperands* move) const { } -ExplicitOperand::ExplicitOperand(LocationKind kind, MachineType machine_type, +ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep, int index) - : LocationOperand(EXPLICIT, kind, machine_type, index) { - DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(machine_type), + : LocationOperand(EXPLICIT, kind, rep, index) { + DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(rep), Register::from_code(index).IsAllocatable()); - DCHECK_IMPLIES(kind == REGISTER && IsFloatingPoint(machine_type), + DCHECK_IMPLIES(kind == REGISTER && IsFloatingPoint(rep), DoubleRegister::from_code(index).IsAllocatable()); } @@ -656,28 +656,28 @@ InstructionBlock* InstructionSequence::GetInstructionBlock( } -static MachineType FilterRepresentation(MachineType rep) { - DCHECK_EQ(rep, RepresentationOf(rep)); +static MachineRepresentation FilterRepresentation(MachineRepresentation rep) { switch (rep) { - case kRepBit: - case kRepWord8: - case kRepWord16: + case MachineRepresentation::kBit: + case MachineRepresentation::kWord8: + case MachineRepresentation::kWord16: return InstructionSequence::DefaultRepresentation(); - case kRepWord32: - case kRepWord64: - case kRepFloat32: - case kRepFloat64: - case kRepTagged: + case MachineRepresentation::kWord32: + case MachineRepresentation::kWord64: + case MachineRepresentation::kFloat32: + case MachineRepresentation::kFloat64: + case MachineRepresentation::kTagged: return rep; default: break; } UNREACHABLE(); - return kMachNone; + return MachineRepresentation::kNone; } -MachineType InstructionSequence::GetRepresentation(int virtual_register) const { +MachineRepresentation InstructionSequence::GetRepresentation( + int virtual_register) const { DCHECK_LE(0, virtual_register); DCHECK_LT(virtual_register, VirtualRegisterCount()); if (virtual_register >= static_cast(representations_.size())) { @@ -687,17 +687,17 @@ MachineType InstructionSequence::GetRepresentation(int virtual_register) const { } -void InstructionSequence::MarkAsRepresentation(MachineType machine_type, +void InstructionSequence::MarkAsRepresentation(MachineRepresentation rep, int virtual_register) { DCHECK_LE(0, virtual_register); DCHECK_LT(virtual_register, VirtualRegisterCount()); if (virtual_register >= static_cast(representations_.size())) { representations_.resize(VirtualRegisterCount(), DefaultRepresentation()); } - machine_type = FilterRepresentation(machine_type); - DCHECK_IMPLIES(representations_[virtual_register] != machine_type, + rep = FilterRepresentation(rep); + DCHECK_IMPLIES(representations_[virtual_register] != rep, representations_[virtual_register] == DefaultRepresentation()); - representations_[virtual_register] = machine_type; + representations_[virtual_register] = rep; } @@ -759,7 +759,7 @@ FrameStateDescriptor::FrameStateDescriptor( types_(zone), shared_info_(shared_info), outer_state_(outer_state) { - types_.resize(GetSize(), kMachNone); + types_.resize(GetSize(), MachineType::None()); } diff --git a/src/compiler/instruction.h b/src/compiler/instruction.h index 5c052ac3c5..f15a0ecfaa 100644 --- a/src/compiler/instruction.h +++ b/src/compiler/instruction.h @@ -392,12 +392,12 @@ class LocationOperand : public InstructionOperand { LocationOperand(InstructionOperand::Kind operand_kind, LocationOperand::LocationKind location_kind, - MachineType machine_type, int index) + MachineRepresentation rep, int index) : InstructionOperand(operand_kind) { DCHECK_IMPLIES(location_kind == REGISTER, index >= 0); - DCHECK(IsSupportedMachineType(machine_type)); + DCHECK(IsSupportedRepresentation(rep)); value_ |= LocationKindField::encode(location_kind); - value_ |= MachineTypeField::encode(machine_type); + value_ |= RepresentationField::encode(rep); value_ |= static_cast(index) << IndexField::kShift; } @@ -422,16 +422,17 @@ class LocationOperand : public InstructionOperand { return LocationKindField::decode(value_); } - MachineType machine_type() const { return MachineTypeField::decode(value_); } + MachineRepresentation representation() const { + return RepresentationField::decode(value_); + } - static bool IsSupportedMachineType(MachineType machine_type) { - if (RepresentationOf(machine_type) != machine_type) return false; - switch (machine_type) { - case kRepWord32: - case kRepWord64: - case kRepFloat32: - case kRepFloat64: - case kRepTagged: + static bool IsSupportedRepresentation(MachineRepresentation rep) { + switch (rep) { + case MachineRepresentation::kWord32: + case MachineRepresentation::kWord64: + case MachineRepresentation::kFloat32: + case MachineRepresentation::kFloat64: + case MachineRepresentation::kTagged: return true; default: return false; @@ -455,19 +456,18 @@ class LocationOperand : public InstructionOperand { STATIC_ASSERT(KindField::kSize == 3); class LocationKindField : public BitField64 {}; - class MachineTypeField : public BitField64 {}; + class RepresentationField : public BitField64 {}; class IndexField : public BitField64 {}; }; class ExplicitOperand : public LocationOperand { public: - ExplicitOperand(LocationKind kind, MachineType machine_type, int index); + ExplicitOperand(LocationKind kind, MachineRepresentation rep, int index); static ExplicitOperand* New(Zone* zone, LocationKind kind, - MachineType machine_type, int index) { - return InstructionOperand::New(zone, - ExplicitOperand(kind, machine_type, index)); + MachineRepresentation rep, int index) { + return InstructionOperand::New(zone, ExplicitOperand(kind, rep, index)); } INSTRUCTION_OPERAND_CASTS(ExplicitOperand, EXPLICIT); @@ -476,13 +476,12 @@ class ExplicitOperand : public LocationOperand { class AllocatedOperand : public LocationOperand { public: - AllocatedOperand(LocationKind kind, MachineType machine_type, int index) - : LocationOperand(ALLOCATED, kind, machine_type, index) {} + AllocatedOperand(LocationKind kind, MachineRepresentation rep, int index) + : LocationOperand(ALLOCATED, kind, rep, index) {} static AllocatedOperand* New(Zone* zone, LocationKind kind, - MachineType machine_type, int index) { - return InstructionOperand::New(zone, - AllocatedOperand(kind, machine_type, index)); + MachineRepresentation rep, int index) { + return InstructionOperand::New(zone, AllocatedOperand(kind, rep, index)); } INSTRUCTION_OPERAND_CASTS(AllocatedOperand, ALLOCATED); @@ -496,40 +495,40 @@ bool InstructionOperand::IsRegister() const { return (IsAllocated() || IsExplicit()) && LocationOperand::cast(this)->location_kind() == LocationOperand::REGISTER && - !IsFloatingPoint(LocationOperand::cast(this)->machine_type()); + !IsFloatingPoint(LocationOperand::cast(this)->representation()); } bool InstructionOperand::IsDoubleRegister() const { return (IsAllocated() || IsExplicit()) && LocationOperand::cast(this)->location_kind() == LocationOperand::REGISTER && - IsFloatingPoint(LocationOperand::cast(this)->machine_type()); + IsFloatingPoint(LocationOperand::cast(this)->representation()); } bool InstructionOperand::IsStackSlot() const { return (IsAllocated() || IsExplicit()) && LocationOperand::cast(this)->location_kind() == LocationOperand::STACK_SLOT && - !IsFloatingPoint(LocationOperand::cast(this)->machine_type()); + !IsFloatingPoint(LocationOperand::cast(this)->representation()); } bool InstructionOperand::IsDoubleStackSlot() const { return (IsAllocated() || IsExplicit()) && LocationOperand::cast(this)->location_kind() == LocationOperand::STACK_SLOT && - IsFloatingPoint(LocationOperand::cast(this)->machine_type()); + IsFloatingPoint(LocationOperand::cast(this)->representation()); } uint64_t InstructionOperand::GetCanonicalizedValue() const { if (IsAllocated() || IsExplicit()) { // TODO(dcarney): put machine type last and mask. - MachineType canonicalized_machine_type = - IsFloatingPoint(LocationOperand::cast(this)->machine_type()) - ? kMachFloat64 - : kMachNone; + MachineRepresentation canonicalized_representation = + IsFloatingPoint(LocationOperand::cast(this)->representation()) + ? MachineRepresentation::kFloat64 + : MachineRepresentation::kNone; return InstructionOperand::KindField::update( - LocationOperand::MachineTypeField::update(this->value_, - canonicalized_machine_type), + LocationOperand::RepresentationField::update( + this->value_, canonicalized_representation), LocationOperand::EXPLICIT); } return this->value_; @@ -1131,19 +1130,20 @@ class InstructionSequence final : public ZoneObject { InstructionBlock* GetInstructionBlock(int instruction_index) const; - static MachineType DefaultRepresentation() { - return kPointerSize == 8 ? kRepWord64 : kRepWord32; + static MachineRepresentation DefaultRepresentation() { + return MachineType::PointerRepresentation(); } - MachineType GetRepresentation(int virtual_register) const; - void MarkAsRepresentation(MachineType machine_type, int virtual_register); + MachineRepresentation GetRepresentation(int virtual_register) const; + void MarkAsRepresentation(MachineRepresentation rep, int virtual_register); bool IsReference(int virtual_register) const { - return GetRepresentation(virtual_register) == kRepTagged; + return GetRepresentation(virtual_register) == + MachineRepresentation::kTagged; } bool IsFloat(int virtual_register) const { switch (GetRepresentation(virtual_register)) { - case kRepFloat32: - case kRepFloat64: + case MachineRepresentation::kFloat32: + case MachineRepresentation::kFloat64: return true; default: return false; @@ -1263,7 +1263,7 @@ class InstructionSequence final : public ZoneObject { InstructionDeque instructions_; int next_virtual_register_; ReferenceMapDeque reference_maps_; - ZoneVector representations_; + ZoneVector representations_; DeoptimizationVector deoptimization_entries_; DISALLOW_COPY_AND_ASSIGN(InstructionSequence); diff --git a/src/compiler/interpreter-assembler.cc b/src/compiler/interpreter-assembler.cc index fa2612354f..3179895c92 100644 --- a/src/compiler/interpreter-assembler.cc +++ b/src/compiler/interpreter-assembler.cc @@ -30,7 +30,8 @@ InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone, : bytecode_(bytecode), raw_assembler_(new RawMachineAssembler( isolate, new (zone) Graph(zone), - Linkage::GetInterpreterDispatchDescriptor(zone), kMachPtr, + Linkage::GetInterpreterDispatchDescriptor(zone), + MachineType::PointerRepresentation(), InstructionSelector::SupportedMachineOperatorFlags())), accumulator_( raw_assembler_->Parameter(Linkage::kInterpreterAccumulatorParameter)), @@ -112,21 +113,22 @@ Node* InterpreterAssembler::RegisterLocation(Node* reg_index) { Node* InterpreterAssembler::LoadRegister(interpreter::Register reg) { return raw_assembler_->Load( - kMachAnyTagged, RegisterFileRawPointer(), + MachineType::AnyTagged(), RegisterFileRawPointer(), RegisterFrameOffset(Int32Constant(reg.ToOperand()))); } Node* InterpreterAssembler::LoadRegister(Node* reg_index) { - return raw_assembler_->Load(kMachAnyTagged, RegisterFileRawPointer(), + return raw_assembler_->Load(MachineType::AnyTagged(), + RegisterFileRawPointer(), RegisterFrameOffset(reg_index)); } Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { - return raw_assembler_->Store(kMachAnyTagged, RegisterFileRawPointer(), - RegisterFrameOffset(reg_index), value, - kNoWriteBarrier); + return raw_assembler_->Store( + MachineType::AnyTagged(), RegisterFileRawPointer(), + RegisterFrameOffset(reg_index), value, kNoWriteBarrier); } @@ -135,7 +137,7 @@ Node* InterpreterAssembler::BytecodeOperand(int operand_index) { DCHECK_EQ(interpreter::OperandSize::kByte, interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); return raw_assembler_->Load( - kMachUint8, BytecodeArrayTaggedPointer(), + MachineType::Uint8(), BytecodeArrayTaggedPointer(), IntPtrAdd(BytecodeOffset(), Int32Constant(interpreter::Bytecodes::GetOperandOffset( bytecode_, operand_index)))); @@ -147,7 +149,7 @@ Node* InterpreterAssembler::BytecodeOperandSignExtended(int operand_index) { DCHECK_EQ(interpreter::OperandSize::kByte, interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); Node* load = raw_assembler_->Load( - kMachInt8, BytecodeArrayTaggedPointer(), + MachineType::Int8(), BytecodeArrayTaggedPointer(), IntPtrAdd(BytecodeOffset(), Int32Constant(interpreter::Bytecodes::GetOperandOffset( bytecode_, operand_index)))); @@ -165,7 +167,7 @@ Node* InterpreterAssembler::BytecodeOperandShort(int operand_index) { interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); if (TargetSupportsUnalignedAccess()) { return raw_assembler_->Load( - kMachUint16, BytecodeArrayTaggedPointer(), + MachineType::Uint16(), BytecodeArrayTaggedPointer(), IntPtrAdd(BytecodeOffset(), Int32Constant(interpreter::Bytecodes::GetOperandOffset( bytecode_, operand_index)))); @@ -173,10 +175,10 @@ Node* InterpreterAssembler::BytecodeOperandShort(int operand_index) { int offset = interpreter::Bytecodes::GetOperandOffset(bytecode_, operand_index); Node* first_byte = raw_assembler_->Load( - kMachUint8, BytecodeArrayTaggedPointer(), + MachineType::Uint8(), BytecodeArrayTaggedPointer(), IntPtrAdd(BytecodeOffset(), Int32Constant(offset))); Node* second_byte = raw_assembler_->Load( - kMachUint8, BytecodeArrayTaggedPointer(), + MachineType::Uint8(), BytecodeArrayTaggedPointer(), IntPtrAdd(BytecodeOffset(), Int32Constant(offset + 1))); #if V8_TARGET_LITTLE_ENDIAN return raw_assembler_->WordOr(WordShl(second_byte, kBitsPerByte), @@ -308,7 +310,8 @@ Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) { Node* entry_offset = IntPtrAdd(IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), WordShl(index, kPointerSizeLog2)); - return raw_assembler_->Load(kMachAnyTagged, constant_pool, entry_offset); + return raw_assembler_->Load(MachineType::AnyTagged(), constant_pool, + entry_offset); } @@ -317,18 +320,19 @@ Node* InterpreterAssembler::LoadFixedArrayElement(Node* fixed_array, Node* entry_offset = IntPtrAdd(IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), WordShl(Int32Constant(index), kPointerSizeLog2)); - return raw_assembler_->Load(kMachAnyTagged, fixed_array, entry_offset); + return raw_assembler_->Load(MachineType::AnyTagged(), fixed_array, + entry_offset); } Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) { - return raw_assembler_->Load(kMachAnyTagged, object, + return raw_assembler_->Load(MachineType::AnyTagged(), object, IntPtrConstant(offset - kHeapObjectTag)); } Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) { - return raw_assembler_->Load(kMachAnyTagged, context, + return raw_assembler_->Load(MachineType::AnyTagged(), context, IntPtrConstant(Context::SlotOffset(slot_index))); } @@ -337,7 +341,7 @@ Node* InterpreterAssembler::LoadContextSlot(Node* context, Node* slot_index) { Node* offset = IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), Int32Constant(Context::kHeaderSize - kHeapObjectTag)); - return raw_assembler_->Load(kMachAnyTagged, context, offset); + return raw_assembler_->Load(MachineType::AnyTagged(), context, offset); } @@ -346,14 +350,14 @@ Node* InterpreterAssembler::StoreContextSlot(Node* context, Node* slot_index, Node* offset = IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), Int32Constant(Context::kHeaderSize - kHeapObjectTag)); - return raw_assembler_->Store(kMachAnyTagged, context, offset, value, + return raw_assembler_->Store(MachineType::AnyTagged(), context, offset, value, kFullWriteBarrier); } Node* InterpreterAssembler::LoadTypeFeedbackVector() { Node* function = raw_assembler_->Load( - kMachAnyTagged, RegisterFileRawPointer(), + MachineType::AnyTagged(), RegisterFileRawPointer(), IntPtrConstant(InterpreterFrameConstants::kFunctionFromRegisterPointer)); Node* shared_info = LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset); @@ -477,8 +481,9 @@ Node* InterpreterAssembler::CallRuntime(Node* function_id, Node* first_arg, Node* function_offset = raw_assembler_->Int32Mul( function_id, Int32Constant(sizeof(Runtime::Function))); Node* function = IntPtrAdd(function_table, function_offset); - Node* function_entry = raw_assembler_->Load( - kMachPtr, function, Int32Constant(offsetof(Runtime::Function, entry))); + Node* function_entry = + raw_assembler_->Load(MachineType::Pointer(), function, + Int32Constant(offsetof(Runtime::Function, entry))); Node** args = zone()->NewArray(4); args[0] = arg_count; @@ -562,12 +567,12 @@ void InterpreterAssembler::Dispatch() { void InterpreterAssembler::DispatchTo(Node* new_bytecode_offset) { Node* target_bytecode = raw_assembler_->Load( - kMachUint8, BytecodeArrayTaggedPointer(), new_bytecode_offset); + MachineType::Uint8(), BytecodeArrayTaggedPointer(), new_bytecode_offset); // TODO(rmcilroy): Create a code target dispatch table to avoid conversion // from code object on every dispatch. Node* target_code_object = raw_assembler_->Load( - kMachPtr, DispatchTableRawPointer(), + MachineType::Pointer(), DispatchTableRawPointer(), raw_assembler_->Word32Shl(target_bytecode, Int32Constant(kPointerSizeLog2))); diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc index 3e06c4f6f5..a7a7da57cd 100644 --- a/src/compiler/js-builtin-reducer.cc +++ b/src/compiler/js-builtin-reducer.cc @@ -107,7 +107,7 @@ Reduction JSBuiltinReducer::ReduceMathMax(Node* node) { for (int i = 1; i < r.GetJSCallArity(); i++) { Node* const input = r.GetJSCallInput(i); value = graph()->NewNode( - common()->Select(kMachNone), + common()->Select(MachineRepresentation::kNone), graph()->NewNode(simplified()->NumberLessThan(), input, value), value, input); } diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc index f44cc414a5..eca6f352a5 100644 --- a/src/compiler/js-generic-lowering.cc +++ b/src/compiler/js-generic-lowering.cc @@ -159,7 +159,7 @@ void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, CallDescriptor* desc_compare = Linkage::GetStubCallDescriptor( isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node), - Operator::kNoProperties, kMachIntPtr); + Operator::kNoProperties, MachineType::IntPtr()); Node* compare = graph()->NewNode(common()->Call(desc_compare), static_cast(inputs.size()), &inputs.front()); @@ -204,7 +204,8 @@ void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, node->ReplaceInput(0, booleanize); node->ReplaceInput(1, true_value); node->ReplaceInput(2, false_value); - NodeProperties::ChangeOp(node, common()->Select(kMachAnyTagged)); + NodeProperties::ChangeOp(node, + common()->Select(MachineRepresentation::kTagged)); } @@ -307,12 +308,12 @@ void JSGenericLowering::LowerJSLoadGlobal(Node* node) { isolate(), p.typeof_mode(), SLOPPY, UNINITIALIZED); // Load global object from the context. Node* native_context = - graph()->NewNode(machine()->Load(kMachAnyTagged), context, + graph()->NewNode(machine()->Load(MachineType::AnyTagged()), context, jsgraph()->IntPtrConstant( Context::SlotOffset(Context::NATIVE_CONTEXT_INDEX)), effect, graph()->start()); Node* global = graph()->NewNode( - machine()->Load(kMachAnyTagged), native_context, + machine()->Load(MachineType::AnyTagged()), native_context, jsgraph()->IntPtrConstant(Context::SlotOffset(Context::EXTENSION_INDEX)), effect, graph()->start()); node->InsertInput(zone(), 0, global); @@ -357,12 +358,12 @@ void JSGenericLowering::LowerJSStoreGlobal(Node* node) { isolate(), p.language_mode(), UNINITIALIZED); // Load global object from the context. Node* native_context = - graph()->NewNode(machine()->Load(kMachAnyTagged), context, + graph()->NewNode(machine()->Load(MachineType::AnyTagged()), context, jsgraph()->IntPtrConstant( Context::SlotOffset(Context::NATIVE_CONTEXT_INDEX)), effect, graph()->start()); Node* global = graph()->NewNode( - machine()->Load(kMachAnyTagged), native_context, + machine()->Load(MachineType::AnyTagged()), native_context, jsgraph()->IntPtrConstant(Context::SlotOffset(Context::EXTENSION_INDEX)), effect, graph()->start()); node->InsertInput(zone(), 0, global); @@ -398,7 +399,7 @@ void JSGenericLowering::LowerJSLoadContext(Node* node) { const ContextAccess& access = ContextAccessOf(node->op()); for (size_t i = 0; i < access.depth(); ++i) { node->ReplaceInput( - 0, graph()->NewNode(machine()->Load(kMachAnyTagged), + 0, graph()->NewNode(machine()->Load(MachineType::AnyTagged()), NodeProperties::GetValueInput(node, 0), jsgraph()->Int32Constant( Context::SlotOffset(Context::PREVIOUS_INDEX)), @@ -408,7 +409,7 @@ void JSGenericLowering::LowerJSLoadContext(Node* node) { node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset( static_cast(access.index())))); node->AppendInput(zone(), graph()->start()); - NodeProperties::ChangeOp(node, machine()->Load(kMachAnyTagged)); + NodeProperties::ChangeOp(node, machine()->Load(MachineType::AnyTagged())); } @@ -416,7 +417,7 @@ void JSGenericLowering::LowerJSStoreContext(Node* node) { const ContextAccess& access = ContextAccessOf(node->op()); for (size_t i = 0; i < access.depth(); ++i) { node->ReplaceInput( - 0, graph()->NewNode(machine()->Load(kMachAnyTagged), + 0, graph()->NewNode(machine()->Load(MachineType::AnyTagged()), NodeProperties::GetValueInput(node, 0), jsgraph()->Int32Constant( Context::SlotOffset(Context::PREVIOUS_INDEX)), @@ -426,8 +427,9 @@ void JSGenericLowering::LowerJSStoreContext(Node* node) { node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset( static_cast(access.index())))); - NodeProperties::ChangeOp(node, machine()->Store(StoreRepresentation( - kMachAnyTagged, kFullWriteBarrier))); + NodeProperties::ChangeOp( + node, machine()->Store(StoreRepresentation(MachineType::AnyTagged(), + kFullWriteBarrier))); } @@ -626,11 +628,11 @@ void JSGenericLowering::LowerJSForInPrepare(Node* node) { control = graph()->NewNode(common()->IfSuccess(), cache_type); Node* object_map = effect = graph()->NewNode( - machine()->Load(kMachAnyTagged), object, + machine()->Load(MachineType::AnyTagged()), object, jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), effect, control); Node* cache_type_map = effect = graph()->NewNode( - machine()->Load(kMachAnyTagged), cache_type, + machine()->Load(MachineType::AnyTagged()), cache_type, jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), effect, control); Node* meta_map = jsgraph()->HeapConstant(isolate()->factory()->meta_map()); @@ -651,7 +653,7 @@ void JSGenericLowering::LowerJSForInPrepare(Node* node) { { // Enum cache case. Node* cache_type_enum_length = etrue0 = graph()->NewNode( - machine()->Load(kMachUint32), cache_type, + machine()->Load(MachineType::Uint32()), cache_type, jsgraph()->IntPtrConstant(Map::kBitField3Offset - kHeapObjectTag), effect, if_true0); cache_type_enum_length = @@ -680,16 +682,16 @@ void JSGenericLowering::LowerJSForInPrepare(Node* node) { { // Load the enumeration cache from the instance descriptors of {object}. Node* object_map_descriptors = efalse1 = graph()->NewNode( - machine()->Load(kMachAnyTagged), object_map, + machine()->Load(MachineType::AnyTagged()), object_map, jsgraph()->IntPtrConstant(Map::kDescriptorsOffset - kHeapObjectTag), etrue0, if_false1); Node* object_map_enum_cache = efalse1 = graph()->NewNode( - machine()->Load(kMachAnyTagged), object_map_descriptors, + machine()->Load(MachineType::AnyTagged()), object_map_descriptors, jsgraph()->IntPtrConstant(DescriptorArray::kEnumCacheOffset - kHeapObjectTag), efalse1, if_false1); cache_array_false1 = efalse1 = graph()->NewNode( - machine()->Load(kMachAnyTagged), object_map_enum_cache, + machine()->Load(MachineType::AnyTagged()), object_map_enum_cache, jsgraph()->IntPtrConstant( DescriptorArray::kEnumCacheBridgeCacheOffset - kHeapObjectTag), efalse1, if_false1); @@ -699,8 +701,8 @@ void JSGenericLowering::LowerJSForInPrepare(Node* node) { etrue0 = graph()->NewNode(common()->EffectPhi(2), etrue1, efalse1, if_true0); cache_array_true0 = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), cache_array_true1, - cache_array_false1, if_true0); + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + cache_array_true1, cache_array_false1, if_true0); cache_length_true0 = graph()->NewNode( machine()->WordShl(), @@ -720,7 +722,7 @@ void JSGenericLowering::LowerJSForInPrepare(Node* node) { { // FixedArray case. Node* object_instance_type = efalse0 = graph()->NewNode( - machine()->Load(kMachUint8), object_map, + machine()->Load(MachineType::Uint8()), object_map, jsgraph()->IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag), effect, if_false0); @@ -738,12 +740,12 @@ void JSGenericLowering::LowerJSForInPrepare(Node* node) { if_false0 = graph()->NewNode(common()->Merge(2), if_true1, if_false1); cache_type_false0 = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), cache_type_true1, - cache_type_false1, if_false0); + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + cache_type_true1, cache_type_false1, if_false0); cache_array_false0 = cache_type; cache_length_false0 = efalse0 = graph()->NewNode( - machine()->Load(kMachAnyTagged), cache_array_false0, + machine()->Load(MachineType::AnyTagged()), cache_array_false0, jsgraph()->IntPtrConstant(FixedArray::kLengthOffset - kHeapObjectTag), efalse0, if_false0); } @@ -751,13 +753,14 @@ void JSGenericLowering::LowerJSForInPrepare(Node* node) { control = graph()->NewNode(common()->Merge(2), if_true0, if_false0); effect = graph()->NewNode(common()->EffectPhi(2), etrue0, efalse0, control); Node* cache_array = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), cache_array_true0, - cache_array_false0, control); + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + cache_array_true0, cache_array_false0, control); Node* cache_length = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), cache_length_true0, - cache_length_false0, control); - cache_type = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), - cache_type_true0, cache_type_false0, control); + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + cache_length_true0, cache_length_false0, control); + cache_type = + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + cache_type_true0, cache_type_false0, control); for (auto edge : node->use_edges()) { if (NodeProperties::IsEffectEdge(edge)) { @@ -807,7 +810,7 @@ void JSGenericLowering::LowerJSLoadMessage(Node* node) { node->RemoveInput(NodeProperties::FirstContextIndex(node)); node->InsertInput(zone(), 0, jsgraph()->ExternalConstant(message_address)); node->InsertInput(zone(), 1, jsgraph()->IntPtrConstant(0)); - NodeProperties::ChangeOp(node, machine()->Load(kMachAnyTagged)); + NodeProperties::ChangeOp(node, machine()->Load(MachineType::AnyTagged())); } @@ -817,7 +820,7 @@ void JSGenericLowering::LowerJSStoreMessage(Node* node) { node->RemoveInput(NodeProperties::FirstContextIndex(node)); node->InsertInput(zone(), 0, jsgraph()->ExternalConstant(message_address)); node->InsertInput(zone(), 1, jsgraph()->IntPtrConstant(0)); - StoreRepresentation representation(kMachAnyTagged, kNoWriteBarrier); + StoreRepresentation representation(MachineType::AnyTagged(), kNoWriteBarrier); NodeProperties::ChangeOp(node, machine()->Store(representation)); } @@ -830,7 +833,7 @@ void JSGenericLowering::LowerJSStackCheck(Node* node) { Node* control = NodeProperties::GetControlInput(node); Node* limit = graph()->NewNode( - machine()->Load(kMachPtr), + machine()->Load(MachineType::Pointer()), jsgraph()->ExternalConstant( ExternalReference::address_of_stack_limit(isolate())), jsgraph()->IntPtrConstant(0), effect, control); diff --git a/src/compiler/js-inlining.cc b/src/compiler/js-inlining.cc index 74ac82799a..d9f4e4968c 100644 --- a/src/compiler/js-inlining.cc +++ b/src/compiler/js-inlining.cc @@ -223,7 +223,7 @@ Reduction JSInliner::InlineCall(Node* call, Node* new_target, Node* context, values.push_back(control_output); effects.push_back(control_output); Node* value_output = jsgraph_->graph()->NewNode( - jsgraph_->common()->Phi(kMachAnyTagged, input_count), + jsgraph_->common()->Phi(MachineRepresentation::kTagged, input_count), static_cast(values.size()), &values.front()); Node* effect_output = jsgraph_->graph()->NewNode( jsgraph_->common()->EffectPhi(input_count), @@ -455,7 +455,8 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle function) { jsgraph_->javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), node, context, node, start); Node* select = jsgraph_->graph()->NewNode( - jsgraph_->common()->Select(kMachAnyTagged), check, node, create); + jsgraph_->common()->Select(MachineRepresentation::kTagged), check, node, + create); NodeProperties::ReplaceUses(node, select, check, node, node); NodeProperties::ReplaceValueInput(select, node, 1); NodeProperties::ReplaceValueInput(check, node, 0); diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc index bba3749532..9acab4bbe0 100644 --- a/src/compiler/js-intrinsic-lowering.cc +++ b/src/compiler/js-intrinsic-lowering.cc @@ -210,8 +210,6 @@ Reduction JSIntrinsicLowering::ReduceIsInstanceType( // } else { // return %_GetInstanceType(%_GetMap(value)) == instance_type; // } - MachineType const type = static_cast(kTypeBool | kRepTagged); - Node* value = NodeProperties::GetValueInput(node, 0); Node* effect = NodeProperties::GetEffectInput(node); Node* control = NodeProperties::GetControlInput(node); @@ -239,7 +237,8 @@ Reduction JSIntrinsicLowering::ReduceIsInstanceType( ReplaceWithValue(node, node, ephi); // Turn the {node} into a Phi. - return Change(node, common()->Phi(type, 2), vtrue, vfalse, merge); + return Change(node, common()->Phi(MachineRepresentation::kTagged, 2), vtrue, + vfalse, merge); } @@ -279,8 +278,8 @@ Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) { control = graph()->NewNode(common()->Merge(2), if_true, if_false); effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); - value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vtrue, vfalse, - control); + value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + vtrue, vfalse, control); } ReplaceWithValue(node, node, effect, control); return Replace(value); @@ -346,7 +345,8 @@ Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) { // } const Operator* const merge_op = common()->Merge(2); const Operator* const ephi_op = common()->EffectPhi(2); - const Operator* const phi_op = common()->Phi(kMachAnyTagged, 2); + const Operator* const phi_op = + common()->Phi(MachineRepresentation::kTagged, 2); Node* value = NodeProperties::GetValueInput(node, 0); Node* effect = NodeProperties::GetEffectInput(node); @@ -511,7 +511,7 @@ Reduction JSIntrinsicLowering::ReduceToLength(Node* node) { } else { if (value_type->Min() <= 0.0) { value = graph()->NewNode( - common()->Select(kMachAnyTagged), + common()->Select(MachineRepresentation::kTagged), graph()->NewNode(simplified()->NumberLessThanOrEqual(), value, jsgraph()->ZeroConstant()), jsgraph()->ZeroConstant(), value); @@ -520,7 +520,7 @@ Reduction JSIntrinsicLowering::ReduceToLength(Node* node) { } if (value_type->Max() > kMaxSafeInteger) { value = graph()->NewNode( - common()->Select(kMachAnyTagged), + common()->Select(MachineRepresentation::kTagged), graph()->NewNode(simplified()->NumberLessThanOrEqual(), jsgraph()->Constant(kMaxSafeInteger), value), jsgraph()->Constant(kMaxSafeInteger), value); diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc index b1fadb5ae2..6280c81f38 100644 --- a/src/compiler/js-native-context-specialization.cc +++ b/src/compiler/js-native-context-specialization.cc @@ -254,7 +254,7 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess( this_storage, this_effect, this_control); } FieldAccess field_access = {kTaggedBase, field_index.offset(), name, - field_type, kMachAnyTagged}; + field_type, MachineType::AnyTagged()}; if (access_mode == AccessMode::kLoad) { if (field_type->Is(Type::UntaggedFloat64())) { if (!field_index.is_inobject() || field_index.is_hidden_field() || @@ -265,7 +265,7 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess( field_access.offset = HeapNumber::kValueOffset; field_access.name = MaybeHandle(); } - field_access.machine_type = kMachFloat64; + field_access.machine_type = MachineType::Float64(); } this_value = this_effect = graph()->NewNode(simplified()->LoadField(field_access), @@ -309,11 +309,11 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess( this_storage, this_effect, this_control); field_access.offset = HeapNumber::kValueOffset; field_access.name = MaybeHandle(); - field_access.machine_type = kMachFloat64; + field_access.machine_type = MachineType::Float64(); } } else { // Unboxed double field, we store directly to the field. - field_access.machine_type = kMachFloat64; + field_access.machine_type = MachineType::Float64(); } } else if (field_type->Is(Type::TaggedSigned())) { Node* check = @@ -429,8 +429,9 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess( control = graph()->NewNode(common()->Merge(control_count), control_count, &controls.front()); values.push_back(control); - value = graph()->NewNode(common()->Phi(kMachAnyTagged, control_count), - control_count + 1, &values.front()); + value = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, control_count), + control_count + 1, &values.front()); effects.push_back(control); effect = graph()->NewNode(common()->EffectPhi(control_count), control_count + 1, &effects.front()); @@ -700,10 +701,10 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( // Compute the element access. Type* element_type = Type::Any(); - MachineType element_machine_type = kMachAnyTagged; + MachineType element_machine_type = MachineType::AnyTagged(); if (IsFastDoubleElementsKind(elements_kind)) { element_type = type_cache_.kFloat64; - element_machine_type = kMachFloat64; + element_machine_type = MachineType::Float64(); } else if (IsFastSmiElementsKind(elements_kind)) { element_type = type_cache_.kSmi; } @@ -752,9 +753,9 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( // Turn the hole into undefined. this_control = graph()->NewNode(common()->Merge(2), if_true, if_false); - this_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), - jsgraph()->UndefinedConstant(), - this_value, this_control); + this_value = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), + jsgraph()->UndefinedConstant(), this_value, this_control); element_type = Type::Union(element_type, Type::Undefined(), graph()->zone()); } else { @@ -782,8 +783,9 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( dependencies()->AssumePropertyCell(factory()->array_protector()); // Turn the hole into undefined. this_value = graph()->NewNode( - common()->Select(kMachAnyTagged, BranchHint::kFalse), check, - jsgraph()->UndefinedConstant(), this_value); + common()->Select(MachineRepresentation::kTagged, + BranchHint::kFalse), + check, jsgraph()->UndefinedConstant(), this_value); } else { // Deoptimize in case of the hole. Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse), @@ -857,8 +859,9 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( control = graph()->NewNode(common()->Merge(control_count), control_count, &controls.front()); values.push_back(control); - value = graph()->NewNode(common()->Phi(kMachAnyTagged, control_count), - control_count + 1, &values.front()); + value = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, control_count), + control_count + 1, &values.front()); effects.push_back(control); effect = graph()->NewNode(common()->EffectPhi(control_count), control_count + 1, &effects.front()); diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc index fac10fecb0..903bf88a7b 100644 --- a/src/compiler/js-typed-lowering.cc +++ b/src/compiler/js-typed-lowering.cc @@ -384,8 +384,8 @@ class JSBinopReduction final { // Wire conversions to existing {IfException} continuation. Node* exception_merge = if_exception; Node* exception_value = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), left_exception, - right_exception, exception_merge); + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + left_exception, right_exception, exception_merge); Node* exception_effect = graph()->NewNode(common()->EffectPhi(2), left_exception, right_exception, exception_merge); @@ -829,10 +829,10 @@ Reduction JSTypedLowering::ReduceJSToStringInput(Node* input) { return Changed(input); // JSToString(x:string) => x } if (input_type->Is(Type::Boolean())) { - return Replace( - graph()->NewNode(common()->Select(kMachAnyTagged), input, - jsgraph()->HeapConstant(factory()->true_string()), - jsgraph()->HeapConstant(factory()->false_string()))); + return Replace(graph()->NewNode( + common()->Select(MachineRepresentation::kTagged), input, + jsgraph()->HeapConstant(factory()->true_string()), + jsgraph()->HeapConstant(factory()->false_string()))); } if (input_type->Is(Type::Undefined())) { return Replace(jsgraph()->HeapConstant(factory()->undefined_string())); @@ -928,8 +928,9 @@ Reduction JSTypedLowering::ReduceJSToObject(Node* node) { control = graph()->NewNode(common()->Merge(2), if_convert, if_done); effect = graph()->NewNode(common()->EffectPhi(2), econvert, edone, control); - receiver = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), rconvert, - rdone, control); + receiver = + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + rconvert, rdone, control); } ReplaceWithValue(node, receiver, effect, control); return Changed(receiver); @@ -988,7 +989,8 @@ Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { if (!array->GetBuffer()->was_neutered()) { array->GetBuffer()->set_is_neuterable(false); BufferAccess const access(array->type()); - size_t const k = ElementSizeLog2Of(access.machine_type()); + size_t const k = + ElementSizeLog2Of(access.machine_type().representation()); double const byte_length = array->byte_length()->Number(); CHECK_LT(k, arraysize(shifted_int32_ranges_)); if (key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { @@ -1034,7 +1036,8 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { if (!array->GetBuffer()->was_neutered()) { array->GetBuffer()->set_is_neuterable(false); BufferAccess const access(array->type()); - size_t const k = ElementSizeLog2Of(access.machine_type()); + size_t const k = + ElementSizeLog2Of(access.machine_type().representation()); double const byte_length = array->byte_length()->Number(); CHECK_LT(k, arraysize(shifted_int32_ranges_)); if (access.external_array_type() != kExternalUint8ClampedArray && @@ -1061,10 +1064,11 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { } } // For integer-typed arrays, convert to the integer type. - if (TypeOf(access.machine_type()) == kTypeInt32 && + if (access.machine_type().semantic() == MachineSemantic::kInt32 && !value_type->Is(Type::Signed32())) { value = graph()->NewNode(simplified()->NumberToInt32(), value); - } else if (TypeOf(access.machine_type()) == kTypeUint32 && + } else if (access.machine_type().semantic() == + MachineSemantic::kUint32 && !value_type->Is(Type::Unsigned32())) { value = graph()->NewNode(simplified()->NumberToUint32(), value); } @@ -1150,8 +1154,9 @@ Reduction JSTypedLowering::ReduceJSInstanceOf(Node* node) { Node* loop_effect = effect = graph()->NewNode(common()->EffectPhi(2), effect, effect, loop); - Node* loop_object_map = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), - object_map, r.left(), loop); + Node* loop_object_map = + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + object_map, r.left(), loop); Node* object_prototype = effect = graph()->NewNode( @@ -1194,17 +1199,18 @@ Reduction JSTypedLowering::ReduceJSInstanceOf(Node* node) { e_null_proto, control); - Node* result = graph()->NewNode(common()->Phi(kTypeBool, 2), - jsgraph()->TrueConstant(), - jsgraph()->FalseConstant(), control); + Node* result = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), + jsgraph()->TrueConstant(), jsgraph()->FalseConstant(), control); if (if_is_smi != nullptr) { DCHECK(e_is_smi != nullptr); control = graph()->NewNode(common()->Merge(2), if_is_smi, control); effect = graph()->NewNode(common()->EffectPhi(2), e_is_smi, effect, control); - result = graph()->NewNode(common()->Phi(kTypeBool, 2), - jsgraph()->FalseConstant(), result, control); + result = + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + jsgraph()->FalseConstant(), result, control); } ReplaceWithValue(node, result, effect, control); return Changed(result); @@ -1343,8 +1349,9 @@ Reduction JSTypedLowering::ReduceJSConvertReceiver(Node* node) { control = graph()->NewNode(common()->Merge(2), if_convert, if_global); effect = graph()->NewNode(common()->EffectPhi(2), econvert, eglobal, control); - receiver = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), rconvert, - rglobal, control); + receiver = + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + rconvert, rglobal, control); } } ReplaceWithValue(node, receiver, effect, control); @@ -2212,8 +2219,8 @@ Reduction JSTypedLowering::ReduceJSForInPrepare(Node* node) { etrue0 = graph()->NewNode(common()->EffectPhi(2), etrue1, efalse1, if_true0); cache_array_true0 = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), cache_array_true1, - cache_array_false1, if_true0); + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + cache_array_true1, cache_array_false1, if_true0); cache_type_true0 = cache_type; } @@ -2230,7 +2237,7 @@ Reduction JSTypedLowering::ReduceJSForInPrepare(Node* node) { receiver_map, effect, if_false0); cache_type_false0 = graph()->NewNode( - common()->Select(kMachAnyTagged, BranchHint::kFalse), + common()->Select(MachineRepresentation::kTagged, BranchHint::kFalse), graph()->NewNode(machine()->Word32Equal(), receiver_instance_type, jsgraph()->Uint32Constant(JS_PROXY_TYPE)), jsgraph()->ZeroConstant(), // Zero indicagtes proxy. @@ -2245,13 +2252,14 @@ Reduction JSTypedLowering::ReduceJSForInPrepare(Node* node) { control = graph()->NewNode(common()->Merge(2), if_true0, if_false0); effect = graph()->NewNode(common()->EffectPhi(2), etrue0, efalse0, control); Node* cache_array = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), cache_array_true0, - cache_array_false0, control); + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + cache_array_true0, cache_array_false0, control); Node* cache_length = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), cache_length_true0, - cache_length_false0, control); - cache_type = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), - cache_type_true0, cache_type_false0, control); + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + cache_length_true0, cache_length_false0, control); + cache_type = + graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + cache_type_true0, cache_type_false0, control); for (auto edge : node->use_edges()) { Node* const use = edge.from(); @@ -2364,8 +2372,8 @@ Reduction JSTypedLowering::ReduceJSForInNext(Node* node) { if_false0 = graph()->NewNode(common()->Merge(2), if_true1, if_false1); efalse0 = graph()->NewNode(common()->EffectPhi(2), etrue1, efalse1, if_false0); - vfalse0 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vtrue1, - vfalse1, if_false0); + vfalse0 = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + vtrue1, vfalse1, if_false0); } control = graph()->NewNode(common()->Merge(2), if_true0, if_false0); @@ -2375,7 +2383,8 @@ Reduction JSTypedLowering::ReduceJSForInNext(Node* node) { node->ReplaceInput(1, vfalse0); node->ReplaceInput(2, control); node->TrimInputCount(3); - NodeProperties::ChangeOp(node, common()->Phi(kMachAnyTagged, 2)); + NodeProperties::ChangeOp(node, + common()->Phi(MachineRepresentation::kTagged, 2)); return Changed(node); } diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc index 7fd8202bd6..7dc4018e25 100644 --- a/src/compiler/linkage.cc +++ b/src/compiler/linkage.cc @@ -25,29 +25,29 @@ LinkageLocation regloc(Register reg) { MachineType reptyp(Representation representation) { switch (representation.kind()) { case Representation::kInteger8: - return kMachInt8; + return MachineType::Int8(); case Representation::kUInteger8: - return kMachUint8; + return MachineType::Uint8(); case Representation::kInteger16: - return kMachInt16; + return MachineType::Int16(); case Representation::kUInteger16: - return kMachUint16; + return MachineType::Uint16(); case Representation::kInteger32: - return kMachInt32; + return MachineType::Int32(); case Representation::kSmi: case Representation::kTagged: case Representation::kHeapObject: - return kMachAnyTagged; + return MachineType::AnyTagged(); case Representation::kDouble: - return kMachFloat64; + return MachineType::Float64(); case Representation::kExternal: - return kMachPtr; + return MachineType::Pointer(); case Representation::kNone: case Representation::kNumRepresentations: break; } UNREACHABLE(); - return kMachNone; + return MachineType::None(); } } // namespace @@ -242,26 +242,26 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor( locations.AddReturn(regloc(kReturnRegister1)); } for (size_t i = 0; i < return_count; i++) { - types.AddReturn(kMachAnyTagged); + types.AddReturn(MachineType::AnyTagged()); } // All parameters to the runtime call go on the stack. for (int i = 0; i < js_parameter_count; i++) { locations.AddParam( LinkageLocation::ForCallerFrameSlot(i - js_parameter_count)); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); } // Add runtime function itself. locations.AddParam(regloc(kRuntimeCallFunctionRegister)); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); // Add runtime call argument count. locations.AddParam(regloc(kRuntimeCallArgCountRegister)); - types.AddParam(kMachPtr); + types.AddParam(MachineType::Pointer()); // Add context. locations.AddParam(regloc(kContextRegister)); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); if (Linkage::FrameStateInputCount(function_id) == 0) { flags = static_cast( @@ -269,7 +269,7 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor( } // The target for runtime calls is a code object. - MachineType target_type = kMachAnyTagged; + MachineType target_type = MachineType::AnyTagged(); LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); return new (zone) CallDescriptor( // -- CallDescriptor::kCallCodeObject, // kind @@ -294,7 +294,7 @@ CallDescriptor* Linkage::GetLazyBailoutDescriptor(Zone* zone) { MachineSignature::Builder types(zone, return_count, parameter_count); // The target is ignored, but we need to give some values here. - MachineType target_type = kMachAnyTagged; + MachineType target_type = MachineType::AnyTagged(); LinkageLocation target_loc = regloc(kJSFunctionRegister); return new (zone) CallDescriptor( // -- CallDescriptor::kLazyBailout, // kind @@ -326,29 +326,29 @@ CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, // All JS calls have exactly one return value. locations.AddReturn(regloc(kReturnRegister0)); - types.AddReturn(kMachAnyTagged); + types.AddReturn(MachineType::AnyTagged()); // All parameters to JS calls go on the stack. for (int i = 0; i < js_parameter_count; i++) { int spill_slot_index = i - js_parameter_count; locations.AddParam(LinkageLocation::ForCallerFrameSlot(spill_slot_index)); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); } // Add JavaScript call new target value. locations.AddParam(regloc(kJavaScriptCallNewTargetRegister)); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); // Add JavaScript call argument count. locations.AddParam(regloc(kJavaScriptCallArgCountRegister)); - types.AddParam(kMachInt32); + types.AddParam(MachineType::Int32()); // Add context. locations.AddParam(regloc(kContextRegister)); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); // The target for JS function calls is the JSFunction object. - MachineType target_type = kMachAnyTagged; + MachineType target_type = MachineType::AnyTagged(); // TODO(titzer): When entering into an OSR function from unoptimized code, // the JSFunction is not in a register, but it is on the stack in an // unaddressable spill slot. We hack this in the OSR prologue. Fix. @@ -375,23 +375,23 @@ CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(Zone* zone) { // Add registers for fixed parameters passed via interpreter dispatch. STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); locations.AddParam(regloc(kInterpreterAccumulatorRegister)); STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); - types.AddParam(kMachPtr); + types.AddParam(MachineType::Pointer()); locations.AddParam(regloc(kInterpreterRegisterFileRegister)); STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter); - types.AddParam(kMachIntPtr); + types.AddParam(MachineType::IntPtr()); locations.AddParam(regloc(kInterpreterBytecodeOffsetRegister)); STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); locations.AddParam(regloc(kInterpreterBytecodeArrayRegister)); STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter); - types.AddParam(kMachPtr); + types.AddParam(MachineType::Pointer()); #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X87) // TODO(rmcilroy): Make the context param the one spilled to the stack once // Turbofan supports modified stack arguments in tail calls. @@ -402,13 +402,13 @@ CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(Zone* zone) { #endif STATIC_ASSERT(5 == Linkage::kInterpreterContextParameter); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); locations.AddParam(regloc(kContextRegister)); LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); return new (zone) CallDescriptor( // -- CallDescriptor::kCallCodeObject, // kind - kMachNone, // target MachineType + MachineType::None(), // target MachineType target_loc, // target location types.Build(), // machine_sig locations.Build(), // location_sig @@ -457,15 +457,15 @@ CallDescriptor* Linkage::GetStubCallDescriptor( // The rest of the parameters go on the stack. int stack_slot = i - register_parameter_count - stack_parameter_count; locations.AddParam(LinkageLocation::ForCallerFrameSlot(stack_slot)); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); } } // Add context. locations.AddParam(regloc(kContextRegister)); - types.AddParam(kMachAnyTagged); + types.AddParam(MachineType::AnyTagged()); // The target for stub calls is a code object. - MachineType target_type = kMachAnyTagged; + MachineType target_type = MachineType::AnyTagged(); LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); return new (zone) CallDescriptor( // -- CallDescriptor::kCallCodeObject, // kind diff --git a/src/compiler/linkage.h b/src/compiler/linkage.h index 0c6b4cd4d0..d75a3e7ea6 100644 --- a/src/compiler/linkage.h +++ b/src/compiler/linkage.h @@ -319,7 +319,7 @@ class Linkage : public ZoneObject { Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, int stack_parameter_count, CallDescriptor::Flags flags, Operator::Properties properties = Operator::kNoProperties, - MachineType return_type = kMachAnyTagged); + MachineType return_type = MachineType::AnyTagged()); // Creates a call descriptor for simplified C calls that is appropriate // for the host platform. This simplified calling convention only supports diff --git a/src/compiler/live-range-separator.cc b/src/compiler/live-range-separator.cc index 2333154242..42407d8aa1 100644 --- a/src/compiler/live-range-separator.cc +++ b/src/compiler/live-range-separator.cc @@ -45,7 +45,8 @@ void CreateSplinter(TopLevelLiveRange *range, RegisterAllocationData *data, data->CreateSpillRangeForLiveRange(range); } if (range->splinter() == nullptr) { - TopLevelLiveRange *splinter = data->NextLiveRange(range->machine_type()); + TopLevelLiveRange *splinter = + data->NextLiveRange(range->representation()); DCHECK_NULL(data->live_ranges()[splinter->vreg()]); data->live_ranges()[splinter->vreg()] = splinter; range->SetSplinter(splinter); diff --git a/src/compiler/loop-peeling.cc b/src/compiler/loop-peeling.cc index 8c980aa125..b553a9ff58 100644 --- a/src/compiler/loop-peeling.cc +++ b/src/compiler/loop-peeling.cc @@ -311,8 +311,9 @@ PeeledIteration* LoopPeeler::Peel(Graph* graph, CommonOperatorBuilder* common, // Update all the value and effect edges at once. if (!value_edges.empty()) { // TODO(titzer): machine type is wrong here. - Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), node, - peeling.map(node), merge); + Node* phi = + graph->NewNode(common->Phi(MachineRepresentation::kTagged, 2), node, + peeling.map(node), merge); for (Edge edge : value_edges) edge.UpdateTo(phi); value_edges.clear(); } diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc index c174da2f7f..b31784e6ba 100644 --- a/src/compiler/machine-operator-reducer.cc +++ b/src/compiler/machine-operator-reducer.cc @@ -600,7 +600,8 @@ Reduction MachineOperatorReducer::ReduceInt32Mod(Node* node) { 1, Int32Sub(zero, Word32And(Int32Sub(zero, dividend), mask))); node->ReplaceInput(2, Word32And(dividend, mask)); NodeProperties::ChangeOp( - node, common()->Select(kMachInt32, BranchHint::kFalse)); + node, + common()->Select(MachineRepresentation::kWord32, BranchHint::kFalse)); } else { Node* quotient = Int32Div(dividend, divisor); DCHECK_EQ(dividend, node->InputAt(0)); @@ -650,7 +651,7 @@ Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) { if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); if (m.IsPhi()) { Node* const phi = m.node(); - DCHECK_EQ(kRepFloat64, RepresentationOf(OpParameter(phi))); + DCHECK_EQ(MachineRepresentation::kFloat64, PhiRepresentationOf(phi->op())); if (phi->OwnedBy(node)) { // TruncateFloat64ToInt32[mode](Phi[Float64](x1,...,xn)) // => Phi[Int32](TruncateFloat64ToInt32[mode](x1), @@ -665,8 +666,9 @@ Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) { if (reduction.Changed()) input = reduction.replacement(); phi->ReplaceInput(i, input); } - NodeProperties::ChangeOp(phi, - common()->Phi(kMachInt32, value_input_count)); + NodeProperties::ChangeOp( + phi, + common()->Phi(MachineRepresentation::kWord32, value_input_count)); return Replace(phi); } } @@ -675,15 +677,16 @@ Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) { Reduction MachineOperatorReducer::ReduceStore(Node* node) { - MachineType const rep = - RepresentationOf(StoreRepresentationOf(node->op()).machine_type()); + MachineRepresentation const rep = + StoreRepresentationOf(node->op()).machine_type().representation(); Node* const value = node->InputAt(2); switch (value->opcode()) { case IrOpcode::kWord32And: { Uint32BinopMatcher m(value); - if (m.right().HasValue() && - ((rep == kRepWord8 && (m.right().Value() & 0xff) == 0xff) || - (rep == kRepWord16 && (m.right().Value() & 0xffff) == 0xffff))) { + if (m.right().HasValue() && ((rep == MachineRepresentation::kWord8 && + (m.right().Value() & 0xff) == 0xff) || + (rep == MachineRepresentation::kWord16 && + (m.right().Value() & 0xffff) == 0xffff))) { node->ReplaceInput(2, m.left().node()); return Changed(node); } @@ -691,9 +694,10 @@ Reduction MachineOperatorReducer::ReduceStore(Node* node) { } case IrOpcode::kWord32Sar: { Int32BinopMatcher m(value); - if (m.left().IsWord32Shl() && - ((rep == kRepWord8 && m.right().IsInRange(1, 24)) || - (rep == kRepWord16 && m.right().IsInRange(1, 16)))) { + if (m.left().IsWord32Shl() && ((rep == MachineRepresentation::kWord8 && + m.right().IsInRange(1, 24)) || + (rep == MachineRepresentation::kWord16 && + m.right().IsInRange(1, 16)))) { Int32BinopMatcher mleft(m.left().node()); if (mleft.right().Is(m.right().Value())) { node->ReplaceInput(2, mleft.left().node()); @@ -811,12 +815,14 @@ Reduction MachineOperatorReducer::ReduceWord32Sar(Node* node) { } } else if (mleft.left().IsLoad()) { LoadRepresentation const rep = - OpParameter(mleft.left().node()); - if (m.right().Is(24) && mleft.right().Is(24) && rep == kMachInt8) { + LoadRepresentationOf(mleft.left().node()->op()); + if (m.right().Is(24) && mleft.right().Is(24) && + rep == MachineType::Int8()) { // Load[kMachInt8] << 24 >> 24 => Load[kMachInt8] return Replace(mleft.left().node()); } - if (m.right().Is(16) && mleft.right().Is(16) && rep == kMachInt16) { + if (m.right().Is(16) && mleft.right().Is(16) && + rep == MachineType::Int16()) { // Load[kMachInt16] << 16 >> 16 => Load[kMachInt8] return Replace(mleft.left().node()); } diff --git a/src/compiler/machine-operator.cc b/src/compiler/machine-operator.cc index 7c2fc603a2..0635594b6e 100644 --- a/src/compiler/machine-operator.cc +++ b/src/compiler/machine-operator.cc @@ -68,6 +68,12 @@ std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) { } +LoadRepresentation LoadRepresentationOf(Operator const* op) { + DCHECK_EQ(IrOpcode::kLoad, op->opcode()); + return OpParameter(op); +} + + StoreRepresentation const& StoreRepresentationOf(Operator const* op) { DCHECK_EQ(IrOpcode::kStore, op->opcode()); return OpParameter(op); @@ -200,18 +206,18 @@ CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { #define MACHINE_TYPE_LIST(V) \ - V(MachFloat32) \ - V(MachFloat64) \ - V(MachInt8) \ - V(MachUint8) \ - V(MachInt16) \ - V(MachUint16) \ - V(MachInt32) \ - V(MachUint32) \ - V(MachInt64) \ - V(MachUint64) \ - V(MachPtr) \ - V(MachAnyTagged) + V(Float32) \ + V(Float64) \ + V(Int8) \ + V(Uint8) \ + V(Int16) \ + V(Uint16) \ + V(Int32) \ + V(Uint32) \ + V(Int64) \ + V(Uint64) \ + V(Pointer) \ + V(AnyTagged) struct MachineOperatorGlobalCache { @@ -246,14 +252,14 @@ struct MachineOperatorGlobalCache { Load##Type##Operator() \ : Operator1( \ IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \ - "Load", 2, 1, 1, 1, 1, 0, k##Type) {} \ + "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ }; \ struct CheckedLoad##Type##Operator final \ : public Operator1 { \ CheckedLoad##Type##Operator() \ : Operator1( \ IrOpcode::kCheckedLoad, Operator::kNoThrow | Operator::kNoWrite, \ - "CheckedLoad", 3, 1, 1, 1, 1, 0, k##Type) {} \ + "CheckedLoad", 3, 1, 1, 1, 1, 0, MachineType::Type()) {} \ }; \ Load##Type##Operator kLoad##Type; \ CheckedLoad##Type##Operator kCheckedLoad##Type; @@ -266,7 +272,7 @@ struct MachineOperatorGlobalCache { : Operator1( \ IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, \ "Store", 3, 1, 1, 0, 1, 0, \ - StoreRepresentation(k##Type, write_barrier_kind)) {} \ + StoreRepresentation(MachineType::Type(), write_barrier_kind)) {} \ }; \ struct Store##Type##NoWriteBarrier##Operator final \ : public Store##Type##Operator { \ @@ -293,7 +299,7 @@ struct MachineOperatorGlobalCache { CheckedStore##Type##Operator() \ : Operator1( \ IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, \ - "CheckedStore", 4, 1, 1, 0, 1, 0, k##Type) {} \ + "CheckedStore", 4, 1, 1, 0, 1, 0, MachineType::Type()) {} \ }; \ Store##Type##NoWriteBarrier##Operator kStore##Type##NoWriteBarrier; \ Store##Type##MapWriteBarrier##Operator kStore##Type##MapWriteBarrier; \ @@ -310,10 +316,12 @@ static base::LazyInstance::type kCache = LAZY_INSTANCE_INITIALIZER; -MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, MachineType word, +MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, + MachineRepresentation word, Flags flags) : cache_(kCache.Get()), word_(word), flags_(flags) { - DCHECK(word == kRepWord32 || word == kRepWord64); + DCHECK(word == MachineRepresentation::kWord32 || + word == MachineRepresentation::kWord64); } @@ -346,25 +354,22 @@ const Operator* MachineOperatorBuilder::TruncateFloat64ToInt32( const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { - switch (rep) { -#define LOAD(Type) \ - case k##Type: \ - return &cache_.kLoad##Type; +#define LOAD(Type) \ + if (rep == MachineType::Type()) { \ + return &cache_.kLoad##Type; \ + } MACHINE_TYPE_LIST(LOAD) #undef LOAD - default: - break; - } UNREACHABLE(); return nullptr; } -const Operator* MachineOperatorBuilder::Store(StoreRepresentation rep) { - switch (rep.machine_type()) { +const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { + MachineType type = store_rep.machine_type(); #define STORE(Type) \ - case k##Type: \ - switch (rep.write_barrier_kind()) { \ + if (type == MachineType::Type()) { \ + switch (store_rep.write_barrier_kind()) { \ case kNoWriteBarrier: \ return &cache_.k##Store##Type##NoWriteBarrier; \ case kMapWriteBarrier: \ @@ -374,13 +379,9 @@ const Operator* MachineOperatorBuilder::Store(StoreRepresentation rep) { case kFullWriteBarrier: \ return &cache_.k##Store##Type##FullWriteBarrier; \ } \ - break; + } MACHINE_TYPE_LIST(STORE) #undef STORE - - default: - break; - } UNREACHABLE(); return nullptr; } @@ -388,15 +389,12 @@ const Operator* MachineOperatorBuilder::Store(StoreRepresentation rep) { const Operator* MachineOperatorBuilder::CheckedLoad( CheckedLoadRepresentation rep) { - switch (rep) { -#define LOAD(Type) \ - case k##Type: \ - return &cache_.kCheckedLoad##Type; +#define LOAD(Type) \ + if (rep == MachineType::Type()) { \ + return &cache_.kCheckedLoad##Type; \ + } MACHINE_TYPE_LIST(LOAD) #undef LOAD - default: - break; - } UNREACHABLE(); return nullptr; } @@ -404,15 +402,12 @@ const Operator* MachineOperatorBuilder::CheckedLoad( const Operator* MachineOperatorBuilder::CheckedStore( CheckedStoreRepresentation rep) { - switch (rep) { -#define STORE(Type) \ - case k##Type: \ - return &cache_.kCheckedStore##Type; +#define STORE(Type) \ + if (rep == MachineType::Type()) { \ + return &cache_.kCheckedStore##Type; \ + } MACHINE_TYPE_LIST(STORE) #undef STORE - default: - break; - } UNREACHABLE(); return nullptr; } diff --git a/src/compiler/machine-operator.h b/src/compiler/machine-operator.h index bc84db4416..660fee7065 100644 --- a/src/compiler/machine-operator.h +++ b/src/compiler/machine-operator.h @@ -62,6 +62,7 @@ std::ostream& operator<<(std::ostream& os, WriteBarrierKind); // A Load needs a MachineType. typedef MachineType LoadRepresentation; +LoadRepresentation LoadRepresentationOf(Operator const*); // A Store needs a MachineType and a WriteBarrierKind in order to emit the // correct write barrier. @@ -141,8 +142,10 @@ class MachineOperatorBuilder final : public ZoneObject { }; typedef base::Flags Flags; - explicit MachineOperatorBuilder(Zone* zone, MachineType word = kMachPtr, - Flags supportedOperators = kNoFlags); + explicit MachineOperatorBuilder( + Zone* zone, + MachineRepresentation word = MachineType::PointerRepresentation(), + Flags supportedOperators = kNoFlags); const Operator* Word32And(); const Operator* Word32Or(); @@ -307,9 +310,9 @@ class MachineOperatorBuilder final : public ZoneObject { const Operator* CheckedStore(CheckedStoreRepresentation); // Target machine word-size assumed by this builder. - bool Is32() const { return word() == kRepWord32; } - bool Is64() const { return word() == kRepWord64; } - MachineType word() const { return word_; } + bool Is32() const { return word() == MachineRepresentation::kWord32; } + bool Is64() const { return word() == MachineRepresentation::kWord64; } + MachineRepresentation word() const { return word_; } // Pseudo operators that translate to 32/64-bit operators depending on the // word-size of the target machine assumed by this builder. @@ -342,7 +345,7 @@ class MachineOperatorBuilder final : public ZoneObject { private: MachineOperatorGlobalCache const& cache_; - MachineType const word_; + MachineRepresentation const word_; Flags const flags_; DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); diff --git a/src/compiler/mips/instruction-selector-mips.cc b/src/compiler/mips/instruction-selector-mips.cc index 2a7020e9e6..94beec1e94 100644 --- a/src/compiler/mips/instruction-selector-mips.cc +++ b/src/compiler/mips/instruction-selector-mips.cc @@ -127,29 +127,28 @@ static void VisitBinop(InstructionSelector* selector, Node* node, void InstructionSelector::VisitLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + LoadRepresentation load_rep = LoadRepresentationOf(node->op()); MipsOperandGenerator g(this); Node* base = node->InputAt(0); Node* index = node->InputAt(1); ArchOpcode opcode; - switch (rep) { - case kRepFloat32: + switch (load_rep.representation()) { + case MachineRepresentation::kFloat32: opcode = kMipsLwc1; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kMipsLdc1; break; - case kRepBit: // Fall through. - case kRepWord8: - opcode = typ == kTypeUint32 ? kMipsLbu : kMipsLb; + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: + opcode = load_rep.IsUnsigned() ? kMipsLbu : kMipsLb; break; - case kRepWord16: - opcode = typ == kTypeUint32 ? kMipsLhu : kMipsLh; + case MachineRepresentation::kWord16: + opcode = load_rep.IsUnsigned() ? kMipsLhu : kMipsLh; break; - case kRepTagged: // Fall through. - case kRepWord32: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord32: opcode = kMipsLw; break; default: @@ -179,11 +178,11 @@ void InstructionSelector::VisitStore(Node* node) { StoreRepresentation store_rep = OpParameter(node); WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); - MachineType rep = RepresentationOf(store_rep.machine_type()); + MachineRepresentation rep = store_rep.machine_type().representation(); // TODO(mips): I guess this could be done in a better way. if (write_barrier_kind != kNoWriteBarrier) { - DCHECK_EQ(kRepTagged, rep); + DCHECK_EQ(MachineRepresentation::kTagged, rep); InstructionOperand inputs[3]; size_t input_count = 0; inputs[input_count++] = g.UseUniqueRegister(base); @@ -214,21 +213,21 @@ void InstructionSelector::VisitStore(Node* node) { } else { ArchOpcode opcode; switch (rep) { - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kMipsSwc1; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kMipsSdc1; break; - case kRepBit: // Fall through. - case kRepWord8: + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: opcode = kMipsSb; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kMipsSh; break; - case kRepTagged: // Fall through. - case kRepWord32: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord32: opcode = kMipsSw; break; default: @@ -803,27 +802,26 @@ bool InstructionSelector::IsTailCallAddressImmediate() { return false; } void InstructionSelector::VisitCheckedLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); MipsOperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); Node* const length = node->InputAt(2); ArchOpcode opcode; - switch (rep) { - case kRepWord8: - opcode = typ == kTypeInt32 ? kCheckedLoadInt8 : kCheckedLoadUint8; + switch (load_rep.representation()) { + case MachineRepresentation::kWord8: + opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; break; - case kRepWord16: - opcode = typ == kTypeInt32 ? kCheckedLoadInt16 : kCheckedLoadUint16; + case MachineRepresentation::kWord16: + opcode = load_rep.IsSigned() ? kCheckedLoadInt16 : kCheckedLoadUint16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedLoadWord32; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedLoadFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedLoadFloat64; break; default: @@ -847,7 +845,8 @@ void InstructionSelector::VisitCheckedLoad(Node* node) { void InstructionSelector::VisitCheckedStore(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); + MachineRepresentation rep = + CheckedStoreRepresentationOf(node->op()).representation(); MipsOperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); @@ -855,19 +854,19 @@ void InstructionSelector::VisitCheckedStore(Node* node) { Node* const value = node->InputAt(3); ArchOpcode opcode; switch (rep) { - case kRepWord8: + case MachineRepresentation::kWord8: opcode = kCheckedStoreWord8; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kCheckedStoreWord16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedStoreWord32; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedStoreFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedStoreFloat64; break; default: diff --git a/src/compiler/mips64/instruction-selector-mips64.cc b/src/compiler/mips64/instruction-selector-mips64.cc index 43eb403779..11549e1899 100644 --- a/src/compiler/mips64/instruction-selector-mips64.cc +++ b/src/compiler/mips64/instruction-selector-mips64.cc @@ -132,32 +132,31 @@ static void VisitBinop(InstructionSelector* selector, Node* node, void InstructionSelector::VisitLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + LoadRepresentation load_rep = LoadRepresentationOf(node->op()); Mips64OperandGenerator g(this); Node* base = node->InputAt(0); Node* index = node->InputAt(1); ArchOpcode opcode; - switch (rep) { - case kRepFloat32: + switch (load_rep.representation()) { + case MachineRepresentation::kFloat32: opcode = kMips64Lwc1; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kMips64Ldc1; break; - case kRepBit: // Fall through. - case kRepWord8: - opcode = typ == kTypeUint32 ? kMips64Lbu : kMips64Lb; + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: + opcode = load_rep.IsUnsigned() ? kMips64Lbu : kMips64Lb; break; - case kRepWord16: - opcode = typ == kTypeUint32 ? kMips64Lhu : kMips64Lh; + case MachineRepresentation::kWord16: + opcode = load_rep.IsUnsigned() ? kMips64Lhu : kMips64Lh; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kMips64Lw; break; - case kRepTagged: // Fall through. - case kRepWord64: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord64: opcode = kMips64Ld; break; default: @@ -187,11 +186,11 @@ void InstructionSelector::VisitStore(Node* node) { StoreRepresentation store_rep = OpParameter(node); WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); - MachineType rep = RepresentationOf(store_rep.machine_type()); + MachineRepresentation rep = store_rep.machine_type().representation(); // TODO(mips): I guess this could be done in a better way. if (write_barrier_kind != kNoWriteBarrier) { - DCHECK_EQ(kRepTagged, rep); + DCHECK_EQ(MachineRepresentation::kTagged, rep); InstructionOperand inputs[3]; size_t input_count = 0; inputs[input_count++] = g.UseUniqueRegister(base); @@ -222,24 +221,24 @@ void InstructionSelector::VisitStore(Node* node) { } else { ArchOpcode opcode; switch (rep) { - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kMips64Swc1; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kMips64Sdc1; break; - case kRepBit: // Fall through. - case kRepWord8: + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: opcode = kMips64Sb; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kMips64Sh; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kMips64Sw; break; - case kRepTagged: // Fall through. - case kRepWord64: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord64: opcode = kMips64Sd; break; default: @@ -1227,30 +1226,29 @@ bool InstructionSelector::IsTailCallAddressImmediate() { return false; } void InstructionSelector::VisitCheckedLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); Mips64OperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); Node* const length = node->InputAt(2); ArchOpcode opcode; - switch (rep) { - case kRepWord8: - opcode = typ == kTypeInt32 ? kCheckedLoadInt8 : kCheckedLoadUint8; + switch (load_rep.representation()) { + case MachineRepresentation::kWord8: + opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; break; - case kRepWord16: - opcode = typ == kTypeInt32 ? kCheckedLoadInt16 : kCheckedLoadUint16; + case MachineRepresentation::kWord16: + opcode = load_rep.IsSigned() ? kCheckedLoadInt16 : kCheckedLoadUint16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedLoadWord32; break; - case kRepWord64: + case MachineRepresentation::kWord64: opcode = kCheckedLoadWord64; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedLoadFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedLoadFloat64; break; default: @@ -1274,7 +1272,8 @@ void InstructionSelector::VisitCheckedLoad(Node* node) { void InstructionSelector::VisitCheckedStore(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); + MachineRepresentation rep = + CheckedStoreRepresentationOf(node->op()).representation(); Mips64OperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); @@ -1282,22 +1281,22 @@ void InstructionSelector::VisitCheckedStore(Node* node) { Node* const value = node->InputAt(3); ArchOpcode opcode; switch (rep) { - case kRepWord8: + case MachineRepresentation::kWord8: opcode = kCheckedStoreWord8; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kCheckedStoreWord16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedStoreWord32; break; - case kRepWord64: + case MachineRepresentation::kWord64: opcode = kCheckedStoreWord64; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedStoreFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedStoreFloat64; break; default: diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc index 1175027f92..801c97aa7c 100644 --- a/src/compiler/pipeline.cc +++ b/src/compiler/pipeline.cc @@ -105,7 +105,7 @@ class PipelineData { source_positions_.Reset(new SourcePositionTable(graph_)); simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); machine_ = new (graph_zone_) MachineOperatorBuilder( - graph_zone_, kMachPtr, + graph_zone_, MachineType::PointerRepresentation(), InstructionSelector::SupportedMachineOperatorFlags()); common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); diff --git a/src/compiler/raw-machine-assembler.cc b/src/compiler/raw-machine-assembler.cc index 0b93eb9cf1..441a582292 100644 --- a/src/compiler/raw-machine-assembler.cc +++ b/src/compiler/raw-machine-assembler.cc @@ -15,7 +15,7 @@ namespace compiler { RawMachineAssembler::RawMachineAssembler(Isolate* isolate, Graph* graph, CallDescriptor* call_descriptor, - MachineType word, + MachineRepresentation word, MachineOperatorBuilder::Flags flags) : isolate_(isolate), graph_(graph), diff --git a/src/compiler/raw-machine-assembler.h b/src/compiler/raw-machine-assembler.h index 7c56e9c84c..f41bda3c98 100644 --- a/src/compiler/raw-machine-assembler.h +++ b/src/compiler/raw-machine-assembler.h @@ -36,11 +36,11 @@ class Schedule; // non-schedulable due to missing control and effect dependencies. class RawMachineAssembler { public: - RawMachineAssembler(Isolate* isolate, Graph* graph, - CallDescriptor* call_descriptor, - MachineType word = kMachPtr, - MachineOperatorBuilder::Flags flags = - MachineOperatorBuilder::Flag::kNoFlags); + RawMachineAssembler( + Isolate* isolate, Graph* graph, CallDescriptor* call_descriptor, + MachineRepresentation word = MachineType::PointerRepresentation(), + MachineOperatorBuilder::Flags flags = + MachineOperatorBuilder::Flag::kNoFlags); ~RawMachineAssembler() {} Isolate* isolate() const { return isolate_; } @@ -611,14 +611,14 @@ class RawMachineAssembler { void Deoptimize(Node* state); // Variables. - Node* Phi(MachineType type, Node* n1, Node* n2) { - return AddNode(common()->Phi(type, 2), n1, n2); + Node* Phi(MachineRepresentation rep, Node* n1, Node* n2) { + return AddNode(common()->Phi(rep, 2), n1, n2); } - Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3) { - return AddNode(common()->Phi(type, 3), n1, n2, n3); + Node* Phi(MachineRepresentation rep, Node* n1, Node* n2, Node* n3) { + return AddNode(common()->Phi(rep, 3), n1, n2, n3); } - Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3, Node* n4) { - return AddNode(common()->Phi(type, 4), n1, n2, n3, n4); + Node* Phi(MachineRepresentation rep, Node* n1, Node* n2, Node* n3, Node* n4) { + return AddNode(common()->Phi(rep, 4), n1, n2, n3, n4); } // =========================================================================== diff --git a/src/compiler/register-allocator-verifier.cc b/src/compiler/register-allocator-verifier.cc index ee6b66f3b1..463795ecf2 100644 --- a/src/compiler/register-allocator-verifier.cc +++ b/src/compiler/register-allocator-verifier.cc @@ -717,9 +717,9 @@ void RegisterAllocatorVerifier::VerifyGapMoves(BlockMaps* block_maps, if (op_constraints[count].type_ == kRegisterAndSlot) { const AllocatedOperand* reg_op = AllocatedOperand::cast(instr->OutputAt(i)); - MachineType mt = reg_op->machine_type(); + MachineRepresentation rep = reg_op->representation(); const AllocatedOperand* stack_op = AllocatedOperand::New( - zone(), LocationOperand::LocationKind::STACK_SLOT, mt, + zone(), LocationOperand::LocationKind::STACK_SLOT, rep, op_constraints[i].spilled_slot_); auto insert_result = current->map().insert(std::make_pair(stack_op, value)); diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc index 13f7ceeb91..fcb935a940 100644 --- a/src/compiler/register-allocator.cc +++ b/src/compiler/register-allocator.cc @@ -92,18 +92,17 @@ bool IsOutputDoubleRegisterOf(Instruction* instr, DoubleRegister reg) { // TODO(dcarney): fix frame to allow frame accesses to half size location. -int GetByteWidth(MachineType machine_type) { - DCHECK_EQ(RepresentationOf(machine_type), machine_type); - switch (machine_type) { - case kRepBit: - case kRepWord8: - case kRepWord16: - case kRepWord32: - case kRepTagged: +int GetByteWidth(MachineRepresentation rep) { + switch (rep) { + case MachineRepresentation::kBit: + case MachineRepresentation::kWord8: + case MachineRepresentation::kWord16: + case MachineRepresentation::kWord32: + case MachineRepresentation::kTagged: return kPointerSize; - case kRepFloat32: - case kRepWord64: - case kRepFloat64: + case MachineRepresentation::kFloat32: + case MachineRepresentation::kWord64: + case MachineRepresentation::kFloat64: return 8; default: UNREACHABLE(); @@ -251,7 +250,7 @@ const float LiveRange::kInvalidWeight = -1; const float LiveRange::kMaxWeight = std::numeric_limits::max(); -LiveRange::LiveRange(int relative_id, MachineType machine_type, +LiveRange::LiveRange(int relative_id, MachineRepresentation rep, TopLevelLiveRange* top_level) : relative_id_(relative_id), bits_(0), @@ -267,9 +266,9 @@ LiveRange::LiveRange(int relative_id, MachineType machine_type, size_(kInvalidSize), weight_(kInvalidWeight), group_(nullptr) { - DCHECK(AllocatedOperand::IsSupportedMachineType(machine_type)); + DCHECK(AllocatedOperand::IsSupportedRepresentation(rep)); bits_ = AssignedRegisterField::encode(kUnassignedRegister) | - MachineTypeField::encode(machine_type); + RepresentationField::encode(rep); } @@ -309,14 +308,8 @@ void LiveRange::Spill() { RegisterKind LiveRange::kind() const { - switch (RepresentationOf(machine_type())) { - case kRepFloat32: - case kRepFloat64: - return DOUBLE_REGISTERS; - default: - break; - } - return GENERAL_REGISTERS; + return IsFloatingPoint(representation()) ? DOUBLE_REGISTERS + : GENERAL_REGISTERS; } @@ -397,7 +390,7 @@ bool LiveRange::IsTopLevel() const { return top_level_ == this; } InstructionOperand LiveRange::GetAssignedOperand() const { if (HasRegisterAssigned()) { DCHECK(!spilled()); - return AllocatedOperand(LocationOperand::REGISTER, machine_type(), + return AllocatedOperand(LocationOperand::REGISTER, representation(), assigned_register()); } DCHECK(spilled()); @@ -436,7 +429,7 @@ void LiveRange::AdvanceLastProcessedMarker( LiveRange* LiveRange::SplitAt(LifetimePosition position, Zone* zone) { int new_id = TopLevel()->GetNextChildId(); - LiveRange* child = new (zone) LiveRange(new_id, machine_type(), TopLevel()); + LiveRange* child = new (zone) LiveRange(new_id, representation(), TopLevel()); DetachAt(position, child, zone); child->top_level_ = TopLevel(); @@ -681,8 +674,8 @@ struct TopLevelLiveRange::SpillMoveInsertionList : ZoneObject { }; -TopLevelLiveRange::TopLevelLiveRange(int vreg, MachineType machine_type) - : LiveRange(0, machine_type, this), +TopLevelLiveRange::TopLevelLiveRange(int vreg, MachineRepresentation rep) + : LiveRange(0, rep, this), vreg_(vreg), last_child_id_(0), splintered_from_(nullptr), @@ -797,7 +790,7 @@ void TopLevelLiveRange::SetSpillRange(SpillRange* spill_range) { AllocatedOperand TopLevelLiveRange::GetSpillRangeOperand() const { auto spill_range = GetSpillRange(); int index = spill_range->assigned_slot(); - return AllocatedOperand(LocationOperand::STACK_SLOT, machine_type(), index); + return AllocatedOperand(LocationOperand::STACK_SLOT, representation(), index); } @@ -806,7 +799,7 @@ void TopLevelLiveRange::Splinter(LifetimePosition start, LifetimePosition end, DCHECK(start != Start() || end != End()); DCHECK(start < end); - TopLevelLiveRange splinter_temp(-1, machine_type()); + TopLevelLiveRange splinter_temp(-1, representation()); UsePosition* last_in_splinter = nullptr; // Live ranges defined in deferred blocks stay in deferred blocks, so we // don't need to splinter them. That means that start should always be @@ -824,7 +817,7 @@ void TopLevelLiveRange::Splinter(LifetimePosition start, LifetimePosition end, UsePosition* last = DetachAt(start, &splinter_temp, zone); - LiveRange end_part(kInvalidId, this->machine_type(), nullptr); + LiveRange end_part(kInvalidId, this->representation(), nullptr); last_in_splinter = splinter_temp.DetachAt(end, &end_part, zone); next_ = end_part.next_; @@ -1088,7 +1081,7 @@ std::ostream& operator<<(std::ostream& os, SpillRange::SpillRange(TopLevelLiveRange* parent, Zone* zone) : live_ranges_(zone), assigned_slot_(kUnassignedSlot), - byte_width_(GetByteWidth(parent->machine_type())), + byte_width_(GetByteWidth(parent->representation())), kind_(parent->kind()) { // Spill ranges are created for top level, non-splintered ranges. This is so // that, when merging decisions are made, we consider the full extent of the @@ -1118,7 +1111,7 @@ SpillRange::SpillRange(TopLevelLiveRange* parent, Zone* zone) int SpillRange::ByteWidth() const { - return GetByteWidth(live_ranges_[0]->machine_type()); + return GetByteWidth(live_ranges_[0]->representation()); } @@ -1257,7 +1250,8 @@ MoveOperands* RegisterAllocationData::AddGapMove( } -MachineType RegisterAllocationData::MachineTypeFor(int virtual_register) { +MachineRepresentation RegisterAllocationData::RepresentationFor( + int virtual_register) { DCHECK_LT(virtual_register, code()->VirtualRegisterCount()); return code()->GetRepresentation(virtual_register); } @@ -1269,7 +1263,7 @@ TopLevelLiveRange* RegisterAllocationData::GetOrCreateLiveRangeFor(int index) { } auto result = live_ranges()[index]; if (result == nullptr) { - result = NewLiveRange(index, MachineTypeFor(index)); + result = NewLiveRange(index, RepresentationFor(index)); live_ranges()[index] = result; } return result; @@ -1277,8 +1271,8 @@ TopLevelLiveRange* RegisterAllocationData::GetOrCreateLiveRangeFor(int index) { TopLevelLiveRange* RegisterAllocationData::NewLiveRange( - int index, MachineType machine_type) { - return new (allocation_zone()) TopLevelLiveRange(index, machine_type); + int index, MachineRepresentation rep) { + return new (allocation_zone()) TopLevelLiveRange(index, rep); } @@ -1292,9 +1286,9 @@ int RegisterAllocationData::GetNextLiveRangeId() { TopLevelLiveRange* RegisterAllocationData::NextLiveRange( - MachineType machine_type) { + MachineRepresentation rep) { int vreg = GetNextLiveRangeId(); - TopLevelLiveRange* ret = NewLiveRange(vreg, machine_type); + TopLevelLiveRange* ret = NewLiveRange(vreg, rep); return ret; } @@ -1501,22 +1495,22 @@ InstructionOperand* ConstraintBuilder::AllocateFixed( TRACE("Allocating fixed reg for op %d\n", operand->virtual_register()); DCHECK(operand->HasFixedPolicy()); InstructionOperand allocated; - MachineType machine_type = InstructionSequence::DefaultRepresentation(); + MachineRepresentation rep = InstructionSequence::DefaultRepresentation(); int virtual_register = operand->virtual_register(); if (virtual_register != InstructionOperand::kInvalidVirtualRegister) { - machine_type = data()->MachineTypeFor(virtual_register); + rep = data()->RepresentationFor(virtual_register); } if (operand->HasFixedSlotPolicy()) { - allocated = AllocatedOperand(AllocatedOperand::STACK_SLOT, machine_type, + allocated = AllocatedOperand(AllocatedOperand::STACK_SLOT, rep, operand->fixed_slot_index()); } else if (operand->HasFixedRegisterPolicy()) { - DCHECK(!IsFloatingPoint(machine_type)); - allocated = AllocatedOperand(AllocatedOperand::REGISTER, machine_type, + DCHECK(!IsFloatingPoint(rep)); + allocated = AllocatedOperand(AllocatedOperand::REGISTER, rep, operand->fixed_register_index()); } else if (operand->HasFixedDoubleRegisterPolicy()) { - DCHECK(IsFloatingPoint(machine_type)); + DCHECK(IsFloatingPoint(rep)); DCHECK_NE(InstructionOperand::kInvalidVirtualRegister, virtual_register); - allocated = AllocatedOperand(AllocatedOperand::REGISTER, machine_type, + allocated = AllocatedOperand(AllocatedOperand::REGISTER, rep, operand->fixed_register_index()); } else { UNREACHABLE(); @@ -1628,7 +1622,7 @@ void ConstraintBuilder::MeetConstraintsAfter(int instr_index) { range->MarkHasPreassignedSlot(); InstructionOperand* spill_op = AllocatedOperand::New( data()->code_zone(), LocationOperand::LocationKind::STACK_SLOT, - range->machine_type(), first_output->GetSecondaryStorage()); + range->representation(), first_output->GetSecondaryStorage()); range->RecordSpillLocation(allocation_zone(), instr_index + 1, first_output); range->SetSpillOperand(spill_op); @@ -1827,7 +1821,8 @@ TopLevelLiveRange* LiveRangeBuilder::FixedDoubleLiveRangeFor(int index) { DCHECK(index < config()->num_double_registers()); auto result = data()->fixed_double_live_ranges()[index]; if (result == nullptr) { - result = data()->NewLiveRange(FixedDoubleLiveRangeID(index), kRepFloat64); + result = data()->NewLiveRange(FixedDoubleLiveRangeID(index), + MachineRepresentation::kFloat64); DCHECK(result->IsFixed()); result->set_assigned_register(index); data()->MarkAllocated(DOUBLE_REGISTERS, index); @@ -3100,8 +3095,8 @@ void ReferenceMapPopulator::PopulateReferenceMaps() { spill_operand = range->GetSpillRangeOperand(); } DCHECK(spill_operand.IsStackSlot()); - DCHECK_EQ(kRepTagged, - AllocatedOperand::cast(spill_operand).machine_type()); + DCHECK_EQ(MachineRepresentation::kTagged, + AllocatedOperand::cast(spill_operand).representation()); } // Step through the safe points to see whether they are in the range. @@ -3142,7 +3137,8 @@ void ReferenceMapPopulator::PopulateReferenceMaps() { safe_point); auto operand = cur->GetAssignedOperand(); DCHECK(!operand.IsStackSlot()); - DCHECK_EQ(kRepTagged, AllocatedOperand::cast(operand).machine_type()); + DCHECK_EQ(MachineRepresentation::kTagged, + AllocatedOperand::cast(operand).representation()); map->RecordReference(AllocatedOperand::cast(operand)); } } diff --git a/src/compiler/register-allocator.h b/src/compiler/register-allocator.h index 9032fde224..a5d46b058d 100644 --- a/src/compiler/register-allocator.h +++ b/src/compiler/register-allocator.h @@ -315,7 +315,9 @@ class LiveRange : public ZoneObject { InstructionOperand GetAssignedOperand() const; - MachineType machine_type() const { return MachineTypeField::decode(bits_); } + MachineRepresentation representation() const { + return RepresentationField::decode(bits_); + } int assigned_register() const { return AssignedRegisterField::decode(bits_); } bool HasRegisterAssigned() const { @@ -414,7 +416,7 @@ class LiveRange : public ZoneObject { private: friend class TopLevelLiveRange; - explicit LiveRange(int relative_id, MachineType machine_type, + explicit LiveRange(int relative_id, MachineRepresentation rep, TopLevelLiveRange* top_level); void AppendAsChild(TopLevelLiveRange* other); @@ -428,7 +430,7 @@ class LiveRange : public ZoneObject { typedef BitField SpilledField; typedef BitField AssignedRegisterField; - typedef BitField MachineTypeField; + typedef BitField RepresentationField; // Unique among children and splinters of the same virtual register. int relative_id_; @@ -481,7 +483,7 @@ class LiveRangeGroup final : public ZoneObject { class TopLevelLiveRange final : public LiveRange { public: - explicit TopLevelLiveRange(int vreg, MachineType machine_type); + explicit TopLevelLiveRange(int vreg, MachineRepresentation rep); int spill_start_index() const { return spill_start_index_; } bool IsFixed() const { return vreg_ < 0; } @@ -773,12 +775,12 @@ class RegisterAllocationData final : public ZoneObject { const char* debug_name() const { return debug_name_; } const RegisterConfiguration* config() const { return config_; } - MachineType MachineTypeFor(int virtual_register); + MachineRepresentation RepresentationFor(int virtual_register); TopLevelLiveRange* GetOrCreateLiveRangeFor(int index); // Creates a new live range. - TopLevelLiveRange* NewLiveRange(int index, MachineType machine_type); - TopLevelLiveRange* NextLiveRange(MachineType machine_type); + TopLevelLiveRange* NewLiveRange(int index, MachineRepresentation rep); + TopLevelLiveRange* NextLiveRange(MachineRepresentation rep); SpillRange* AssignSpillRangeToLiveRange(TopLevelLiveRange* range); SpillRange* CreateSpillRangeForLiveRange(TopLevelLiveRange* range); diff --git a/src/compiler/representation-change.cc b/src/compiler/representation-change.cc index b4b408d7e0..90ac4c30d3 100644 --- a/src/compiler/representation-change.cc +++ b/src/compiler/representation-change.cc @@ -98,8 +98,10 @@ bool Truncation::LessGeneral(TruncationKind rep1, TruncationKind rep2) { namespace { // TODO(titzer): should Word64 also be implicitly convertable to others? -bool IsWord(MachineTypeUnion type) { - return (type & (kRepWord8 | kRepWord16 | kRepWord32)) != 0; +bool IsWord(MachineRepresentation rep) { + return rep == MachineRepresentation::kWord8 || + rep == MachineRepresentation::kWord16 || + rep == MachineRepresentation::kWord32; } } // namespace @@ -110,62 +112,66 @@ bool IsWord(MachineTypeUnion type) { // out signedness for the word32->float64 conversion, then we check that the // uses truncate to word32 (so they do not care about signedness). Node* RepresentationChanger::GetRepresentationFor(Node* node, - MachineTypeUnion output_type, - MachineTypeUnion use_rep, + MachineType output_type, + MachineRepresentation use_rep, Truncation truncation) { - DCHECK((use_rep & kRepMask) == use_rep); - if (!base::bits::IsPowerOfTwo32(output_type & kRepMask)) { - // There should be only one output representation. + if (output_type.representation() == MachineRepresentation::kNone) { + // The output representation should be set. return TypeError(node, output_type, use_rep); } - if (use_rep == (output_type & kRepMask)) { + if (use_rep == output_type.representation()) { // Representations are the same. That's a no-op. return node; } - if (IsWord(use_rep) && IsWord(output_type)) { + if (IsWord(use_rep) && IsWord(output_type.representation())) { // Both are words less than or equal to 32-bits. // Since loads of integers from memory implicitly sign or zero extend the // value to the full machine word size and stores implicitly truncate, // no representation change is necessary. return node; } - if (use_rep & kRepTagged) { - return GetTaggedRepresentationFor(node, output_type); - } else if (use_rep & kRepFloat32) { - return GetFloat32RepresentationFor(node, output_type, truncation); - } else if (use_rep & kRepFloat64) { - return GetFloat64RepresentationFor(node, output_type, truncation); - } else if (use_rep & kRepBit) { - return GetBitRepresentationFor(node, output_type); - } else if (IsWord(use_rep)) { - return GetWord32RepresentationFor(node, output_type); - } else if (use_rep & kRepWord64) { - return GetWord64RepresentationFor(node, output_type); - } else { - return node; + switch (use_rep) { + case MachineRepresentation::kTagged: + return GetTaggedRepresentationFor(node, output_type); + case MachineRepresentation::kFloat32: + return GetFloat32RepresentationFor(node, output_type, truncation); + case MachineRepresentation::kFloat64: + return GetFloat64RepresentationFor(node, output_type, truncation); + case MachineRepresentation::kBit: + return GetBitRepresentationFor(node, output_type); + case MachineRepresentation::kWord8: + case MachineRepresentation::kWord16: + case MachineRepresentation::kWord32: + return GetWord32RepresentationFor(node, output_type); + case MachineRepresentation::kWord64: + return GetWord64RepresentationFor(node, output_type); + default: + return node; } + UNREACHABLE(); + return nullptr; } Node* RepresentationChanger::GetTaggedRepresentationFor( - Node* node, MachineTypeUnion output_type) { + Node* node, MachineType output_type) { // Eagerly fold representation changes for constants. switch (node->opcode()) { case IrOpcode::kNumberConstant: case IrOpcode::kHeapConstant: return node; // No change necessary. case IrOpcode::kInt32Constant: - if (output_type & kTypeUint32) { + if (output_type.semantic() == MachineSemantic::kUint32) { uint32_t value = static_cast(OpParameter(node)); return jsgraph()->Constant(static_cast(value)); - } else if (output_type & kTypeInt32) { + } else if (output_type.semantic() == MachineSemantic::kInt32) { int32_t value = OpParameter(node); return jsgraph()->Constant(value); - } else if (output_type & kRepBit) { + } else if (output_type.representation() == MachineRepresentation::kBit) { return OpParameter(node) == 0 ? jsgraph()->FalseConstant() : jsgraph()->TrueConstant(); } else { - return TypeError(node, output_type, kRepTagged); + return TypeError(node, output_type, MachineRepresentation::kTagged); } case IrOpcode::kFloat64Constant: return jsgraph()->Constant(OpParameter(node)); @@ -176,30 +182,31 @@ Node* RepresentationChanger::GetTaggedRepresentationFor( } // Select the correct X -> Tagged operator. const Operator* op; - if (output_type & kRepBit) { + if (output_type.representation() == MachineRepresentation::kBit) { op = simplified()->ChangeBitToBool(); - } else if (IsWord(output_type)) { - if (output_type & kTypeUint32) { + } else if (IsWord(output_type.representation())) { + if (output_type.semantic() == MachineSemantic::kUint32) { op = simplified()->ChangeUint32ToTagged(); - } else if (output_type & kTypeInt32) { + } else if (output_type.semantic() == MachineSemantic::kInt32) { op = simplified()->ChangeInt32ToTagged(); } else { - return TypeError(node, output_type, kRepTagged); + return TypeError(node, output_type, MachineRepresentation::kTagged); } - } else if (output_type & kRepFloat32) { // float32 -> float64 -> tagged + } else if (output_type.representation() == + MachineRepresentation::kFloat32) { // float32 -> float64 -> tagged node = InsertChangeFloat32ToFloat64(node); op = simplified()->ChangeFloat64ToTagged(); - } else if (output_type & kRepFloat64) { + } else if (output_type.representation() == MachineRepresentation::kFloat64) { op = simplified()->ChangeFloat64ToTagged(); } else { - return TypeError(node, output_type, kRepTagged); + return TypeError(node, output_type, MachineRepresentation::kTagged); } return jsgraph()->graph()->NewNode(op, node); } Node* RepresentationChanger::GetFloat32RepresentationFor( - Node* node, MachineTypeUnion output_type, Truncation truncation) { + Node* node, MachineType output_type, Truncation truncation) { // Eagerly fold representation changes for constants. switch (node->opcode()) { case IrOpcode::kFloat64Constant: @@ -207,7 +214,7 @@ Node* RepresentationChanger::GetFloat32RepresentationFor( return jsgraph()->Float32Constant( DoubleToFloat32(OpParameter(node))); case IrOpcode::kInt32Constant: - if (output_type & kTypeUint32) { + if (output_type.semantic() == MachineSemantic::kUint32) { uint32_t value = static_cast(OpParameter(node)); return jsgraph()->Float32Constant(static_cast(value)); } else { @@ -221,41 +228,42 @@ Node* RepresentationChanger::GetFloat32RepresentationFor( } // Select the correct X -> Float32 operator. const Operator* op; - if (output_type & kRepBit) { - return TypeError(node, output_type, kRepFloat32); - } else if (IsWord(output_type)) { - if (output_type & kTypeUint32) { + if (output_type.representation() == MachineRepresentation::kBit) { + return TypeError(node, output_type, MachineRepresentation::kFloat32); + } else if (IsWord(output_type.representation())) { + if (output_type.semantic() == MachineSemantic::kUint32) { op = machine()->ChangeUint32ToFloat64(); } else { // Either the output is int32 or the uses only care about the // low 32 bits (so we can pick int32 safely). - DCHECK(output_type & kTypeInt32 || truncation.TruncatesToWord32()); + DCHECK(output_type.semantic() == MachineSemantic::kInt32 || + truncation.TruncatesToWord32()); op = machine()->ChangeInt32ToFloat64(); } // int32 -> float64 -> float32 node = jsgraph()->graph()->NewNode(op, node); op = machine()->TruncateFloat64ToFloat32(); - } else if (output_type & kRepTagged) { + } else if (output_type.representation() == MachineRepresentation::kTagged) { op = simplified()->ChangeTaggedToFloat64(); // tagged -> float64 -> float32 node = jsgraph()->graph()->NewNode(op, node); op = machine()->TruncateFloat64ToFloat32(); - } else if (output_type & kRepFloat64) { + } else if (output_type.representation() == MachineRepresentation::kFloat64) { op = machine()->TruncateFloat64ToFloat32(); } else { - return TypeError(node, output_type, kRepFloat32); + return TypeError(node, output_type, MachineRepresentation::kFloat32); } return jsgraph()->graph()->NewNode(op, node); } Node* RepresentationChanger::GetFloat64RepresentationFor( - Node* node, MachineTypeUnion output_type, Truncation truncation) { + Node* node, MachineType output_type, Truncation truncation) { // Eagerly fold representation changes for constants. switch (node->opcode()) { case IrOpcode::kNumberConstant: return jsgraph()->Float64Constant(OpParameter(node)); case IrOpcode::kInt32Constant: - if (output_type & kTypeUint32) { + if (output_type.semantic() == MachineSemantic::kUint32) { uint32_t value = static_cast(OpParameter(node)); return jsgraph()->Float64Constant(static_cast(value)); } else { @@ -271,23 +279,24 @@ Node* RepresentationChanger::GetFloat64RepresentationFor( } // Select the correct X -> Float64 operator. const Operator* op; - if (output_type & kRepBit) { - return TypeError(node, output_type, kRepFloat64); - } else if (IsWord(output_type)) { - if (output_type & kTypeUint32) { + if (output_type.representation() == MachineRepresentation::kBit) { + return TypeError(node, output_type, MachineRepresentation::kFloat64); + } else if (IsWord(output_type.representation())) { + if (output_type.semantic() == MachineSemantic::kUint32) { op = machine()->ChangeUint32ToFloat64(); } else { // Either the output is int32 or the uses only care about the // low 32 bits (so we can pick int32 safely). - DCHECK(output_type & kTypeInt32 || truncation.TruncatesToWord32()); + DCHECK(output_type.semantic() == MachineSemantic::kInt32 || + truncation.TruncatesToWord32()); op = machine()->ChangeInt32ToFloat64(); } - } else if (output_type & kRepTagged) { + } else if (output_type.representation() == MachineRepresentation::kTagged) { op = simplified()->ChangeTaggedToFloat64(); - } else if (output_type & kRepFloat32) { + } else if (output_type.representation() == MachineRepresentation::kFloat32) { op = machine()->ChangeFloat32ToFloat64(); } else { - return TypeError(node, output_type, kRepFloat64); + return TypeError(node, output_type, MachineRepresentation::kFloat64); } return jsgraph()->graph()->NewNode(op, node); } @@ -299,7 +308,7 @@ Node* RepresentationChanger::MakeTruncatedInt32Constant(double value) { Node* RepresentationChanger::GetWord32RepresentationFor( - Node* node, MachineTypeUnion output_type) { + Node* node, MachineType output_type) { // Eagerly fold representation changes for constants. switch (node->opcode()) { case IrOpcode::kInt32Constant: @@ -316,43 +325,49 @@ Node* RepresentationChanger::GetWord32RepresentationFor( const Operator* op; Type* type = NodeProperties::GetType(node); - if (output_type & kRepBit) { + if (output_type.representation() == MachineRepresentation::kBit) { return node; // Sloppy comparison -> word32 - } else if (output_type & kRepFloat64) { - if (output_type & kTypeUint32 || type->Is(Type::Unsigned32())) { + } else if (output_type.representation() == MachineRepresentation::kFloat64) { + if (output_type.semantic() == MachineSemantic::kUint32 || + type->Is(Type::Unsigned32())) { op = machine()->ChangeFloat64ToUint32(); - } else if (output_type & kTypeInt32 || type->Is(Type::Signed32())) { + } else if (output_type.semantic() == MachineSemantic::kInt32 || + type->Is(Type::Signed32())) { op = machine()->ChangeFloat64ToInt32(); } else { op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript); } - } else if (output_type & kRepFloat32) { + } else if (output_type.representation() == MachineRepresentation::kFloat32) { node = InsertChangeFloat32ToFloat64(node); // float32 -> float64 -> int32 - if (output_type & kTypeUint32 || type->Is(Type::Unsigned32())) { + if (output_type.semantic() == MachineSemantic::kUint32 || + type->Is(Type::Unsigned32())) { op = machine()->ChangeFloat64ToUint32(); - } else if (output_type & kTypeInt32 || type->Is(Type::Signed32())) { + } else if (output_type.semantic() == MachineSemantic::kInt32 || + type->Is(Type::Signed32())) { op = machine()->ChangeFloat64ToInt32(); } else { op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript); } - } else if (output_type & kRepTagged) { - if (output_type & kTypeUint32 || type->Is(Type::Unsigned32())) { + } else if (output_type.representation() == MachineRepresentation::kTagged) { + if (output_type.semantic() == MachineSemantic::kUint32 || + type->Is(Type::Unsigned32())) { op = simplified()->ChangeTaggedToUint32(); - } else if (output_type & kTypeInt32 || type->Is(Type::Signed32())) { + } else if (output_type.semantic() == MachineSemantic::kInt32 || + type->Is(Type::Signed32())) { op = simplified()->ChangeTaggedToInt32(); } else { node = InsertChangeTaggedToFloat64(node); op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript); } } else { - return TypeError(node, output_type, kRepWord32); + return TypeError(node, output_type, MachineRepresentation::kWord32); } return jsgraph()->graph()->NewNode(op, node); } -Node* RepresentationChanger::GetBitRepresentationFor( - Node* node, MachineTypeUnion output_type) { +Node* RepresentationChanger::GetBitRepresentationFor(Node* node, + MachineType output_type) { // Eagerly fold representation changes for constants. switch (node->opcode()) { case IrOpcode::kHeapConstant: { @@ -367,22 +382,22 @@ Node* RepresentationChanger::GetBitRepresentationFor( } // Select the correct X -> Bit operator. const Operator* op; - if (output_type & kRepTagged) { + if (output_type.representation() == MachineRepresentation::kTagged) { op = simplified()->ChangeBoolToBit(); } else { - return TypeError(node, output_type, kRepBit); + return TypeError(node, output_type, MachineRepresentation::kBit); } return jsgraph()->graph()->NewNode(op, node); } Node* RepresentationChanger::GetWord64RepresentationFor( - Node* node, MachineTypeUnion output_type) { - if (output_type & kRepBit) { + Node* node, MachineType output_type) { + if (output_type.representation() == MachineRepresentation::kBit) { return node; // Sloppy comparison -> word64 } // Can't really convert Word64 to anything else. Purported to be internal. - return TypeError(node, output_type, kRepWord64); + return TypeError(node, output_type, MachineRepresentation::kWord64); } @@ -470,25 +485,25 @@ const Operator* RepresentationChanger::Float64OperatorFor( } -MachineType RepresentationChanger::TypeFromUpperBound(Type* type) { +MachineSemantic RepresentationChanger::TypeFromUpperBound(Type* type) { CHECK(!type->Is(Type::None())); - if (type->Is(Type::Signed32())) return kTypeInt32; - if (type->Is(Type::Unsigned32())) return kTypeUint32; - if (type->Is(Type::Number())) return kTypeNumber; - if (type->Is(Type::Boolean())) return kTypeBool; - return kTypeAny; + if (type->Is(Type::Signed32())) return MachineSemantic::kInt32; + if (type->Is(Type::Unsigned32())) return MachineSemantic::kUint32; + if (type->Is(Type::Number())) return MachineSemantic::kNumber; + if (type->Is(Type::Boolean())) return MachineSemantic::kBool; + return MachineSemantic::kAny; } -Node* RepresentationChanger::TypeError(Node* node, MachineTypeUnion output_type, - MachineTypeUnion use) { +Node* RepresentationChanger::TypeError(Node* node, MachineType output_type, + MachineRepresentation use) { type_error_ = true; if (!testing_type_errors_) { std::ostringstream out_str; - out_str << static_cast(output_type); + out_str << output_type; std::ostringstream use_str; - use_str << static_cast(use); + use_str << use; V8_Fatal(__FILE__, __LINE__, "RepresentationChangerError: node #%d:%s of " diff --git a/src/compiler/representation-change.h b/src/compiler/representation-change.h index c26fdd3dcd..b157b0b3fe 100644 --- a/src/compiler/representation-change.h +++ b/src/compiler/representation-change.h @@ -86,20 +86,22 @@ class RepresentationChanger final { // parameter is only used for sanity checking - if the changer cannot figure // out signedness for the word32->float64 conversion, then we check that the // uses truncate to word32 (so they do not care about signedness). - Node* GetRepresentationFor(Node* node, MachineTypeUnion output_type, - MachineTypeUnion use_rep, + Node* GetRepresentationFor(Node* node, MachineType output_type, + MachineRepresentation use_rep, Truncation truncation = Truncation::None()); const Operator* Int32OperatorFor(IrOpcode::Value opcode); const Operator* Uint32OperatorFor(IrOpcode::Value opcode); const Operator* Float64OperatorFor(IrOpcode::Value opcode); - MachineType TypeFromUpperBound(Type* type); + MachineSemantic TypeFromUpperBound(Type* type); MachineType TypeForBasePointer(const FieldAccess& access) { - return access.tag() != 0 ? kMachAnyTagged : kMachPtr; + return access.tag() != 0 ? MachineType::AnyTagged() + : MachineType::Pointer(); } MachineType TypeForBasePointer(const ElementAccess& access) { - return access.tag() != 0 ? kMachAnyTagged : kMachPtr; + return access.tag() != 0 ? MachineType::AnyTagged() + : MachineType::Pointer(); } private: @@ -111,16 +113,16 @@ class RepresentationChanger final { bool testing_type_errors_; // If {true}, don't abort on a type error. bool type_error_; // Set when a type error is detected. - Node* GetTaggedRepresentationFor(Node* node, MachineTypeUnion output_type); - Node* GetFloat32RepresentationFor(Node* node, MachineTypeUnion output_type, + Node* GetTaggedRepresentationFor(Node* node, MachineType output_type); + Node* GetFloat32RepresentationFor(Node* node, MachineType output_type, Truncation truncation); - Node* GetFloat64RepresentationFor(Node* node, MachineTypeUnion output_type, + Node* GetFloat64RepresentationFor(Node* node, MachineType output_type, Truncation truncation); - Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type); - Node* GetBitRepresentationFor(Node* node, MachineTypeUnion output_type); - Node* GetWord64RepresentationFor(Node* node, MachineTypeUnion output_type); - Node* TypeError(Node* node, MachineTypeUnion output_type, - MachineTypeUnion use); + Node* GetWord32RepresentationFor(Node* node, MachineType output_type); + Node* GetBitRepresentationFor(Node* node, MachineType output_type); + Node* GetWord64RepresentationFor(Node* node, MachineType output_type); + Node* TypeError(Node* node, MachineType output_type, + MachineRepresentation use); Node* MakeTruncatedInt32Constant(double value); Node* InsertChangeFloat32ToFloat64(Node* node); Node* InsertChangeTaggedToFloat64(Node* node); diff --git a/src/compiler/select-lowering.cc b/src/compiler/select-lowering.cc index 28a5d922b7..0e8b36fa73 100644 --- a/src/compiler/select-lowering.cc +++ b/src/compiler/select-lowering.cc @@ -55,7 +55,7 @@ Reduction SelectLowering::Reduce(Node* node) { node->ReplaceInput(0, vthen); node->ReplaceInput(1, velse); node->ReplaceInput(2, merge); - NodeProperties::ChangeOp(node, common()->Phi(p.type(), 2)); + NodeProperties::ChangeOp(node, common()->Phi(p.representation(), 2)); return Changed(node); } diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc index 9d00d44e32..bdc4787996 100644 --- a/src/compiler/simplified-lowering.cc +++ b/src/compiler/simplified-lowering.cc @@ -73,75 +73,80 @@ namespace { // need the signedness information to produce the correct value. class UseInfo { public: - UseInfo(MachineType preferred, Truncation truncation) - : preferred_(preferred), truncation_(truncation) { - DCHECK(preferred == (preferred & kRepMask)); - } + UseInfo(MachineRepresentation preferred, Truncation truncation) + : preferred_(preferred), truncation_(truncation) {} static UseInfo TruncatingWord32() { - return UseInfo(kRepWord32, Truncation::Word32()); + return UseInfo(MachineRepresentation::kWord32, Truncation::Word32()); } static UseInfo TruncatingWord64() { - return UseInfo(kRepWord64, Truncation::Word64()); + return UseInfo(MachineRepresentation::kWord64, Truncation::Word64()); + } + static UseInfo Bool() { + return UseInfo(MachineRepresentation::kBit, Truncation::Bool()); } - static UseInfo Bool() { return UseInfo(kRepBit, Truncation::Bool()); } static UseInfo Float32() { - return UseInfo(kRepFloat32, Truncation::Float32()); + return UseInfo(MachineRepresentation::kFloat32, Truncation::Float32()); } static UseInfo Float64() { - return UseInfo(kRepFloat64, Truncation::Float64()); + return UseInfo(MachineRepresentation::kFloat64, Truncation::Float64()); } static UseInfo PointerInt() { return kPointerSize == 4 ? TruncatingWord32() : TruncatingWord64(); } - static UseInfo AnyTagged() { return UseInfo(kRepTagged, Truncation::Any()); } + static UseInfo AnyTagged() { + return UseInfo(MachineRepresentation::kTagged, Truncation::Any()); + } // Undetermined representation. - static UseInfo Any() { return UseInfo(kMachNone, Truncation::Any()); } - static UseInfo None() { return UseInfo(kMachNone, Truncation::None()); } + static UseInfo Any() { + return UseInfo(MachineRepresentation::kNone, Truncation::Any()); + } + static UseInfo None() { + return UseInfo(MachineRepresentation::kNone, Truncation::None()); + } // Truncation to a representation that is smaller than the preferred // one. static UseInfo Float64TruncatingToWord32() { - return UseInfo(kRepFloat64, Truncation::Word32()); + return UseInfo(MachineRepresentation::kFloat64, Truncation::Word32()); } static UseInfo Word64TruncatingToWord32() { - return UseInfo(kRepWord64, Truncation::Word32()); + return UseInfo(MachineRepresentation::kWord64, Truncation::Word32()); } static UseInfo AnyTruncatingToBool() { - return UseInfo(kMachNone, Truncation::Bool()); + return UseInfo(MachineRepresentation::kNone, Truncation::Bool()); } - MachineType preferred() const { return preferred_; } + MachineRepresentation preferred() const { return preferred_; } Truncation truncation() const { return truncation_; } private: - MachineType preferred_; + MachineRepresentation preferred_; Truncation truncation_; }; -UseInfo UseInfoFromMachineType(MachineType type) { - MachineTypeUnion rep = RepresentationOf(type); - DCHECK((rep & kTypeMask) == 0); - - if (rep & kRepTagged) return UseInfo::AnyTagged(); - if (rep & kRepFloat64) { - DCHECK((rep & kRepWord64) == 0); +UseInfo TruncatingUseInfoFromRepresentation(MachineRepresentation rep) { + switch (rep) { + case MachineRepresentation::kTagged: + return UseInfo::AnyTagged(); + case MachineRepresentation::kFloat64: return UseInfo::Float64(); - } - if (rep & kRepFloat32) { - if (rep == kRepFloat32) return UseInfo::Float32(); - return UseInfo::AnyTagged(); - } - if (rep & kRepWord64) { + case MachineRepresentation::kFloat32: + return UseInfo::Float32(); + case MachineRepresentation::kWord64: return UseInfo::TruncatingWord64(); - } - if (rep & (kRepWord32 | kRepWord16 | kRepWord8)) { - CHECK(!(rep & kRepBit)); + case MachineRepresentation::kWord8: + case MachineRepresentation::kWord16: + case MachineRepresentation::kWord32: return UseInfo::TruncatingWord32(); + case MachineRepresentation::kBit: + return UseInfo::Bool(); + case MachineRepresentation::kNone: + break; } - DCHECK(rep & kRepBit); - return UseInfo::Bool(); + UNREACHABLE(); + return UseInfo::None(); } @@ -158,24 +163,27 @@ UseInfo UseInfoForBasePointer(const ElementAccess& access) { #ifdef DEBUG // Helpers for monotonicity checking. -bool MachineTypeIsSubtype(MachineType t1, MachineType t2) { +bool MachineTypeIsSubtype(MachineSemantic t1, MachineSemantic t2) { switch (t1) { - case kMachNone: + case MachineSemantic::kNone: return true; - case kTypeBool: - return t2 == kTypeBool || t2 == kTypeNumber || t2 == kTypeAny; - case kTypeInt32: - return t2 == kTypeInt32 || t2 == kTypeNumber || t2 == kTypeAny; - case kTypeUint32: - return t2 == kTypeUint32 || t2 == kTypeNumber || t2 == kTypeAny; - case kTypeInt64: - return t2 == kTypeInt64; - case kTypeUint64: - return t2 == kTypeUint64; - case kTypeNumber: - return t2 == kTypeNumber || t2 == kTypeAny; - case kTypeAny: - return t2 == kTypeAny; + case MachineSemantic::kBool: + return t2 == MachineSemantic::kBool || t2 == MachineSemantic::kNumber || + t2 == MachineSemantic::kAny; + case MachineSemantic::kInt32: + return t2 == MachineSemantic::kInt32 || t2 == MachineSemantic::kNumber || + t2 == MachineSemantic::kAny; + case MachineSemantic::kUint32: + return t2 == MachineSemantic::kUint32 || t2 == MachineSemantic::kNumber || + t2 == MachineSemantic::kAny; + case MachineSemantic::kInt64: + return t2 == MachineSemantic::kInt64; + case MachineSemantic::kUint64: + return t2 == MachineSemantic::kUint64; + case MachineSemantic::kNumber: + return t2 == MachineSemantic::kNumber || t2 == MachineSemantic::kAny; + case MachineSemantic::kAny: + return t2 == MachineSemantic::kAny; default: break; } @@ -184,30 +192,45 @@ bool MachineTypeIsSubtype(MachineType t1, MachineType t2) { } -bool MachineRepresentationIsSubtype(MachineType r1, MachineType r2) { +bool MachineRepresentationIsSubtype(MachineRepresentation r1, + MachineRepresentation r2) { switch (r1) { - case kMachNone: + case MachineRepresentation::kNone: return true; - case kRepBit: - return r2 == kRepBit || r2 == kRepTagged; - case kRepWord8: - return r2 == kRepWord8 || r2 == kRepWord16 || r2 == kRepWord32 || - r2 == kRepWord64 || r2 == kRepFloat32 || r2 == kRepFloat64 || - r2 == kRepTagged; - case kRepWord16: - return r2 == kRepWord16 || r2 == kRepWord32 || r2 == kRepWord64 || - r2 == kRepFloat32 || r2 == kRepFloat64 || r2 == kRepTagged; - case kRepWord32: - return r2 == kRepWord32 || r2 == kRepWord64 || r2 == kRepFloat64 || - r2 == kRepTagged; - case kRepWord64: - return r2 == kRepWord64; - case kRepFloat32: - return r2 == kRepFloat32 || r2 == kRepFloat64 || r2 == kRepTagged; - case kRepFloat64: - return r2 == kRepFloat64 || r2 == kRepTagged; - case kRepTagged: - return r2 == kRepTagged; + case MachineRepresentation::kBit: + return r2 == MachineRepresentation::kBit || + r2 == MachineRepresentation::kTagged; + case MachineRepresentation::kWord8: + return r2 == MachineRepresentation::kWord8 || + r2 == MachineRepresentation::kWord16 || + r2 == MachineRepresentation::kWord32 || + r2 == MachineRepresentation::kWord64 || + r2 == MachineRepresentation::kFloat32 || + r2 == MachineRepresentation::kFloat64 || + r2 == MachineRepresentation::kTagged; + case MachineRepresentation::kWord16: + return r2 == MachineRepresentation::kWord16 || + r2 == MachineRepresentation::kWord32 || + r2 == MachineRepresentation::kWord64 || + r2 == MachineRepresentation::kFloat32 || + r2 == MachineRepresentation::kFloat64 || + r2 == MachineRepresentation::kTagged; + case MachineRepresentation::kWord32: + return r2 == MachineRepresentation::kWord32 || + r2 == MachineRepresentation::kWord64 || + r2 == MachineRepresentation::kFloat64 || + r2 == MachineRepresentation::kTagged; + case MachineRepresentation::kWord64: + return r2 == MachineRepresentation::kWord64; + case MachineRepresentation::kFloat32: + return r2 == MachineRepresentation::kFloat32 || + r2 == MachineRepresentation::kFloat64 || + r2 == MachineRepresentation::kTagged; + case MachineRepresentation::kFloat64: + return r2 == MachineRepresentation::kFloat64 || + r2 == MachineRepresentation::kTagged; + case MachineRepresentation::kTagged: + return r2 == MachineRepresentation::kTagged; default: break; } @@ -216,12 +239,10 @@ bool MachineRepresentationIsSubtype(MachineType r1, MachineType r2) { } -bool MachineTypeRepIsSubtype(MachineTypeUnion m1, MachineTypeUnion m2) { - return MachineTypeIsSubtype(static_cast(m1 & kTypeMask), - static_cast(m2 & kTypeMask)) && - MachineRepresentationIsSubtype( - static_cast(m1 & kRepMask), - static_cast(m2 & kRepMask)); +bool MachineTypeRepIsSubtype(MachineType m1, MachineType m2) { + return MachineTypeIsSubtype(m1.semantic(), m2.semantic()) && + MachineRepresentationIsSubtype(m1.representation(), + m2.representation()); } @@ -271,13 +292,13 @@ class RepresentationSelector { void set_visited() { visited_ = true; } bool visited() const { return visited_; } Truncation truncation() const { return truncation_; } - void set_output_type(MachineTypeUnion type) { output_ = type; } - MachineTypeUnion output_type() const { return output_; } + void set_output_type(MachineType type) { output_ = type; } + MachineType output_type() const { return output_; } private: bool queued_ = false; // Bookkeeping for the traversal. bool visited_ = false; // Bookkeeping for the traversal. - MachineTypeUnion output_ = kMachNone; // Output type of the node. + MachineType output_ = MachineType::None(); // Output type of the node. Truncation truncation_ = Truncation::None(); // Information about uses. }; @@ -394,12 +415,10 @@ class RepresentationSelector { bool lower() { return phase_ == LOWER; } - void SetOutput(Node* node, MachineTypeUnion output) { + void SetOutput(Node* node, MachineType output) { // Every node should have at most one output representation. Note that // phis can have 0, if they have not been used in a representation-inducing // instruction. - DCHECK((output & kRepMask) == 0 || - base::bits::IsPowerOfTwo32(output & kRepMask)); NodeInfo* info = GetInfo(node); DCHECK(MachineTypeRepIsSubtype(info->output_type(), output)); info->set_output_type(output); @@ -414,10 +433,10 @@ class RepresentationSelector { void ConvertInput(Node* node, int index, UseInfo use) { Node* input = node->InputAt(index); // In the change phase, insert a change before the use if necessary. - if (use.preferred() == kMachNone) + if (use.preferred() == MachineRepresentation::kNone) return; // No input requirement on the use. - MachineTypeUnion output = GetInfo(input)->output_type(); - if ((output & kRepMask) != use.preferred()) { + MachineType output = GetInfo(input)->output_type(); + if (output.representation() != use.preferred()) { // Output representation doesn't match usage. TRACE(" change: #%d:%s(@%d #%d:%s) ", node->id(), node->op()->mnemonic(), index, input->id(), input->op()->mnemonic()); @@ -472,7 +491,7 @@ class RepresentationSelector { // Helper for binops of the R x L -> O variety. void VisitBinop(Node* node, UseInfo left_use, UseInfo right_use, - MachineTypeUnion output) { + MachineType output) { DCHECK_EQ(2, node->op()->ValueInputCount()); ProcessInput(node, 0, left_use); ProcessInput(node, 1, right_use); @@ -483,95 +502,95 @@ class RepresentationSelector { } // Helper for binops of the I x I -> O variety. - void VisitBinop(Node* node, UseInfo input_use, MachineTypeUnion output) { + void VisitBinop(Node* node, UseInfo input_use, MachineType output) { VisitBinop(node, input_use, input_use, output); } // Helper for unops of the I -> O variety. - void VisitUnop(Node* node, UseInfo input_use, MachineTypeUnion output) { + void VisitUnop(Node* node, UseInfo input_use, MachineType output) { DCHECK_EQ(1, node->InputCount()); ProcessInput(node, 0, input_use); SetOutput(node, output); } // Helper for leaf nodes. - void VisitLeaf(Node* node, MachineTypeUnion output) { + void VisitLeaf(Node* node, MachineType output) { DCHECK_EQ(0, node->InputCount()); SetOutput(node, output); } // Helpers for specific types of binops. void VisitFloat64Binop(Node* node) { - VisitBinop(node, UseInfo::Float64(), kMachFloat64); + VisitBinop(node, UseInfo::Float64(), MachineType::Float64()); } void VisitInt32Binop(Node* node) { - VisitBinop(node, UseInfo::TruncatingWord32(), kMachInt32); + VisitBinop(node, UseInfo::TruncatingWord32(), MachineType::Int32()); } void VisitUint32Binop(Node* node) { - VisitBinop(node, UseInfo::TruncatingWord32(), kMachUint32); + VisitBinop(node, UseInfo::TruncatingWord32(), MachineType::Uint32()); } void VisitInt64Binop(Node* node) { - VisitBinop(node, UseInfo::TruncatingWord64(), kMachInt64); + VisitBinop(node, UseInfo::TruncatingWord64(), MachineType::Int64()); } void VisitUint64Binop(Node* node) { - VisitBinop(node, UseInfo::TruncatingWord64(), kMachUint64); + VisitBinop(node, UseInfo::TruncatingWord64(), MachineType::Uint64()); } void VisitFloat64Cmp(Node* node) { - VisitBinop(node, UseInfo::Float64(), kMachBool); + VisitBinop(node, UseInfo::Float64(), MachineType::Bool()); } void VisitInt32Cmp(Node* node) { - VisitBinop(node, UseInfo::TruncatingWord32(), kMachBool); + VisitBinop(node, UseInfo::TruncatingWord32(), MachineType::Bool()); } void VisitUint32Cmp(Node* node) { - VisitBinop(node, UseInfo::TruncatingWord32(), kMachBool); + VisitBinop(node, UseInfo::TruncatingWord32(), MachineType::Bool()); } void VisitInt64Cmp(Node* node) { - VisitBinop(node, UseInfo::TruncatingWord64(), kMachBool); + VisitBinop(node, UseInfo::TruncatingWord64(), MachineType::Bool()); } void VisitUint64Cmp(Node* node) { - VisitBinop(node, UseInfo::TruncatingWord64(), kMachBool); + VisitBinop(node, UseInfo::TruncatingWord64(), MachineType::Bool()); } // Infer representation for phi-like nodes. - static MachineType GetRepresentationForPhi(Node* node, Truncation use) { + static MachineRepresentation GetRepresentationForPhi(Node* node, + Truncation use) { // Phis adapt to the output representation their uses demand. Type* upper = NodeProperties::GetType(node); if (upper->Is(Type::Signed32()) || upper->Is(Type::Unsigned32())) { // We are within 32 bits range => pick kRepWord32. - return kRepWord32; + return MachineRepresentation::kWord32; } else if (use.TruncatesToWord32()) { // We only use 32 bits. - return kRepWord32; + return MachineRepresentation::kWord32; } else if (upper->Is(Type::Boolean())) { // multiple uses => pick kRepBit. - return kRepBit; + return MachineRepresentation::kBit; } else if (upper->Is(Type::Number())) { // multiple uses => pick kRepFloat64. - return kRepFloat64; + return MachineRepresentation::kFloat64; } else if (upper->Is(Type::Internal())) { - return kMachPtr; + return MachineType::PointerRepresentation(); } - return kRepTagged; + return MachineRepresentation::kTagged; } // Helper for handling selects. void VisitSelect(Node* node, Truncation truncation, SimplifiedLowering* lowering) { ProcessInput(node, 0, UseInfo::Bool()); - MachineType output = GetRepresentationForPhi(node, truncation); + MachineRepresentation output = GetRepresentationForPhi(node, truncation); Type* upper = NodeProperties::GetType(node); MachineType output_type = - static_cast(changer_->TypeFromUpperBound(upper) | output); + MachineType(output, changer_->TypeFromUpperBound(upper)); SetOutput(node, output_type); if (lower()) { // Update the select operator. SelectParameters p = SelectParametersOf(node->op()); - MachineType type = static_cast(output_type); - if (type != p.type()) { + if (output != p.representation()) { NodeProperties::ChangeOp(node, - lowering->common()->Select(type, p.hint())); + lowering->common()->Select(output, p.hint())); } } // Convert inputs to the output representation of this phi, pass the @@ -584,20 +603,19 @@ class RepresentationSelector { // Helper for handling phis. void VisitPhi(Node* node, Truncation truncation, SimplifiedLowering* lowering) { - MachineType output = GetRepresentationForPhi(node, truncation); + MachineRepresentation output = GetRepresentationForPhi(node, truncation); Type* upper = NodeProperties::GetType(node); MachineType output_type = - static_cast(changer_->TypeFromUpperBound(upper) | output); + MachineType(output, changer_->TypeFromUpperBound(upper)); SetOutput(node, output_type); int values = node->op()->ValueInputCount(); if (lower()) { // Update the phi operator. - MachineType type = static_cast(output_type); - if (type != OpParameter(node)) { - NodeProperties::ChangeOp(node, lowering->common()->Phi(type, values)); + if (output != PhiRepresentationOf(node->op())) { + NodeProperties::ChangeOp(node, lowering->common()->Phi(output, values)); } } @@ -619,7 +637,8 @@ class RepresentationSelector { // The target of the call. ProcessInput(node, i, UseInfo::None()); } else if ((i - 1) < params) { - ProcessInput(node, i, UseInfoFromMachineType(sig->GetParam(i - 1))); + ProcessInput(node, i, TruncatingUseInfoFromRepresentation( + sig->GetParam(i - 1).representation())); } else { ProcessInput(node, i, UseInfo::None()); } @@ -628,7 +647,7 @@ class RepresentationSelector { if (sig->return_count() > 0) { SetOutput(node, desc->GetMachineSignature()->GetReturn()); } else { - SetOutput(node, kMachAnyTagged); + SetOutput(node, MachineType::AnyTagged()); } } @@ -643,13 +662,13 @@ class RepresentationSelector { new (zone->New(sizeof(ZoneVector))) ZoneVector(node->InputCount(), zone); for (int i = 0; i < node->InputCount(); i++) { - MachineTypeUnion input_type = GetInfo(node->InputAt(i))->output_type(); - (*types)[i] = static_cast(input_type); + MachineType input_type = GetInfo(node->InputAt(i))->output_type(); + (*types)[i] = input_type; } NodeProperties::ChangeOp(node, jsgraph_->common()->TypedStateValues(types)); } - SetOutput(node, kMachAnyTagged); + SetOutput(node, MachineType::AnyTagged()); } const Operator* Int32Op(Node* node) { @@ -700,28 +719,29 @@ class RepresentationSelector { //------------------------------------------------------------------ case IrOpcode::kStart: case IrOpcode::kDead: - return VisitLeaf(node, 0); + return VisitLeaf(node, MachineType::None()); case IrOpcode::kParameter: { // TODO(titzer): use representation from linkage. Type* upper = NodeProperties::GetType(node); ProcessInput(node, 0, UseInfo::None()); - SetOutput(node, kRepTagged | changer_->TypeFromUpperBound(upper)); + SetOutput(node, MachineType(MachineRepresentation::kTagged, + changer_->TypeFromUpperBound(upper))); return; } case IrOpcode::kInt32Constant: - return VisitLeaf(node, kRepWord32); + return VisitLeaf(node, MachineType::RepWord32()); case IrOpcode::kInt64Constant: - return VisitLeaf(node, kRepWord64); + return VisitLeaf(node, MachineType::RepWord64()); case IrOpcode::kFloat32Constant: - return VisitLeaf(node, kRepFloat32); + return VisitLeaf(node, MachineType::RepFloat32()); case IrOpcode::kFloat64Constant: - return VisitLeaf(node, kRepFloat64); + return VisitLeaf(node, MachineType::RepFloat64()); case IrOpcode::kExternalConstant: - return VisitLeaf(node, kMachPtr); + return VisitLeaf(node, MachineType::Pointer()); case IrOpcode::kNumberConstant: - return VisitLeaf(node, kRepTagged); + return VisitLeaf(node, MachineType::RepTagged()); case IrOpcode::kHeapConstant: - return VisitLeaf(node, kRepTagged); + return VisitLeaf(node, MachineType::RepTagged()); case IrOpcode::kBranch: ProcessInput(node, 0, UseInfo::Bool()); @@ -750,15 +770,15 @@ class RepresentationSelector { JS_OP_LIST(DEFINE_JS_CASE) #undef DEFINE_JS_CASE VisitInputs(node); - return SetOutput(node, kRepTagged); + return SetOutput(node, MachineType::RepTagged()); //------------------------------------------------------------------ // Simplified operators. //------------------------------------------------------------------ case IrOpcode::kBooleanNot: { if (lower()) { - MachineTypeUnion input = GetInfo(node->InputAt(0))->output_type(); - if (input & kRepBit) { + MachineType input = GetInfo(node->InputAt(0))->output_type(); + if (input.representation() == MachineRepresentation::kBit) { // BooleanNot(x: kRepBit) => Word32Equal(x, #0) node->AppendInput(jsgraph_->zone(), jsgraph_->Int32Constant(0)); NodeProperties::ChangeOp(node, lowering->machine()->Word32Equal()); @@ -770,14 +790,14 @@ class RepresentationSelector { } else { // No input representation requirement; adapt during lowering. ProcessInput(node, 0, UseInfo::AnyTruncatingToBool()); - SetOutput(node, kRepBit); + SetOutput(node, MachineType::RepBit()); } break; } case IrOpcode::kBooleanToNumber: { if (lower()) { - MachineTypeUnion input = GetInfo(node->InputAt(0))->output_type(); - if (input & kRepBit) { + MachineType input = GetInfo(node->InputAt(0))->output_type(); + if (input.representation() == MachineRepresentation::kBit) { // BooleanToNumber(x: kRepBit) => x DeferReplacement(node, node->InputAt(0)); } else { @@ -788,7 +808,7 @@ class RepresentationSelector { } else { // No input representation requirement; adapt during lowering. ProcessInput(node, 0, UseInfo::AnyTruncatingToBool()); - SetOutput(node, kMachInt32); + SetOutput(node, MachineType::Int32()); } break; } @@ -887,36 +907,36 @@ class RepresentationSelector { } case IrOpcode::kNumberShiftLeft: { VisitBinop(node, UseInfo::TruncatingWord32(), - UseInfo::TruncatingWord32(), kMachInt32); + UseInfo::TruncatingWord32(), MachineType::Int32()); if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shl()); break; } case IrOpcode::kNumberShiftRight: { VisitBinop(node, UseInfo::TruncatingWord32(), - UseInfo::TruncatingWord32(), kMachInt32); + UseInfo::TruncatingWord32(), MachineType::Int32()); if (lower()) lowering->DoShift(node, lowering->machine()->Word32Sar()); break; } case IrOpcode::kNumberShiftRightLogical: { VisitBinop(node, UseInfo::TruncatingWord32(), - UseInfo::TruncatingWord32(), kMachUint32); + UseInfo::TruncatingWord32(), MachineType::Uint32()); if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shr()); break; } case IrOpcode::kNumberToInt32: { // Just change representation if necessary. - VisitUnop(node, UseInfo::TruncatingWord32(), kMachInt32); + VisitUnop(node, UseInfo::TruncatingWord32(), MachineType::Int32()); if (lower()) DeferReplacement(node, node->InputAt(0)); break; } case IrOpcode::kNumberToUint32: { // Just change representation if necessary. - VisitUnop(node, UseInfo::TruncatingWord32(), kMachUint32); + VisitUnop(node, UseInfo::TruncatingWord32(), MachineType::Uint32()); if (lower()) DeferReplacement(node, node->InputAt(0)); break; } case IrOpcode::kNumberIsHoleNaN: { - VisitUnop(node, UseInfo::Float64(), kMachBool); + VisitUnop(node, UseInfo::Float64(), MachineType::Bool()); if (lower()) { // NumberIsHoleNaN(x) => Word32Equal(Float64ExtractLowWord32(x), // #HoleNaNLower32) @@ -931,7 +951,9 @@ class RepresentationSelector { break; } case IrOpcode::kPlainPrimitiveToNumber: { - VisitUnop(node, UseInfo::AnyTagged(), kTypeNumber | kRepTagged); + VisitUnop(node, UseInfo::AnyTagged(), + MachineType(MachineRepresentation::kTagged, + MachineSemantic::kNumber)); if (lower()) { // PlainPrimitiveToNumber(x) => Call(ToNumberStub, x, no-context) Operator::Properties properties = node->op()->properties(); @@ -948,31 +970,31 @@ class RepresentationSelector { break; } case IrOpcode::kReferenceEqual: { - VisitBinop(node, UseInfo::AnyTagged(), kMachBool); + VisitBinop(node, UseInfo::AnyTagged(), MachineType::Bool()); if (lower()) { NodeProperties::ChangeOp(node, lowering->machine()->WordEqual()); } break; } case IrOpcode::kStringEqual: { - VisitBinop(node, UseInfo::AnyTagged(), kMachBool); + VisitBinop(node, UseInfo::AnyTagged(), MachineType::Bool()); if (lower()) lowering->DoStringEqual(node); break; } case IrOpcode::kStringLessThan: { - VisitBinop(node, UseInfo::AnyTagged(), kMachBool); + VisitBinop(node, UseInfo::AnyTagged(), MachineType::Bool()); if (lower()) lowering->DoStringLessThan(node); break; } case IrOpcode::kStringLessThanOrEqual: { - VisitBinop(node, UseInfo::AnyTagged(), kMachBool); + VisitBinop(node, UseInfo::AnyTagged(), MachineType::Bool()); if (lower()) lowering->DoStringLessThanOrEqual(node); break; } case IrOpcode::kAllocate: { ProcessInput(node, 0, UseInfo::AnyTagged()); ProcessRemainingInputs(node, 1); - SetOutput(node, kMachAnyTagged); + SetOutput(node, MachineType::AnyTagged()); break; } case IrOpcode::kLoadField: { @@ -985,9 +1007,10 @@ class RepresentationSelector { case IrOpcode::kStoreField: { FieldAccess access = FieldAccessOf(node->op()); ProcessInput(node, 0, UseInfoForBasePointer(access)); - ProcessInput(node, 1, UseInfoFromMachineType(access.machine_type)); + ProcessInput(node, 1, TruncatingUseInfoFromRepresentation( + access.machine_type.representation())); ProcessRemainingInputs(node, 2); - SetOutput(node, 0); + SetOutput(node, MachineType::None()); break; } case IrOpcode::kLoadBuffer: { @@ -1007,16 +1030,17 @@ class RepresentationSelector { // If undefined is truncated to a number, but the use can // observe NaN, we need to output at least the float32 // representation. - if (access.machine_type() & kRepFloat32) { + if (access.machine_type().representation() == + MachineRepresentation::kFloat32) { output_type = access.machine_type(); } else { - output_type = kMachFloat64; + output_type = MachineType::Float64(); } } } else { // If undefined is not truncated away, we need to have the tagged // representation. - output_type = kMachAnyTagged; + output_type = MachineType::AnyTagged(); } SetOutput(node, output_type); if (lower()) lowering->DoLoadBuffer(node, output_type, changer_); @@ -1028,9 +1052,10 @@ class RepresentationSelector { ProcessInput(node, 1, UseInfo::TruncatingWord32()); // offset ProcessInput(node, 2, UseInfo::TruncatingWord32()); // length ProcessInput(node, 3, - UseInfoFromMachineType(access.machine_type())); // value + TruncatingUseInfoFromRepresentation( + access.machine_type().representation())); // value ProcessRemainingInputs(node, 4); - SetOutput(node, 0); + SetOutput(node, MachineType::None()); if (lower()) lowering->DoStoreBuffer(node); break; } @@ -1047,20 +1072,21 @@ class RepresentationSelector { ProcessInput(node, 0, UseInfoForBasePointer(access)); // base ProcessInput(node, 1, UseInfo::TruncatingWord32()); // index ProcessInput(node, 2, - UseInfoFromMachineType(access.machine_type)); // value + TruncatingUseInfoFromRepresentation( + access.machine_type.representation())); // value ProcessRemainingInputs(node, 3); - SetOutput(node, 0); + SetOutput(node, MachineType::None()); break; } case IrOpcode::kObjectIsNumber: { ProcessInput(node, 0, UseInfo::AnyTagged()); - SetOutput(node, kMachBool); + SetOutput(node, MachineType::Bool()); if (lower()) lowering->DoObjectIsNumber(node); break; } case IrOpcode::kObjectIsSmi: { ProcessInput(node, 0, UseInfo::AnyTagged()); - SetOutput(node, kMachBool); + SetOutput(node, MachineType::Bool()); if (lower()) lowering->DoObjectIsSmi(node); break; } @@ -1071,7 +1097,7 @@ class RepresentationSelector { case IrOpcode::kLoad: { // TODO(jarin) Eventually, we should get rid of all machine stores // from the high-level phases, then this becomes UNREACHABLE. - LoadRepresentation rep = OpParameter(node); + LoadRepresentation rep = LoadRepresentationOf(node->op()); ProcessInput(node, 0, UseInfo::AnyTagged()); // tagged pointer ProcessInput(node, 1, UseInfo::PointerInt()); // index ProcessRemainingInputs(node, 2); @@ -1081,17 +1107,19 @@ class RepresentationSelector { case IrOpcode::kStore: { // TODO(jarin) Eventually, we should get rid of all machine stores // from the high-level phases, then this becomes UNREACHABLE. - StoreRepresentation rep = OpParameter(node); + StoreRepresentation rep = StoreRepresentationOf(node->op()); ProcessInput(node, 0, UseInfo::AnyTagged()); // tagged pointer ProcessInput(node, 1, UseInfo::PointerInt()); // index - ProcessInput(node, 2, UseInfoFromMachineType(rep.machine_type())); + ProcessInput(node, 2, TruncatingUseInfoFromRepresentation( + rep.machine_type().representation())); ProcessRemainingInputs(node, 3); - SetOutput(node, 0); + SetOutput(node, MachineType::None()); break; } case IrOpcode::kWord32Shr: // We output unsigned int32 for shift right because JavaScript. - return VisitBinop(node, UseInfo::TruncatingWord32(), kMachUint32); + return VisitBinop(node, UseInfo::TruncatingWord32(), + MachineType::Uint32()); case IrOpcode::kWord32And: case IrOpcode::kWord32Or: case IrOpcode::kWord32Xor: @@ -1101,12 +1129,14 @@ class RepresentationSelector { // though the machine bits are the same for either signed or unsigned, // because JavaScript considers the result from these operations signed. return VisitBinop(node, UseInfo::TruncatingWord32(), - kRepWord32 | kTypeInt32); + MachineType::Int32()); case IrOpcode::kWord32Equal: - return VisitBinop(node, UseInfo::TruncatingWord32(), kMachBool); + return VisitBinop(node, UseInfo::TruncatingWord32(), + MachineType::Bool()); case IrOpcode::kWord32Clz: - return VisitUnop(node, UseInfo::TruncatingWord32(), kMachUint32); + return VisitUnop(node, UseInfo::TruncatingWord32(), + MachineType::Uint32()); case IrOpcode::kInt32Add: case IrOpcode::kInt32Sub: @@ -1150,39 +1180,46 @@ class RepresentationSelector { case IrOpcode::kWord64Shl: case IrOpcode::kWord64Shr: case IrOpcode::kWord64Sar: - return VisitBinop(node, UseInfo::TruncatingWord64(), kRepWord64); + return VisitBinop(node, UseInfo::TruncatingWord64(), + MachineType(MachineRepresentation::kWord64, + MachineSemantic::kNone)); case IrOpcode::kWord64Equal: - return VisitBinop(node, UseInfo::TruncatingWord64(), kMachBool); + return VisitBinop(node, UseInfo::TruncatingWord64(), + MachineType::Bool()); case IrOpcode::kChangeInt32ToInt64: return VisitUnop(node, UseInfo::TruncatingWord32(), - kTypeInt32 | kRepWord64); + MachineType(MachineRepresentation::kWord64, + MachineSemantic::kInt32)); case IrOpcode::kChangeUint32ToUint64: return VisitUnop(node, UseInfo::TruncatingWord32(), - kTypeUint32 | kRepWord64); + MachineType(MachineRepresentation::kWord64, + MachineSemantic::kUint32)); case IrOpcode::kTruncateFloat64ToFloat32: - return VisitUnop(node, UseInfo::Float64(), kTypeNumber | kRepFloat32); + return VisitUnop(node, UseInfo::Float64(), MachineType::Float32()); case IrOpcode::kTruncateFloat64ToInt32: - return VisitUnop(node, UseInfo::Float64(), kTypeInt32 | kRepWord32); + return VisitUnop(node, UseInfo::Float64(), MachineType::Int32()); case IrOpcode::kTruncateInt64ToInt32: // TODO(titzer): Is kTypeInt32 correct here? return VisitUnop(node, UseInfo::Word64TruncatingToWord32(), - kTypeInt32 | kRepWord32); + MachineType::Int32()); case IrOpcode::kChangeFloat32ToFloat64: - return VisitUnop(node, UseInfo::Float32(), kTypeNumber | kRepFloat64); + return VisitUnop(node, UseInfo::Float32(), MachineType::Float64()); case IrOpcode::kChangeInt32ToFloat64: return VisitUnop(node, UseInfo::TruncatingWord32(), - kTypeInt32 | kRepFloat64); + MachineType(MachineRepresentation::kFloat64, + MachineSemantic::kInt32)); case IrOpcode::kChangeUint32ToFloat64: return VisitUnop(node, UseInfo::TruncatingWord32(), - kTypeUint32 | kRepFloat64); + MachineType(MachineRepresentation::kFloat64, + MachineSemantic::kUint32)); case IrOpcode::kChangeFloat64ToInt32: return VisitUnop(node, UseInfo::Float64TruncatingToWord32(), - kTypeInt32 | kRepWord32); + MachineType::Int32()); case IrOpcode::kChangeFloat64ToUint32: return VisitUnop(node, UseInfo::Float64TruncatingToWord32(), - kTypeUint32 | kRepWord32); + MachineType::Uint32()); case IrOpcode::kFloat64Add: case IrOpcode::kFloat64Sub: @@ -1196,28 +1233,28 @@ class RepresentationSelector { case IrOpcode::kFloat64RoundDown: case IrOpcode::kFloat64RoundTruncate: case IrOpcode::kFloat64RoundTiesAway: - return VisitUnop(node, UseInfo::Float64(), kMachFloat64); + return VisitUnop(node, UseInfo::Float64(), MachineType::Float64()); case IrOpcode::kFloat64Equal: case IrOpcode::kFloat64LessThan: case IrOpcode::kFloat64LessThanOrEqual: return VisitFloat64Cmp(node); case IrOpcode::kFloat64ExtractLowWord32: case IrOpcode::kFloat64ExtractHighWord32: - return VisitUnop(node, UseInfo::Float64(), kMachInt32); + return VisitUnop(node, UseInfo::Float64(), MachineType::Int32()); case IrOpcode::kFloat64InsertLowWord32: case IrOpcode::kFloat64InsertHighWord32: return VisitBinop(node, UseInfo::Float64(), UseInfo::TruncatingWord32(), - kMachFloat64); + MachineType::Float64()); case IrOpcode::kLoadStackPointer: case IrOpcode::kLoadFramePointer: - return VisitLeaf(node, kMachPtr); + return VisitLeaf(node, MachineType::Pointer()); case IrOpcode::kStateValues: VisitStateValues(node); break; default: VisitInputs(node); // Assume the output is tagged. - SetOutput(node, kMachAnyTagged); + SetOutput(node, MachineType::AnyTagged()); break; } } @@ -1243,10 +1280,10 @@ class RepresentationSelector { node->NullAllInputs(); // Node is now dead. } - void PrintInfo(MachineTypeUnion info) { + void PrintInfo(MachineType info) { if (FLAG_trace_representation) { OFStream os(stdout); - os << static_cast(info); + os << info; } } @@ -1312,7 +1349,7 @@ void SimplifiedLowering::LowerAllNodes() { void SimplifiedLowering::DoLoadBuffer(Node* node, MachineType output_type, RepresentationChanger* changer) { DCHECK_EQ(IrOpcode::kLoadBuffer, node->opcode()); - DCHECK_NE(kMachNone, RepresentationOf(output_type)); + DCHECK_NE(MachineRepresentation::kNone, output_type.representation()); MachineType const type = BufferAccessOf(node->op()).machine_type(); if (output_type != type) { Node* const buffer = node->InputAt(0); @@ -1333,17 +1370,19 @@ void SimplifiedLowering::DoLoadBuffer(Node* node, MachineType output_type, Node* etrue = graph()->NewNode(machine()->Load(type), buffer, index, effect, if_true); Node* vtrue = changer->GetRepresentationFor( - etrue, type, RepresentationOf(output_type), Truncation::None()); + etrue, type, output_type.representation(), Truncation::None()); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* efalse = effect; Node* vfalse; - if (output_type & kRepTagged) { + if (output_type.representation() == MachineRepresentation::kTagged) { vfalse = jsgraph()->UndefinedConstant(); - } else if (output_type & kRepFloat64) { + } else if (output_type.representation() == + MachineRepresentation::kFloat64) { vfalse = jsgraph()->Float64Constant(std::numeric_limits::quiet_NaN()); - } else if (output_type & kRepFloat32) { + } else if (output_type.representation() == + MachineRepresentation::kFloat32) { vfalse = jsgraph()->Float32Constant(std::numeric_limits::quiet_NaN()); } else { @@ -1361,7 +1400,8 @@ void SimplifiedLowering::DoLoadBuffer(Node* node, MachineType output_type, node->ReplaceInput(1, vfalse); node->ReplaceInput(2, merge); node->TrimInputCount(3); - NodeProperties::ChangeOp(node, common()->Phi(output_type, 2)); + NodeProperties::ChangeOp(node, + common()->Phi(output_type.representation(), 2)); } else { NodeProperties::ChangeOp(node, machine()->CheckedLoad(type)); } @@ -1390,7 +1430,7 @@ void SimplifiedLowering::DoObjectIsNumber(Node* node) { Node* vfalse = graph()->NewNode( machine()->WordEqual(), graph()->NewNode( - machine()->Load(kMachAnyTagged), input, + machine()->Load(MachineType::AnyTagged()), input, jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), graph()->start(), if_false), jsgraph()->HeapConstant(isolate()->factory()->heap_number_map())); @@ -1398,7 +1438,7 @@ void SimplifiedLowering::DoObjectIsNumber(Node* node) { node->ReplaceInput(0, vtrue); node->AppendInput(graph()->zone(), vfalse); node->AppendInput(graph()->zone(), control); - NodeProperties::ChangeOp(node, common()->Phi(kMachBool, 2)); + NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); } @@ -1456,7 +1496,8 @@ Node* SimplifiedLowering::Int32Div(Node* const node) { // Note: We do not use the Diamond helper class here, because it really hurts // readability with nested diamonds. const Operator* const merge_op = common()->Merge(2); - const Operator* const phi_op = common()->Phi(kMachInt32, 2); + const Operator* const phi_op = + common()->Phi(MachineRepresentation::kWord32, 2); Node* check0 = graph()->NewNode(machine()->Int32LessThan(), zero, rhs); Node* branch0 = graph()->NewNode(common()->Branch(BranchHint::kTrue), check0, @@ -1533,7 +1574,8 @@ Node* SimplifiedLowering::Int32Mod(Node* const node) { // Note: We do not use the Diamond helper class here, because it really hurts // readability with nested diamonds. const Operator* const merge_op = common()->Merge(2); - const Operator* const phi_op = common()->Phi(kMachInt32, 2); + const Operator* const phi_op = + common()->Phi(MachineRepresentation::kWord32, 2); Node* check0 = graph()->NewNode(machine()->Int32LessThan(), zero, rhs); Node* branch0 = graph()->NewNode(common()->Branch(BranchHint::kTrue), check0, @@ -1612,7 +1654,7 @@ Node* SimplifiedLowering::Uint32Div(Node* const node) { Node* check = graph()->NewNode(machine()->Word32Equal(), rhs, zero); Diamond d(graph(), common(), check, BranchHint::kFalse); Node* div = graph()->NewNode(machine()->Uint32Div(), lhs, rhs, d.if_false); - return d.Phi(kMachUint32, zero, div); + return d.Phi(MachineRepresentation::kWord32, zero, div); } @@ -1644,7 +1686,8 @@ Node* SimplifiedLowering::Uint32Mod(Node* const node) { // Note: We do not use the Diamond helper class here, because it really hurts // readability with nested diamonds. const Operator* const merge_op = common()->Merge(2); - const Operator* const phi_op = common()->Phi(kMachInt32, 2); + const Operator* const phi_op = + common()->Phi(MachineRepresentation::kWord32, 2); Node* branch0 = graph()->NewNode(common()->Branch(BranchHint::kTrue), rhs, graph()->start()); diff --git a/src/compiler/simplified-operator.cc b/src/compiler/simplified-operator.cc index 5b973e1a94..1eaa287fee 100644 --- a/src/compiler/simplified-operator.cc +++ b/src/compiler/simplified-operator.cc @@ -29,24 +29,24 @@ MachineType BufferAccess::machine_type() const { switch (external_array_type_) { case kExternalUint8Array: case kExternalUint8ClampedArray: - return kMachUint8; + return MachineType::Uint8(); case kExternalInt8Array: - return kMachInt8; + return MachineType::Int8(); case kExternalUint16Array: - return kMachUint16; + return MachineType::Uint16(); case kExternalInt16Array: - return kMachInt16; + return MachineType::Int16(); case kExternalUint32Array: - return kMachUint32; + return MachineType::Uint32(); case kExternalInt32Array: - return kMachInt32; + return MachineType::Int32(); case kExternalFloat32Array: - return kMachFloat32; + return MachineType::Float32(); case kExternalFloat64Array: - return kMachFloat64; + return MachineType::Float64(); } UNREACHABLE(); - return kMachNone; + return MachineType::None(); } diff --git a/src/compiler/state-values-utils.cc b/src/compiler/state-values-utils.cc index 1c23c8ab88..77cc227038 100644 --- a/src/compiler/state-values-utils.cc +++ b/src/compiler/state-values-utils.cc @@ -271,7 +271,7 @@ Node* StateValuesAccess::iterator::node() { MachineType StateValuesAccess::iterator::type() { Node* state = Top()->node; if (state->opcode() == IrOpcode::kStateValues) { - return kMachAnyTagged; + return MachineType::AnyTagged(); } else { DCHECK_EQ(IrOpcode::kTypedStateValues, state->opcode()); const ZoneVector* types = diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc index ff191fe580..d41eb7a490 100644 --- a/src/compiler/x64/instruction-selector-x64.cc +++ b/src/compiler/x64/instruction-selector-x64.cc @@ -108,30 +108,29 @@ class X64OperandGenerator final : public OperandGenerator { void InstructionSelector::VisitLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + LoadRepresentation load_rep = LoadRepresentationOf(node->op()); X64OperandGenerator g(this); ArchOpcode opcode; - switch (rep) { - case kRepFloat32: + switch (load_rep.representation()) { + case MachineRepresentation::kFloat32: opcode = kX64Movss; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kX64Movsd; break; - case kRepBit: // Fall through. - case kRepWord8: - opcode = typ == kTypeInt32 ? kX64Movsxbl : kX64Movzxbl; + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: + opcode = load_rep.IsSigned() ? kX64Movsxbl : kX64Movzxbl; break; - case kRepWord16: - opcode = typ == kTypeInt32 ? kX64Movsxwl : kX64Movzxwl; + case MachineRepresentation::kWord16: + opcode = load_rep.IsSigned() ? kX64Movsxwl : kX64Movzxwl; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kX64Movl; break; - case kRepTagged: // Fall through. - case kRepWord64: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord64: opcode = kX64Movq; break; default: @@ -158,10 +157,10 @@ void InstructionSelector::VisitStore(Node* node) { StoreRepresentation store_rep = OpParameter(node); WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); - MachineType rep = RepresentationOf(store_rep.machine_type()); + MachineRepresentation rep = store_rep.machine_type().representation(); if (write_barrier_kind != kNoWriteBarrier) { - DCHECK_EQ(kRepTagged, rep); + DCHECK_EQ(MachineRepresentation::kTagged, rep); AddressingMode addressing_mode; InstructionOperand inputs[3]; size_t input_count = 0; @@ -200,24 +199,24 @@ void InstructionSelector::VisitStore(Node* node) { } else { ArchOpcode opcode; switch (rep) { - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kX64Movss; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kX64Movsd; break; - case kRepBit: // Fall through. - case kRepWord8: + case MachineRepresentation::kBit: // Fall through. + case MachineRepresentation::kWord8: opcode = kX64Movb; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kX64Movw; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kX64Movl; break; - case kRepTagged: // Fall through. - case kRepWord64: + case MachineRepresentation::kTagged: // Fall through. + case MachineRepresentation::kWord64: opcode = kX64Movq; break; default: @@ -239,30 +238,29 @@ void InstructionSelector::VisitStore(Node* node) { void InstructionSelector::VisitCheckedLoad(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); - MachineType typ = TypeOf(OpParameter(node)); + CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); X64OperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); Node* const length = node->InputAt(2); ArchOpcode opcode; - switch (rep) { - case kRepWord8: - opcode = typ == kTypeInt32 ? kCheckedLoadInt8 : kCheckedLoadUint8; + switch (load_rep.representation()) { + case MachineRepresentation::kWord8: + opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; break; - case kRepWord16: - opcode = typ == kTypeInt32 ? kCheckedLoadInt16 : kCheckedLoadUint16; + case MachineRepresentation::kWord16: + opcode = load_rep.IsSigned() ? kCheckedLoadInt16 : kCheckedLoadUint16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedLoadWord32; break; - case kRepWord64: + case MachineRepresentation::kWord64: opcode = kCheckedLoadWord64; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedLoadFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedLoadFloat64; break; default: @@ -289,7 +287,8 @@ void InstructionSelector::VisitCheckedLoad(Node* node) { void InstructionSelector::VisitCheckedStore(Node* node) { - MachineType rep = RepresentationOf(OpParameter(node)); + MachineRepresentation rep = + CheckedStoreRepresentationOf(node->op()).representation(); X64OperandGenerator g(this); Node* const buffer = node->InputAt(0); Node* const offset = node->InputAt(1); @@ -297,22 +296,22 @@ void InstructionSelector::VisitCheckedStore(Node* node) { Node* const value = node->InputAt(3); ArchOpcode opcode; switch (rep) { - case kRepWord8: + case MachineRepresentation::kWord8: opcode = kCheckedStoreWord8; break; - case kRepWord16: + case MachineRepresentation::kWord16: opcode = kCheckedStoreWord16; break; - case kRepWord32: + case MachineRepresentation::kWord32: opcode = kCheckedStoreWord32; break; - case kRepWord64: + case MachineRepresentation::kWord64: opcode = kCheckedStoreWord64; break; - case kRepFloat32: + case MachineRepresentation::kFloat32: opcode = kCheckedStoreFloat32; break; - case kRepFloat64: + case MachineRepresentation::kFloat64: opcode = kCheckedStoreFloat64; break; default: diff --git a/src/machine-type.cc b/src/machine-type.cc index c7dc0b47c8..1fb886ca52 100644 --- a/src/machine-type.cc +++ b/src/machine-type.cc @@ -8,37 +8,68 @@ namespace v8 { namespace internal { -#define PRINT(bit) \ - if (type & bit) { \ - if (before) os << "|"; \ - os << #bit; \ - before = true; \ +std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) { + switch (rep) { + case MachineRepresentation::kNone: + return os << "kMachNone"; + case MachineRepresentation::kBit: + return os << "kRepBit"; + case MachineRepresentation::kWord8: + return os << "kRepWord8"; + case MachineRepresentation::kWord16: + return os << "kRepWord16"; + case MachineRepresentation::kWord32: + return os << "kRepWord32"; + case MachineRepresentation::kWord64: + return os << "kRepWord64"; + case MachineRepresentation::kFloat32: + return os << "kRepFloat32"; + case MachineRepresentation::kFloat64: + return os << "kRepFloat64"; + case MachineRepresentation::kTagged: + return os << "kRepTagged"; } - - -std::ostream& operator<<(std::ostream& os, const MachineType& type) { - bool before = false; - PRINT(kRepBit); - PRINT(kRepWord8); - PRINT(kRepWord16); - PRINT(kRepWord32); - PRINT(kRepWord64); - PRINT(kRepFloat32); - PRINT(kRepFloat64); - PRINT(kRepTagged); - - PRINT(kTypeBool); - PRINT(kTypeInt32); - PRINT(kTypeUint32); - PRINT(kTypeInt64); - PRINT(kTypeUint64); - PRINT(kTypeNumber); - PRINT(kTypeAny); + UNREACHABLE(); return os; } -#undef PRINT +std::ostream& operator<<(std::ostream& os, MachineSemantic type) { + switch (type) { + case MachineSemantic::kNone: + return os << "kMachNone"; + case MachineSemantic::kBool: + return os << "kTypeBool"; + case MachineSemantic::kInt32: + return os << "kTypeInt32"; + case MachineSemantic::kUint32: + return os << "kTypeUint32"; + case MachineSemantic::kInt64: + return os << "kTypeInt64"; + case MachineSemantic::kUint64: + return os << "kTypeUint64"; + case MachineSemantic::kNumber: + return os << "kTypeNumber"; + case MachineSemantic::kAny: + return os << "kTypeAny"; + } + UNREACHABLE(); + return os; +} + + +std::ostream& operator<<(std::ostream& os, MachineType type) { + if (type == MachineType::None()) { + return os; + } else if (type.representation() == MachineRepresentation::kNone) { + return os << type.semantic(); + } else if (type.semantic() == MachineSemantic::kNone) { + return os << type.representation(); + } else { + return os << type.representation() << "|" << type.semantic(); + } + return os; +} } // namespace internal } // namespace v8 diff --git a/src/machine-type.h b/src/machine-type.h index 69a48e76f7..97f6ae3bbd 100644 --- a/src/machine-type.h +++ b/src/machine-type.h @@ -15,91 +15,179 @@ namespace v8 { namespace internal { -// Machine-level types and representations. -// TODO(titzer): Use the real type system instead of MachineType. -enum MachineType : uint16_t { - // Representations. - kRepBit = 1u << 0, - kRepWord8 = 1u << 1, - kRepWord16 = 1u << 2, - kRepWord32 = 1u << 3, - kRepWord64 = 1u << 4, - kRepFloat32 = 1u << 5, - kRepFloat64 = 1u << 6, - kRepTagged = 1u << 7, - - // Types. - kTypeBool = 1u << 8, - kTypeInt32 = 1u << 9, - kTypeUint32 = 1u << 10, - kTypeInt64 = 1u << 11, - kTypeUint64 = 1u << 12, - kTypeNumber = 1u << 13, - kTypeAny = 1u << 14, - - // Machine types. - kMachNone = 0u, - kMachBool = kRepBit | kTypeBool, - kMachFloat32 = kRepFloat32 | kTypeNumber, - kMachFloat64 = kRepFloat64 | kTypeNumber, - kMachInt8 = kRepWord8 | kTypeInt32, - kMachUint8 = kRepWord8 | kTypeUint32, - kMachInt16 = kRepWord16 | kTypeInt32, - kMachUint16 = kRepWord16 | kTypeUint32, - kMachInt32 = kRepWord32 | kTypeInt32, - kMachUint32 = kRepWord32 | kTypeUint32, - kMachInt64 = kRepWord64 | kTypeInt64, - kMachUint64 = kRepWord64 | kTypeUint64, - kMachIntPtr = (kPointerSize == 4) ? kMachInt32 : kMachInt64, - kMachUintPtr = (kPointerSize == 4) ? kMachUint32 : kMachUint64, - kMachPtr = (kPointerSize == 4) ? kRepWord32 : kRepWord64, - kMachAnyTagged = kRepTagged | kTypeAny +enum class MachineRepresentation : uint8_t { + kNone, + kBit, + kWord8, + kWord16, + kWord32, + kWord64, + kFloat32, + kFloat64, + kTagged }; +enum class MachineSemantic : uint8_t { + kNone, + kBool, + kInt32, + kUint32, + kInt64, + kUint64, + kNumber, + kAny +}; + +class MachineType { + public: + MachineType() + : representation_(MachineRepresentation::kNone), + semantic_(MachineSemantic::kNone) {} + MachineType(MachineRepresentation representation, MachineSemantic semantic) + : representation_(representation), semantic_(semantic) {} + + bool operator==(MachineType other) const { + return representation() == other.representation() && + semantic() == other.semantic(); + } + + bool operator!=(MachineType other) const { return !(*this == other); } + + + MachineRepresentation representation() const { return representation_; } + MachineSemantic semantic() const { return semantic_; } + + bool IsSigned() { + return semantic() == MachineSemantic::kInt32 || + semantic() == MachineSemantic::kInt64; + } + bool IsUnsigned() { + return semantic() == MachineSemantic::kUint32 || + semantic() == MachineSemantic::kUint64; + } + + static MachineRepresentation PointerRepresentation() { + return (kPointerSize == 4) ? MachineRepresentation::kWord32 + : MachineRepresentation::kWord64; + } + static MachineType Pointer() { + return MachineType(PointerRepresentation(), MachineSemantic::kNone); + } + static MachineType IntPtr() { + return (kPointerSize == 4) ? Int32() : Int64(); + } + static MachineType Float32() { + return MachineType(MachineRepresentation::kFloat32, + MachineSemantic::kNumber); + } + static MachineType Float64() { + return MachineType(MachineRepresentation::kFloat64, + MachineSemantic::kNumber); + } + static MachineType Int8() { + return MachineType(MachineRepresentation::kWord8, MachineSemantic::kInt32); + } + static MachineType Uint8() { + return MachineType(MachineRepresentation::kWord8, MachineSemantic::kUint32); + } + static MachineType Int16() { + return MachineType(MachineRepresentation::kWord16, MachineSemantic::kInt32); + } + static MachineType Uint16() { + return MachineType(MachineRepresentation::kWord16, + MachineSemantic::kUint32); + } + static MachineType Int32() { + return MachineType(MachineRepresentation::kWord32, MachineSemantic::kInt32); + } + static MachineType Uint32() { + return MachineType(MachineRepresentation::kWord32, + MachineSemantic::kUint32); + } + static MachineType Int64() { + return MachineType(MachineRepresentation::kWord64, MachineSemantic::kInt64); + } + static MachineType Uint64() { + return MachineType(MachineRepresentation::kWord64, + MachineSemantic::kUint64); + } + static MachineType AnyTagged() { + return MachineType(MachineRepresentation::kTagged, MachineSemantic::kAny); + } + static MachineType Bool() { + return MachineType(MachineRepresentation::kBit, MachineSemantic::kBool); + } + static MachineType TaggedBool() { + return MachineType(MachineRepresentation::kTagged, MachineSemantic::kBool); + } + static MachineType None() { + return MachineType(MachineRepresentation::kNone, MachineSemantic::kNone); + } + + // These naked representations should eventually go away. + static MachineType RepWord8() { + return MachineType(MachineRepresentation::kWord8, MachineSemantic::kNone); + } + static MachineType RepWord16() { + return MachineType(MachineRepresentation::kWord16, MachineSemantic::kNone); + } + static MachineType RepWord32() { + return MachineType(MachineRepresentation::kWord32, MachineSemantic::kNone); + } + static MachineType RepWord64() { + return MachineType(MachineRepresentation::kWord64, MachineSemantic::kNone); + } + static MachineType RepFloat32() { + return MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone); + } + static MachineType RepFloat64() { + return MachineType(MachineRepresentation::kFloat64, MachineSemantic::kNone); + } + static MachineType RepTagged() { + return MachineType(MachineRepresentation::kTagged, MachineSemantic::kNone); + } + static MachineType RepBit() { + return MachineType(MachineRepresentation::kBit, MachineSemantic::kNone); + } + + private: + MachineRepresentation representation_; + MachineSemantic semantic_; +}; + +V8_INLINE size_t hash_value(MachineRepresentation rep) { + return static_cast(rep); +} + V8_INLINE size_t hash_value(MachineType type) { - return static_cast(type); + return static_cast(type.representation()) + + static_cast(type.semantic()) * 16; } -std::ostream& operator<<(std::ostream& os, const MachineType& type); +std::ostream& operator<<(std::ostream& os, MachineRepresentation rep); +std::ostream& operator<<(std::ostream& os, MachineSemantic type); +std::ostream& operator<<(std::ostream& os, MachineType type); -typedef uint16_t MachineTypeUnion; - -// Globally useful machine types and constants. -const MachineTypeUnion kRepMask = kRepBit | kRepWord8 | kRepWord16 | - kRepWord32 | kRepWord64 | kRepFloat32 | - kRepFloat64 | kRepTagged; -const MachineTypeUnion kTypeMask = kTypeBool | kTypeInt32 | kTypeUint32 | - kTypeInt64 | kTypeUint64 | kTypeNumber | - kTypeAny; - -// Gets only the type of the given type. -inline MachineType TypeOf(MachineType machine_type) { - int result = machine_type & kTypeMask; - return static_cast(result); -} - -// Gets only the representation of the given type. -inline MachineType RepresentationOf(MachineType machine_type) { - int result = machine_type & kRepMask; - CHECK(base::bits::IsPowerOfTwo32(result)); - return static_cast(result); +inline bool IsFloatingPoint(MachineRepresentation rep) { + return rep == MachineRepresentation::kFloat32 || + rep == MachineRepresentation::kFloat64; } // Gets the log2 of the element size in bytes of the machine type. -inline int ElementSizeLog2Of(MachineType machine_type) { - switch (RepresentationOf(machine_type)) { - case kRepBit: - case kRepWord8: +inline int ElementSizeLog2Of(MachineRepresentation rep) { + switch (rep) { + case MachineRepresentation::kBit: + case MachineRepresentation::kWord8: return 0; - case kRepWord16: + case MachineRepresentation::kWord16: return 1; - case kRepWord32: - case kRepFloat32: + case MachineRepresentation::kWord32: + case MachineRepresentation::kFloat32: return 2; - case kRepWord64: - case kRepFloat64: + case MachineRepresentation::kWord64: + case MachineRepresentation::kFloat64: return 3; - case kRepTagged: + case MachineRepresentation::kTagged: return kPointerSizeLog2; default: break; @@ -108,18 +196,6 @@ inline int ElementSizeLog2Of(MachineType machine_type) { return -1; } -// Gets the element size in bytes of the machine type. -inline int ElementSizeOf(MachineType machine_type) { - const int shift = ElementSizeLog2Of(machine_type); - DCHECK_NE(-1, shift); - return 1 << shift; -} - -inline bool IsFloatingPoint(MachineType type) { - MachineType rep = RepresentationOf(type); - return rep == kRepFloat32 || rep == kRepFloat64; -} - typedef Signature MachineSignature; } // namespace internal diff --git a/test/cctest/compiler/c-signature.h b/test/cctest/compiler/c-signature.h index 7c537c04ea..13ef38aaed 100644 --- a/test/cctest/compiler/c-signature.h +++ b/test/cctest/compiler/c-signature.h @@ -12,20 +12,20 @@ namespace internal { namespace compiler { #define FOREACH_CTYPE_MACHINE_TYPE_MAPPING(V) \ - V(void, kMachNone) \ - V(bool, kMachUint8) \ - V(int8_t, kMachInt8) \ - V(uint8_t, kMachUint8) \ - V(int16_t, kMachInt16) \ - V(uint16_t, kMachUint16) \ - V(int32_t, kMachInt32) \ - V(uint32_t, kMachUint32) \ - V(int64_t, kMachInt64) \ - V(uint64_t, kMachUint64) \ - V(float, kMachFloat32) \ - V(double, kMachFloat64) \ - V(void*, kMachPtr) \ - V(int*, kMachPtr) + V(void, MachineType::None()) \ + V(bool, MachineType::Uint8()) \ + V(int8_t, MachineType::Int8()) \ + V(uint8_t, MachineType::Uint8()) \ + V(int16_t, MachineType::Int16()) \ + V(uint16_t, MachineType::Uint16()) \ + V(int32_t, MachineType::Int32()) \ + V(uint32_t, MachineType::Uint32()) \ + V(int64_t, MachineType::Int64()) \ + V(uint64_t, MachineType::Uint64()) \ + V(float, MachineType::Float32()) \ + V(double, MachineType::Float64()) \ + V(void*, MachineType::Pointer()) \ + V(int*, MachineType::Pointer()) template inline MachineType MachineTypeForC() { @@ -33,7 +33,7 @@ inline MachineType MachineTypeForC() { // All other types T must be assignable to Object* *(static_cast(0)) = static_cast(0); } - return kMachAnyTagged; + return MachineType::AnyTagged(); } #define DECLARE_TEMPLATE_SPECIALIZATION(ctype, mtype) \ @@ -64,7 +64,7 @@ class CSignature : public MachineSignature { if (p < static_cast(parameter_count())) { CHECK_EQ(GetParam(p), params[p]); } else { - CHECK_EQ(kMachNone, params[p]); + CHECK_EQ(MachineType::None(), params[p]); } } } @@ -74,13 +74,15 @@ class CSignature : public MachineSignature { } static CSignature* New(Zone* zone, MachineType ret, - MachineType p1 = kMachNone, MachineType p2 = kMachNone, - MachineType p3 = kMachNone, MachineType p4 = kMachNone, - MachineType p5 = kMachNone) { + MachineType p1 = MachineType::None(), + MachineType p2 = MachineType::None(), + MachineType p3 = MachineType::None(), + MachineType p4 = MachineType::None(), + MachineType p5 = MachineType::None()) { MachineType* buffer = zone->NewArray(6); int pos = 0; size_t return_count = 0; - if (ret != kMachNone) { + if (ret != MachineType::None()) { buffer[pos++] = ret; return_count++; } @@ -90,14 +92,15 @@ class CSignature : public MachineSignature { buffer[pos++] = p4; buffer[pos++] = p5; size_t param_count = 5; - if (p5 == kMachNone) param_count--; - if (p4 == kMachNone) param_count--; - if (p3 == kMachNone) param_count--; - if (p2 == kMachNone) param_count--; - if (p1 == kMachNone) param_count--; + if (p5 == MachineType::None()) param_count--; + if (p4 == MachineType::None()) param_count--; + if (p3 == MachineType::None()) param_count--; + if (p2 == MachineType::None()) param_count--; + if (p1 == MachineType::None()) param_count--; for (size_t i = 0; i < param_count; i++) { - // Check that there are no kMachNone's in the middle of parameters. - CHECK_NE(kMachNone, buffer[return_count + i]); + // Check that there are no MachineType::None()'s in the middle of + // parameters. + CHECK_NE(MachineType::None(), buffer[return_count + i]); } return new (zone) CSignature(return_count, param_count, buffer); } @@ -110,8 +113,8 @@ class CSignatureOf : public CSignature { MachineType storage_[1 + kParamCount]; CSignatureOf() - : CSignature(MachineTypeForC() != kMachNone ? 1 : 0, kParamCount, - reinterpret_cast(&storage_)) { + : CSignature(MachineTypeForC() != MachineType::None() ? 1 : 0, + kParamCount, reinterpret_cast(&storage_)) { if (return_count_ == 1) storage_[0] = MachineTypeForC(); } void Set(int index, MachineType type) { diff --git a/test/cctest/compiler/codegen-tester.cc b/test/cctest/compiler/codegen-tester.cc index ba73822d32..8e1ec0bfbb 100644 --- a/test/cctest/compiler/codegen-tester.cc +++ b/test/cctest/compiler/codegen-tester.cc @@ -291,7 +291,8 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { for (int i = -2; i < num_int_inputs; i++) { // for all left shapes for (int j = -2; j < num_int_inputs; j++) { // for all right shapes if (i >= 0 && j >= 0) break; // No constant/constant combos - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); Node* n0; @@ -301,7 +302,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { if (i == -2) { n0 = p0; } else if (i == -1) { - n0 = m.LoadFromPointer(&input_a, kMachInt32); + n0 = m.LoadFromPointer(&input_a, MachineType::Int32()); } else { n0 = m.Int32Constant(inputs[i]); } @@ -310,7 +311,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { if (j == -2) { n1 = p1; } else if (j == -1) { - n1 = m.LoadFromPointer(&input_b, kMachInt32); + n1 = m.LoadFromPointer(&input_b, MachineType::Int32()); } else { n1 = m.Int32Constant(inputs[j]); } @@ -368,7 +369,8 @@ void Int32BinopInputShapeTester::RunRight( TEST(ParametersEqual) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); Node* p1 = m.Parameter(1); CHECK(p1); Node* p0 = m.Parameter(0); @@ -482,7 +484,7 @@ TEST(RunHeapNumberConstant) { TEST(RunParam1) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); m.Return(m.Parameter(0)); FOR_INT32_INPUTS(i) { @@ -493,7 +495,8 @@ TEST(RunParam1) { TEST(RunParam2_1) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); m.Return(p0); @@ -507,7 +510,8 @@ TEST(RunParam2_1) { TEST(RunParam2_2) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); m.Return(p1); @@ -522,7 +526,8 @@ TEST(RunParam2_2) { TEST(RunParam3) { for (int i = 0; i < 3; i++) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); Node* nodes[] = {m.Parameter(0), m.Parameter(1), m.Parameter(2)}; m.Return(nodes[i]); @@ -580,12 +585,13 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { CHECK_EQ(0x12500000000, m.Call()); } { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.Parameter(0)); FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(*i, m.Call(*i)); } } { - BufferedRawMachineAssemblerTester m(kMachInt64, kMachInt64); + BufferedRawMachineAssemblerTester m(MachineType::Int64(), + MachineType::Int64()); m.Return(m.Int64Add(m.Parameter(0), m.Parameter(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { @@ -595,8 +601,8 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { } } { - BufferedRawMachineAssemblerTester m(kMachInt64, kMachInt64, - kMachInt64); + BufferedRawMachineAssemblerTester m( + MachineType::Int64(), MachineType::Int64(), MachineType::Int64()); m.Return( m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT64_INPUTS(i) { @@ -608,8 +614,9 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { } } { - BufferedRawMachineAssemblerTester m(kMachInt64, kMachInt64, - kMachInt64, kMachInt64); + BufferedRawMachineAssemblerTester m( + MachineType::Int64(), MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return(m.Int64Add( m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2)), m.Parameter(3))); @@ -632,7 +639,7 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { CHECK_EQ(0x12500000000, result); } { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); double result; m.Store(MachineTypeForC(), m.PointerConstant(&result), m.Parameter(0), kNoWriteBarrier); @@ -643,7 +650,8 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { } } { - BufferedRawMachineAssemblerTester m(kMachInt64, kMachInt64); + BufferedRawMachineAssemblerTester m(MachineType::Int64(), + MachineType::Int64()); int64_t result; m.Store(MachineTypeForC(), m.PointerConstant(&result), m.Int64Add(m.Parameter(0), m.Parameter(1)), kNoWriteBarrier); @@ -659,8 +667,8 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { } } { - BufferedRawMachineAssemblerTester m(kMachInt64, kMachInt64, - kMachInt64); + BufferedRawMachineAssemblerTester m( + MachineType::Int64(), MachineType::Int64(), MachineType::Int64()); int64_t result; m.Store( MachineTypeForC(), m.PointerConstant(&result), @@ -681,8 +689,9 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { } } { - BufferedRawMachineAssemblerTester m(kMachInt64, kMachInt64, - kMachInt64, kMachInt64); + BufferedRawMachineAssemblerTester m( + MachineType::Int64(), MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); int64_t result; m.Store(MachineTypeForC(), m.PointerConstant(&result), m.Int64Add(m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), diff --git a/test/cctest/compiler/codegen-tester.h b/test/cctest/compiler/codegen-tester.h index 1319f9421c..5572f8536b 100644 --- a/test/cctest/compiler/codegen-tester.h +++ b/test/cctest/compiler/codegen-tester.h @@ -20,11 +20,11 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, public CallHelper, public RawMachineAssembler { public: - RawMachineAssemblerTester(MachineType p0 = kMachNone, - MachineType p1 = kMachNone, - MachineType p2 = kMachNone, - MachineType p3 = kMachNone, - MachineType p4 = kMachNone) + RawMachineAssemblerTester(MachineType p0 = MachineType::None(), + MachineType p1 = MachineType::None(), + MachineType p2 = MachineType::None(), + MachineType p3 = MachineType::None(), + MachineType p4 = MachineType::None()) : HandleAndZoneScope(), CallHelper( main_isolate(), @@ -36,7 +36,8 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, main_zone(), CSignature::New(main_zone(), MachineTypeForC(), p0, p1, p2, p3, p4)), - kMachPtr, InstructionSelector::SupportedMachineOperatorFlags()) {} + MachineType::PointerRepresentation(), + InstructionSelector::SupportedMachineOperatorFlags()) {} void CheckNumber(double expected, Object* number) { CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number)); @@ -77,10 +78,10 @@ template class BufferedRawMachineAssemblerTester : public RawMachineAssemblerTester { public: - BufferedRawMachineAssemblerTester(MachineType p0 = kMachNone, - MachineType p1 = kMachNone, - MachineType p2 = kMachNone, - MachineType p3 = kMachNone) + BufferedRawMachineAssemblerTester(MachineType p0 = MachineType::None(), + MachineType p1 = MachineType::None(), + MachineType p2 = MachineType::None(), + MachineType p3 = MachineType::None()) : BufferedRawMachineAssemblerTester(ComputeParameterCount(p0, p1, p2, p3), p0, p1, p2, p3) {} @@ -159,36 +160,45 @@ class BufferedRawMachineAssemblerTester MachineType p0, MachineType p1, MachineType p2, MachineType p3) : RawMachineAssemblerTester( - kMachPtr, p0 == kMachNone ? kMachNone : kMachPtr, - p1 == kMachNone ? kMachNone : kMachPtr, - p2 == kMachNone ? kMachNone : kMachPtr, - p3 == kMachNone ? kMachNone : kMachPtr), + MachineType::Pointer(), + p0 == MachineType::None() ? MachineType::None() + : MachineType::Pointer(), + p1 == MachineType::None() ? MachineType::None() + : MachineType::Pointer(), + p2 == MachineType::None() ? MachineType::None() + : MachineType::Pointer(), + p3 == MachineType::None() ? MachineType::None() + : MachineType::Pointer()), test_graph_signature_( - CSignature::New(main_zone(), kMachInt32, p0, p1, p2, p3)), + CSignature::New(main_zone(), MachineType::Int32(), p0, p1, p2, p3)), return_parameter_index_(return_parameter_index) { - parameter_nodes_[0] = - p0 == kMachNone ? nullptr : Load(p0, RawMachineAssembler::Parameter(0)); - parameter_nodes_[1] = - p1 == kMachNone ? nullptr : Load(p1, RawMachineAssembler::Parameter(1)); - parameter_nodes_[2] = - p2 == kMachNone ? nullptr : Load(p2, RawMachineAssembler::Parameter(2)); - parameter_nodes_[3] = - p3 == kMachNone ? nullptr : Load(p3, RawMachineAssembler::Parameter(3)); + parameter_nodes_[0] = p0 == MachineType::None() + ? nullptr + : Load(p0, RawMachineAssembler::Parameter(0)); + parameter_nodes_[1] = p1 == MachineType::None() + ? nullptr + : Load(p1, RawMachineAssembler::Parameter(1)); + parameter_nodes_[2] = p2 == MachineType::None() + ? nullptr + : Load(p2, RawMachineAssembler::Parameter(2)); + parameter_nodes_[3] = p3 == MachineType::None() + ? nullptr + : Load(p3, RawMachineAssembler::Parameter(3)); } static uint32_t ComputeParameterCount(MachineType p0, MachineType p1, MachineType p2, MachineType p3) { - if (p0 == kMachNone) { + if (p0 == MachineType::None()) { return 0; } - if (p1 == kMachNone) { + if (p1 == MachineType::None()) { return 1; } - if (p2 == kMachNone) { + if (p2 == MachineType::None()) { return 2; } - if (p3 == kMachNone) { + if (p3 == MachineType::None()) { return 3; } return 4; @@ -205,25 +215,34 @@ template <> class BufferedRawMachineAssemblerTester : public RawMachineAssemblerTester { public: - BufferedRawMachineAssemblerTester(MachineType p0 = kMachNone, - MachineType p1 = kMachNone, - MachineType p2 = kMachNone, - MachineType p3 = kMachNone) - : RawMachineAssemblerTester(p0 == kMachNone ? kMachNone : kMachPtr, - p1 == kMachNone ? kMachNone : kMachPtr, - p2 == kMachNone ? kMachNone : kMachPtr, - p3 == kMachNone ? kMachNone : kMachPtr), + BufferedRawMachineAssemblerTester(MachineType p0 = MachineType::None(), + MachineType p1 = MachineType::None(), + MachineType p2 = MachineType::None(), + MachineType p3 = MachineType::None()) + : RawMachineAssemblerTester( + p0 == MachineType::None() ? MachineType::None() + : MachineType::Pointer(), + p1 == MachineType::None() ? MachineType::None() + : MachineType::Pointer(), + p2 == MachineType::None() ? MachineType::None() + : MachineType::Pointer(), + p3 == MachineType::None() ? MachineType::None() + : MachineType::Pointer()), test_graph_signature_( CSignature::New(RawMachineAssemblerTester::main_zone(), - kMachNone, p0, p1, p2, p3)) { - parameter_nodes_[0] = - p0 == kMachNone ? nullptr : Load(p0, RawMachineAssembler::Parameter(0)); - parameter_nodes_[1] = - p1 == kMachNone ? nullptr : Load(p1, RawMachineAssembler::Parameter(1)); - parameter_nodes_[2] = - p2 == kMachNone ? nullptr : Load(p2, RawMachineAssembler::Parameter(2)); - parameter_nodes_[3] = - p3 == kMachNone ? nullptr : Load(p3, RawMachineAssembler::Parameter(3)); + MachineType::None(), p0, p1, p2, p3)) { + parameter_nodes_[0] = p0 == MachineType::None() + ? nullptr + : Load(p0, RawMachineAssembler::Parameter(0)); + parameter_nodes_[1] = p1 == MachineType::None() + ? nullptr + : Load(p1, RawMachineAssembler::Parameter(1)); + parameter_nodes_[2] = p2 == MachineType::None() + ? nullptr + : Load(p2, RawMachineAssembler::Parameter(2)); + parameter_nodes_[3] = p3 == MachineType::None() + ? nullptr + : Load(p3, RawMachineAssembler::Parameter(3)); } @@ -283,13 +302,15 @@ static const int32_t CHECK_VALUE = 0x99BEEDCE; // TODO(titzer): use the C-style calling convention, or any register-based // calling convention for binop tests. -template +template class BinopTester { public: - explicit BinopTester(RawMachineAssemblerTester* tester) + explicit BinopTester(RawMachineAssemblerTester* tester, + MachineType rep) : T(tester), param0(T->LoadFromPointer(&p0, rep)), param1(T->LoadFromPointer(&p1, rep)), + rep(rep), p0(static_cast(0)), p1(static_cast(0)), result(static_cast(0)) {} @@ -331,6 +352,7 @@ class BinopTester { } protected: + MachineType rep; CType p0; CType p1; CType result; @@ -339,21 +361,21 @@ class BinopTester { // A helper class for testing code sequences that take two int parameters and // return an int value. -class Int32BinopTester - : public BinopTester { +class Int32BinopTester : public BinopTester { public: explicit Int32BinopTester(RawMachineAssemblerTester* tester) - : BinopTester(tester) {} + : BinopTester(tester, + MachineType::Int32()) {} }; // A helper class for testing code sequences that take two uint parameters and // return an uint value. -class Uint32BinopTester - : public BinopTester { +class Uint32BinopTester : public BinopTester { public: explicit Uint32BinopTester(RawMachineAssemblerTester* tester) - : BinopTester(tester) {} + : BinopTester(tester, + MachineType::Uint32()) {} uint32_t call(uint32_t a0, uint32_t a1) { p0 = a0; @@ -366,22 +388,21 @@ class Uint32BinopTester // A helper class for testing code sequences that take two float parameters and // return a float value. // TODO(titzer): figure out how to return floats correctly on ia32. -class Float32BinopTester - : public BinopTester { +class Float32BinopTester : public BinopTester { public: explicit Float32BinopTester(RawMachineAssemblerTester* tester) - : BinopTester(tester) {} + : BinopTester(tester, MachineType::Float32()) {} }; // A helper class for testing code sequences that take two double parameters and // return a double value. // TODO(titzer): figure out how to return doubles correctly on ia32. -class Float64BinopTester - : public BinopTester { +class Float64BinopTester : public BinopTester { public: explicit Float64BinopTester(RawMachineAssemblerTester* tester) - : BinopTester(tester) {} + : BinopTester(tester, MachineType::Float64()) { + } }; @@ -389,22 +410,22 @@ class Float64BinopTester // and return a pointer value. // TODO(titzer): pick word size of pointers based on V8_TARGET. template -class PointerBinopTester - : public BinopTester { +class PointerBinopTester : public BinopTester { public: explicit PointerBinopTester(RawMachineAssemblerTester* tester) - : BinopTester(tester) {} + : BinopTester(tester, + MachineType::Pointer()) {} }; // A helper class for testing code sequences that take two tagged parameters and // return a tagged value. template -class TaggedBinopTester - : public BinopTester { +class TaggedBinopTester : public BinopTester { public: explicit TaggedBinopTester(RawMachineAssemblerTester* tester) - : BinopTester(tester) {} + : BinopTester(tester, + MachineType::AnyTagged()) {} }; // A helper class for testing compares. Wraps a machine opcode and provides diff --git a/test/cctest/compiler/graph-builder-tester.h b/test/cctest/compiler/graph-builder-tester.h index c1684d1ba0..de2713a5ac 100644 --- a/test/cctest/compiler/graph-builder-tester.h +++ b/test/cctest/compiler/graph-builder-tester.h @@ -24,7 +24,7 @@ class GraphAndBuilders { explicit GraphAndBuilders(Zone* zone) : main_graph_(new (zone) Graph(zone)), main_common_(zone), - main_machine_(zone, kMachPtr, + main_machine_(zone, MachineType::PointerRepresentation(), InstructionSelector::SupportedMachineOperatorFlags()), main_simplified_(zone) {} @@ -48,11 +48,11 @@ class GraphBuilderTester : public HandleAndZoneScope, public GraphAndBuilders, public CallHelper { public: - explicit GraphBuilderTester(MachineType p0 = kMachNone, - MachineType p1 = kMachNone, - MachineType p2 = kMachNone, - MachineType p3 = kMachNone, - MachineType p4 = kMachNone) + explicit GraphBuilderTester(MachineType p0 = MachineType::None(), + MachineType p1 = MachineType::None(), + MachineType p2 = MachineType::None(), + MachineType p3 = MachineType::None(), + MachineType p4 = MachineType::None()) : GraphAndBuilders(main_zone()), CallHelper( main_isolate(), diff --git a/test/cctest/compiler/test-basic-block-profiler.cc b/test/cctest/compiler/test-basic-block-profiler.cc index 5961ad6ad5..17400abe53 100644 --- a/test/cctest/compiler/test-basic-block-profiler.cc +++ b/test/cctest/compiler/test-basic-block-profiler.cc @@ -12,7 +12,8 @@ namespace compiler { class BasicBlockProfilerTest : public RawMachineAssemblerTester { public: - BasicBlockProfilerTest() : RawMachineAssemblerTester(kMachInt32) { + BasicBlockProfilerTest() + : RawMachineAssemblerTester(MachineType::Int32()) { FLAG_turbo_profiling = true; } @@ -81,7 +82,7 @@ TEST(ProfileLoop) { m.Goto(&header); m.Bind(&header); - Node* count = m.Phi(kMachInt32, m.Parameter(0), one); + Node* count = m.Phi(MachineRepresentation::kWord32, m.Parameter(0), one); m.Branch(count, &body, &end); m.Bind(&body); diff --git a/test/cctest/compiler/test-branch-combine.cc b/test/cctest/compiler/test-branch-combine.cc index 522b80f384..c3b4308a93 100644 --- a/test/cctest/compiler/test-branch-combine.cc +++ b/test/cctest/compiler/test-branch-combine.cc @@ -18,7 +18,7 @@ static IrOpcode::Value int32cmp_opcodes[] = { TEST(BranchCombineWord32EqualZero_1) { // Test combining a branch with x == 0 - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); int32_t eq_constant = -1033; int32_t ne_constant = 825118; Node* p0 = m.Parameter(0); @@ -44,7 +44,7 @@ TEST(BranchCombineWord32EqualZero_chain) { int32_t ne_constant = 815118; for (int k = 0; k < 6; k++) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); Node* p0 = m.Parameter(0); RawMachineLabel blocka, blockb; Node* cond = p0; @@ -69,7 +69,7 @@ TEST(BranchCombineWord32EqualZero_chain) { TEST(BranchCombineInt32LessThanZero_1) { // Test combining a branch with x < 0 - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); int32_t eq_constant = -1433; int32_t ne_constant = 845118; Node* p0 = m.Parameter(0); @@ -91,7 +91,7 @@ TEST(BranchCombineInt32LessThanZero_1) { TEST(BranchCombineUint32LessThan100_1) { // Test combining a branch with x < 100 - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); int32_t eq_constant = 1471; int32_t ne_constant = 88845718; Node* p0 = m.Parameter(0); @@ -113,7 +113,7 @@ TEST(BranchCombineUint32LessThan100_1) { TEST(BranchCombineUint32LessThanOrEqual100_1) { // Test combining a branch with x <= 100 - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); int32_t eq_constant = 1479; int32_t ne_constant = 77845719; Node* p0 = m.Parameter(0); @@ -135,7 +135,7 @@ TEST(BranchCombineUint32LessThanOrEqual100_1) { TEST(BranchCombineZeroLessThanInt32_1) { // Test combining a branch with 0 < x - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); int32_t eq_constant = -2033; int32_t ne_constant = 225118; Node* p0 = m.Parameter(0); @@ -157,7 +157,7 @@ TEST(BranchCombineZeroLessThanInt32_1) { TEST(BranchCombineInt32GreaterThanZero_1) { // Test combining a branch with x > 0 - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); int32_t eq_constant = -1073; int32_t ne_constant = 825178; Node* p0 = m.Parameter(0); @@ -179,7 +179,8 @@ TEST(BranchCombineInt32GreaterThanZero_1) { TEST(BranchCombineWord32EqualP) { // Test combining a branch with an Word32Equal. - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); int32_t eq_constant = -1035; int32_t ne_constant = 825018; Node* p0 = m.Parameter(0); @@ -209,7 +210,7 @@ TEST(BranchCombineWord32EqualI) { for (int left = 0; left < 2; left++) { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); int32_t a = *i; Node* p0 = m.Int32Constant(a); @@ -238,7 +239,8 @@ TEST(BranchCombineInt32CmpP) { int32_t ne_constant = 725018; for (int op = 0; op < 2; op++) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); @@ -270,7 +272,7 @@ TEST(BranchCombineInt32CmpI) { for (int op = 0; op < 2; op++) { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); int32_t a = *i; Node* p0 = m.Int32Constant(a); Node* p1 = m.Parameter(0); @@ -427,8 +429,8 @@ TEST(BranchCombineFloat64Compares) { CompareWrapper cmp = cmps[c]; for (int invert = 0; invert < 2; invert++) { RawMachineAssemblerTester m; - Node* a = m.LoadFromPointer(&input_a, kMachFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachFloat64); + Node* a = m.LoadFromPointer(&input_a, MachineType::Float64()); + Node* b = m.LoadFromPointer(&input_b, MachineType::Float64()); RawMachineLabel blocka, blockb; Node* cond = cmp.MakeNode(&m, a, b); diff --git a/test/cctest/compiler/test-changes-lowering.cc b/test/cctest/compiler/test-changes-lowering.cc index ceab902ce1..965382cfd6 100644 --- a/test/cctest/compiler/test-changes-lowering.cc +++ b/test/cctest/compiler/test-changes-lowering.cc @@ -31,7 +31,7 @@ namespace compiler { template class ChangesLoweringTester : public GraphBuilderTester { public: - explicit ChangesLoweringTester(MachineType p0 = kMachNone) + explicit ChangesLoweringTester(MachineType p0 = MachineType::None()) : GraphBuilderTester(p0), javascript(this->zone()), jsgraph(this->isolate(), this->graph(), this->common(), &javascript, @@ -60,22 +60,22 @@ class ChangesLoweringTester : public GraphBuilderTester { void StoreFloat64(Node* node, double* ptr) { Node* ptr_node = this->PointerConstant(ptr); - this->Store(kMachFloat64, ptr_node, node); + this->Store(MachineType::Float64(), ptr_node, node); } Node* LoadInt32(int32_t* ptr) { Node* ptr_node = this->PointerConstant(ptr); - return this->Load(kMachInt32, ptr_node); + return this->Load(MachineType::Int32(), ptr_node); } Node* LoadUint32(uint32_t* ptr) { Node* ptr_node = this->PointerConstant(ptr); - return this->Load(kMachUint32, ptr_node); + return this->Load(MachineType::Uint32(), ptr_node); } Node* LoadFloat64(double* ptr) { Node* ptr_node = this->PointerConstant(ptr); - return this->Load(kMachFloat64, ptr_node); + return this->Load(MachineType::Float64(), ptr_node); } void CheckNumber(double expected, Object* number) { @@ -145,7 +145,7 @@ class ChangesLoweringTester : public GraphBuilderTester { TEST(RunChangeTaggedToInt32) { // Build and lower a graph by hand. - ChangesLoweringTester t(kMachAnyTagged); + ChangesLoweringTester t(MachineType::AnyTagged()); t.BuildAndLower(t.simplified()->ChangeTaggedToInt32()); FOR_INT32_INPUTS(i) { @@ -173,7 +173,7 @@ TEST(RunChangeTaggedToInt32) { TEST(RunChangeTaggedToUint32) { // Build and lower a graph by hand. - ChangesLoweringTester t(kMachAnyTagged); + ChangesLoweringTester t(MachineType::AnyTagged()); t.BuildAndLower(t.simplified()->ChangeTaggedToUint32()); FOR_UINT32_INPUTS(i) { @@ -200,13 +200,13 @@ TEST(RunChangeTaggedToUint32) { TEST(RunChangeTaggedToFloat64) { - ChangesLoweringTester t(kMachAnyTagged); + ChangesLoweringTester t(MachineType::AnyTagged()); double result; - t.BuildStoreAndLower( - t.simplified()->ChangeTaggedToFloat64(), - t.machine()->Store(StoreRepresentation(kMachFloat64, kNoWriteBarrier)), - &result); + t.BuildStoreAndLower(t.simplified()->ChangeTaggedToFloat64(), + t.machine()->Store(StoreRepresentation( + MachineType::Float64(), kNoWriteBarrier)), + &result); { FOR_INT32_INPUTS(i) { @@ -251,7 +251,7 @@ TEST(RunChangeTaggedToFloat64) { TEST(RunChangeBoolToBit) { - ChangesLoweringTester t(kMachAnyTagged); + ChangesLoweringTester t(MachineType::AnyTagged()); t.BuildAndLower(t.simplified()->ChangeBoolToBit()); { @@ -269,7 +269,7 @@ TEST(RunChangeBoolToBit) { TEST(RunChangeBitToBool) { - ChangesLoweringTester t(kMachInt32); + ChangesLoweringTester t(MachineType::Int32()); t.BuildAndLower(t.simplified()->ChangeBitToBool()); { diff --git a/test/cctest/compiler/test-gap-resolver.cc b/test/cctest/compiler/test-gap-resolver.cc index e6a5dc2a2c..7f85088809 100644 --- a/test/cctest/compiler/test-gap-resolver.cc +++ b/test/cctest/compiler/test-gap-resolver.cc @@ -86,7 +86,7 @@ class InterpreterState { } else { index = LocationOperand::cast(op).index(); } - is_float = IsFloatingPoint(LocationOperand::cast(op).machine_type()); + is_float = IsFloatingPoint(LocationOperand::cast(op).representation()); kind = LocationOperand::cast(op).location_kind(); } else { index = ConstantOperand::cast(op).virtual_register(); @@ -178,24 +178,24 @@ class ParallelMoveCreator : public HandleAndZoneScope { } private: - MachineType RandomType() { + MachineRepresentation RandomRepresentation() { int index = rng_->NextInt(3); switch (index) { case 0: - return kRepWord32; + return MachineRepresentation::kWord32; case 1: - return kRepWord64; + return MachineRepresentation::kWord64; case 2: - return kRepTagged; + return MachineRepresentation::kTagged; } UNREACHABLE(); - return kMachNone; + return MachineRepresentation::kNone; } - MachineType RandomDoubleType() { + MachineRepresentation RandomDoubleRepresentation() { int index = rng_->NextInt(2); - if (index == 0) return kRepFloat64; - return kRepFloat32; + if (index == 0) return MachineRepresentation::kFloat64; + return MachineRepresentation::kFloat32; } InstructionOperand CreateRandomOperand(bool is_source) { @@ -203,24 +203,25 @@ class ParallelMoveCreator : public HandleAndZoneScope { // destination can't be Constant. switch (rng_->NextInt(is_source ? 7 : 6)) { case 0: - return AllocatedOperand(LocationOperand::STACK_SLOT, RandomType(), - index); + return AllocatedOperand(LocationOperand::STACK_SLOT, + RandomRepresentation(), index); case 1: - return AllocatedOperand(LocationOperand::STACK_SLOT, RandomDoubleType(), - index); + return AllocatedOperand(LocationOperand::STACK_SLOT, + RandomDoubleRepresentation(), index); case 2: - return AllocatedOperand(LocationOperand::REGISTER, RandomType(), index); + return AllocatedOperand(LocationOperand::REGISTER, + RandomRepresentation(), index); case 3: - return AllocatedOperand(LocationOperand::REGISTER, RandomDoubleType(), - index); + return AllocatedOperand(LocationOperand::REGISTER, + RandomDoubleRepresentation(), index); case 4: return ExplicitOperand( - LocationOperand::REGISTER, RandomType(), + LocationOperand::REGISTER, RandomRepresentation(), RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) ->GetAllocatableGeneralCode(1)); case 5: return ExplicitOperand( - LocationOperand::STACK_SLOT, RandomType(), + LocationOperand::STACK_SLOT, RandomRepresentation(), RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) ->GetAllocatableGeneralCode(index)); case 6: diff --git a/test/cctest/compiler/test-graph-visualizer.cc b/test/cctest/compiler/test-graph-visualizer.cc index 986b673c26..9cc491922b 100644 --- a/test/cctest/compiler/test-graph-visualizer.cc +++ b/test/cctest/compiler/test-graph-visualizer.cc @@ -33,7 +33,8 @@ TEST(NodeWithNullInputReachableFromEnd) { Node* start = graph.NewNode(common.Start(0)); graph.SetStart(start); Node* k = graph.NewNode(common.Int32Constant(0)); - Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); + Node* phi = + graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start); phi->ReplaceInput(0, NULL); graph.SetEnd(phi); @@ -52,7 +53,8 @@ TEST(NodeWithNullControlReachableFromEnd) { Node* start = graph.NewNode(common.Start(0)); graph.SetStart(start); Node* k = graph.NewNode(common.Int32Constant(0)); - Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); + Node* phi = + graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start); phi->ReplaceInput(1, NULL); graph.SetEnd(phi); @@ -71,7 +73,8 @@ TEST(NodeWithNullInputReachableFromStart) { Node* start = graph.NewNode(common.Start(0)); graph.SetStart(start); Node* k = graph.NewNode(common.Int32Constant(0)); - Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); + Node* phi = + graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start); phi->ReplaceInput(0, NULL); graph.SetEnd(start); diff --git a/test/cctest/compiler/test-jump-threading.cc b/test/cctest/compiler/test-jump-threading.cc index 43ca4aefed..8c02012e0a 100644 --- a/test/cctest/compiler/test-jump-threading.cc +++ b/test/cctest/compiler/test-jump-threading.cc @@ -57,16 +57,18 @@ class TestCode : public HandleAndZoneScope { Start(); sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); int index = static_cast(sequence_.instructions().size()) - 1; - AddGapMove(index, - AllocatedOperand(LocationOperand::REGISTER, kRepWord32, 13), - AllocatedOperand(LocationOperand::REGISTER, kRepWord32, 13)); + AddGapMove(index, AllocatedOperand(LocationOperand::REGISTER, + MachineRepresentation::kWord32, 13), + AllocatedOperand(LocationOperand::REGISTER, + MachineRepresentation::kWord32, 13)); } void NonRedundantMoves() { Start(); sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); int index = static_cast(sequence_.instructions().size()) - 1; AddGapMove(index, ConstantOperand(11), - AllocatedOperand(LocationOperand::REGISTER, kRepWord32, 11)); + AllocatedOperand(LocationOperand::REGISTER, + MachineRepresentation::kWord32, 11)); } void Other() { Start(); diff --git a/test/cctest/compiler/test-loop-analysis.cc b/test/cctest/compiler/test-loop-analysis.cc index 40c413042b..68bfc2858f 100644 --- a/test/cctest/compiler/test-loop-analysis.cc +++ b/test/cctest/compiler/test-loop-analysis.cc @@ -111,7 +111,8 @@ class LoopFinderTester : HandleAndZoneScope { } const Operator* op(int count, bool effect) { - return effect ? common.EffectPhi(count) : common.Phi(kMachAnyTagged, count); + return effect ? common.EffectPhi(count) + : common.Phi(MachineRepresentation::kTagged, count); } Node* Return(Node* val, Node* effect, Node* control) { @@ -266,8 +267,8 @@ TEST(LaLoop1phi) { // One loop with a simple phi. LoopFinderTester t; While w(t, t.p0); - Node* phi = - t.graph.NewNode(t.common.Phi(kMachAnyTagged, 2), t.zero, t.one, w.loop); + Node* phi = t.graph.NewNode(t.common.Phi(MachineRepresentation::kTagged, 2), + t.zero, t.one, w.loop); t.Return(phi, t.start, w.exit); Node* chain[] = {w.loop}; @@ -475,7 +476,7 @@ TEST(LaNestedLoop1x) { While w2(t, t.p0); w2.nest(w1); - const Operator* op = t.common.Phi(kMachInt32, 2); + const Operator* op = t.common.Phi(MachineRepresentation::kWord32, 2); Node* p1a = t.graph.NewNode(op, t.p0, t.p0, w1.loop); Node* p1b = t.graph.NewNode(op, t.p0, t.p0, w1.loop); Node* p2a = t.graph.NewNode(op, p1a, t.p0, w2.loop); @@ -688,8 +689,8 @@ TEST(LaEdgeMatrix1) { Node* p3 = t.jsgraph.Int32Constant(33); Node* loop = t.graph.NewNode(t.common.Loop(2), t.start, t.start); - Node* phi = - t.graph.NewNode(t.common.Phi(kMachInt32, 2), t.one, p1, loop); + Node* phi = t.graph.NewNode( + t.common.Phi(MachineRepresentation::kWord32, 2), t.one, p1, loop); Node* cond = t.graph.NewNode(&kIntAdd, phi, p2); Node* branch = t.graph.NewNode(t.common.Branch(), cond, loop); Node* if_true = t.graph.NewNode(t.common.IfTrue(), branch); @@ -724,8 +725,8 @@ void RunEdgeMatrix2(int i) { // outer loop. Node* loop1 = t.graph.NewNode(t.common.Loop(2), t.start, t.start); - Node* phi1 = - t.graph.NewNode(t.common.Phi(kMachInt32, 2), t.one, p1, loop1); + Node* phi1 = t.graph.NewNode( + t.common.Phi(MachineRepresentation::kWord32, 2), t.one, p1, loop1); Node* cond1 = t.graph.NewNode(&kIntAdd, phi1, t.one); Node* branch1 = t.graph.NewNode(t.common.Branch(), cond1, loop1); Node* if_true1 = t.graph.NewNode(t.common.IfTrue(), branch1); @@ -733,8 +734,8 @@ void RunEdgeMatrix2(int i) { // inner loop. Node* loop2 = t.graph.NewNode(t.common.Loop(2), if_true1, t.start); - Node* phi2 = - t.graph.NewNode(t.common.Phi(kMachInt32, 2), t.one, p2, loop2); + Node* phi2 = t.graph.NewNode( + t.common.Phi(MachineRepresentation::kWord32, 2), t.one, p2, loop2); Node* cond2 = t.graph.NewNode(&kIntAdd, phi2, p3); Node* branch2 = t.graph.NewNode(t.common.Branch(), cond2, loop2); Node* if_true2 = t.graph.NewNode(t.common.IfTrue(), branch2); @@ -800,7 +801,8 @@ void RunEdgeMatrix3(int c1a, int c1b, int c1c, // line break // L1 depth = 0 Node* loop1 = t.graph.NewNode(t.common.Loop(2), t.start, t.start); - Node* phi1 = t.graph.NewNode(t.common.Phi(kMachInt32, 2), p1a, p1c, loop1); + Node* phi1 = t.graph.NewNode(t.common.Phi(MachineRepresentation::kWord32, 2), + p1a, p1c, loop1); Node* cond1 = t.graph.NewNode(&kIntAdd, phi1, p1b); Node* branch1 = t.graph.NewNode(t.common.Branch(), cond1, loop1); Node* if_true1 = t.graph.NewNode(t.common.IfTrue(), branch1); @@ -808,7 +810,8 @@ void RunEdgeMatrix3(int c1a, int c1b, int c1c, // line break // L2 depth = 1 Node* loop2 = t.graph.NewNode(t.common.Loop(2), if_true1, t.start); - Node* phi2 = t.graph.NewNode(t.common.Phi(kMachInt32, 2), p2a, p2c, loop2); + Node* phi2 = t.graph.NewNode(t.common.Phi(MachineRepresentation::kWord32, 2), + p2a, p2c, loop2); Node* cond2 = t.graph.NewNode(&kIntAdd, phi2, p2b); Node* branch2 = t.graph.NewNode(t.common.Branch(), cond2, loop2); Node* if_true2 = t.graph.NewNode(t.common.IfTrue(), branch2); @@ -816,7 +819,8 @@ void RunEdgeMatrix3(int c1a, int c1b, int c1c, // line break // L3 depth = 2 Node* loop3 = t.graph.NewNode(t.common.Loop(2), if_true2, t.start); - Node* phi3 = t.graph.NewNode(t.common.Phi(kMachInt32, 2), p3a, p3c, loop3); + Node* phi3 = t.graph.NewNode(t.common.Phi(MachineRepresentation::kWord32, 2), + p3a, p3c, loop3); Node* cond3 = t.graph.NewNode(&kIntAdd, phi3, p3b); Node* branch3 = t.graph.NewNode(t.common.Branch(), cond3, loop3); Node* if_true3 = t.graph.NewNode(t.common.IfTrue(), branch3); @@ -924,7 +928,8 @@ static void RunManyChainedLoops_i(int count) { // Build loops. for (int i = 0; i < count; i++) { Node* loop = t.graph.NewNode(t.common.Loop(2), last, t.start); - Node* phi = t.graph.NewNode(t.common.Phi(kMachInt32, 2), k11, k12, loop); + Node* phi = t.graph.NewNode(t.common.Phi(MachineRepresentation::kWord32, 2), + k11, k12, loop); Node* branch = t.graph.NewNode(t.common.Branch(), phi, loop); Node* if_true = t.graph.NewNode(t.common.IfTrue(), branch); Node* exit = t.graph.NewNode(t.common.IfFalse(), branch); @@ -959,7 +964,8 @@ static void RunManyNestedLoops_i(int count) { // Build loops. for (int i = 0; i < count; i++) { Node* loop = t.graph.NewNode(t.common.Loop(2), entry, t.start); - Node* phi = t.graph.NewNode(t.common.Phi(kMachInt32, 2), k11, k12, loop); + Node* phi = t.graph.NewNode(t.common.Phi(MachineRepresentation::kWord32, 2), + k11, k12, loop); Node* branch = t.graph.NewNode(t.common.Branch(), phi, loop); Node* if_true = t.graph.NewNode(t.common.IfTrue(), branch); Node* exit = t.graph.NewNode(t.common.IfFalse(), branch); diff --git a/test/cctest/compiler/test-machine-operator-reducer.cc b/test/cctest/compiler/test-machine-operator-reducer.cc index a8e1896772..ba2276821c 100644 --- a/test/cctest/compiler/test-machine-operator-reducer.cc +++ b/test/cctest/compiler/test-machine-operator-reducer.cc @@ -56,7 +56,7 @@ class ReducerTester : public HandleAndZoneScope { : isolate(main_isolate()), binop(NULL), unop(NULL), - machine(main_zone(), kMachPtr, flags), + machine(main_zone(), MachineType::PointerRepresentation(), flags), common(main_zone()), graph(main_zone()), javascript(main_zone()), @@ -703,8 +703,8 @@ TEST(ReduceLoadStore) { Node* base = R.Constant(11); Node* index = R.Constant(4); - Node* load = R.graph.NewNode(R.machine.Load(kMachInt32), base, index, - R.graph.start(), R.graph.start()); + Node* load = R.graph.NewNode(R.machine.Load(MachineType::Int32()), base, + index, R.graph.start(), R.graph.start()); { MachineOperatorReducer reducer(&R.jsgraph); @@ -713,9 +713,9 @@ TEST(ReduceLoadStore) { } { - Node* store = R.graph.NewNode( - R.machine.Store(StoreRepresentation(kMachInt32, kNoWriteBarrier)), base, - index, load, load, R.graph.start()); + Node* store = R.graph.NewNode(R.machine.Store(StoreRepresentation( + MachineType::Int32(), kNoWriteBarrier)), + base, index, load, load, R.graph.start()); MachineOperatorReducer reducer(&R.jsgraph); Reduction reduction = reducer.Reduce(store); CHECK(!reduction.Changed()); // stores should not be reduced. diff --git a/test/cctest/compiler/test-multiple-return.cc b/test/cctest/compiler/test-multiple-return.cc index 9e0a6787be..7c08238411 100644 --- a/test/cctest/compiler/test-multiple-return.cc +++ b/test/cctest/compiler/test-multiple-return.cc @@ -33,7 +33,7 @@ CallDescriptor* GetCallDescriptor(Zone* zone, int return_count, // Add return location(s). CHECK(return_count <= config->num_allocatable_general_registers()); for (int i = 0; i < return_count; i++) { - msig.AddReturn(kMachInt32); + msig.AddReturn(MachineType::Int32()); locations.AddReturn( LinkageLocation::ForRegister(config->allocatable_general_codes()[i])); } @@ -41,7 +41,7 @@ CallDescriptor* GetCallDescriptor(Zone* zone, int return_count, // Add register and/or stack parameter(s). CHECK(param_count <= config->num_allocatable_general_registers()); for (int i = 0; i < param_count; i++) { - msig.AddParam(kMachInt32); + msig.AddParam(MachineType::Int32()); locations.AddParam( LinkageLocation::ForRegister(config->allocatable_general_codes()[i])); } @@ -50,7 +50,7 @@ CallDescriptor* GetCallDescriptor(Zone* zone, int return_count, const RegList kCalleeSaveFPRegisters = 0; // The target for WASM calls is always a code object. - MachineType target_type = kMachAnyTagged; + MachineType target_type = MachineType::AnyTagged(); LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); return new (zone) CallDescriptor( // -- CallDescriptor::kCallCodeObject, // kind @@ -74,7 +74,7 @@ TEST(ReturnThreeValues) { HandleAndZoneScope handles; RawMachineAssembler m(handles.main_isolate(), new (handles.main_zone()) Graph(handles.main_zone()), - desc, kMachPtr, + desc, MachineType::PointerRepresentation(), InstructionSelector::SupportedMachineOperatorFlags()); Node* p0 = m.Parameter(0); diff --git a/test/cctest/compiler/test-osr.cc b/test/cctest/compiler/test-osr.cc index 6e1b6fc899..f0640c2e0a 100644 --- a/test/cctest/compiler/test-osr.cc +++ b/test/cctest/compiler/test-osr.cc @@ -91,7 +91,8 @@ class OsrDeconstructorTester : public HandleAndZoneScope { if (count > 3) inputs[3] = back2; if (count > 4) inputs[4] = back3; inputs[count] = loop; - return graph.NewNode(common.Phi(kMachAnyTagged, count), count + 1, inputs); + return graph.NewNode(common.Phi(MachineRepresentation::kTagged, count), + count + 1, inputs); } Node* NewLoop(bool is_osr, int num_backedges, Node* entry = nullptr) { @@ -314,9 +315,11 @@ struct While { Node* Phi(Node* i1, Node* i2, Node* i3) { if (loop->InputCount() == 2) { - return t.graph.NewNode(t.common.Phi(kMachAnyTagged, 2), i1, i2, loop); + return t.graph.NewNode(t.common.Phi(MachineRepresentation::kTagged, 2), + i1, i2, loop); } else { - return t.graph.NewNode(t.common.Phi(kMachAnyTagged, 3), i1, i2, i3, loop); + return t.graph.NewNode(t.common.Phi(MachineRepresentation::kTagged, 3), + i1, i2, i3, loop); } } }; @@ -473,7 +476,8 @@ Node* MakeCounter(JSGraph* jsgraph, Node* start, Node* loop) { tmp_inputs.push_back(loop); Node* phi = jsgraph->graph()->NewNode( - jsgraph->common()->Phi(kMachInt32, count), count + 1, &tmp_inputs[0]); + jsgraph->common()->Phi(MachineRepresentation::kWord32, count), count + 1, + &tmp_inputs[0]); Node* inc = jsgraph->graph()->NewNode(&kIntAdd, phi, jsgraph->OneConstant()); for (int i = 1; i < count; i++) { @@ -493,8 +497,9 @@ TEST(Deconstruct_osr_nested3) { // middle loop. Node* loop1 = T.graph.NewNode(T.common.Loop(1), loop0.if_true); - Node* loop1_phi = T.graph.NewNode(T.common.Phi(kMachAnyTagged, 2), loop0_cntr, - loop0_cntr, loop1); + Node* loop1_phi = + T.graph.NewNode(T.common.Phi(MachineRepresentation::kTagged, 2), + loop0_cntr, loop0_cntr, loop1); // innermost (OSR) loop. While loop2(T, T.p0, true, 1); diff --git a/test/cctest/compiler/test-representation-change.cc b/test/cctest/compiler/test-representation-change.cc index db75d4c154..fc319df79b 100644 --- a/test/cctest/compiler/test-representation-change.cc +++ b/test/cctest/compiler/test-representation-change.cc @@ -83,7 +83,7 @@ class RepresentationChangerTester : public HandleAndZoneScope, return n; } - void CheckTypeError(MachineTypeUnion from, MachineTypeUnion to) { + void CheckTypeError(MachineType from, MachineRepresentation to) { changer()->testing_type_errors_ = true; changer()->type_error_ = false; Node* n = Parameter(0); @@ -92,7 +92,7 @@ class RepresentationChangerTester : public HandleAndZoneScope, CHECK_EQ(n, c); } - void CheckNop(MachineTypeUnion from, MachineTypeUnion to) { + void CheckNop(MachineType from, MachineRepresentation to) { Node* n = Parameter(0); Node* c = changer()->GetRepresentationFor(n, from, to); CHECK_EQ(n, c); @@ -100,21 +100,24 @@ class RepresentationChangerTester : public HandleAndZoneScope, }; -static const MachineType all_reps[] = {kRepBit, kRepWord32, kRepWord64, - kRepFloat32, kRepFloat64, kRepTagged}; +const MachineType kMachineTypes[] = { + MachineType::Float32(), MachineType::Float64(), MachineType::Int8(), + MachineType::Uint8(), MachineType::Int16(), MachineType::Uint16(), + MachineType::Int32(), MachineType::Uint32(), MachineType::Int64(), + MachineType::Uint64(), MachineType::AnyTagged()}; TEST(BoolToBit_constant) { RepresentationChangerTester r; Node* true_node = r.jsgraph()->TrueConstant(); - Node* true_bit = - r.changer()->GetRepresentationFor(true_node, kRepTagged, kRepBit); + Node* true_bit = r.changer()->GetRepresentationFor( + true_node, MachineType::RepTagged(), MachineRepresentation::kBit); r.CheckInt32Constant(true_bit, 1); Node* false_node = r.jsgraph()->FalseConstant(); - Node* false_bit = - r.changer()->GetRepresentationFor(false_node, kRepTagged, kRepBit); + Node* false_bit = r.changer()->GetRepresentationFor( + false_node, MachineType::RepTagged(), MachineRepresentation::kBit); r.CheckInt32Constant(false_bit, 0); } @@ -124,7 +127,8 @@ TEST(BitToBool_constant) { for (int i = -5; i < 5; i++) { Node* node = r.jsgraph()->Int32Constant(i); - Node* val = r.changer()->GetRepresentationFor(node, kRepBit, kRepTagged); + Node* val = r.changer()->GetRepresentationFor( + node, MachineType::RepBit(), MachineRepresentation::kTagged); r.CheckHeapConstant(val, i == 0 ? r.isolate()->heap()->false_value() : r.isolate()->heap()->true_value()); } @@ -137,7 +141,8 @@ TEST(ToTagged_constant) { { FOR_FLOAT64_INPUTS(i) { Node* n = r.jsgraph()->Float64Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepTagged); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::RepFloat64(), MachineRepresentation::kTagged); r.CheckNumberConstant(c, *i); } } @@ -145,7 +150,8 @@ TEST(ToTagged_constant) { { FOR_FLOAT64_INPUTS(i) { Node* n = r.jsgraph()->Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepTagged); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::RepFloat64(), MachineRepresentation::kTagged); r.CheckNumberConstant(c, *i); } } @@ -153,7 +159,8 @@ TEST(ToTagged_constant) { { FOR_FLOAT32_INPUTS(i) { Node* n = r.jsgraph()->Float32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32, kRepTagged); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::RepFloat32(), MachineRepresentation::kTagged); r.CheckNumberConstant(c, *i); } } @@ -161,8 +168,8 @@ TEST(ToTagged_constant) { { FOR_INT32_INPUTS(i) { Node* n = r.jsgraph()->Int32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, - kRepTagged); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::Int32(), MachineRepresentation::kTagged); r.CheckNumberConstant(c, *i); } } @@ -170,8 +177,8 @@ TEST(ToTagged_constant) { { FOR_UINT32_INPUTS(i) { Node* n = r.jsgraph()->Int32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, - kRepTagged); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::Uint32(), MachineRepresentation::kTagged); r.CheckNumberConstant(c, *i); } } @@ -184,7 +191,8 @@ TEST(ToFloat64_constant) { { FOR_FLOAT64_INPUTS(i) { Node* n = r.jsgraph()->Float64Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepFloat64); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::RepFloat64(), MachineRepresentation::kFloat64); CHECK_EQ(n, c); } } @@ -192,7 +200,8 @@ TEST(ToFloat64_constant) { { FOR_FLOAT64_INPUTS(i) { Node* n = r.jsgraph()->Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepTagged, kRepFloat64); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::RepTagged(), MachineRepresentation::kFloat64); r.CheckFloat64Constant(c, *i); } } @@ -200,7 +209,8 @@ TEST(ToFloat64_constant) { { FOR_FLOAT32_INPUTS(i) { Node* n = r.jsgraph()->Float32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32, kRepFloat64); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::RepFloat32(), MachineRepresentation::kFloat64); r.CheckFloat64Constant(c, *i); } } @@ -208,8 +218,8 @@ TEST(ToFloat64_constant) { { FOR_INT32_INPUTS(i) { Node* n = r.jsgraph()->Int32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, - kRepFloat64); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::Int32(), MachineRepresentation::kFloat64); r.CheckFloat64Constant(c, *i); } } @@ -217,8 +227,8 @@ TEST(ToFloat64_constant) { { FOR_UINT32_INPUTS(i) { Node* n = r.jsgraph()->Int32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, - kRepFloat64); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::Uint32(), MachineRepresentation::kFloat64); r.CheckFloat64Constant(c, *i); } } @@ -239,7 +249,8 @@ TEST(ToFloat32_constant) { { FOR_FLOAT32_INPUTS(i) { Node* n = r.jsgraph()->Float32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32, kRepFloat32); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::RepFloat32(), MachineRepresentation::kFloat32); CHECK_EQ(n, c); } } @@ -247,7 +258,8 @@ TEST(ToFloat32_constant) { { FOR_FLOAT32_INPUTS(i) { Node* n = r.jsgraph()->Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepTagged, kRepFloat32); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::RepTagged(), MachineRepresentation::kFloat32); r.CheckFloat32Constant(c, *i); } } @@ -255,7 +267,8 @@ TEST(ToFloat32_constant) { { FOR_FLOAT32_INPUTS(i) { Node* n = r.jsgraph()->Float64Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepFloat32); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::RepFloat64(), MachineRepresentation::kFloat32); r.CheckFloat32Constant(c, *i); } } @@ -264,8 +277,8 @@ TEST(ToFloat32_constant) { FOR_INT32_INPUTS(i) { if (!IsFloat32Int32(*i)) continue; Node* n = r.jsgraph()->Int32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, - kRepFloat32); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::Int32(), MachineRepresentation::kFloat32); r.CheckFloat32Constant(c, static_cast(*i)); } } @@ -274,8 +287,8 @@ TEST(ToFloat32_constant) { FOR_UINT32_INPUTS(i) { if (!IsFloat32Uint32(*i)) continue; Node* n = r.jsgraph()->Int32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, - kRepFloat32); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::Uint32(), MachineRepresentation::kFloat32); r.CheckFloat32Constant(c, static_cast(*i)); } } @@ -288,8 +301,8 @@ TEST(ToInt32_constant) { { FOR_INT32_INPUTS(i) { Node* n = r.jsgraph()->Int32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, - kRepWord32); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::Int32(), MachineRepresentation::kWord32); r.CheckInt32Constant(c, *i); } } @@ -298,8 +311,10 @@ TEST(ToInt32_constant) { FOR_INT32_INPUTS(i) { if (!IsFloat32Int32(*i)) continue; Node* n = r.jsgraph()->Float32Constant(static_cast(*i)); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeInt32, - kRepWord32); + Node* c = r.changer()->GetRepresentationFor( + n, + MachineType(MachineRepresentation::kFloat32, MachineSemantic::kInt32), + MachineRepresentation::kWord32); r.CheckInt32Constant(c, *i); } } @@ -307,8 +322,10 @@ TEST(ToInt32_constant) { { FOR_INT32_INPUTS(i) { Node* n = r.jsgraph()->Float64Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeInt32, - kRepWord32); + Node* c = r.changer()->GetRepresentationFor( + n, + MachineType(MachineRepresentation::kFloat64, MachineSemantic::kInt32), + MachineRepresentation::kWord32); r.CheckInt32Constant(c, *i); } } @@ -316,8 +333,10 @@ TEST(ToInt32_constant) { { FOR_INT32_INPUTS(i) { Node* n = r.jsgraph()->Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepTagged | kTypeInt32, - kRepWord32); + Node* c = r.changer()->GetRepresentationFor( + n, + MachineType(MachineRepresentation::kTagged, MachineSemantic::kInt32), + MachineRepresentation::kWord32); r.CheckInt32Constant(c, *i); } } @@ -330,8 +349,8 @@ TEST(ToUint32_constant) { { FOR_UINT32_INPUTS(i) { Node* n = r.jsgraph()->Int32Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, - kRepWord32); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType::Uint32(), MachineRepresentation::kWord32); r.CheckUint32Constant(c, *i); } } @@ -340,8 +359,10 @@ TEST(ToUint32_constant) { FOR_UINT32_INPUTS(i) { if (!IsFloat32Uint32(*i)) continue; Node* n = r.jsgraph()->Float32Constant(static_cast(*i)); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeUint32, - kRepWord32); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType(MachineRepresentation::kFloat32, + MachineSemantic::kUint32), + MachineRepresentation::kWord32); r.CheckUint32Constant(c, *i); } } @@ -349,8 +370,10 @@ TEST(ToUint32_constant) { { FOR_UINT32_INPUTS(i) { Node* n = r.jsgraph()->Float64Constant(*i); - Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeUint32, - kRepWord32); + Node* c = r.changer()->GetRepresentationFor( + n, MachineType(MachineRepresentation::kFloat64, + MachineSemantic::kUint32), + MachineRepresentation::kWord32); r.CheckUint32Constant(c, *i); } } @@ -358,16 +381,18 @@ TEST(ToUint32_constant) { { FOR_UINT32_INPUTS(i) { Node* n = r.jsgraph()->Constant(static_cast(*i)); - Node* c = r.changer()->GetRepresentationFor(n, kRepTagged | kTypeUint32, - kRepWord32); + Node* c = r.changer()->GetRepresentationFor( + n, + MachineType(MachineRepresentation::kTagged, MachineSemantic::kUint32), + MachineRepresentation::kWord32); r.CheckUint32Constant(c, *i); } } } -static void CheckChange(IrOpcode::Value expected, MachineTypeUnion from, - MachineTypeUnion to) { +static void CheckChange(IrOpcode::Value expected, MachineType from, + MachineRepresentation to) { RepresentationChangerTester r; Node* n = r.Parameter(); @@ -380,8 +405,8 @@ static void CheckChange(IrOpcode::Value expected, MachineTypeUnion from, static void CheckTwoChanges(IrOpcode::Value expected2, - IrOpcode::Value expected1, MachineTypeUnion from, - MachineTypeUnion to) { + IrOpcode::Value expected1, MachineType from, + MachineRepresentation to) { RepresentationChangerTester r; Node* n = r.Parameter(); @@ -397,71 +422,98 @@ static void CheckTwoChanges(IrOpcode::Value expected2, TEST(SingleChanges) { - CheckChange(IrOpcode::kChangeBoolToBit, kRepTagged, kRepBit); - CheckChange(IrOpcode::kChangeBitToBool, kRepBit, kRepTagged); + CheckChange(IrOpcode::kChangeBoolToBit, MachineType::RepTagged(), + MachineRepresentation::kBit); + CheckChange(IrOpcode::kChangeBitToBool, MachineType::RepBit(), + MachineRepresentation::kTagged); - CheckChange(IrOpcode::kChangeInt32ToTagged, kRepWord32 | kTypeInt32, - kRepTagged); - CheckChange(IrOpcode::kChangeUint32ToTagged, kRepWord32 | kTypeUint32, - kRepTagged); - CheckChange(IrOpcode::kChangeFloat64ToTagged, kRepFloat64, kRepTagged); + CheckChange(IrOpcode::kChangeInt32ToTagged, MachineType::Int32(), + MachineRepresentation::kTagged); + CheckChange(IrOpcode::kChangeUint32ToTagged, MachineType::Uint32(), + MachineRepresentation::kTagged); + CheckChange(IrOpcode::kChangeFloat64ToTagged, MachineType::RepFloat64(), + MachineRepresentation::kTagged); - CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged | kTypeInt32, - kRepWord32); - CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged | kTypeUint32, - kRepWord32); - CheckChange(IrOpcode::kChangeTaggedToFloat64, kRepTagged, kRepFloat64); + CheckChange( + IrOpcode::kChangeTaggedToInt32, + MachineType(MachineRepresentation::kTagged, MachineSemantic::kInt32), + MachineRepresentation::kWord32); + CheckChange( + IrOpcode::kChangeTaggedToUint32, + MachineType(MachineRepresentation::kTagged, MachineSemantic::kUint32), + MachineRepresentation::kWord32); + CheckChange(IrOpcode::kChangeTaggedToFloat64, MachineType::RepTagged(), + MachineRepresentation::kFloat64); // Int32,Uint32 <-> Float64 are actually machine conversions. - CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32 | kTypeInt32, - kRepFloat64); - CheckChange(IrOpcode::kChangeUint32ToFloat64, kRepWord32 | kTypeUint32, - kRepFloat64); - CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64 | kTypeInt32, - kRepWord32); - CheckChange(IrOpcode::kChangeFloat64ToUint32, kRepFloat64 | kTypeUint32, - kRepWord32); + CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineType::Int32(), + MachineRepresentation::kFloat64); + CheckChange(IrOpcode::kChangeUint32ToFloat64, MachineType::Uint32(), + MachineRepresentation::kFloat64); + CheckChange( + IrOpcode::kChangeFloat64ToInt32, + MachineType(MachineRepresentation::kFloat64, MachineSemantic::kInt32), + MachineRepresentation::kWord32); + CheckChange( + IrOpcode::kChangeFloat64ToUint32, + MachineType(MachineRepresentation::kFloat64, MachineSemantic::kUint32), + MachineRepresentation::kWord32); - CheckChange(IrOpcode::kTruncateFloat64ToFloat32, kRepFloat64, kRepFloat32); + CheckChange(IrOpcode::kTruncateFloat64ToFloat32, MachineType::RepFloat64(), + MachineRepresentation::kFloat32); // Int32,Uint32 <-> Float32 require two changes. CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, - IrOpcode::kTruncateFloat64ToFloat32, kRepWord32 | kTypeInt32, - kRepFloat32); + IrOpcode::kTruncateFloat64ToFloat32, MachineType::Int32(), + MachineRepresentation::kFloat32); CheckTwoChanges(IrOpcode::kChangeUint32ToFloat64, - IrOpcode::kTruncateFloat64ToFloat32, kRepWord32 | kTypeUint32, - kRepFloat32); - CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, - IrOpcode::kChangeFloat64ToInt32, kRepFloat32 | kTypeInt32, - kRepWord32); - CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, - IrOpcode::kChangeFloat64ToUint32, kRepFloat32 | kTypeUint32, - kRepWord32); + IrOpcode::kTruncateFloat64ToFloat32, MachineType::Uint32(), + MachineRepresentation::kFloat32); + CheckTwoChanges( + IrOpcode::kChangeFloat32ToFloat64, IrOpcode::kChangeFloat64ToInt32, + MachineType(MachineRepresentation::kFloat32, MachineSemantic::kInt32), + MachineRepresentation::kWord32); + CheckTwoChanges( + IrOpcode::kChangeFloat32ToFloat64, IrOpcode::kChangeFloat64ToUint32, + MachineType(MachineRepresentation::kFloat32, MachineSemantic::kUint32), + MachineRepresentation::kWord32); // Float32 <-> Tagged require two changes. CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, - IrOpcode::kChangeFloat64ToTagged, kRepFloat32, kRepTagged); + IrOpcode::kChangeFloat64ToTagged, MachineType::RepFloat32(), + MachineRepresentation::kTagged); CheckTwoChanges(IrOpcode::kChangeTaggedToFloat64, - IrOpcode::kTruncateFloat64ToFloat32, kRepTagged, kRepFloat32); + IrOpcode::kTruncateFloat64ToFloat32, MachineType::RepTagged(), + MachineRepresentation::kFloat32); } TEST(SignednessInWord32) { RepresentationChangerTester r; - CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged | kTypeInt32, - kRepWord32); - CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged | kTypeUint32, - kRepWord32); - CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32, kRepFloat64); - CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64 | kTypeInt32, - kRepWord32); - CheckChange(IrOpcode::kTruncateFloat64ToInt32, kRepFloat64, kRepWord32); + CheckChange( + IrOpcode::kChangeTaggedToInt32, + MachineType(MachineRepresentation::kTagged, MachineSemantic::kInt32), + MachineRepresentation::kWord32); + CheckChange( + IrOpcode::kChangeTaggedToUint32, + MachineType(MachineRepresentation::kTagged, MachineSemantic::kUint32), + MachineRepresentation::kWord32); + CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineType::RepWord32(), + MachineRepresentation::kFloat64); + CheckChange( + IrOpcode::kChangeFloat64ToInt32, + MachineType(MachineRepresentation::kFloat64, MachineSemantic::kInt32), + MachineRepresentation::kWord32); + CheckChange(IrOpcode::kTruncateFloat64ToInt32, MachineType::RepFloat64(), + MachineRepresentation::kWord32); CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, - IrOpcode::kTruncateFloat64ToFloat32, kRepWord32, kRepFloat32); + IrOpcode::kTruncateFloat64ToFloat32, MachineType::RepWord32(), + MachineRepresentation::kFloat32); CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, - IrOpcode::kTruncateFloat64ToInt32, kRepFloat32, kRepWord32); + IrOpcode::kTruncateFloat64ToInt32, MachineType::RepFloat32(), + MachineRepresentation::kWord32); } @@ -469,32 +521,32 @@ TEST(Nops) { RepresentationChangerTester r; // X -> X is always a nop for any single representation X. - for (size_t i = 0; i < arraysize(all_reps); i++) { - r.CheckNop(all_reps[i], all_reps[i]); + for (size_t i = 0; i < arraysize(kMachineTypes); i++) { + r.CheckNop(kMachineTypes[i], kMachineTypes[i].representation()); } // 32-bit floats. - r.CheckNop(kRepFloat32, kRepFloat32); - r.CheckNop(kRepFloat32 | kTypeNumber, kRepFloat32); + r.CheckNop(MachineType::RepFloat32(), MachineRepresentation::kFloat32); + r.CheckNop(MachineType::Float32(), MachineRepresentation::kFloat32); // 32-bit words can be used as smaller word sizes and vice versa, because // loads from memory implicitly sign or zero extend the value to the // full machine word size, and stores implicitly truncate. - r.CheckNop(kRepWord32, kRepWord8); - r.CheckNop(kRepWord32, kRepWord16); - r.CheckNop(kRepWord32, kRepWord32); - r.CheckNop(kRepWord8, kRepWord32); - r.CheckNop(kRepWord16, kRepWord32); + r.CheckNop(MachineType::Int32(), MachineRepresentation::kWord8); + r.CheckNop(MachineType::Int32(), MachineRepresentation::kWord16); + r.CheckNop(MachineType::Int32(), MachineRepresentation::kWord32); + r.CheckNop(MachineType::Int8(), MachineRepresentation::kWord32); + r.CheckNop(MachineType::Int16(), MachineRepresentation::kWord32); // kRepBit (result of comparison) is implicitly a wordish thing. - r.CheckNop(kRepBit, kRepWord8); - r.CheckNop(kRepBit | kTypeBool, kRepWord8); - r.CheckNop(kRepBit, kRepWord16); - r.CheckNop(kRepBit | kTypeBool, kRepWord16); - r.CheckNop(kRepBit, kRepWord32); - r.CheckNop(kRepBit | kTypeBool, kRepWord32); - r.CheckNop(kRepBit, kRepWord64); - r.CheckNop(kRepBit | kTypeBool, kRepWord64); + r.CheckNop(MachineType::RepBit(), MachineRepresentation::kWord8); + r.CheckNop(MachineType::RepBit(), MachineRepresentation::kWord16); + r.CheckNop(MachineType::RepBit(), MachineRepresentation::kWord32); + r.CheckNop(MachineType::RepBit(), MachineRepresentation::kWord64); + r.CheckNop(MachineType::Bool(), MachineRepresentation::kWord8); + r.CheckNop(MachineType::Bool(), MachineRepresentation::kWord16); + r.CheckNop(MachineType::Bool(), MachineRepresentation::kWord32); + r.CheckNop(MachineType::Bool(), MachineRepresentation::kWord64); } @@ -502,39 +554,31 @@ TEST(TypeErrors) { RepresentationChangerTester r; // Wordish cannot be implicitly converted to/from comparison conditions. - r.CheckTypeError(kRepWord8, kRepBit); - r.CheckTypeError(kRepWord16, kRepBit); - r.CheckTypeError(kRepWord32, kRepBit); - r.CheckTypeError(kRepWord64, kRepBit); + r.CheckTypeError(MachineType::RepWord8(), MachineRepresentation::kBit); + r.CheckTypeError(MachineType::RepWord16(), MachineRepresentation::kBit); + r.CheckTypeError(MachineType::RepWord32(), MachineRepresentation::kBit); + r.CheckTypeError(MachineType::RepWord64(), MachineRepresentation::kBit); // Floats cannot be implicitly converted to/from comparison conditions. - r.CheckTypeError(kRepFloat64, kRepBit); - r.CheckTypeError(kRepBit, kRepFloat64); - r.CheckTypeError(kRepBit | kTypeBool, kRepFloat64); + r.CheckTypeError(MachineType::RepFloat64(), MachineRepresentation::kBit); + r.CheckTypeError(MachineType::RepBit(), MachineRepresentation::kFloat64); + r.CheckTypeError(MachineType::Bool(), MachineRepresentation::kFloat64); // Floats cannot be implicitly converted to/from comparison conditions. - r.CheckTypeError(kRepFloat32, kRepBit); - r.CheckTypeError(kRepBit, kRepFloat32); - r.CheckTypeError(kRepBit | kTypeBool, kRepFloat32); + r.CheckTypeError(MachineType::RepFloat32(), MachineRepresentation::kBit); + r.CheckTypeError(MachineType::RepBit(), MachineRepresentation::kFloat32); + r.CheckTypeError(MachineType::Bool(), MachineRepresentation::kFloat32); // Word64 is internal and shouldn't be implicitly converted. - r.CheckTypeError(kRepWord64, kRepTagged); - r.CheckTypeError(kRepTagged, kRepWord64); - r.CheckTypeError(kRepTagged | kTypeBool, kRepWord64); + r.CheckTypeError(MachineType::RepWord64(), MachineRepresentation::kTagged); + r.CheckTypeError(MachineType::RepTagged(), MachineRepresentation::kWord64); + r.CheckTypeError(MachineType::TaggedBool(), MachineRepresentation::kWord64); // Word64 / Word32 shouldn't be implicitly converted. - r.CheckTypeError(kRepWord64, kRepWord32); - r.CheckTypeError(kRepWord32, kRepWord64); - r.CheckTypeError(kRepWord32 | kTypeInt32, kRepWord64); - r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); - - for (size_t i = 0; i < arraysize(all_reps); i++) { - for (size_t j = 0; j < arraysize(all_reps); j++) { - if (i == j) continue; - // Only a single from representation is allowed. - r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); - } - } + r.CheckTypeError(MachineType::RepWord64(), MachineRepresentation::kWord32); + r.CheckTypeError(MachineType::RepWord32(), MachineRepresentation::kWord64); + r.CheckTypeError(MachineType::Int32(), MachineRepresentation::kWord64); + r.CheckTypeError(MachineType::Uint32(), MachineRepresentation::kWord64); } } // namespace compiler diff --git a/test/cctest/compiler/test-run-machops.cc b/test/cctest/compiler/test-run-machops.cc index 7b251b52f5..41603dfbbf 100644 --- a/test/cctest/compiler/test-run-machops.cc +++ b/test/cctest/compiler/test-run-machops.cc @@ -30,7 +30,7 @@ TEST(RunInt32Add) { TEST(RunWord32Ctz) { - BufferedRawMachineAssemblerTester m(kMachUint32); + BufferedRawMachineAssemblerTester m(MachineType::Uint32()); if (!m.machine()->Word32Ctz().IsSupported()) { // We can only test the operator if it exists on the testing platform. return; @@ -74,7 +74,7 @@ TEST(RunWord32Ctz) { TEST(RunWord32Clz) { - BufferedRawMachineAssemblerTester m(kMachUint32); + BufferedRawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Clz(m.Parameter(0))); CHECK_EQ(0, m.Call(uint32_t(0x80001000))); @@ -114,7 +114,7 @@ TEST(RunWord32Clz) { TEST(RunWord32Popcnt) { - BufferedRawMachineAssemblerTester m(kMachUint32); + BufferedRawMachineAssemblerTester m(MachineType::Uint32()); if (!m.machine()->Word32Popcnt().IsSupported()) { // We can only test the operator if it exists on the testing platform. return; @@ -134,7 +134,7 @@ TEST(RunWord32Popcnt) { #if V8_TARGET_ARCH_64_BIT TEST(RunWord64Clz) { - BufferedRawMachineAssemblerTester m(kMachUint64); + BufferedRawMachineAssemblerTester m(MachineType::Uint64()); m.Return(m.Word64Clz(m.Parameter(0))); CHECK_EQ(0, m.Call(uint64_t(0x8000100000000000))); @@ -206,7 +206,7 @@ TEST(RunWord64Clz) { TEST(RunWord64Ctz) { - RawMachineAssemblerTester m(kMachUint64); + RawMachineAssemblerTester m(MachineType::Uint64()); if (!m.machine()->Word64Ctz().IsSupported()) { return; } @@ -282,7 +282,7 @@ TEST(RunWord64Ctz) { TEST(RunWord64Popcnt) { - BufferedRawMachineAssemblerTester m(kMachUint64); + BufferedRawMachineAssemblerTester m(MachineType::Uint64()); if (!m.machine()->Word64Popcnt().IsSupported()) { return; } @@ -318,7 +318,7 @@ static Node* Int32Input(RawMachineAssemblerTester* m, int index) { case 6: return m->Int32Constant(0x01234567); case 7: - return m->Load(kMachInt32, m->PointerConstant(NULL)); + return m->Load(MachineType::Int32(), m->PointerConstant(NULL)); default: return NULL; } @@ -343,7 +343,8 @@ TEST(CodeGenInt32Binop) { for (size_t i = 0; i < arraysize(kOps); ++i) { for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); Node* a = Int32Input(&m, j); Node* b = Int32Input(&m, k); m.Return(m.AddNode(kOps[i], a, b)); @@ -379,7 +380,7 @@ static Node* Int64Input(RawMachineAssemblerTester* m, int index) { case 6: return m->Int64Constant(0x0123456789abcdefLL); case 7: - return m->Load(kMachInt64, m->PointerConstant(NULL)); + return m->Load(MachineType::Int64(), m->PointerConstant(NULL)); default: return NULL; } @@ -403,7 +404,8 @@ TEST(CodeGenInt64Binop) { for (size_t i = 0; i < arraysize(kOps); ++i) { for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { - RawMachineAssemblerTester m(kMachInt64, kMachInt64); + RawMachineAssemblerTester m(MachineType::Int64(), + MachineType::Int64()); Node* a = Int64Input(&m, j); Node* b = Int64Input(&m, k); m.Return(m.AddNode(kOps[i], a, b)); @@ -498,7 +500,7 @@ TEST(RunLoop) { template static void BuildDiamondPhi(RawMachineAssemblerTester* m, Node* cond_node, - MachineType type, Node* true_node, + MachineRepresentation rep, Node* true_node, Node* false_node) { RawMachineLabel blocka, blockb, end; m->Branch(cond_node, &blocka, &blockb); @@ -508,51 +510,55 @@ static void BuildDiamondPhi(RawMachineAssemblerTester* m, Node* cond_node, m->Goto(&end); m->Bind(&end); - Node* phi = m->Phi(type, true_node, false_node); + Node* phi = m->Phi(rep, true_node, false_node); m->Return(phi); } TEST(RunDiamondPhiConst) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); int false_val = 0xFF666; int true_val = 0x00DDD; Node* true_node = m.Int32Constant(true_val); Node* false_node = m.Int32Constant(false_val); - BuildDiamondPhi(&m, m.Parameter(0), kMachInt32, true_node, false_node); + BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kWord32, true_node, + false_node); CHECK_EQ(false_val, m.Call(0)); CHECK_EQ(true_val, m.Call(1)); } TEST(RunDiamondPhiNumber) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); double false_val = -11.1; double true_val = 200.1; Node* true_node = m.NumberConstant(true_val); Node* false_node = m.NumberConstant(false_val); - BuildDiamondPhi(&m, m.Parameter(0), kMachAnyTagged, true_node, false_node); + BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kTagged, true_node, + false_node); m.CheckNumber(false_val, m.Call(0)); m.CheckNumber(true_val, m.Call(1)); } TEST(RunDiamondPhiString) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); const char* false_val = "false"; const char* true_val = "true"; Node* true_node = m.StringConstant(true_val); Node* false_node = m.StringConstant(false_val); - BuildDiamondPhi(&m, m.Parameter(0), kMachAnyTagged, true_node, false_node); + BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kTagged, true_node, + false_node); m.CheckString(false_val, m.Call(0)); m.CheckString(true_val, m.Call(1)); } TEST(RunDiamondPhiParam) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachInt32); - BuildDiamondPhi(&m, m.Parameter(0), kMachInt32, m.Parameter(1), - m.Parameter(2)); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); + BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kWord32, + m.Parameter(1), m.Parameter(2)); int32_t c1 = 0x260cb75a; int32_t c2 = 0xcd3e9c8b; int result = m.Call(0, c1, c2); @@ -576,7 +582,7 @@ TEST(RunLoopPhiConst) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachInt32, false_node, true_node); + Node* phi = m.Phi(MachineRepresentation::kWord32, false_node, true_node); m.Branch(cond_node, &body, &end); m.Bind(&body); m.Goto(&header); @@ -588,15 +594,18 @@ TEST(RunLoopPhiConst) { TEST(RunLoopPhiParam) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); RawMachineLabel blocka, blockb, end; m.Goto(&blocka); m.Bind(&blocka); - Node* phi = m.Phi(kMachInt32, m.Parameter(1), m.Parameter(2)); - Node* cond = m.Phi(kMachInt32, m.Parameter(0), m.Int32Constant(0)); + Node* phi = + m.Phi(MachineRepresentation::kWord32, m.Parameter(1), m.Parameter(2)); + Node* cond = + m.Phi(MachineRepresentation::kWord32, m.Parameter(0), m.Int32Constant(0)); m.Branch(cond, &blockb, &end); m.Bind(&blockb); @@ -626,7 +635,7 @@ TEST(RunLoopPhiInduction) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachInt32, false_node, false_node); + Node* phi = m.Phi(MachineRepresentation::kWord32, false_node, false_node); m.Branch(m.Int32Constant(0), &body, &end); m.Bind(&body); @@ -652,7 +661,7 @@ TEST(RunLoopIncrement) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachInt32, zero, zero); + Node* phi = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Branch(m.WordXor(phi, bt.param0), &body, &end); m.Bind(&body); @@ -679,7 +688,7 @@ TEST(RunLoopIncrement2) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachInt32, zero, zero); + Node* phi = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Branch(m.Int32LessThan(phi, bt.param0), &body, &end); m.Bind(&body); @@ -707,7 +716,7 @@ TEST(RunLoopIncrement3) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachInt32, zero, zero); + Node* phi = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Branch(m.Uint32LessThan(phi, bt.param0), &body, &end); m.Bind(&body); @@ -734,7 +743,8 @@ TEST(RunLoopDecrement) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachInt32, bt.param0, m.Int32Constant(0)); + Node* phi = + m.Phi(MachineRepresentation::kWord32, bt.param0, m.Int32Constant(0)); m.Branch(phi, &body, &end); m.Bind(&body); @@ -761,7 +771,7 @@ TEST(RunLoopIncrementFloat32) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachFloat32, minus_3, ten); + Node* phi = m.Phi(MachineRepresentation::kFloat32, minus_3, ten); m.Branch(m.Float32LessThan(phi, ten), &body, &end); m.Bind(&body); @@ -786,7 +796,7 @@ TEST(RunLoopIncrementFloat64) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachFloat64, minus_3, ten); + Node* phi = m.Phi(MachineRepresentation::kFloat64, minus_3, ten); m.Branch(m.Float64LessThan(phi, ten), &body, &end); m.Bind(&body); @@ -824,7 +834,7 @@ TEST(RunSwitch1) { TEST(RunSwitch2) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); RawMachineLabel blocka, blockb, blockc; RawMachineLabel* case_labels[] = {&blocka, &blockb}; @@ -848,7 +858,7 @@ TEST(RunSwitch2) { TEST(RunSwitch3) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); RawMachineLabel blocka, blockb, blockc; RawMachineLabel* case_labels[] = {&blocka, &blockb}; @@ -872,7 +882,7 @@ TEST(RunSwitch3) { TEST(RunSwitch4) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); const size_t kNumCases = 512; const size_t kNumValues = kNumCases + 1; @@ -901,7 +911,8 @@ TEST(RunSwitch4) { m.Bind(&end); const int num_results = static_cast(arraysize(results)); Node* phi = - m.AddNode(m.common()->Phi(kMachInt32, num_results), num_results, results); + m.AddNode(m.common()->Phi(MachineRepresentation::kWord32, num_results), + num_results, results); m.Return(phi); for (size_t i = 0; i < kNumValues; ++i) { @@ -914,7 +925,7 @@ TEST(RunLoadInt32) { RawMachineAssemblerTester m; int32_t p1 = 0; // loads directly from this location. - m.Return(m.LoadFromPointer(&p1, kMachInt32)); + m.Return(m.LoadFromPointer(&p1, MachineType::Int32())); FOR_INT32_INPUTS(i) { p1 = *i; @@ -934,7 +945,7 @@ TEST(RunLoadInt32Offset) { int32_t offset = offsets[i]; byte* pointer = reinterpret_cast(&p1) - offset; // generate load [#base + #index] - m.Return(m.LoadFromPointer(pointer, kMachInt32, offset)); + m.Return(m.LoadFromPointer(pointer, MachineType::Int32(), offset)); FOR_INT32_INPUTS(j) { p1 = *j; @@ -955,10 +966,10 @@ TEST(RunLoadStoreFloat32Offset) { byte* from = reinterpret_cast(&p1) - offset; byte* to = reinterpret_cast(&p2) - offset; // generate load [#base + #index] - Node* load = - m.Load(kMachFloat32, m.PointerConstant(from), m.IntPtrConstant(offset)); - m.Store(kMachFloat32, m.PointerConstant(to), m.IntPtrConstant(offset), load, - kNoWriteBarrier); + Node* load = m.Load(MachineType::Float32(), m.PointerConstant(from), + m.IntPtrConstant(offset)); + m.Store(MachineType::Float32(), m.PointerConstant(to), + m.IntPtrConstant(offset), load, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); FOR_FLOAT32_INPUTS(j) { @@ -982,10 +993,10 @@ TEST(RunLoadStoreFloat64Offset) { byte* from = reinterpret_cast(&p1) - offset; byte* to = reinterpret_cast(&p2) - offset; // generate load [#base + #index] - Node* load = - m.Load(kMachFloat64, m.PointerConstant(from), m.IntPtrConstant(offset)); - m.Store(kMachFloat64, m.PointerConstant(to), m.IntPtrConstant(offset), load, - kNoWriteBarrier); + Node* load = m.Load(MachineType::Float64(), m.PointerConstant(from), + m.IntPtrConstant(offset)); + m.Store(MachineType::Float64(), m.PointerConstant(to), + m.IntPtrConstant(offset), load, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); FOR_FLOAT64_INPUTS(j) { @@ -1016,7 +1027,8 @@ TEST(RunInt32AddP) { TEST(RunInt32AddAndWord32EqualP) { { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32Equal(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { @@ -1031,7 +1043,8 @@ TEST(RunInt32AddAndWord32EqualP) { } } { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Word32Equal(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { @@ -1051,7 +1064,8 @@ TEST(RunInt32AddAndWord32EqualP) { TEST(RunInt32AddAndWord32EqualImm) { { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Add(m.Int32Constant(*i), m.Word32Equal(m.Parameter(0), m.Parameter(1)))); FOR_INT32_INPUTS(j) { @@ -1066,7 +1080,8 @@ TEST(RunInt32AddAndWord32EqualImm) { } { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Add(m.Word32Equal(m.Int32Constant(*i), m.Parameter(0)), m.Parameter(1))); FOR_INT32_INPUTS(j) { @@ -1084,7 +1099,8 @@ TEST(RunInt32AddAndWord32EqualImm) { TEST(RunInt32AddAndWord32NotEqualP) { { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32NotEqual(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { @@ -1099,7 +1115,8 @@ TEST(RunInt32AddAndWord32NotEqualP) { } } { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Word32NotEqual(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { @@ -1119,7 +1136,8 @@ TEST(RunInt32AddAndWord32NotEqualP) { TEST(RunInt32AddAndWord32NotEqualImm) { { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Add(m.Int32Constant(*i), m.Word32NotEqual(m.Parameter(0), m.Parameter(1)))); FOR_INT32_INPUTS(j) { @@ -1134,7 +1152,8 @@ TEST(RunInt32AddAndWord32NotEqualImm) { } { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Add(m.Word32NotEqual(m.Int32Constant(*i), m.Parameter(0)), m.Parameter(1))); FOR_INT32_INPUTS(j) { @@ -1152,7 +1171,8 @@ TEST(RunInt32AddAndWord32NotEqualImm) { TEST(RunInt32AddAndWord32SarP) { { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32Sar(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -1166,7 +1186,8 @@ TEST(RunInt32AddAndWord32SarP) { } } { - RawMachineAssemblerTester m(kMachInt32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Word32Sar(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { @@ -1184,7 +1205,8 @@ TEST(RunInt32AddAndWord32SarP) { TEST(RunInt32AddAndWord32ShlP) { { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32Shl(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -1198,7 +1220,8 @@ TEST(RunInt32AddAndWord32ShlP) { } } { - RawMachineAssemblerTester m(kMachInt32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Word32Shl(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { @@ -1216,7 +1239,8 @@ TEST(RunInt32AddAndWord32ShlP) { TEST(RunInt32AddAndWord32ShrP) { { - RawMachineAssemblerTester m(kMachUint32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Parameter(0), m.Word32Shr(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -1230,7 +1254,8 @@ TEST(RunInt32AddAndWord32ShrP) { } } { - RawMachineAssemblerTester m(kMachUint32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Add(m.Word32Shr(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { @@ -1286,7 +1311,7 @@ TEST(RunInt32AddInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -1303,7 +1328,7 @@ TEST(RunInt32AddInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -1324,8 +1349,8 @@ TEST(RunInt32AddInBranch) { m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, - kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), @@ -1390,7 +1415,7 @@ TEST(RunInt32AddInComparison) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { @@ -1401,7 +1426,7 @@ TEST(RunInt32AddInComparison) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { @@ -1416,8 +1441,8 @@ TEST(RunInt32AddInComparison) { m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, - kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Word32Equal( m.Int32Add(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), @@ -1467,7 +1492,7 @@ TEST(RunInt32SubP) { TEST(RunInt32SubImm) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i - *j; @@ -1477,7 +1502,7 @@ TEST(RunInt32SubImm) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j - *i; @@ -1490,7 +1515,8 @@ TEST(RunInt32SubImm) { TEST(RunInt32SubAndWord32SarP) { { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Parameter(0), m.Word32Sar(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -1503,7 +1529,8 @@ TEST(RunInt32SubAndWord32SarP) { } } { - RawMachineAssemblerTester m(kMachInt32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Word32Sar(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { @@ -1520,7 +1547,8 @@ TEST(RunInt32SubAndWord32SarP) { TEST(RunInt32SubAndWord32ShlP) { { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Parameter(0), m.Word32Shl(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -1533,7 +1561,8 @@ TEST(RunInt32SubAndWord32ShlP) { } } { - RawMachineAssemblerTester m(kMachInt32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Word32Shl(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { @@ -1551,8 +1580,8 @@ TEST(RunInt32SubAndWord32ShlP) { TEST(RunInt32SubAndWord32ShrP) { { - RawMachineAssemblerTester m(kMachUint32, kMachUint32, - kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Parameter(0), m.Word32Shr(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -1566,8 +1595,8 @@ TEST(RunInt32SubAndWord32ShrP) { } } { - RawMachineAssemblerTester m(kMachUint32, kMachUint32, - kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { @@ -1623,7 +1652,7 @@ TEST(RunInt32SubInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -1640,7 +1669,7 @@ TEST(RunInt32SubInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -1661,8 +1690,8 @@ TEST(RunInt32SubInBranch) { m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, - kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), @@ -1727,7 +1756,7 @@ TEST(RunInt32SubInComparison) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { @@ -1738,7 +1767,7 @@ TEST(RunInt32SubInComparison) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { @@ -1753,8 +1782,8 @@ TEST(RunInt32SubInComparison) { m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, - kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Word32Equal( m.Int32Sub(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), @@ -1829,7 +1858,7 @@ TEST(RunInt32MulHighP) { TEST(RunInt32MulImm) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Int32Mul(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i * *j; @@ -1839,7 +1868,7 @@ TEST(RunInt32MulImm) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant(*i))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j * *i; @@ -1854,7 +1883,7 @@ TEST(RunInt32MulAndInt32AddP) { { FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); int32_t p0 = *i; int32_t p1 = *j; m.Return(m.Int32Add(m.Int32Constant(p0), @@ -1868,7 +1897,8 @@ TEST(RunInt32MulAndInt32AddP) { } } { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return( m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { @@ -1884,7 +1914,8 @@ TEST(RunInt32MulAndInt32AddP) { } } { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32()); m.Return( m.Int32Add(m.Int32Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { @@ -1920,7 +1951,8 @@ TEST(RunInt32MulAndInt32AddP) { TEST(RunInt32MulAndInt32SubP) { { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Int32()); m.Return( m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -2230,7 +2262,7 @@ TEST(RunWord32AndAndWord32SarP) { TEST(RunWord32AndImm) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32And(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i & *j; @@ -2240,7 +2272,7 @@ TEST(RunWord32AndImm) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i & ~(*j); @@ -2291,7 +2323,7 @@ TEST(RunWord32AndInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -2308,7 +2340,7 @@ TEST(RunWord32AndInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), @@ -2330,8 +2362,8 @@ TEST(RunWord32AndInBranch) { m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, - kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), @@ -2396,7 +2428,7 @@ TEST(RunWord32AndInComparison) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { @@ -2407,7 +2439,7 @@ TEST(RunWord32AndInComparison) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32And(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { @@ -2459,7 +2491,7 @@ TEST(RunWord32OrP) { TEST(RunWord32OrImm) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Or(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i | *j; @@ -2469,7 +2501,7 @@ TEST(RunWord32OrImm) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i | ~(*j); @@ -2520,7 +2552,7 @@ TEST(RunWord32OrInBranch) { } { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -2537,7 +2569,7 @@ TEST(RunWord32OrInBranch) { } { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32NotEqual(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -2558,8 +2590,8 @@ TEST(RunWord32OrInBranch) { m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, - kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), @@ -2624,7 +2656,7 @@ TEST(RunWord32OrInComparison) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { @@ -2635,7 +2667,7 @@ TEST(RunWord32OrInComparison) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32Or(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { @@ -2650,7 +2682,7 @@ TEST(RunWord32OrInComparison) { TEST(RunWord32XorP) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i ^ *j; @@ -2693,7 +2725,7 @@ TEST(RunWord32XorP) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i ^ ~(*j); @@ -2744,7 +2776,7 @@ TEST(RunWord32XorInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -2761,7 +2793,7 @@ TEST(RunWord32XorInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), @@ -2783,8 +2815,8 @@ TEST(RunWord32XorInBranch) { m.machine()->Word32Shl(), m.machine()->Word32Shr()}; for (size_t n = 0; n < arraysize(shops); n++) { - RawMachineAssemblerTester m(kMachUint32, kMachInt32, - kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32()); RawMachineLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), m.AddNode(shops[n], m.Parameter(1), @@ -2825,7 +2857,7 @@ TEST(RunWord32XorInBranch) { TEST(RunWord32ShlP) { { FOR_UINT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j << shift; @@ -2874,7 +2906,7 @@ TEST(RunWord32ShlInComparison) { } { FOR_UINT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Int32Constant(0), m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)))); @@ -2886,7 +2918,7 @@ TEST(RunWord32ShlInComparison) { } { FOR_UINT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(0))); @@ -2902,7 +2934,7 @@ TEST(RunWord32ShlInComparison) { TEST(RunWord32ShrP) { { FOR_UINT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j >> shift; @@ -2952,7 +2984,7 @@ TEST(RunWord32ShrInComparison) { } { FOR_UINT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Int32Constant(0), m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); @@ -2964,7 +2996,7 @@ TEST(RunWord32ShrInComparison) { } { FOR_UINT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(0))); @@ -2980,7 +3012,7 @@ TEST(RunWord32ShrInComparison) { TEST(RunWord32SarP) { { FOR_INT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift))); FOR_INT32_INPUTS(j) { int32_t expected = *j >> shift; @@ -3030,7 +3062,7 @@ TEST(RunWord32SarInComparison) { } { FOR_INT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); m.Return( m.Word32Equal(m.Int32Constant(0), m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)))); @@ -3042,7 +3074,7 @@ TEST(RunWord32SarInComparison) { } { FOR_INT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); m.Return( m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(0))); @@ -3058,7 +3090,7 @@ TEST(RunWord32SarInComparison) { TEST(RunWord32RorP) { { FOR_UINT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift))); FOR_UINT32_INPUTS(j) { int32_t expected = bits::RotateRight32(*j, shift); @@ -3107,7 +3139,7 @@ TEST(RunWord32RorInComparison) { } { FOR_UINT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Int32Constant(0), m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)))); @@ -3119,7 +3151,7 @@ TEST(RunWord32RorInComparison) { } { FOR_UINT32_SHIFTS(shift) { - RawMachineAssemblerTester m(kMachUint32); + RawMachineAssemblerTester m(MachineType::Uint32()); m.Return( m.Word32Equal(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(0))); @@ -3133,7 +3165,7 @@ TEST(RunWord32RorInComparison) { TEST(RunWord32NotP) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); m.Return(m.Word32Not(m.Parameter(0))); FOR_INT32_INPUTS(i) { int expected = ~(*i); @@ -3143,7 +3175,7 @@ TEST(RunWord32NotP) { TEST(RunInt32NegP) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); m.Return(m.Int32Neg(m.Parameter(0))); FOR_INT32_INPUTS(i) { int expected = -*i; @@ -3154,7 +3186,8 @@ TEST(RunInt32NegP) { TEST(RunWord32EqualAndWord32SarP) { { - RawMachineAssemblerTester m(kMachInt32, kMachInt32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Int32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Parameter(0), m.Word32Sar(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { @@ -3167,7 +3200,8 @@ TEST(RunWord32EqualAndWord32SarP) { } } { - RawMachineAssemblerTester m(kMachInt32, kMachUint32, kMachInt32); + RawMachineAssemblerTester m( + MachineType::Int32(), MachineType::Uint32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { @@ -3184,7 +3218,8 @@ TEST(RunWord32EqualAndWord32SarP) { TEST(RunWord32EqualAndWord32ShlP) { { - RawMachineAssemblerTester m(kMachUint32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Parameter(0), m.Word32Shl(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -3197,7 +3232,8 @@ TEST(RunWord32EqualAndWord32ShlP) { } } { - RawMachineAssemblerTester m(kMachUint32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { @@ -3214,7 +3250,8 @@ TEST(RunWord32EqualAndWord32ShlP) { TEST(RunWord32EqualAndWord32ShrP) { { - RawMachineAssemblerTester m(kMachUint32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Parameter(0), m.Word32Shr(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -3227,7 +3264,8 @@ TEST(RunWord32EqualAndWord32ShrP) { } } { - RawMachineAssemblerTester m(kMachUint32, kMachUint32, kMachUint32); + RawMachineAssemblerTester m( + MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); m.Return(m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { @@ -3244,7 +3282,8 @@ TEST(RunWord32EqualAndWord32ShrP) { TEST(RunDeadNodes) { for (int i = 0; true; i++) { - RawMachineAssemblerTester m(i == 5 ? kMachInt32 : kMachNone); + RawMachineAssemblerTester m(i == 5 ? MachineType::Int32() + : MachineType::None()); int constant = 0x55 + i; switch (i) { case 0: @@ -3260,7 +3299,7 @@ TEST(RunDeadNodes) { m.PointerConstant(&constant); break; case 4: - m.LoadFromPointer(&constant, kMachInt32); + m.LoadFromPointer(&constant, MachineType::Int32()); break; case 5: m.Parameter(0); @@ -3295,7 +3334,8 @@ TEST(RunDeadInt32Binops) { m.machine()->Uint32LessThanOrEqual()}; for (size_t i = 0; i < arraysize(kOps); ++i) { - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); int32_t constant = static_cast(0x55555 + i); m.AddNode(kOps[i], m.Parameter(0), m.Parameter(1)); m.Return(m.Int32Constant(constant)); @@ -3333,16 +3373,16 @@ static void RunLoadImmIndex(MachineType rep) { TEST(RunLoadImmIndex) { - RunLoadImmIndex(kMachInt8); - RunLoadImmIndex(kMachUint8); - RunLoadImmIndex(kMachInt16); - RunLoadImmIndex(kMachUint16); - RunLoadImmIndex(kMachInt32); - RunLoadImmIndex(kMachUint32); - RunLoadImmIndex(kMachAnyTagged); + RunLoadImmIndex(MachineType::Int8()); + RunLoadImmIndex(MachineType::Uint8()); + RunLoadImmIndex(MachineType::Int16()); + RunLoadImmIndex(MachineType::Uint16()); + RunLoadImmIndex(MachineType::Int32()); + RunLoadImmIndex(MachineType::Uint32()); + RunLoadImmIndex(MachineType::AnyTagged()); // TODO(titzer): test kRepBit loads - // TODO(titzer): test kMachFloat64 loads + // TODO(titzer): test MachineType::Float64() loads // TODO(titzer): test various indexing modes. } @@ -3377,20 +3417,21 @@ static void RunLoadStore(MachineType rep) { TEST(RunLoadStore) { - RunLoadStore(kMachInt8); - RunLoadStore(kMachUint8); - RunLoadStore(kMachInt16); - RunLoadStore(kMachUint16); - RunLoadStore(kMachInt32); - RunLoadStore(kMachUint32); - RunLoadStore(kMachAnyTagged); - RunLoadStore(kMachFloat32); - RunLoadStore(kMachFloat64); + RunLoadStore(MachineType::Int8()); + RunLoadStore(MachineType::Uint8()); + RunLoadStore(MachineType::Int16()); + RunLoadStore(MachineType::Uint16()); + RunLoadStore(MachineType::Int32()); + RunLoadStore(MachineType::Uint32()); + RunLoadStore(MachineType::AnyTagged()); + RunLoadStore(MachineType::Float32()); + RunLoadStore(MachineType::Float64()); } TEST(RunFloat32Add) { - BufferedRawMachineAssemblerTester m(kMachFloat32, kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32(), + MachineType::Float32()); m.Return(m.Float32Add(m.Parameter(0), m.Parameter(1))); FOR_FLOAT32_INPUTS(i) { @@ -3403,7 +3444,8 @@ TEST(RunFloat32Add) { TEST(RunFloat32Sub) { - BufferedRawMachineAssemblerTester m(kMachFloat32, kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32(), + MachineType::Float32()); m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1))); FOR_FLOAT32_INPUTS(i) { @@ -3416,7 +3458,8 @@ TEST(RunFloat32Sub) { TEST(RunFloat32Mul) { - BufferedRawMachineAssemblerTester m(kMachFloat32, kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32(), + MachineType::Float32()); m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1))); FOR_FLOAT32_INPUTS(i) { @@ -3429,7 +3472,8 @@ TEST(RunFloat32Mul) { TEST(RunFloat32Div) { - BufferedRawMachineAssemblerTester m(kMachFloat32, kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32(), + MachineType::Float32()); m.Return(m.Float32Div(m.Parameter(0), m.Parameter(1))); FOR_FLOAT32_INPUTS(i) { @@ -3442,7 +3486,8 @@ TEST(RunFloat32Div) { TEST(RunFloat64Add) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64(), + MachineType::Float64()); m.Return(m.Float64Add(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { @@ -3452,7 +3497,8 @@ TEST(RunFloat64Add) { TEST(RunFloat64Sub) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64(), + MachineType::Float64()); m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { @@ -3462,7 +3508,8 @@ TEST(RunFloat64Sub) { TEST(RunFloat64Mul) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64(), + MachineType::Float64()); m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { @@ -3475,7 +3522,8 @@ TEST(RunFloat64Mul) { TEST(RunFloat64Div) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64(), + MachineType::Float64()); m.Return(m.Float64Div(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { @@ -3488,7 +3536,8 @@ TEST(RunFloat64Div) { TEST(RunFloat64Mod) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64(), + MachineType::Float64()); m.Return(m.Float64Mod(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { @@ -3642,7 +3691,7 @@ TEST(RunFloat32SubP) { TEST(RunFloat32SubImm1) { FOR_FLOAT32_INPUTS(i) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); m.Return(m.Float32Sub(m.Float32Constant(*i), m.Parameter(0))); FOR_FLOAT32_INPUTS(j) { @@ -3655,7 +3704,7 @@ TEST(RunFloat32SubImm1) { TEST(RunFloat32SubImm2) { FOR_FLOAT32_INPUTS(i) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); m.Return(m.Float32Sub(m.Parameter(0), m.Float32Constant(*i))); FOR_FLOAT32_INPUTS(j) { @@ -3668,7 +3717,7 @@ TEST(RunFloat32SubImm2) { TEST(RunFloat64SubImm1) { FOR_FLOAT64_INPUTS(i) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.Float64Sub(m.Float64Constant(*i), m.Parameter(0))); FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i - *j, m.Call(*j)); } @@ -3678,7 +3727,7 @@ TEST(RunFloat64SubImm1) { TEST(RunFloat64SubImm2) { FOR_FLOAT64_INPUTS(i) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.Float64Sub(m.Parameter(0), m.Float64Constant(*i))); FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j - *i, m.Call(*j)); } @@ -3732,8 +3781,8 @@ TEST(RunFloat64MulP) { TEST(RunFloat64MulAndFloat64Add1) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachFloat64, - kMachFloat64); + BufferedRawMachineAssemblerTester m( + MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Add(m.Float64Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); @@ -3748,8 +3797,8 @@ TEST(RunFloat64MulAndFloat64Add1) { TEST(RunFloat64MulAndFloat64Add2) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachFloat64, - kMachFloat64); + BufferedRawMachineAssemblerTester m( + MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Add(m.Parameter(0), m.Float64Mul(m.Parameter(1), m.Parameter(2)))); @@ -3764,8 +3813,8 @@ TEST(RunFloat64MulAndFloat64Add2) { TEST(RunFloat64MulAndFloat64Sub1) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachFloat64, - kMachFloat64); + BufferedRawMachineAssemblerTester m( + MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Sub(m.Float64Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); @@ -3780,8 +3829,8 @@ TEST(RunFloat64MulAndFloat64Sub1) { TEST(RunFloat64MulAndFloat64Sub2) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachFloat64, - kMachFloat64); + BufferedRawMachineAssemblerTester m( + MachineType::Float64(), MachineType::Float64(), MachineType::Float64()); m.Return(m.Float64Sub(m.Parameter(0), m.Float64Mul(m.Parameter(1), m.Parameter(2)))); @@ -3797,7 +3846,7 @@ TEST(RunFloat64MulAndFloat64Sub2) { TEST(RunFloat64MulImm1) { FOR_FLOAT64_INPUTS(i) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.Float64Mul(m.Float64Constant(*i), m.Parameter(0))); FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i * *j, m.Call(*j)); } @@ -3807,7 +3856,7 @@ TEST(RunFloat64MulImm1) { TEST(RunFloat64MulImm2) { FOR_FLOAT64_INPUTS(i) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.Float64Mul(m.Parameter(0), m.Float64Constant(*i))); FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j * *i, m.Call(*j)); } @@ -3870,7 +3919,7 @@ TEST(RunChangeInt32ToFloat64_A) { TEST(RunChangeInt32ToFloat64_B) { - BufferedRawMachineAssemblerTester m(kMachInt32); + BufferedRawMachineAssemblerTester m(MachineType::Int32()); m.Return(m.ChangeInt32ToFloat64(m.Parameter(0))); FOR_INT32_INPUTS(i) { CheckDoubleEq(static_cast(*i), m.Call(*i)); } @@ -3878,7 +3927,7 @@ TEST(RunChangeInt32ToFloat64_B) { TEST(RunChangeUint32ToFloat64) { - BufferedRawMachineAssemblerTester m(kMachUint32); + BufferedRawMachineAssemblerTester m(MachineType::Uint32()); m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); FOR_UINT32_INPUTS(i) { CheckDoubleEq(static_cast(*i), m.Call(*i)); } @@ -3894,7 +3943,7 @@ TEST(RunChangeFloat64ToInt32_A) { TEST(RunChangeFloat64ToInt32_B) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.ChangeFloat64ToInt32(m.Parameter(0))); // Note we don't check fractional inputs, or inputs outside the range of @@ -3912,7 +3961,7 @@ TEST(RunChangeFloat64ToInt32_B) { TEST(RunChangeFloat64ToUint32) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.ChangeFloat64ToUint32(m.Parameter(0))); { @@ -3931,7 +3980,7 @@ TEST(RunChangeFloat64ToUint32) { TEST(RunTruncateFloat64ToFloat32) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); @@ -3967,7 +4016,7 @@ TEST(RunLoopPhiInduction2) { Node* false_node = m.Int32Constant(false_val); m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachInt32, false_node, false_node); + Node* phi = m.Phi(MachineRepresentation::kWord32, false_node, false_node); m.Branch(m.Int32Constant(0), &body, &end); m.Bind(&body); Node* add = m.Int32Add(phi, m.Int32Constant(1)); @@ -3996,9 +4045,9 @@ TEST(RunFloatDiamond) { m.Bind(&blockb); m.Goto(&end); m.Bind(&end); - Node* phi = m.Phi(kMachFloat32, k2, k1); - m.Store(kMachFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi, - kNoWriteBarrier); + Node* phi = m.Phi(MachineRepresentation::kFloat32, k2, k1); + m.Store(MachineType::Float32(), m.PointerConstant(&buffer), + m.IntPtrConstant(0), phi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -4022,9 +4071,9 @@ TEST(RunDoubleDiamond) { m.Bind(&blockb); m.Goto(&end); m.Bind(&end); - Node* phi = m.Phi(kMachFloat64, k2, k1); - m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, - kNoWriteBarrier); + Node* phi = m.Phi(MachineRepresentation::kFloat64, k2, k1); + m.Store(MachineType::Float64(), m.PointerConstant(&buffer), + m.Int32Constant(0), phi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -4049,9 +4098,9 @@ TEST(RunRefDiamond) { m.Bind(&blockb); m.Goto(&end); m.Bind(&end); - Node* phi = m.Phi(kMachAnyTagged, k2, k1); - m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi, - kNoWriteBarrier); + Node* phi = m.Phi(MachineRepresentation::kTagged, k2, k1); + m.Store(MachineType::AnyTagged(), m.PointerConstant(&buffer), + m.Int32Constant(0), phi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -4080,12 +4129,12 @@ TEST(RunDoubleRefDiamond) { m.Bind(&blockb); m.Goto(&end); m.Bind(&end); - Node* dphi = m.Phi(kMachFloat64, d2, d1); - Node* rphi = m.Phi(kMachAnyTagged, r2, r1); - m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi, - kNoWriteBarrier); - m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi, - kNoWriteBarrier); + Node* dphi = m.Phi(MachineRepresentation::kFloat64, d2, d1); + Node* rphi = m.Phi(MachineRepresentation::kTagged, r2, r1); + m.Store(MachineType::Float64(), m.PointerConstant(&dbuffer), + m.Int32Constant(0), dphi, kNoWriteBarrier); + m.Store(MachineType::AnyTagged(), m.PointerConstant(&rbuffer), + m.Int32Constant(0), rphi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -4115,8 +4164,8 @@ TEST(RunDoubleRefDoubleDiamond) { m.Bind(&blockb); m.Goto(&mid); m.Bind(&mid); - Node* dphi1 = m.Phi(kMachFloat64, d2, d1); - Node* rphi1 = m.Phi(kMachAnyTagged, r2, r1); + Node* dphi1 = m.Phi(MachineRepresentation::kFloat64, d2, d1); + Node* rphi1 = m.Phi(MachineRepresentation::kTagged, r2, r1); m.Branch(m.Int32Constant(0), &blockd, &blocke); m.Bind(&blockd); @@ -4124,13 +4173,13 @@ TEST(RunDoubleRefDoubleDiamond) { m.Bind(&blocke); m.Goto(&end); m.Bind(&end); - Node* dphi2 = m.Phi(kMachFloat64, d1, dphi1); - Node* rphi2 = m.Phi(kMachAnyTagged, r1, rphi1); + Node* dphi2 = m.Phi(MachineRepresentation::kFloat64, d1, dphi1); + Node* rphi2 = m.Phi(MachineRepresentation::kTagged, r1, rphi1); - m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2, - kNoWriteBarrier); - m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), - rphi2, kNoWriteBarrier); + m.Store(MachineType::Float64(), m.PointerConstant(&dbuffer), + m.Int32Constant(0), dphi2, kNoWriteBarrier); + m.Store(MachineType::AnyTagged(), m.PointerConstant(&rbuffer), + m.Int32Constant(0), rphi2, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -4152,14 +4201,14 @@ TEST(RunDoubleLoopPhi) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(kMachFloat64, dk, dk); + Node* phi = m.Phi(MachineRepresentation::kFloat64, dk, dk); phi->ReplaceInput(1, phi); m.Branch(zero, &body, &end); m.Bind(&body); m.Goto(&header); m.Bind(&end); - m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, - kNoWriteBarrier); + m.Store(MachineType::Float64(), m.PointerConstant(&buffer), + m.Int32Constant(0), phi, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -4178,8 +4227,8 @@ TEST(RunCountToTenAccRaw) { m.Goto(&header); m.Bind(&header); - Node* i = m.Phi(kMachInt32, zero, zero); - Node* j = m.Phi(kMachInt32, zero, zero); + Node* i = m.Phi(MachineRepresentation::kWord32, zero, zero); + Node* j = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Goto(&body); m.Bind(&body); @@ -4211,9 +4260,9 @@ TEST(RunCountToTenAccRaw2) { m.Goto(&header); m.Bind(&header); - Node* i = m.Phi(kMachInt32, zero, zero); - Node* j = m.Phi(kMachInt32, zero, zero); - Node* k = m.Phi(kMachInt32, zero, zero); + Node* i = m.Phi(MachineRepresentation::kWord32, zero, zero); + Node* j = m.Phi(MachineRepresentation::kWord32, zero, zero); + Node* k = m.Phi(MachineRepresentation::kWord32, zero, zero); m.Goto(&body); m.Bind(&body); @@ -4240,14 +4289,22 @@ TEST(RunAddTree) { int32_t inputs[] = {11, 12, 13, 14, 15, 16, 17, 18}; Node* base = m.PointerConstant(inputs); - Node* n0 = m.Load(kMachInt32, base, m.Int32Constant(0 * sizeof(int32_t))); - Node* n1 = m.Load(kMachInt32, base, m.Int32Constant(1 * sizeof(int32_t))); - Node* n2 = m.Load(kMachInt32, base, m.Int32Constant(2 * sizeof(int32_t))); - Node* n3 = m.Load(kMachInt32, base, m.Int32Constant(3 * sizeof(int32_t))); - Node* n4 = m.Load(kMachInt32, base, m.Int32Constant(4 * sizeof(int32_t))); - Node* n5 = m.Load(kMachInt32, base, m.Int32Constant(5 * sizeof(int32_t))); - Node* n6 = m.Load(kMachInt32, base, m.Int32Constant(6 * sizeof(int32_t))); - Node* n7 = m.Load(kMachInt32, base, m.Int32Constant(7 * sizeof(int32_t))); + Node* n0 = + m.Load(MachineType::Int32(), base, m.Int32Constant(0 * sizeof(int32_t))); + Node* n1 = + m.Load(MachineType::Int32(), base, m.Int32Constant(1 * sizeof(int32_t))); + Node* n2 = + m.Load(MachineType::Int32(), base, m.Int32Constant(2 * sizeof(int32_t))); + Node* n3 = + m.Load(MachineType::Int32(), base, m.Int32Constant(3 * sizeof(int32_t))); + Node* n4 = + m.Load(MachineType::Int32(), base, m.Int32Constant(4 * sizeof(int32_t))); + Node* n5 = + m.Load(MachineType::Int32(), base, m.Int32Constant(5 * sizeof(int32_t))); + Node* n6 = + m.Load(MachineType::Int32(), base, m.Int32Constant(6 * sizeof(int32_t))); + Node* n7 = + m.Load(MachineType::Int32(), base, m.Int32Constant(7 * sizeof(int32_t))); Node* i1 = m.Int32Add(n0, n1); Node* i2 = m.Int32Add(n2, n3); @@ -4279,10 +4336,12 @@ static int Float64CompareHelper(RawMachineAssemblerTester* m, CHECK(x < y); bool load_a = node_type / 2 == 1; bool load_b = node_type % 2 == 1; - Node* a = load_a ? m->Load(kMachFloat64, m->PointerConstant(&buffer[0])) - : m->Float64Constant(x); - Node* b = load_b ? m->Load(kMachFloat64, m->PointerConstant(&buffer[1])) - : m->Float64Constant(y); + Node* a = + load_a ? m->Load(MachineType::Float64(), m->PointerConstant(&buffer[0])) + : m->Float64Constant(x); + Node* b = + load_b ? m->Load(MachineType::Float64(), m->PointerConstant(&buffer[1])) + : m->Float64Constant(y); Node* cmp = NULL; bool expected = false; switch (test_case) { @@ -4409,8 +4468,8 @@ TEST(RunFloat64Equal) { double input_b = 0.0; RawMachineAssemblerTester m; - Node* a = m.LoadFromPointer(&input_a, kMachFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachFloat64); + Node* a = m.LoadFromPointer(&input_a, MachineType::Float64()); + Node* b = m.LoadFromPointer(&input_b, MachineType::Float64()); m.Return(m.Float64Equal(a, b)); CompareWrapper cmp(IrOpcode::kFloat64Equal); @@ -4430,8 +4489,8 @@ TEST(RunFloat64LessThan) { double input_b = 0.0; RawMachineAssemblerTester m; - Node* a = m.LoadFromPointer(&input_a, kMachFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachFloat64); + Node* a = m.LoadFromPointer(&input_a, MachineType::Float64()); + Node* b = m.LoadFromPointer(&input_b, MachineType::Float64()); m.Return(m.Float64LessThan(a, b)); CompareWrapper cmp(IrOpcode::kFloat64LessThan); @@ -4446,8 +4505,8 @@ TEST(RunFloat64LessThan) { } -template -static void LoadStoreTruncation() { +template +static void LoadStoreTruncation(MachineType kRepresentation) { IntType input; RawMachineAssemblerTester m; @@ -4480,14 +4539,15 @@ static void LoadStoreTruncation() { TEST(RunLoadStoreTruncation) { - LoadStoreTruncation(); - LoadStoreTruncation(); + LoadStoreTruncation(MachineType::Int8()); + LoadStoreTruncation(MachineType::Int16()); } static void IntPtrCompare(intptr_t left, intptr_t right) { for (int test = 0; test < 7; test++) { - RawMachineAssemblerTester m(kMachPtr, kMachPtr); + RawMachineAssemblerTester m(MachineType::Pointer(), + MachineType::Pointer()); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); Node* res = NULL; @@ -4556,7 +4616,8 @@ TEST(RunTestIntPtrArithmetic) { Node* output = m.PointerConstant(&outputs[kInputSize - 1]); Node* elem_size = m.IntPtrConstant(sizeof(inputs[0])); for (int i = 0; i < kInputSize; i++) { - m.Store(kMachInt32, output, m.Load(kMachInt32, input), kNoWriteBarrier); + m.Store(MachineType::Int32(), output, m.Load(MachineType::Int32(), input), + kNoWriteBarrier); input = m.IntPtrAdd(input, elem_size); output = m.IntPtrSub(output, elem_size); } @@ -4581,7 +4642,7 @@ TEST(RunSpillLotsOfThings) { accs[i] = acc; } for (int i = 0; i < kInputSize; i++) { - m.StoreToPointer(&outputs[i], kMachInt32, accs[i]); + m.StoreToPointer(&outputs[i], MachineType::Int32(), accs[i]); } m.Return(one); m.Call(); @@ -4594,7 +4655,8 @@ TEST(RunSpillLotsOfThings) { TEST(RunSpillConstantsAndParameters) { static const int kInputSize = 1000; static const int32_t kBase = 987; - RawMachineAssemblerTester m(kMachInt32, kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); int32_t outputs[kInputSize]; Node* csts[kInputSize]; Node* accs[kInputSize]; @@ -4607,7 +4669,7 @@ TEST(RunSpillConstantsAndParameters) { accs[i] = acc; } for (int i = 0; i < kInputSize; i++) { - m.StoreToPointer(&outputs[i], kMachInt32, accs[i]); + m.StoreToPointer(&outputs[i], MachineType::Int32(), accs[i]); } m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1)))); FOR_INT32_INPUTS(i) { @@ -4628,7 +4690,7 @@ TEST(RunSpillConstantsAndParameters) { TEST(RunNewSpaceConstantsInPhi) { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); Isolate* isolate = CcTest::i_isolate(); Handle true_val = isolate->factory()->NewHeapNumber(11.2); @@ -4644,7 +4706,7 @@ TEST(RunNewSpaceConstantsInPhi) { m.Goto(&end); m.Bind(&end); - Node* phi = m.Phi(kMachAnyTagged, true_node, false_node); + Node* phi = m.Phi(MachineRepresentation::kTagged, true_node, false_node); m.Return(phi); CHECK_EQ(*false_val, m.Call(0)); @@ -4659,7 +4721,7 @@ TEST(RunInt32AddWithOverflowP) { Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachInt32, val); + m.StoreToPointer(&actual_val, MachineType::Int32(), val); bt.AddReturn(ovf); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { @@ -4676,11 +4738,11 @@ TEST(RunInt32AddWithOverflowImm) { int32_t actual_val = -1, expected_val = 0; FOR_INT32_INPUTS(i) { { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachInt32, val); + m.StoreToPointer(&actual_val, MachineType::Int32(), val); m.Return(ovf); FOR_INT32_INPUTS(j) { int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); @@ -4689,11 +4751,11 @@ TEST(RunInt32AddWithOverflowImm) { } } { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachInt32, val); + m.StoreToPointer(&actual_val, MachineType::Int32(), val); m.Return(ovf); FOR_INT32_INPUTS(j) { int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); @@ -4707,7 +4769,7 @@ TEST(RunInt32AddWithOverflowImm) { m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachInt32, val); + m.StoreToPointer(&actual_val, MachineType::Int32(), val); m.Return(ovf); int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call()); @@ -4747,7 +4809,7 @@ TEST(RunInt32SubWithOverflowP) { Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachInt32, val); + m.StoreToPointer(&actual_val, MachineType::Int32(), val); bt.AddReturn(ovf); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { @@ -4764,11 +4826,11 @@ TEST(RunInt32SubWithOverflowImm) { int32_t actual_val = -1, expected_val = 0; FOR_INT32_INPUTS(i) { { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachInt32, val); + m.StoreToPointer(&actual_val, MachineType::Int32(), val); m.Return(ovf); FOR_INT32_INPUTS(j) { int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); @@ -4777,11 +4839,11 @@ TEST(RunInt32SubWithOverflowImm) { } } { - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachInt32, val); + m.StoreToPointer(&actual_val, MachineType::Int32(), val); m.Return(ovf); FOR_INT32_INPUTS(j) { int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val); @@ -4795,7 +4857,7 @@ TEST(RunInt32SubWithOverflowImm) { m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachInt32, val); + m.StoreToPointer(&actual_val, MachineType::Int32(), val); m.Return(ovf); int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call()); @@ -4833,7 +4895,7 @@ TEST(RunWord64EqualInBranchP) { RawMachineLabel blocka, blockb; RawMachineAssemblerTester m; if (!m.machine()->Is64()) return; - Node* value = m.LoadFromPointer(&input, kMachInt64); + Node* value = m.LoadFromPointer(&input, MachineType::Int64()); m.Branch(m.Word64Equal(value, m.Int64Constant(0)), &blocka, &blockb); m.Bind(&blocka); m.Return(m.Int32Constant(1)); @@ -4851,8 +4913,9 @@ TEST(RunWord64EqualInBranchP) { TEST(RunChangeInt32ToInt64P) { if (kPointerSize < 8) return; int64_t actual = -1; - RawMachineAssemblerTester m(kMachInt32); - m.StoreToPointer(&actual, kMachInt64, m.ChangeInt32ToInt64(m.Parameter(0))); + RawMachineAssemblerTester m(MachineType::Int32()); + m.StoreToPointer(&actual, MachineType::Int64(), + m.ChangeInt32ToInt64(m.Parameter(0))); m.Return(m.Int32Constant(0)); FOR_INT32_INPUTS(i) { int64_t expected = *i; @@ -4865,8 +4928,8 @@ TEST(RunChangeInt32ToInt64P) { TEST(RunChangeUint32ToUint64P) { if (kPointerSize < 8) return; int64_t actual = -1; - RawMachineAssemblerTester m(kMachUint32); - m.StoreToPointer(&actual, kMachUint64, + RawMachineAssemblerTester m(MachineType::Uint32()); + m.StoreToPointer(&actual, MachineType::Uint64(), m.ChangeUint32ToUint64(m.Parameter(0))); m.Return(m.Int32Constant(0)); FOR_UINT32_INPUTS(i) { @@ -4881,7 +4944,8 @@ TEST(RunTruncateInt64ToInt32P) { if (kPointerSize < 8) return; int64_t expected = -1; RawMachineAssemblerTester m; - m.Return(m.TruncateInt64ToInt32(m.LoadFromPointer(&expected, kMachInt64))); + m.Return(m.TruncateInt64ToInt32( + m.LoadFromPointer(&expected, MachineType::Int64()))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { expected = (static_cast(*j) << 32) | *i; @@ -4952,8 +5016,9 @@ TEST(RunTruncateFloat64ToInt32P) { {-1.7976931348623157e+308, 0}}; double input = -1.0; RawMachineAssemblerTester m; - m.Return(m.TruncateFloat64ToInt32(TruncationMode::kJavaScript, - m.LoadFromPointer(&input, kMachFloat64))); + m.Return(m.TruncateFloat64ToInt32( + TruncationMode::kJavaScript, + m.LoadFromPointer(&input, MachineType::Float64()))); for (size_t i = 0; i < arraysize(kValues); ++i) { input = kValues[i].from; uint64_t expected = static_cast(kValues[i].raw); @@ -4963,7 +5028,7 @@ TEST(RunTruncateFloat64ToInt32P) { TEST(RunChangeFloat32ToFloat64) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); @@ -4981,7 +5046,7 @@ TEST(RunFloat32Constant) { TEST(RunFloat64ExtractLowWord32) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.Float64ExtractLowWord32(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { uint32_t expected = static_cast(bit_cast(*i)); @@ -4991,7 +5056,7 @@ TEST(RunFloat64ExtractLowWord32) { TEST(RunFloat64ExtractHighWord32) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.Float64ExtractHighWord32(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { uint32_t expected = static_cast(bit_cast(*i) >> 32); @@ -5001,7 +5066,8 @@ TEST(RunFloat64ExtractHighWord32) { TEST(RunFloat64InsertLowWord32) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachInt32); + BufferedRawMachineAssemblerTester m(MachineType::Float64(), + MachineType::Int32()); m.Return(m.Float64InsertLowWord32(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_INT32_INPUTS(j) { @@ -5015,7 +5081,8 @@ TEST(RunFloat64InsertLowWord32) { TEST(RunFloat64InsertHighWord32) { - BufferedRawMachineAssemblerTester m(kMachFloat64, kMachUint32); + BufferedRawMachineAssemblerTester m(MachineType::Float64(), + MachineType::Uint32()); m.Return(m.Float64InsertHighWord32(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_UINT32_INPUTS(j) { @@ -5029,14 +5096,14 @@ TEST(RunFloat64InsertHighWord32) { TEST(RunFloat32Abs) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); m.Return(m.Float32Abs(m.Parameter(0))); FOR_FLOAT32_INPUTS(i) { CheckFloatEq(std::abs(*i), m.Call(*i)); } } TEST(RunFloat64Abs) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.Float64Abs(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::abs(*i), m.Call(*i)); } } @@ -5141,7 +5208,7 @@ static double kValues[] = {0.1, TEST(RunFloat32RoundDown) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); if (!m.machine()->Float32RoundDown().IsSupported()) return; m.Return(m.Float32RoundDown(m.Parameter(0))); @@ -5151,7 +5218,7 @@ TEST(RunFloat32RoundDown) { TEST(RunFloat64RoundDown1) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); if (!m.machine()->Float64RoundDown().IsSupported()) return; m.Return(m.Float64RoundDown(m.Parameter(0))); @@ -5161,7 +5228,7 @@ TEST(RunFloat64RoundDown1) { TEST(RunFloat64RoundDown2) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); if (!m.machine()->Float64RoundDown().IsSupported()) return; m.Return(m.Float64Sub(m.Float64Constant(-0.0), m.Float64RoundDown(m.Float64Sub(m.Float64Constant(-0.0), @@ -5174,7 +5241,7 @@ TEST(RunFloat64RoundDown2) { TEST(RunFloat32RoundUp) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); if (!m.machine()->Float32RoundUp().IsSupported()) return; m.Return(m.Float32RoundUp(m.Parameter(0))); @@ -5183,7 +5250,7 @@ TEST(RunFloat32RoundUp) { TEST(RunFloat64RoundUp) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); if (!m.machine()->Float64RoundUp().IsSupported()) return; m.Return(m.Float64RoundUp(m.Parameter(0))); @@ -5192,7 +5259,7 @@ TEST(RunFloat64RoundUp) { TEST(RunFloat32RoundTiesEven) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); if (!m.machine()->Float32RoundTiesEven().IsSupported()) return; m.Return(m.Float32RoundTiesEven(m.Parameter(0))); @@ -5201,7 +5268,7 @@ TEST(RunFloat32RoundTiesEven) { TEST(RunFloat64RoundTiesEven) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); if (!m.machine()->Float64RoundTiesEven().IsSupported()) return; m.Return(m.Float64RoundTiesEven(m.Parameter(0))); @@ -5210,7 +5277,7 @@ TEST(RunFloat64RoundTiesEven) { TEST(RunFloat32RoundTruncate) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); if (!m.machine()->Float32RoundTruncate().IsSupported()) return; m.Return(m.Float32RoundTruncate(m.Parameter(0))); @@ -5220,7 +5287,7 @@ TEST(RunFloat32RoundTruncate) { TEST(RunFloat64RoundTruncate) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); if (!m.machine()->Float64RoundTruncate().IsSupported()) return; m.Return(m.Float64RoundTruncate(m.Parameter(0))); for (size_t i = 0; i < arraysize(kValues); ++i) { @@ -5230,7 +5297,7 @@ TEST(RunFloat64RoundTruncate) { TEST(RunFloat64RoundTiesAway) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); if (!m.machine()->Float64RoundTiesAway().IsSupported()) return; m.Return(m.Float64RoundTiesAway(m.Parameter(0))); for (size_t i = 0; i < arraysize(kValues); ++i) { @@ -5266,17 +5333,18 @@ int32_t foo8(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, TEST(RunCallCFunction0) { auto* foo0_ptr = &foo0; RawMachineAssemblerTester m; - Node* function = m.LoadFromPointer(&foo0_ptr, kMachPtr); - m.Return(m.CallCFunction0(kMachInt32, function)); + Node* function = m.LoadFromPointer(&foo0_ptr, MachineType::Pointer()); + m.Return(m.CallCFunction0(MachineType::Int32(), function)); CHECK_EQ(kMagicFoo0, m.Call()); } TEST(RunCallCFunction1) { auto* foo1_ptr = &foo1; - RawMachineAssemblerTester m(kMachInt32); - Node* function = m.LoadFromPointer(&foo1_ptr, kMachPtr); - m.Return(m.CallCFunction1(kMachInt32, kMachInt32, function, m.Parameter(0))); + RawMachineAssemblerTester m(MachineType::Int32()); + Node* function = m.LoadFromPointer(&foo1_ptr, MachineType::Pointer()); + m.Return(m.CallCFunction1(MachineType::Int32(), MachineType::Int32(), + function, m.Parameter(0))); FOR_INT32_INPUTS(i) { int32_t const expected = *i; CHECK_EQ(expected, m.Call(expected)); @@ -5286,10 +5354,12 @@ TEST(RunCallCFunction1) { TEST(RunCallCFunction2) { auto* foo2_ptr = &foo2; - RawMachineAssemblerTester m(kMachInt32, kMachInt32); - Node* function = m.LoadFromPointer(&foo2_ptr, kMachPtr); - m.Return(m.CallCFunction2(kMachInt32, kMachInt32, kMachInt32, function, - m.Parameter(0), m.Parameter(1))); + RawMachineAssemblerTester m(MachineType::Int32(), + MachineType::Int32()); + Node* function = m.LoadFromPointer(&foo2_ptr, MachineType::Pointer()); + m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), function, m.Parameter(0), + m.Parameter(1))); FOR_INT32_INPUTS(i) { int32_t const x = *i; FOR_INT32_INPUTS(j) { @@ -5302,13 +5372,14 @@ TEST(RunCallCFunction2) { TEST(RunCallCFunction8) { auto* foo8_ptr = &foo8; - RawMachineAssemblerTester m(kMachInt32); - Node* function = m.LoadFromPointer(&foo8_ptr, kMachPtr); + RawMachineAssemblerTester m(MachineType::Int32()); + Node* function = m.LoadFromPointer(&foo8_ptr, MachineType::Pointer()); Node* param = m.Parameter(0); - m.Return(m.CallCFunction8(kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, function, param, param, param, param, - param, param, param, param)); + m.Return(m.CallCFunction8( + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + function, param, param, param, param, param, param, param, param)); FOR_INT32_INPUTS(i) { int32_t const x = *i; CHECK_EQ(x * 8, m.Call(x)); @@ -5320,12 +5391,12 @@ TEST(RunCallCFunction8) { // TODO(titzer): run int64 tests on all platforms when supported. TEST(RunCheckedLoadInt64) { int64_t buffer[] = {0x66bbccddeeff0011LL, 0x1122334455667788LL}; - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); Node* base = m.PointerConstant(buffer); Node* index = m.Parameter(0); Node* length = m.Int32Constant(16); - Node* load = - m.AddNode(m.machine()->CheckedLoad(kMachInt64), base, index, length); + Node* load = m.AddNode(m.machine()->CheckedLoad(MachineType::Int64()), base, + index, length); m.Return(load); CHECK_EQ(buffer[0], m.Call(0)); @@ -5338,13 +5409,13 @@ TEST(RunCheckedStoreInt64) { const int64_t write = 0x5566778899aabbLL; const int64_t before = 0x33bbccddeeff0011LL; int64_t buffer[] = {before, before}; - RawMachineAssemblerTester m(kMachInt32); + RawMachineAssemblerTester m(MachineType::Int32()); Node* base = m.PointerConstant(buffer); Node* index = m.Parameter(0); Node* length = m.Int32Constant(16); Node* value = m.Int64Constant(write); - Node* store = m.AddNode(m.machine()->CheckedStore(kMachInt64), base, index, - length, value); + Node* store = m.AddNode(m.machine()->CheckedStore(MachineType::Int64()), base, + index, length, value); USE(store); m.Return(m.Int32Constant(11)); @@ -5367,8 +5438,8 @@ TEST(RunBitcastInt64ToFloat64) { double output = 0.0; RawMachineAssemblerTester m; m.StoreToPointer( - &output, kMachFloat64, - m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, kMachInt64))); + &output, MachineType::Float64(), + m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, MachineType::Int64()))); m.Return(m.Int32Constant(11)); FOR_INT64_INPUTS(i) { input = *i; @@ -5380,7 +5451,7 @@ TEST(RunBitcastInt64ToFloat64) { TEST(RunBitcastFloat64ToInt64) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.BitcastFloat64ToInt64(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { CHECK_EQ(bit_cast(*i), m.Call(*i)); } @@ -5388,7 +5459,7 @@ TEST(RunBitcastFloat64ToInt64) { TEST(RunTryTruncateFloat32ToInt64WithoutCheck) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); m.Return(m.TryTruncateFloat32ToInt64(m.Parameter(0))); FOR_INT64_INPUTS(i) { @@ -5402,11 +5473,11 @@ TEST(RunTryTruncateFloat32ToInt64WithoutCheck) { TEST(RunTryTruncateFloat32ToInt64WithCheck) { int64_t success = 0; - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); Node* trunc = m.TryTruncateFloat32ToInt64(m.Parameter(0)); Node* val = m.Projection(0, trunc); Node* check = m.Projection(1, trunc); - m.StoreToPointer(&success, kMachInt64, check); + m.StoreToPointer(&success, MachineType::Int64(), check); m.Return(val); FOR_FLOAT32_INPUTS(i) { @@ -5422,7 +5493,7 @@ TEST(RunTryTruncateFloat32ToInt64WithCheck) { TEST(RunTryTruncateFloat64ToInt64WithoutCheck) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.TryTruncateFloat64ToInt64(m.Parameter(0))); FOR_INT64_INPUTS(i) { @@ -5434,11 +5505,11 @@ TEST(RunTryTruncateFloat64ToInt64WithoutCheck) { TEST(RunTryTruncateFloat64ToInt64WithCheck) { int64_t success = 0; - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); Node* trunc = m.TryTruncateFloat64ToInt64(m.Parameter(0)); Node* val = m.Projection(0, trunc); Node* check = m.Projection(1, trunc); - m.StoreToPointer(&success, kMachInt64, check); + m.StoreToPointer(&success, MachineType::Int64(), check); m.Return(val); FOR_FLOAT64_INPUTS(i) { @@ -5455,7 +5526,7 @@ TEST(RunTryTruncateFloat64ToInt64WithCheck) { TEST(RunTruncateFloat32ToUint64) { - BufferedRawMachineAssemblerTester m(kMachFloat32); + BufferedRawMachineAssemblerTester m(MachineType::Float32()); m.Return(m.TruncateFloat32ToUint64(m.Parameter(0))); FOR_UINT64_INPUTS(i) { @@ -5473,7 +5544,7 @@ TEST(RunTruncateFloat32ToUint64) { TEST(RunTryTruncateFloat64ToUint64WithoutCheck) { - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); m.Return(m.TruncateFloat64ToUint64(m.Parameter(0))); FOR_UINT64_INPUTS(j) { @@ -5488,11 +5559,11 @@ TEST(RunTryTruncateFloat64ToUint64WithoutCheck) { TEST(RunTryTruncateFloat64ToUint64WithCheck) { int64_t success = 0; - BufferedRawMachineAssemblerTester m(kMachFloat64); + BufferedRawMachineAssemblerTester m(MachineType::Float64()); Node* trunc = m.TryTruncateFloat64ToUint64(m.Parameter(0)); Node* val = m.Projection(0, trunc); Node* check = m.Projection(1, trunc); - m.StoreToPointer(&success, kMachInt64, check); + m.StoreToPointer(&success, MachineType::Int64(), check); m.Return(val); FOR_FLOAT64_INPUTS(i) { @@ -5509,14 +5580,14 @@ TEST(RunTryTruncateFloat64ToUint64WithCheck) { TEST(RunRoundInt64ToFloat32) { - BufferedRawMachineAssemblerTester m(kMachInt64); + BufferedRawMachineAssemblerTester m(MachineType::Int64()); m.Return(m.RoundInt64ToFloat32(m.Parameter(0))); FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast(*i), m.Call(*i)); } } TEST(RunRoundInt64ToFloat64) { - BufferedRawMachineAssemblerTester m(kMachInt64); + BufferedRawMachineAssemblerTester m(MachineType::Int64()); m.Return(m.RoundInt64ToFloat64(m.Parameter(0))); FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast(*i), m.Call(*i)); } } @@ -5602,7 +5673,7 @@ TEST(RunRoundUint64ToFloat64) { {0x8000000000000400, 0x43e0000000000000}, {0x8000000000000401, 0x43e0000000000001}}; - BufferedRawMachineAssemblerTester m(kMachUint64); + BufferedRawMachineAssemblerTester m(MachineType::Uint64()); m.Return(m.RoundUint64ToFloat64(m.Parameter(0))); for (size_t i = 0; i < arraysize(values); i++) { @@ -5692,7 +5763,7 @@ TEST(RunRoundUint64ToFloat32) { {0x8000000000000400, 0x5f000000}, {0x8000000000000401, 0x5f000000}}; - BufferedRawMachineAssemblerTester m(kMachUint64); + BufferedRawMachineAssemblerTester m(MachineType::Uint64()); m.Return(m.RoundUint64ToFloat32(m.Parameter(0))); for (size_t i = 0; i < arraysize(values); i++) { @@ -5707,7 +5778,8 @@ TEST(RunRoundUint64ToFloat32) { TEST(RunBitcastFloat32ToInt32) { float input = 32.25; RawMachineAssemblerTester m; - m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32))); + m.Return(m.BitcastFloat32ToInt32( + m.LoadFromPointer(&input, MachineType::Float32()))); FOR_FLOAT32_INPUTS(i) { input = *i; int32_t expected = bit_cast(input); @@ -5721,8 +5793,8 @@ TEST(RunBitcastInt32ToFloat32) { float output = 0.0; RawMachineAssemblerTester m; m.StoreToPointer( - &output, kMachFloat32, - m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32))); + &output, MachineType::Float32(), + m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32()))); m.Return(m.Int32Constant(11)); FOR_INT32_INPUTS(i) { input = *i; @@ -5744,7 +5816,7 @@ TEST(RunComputedCodeObject) { b.End(); Handle code_b = b.GetCode(); - RawMachineAssemblerTester r(kMachInt32); + RawMachineAssemblerTester r(MachineType::Int32()); RawMachineLabel tlabel; RawMachineLabel flabel; RawMachineLabel merge; @@ -5756,7 +5828,7 @@ TEST(RunComputedCodeObject) { Node* fb = r.HeapConstant(code_b); r.Goto(&merge); r.Bind(&merge); - Node* phi = r.Phi(kMachInt32, fa, fb); + Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); // TODO(titzer): all this descriptor hackery is just to call the above // functions as code objects instead of direct addresses. @@ -5766,7 +5838,7 @@ TEST(RunComputedCodeObject) { Signature loc(1, 0, ret); CallDescriptor* desc = new (r.zone()) CallDescriptor( // -- CallDescriptor::kCallCodeObject, // kind - kMachAnyTagged, // target_type + MachineType::AnyTagged(), // target_type c->GetInputLocation(0), // target_loc &sig, // machine_sig &loc, // location_sig diff --git a/test/cctest/compiler/test-run-native-calls.cc b/test/cctest/compiler/test-run-native-calls.cc index f1141632d8..d18da92e0b 100644 --- a/test/cctest/compiler/test-run-native-calls.cc +++ b/test/cctest/compiler/test-run-native-calls.cc @@ -133,7 +133,7 @@ struct Allocator { int stack_offset; LinkageLocation Next(MachineType type) { - if (IsFloatingPoint(type)) { + if (IsFloatingPoint(type.representation())) { // Allocate a floating point register/stack location. if (fp_offset < fp_count) { return LinkageLocation::ForRegister(fp_regs[fp_offset++]); @@ -153,16 +153,11 @@ struct Allocator { } } } - bool IsFloatingPoint(MachineType type) { - return RepresentationOf(type) == kRepFloat32 || - RepresentationOf(type) == kRepFloat64; - } int StackWords(MachineType type) { // TODO(titzer): hack. float32 occupies 8 bytes on stack. - int size = (RepresentationOf(type) == kRepFloat32 || - RepresentationOf(type) == kRepFloat64) + int size = IsFloatingPoint(type.representation()) ? kDoubleSize - : ElementSizeOf(type); + : (1 << ElementSizeLog2Of(type.representation())); return size <= kPointerSize ? 1 : size / kPointerSize; } void Reset() { @@ -198,7 +193,7 @@ class RegisterConfig { const RegList kCalleeSaveRegisters = 0; const RegList kCalleeSaveFPRegisters = 0; - MachineType target_type = kMachAnyTagged; + MachineType target_type = MachineType::AnyTagged(); LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); int stack_param_count = params.stack_offset; return new (zone) CallDescriptor( // -- @@ -223,17 +218,28 @@ class RegisterConfig { const int kMaxParamCount = 64; MachineType kIntTypes[kMaxParamCount + 1] = { - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32, - kMachInt32, kMachInt32, kMachInt32, kMachInt32, kMachInt32}; + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()}; // For making uniform int32 signatures shorter. @@ -563,7 +569,8 @@ static void CopyTwentyInt32(CallDescriptor* desc) { Node* base = raw.PointerConstant(output); for (int i = 0; i < kNumParams; i++) { Node* offset = raw.Int32Constant(i * sizeof(int32_t)); - raw.Store(kMachInt32, base, offset, raw.Parameter(i), kNoWriteBarrier); + raw.Store(MachineType::Int32(), base, offset, raw.Parameter(i), + kNoWriteBarrier); } raw.Return(raw.Int32Constant(42)); inner = CompileGraph("CopyTwentyInt32", desc, &graph, raw.Export()); @@ -582,7 +589,7 @@ static void CopyTwentyInt32(CallDescriptor* desc) { Node** args = zone.NewArray(kNumParams); for (int i = 0; i < kNumParams; i++) { Node* offset = raw.Int32Constant(i * sizeof(int32_t)); - args[i] = raw.Load(kMachInt32, base, offset); + args[i] = raw.Load(MachineType::Int32(), base, offset); } Node* call = raw.CallN(desc, target, args); @@ -1016,16 +1023,21 @@ void MixedParamTest(int start) { // TODO(titzer): mix in 64-bit types on all platforms when supported. #if V8_TARGET_ARCH_32_BIT static MachineType types[] = { - kMachInt32, kMachFloat32, kMachFloat64, kMachInt32, kMachFloat64, - kMachFloat32, kMachFloat32, kMachFloat64, kMachInt32, kMachFloat32, - kMachInt32, kMachFloat64, kMachFloat64, kMachFloat32, kMachInt32, - kMachFloat64, kMachInt32, kMachFloat32}; + MachineType::Int32(), MachineType::Float32(), MachineType::Float64(), + MachineType::Int32(), MachineType::Float64(), MachineType::Float32(), + MachineType::Float32(), MachineType::Float64(), MachineType::Int32(), + MachineType::Float32(), MachineType::Int32(), MachineType::Float64(), + MachineType::Float64(), MachineType::Float32(), MachineType::Int32(), + MachineType::Float64(), MachineType::Int32(), MachineType::Float32()}; #else static MachineType types[] = { - kMachInt32, kMachInt64, kMachFloat32, kMachFloat64, kMachInt32, - kMachFloat64, kMachFloat32, kMachInt64, kMachInt64, kMachFloat32, - kMachFloat32, kMachInt32, kMachFloat64, kMachFloat64, kMachInt64, - kMachInt32, kMachFloat64, kMachInt32, kMachFloat32}; + MachineType::Int32(), MachineType::Int64(), MachineType::Float32(), + MachineType::Float64(), MachineType::Int32(), MachineType::Float64(), + MachineType::Float32(), MachineType::Int64(), MachineType::Int64(), + MachineType::Float32(), MachineType::Float32(), MachineType::Int32(), + MachineType::Float64(), MachineType::Float64(), MachineType::Int64(), + MachineType::Int32(), MachineType::Float64(), MachineType::Int32(), + MachineType::Float32()}; #endif Isolate* isolate = CcTest::InitIsolateOnce(); @@ -1094,22 +1106,22 @@ void MixedParamTest(int start) { for (int i = 0; i < num_params; i++) { MachineType param_type = sig->GetParam(i); Node* konst = nullptr; - if (param_type == kMachInt32) { + if (param_type == MachineType::Int32()) { int32_t value[] = {static_cast(constant)}; konst = raw.Int32Constant(value[0]); if (i == which) memcpy(bytes, value, expected_size = 4); } - if (param_type == kMachInt64) { + if (param_type == MachineType::Int64()) { int64_t value[] = {static_cast(constant)}; konst = raw.Int64Constant(value[0]); if (i == which) memcpy(bytes, value, expected_size = 8); } - if (param_type == kMachFloat32) { + if (param_type == MachineType::Float32()) { float32 value[] = {static_cast(constant)}; konst = raw.Float32Constant(value[0]); if (i == which) memcpy(bytes, value, expected_size = 4); } - if (param_type == kMachFloat64) { + if (param_type == MachineType::Float64()) { float64 value[] = {static_cast(constant)}; konst = raw.Float64Constant(value[0]); if (i == which) memcpy(bytes, value, expected_size = 8); diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc index 2cbaed0c35..c5b48615bb 100644 --- a/test/cctest/compiler/test-simplified-lowering.cc +++ b/test/cctest/compiler/test-simplified-lowering.cc @@ -33,8 +33,8 @@ namespace compiler { template class SimplifiedLoweringTester : public GraphBuilderTester { public: - SimplifiedLoweringTester(MachineType p0 = kMachNone, - MachineType p1 = kMachNone) + SimplifiedLoweringTester(MachineType p0 = MachineType::None(), + MachineType p1 = MachineType::None()) : GraphBuilderTester(p0, p1), typer(this->isolate(), this->graph()), javascript(this->zone()), @@ -100,12 +100,12 @@ TEST(RunNumberToInt32_float64) { int32_t result; SimplifiedLoweringTester t; FieldAccess load = {kUntaggedBase, 0, Handle(), Type::Number(), - kMachFloat64}; + MachineType::Float64()}; Node* loaded = t.LoadField(load, t.PointerConstant(&input)); NodeProperties::SetType(loaded, Type::Number()); Node* convert = t.NumberToInt32(loaded); FieldAccess store = {kUntaggedBase, 0, Handle(), Type::Signed32(), - kMachInt32}; + MachineType::Int32()}; t.StoreField(store, t.PointerConstant(&result), convert); t.Return(t.jsgraph.TrueConstant()); t.LowerAllNodesAndLowerChanges(); @@ -127,12 +127,12 @@ TEST(RunNumberToUint32_float64) { uint32_t result; SimplifiedLoweringTester t; FieldAccess load = {kUntaggedBase, 0, Handle(), Type::Number(), - kMachFloat64}; + MachineType::Float64()}; Node* loaded = t.LoadField(load, t.PointerConstant(&input)); NodeProperties::SetType(loaded, Type::Number()); Node* convert = t.NumberToUint32(loaded); FieldAccess store = {kUntaggedBase, 0, Handle(), Type::Unsigned32(), - kMachUint32}; + MachineType::Uint32()}; t.StoreField(store, t.PointerConstant(&result), convert); t.Return(t.jsgraph.TrueConstant()); t.LowerAllNodesAndLowerChanges(); @@ -157,7 +157,7 @@ static Handle TestObject() { TEST(RunLoadMap) { - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); FieldAccess access = AccessBuilder::ForMap(); Node* load = t.LoadField(access, t.Parameter(0)); t.Return(load); @@ -173,7 +173,8 @@ TEST(RunLoadMap) { TEST(RunStoreMap) { - SimplifiedLoweringTester t(kMachAnyTagged, kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged(), + MachineType::AnyTagged()); FieldAccess access = AccessBuilder::ForMap(); t.StoreField(access, t.Parameter(1), t.Parameter(0)); t.Return(t.jsgraph.TrueConstant()); @@ -191,7 +192,7 @@ TEST(RunStoreMap) { TEST(RunLoadProperties) { - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); FieldAccess access = AccessBuilder::ForJSObjectProperties(); Node* load = t.LoadField(access, t.Parameter(0)); t.Return(load); @@ -207,7 +208,8 @@ TEST(RunLoadProperties) { TEST(RunLoadStoreMap) { - SimplifiedLoweringTester t(kMachAnyTagged, kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged(), + MachineType::AnyTagged()); FieldAccess access = AccessBuilder::ForMap(); Node* load = t.LoadField(access, t.Parameter(0)); t.StoreField(access, t.Parameter(1), load); @@ -228,7 +230,7 @@ TEST(RunLoadStoreMap) { TEST(RunLoadStoreFixedArrayIndex) { - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); ElementAccess access = AccessBuilder::ForFixedArrayElement(); Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0)); t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), load); @@ -250,7 +252,7 @@ TEST(RunLoadStoreFixedArrayIndex) { TEST(RunLoadStoreArrayBuffer) { - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); const int index = 12; const int array_length = 2 * index; ElementAccess buffer_access = @@ -290,7 +292,7 @@ TEST(RunLoadFieldFromUntaggedBase) { for (size_t i = 0; i < arraysize(smis); i++) { int offset = static_cast(i * sizeof(Smi*)); FieldAccess access = {kUntaggedBase, offset, Handle(), - Type::Integral32(), kMachAnyTagged}; + Type::Integral32(), MachineType::AnyTagged()}; SimplifiedLoweringTester t; Node* load = t.LoadField(access, t.PointerConstant(smis)); @@ -312,9 +314,9 @@ TEST(RunStoreFieldToUntaggedBase) { for (size_t i = 0; i < arraysize(smis); i++) { int offset = static_cast(i * sizeof(Smi*)); FieldAccess access = {kUntaggedBase, offset, Handle(), - Type::Integral32(), kMachAnyTagged}; + Type::Integral32(), MachineType::AnyTagged()}; - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* p0 = t.Parameter(0); t.StoreField(access, t.PointerConstant(smis), p0); t.Return(p0); @@ -338,7 +340,7 @@ TEST(RunLoadElementFromUntaggedBase) { for (size_t j = 0; (i + j) < arraysize(smis); j++) { // for element index int offset = static_cast(i * sizeof(Smi*)); ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), - kMachAnyTagged}; + MachineType::AnyTagged()}; SimplifiedLoweringTester t; Node* load = t.LoadElement(access, t.PointerConstant(smis), @@ -364,9 +366,9 @@ TEST(RunStoreElementFromUntaggedBase) { for (size_t j = 0; (i + j) < arraysize(smis); j++) { // for element index int offset = static_cast(i * sizeof(Smi*)); ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), - kMachAnyTagged}; + MachineType::AnyTagged()}; - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* p0 = t.Parameter(0); t.StoreElement(access, t.PointerConstant(smis), t.Int32Constant(static_cast(j)), p0); @@ -592,19 +594,19 @@ static void RunAccessTest(MachineType rep, E* original_elements, size_t num) { TEST(RunAccessTests_uint8) { uint8_t data[] = {0x07, 0x16, 0x25, 0x34, 0x43, 0x99, 0xab, 0x78, 0x89, 0x19, 0x2b, 0x38}; - RunAccessTest(kMachInt8, data, arraysize(data)); + RunAccessTest(MachineType::Int8(), data, arraysize(data)); } TEST(RunAccessTests_uint16) { uint16_t data[] = {0x071a, 0x162b, 0x253c, 0x344d, 0x435e, 0x7777}; - RunAccessTest(kMachInt16, data, arraysize(data)); + RunAccessTest(MachineType::Int16(), data, arraysize(data)); } TEST(RunAccessTests_int32) { int32_t data[] = {-211, 211, 628347, 2000000000, -2000000000, -1, -100000034}; - RunAccessTest(kMachInt32, data, arraysize(data)); + RunAccessTest(MachineType::Int32(), data, arraysize(data)); } @@ -618,13 +620,13 @@ TEST(RunAccessTests_int64) { V8_2PART_INT64(0x30313233, 34353637), V8_2PART_INT64(0xa0a1a2a3, a4a5a6a7), V8_2PART_INT64(0xf0f1f2f3, f4f5f6f7)}; - RunAccessTest(kMachInt64, data, arraysize(data)); + RunAccessTest(MachineType::Int64(), data, arraysize(data)); } TEST(RunAccessTests_float64) { double data[] = {1.25, -1.25, 2.75, 11.0, 11100.8}; - RunAccessTest(kMachFloat64, data, arraysize(data)); + RunAccessTest(MachineType::Float64(), data, arraysize(data)); } @@ -632,7 +634,7 @@ TEST(RunAccessTests_Smi) { Smi* data[] = {Smi::FromInt(-1), Smi::FromInt(-9), Smi::FromInt(0), Smi::FromInt(666), Smi::FromInt(77777), Smi::FromInt(Smi::kMaxValue)}; - RunAccessTest(kMachAnyTagged, data, arraysize(data)); + RunAccessTest(MachineType::AnyTagged(), data, arraysize(data)); } @@ -741,44 +743,43 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { void Effect(Node* node) { ret->ReplaceInput(1, node); } Node* ExampleWithOutput(MachineType type) { - // TODO(titzer): use parameters with guaranteed representations. - if (type & kTypeInt32) { + if (type.semantic() == MachineSemantic::kInt32) { return graph()->NewNode(machine()->Int32Add(), jsgraph.Int32Constant(1), jsgraph.Int32Constant(1)); - } else if (type & kTypeUint32) { + } else if (type.semantic() == MachineSemantic::kUint32) { return graph()->NewNode(machine()->Word32Shr(), jsgraph.Int32Constant(1), jsgraph.Int32Constant(1)); - } else if (type & kRepFloat64) { + } else if (type.representation() == MachineRepresentation::kFloat64) { return graph()->NewNode(machine()->Float64Add(), jsgraph.Float64Constant(1), jsgraph.Float64Constant(1)); - } else if (type & kRepBit) { + } else if (type.representation() == MachineRepresentation::kBit) { return graph()->NewNode(machine()->Word32Equal(), jsgraph.Int32Constant(1), jsgraph.Int32Constant(1)); - } else if (type & kRepWord64) { + } else if (type.representation() == MachineRepresentation::kWord64) { return graph()->NewNode(machine()->Int64Add(), Int64Constant(1), Int64Constant(1)); } else { - CHECK(type & kRepTagged); + CHECK(type.representation() == MachineRepresentation::kTagged); return p0; } } Node* Use(Node* node, MachineType type) { - if (type & kTypeInt32) { + if (type.semantic() == MachineSemantic::kInt32) { return graph()->NewNode(machine()->Int32LessThan(), node, jsgraph.Int32Constant(1)); - } else if (type & kTypeUint32) { + } else if (type.semantic() == MachineSemantic::kUint32) { return graph()->NewNode(machine()->Uint32LessThan(), node, jsgraph.Int32Constant(1)); - } else if (type & kRepFloat64) { + } else if (type.representation() == MachineRepresentation::kFloat64) { return graph()->NewNode(machine()->Float64Add(), node, jsgraph.Float64Constant(1)); - } else if (type & kRepWord64) { + } else if (type.representation() == MachineRepresentation::kWord64) { return graph()->NewNode(machine()->Int64LessThan(), node, Int64Constant(1)); - } else if (type & kRepWord32) { + } else if (type.representation() == MachineRepresentation::kWord32) { return graph()->NewNode(machine()->Word32Equal(), node, jsgraph.Int32Constant(1)); } else { @@ -810,7 +811,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { TEST(LowerBooleanNot_bit_bit) { // BooleanNot(x: kRepBit) used as kRepBit TestingGraph t(Type::Boolean()); - Node* b = t.ExampleWithOutput(kRepBit); + Node* b = t.ExampleWithOutput(MachineType::Bool()); Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); Node* use = t.Branch(inv); t.Lower(); @@ -825,9 +826,9 @@ TEST(LowerBooleanNot_bit_bit) { TEST(LowerBooleanNot_bit_tagged) { // BooleanNot(x: kRepBit) used as kRepTagged TestingGraph t(Type::Boolean()); - Node* b = t.ExampleWithOutput(kRepBit); + Node* b = t.ExampleWithOutput(MachineType::Bool()); Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); - Node* use = t.Use(inv, kRepTagged); + Node* use = t.Use(inv, MachineType::AnyTagged()); t.Return(use); t.Lower(); CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); @@ -859,7 +860,7 @@ TEST(LowerBooleanNot_tagged_tagged) { TestingGraph t(Type::Boolean()); Node* b = t.p0; Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); - Node* use = t.Use(inv, kRepTagged); + Node* use = t.Use(inv, MachineType::AnyTagged()); t.Return(use); t.Lower(); CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); @@ -872,11 +873,11 @@ TEST(LowerBooleanNot_tagged_tagged) { TEST(LowerBooleanToNumber_bit_int32) { - // BooleanToNumber(x: kRepBit) used as kMachInt32 + // BooleanToNumber(x: kRepBit) used as MachineType::Int32() TestingGraph t(Type::Boolean()); - Node* b = t.ExampleWithOutput(kRepBit); + Node* b = t.ExampleWithOutput(MachineType::Bool()); Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); - Node* use = t.Use(cnv, kMachInt32); + Node* use = t.Use(cnv, MachineType::Int32()); t.Return(use); t.Lower(); CHECK_EQ(b, use->InputAt(0)); @@ -884,11 +885,11 @@ TEST(LowerBooleanToNumber_bit_int32) { TEST(LowerBooleanToNumber_tagged_int32) { - // BooleanToNumber(x: kRepTagged) used as kMachInt32 + // BooleanToNumber(x: kRepTagged) used as MachineType::Int32() TestingGraph t(Type::Boolean()); Node* b = t.p0; Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); - Node* use = t.Use(cnv, kMachInt32); + Node* use = t.Use(cnv, MachineType::Int32()); t.Return(use); t.Lower(); CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); @@ -899,11 +900,11 @@ TEST(LowerBooleanToNumber_tagged_int32) { TEST(LowerBooleanToNumber_bit_tagged) { - // BooleanToNumber(x: kRepBit) used as kMachAnyTagged + // BooleanToNumber(x: kRepBit) used as MachineType::AnyTagged() TestingGraph t(Type::Boolean()); - Node* b = t.ExampleWithOutput(kRepBit); + Node* b = t.ExampleWithOutput(MachineType::Bool()); Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); - Node* use = t.Use(cnv, kMachAnyTagged); + Node* use = t.Use(cnv, MachineType::AnyTagged()); t.Return(use); t.Lower(); CHECK_EQ(b, use->InputAt(0)->InputAt(0)); @@ -912,11 +913,11 @@ TEST(LowerBooleanToNumber_bit_tagged) { TEST(LowerBooleanToNumber_tagged_tagged) { - // BooleanToNumber(x: kRepTagged) used as kMachAnyTagged + // BooleanToNumber(x: kRepTagged) used as MachineType::AnyTagged() TestingGraph t(Type::Boolean()); Node* b = t.p0; Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); - Node* use = t.Use(cnv, kMachAnyTagged); + Node* use = t.Use(cnv, MachineType::AnyTagged()); t.Return(use); t.Lower(); CHECK_EQ(cnv, use->InputAt(0)->InputAt(0)); @@ -1046,7 +1047,7 @@ TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) { // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepWord32 TestingGraph t(Type::Signed32()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); - Node* use = t.Use(trunc, kTypeInt32); + Node* use = t.Use(trunc, MachineType::Int32()); t.Return(use); t.Lower(); CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p0, use->InputAt(0)); @@ -1054,11 +1055,11 @@ TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) { TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32) { - // NumberToInt32(x: kRepFloat64) used as kMachInt32 + // NumberToInt32(x: kRepFloat64) used as MachineType::Int32() TestingGraph t(Type::Number()); - Node* p0 = t.ExampleWithOutput(kMachFloat64); + Node* p0 = t.ExampleWithOutput(MachineType::Float64()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), p0); - Node* use = t.Use(trunc, kMachInt32); + Node* use = t.Use(trunc, MachineType::Int32()); t.Return(use); t.Lower(); CheckChangeOf(IrOpcode::kTruncateFloat64ToInt32, p0, use->InputAt(0)); @@ -1066,10 +1067,10 @@ TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32) { TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32_with_change) { - // NumberToInt32(x: kTypeNumber | kRepTagged) used as kMachInt32 + // NumberToInt32(x: kTypeNumber | kRepTagged) used as MachineType::Int32() TestingGraph t(Type::Number()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); - Node* use = t.Use(trunc, kMachInt32); + Node* use = t.Use(trunc, MachineType::Int32()); t.Return(use); t.Lower(); Node* node = use->InputAt(0); @@ -1084,7 +1085,7 @@ TEST(LowerNumberToUint32_to_ChangeTaggedToUint32) { // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32 TestingGraph t(Type::Unsigned32()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); - Node* use = t.Use(trunc, kTypeUint32); + Node* use = t.Use(trunc, MachineType::Uint32()); t.Return(use); t.Lower(); CheckChangeOf(IrOpcode::kChangeTaggedToUint32, t.p0, use->InputAt(0)); @@ -1092,13 +1093,13 @@ TEST(LowerNumberToUint32_to_ChangeTaggedToUint32) { TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32) { - // NumberToUint32(x: kRepFloat64) used as kMachUint32 + // NumberToUint32(x: kRepFloat64) used as MachineType::Uint32() TestingGraph t(Type::Number()); - Node* p0 = t.ExampleWithOutput(kMachFloat64); + Node* p0 = t.ExampleWithOutput(MachineType::Float64()); // TODO(titzer): run the typer here, or attach machine type to param. NodeProperties::SetType(p0, Type::Number()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), p0); - Node* use = t.Use(trunc, kMachUint32); + Node* use = t.Use(trunc, MachineType::Uint32()); t.Return(use); t.Lower(); CheckChangeOf(IrOpcode::kTruncateFloat64ToInt32, p0, use->InputAt(0)); @@ -1106,10 +1107,10 @@ TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32) { TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32_with_change) { - // NumberToInt32(x: kTypeNumber | kRepTagged) used as kMachUint32 + // NumberToInt32(x: kTypeNumber | kRepTagged) used as MachineType::Uint32() TestingGraph t(Type::Number()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); - Node* use = t.Use(trunc, kMachUint32); + Node* use = t.Use(trunc, MachineType::Uint32()); t.Return(use); t.Lower(); Node* node = use->InputAt(0); @@ -1123,9 +1124,9 @@ TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32_with_change) { TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32_uint32) { // NumberToUint32(x: kRepFloat64) used as kRepWord32 TestingGraph t(Type::Unsigned32()); - Node* input = t.ExampleWithOutput(kMachFloat64); + Node* input = t.ExampleWithOutput(MachineType::Float64()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), input); - Node* use = t.Use(trunc, kRepWord32); + Node* use = t.Use(trunc, MachineType::RepWord32()); t.Return(use); t.Lower(); CheckChangeOf(IrOpcode::kTruncateFloat64ToInt32, input, use->InputAt(0)); @@ -1170,30 +1171,33 @@ TEST(LowerStringOps_to_call_and_compare) { TEST(InsertBasicChanges) { - CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, kRepFloat64, kTypeInt32, - Type::Signed32()); - CheckChangeInsertion(IrOpcode::kChangeFloat64ToUint32, kRepFloat64, - kTypeUint32, Type::Unsigned32()); - CheckChangeInsertion(IrOpcode::kTruncateFloat64ToInt32, kRepFloat64, - kTypeUint32, Type::Integral32()); - CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, kRepTagged, kTypeInt32, - Type::Signed32()); - CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, kRepTagged, kTypeUint32, + CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, MachineType::Float64(), + MachineType::Int32(), Type::Signed32()); + CheckChangeInsertion(IrOpcode::kChangeFloat64ToUint32, MachineType::Float64(), + MachineType::Uint32(), Type::Unsigned32()); + CheckChangeInsertion(IrOpcode::kTruncateFloat64ToInt32, + MachineType::Float64(), MachineType::Uint32(), + Type::Integral32()); + CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, MachineType::AnyTagged(), + MachineType::Int32(), Type::Signed32()); + CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, + MachineType::AnyTagged(), MachineType::Uint32(), Type::Unsigned32()); - CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, kRepFloat64, - kRepTagged); - CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, kRepTagged, - kRepFloat64); + CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, MachineType::Float64(), + MachineType::AnyTagged()); + CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, + MachineType::AnyTagged(), MachineType::Float64()); - CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, kTypeInt32, - kRepFloat64); - CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, kTypeInt32, kRepTagged); + CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, MachineType::Int32(), + MachineType::Float64()); + CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, MachineType::Int32(), + MachineType::AnyTagged()); - CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, kTypeUint32, - kRepFloat64); - CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, kTypeUint32, - kRepTagged); + CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, MachineType::Uint32(), + MachineType::Float64()); + CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, MachineType::Uint32(), + MachineType::AnyTagged()); } @@ -1306,7 +1310,8 @@ Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) { CHECK_EQ(IrOpcode::kInt32Add, mindex.node()->opcode()); CHECK(mindex.right().Is(access.header_size - access.tag())); - const int element_size_shift = ElementSizeLog2Of(access.machine_type); + const int element_size_shift = + ElementSizeLog2Of(access.machine_type.representation()); if (element_size_shift) { Int32BinopMatcher shl(mindex.left().node()); CHECK_EQ(IrOpcode::kWord32Shl, shl.node()->opcode()); @@ -1318,9 +1323,10 @@ Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) { } -const MachineType kMachineReps[] = {kMachInt8, kMachInt16, kMachInt32, - kMachUint32, kMachInt64, kMachFloat64, - kMachAnyTagged}; +const MachineType kMachineReps[] = { + MachineType::Int8(), MachineType::Int16(), MachineType::Int32(), + MachineType::Uint32(), MachineType::Int64(), MachineType::Float64(), + MachineType::AnyTagged()}; } // namespace @@ -1341,7 +1347,7 @@ TEST(LowerLoadField_to_load) { CHECK_EQ(t.p0, load->InputAt(0)); CheckFieldAccessArithmetic(access, load); - MachineType rep = OpParameter(load); + MachineType rep = LoadRepresentationOf(load->op()); CHECK_EQ(kMachineReps[i], rep); } } @@ -1366,7 +1372,7 @@ TEST(LowerStoreField_to_store) { CheckFieldAccessArithmetic(access, store); StoreRepresentation rep = OpParameter(store); - if (kMachineReps[i] & kRepTagged) { + if (kMachineReps[i].representation() == MachineRepresentation::kTagged) { CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind()); } CHECK_EQ(kMachineReps[i], rep.machine_type()); @@ -1378,7 +1384,8 @@ TEST(LowerStoreField_to_store) { TestingGraph t(Type::Any(), Type::Intersect(Type::SignedSmall(), Type::TaggedSigned(), z)); FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Handle::null(), Type::Any(), kMachAnyTagged}; + Handle::null(), Type::Any(), + MachineType::AnyTagged()}; Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, t.p1, t.start, t.start); t.Effect(store); @@ -1407,7 +1414,7 @@ TEST(LowerLoadElement_to_load) { CHECK_EQ(t.p0, load->InputAt(0)); CheckElementAccessArithmetic(access, load); - MachineType rep = OpParameter(load); + MachineType rep = LoadRepresentationOf(load->op()); CHECK_EQ(kMachineReps[i], rep); } } @@ -1431,7 +1438,7 @@ TEST(LowerStoreElement_to_store) { CheckElementAccessArithmetic(access, store); StoreRepresentation rep = OpParameter(store); - if (kMachineReps[i] & kRepTagged) { + if (kMachineReps[i].representation() == MachineRepresentation::kTagged) { CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind()); } CHECK_EQ(kMachineReps[i], rep.machine_type()); @@ -1444,7 +1451,7 @@ TEST(LowerStoreElement_to_store) { Type::Any(), Type::Signed32(), Type::Intersect(Type::SignedSmall(), Type::TaggedSigned(), z)); ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Type::Any(), kMachAnyTagged}; + Type::Any(), MachineType::AnyTagged()}; Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, t.p1, t.p2, t.start, t.start); t.Effect(store); @@ -1462,7 +1469,7 @@ TEST(InsertChangeForLoadElementIndex) { // Load(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k)) TestingGraph t(Type::Any(), Type::Signed32()); ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachAnyTagged}; + MachineType::AnyTagged()}; Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, t.p1, t.start, t.start); @@ -1479,7 +1486,7 @@ TEST(InsertChangeForStoreElementIndex) { // Store(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k), val) TestingGraph t(Type::Any(), Type::Signed32()); ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachAnyTagged}; + MachineType::AnyTagged()}; Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, t.p1, @@ -1496,7 +1503,7 @@ TEST(InsertChangeForLoadElement) { // TODO(titzer): test all load/store representation change insertions. TestingGraph t(Type::Any(), Type::Signed32(), Type::Any()); ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachFloat64}; + MachineType::Float64()}; Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, t.p1, t.start, t.start); @@ -1512,7 +1519,8 @@ TEST(InsertChangeForLoadField) { // TODO(titzer): test all load/store representation change insertions. TestingGraph t(Type::Any(), Type::Signed32()); FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Handle::null(), Type::Any(), kMachFloat64}; + Handle::null(), Type::Any(), + MachineType::Float64()}; Node* load = t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start, t.start); @@ -1528,7 +1536,7 @@ TEST(InsertChangeForStoreElement) { // TODO(titzer): test all load/store representation change insertions. TestingGraph t(Type::Any(), Type::Signed32()); ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachFloat64}; + MachineType::Float64()}; Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, @@ -1546,7 +1554,8 @@ TEST(InsertChangeForStoreField) { // TODO(titzer): test all load/store representation change insertions. TestingGraph t(Type::Any(), Type::Signed32()); FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Handle::null(), Type::Any(), kMachFloat64}; + Handle::null(), Type::Any(), + MachineType::Float64()}; Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, t.p1, t.start, t.start); @@ -1561,8 +1570,8 @@ TEST(InsertChangeForStoreField) { TEST(UpdatePhi) { TestingGraph t(Type::Any(), Type::Signed32()); - static const MachineType kMachineTypes[] = {kMachInt32, kMachUint32, - kMachFloat64}; + static const MachineType kMachineTypes[] = { + MachineType::Int32(), MachineType::Uint32(), MachineType::Float64()}; Type* kTypes[] = {Type::Signed32(), Type::Unsigned32(), Type::Number()}; for (size_t i = 0; i < arraysize(kMachineTypes); i++) { @@ -1573,20 +1582,20 @@ TEST(UpdatePhi) { t.start, t.start); Node* load1 = t.graph()->NewNode(t.simplified()->LoadField(access), t.p1, t.start, t.start); - Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0, - load1, t.start); + Node* phi = + t.graph()->NewNode(t.common()->Phi(MachineRepresentation::kTagged, 2), + load0, load1, t.start); t.Return(t.Use(phi, kMachineTypes[i])); t.Lower(); CHECK_EQ(IrOpcode::kPhi, phi->opcode()); - CHECK_EQ(RepresentationOf(kMachineTypes[i]), - RepresentationOf(OpParameter(phi))); + CHECK_EQ(kMachineTypes[i].representation(), PhiRepresentationOf(phi->op())); } } TEST(RunNumberDivide_minus_1_TruncatingToInt32) { - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* num = t.NumberToInt32(t.Parameter(0)); Node* div = t.NumberDivide(num, t.jsgraph.Constant(-1)); Node* trunc = t.NumberToInt32(div); @@ -1607,7 +1616,7 @@ TEST(RunNumberMultiply_TruncatingToInt32) { for (size_t i = 0; i < arraysize(constants); i++) { double k = static_cast(constants[i]); - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* num = t.NumberToInt32(t.Parameter(0)); Node* mul = t.NumberMultiply(num, t.jsgraph.Constant(k)); Node* trunc = t.NumberToInt32(mul); @@ -1629,7 +1638,7 @@ TEST(RunNumberMultiply_TruncatingToUint32) { for (size_t i = 0; i < arraysize(constants); i++) { double k = static_cast(constants[i]); - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* num = t.NumberToUint32(t.Parameter(0)); Node* mul = t.NumberMultiply(num, t.jsgraph.Constant(k)); Node* trunc = t.NumberToUint32(mul); @@ -1647,7 +1656,7 @@ TEST(RunNumberMultiply_TruncatingToUint32) { TEST(RunNumberDivide_2_TruncatingToUint32) { - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* num = t.NumberToUint32(t.Parameter(0)); Node* div = t.NumberDivide(num, t.jsgraph.Constant(2)); Node* trunc = t.NumberToUint32(div); @@ -1693,7 +1702,7 @@ TEST(NumberDivide_TruncatingToInt32) { TestingGraph t(Type::Signed32()); Node* k = t.jsgraph.Constant(constants[i]); Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k); - Node* use = t.Use(div, kMachInt32); + Node* use = t.Use(div, MachineType::Int32()); t.Return(use); t.Lower(); @@ -1707,7 +1716,7 @@ TEST(RunNumberDivide_TruncatingToInt32) { for (size_t i = 0; i < arraysize(constants); i++) { int32_t k = constants[i]; - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* num = t.NumberToInt32(t.Parameter(0)); Node* div = t.NumberDivide(num, t.jsgraph.Constant(k)); Node* trunc = t.NumberToInt32(div); @@ -1732,7 +1741,7 @@ TEST(NumberDivide_TruncatingToUint32) { TestingGraph t(Type::Unsigned32()); Node* k = t.jsgraph.Constant(constants[i]); Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k); - Node* use = t.Use(div, kMachUint32); + Node* use = t.Use(div, MachineType::Uint32()); t.Return(use); t.Lower(); @@ -1746,7 +1755,7 @@ TEST(RunNumberDivide_TruncatingToUint32) { for (size_t i = 0; i < arraysize(constants); i++) { uint32_t k = constants[i]; - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* num = t.NumberToUint32(t.Parameter(0)); Node* div = t.NumberDivide(num, t.jsgraph.Constant(static_cast(k))); Node* trunc = t.NumberToUint32(div); @@ -1768,7 +1777,7 @@ TEST(NumberDivide_BadConstants) { TestingGraph t(Type::Signed32()); Node* k = t.jsgraph.Constant(-1); Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k); - Node* use = t.Use(div, kMachInt32); + Node* use = t.Use(div, MachineType::Int32()); t.Return(use); t.Lower(); @@ -1779,7 +1788,7 @@ TEST(NumberDivide_BadConstants) { TestingGraph t(Type::Signed32()); Node* k = t.jsgraph.Constant(0); Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k); - Node* use = t.Use(div, kMachInt32); + Node* use = t.Use(div, MachineType::Int32()); t.Return(use); t.Lower(); @@ -1791,7 +1800,7 @@ TEST(NumberDivide_BadConstants) { TestingGraph t(Type::Unsigned32()); Node* k = t.jsgraph.Constant(0); Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k); - Node* use = t.Use(div, kMachUint32); + Node* use = t.Use(div, MachineType::Uint32()); t.Return(use); t.Lower(); @@ -1808,7 +1817,7 @@ TEST(NumberModulus_TruncatingToInt32) { TestingGraph t(Type::Signed32()); Node* k = t.jsgraph.Constant(constants[i]); Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k); - Node* use = t.Use(mod, kMachInt32); + Node* use = t.Use(mod, MachineType::Int32()); t.Return(use); t.Lower(); @@ -1822,7 +1831,7 @@ TEST(RunNumberModulus_TruncatingToInt32) { for (size_t i = 0; i < arraysize(constants); i++) { int32_t k = constants[i]; - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* num = t.NumberToInt32(t.Parameter(0)); Node* mod = t.NumberModulus(num, t.jsgraph.Constant(k)); Node* trunc = t.NumberToInt32(mod); @@ -1861,7 +1870,7 @@ TEST(RunNumberModulus_TruncatingToUint32) { for (size_t i = 0; i < arraysize(constants); i++) { uint32_t k = constants[i]; - SimplifiedLoweringTester t(kMachAnyTagged); + SimplifiedLoweringTester t(MachineType::AnyTagged()); Node* num = t.NumberToUint32(t.Parameter(0)); Node* mod = t.NumberModulus(num, t.jsgraph.Constant(static_cast(k))); @@ -1896,7 +1905,7 @@ TEST(NumberModulus_Int32) { TEST(NumberModulus_Uint32) { const double kConstants[] = {2, 100, 1000, 1024, 2048}; - const MachineType kTypes[] = {kMachInt32, kMachUint32}; + const MachineType kTypes[] = {MachineType::Int32(), MachineType::Uint32()}; for (auto const type : kTypes) { for (auto const c : kConstants) { @@ -1921,17 +1930,20 @@ TEST(PhiRepresentation) { Type* arg1; Type* arg2; MachineType use; - MachineTypeUnion expected; + MachineRepresentation expected; }; TestData test_data[] = { - {Type::Signed32(), Type::Unsigned32(), kMachInt32, - kRepWord32 | kTypeNumber}, - {Type::Signed32(), Type::Unsigned32(), kMachUint32, - kRepWord32 | kTypeNumber}, - {Type::Signed32(), Type::Signed32(), kMachInt32, kMachInt32}, - {Type::Unsigned32(), Type::Unsigned32(), kMachInt32, kMachUint32}, - {Type::Number(), Type::Signed32(), kMachInt32, kRepWord32 | kTypeNumber}}; + {Type::Signed32(), Type::Unsigned32(), MachineType::Int32(), + MachineRepresentation::kWord32}, + {Type::Signed32(), Type::Unsigned32(), MachineType::Uint32(), + MachineRepresentation::kWord32}, + {Type::Signed32(), Type::Signed32(), MachineType::Int32(), + MachineRepresentation::kWord32}, + {Type::Unsigned32(), Type::Unsigned32(), MachineType::Int32(), + MachineRepresentation::kWord32}, + {Type::Number(), Type::Signed32(), MachineType::Int32(), + MachineRepresentation::kWord32}}; for (auto const d : test_data) { TestingGraph t(d.arg1, d.arg2, Type::Boolean()); @@ -1941,8 +1953,8 @@ TEST(PhiRepresentation) { Node* fb = t.graph()->NewNode(t.common()->IfFalse(), br); Node* m = t.graph()->NewNode(t.common()->Merge(2), tb, fb); - Node* phi = - t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), t.p0, t.p1, m); + Node* phi = t.graph()->NewNode( + t.common()->Phi(MachineRepresentation::kTagged, 2), t.p0, t.p1, m); Type* phi_type = Type::Union(d.arg1, d.arg2, z); NodeProperties::SetType(phi, phi_type); @@ -1951,7 +1963,7 @@ TEST(PhiRepresentation) { t.Return(use); t.Lower(); - CHECK_EQ(d.expected, OpParameter(phi)); + CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); } } diff --git a/test/unittests/compiler/arm/instruction-selector-arm-unittest.cc b/test/unittests/compiler/arm/instruction-selector-arm-unittest.cc index d07743919d..162d82875d 100644 --- a/test/unittests/compiler/arm/instruction-selector-arm-unittest.cc +++ b/test/unittests/compiler/arm/instruction-selector-arm-unittest.cc @@ -52,16 +52,22 @@ std::ostream& operator<<(std::ostream& os, const FAI& fai) { } -const FAI kFAIs[] = { - {&RawMachineAssembler::Float32Add, "Float32Add", kMachFloat32, kArmVaddF32}, - {&RawMachineAssembler::Float64Add, "Float64Add", kMachFloat64, kArmVaddF64}, - {&RawMachineAssembler::Float32Sub, "Float32Sub", kMachFloat32, kArmVsubF32}, - {&RawMachineAssembler::Float64Sub, "Float64Sub", kMachFloat64, kArmVsubF64}, - {&RawMachineAssembler::Float32Mul, "Float32Mul", kMachFloat32, kArmVmulF32}, - {&RawMachineAssembler::Float64Mul, "Float64Mul", kMachFloat64, kArmVmulF64}, - {&RawMachineAssembler::Float32Div, "Float32Div", kMachFloat32, kArmVdivF32}, - {&RawMachineAssembler::Float64Div, "Float64Div", kMachFloat64, - kArmVdivF64}}; +const FAI kFAIs[] = {{&RawMachineAssembler::Float32Add, "Float32Add", + MachineType::Float32(), kArmVaddF32}, + {&RawMachineAssembler::Float64Add, "Float64Add", + MachineType::Float64(), kArmVaddF64}, + {&RawMachineAssembler::Float32Sub, "Float32Sub", + MachineType::Float32(), kArmVsubF32}, + {&RawMachineAssembler::Float64Sub, "Float64Sub", + MachineType::Float64(), kArmVsubF64}, + {&RawMachineAssembler::Float32Mul, "Float32Mul", + MachineType::Float32(), kArmVmulF32}, + {&RawMachineAssembler::Float64Mul, "Float64Mul", + MachineType::Float64(), kArmVmulF64}, + {&RawMachineAssembler::Float32Div, "Float32Div", + MachineType::Float32(), kArmVdivF32}, + {&RawMachineAssembler::Float64Div, "Float64Div", + MachineType::Float64(), kArmVdivF64}}; // Data processing instructions with overflow. @@ -141,7 +147,8 @@ typedef InstructionSelectorTestWithParam InstructionSelectorDPITest; TEST_P(InstructionSelectorDPITest, Parameters) { const DPI dpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -155,7 +162,7 @@ TEST_P(InstructionSelectorDPITest, Parameters) { TEST_P(InstructionSelectorDPITest, Immediate) { const DPI dpi = GetParam(); TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -166,7 +173,7 @@ TEST_P(InstructionSelectorDPITest, Immediate) { EXPECT_EQ(1U, s[0]->OutputCount()); } TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -182,7 +189,8 @@ TEST_P(InstructionSelectorDPITest, Immediate) { TEST_P(InstructionSelectorDPITest, ShiftByParameter) { const DPI dpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return((m.*dpi.constructor)( m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); @@ -194,7 +202,8 @@ TEST_P(InstructionSelectorDPITest, ShiftByParameter) { EXPECT_EQ(1U, s[0]->OutputCount()); } TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return((m.*dpi.constructor)( (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); @@ -212,7 +221,8 @@ TEST_P(InstructionSelectorDPITest, ShiftByImmediate) { const DPI dpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return((m.*dpi.constructor)( m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); @@ -227,7 +237,8 @@ TEST_P(InstructionSelectorDPITest, ShiftByImmediate) { } TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return((m.*dpi.constructor)( (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), m.Parameter(1))); @@ -245,7 +256,8 @@ TEST_P(InstructionSelectorDPITest, ShiftByImmediate) { TEST_P(InstructionSelectorDPITest, BranchWithParameters) { const DPI dpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); RawMachineLabel a, b; m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), &a, &b); m.Bind(&a); @@ -264,7 +276,7 @@ TEST_P(InstructionSelectorDPITest, BranchWithParameters) { TEST_P(InstructionSelectorDPITest, BranchWithImmediate) { const DPI dpi = GetParam(); TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), &a, &b); @@ -280,7 +292,7 @@ TEST_P(InstructionSelectorDPITest, BranchWithImmediate) { EXPECT_EQ(kNotEqual, s[0]->flags_condition()); } TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), &a, &b); @@ -301,7 +313,8 @@ TEST_P(InstructionSelectorDPITest, BranchWithImmediate) { TEST_P(InstructionSelectorDPITest, BranchWithShiftByParameter) { const DPI dpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch((m.*dpi.constructor)( m.Parameter(0), @@ -319,7 +332,8 @@ TEST_P(InstructionSelectorDPITest, BranchWithShiftByParameter) { EXPECT_EQ(kNotEqual, s[0]->flags_condition()); } TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch((m.*dpi.constructor)( (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), @@ -343,7 +357,8 @@ TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) { const DPI dpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); RawMachineLabel a, b; m.Branch((m.*dpi.constructor)(m.Parameter(0), (m.*shift.constructor)( @@ -365,7 +380,8 @@ TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) { } TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); RawMachineLabel a, b; m.Branch((m.*dpi.constructor)( (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), @@ -390,7 +406,8 @@ TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) { TEST_P(InstructionSelectorDPITest, BranchIfZeroWithParameters) { const DPI dpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Word32Equal((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), m.Int32Constant(0)), @@ -410,7 +427,8 @@ TEST_P(InstructionSelectorDPITest, BranchIfZeroWithParameters) { TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithParameters) { const DPI dpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); RawMachineLabel a, b; m.Branch( m.Word32NotEqual((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), @@ -432,7 +450,7 @@ TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithParameters) { TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) { const DPI dpi = GetParam(); TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Word32Equal( (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), @@ -450,7 +468,7 @@ TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) { EXPECT_EQ(kEqual, s[0]->flags_condition()); } TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Word32Equal( (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), @@ -473,7 +491,7 @@ TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) { TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithImmediate) { const DPI dpi = GetParam(); TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Word32NotEqual( (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), @@ -491,7 +509,7 @@ TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithImmediate) { EXPECT_EQ(kNotEqual, s[0]->flags_condition()); } TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Word32NotEqual( (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), @@ -524,7 +542,8 @@ typedef InstructionSelectorTestWithParam InstructionSelectorODPITest; TEST_P(InstructionSelectorODPITest, OvfWithParameters) { const ODPI odpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Projection(1, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); Stream s = m.Build(); @@ -541,7 +560,7 @@ TEST_P(InstructionSelectorODPITest, OvfWithParameters) { TEST_P(InstructionSelectorODPITest, OvfWithImmediate) { const ODPI odpi = GetParam(); TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 1, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); Stream s = m.Build(); @@ -555,7 +574,7 @@ TEST_P(InstructionSelectorODPITest, OvfWithImmediate) { EXPECT_EQ(kOverflow, s[0]->flags_condition()); } TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 1, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); Stream s = m.Build(); @@ -574,7 +593,8 @@ TEST_P(InstructionSelectorODPITest, OvfWithImmediate) { TEST_P(InstructionSelectorODPITest, OvfWithShiftByParameter) { const ODPI odpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 1, (m.*odpi.constructor)( m.Parameter(0), @@ -589,7 +609,8 @@ TEST_P(InstructionSelectorODPITest, OvfWithShiftByParameter) { EXPECT_EQ(kOverflow, s[0]->flags_condition()); } TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 1, (m.*odpi.constructor)( (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), @@ -610,7 +631,8 @@ TEST_P(InstructionSelectorODPITest, OvfWithShiftByImmediate) { const ODPI odpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Projection( 1, (m.*odpi.constructor)(m.Parameter(0), (m.*shift.constructor)( @@ -628,7 +650,8 @@ TEST_P(InstructionSelectorODPITest, OvfWithShiftByImmediate) { } TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Projection( 1, (m.*odpi.constructor)( (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), @@ -649,7 +672,8 @@ TEST_P(InstructionSelectorODPITest, OvfWithShiftByImmediate) { TEST_P(InstructionSelectorODPITest, ValWithParameters) { const ODPI odpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Projection(0, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); Stream s = m.Build(); @@ -665,7 +689,7 @@ TEST_P(InstructionSelectorODPITest, ValWithParameters) { TEST_P(InstructionSelectorODPITest, ValWithImmediate) { const ODPI odpi = GetParam(); TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 0, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); Stream s = m.Build(); @@ -678,7 +702,7 @@ TEST_P(InstructionSelectorODPITest, ValWithImmediate) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 0, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); Stream s = m.Build(); @@ -696,7 +720,8 @@ TEST_P(InstructionSelectorODPITest, ValWithImmediate) { TEST_P(InstructionSelectorODPITest, ValWithShiftByParameter) { const ODPI odpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 0, (m.*odpi.constructor)( m.Parameter(0), @@ -710,7 +735,8 @@ TEST_P(InstructionSelectorODPITest, ValWithShiftByParameter) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 0, (m.*odpi.constructor)( (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), @@ -730,7 +756,8 @@ TEST_P(InstructionSelectorODPITest, ValWithShiftByImmediate) { const ODPI odpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Projection( 0, (m.*odpi.constructor)(m.Parameter(0), (m.*shift.constructor)( @@ -747,7 +774,8 @@ TEST_P(InstructionSelectorODPITest, ValWithShiftByImmediate) { } TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Projection( 0, (m.*odpi.constructor)( (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), @@ -767,7 +795,8 @@ TEST_P(InstructionSelectorODPITest, ValWithShiftByImmediate) { TEST_P(InstructionSelectorODPITest, BothWithParameters) { const ODPI odpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); Stream s = m.Build(); @@ -784,7 +813,7 @@ TEST_P(InstructionSelectorODPITest, BothWithParameters) { TEST_P(InstructionSelectorODPITest, BothWithImmediate) { const ODPI odpi = GetParam(); TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); Stream s = m.Build(); @@ -798,7 +827,7 @@ TEST_P(InstructionSelectorODPITest, BothWithImmediate) { EXPECT_EQ(kOverflow, s[0]->flags_condition()); } TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); Stream s = m.Build(); @@ -817,7 +846,8 @@ TEST_P(InstructionSelectorODPITest, BothWithImmediate) { TEST_P(InstructionSelectorODPITest, BothWithShiftByParameter) { const ODPI odpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); Node* n = (m.*odpi.constructor)( m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))); m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); @@ -831,7 +861,8 @@ TEST_P(InstructionSelectorODPITest, BothWithShiftByParameter) { EXPECT_EQ(kOverflow, s[0]->flags_condition()); } TRACED_FOREACH(Shift, shift, kShifts) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); Node* n = (m.*odpi.constructor)( (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), m.Parameter(2)); m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); @@ -851,7 +882,8 @@ TEST_P(InstructionSelectorODPITest, BothWithShiftByImmediate) { const ODPI odpi = GetParam(); TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* n = (m.*odpi.constructor)( m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm))); @@ -869,7 +901,8 @@ TEST_P(InstructionSelectorODPITest, BothWithShiftByImmediate) { } TRACED_FOREACH(Shift, shift, kShifts) { TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* n = (m.*odpi.constructor)( (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), m.Parameter(1)); @@ -890,7 +923,8 @@ TEST_P(InstructionSelectorODPITest, BothWithShiftByImmediate) { TEST_P(InstructionSelectorODPITest, BranchWithParameters) { const ODPI odpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); RawMachineLabel a, b; Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); m.Branch(m.Projection(1, n), &a, &b); @@ -912,7 +946,7 @@ TEST_P(InstructionSelectorODPITest, BranchWithParameters) { TEST_P(InstructionSelectorODPITest, BranchWithImmediate) { const ODPI odpi = GetParam(); TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); m.Branch(m.Projection(1, n), &a, &b); @@ -931,7 +965,7 @@ TEST_P(InstructionSelectorODPITest, BranchWithImmediate) { EXPECT_EQ(kOverflow, s[0]->flags_condition()); } TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); m.Branch(m.Projection(1, n), &a, &b); @@ -954,7 +988,8 @@ TEST_P(InstructionSelectorODPITest, BranchWithImmediate) { TEST_P(InstructionSelectorODPITest, BranchIfZeroWithParameters) { const ODPI odpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); RawMachineLabel a, b; Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); m.Branch(m.Word32Equal(m.Projection(1, n), m.Int32Constant(0)), &a, &b); @@ -975,7 +1010,8 @@ TEST_P(InstructionSelectorODPITest, BranchIfZeroWithParameters) { TEST_P(InstructionSelectorODPITest, BranchIfNotZeroWithParameters) { const ODPI odpi = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); RawMachineLabel a, b; Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); m.Branch(m.Word32NotEqual(m.Projection(1, n), m.Int32Constant(0)), &a, &b); @@ -1007,7 +1043,8 @@ typedef InstructionSelectorTestWithParam InstructionSelectorShiftTest; TEST_P(InstructionSelectorShiftTest, Parameters) { const Shift shift = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return((m.*shift.constructor)(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1021,7 +1058,7 @@ TEST_P(InstructionSelectorShiftTest, Parameters) { TEST_P(InstructionSelectorShiftTest, Immediate) { const Shift shift = GetParam(); TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return((m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1037,7 +1074,8 @@ TEST_P(InstructionSelectorShiftTest, Immediate) { TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameter) { const Shift shift = GetParam(); { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return( m.Word32Equal(m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); @@ -1051,7 +1089,8 @@ TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameter) { EXPECT_EQ(kEqual, s[0]->flags_condition()); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return( m.Word32Equal((m.*shift.constructor)(m.Parameter(1), m.Parameter(2)), m.Parameter(0))); @@ -1070,7 +1109,8 @@ TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameter) { TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameterAndImmediate) { const Shift shift = GetParam(); TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Word32Equal( (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), m.Parameter(0))); @@ -1085,7 +1125,8 @@ TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameterAndImmediate) { EXPECT_EQ(kEqual, s[0]->flags_condition()); } TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Word32Equal( m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); @@ -1104,7 +1145,8 @@ TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameterAndImmediate) { TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithParameters) { const Shift shift = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Word32Equal(m.Int32Constant(0), (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); @@ -1122,7 +1164,8 @@ TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithParameters) { TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithImmediate) { const Shift shift = GetParam(); TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Word32Equal( m.Int32Constant(0), (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); @@ -1141,7 +1184,8 @@ TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithImmediate) { TEST_P(InstructionSelectorShiftTest, Word32NotWithParameters) { const Shift shift = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Word32Not((m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1155,7 +1199,7 @@ TEST_P(InstructionSelectorShiftTest, Word32NotWithParameters) { TEST_P(InstructionSelectorShiftTest, Word32NotWithImmediate) { const Shift shift = GetParam(); TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Not( (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); Stream s = m.Build(); @@ -1171,7 +1215,8 @@ TEST_P(InstructionSelectorShiftTest, Word32NotWithImmediate) { TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithParameters) { const Shift shift = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Parameter(0), m.Word32Not((m.*shift.constructor)( m.Parameter(1), m.Parameter(2))))); Stream s = m.Build(); @@ -1186,7 +1231,8 @@ TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithParameters) { TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithImmediate) { const Shift shift = GetParam(); TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Word32And(m.Parameter(0), m.Word32Not((m.*shift.constructor)( m.Parameter(1), m.Int32Constant(imm))))); @@ -1227,49 +1273,49 @@ std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) { const MemoryAccess kMemoryAccesses[] = { - {kMachInt8, + {MachineType::Int8(), kArmLdrsb, kArmStrb, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachUint8, + {MachineType::Uint8(), kArmLdrb, kArmStrb, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3914, -3536, -3234, -3185, -3169, -1073, -990, -859, -720, -434, -127, -124, -122, -105, -91, -86, -64, -55, -53, -30, -10, -3, 0, 20, 28, 39, 58, 64, 73, 75, 100, 108, 121, 686, 963, 1363, 2759, 3449, 4095}}, - {kMachInt16, + {MachineType::Int16(), kArmLdrsh, kArmStrh, &InstructionSelectorTest::Stream::IsInteger, {-255, -251, -232, -220, -144, -138, -130, -126, -116, -115, -102, -101, -98, -69, -59, -56, -39, -35, -23, -19, -7, 0, 22, 26, 37, 68, 83, 87, 98, 102, 108, 111, 117, 171, 195, 203, 204, 245, 246, 255}}, - {kMachUint16, + {MachineType::Uint16(), kArmLdrh, kArmStrh, &InstructionSelectorTest::Stream::IsInteger, {-255, -230, -201, -172, -125, -119, -118, -105, -98, -79, -54, -42, -41, -32, -12, -11, -5, -4, 0, 5, 9, 25, 28, 51, 58, 60, 89, 104, 108, 109, 114, 116, 120, 138, 150, 161, 166, 172, 228, 255}}, - {kMachInt32, + {MachineType::Int32(), kArmLdr, kArmStr, &InstructionSelectorTest::Stream::IsInteger, {-4095, -1898, -1685, -1562, -1408, -1313, -344, -128, -116, -100, -92, -80, -72, -71, -56, -25, -21, -11, -9, 0, 3, 5, 27, 28, 42, 52, 63, 88, 93, 97, 125, 846, 1037, 2102, 2403, 2597, 2632, 2997, 3935, 4095}}, - {kMachFloat32, + {MachineType::Float32(), kArmVldrF32, kArmVstrF32, &InstructionSelectorTest::Stream::IsDouble, {-1020, -928, -896, -772, -728, -680, -660, -488, -372, -112, -100, -92, -84, -80, -72, -64, -60, -56, -52, -48, -36, -32, -20, -8, -4, 0, 8, 20, 24, 40, 64, 112, 204, 388, 516, 852, 856, 976, 988, 1020}}, - {kMachFloat64, + {MachineType::Float64(), kArmVldrF64, kArmVstrF64, &InstructionSelectorTest::Stream::IsDouble, @@ -1286,7 +1332,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32); + StreamBuilder m(this, memacc.type, MachineType::Pointer(), + MachineType::Int32()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1301,7 +1348,7 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) { const MemoryAccess memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, memacc.type, kMachPtr); + StreamBuilder m(this, memacc.type, MachineType::Pointer()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1318,7 +1365,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + MachineType::Int32(), memacc.type); m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -1334,7 +1382,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) { const MemoryAccess memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + memacc.type); m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -1360,7 +1409,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { - StreamBuilder m(this, kMachFloat64, kMachFloat32); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float32()); m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1371,7 +1420,7 @@ TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) { - StreamBuilder m(this, kMachFloat32, kMachFloat64); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float64()); m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1423,7 +1472,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorComparisonTest, Parameters) { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = (m.*cmp.constructor)(p0, p1); @@ -1445,7 +1495,8 @@ TEST_P(InstructionSelectorComparisonTest, Parameters) { TEST_P(InstructionSelectorComparisonTest, Word32EqualWithZero) { { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = @@ -1465,7 +1516,8 @@ TEST_P(InstructionSelectorComparisonTest, Word32EqualWithZero) { } { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = @@ -1514,7 +1566,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorF32ComparisonTest, WithParameters) { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float32(), + MachineType::Float32()); m.Return((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1))); Stream const s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1528,7 +1581,8 @@ TEST_P(InstructionSelectorF32ComparisonTest, WithParameters) { TEST_P(InstructionSelectorF32ComparisonTest, NegatedWithParameters) { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float32(), + MachineType::Float32()); m.Return( m.WordBinaryNot((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1)))); Stream const s = m.Build(); @@ -1543,7 +1597,7 @@ TEST_P(InstructionSelectorF32ComparisonTest, NegatedWithParameters) { TEST_P(InstructionSelectorF32ComparisonTest, WithImmediateZeroOnRight) { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachFloat32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float32()); m.Return((m.*cmp.constructor)(m.Parameter(0), m.Float32Constant(0.0))); Stream const s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1558,7 +1612,7 @@ TEST_P(InstructionSelectorF32ComparisonTest, WithImmediateZeroOnRight) { TEST_P(InstructionSelectorF32ComparisonTest, WithImmediateZeroOnLeft) { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachFloat32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float32()); m.Return((m.*cmp.constructor)(m.Float32Constant(0.0f), m.Parameter(0))); Stream const s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1595,7 +1649,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorF64ComparisonTest, WithParameters) { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float64(), + MachineType::Float64()); m.Return((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1))); Stream const s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1609,7 +1664,8 @@ TEST_P(InstructionSelectorF64ComparisonTest, WithParameters) { TEST_P(InstructionSelectorF64ComparisonTest, NegatedWithParameters) { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float64(), + MachineType::Float64()); m.Return( m.WordBinaryNot((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1)))); Stream const s = m.Build(); @@ -1624,7 +1680,7 @@ TEST_P(InstructionSelectorF64ComparisonTest, NegatedWithParameters) { TEST_P(InstructionSelectorF64ComparisonTest, WithImmediateZeroOnRight) { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachFloat64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float64()); m.Return((m.*cmp.constructor)(m.Parameter(0), m.Float64Constant(0.0))); Stream const s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1639,7 +1695,7 @@ TEST_P(InstructionSelectorF64ComparisonTest, WithImmediateZeroOnRight) { TEST_P(InstructionSelectorF64ComparisonTest, WithImmediateZeroOnLeft) { const Comparison& cmp = GetParam(); - StreamBuilder m(this, kMachInt32, kMachFloat64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float64()); m.Return((m.*cmp.constructor)(m.Float64Constant(0.0), m.Parameter(0))); Stream const s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1689,7 +1745,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFAITest, TEST_F(InstructionSelectorTest, Float32Abs) { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Abs(p0); m.Return(n); @@ -1704,7 +1760,7 @@ TEST_F(InstructionSelectorTest, Float32Abs) { TEST_F(InstructionSelectorTest, Float64Abs) { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Abs(p0); m.Return(n); @@ -1720,8 +1776,8 @@ TEST_F(InstructionSelectorTest, Float64Abs) { TEST_F(InstructionSelectorTest, Float32AddWithFloat32Mul) { { - StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32, - kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), + MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1741,8 +1797,8 @@ TEST_F(InstructionSelectorTest, Float32AddWithFloat32Mul) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32, - kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), + MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1766,8 +1822,8 @@ TEST_F(InstructionSelectorTest, Float32AddWithFloat32Mul) { TEST_F(InstructionSelectorTest, Float64AddWithFloat64Mul) { { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64, - kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1787,8 +1843,8 @@ TEST_F(InstructionSelectorTest, Float64AddWithFloat64Mul) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64, - kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1811,7 +1867,7 @@ TEST_F(InstructionSelectorTest, Float64AddWithFloat64Mul) { TEST_F(InstructionSelectorTest, Float32SubWithMinusZero) { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); m.Return(n); @@ -1826,7 +1882,7 @@ TEST_F(InstructionSelectorTest, Float32SubWithMinusZero) { TEST_F(InstructionSelectorTest, Float64SubWithMinusZero) { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); m.Return(n); @@ -1841,7 +1897,8 @@ TEST_F(InstructionSelectorTest, Float64SubWithMinusZero) { TEST_F(InstructionSelectorTest, Float32SubWithFloat32Mul) { - StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), + MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1862,7 +1919,8 @@ TEST_F(InstructionSelectorTest, Float32SubWithFloat32Mul) { TEST_F(InstructionSelectorTest, Float64SubWithFloat64Mul) { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1883,7 +1941,7 @@ TEST_F(InstructionSelectorTest, Float64SubWithFloat64Mul) { TEST_F(InstructionSelectorTest, Float32Sqrt) { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Sqrt(p0); m.Return(n); @@ -1899,7 +1957,7 @@ TEST_F(InstructionSelectorTest, Float32Sqrt) { TEST_F(InstructionSelectorTest, Float64Sqrt) { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Sqrt(p0); m.Return(n); @@ -1920,7 +1978,8 @@ TEST_F(InstructionSelectorTest, Float64Sqrt) { TEST_F(InstructionSelectorTest, Int32AddWithInt32Mul) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1937,7 +1996,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithInt32Mul) { EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1958,7 +2018,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithInt32Mul) { TEST_F(InstructionSelectorTest, Int32AddWithInt32MulHigh) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1975,7 +2036,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithInt32MulHigh) { EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -1996,7 +2058,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithInt32MulHigh) { TEST_F(InstructionSelectorTest, Int32AddWithWord32And) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = m.Int32Add(m.Word32And(p0, m.Int32Constant(0xff)), p1); @@ -2012,7 +2075,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithWord32And) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = m.Int32Add(p1, m.Word32And(p0, m.Int32Constant(0xff))); @@ -2028,7 +2092,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithWord32And) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = m.Int32Add(m.Word32And(p0, m.Int32Constant(0xffff)), p1); @@ -2044,7 +2109,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithWord32And) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = m.Int32Add(p1, m.Word32And(p0, m.Int32Constant(0xffff))); @@ -2064,7 +2130,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithWord32And) { TEST_F(InstructionSelectorTest, Int32AddWithWord32SarWithWord32Shl) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = m.Int32Add( @@ -2082,7 +2149,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithWord32SarWithWord32Shl) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = m.Int32Add( @@ -2100,7 +2168,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithWord32SarWithWord32Shl) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = m.Int32Add( @@ -2118,7 +2187,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithWord32SarWithWord32Shl) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const r = m.Int32Add( @@ -2139,7 +2209,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithWord32SarWithWord32Shl) { TEST_F(InstructionSelectorTest, Int32SubWithInt32Mul) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return( m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); Stream s = m.Build(); @@ -2153,7 +2224,8 @@ TEST_F(InstructionSelectorTest, Int32SubWithInt32Mul) { TEST_F(InstructionSelectorTest, Int32SubWithInt32MulForMLS) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); m.Return( m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); Stream s = m.Build(MLS); @@ -2165,7 +2237,8 @@ TEST_F(InstructionSelectorTest, Int32SubWithInt32MulForMLS) { TEST_F(InstructionSelectorTest, Int32DivWithParameters) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(4U, s.size()); @@ -2185,7 +2258,8 @@ TEST_F(InstructionSelectorTest, Int32DivWithParameters) { TEST_F(InstructionSelectorTest, Int32DivWithParametersForSUDIV) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(SUDIV); ASSERT_EQ(1U, s.size()); @@ -2194,7 +2268,8 @@ TEST_F(InstructionSelectorTest, Int32DivWithParametersForSUDIV) { TEST_F(InstructionSelectorTest, Int32ModWithParameters) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(6U, s.size()); @@ -2224,7 +2299,8 @@ TEST_F(InstructionSelectorTest, Int32ModWithParameters) { TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIV) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(SUDIV); ASSERT_EQ(3U, s.size()); @@ -2245,7 +2321,8 @@ TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIV) { TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIVAndMLS) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(MLS, SUDIV); ASSERT_EQ(2U, s.size()); @@ -2262,7 +2339,8 @@ TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIVAndMLS) { TEST_F(InstructionSelectorTest, Int32MulWithParameters) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Mul(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2275,7 +2353,7 @@ TEST_F(InstructionSelectorTest, Int32MulWithParameters) { TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { // x * (2^k + 1) -> x + (x >> k) TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) + 1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2288,7 +2366,7 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // x * (2^k - 1) -> -x + (x >> k) TRACED_FORRANGE(int32_t, k, 3, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) - 1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2301,7 +2379,7 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // (2^k + 1) * x -> x + (x >> k) TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2314,7 +2392,7 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // x * (2^k - 1) -> -x + (x >> k) TRACED_FORRANGE(int32_t, k, 3, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Mul(m.Int32Constant((1 << k) - 1), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2329,7 +2407,8 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { TEST_F(InstructionSelectorTest, Int32MulHighWithParameters) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Int32MulHigh(p0, p1); @@ -2346,7 +2425,8 @@ TEST_F(InstructionSelectorTest, Int32MulHighWithParameters) { TEST_F(InstructionSelectorTest, Uint32MulHighWithParameters) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Uint32MulHigh(p0, p1); @@ -2363,7 +2443,8 @@ TEST_F(InstructionSelectorTest, Uint32MulHighWithParameters) { TEST_F(InstructionSelectorTest, Uint32DivWithParameters) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Uint32Div(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(4U, s.size()); @@ -2383,7 +2464,8 @@ TEST_F(InstructionSelectorTest, Uint32DivWithParameters) { TEST_F(InstructionSelectorTest, Uint32DivWithParametersForSUDIV) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Uint32Div(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(SUDIV); ASSERT_EQ(1U, s.size()); @@ -2392,7 +2474,8 @@ TEST_F(InstructionSelectorTest, Uint32DivWithParametersForSUDIV) { TEST_F(InstructionSelectorTest, Uint32ModWithParameters) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Uint32Mod(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(6U, s.size()); @@ -2422,7 +2505,8 @@ TEST_F(InstructionSelectorTest, Uint32ModWithParameters) { TEST_F(InstructionSelectorTest, Uint32ModWithParametersForSUDIV) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Uint32Mod(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(SUDIV); ASSERT_EQ(3U, s.size()); @@ -2443,7 +2527,8 @@ TEST_F(InstructionSelectorTest, Uint32ModWithParametersForSUDIV) { TEST_F(InstructionSelectorTest, Uint32ModWithParametersForSUDIVAndMLS) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Uint32Mod(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(MLS, SUDIV); ASSERT_EQ(2U, s.size()); @@ -2461,7 +2546,7 @@ TEST_F(InstructionSelectorTest, Uint32ModWithParametersForSUDIVAndMLS) { TEST_F(InstructionSelectorTest, Word32AndWithUbfxImmediateForARMv7) { TRACED_FORRANGE(int32_t, width, 1, 32) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Parameter(0), m.Int32Constant(0xffffffffu >> (32 - width)))); Stream s = m.Build(ARMv7); @@ -2472,7 +2557,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithUbfxImmediateForARMv7) { EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); } TRACED_FORRANGE(int32_t, width, 1, 32) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), m.Parameter(0))); Stream s = m.Build(ARMv7); @@ -2488,7 +2573,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithUbfxImmediateForARMv7) { TEST_F(InstructionSelectorTest, Word32AndWithBfcImmediateForARMv7) { TRACED_FORRANGE(int32_t, lsb, 0, 31) { TRACED_FORRANGE(int32_t, width, 9, (32 - lsb) - 1) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And( m.Parameter(0), m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)))); @@ -2505,7 +2590,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithBfcImmediateForARMv7) { } TRACED_FORRANGE(int32_t, lsb, 0, 31) { TRACED_FORRANGE(int32_t, width, 9, (32 - lsb) - 1) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return( m.Word32And(m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)), m.Parameter(0))); @@ -2525,7 +2610,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithBfcImmediateForARMv7) { TEST_F(InstructionSelectorTest, Word32AndWith0xffff) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32And(p0, m.Int32Constant(0xffff)); m.Return(r); @@ -2539,7 +2624,7 @@ TEST_F(InstructionSelectorTest, Word32AndWith0xffff) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32And(m.Int32Constant(0xffff), p0); m.Return(r); @@ -2557,7 +2642,7 @@ TEST_F(InstructionSelectorTest, Word32AndWith0xffff) { TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24)); @@ -2572,7 +2657,7 @@ TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16)); @@ -2596,7 +2681,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) { if (max > static_cast(kMaxInt)) max -= 1; uint32_t jnk = rng()->NextInt(max); uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), m.Int32Constant(lsb))); Stream s = m.Build(ARMv7); @@ -2613,7 +2698,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) { if (max > static_cast(kMaxInt)) max -= 1; uint32_t jnk = rng()->NextInt(max); uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), m.Int32Constant(lsb))); Stream s = m.Build(ARMv7); @@ -2629,7 +2714,8 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) { TEST_F(InstructionSelectorTest, Word32AndWithWord32Not) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Word32And(m.Parameter(0), m.Word32Not(m.Parameter(1)))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2639,7 +2725,8 @@ TEST_F(InstructionSelectorTest, Word32AndWithWord32Not) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Word32And(m.Word32Not(m.Parameter(0)), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2652,7 +2739,8 @@ TEST_F(InstructionSelectorTest, Word32AndWithWord32Not) { TEST_F(InstructionSelectorTest, Word32EqualWithParameters) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Word32Equal(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2668,7 +2756,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithParameters) { TEST_F(InstructionSelectorTest, Word32EqualWithImmediate) { TRACED_FOREACH(int32_t, imm, kImmediates) { if (imm == 0) continue; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(imm))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2682,7 +2770,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithImmediate) { } TRACED_FOREACH(int32_t, imm, kImmediates) { if (imm == 0) continue; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Int32Constant(imm), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2699,7 +2787,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithImmediate) { TEST_F(InstructionSelectorTest, Word32EqualWithZero) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2712,7 +2800,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) { EXPECT_EQ(kEqual, s[0]->flags_condition()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2728,7 +2816,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) { TEST_F(InstructionSelectorTest, Word32NotWithParameter) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Not(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2742,7 +2830,7 @@ TEST_F(InstructionSelectorTest, Word32NotWithParameter) { TEST_F(InstructionSelectorTest, Word32AndWithWord32ShrWithImmediateForARMv7) { TRACED_FORRANGE(int32_t, lsb, 0, 31) { TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)), m.Int32Constant(0xffffffffu >> (32 - width)))); Stream s = m.Build(ARMv7); @@ -2755,7 +2843,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithWord32ShrWithImmediateForARMv7) { } TRACED_FORRANGE(int32_t, lsb, 0, 31) { TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)))); Stream s = m.Build(ARMv7); @@ -2770,7 +2858,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithWord32ShrWithImmediateForARMv7) { TEST_F(InstructionSelectorTest, Word32Clz) { - StreamBuilder m(this, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32Clz(p0); m.Return(n); diff --git a/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc b/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc index c3d82ba7ef..5d52625684 100644 --- a/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc +++ b/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc @@ -43,12 +43,12 @@ std::ostream& operator<<(std::ostream& os, const Shift& shift) { // machine type. Node* BuildConstant(InstructionSelectorTest::StreamBuilder& m, MachineType type, int64_t value) { - switch (type) { - case kMachInt32: + switch (type.representation()) { + case MachineRepresentation::kWord32: return m.Int32Constant(static_cast(value)); break; - case kMachInt64: + case MachineRepresentation::kWord64: return m.Int64Constant(value); break; @@ -61,12 +61,18 @@ Node* BuildConstant(InstructionSelectorTest::StreamBuilder& m, MachineType type, // ARM64 logical instructions. const MachInst2 kLogicalInstructions[] = { - {&RawMachineAssembler::Word32And, "Word32And", kArm64And32, kMachInt32}, - {&RawMachineAssembler::Word64And, "Word64And", kArm64And, kMachInt64}, - {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Or32, kMachInt32}, - {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Or, kMachInt64}, - {&RawMachineAssembler::Word32Xor, "Word32Xor", kArm64Eor32, kMachInt32}, - {&RawMachineAssembler::Word64Xor, "Word64Xor", kArm64Eor, kMachInt64}}; + {&RawMachineAssembler::Word32And, "Word32And", kArm64And32, + MachineType::Int32()}, + {&RawMachineAssembler::Word64And, "Word64And", kArm64And, + MachineType::Int64()}, + {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Or32, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Or, + MachineType::Int64()}, + {&RawMachineAssembler::Word32Xor, "Word32Xor", kArm64Eor32, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Xor, "Word64Xor", kArm64Eor, + MachineType::Int64()}}; // ARM64 logical immediates: contiguous set bits, rotated about a power of two @@ -130,13 +136,17 @@ std::ostream& operator<<(std::ostream& os, const AddSub& op) { const AddSub kAddSubInstructions[] = { - {{&RawMachineAssembler::Int32Add, "Int32Add", kArm64Add32, kMachInt32}, + {{&RawMachineAssembler::Int32Add, "Int32Add", kArm64Add32, + MachineType::Int32()}, kArm64Sub32}, - {{&RawMachineAssembler::Int64Add, "Int64Add", kArm64Add, kMachInt64}, + {{&RawMachineAssembler::Int64Add, "Int64Add", kArm64Add, + MachineType::Int64()}, kArm64Sub}, - {{&RawMachineAssembler::Int32Sub, "Int32Sub", kArm64Sub32, kMachInt32}, + {{&RawMachineAssembler::Int32Sub, "Int32Sub", kArm64Sub32, + MachineType::Int32()}, kArm64Add32}, - {{&RawMachineAssembler::Int64Sub, "Int64Sub", kArm64Sub, kMachInt64}, + {{&RawMachineAssembler::Int64Sub, "Int64Sub", kArm64Sub, + MachineType::Int64()}, kArm64Add}}; @@ -159,60 +169,78 @@ const int32_t kAddSubImmediates[] = { // ARM64 flag setting data processing instructions. const MachInst2 kDPFlagSetInstructions[] = { - {&RawMachineAssembler::Word32And, "Word32And", kArm64Tst32, kMachInt32}, - {&RawMachineAssembler::Int32Add, "Int32Add", kArm64Cmn32, kMachInt32}, - {&RawMachineAssembler::Int32Sub, "Int32Sub", kArm64Cmp32, kMachInt32}, - {&RawMachineAssembler::Word64And, "Word64And", kArm64Tst, kMachInt64}}; + {&RawMachineAssembler::Word32And, "Word32And", kArm64Tst32, + MachineType::Int32()}, + {&RawMachineAssembler::Int32Add, "Int32Add", kArm64Cmn32, + MachineType::Int32()}, + {&RawMachineAssembler::Int32Sub, "Int32Sub", kArm64Cmp32, + MachineType::Int32()}, + {&RawMachineAssembler::Word64And, "Word64And", kArm64Tst, + MachineType::Int64()}}; // ARM64 arithmetic with overflow instructions. const MachInst2 kOvfAddSubInstructions[] = { {&RawMachineAssembler::Int32AddWithOverflow, "Int32AddWithOverflow", - kArm64Add32, kMachInt32}, + kArm64Add32, MachineType::Int32()}, {&RawMachineAssembler::Int32SubWithOverflow, "Int32SubWithOverflow", - kArm64Sub32, kMachInt32}}; + kArm64Sub32, MachineType::Int32()}}; // ARM64 shift instructions. const Shift kShiftInstructions[] = { - {{&RawMachineAssembler::Word32Shl, "Word32Shl", kArm64Lsl32, kMachInt32}, + {{&RawMachineAssembler::Word32Shl, "Word32Shl", kArm64Lsl32, + MachineType::Int32()}, kMode_Operand2_R_LSL_I}, - {{&RawMachineAssembler::Word64Shl, "Word64Shl", kArm64Lsl, kMachInt64}, + {{&RawMachineAssembler::Word64Shl, "Word64Shl", kArm64Lsl, + MachineType::Int64()}, kMode_Operand2_R_LSL_I}, - {{&RawMachineAssembler::Word32Shr, "Word32Shr", kArm64Lsr32, kMachInt32}, + {{&RawMachineAssembler::Word32Shr, "Word32Shr", kArm64Lsr32, + MachineType::Int32()}, kMode_Operand2_R_LSR_I}, - {{&RawMachineAssembler::Word64Shr, "Word64Shr", kArm64Lsr, kMachInt64}, + {{&RawMachineAssembler::Word64Shr, "Word64Shr", kArm64Lsr, + MachineType::Int64()}, kMode_Operand2_R_LSR_I}, - {{&RawMachineAssembler::Word32Sar, "Word32Sar", kArm64Asr32, kMachInt32}, + {{&RawMachineAssembler::Word32Sar, "Word32Sar", kArm64Asr32, + MachineType::Int32()}, kMode_Operand2_R_ASR_I}, - {{&RawMachineAssembler::Word64Sar, "Word64Sar", kArm64Asr, kMachInt64}, + {{&RawMachineAssembler::Word64Sar, "Word64Sar", kArm64Asr, + MachineType::Int64()}, kMode_Operand2_R_ASR_I}, - {{&RawMachineAssembler::Word32Ror, "Word32Ror", kArm64Ror32, kMachInt32}, + {{&RawMachineAssembler::Word32Ror, "Word32Ror", kArm64Ror32, + MachineType::Int32()}, kMode_Operand2_R_ROR_I}, - {{&RawMachineAssembler::Word64Ror, "Word64Ror", kArm64Ror, kMachInt64}, + {{&RawMachineAssembler::Word64Ror, "Word64Ror", kArm64Ror, + MachineType::Int64()}, kMode_Operand2_R_ROR_I}}; // ARM64 Mul/Div instructions. const MachInst2 kMulDivInstructions[] = { - {&RawMachineAssembler::Int32Mul, "Int32Mul", kArm64Mul32, kMachInt32}, - {&RawMachineAssembler::Int64Mul, "Int64Mul", kArm64Mul, kMachInt64}, - {&RawMachineAssembler::Int32Div, "Int32Div", kArm64Idiv32, kMachInt32}, - {&RawMachineAssembler::Int64Div, "Int64Div", kArm64Idiv, kMachInt64}, - {&RawMachineAssembler::Uint32Div, "Uint32Div", kArm64Udiv32, kMachInt32}, - {&RawMachineAssembler::Uint64Div, "Uint64Div", kArm64Udiv, kMachInt64}}; + {&RawMachineAssembler::Int32Mul, "Int32Mul", kArm64Mul32, + MachineType::Int32()}, + {&RawMachineAssembler::Int64Mul, "Int64Mul", kArm64Mul, + MachineType::Int64()}, + {&RawMachineAssembler::Int32Div, "Int32Div", kArm64Idiv32, + MachineType::Int32()}, + {&RawMachineAssembler::Int64Div, "Int64Div", kArm64Idiv, + MachineType::Int64()}, + {&RawMachineAssembler::Uint32Div, "Uint32Div", kArm64Udiv32, + MachineType::Int32()}, + {&RawMachineAssembler::Uint64Div, "Uint64Div", kArm64Udiv, + MachineType::Int64()}}; // ARM64 FP arithmetic instructions. const MachInst2 kFPArithInstructions[] = { {&RawMachineAssembler::Float64Add, "Float64Add", kArm64Float64Add, - kMachFloat64}, + MachineType::Float64()}, {&RawMachineAssembler::Float64Sub, "Float64Sub", kArm64Float64Sub, - kMachFloat64}, + MachineType::Float64()}, {&RawMachineAssembler::Float64Mul, "Float64Mul", kArm64Float64Mul, - kMachFloat64}, + MachineType::Float64()}, {&RawMachineAssembler::Float64Div, "Float64Div", kArm64Float64Div, - kMachFloat64}}; + MachineType::Float64()}}; struct FPCmp { @@ -230,23 +258,29 @@ std::ostream& operator<<(std::ostream& os, const FPCmp& cmp) { // ARM64 FP comparison instructions. const FPCmp kFPCmpInstructions[] = { {{&RawMachineAssembler::Float64Equal, "Float64Equal", kArm64Float64Cmp, - kMachFloat64}, - kEqual, kEqual}, + MachineType::Float64()}, + kEqual, + kEqual}, {{&RawMachineAssembler::Float64LessThan, "Float64LessThan", - kArm64Float64Cmp, kMachFloat64}, - kFloatLessThan, kFloatGreaterThan}, + kArm64Float64Cmp, MachineType::Float64()}, + kFloatLessThan, + kFloatGreaterThan}, {{&RawMachineAssembler::Float64LessThanOrEqual, "Float64LessThanOrEqual", - kArm64Float64Cmp, kMachFloat64}, - kFloatLessThanOrEqual, kFloatGreaterThanOrEqual}, + kArm64Float64Cmp, MachineType::Float64()}, + kFloatLessThanOrEqual, + kFloatGreaterThanOrEqual}, {{&RawMachineAssembler::Float32Equal, "Float32Equal", kArm64Float32Cmp, - kMachFloat32}, - kEqual, kEqual}, + MachineType::Float32()}, + kEqual, + kEqual}, {{&RawMachineAssembler::Float32LessThan, "Float32LessThan", - kArm64Float32Cmp, kMachFloat32}, - kFloatLessThan, kFloatGreaterThan}, + kArm64Float32Cmp, MachineType::Float32()}, + kFloatLessThan, + kFloatGreaterThan}, {{&RawMachineAssembler::Float32LessThanOrEqual, "Float32LessThanOrEqual", - kArm64Float32Cmp, kMachFloat32}, - kFloatLessThanOrEqual, kFloatGreaterThanOrEqual}}; + kArm64Float32Cmp, MachineType::Float32()}, + kFloatLessThanOrEqual, + kFloatGreaterThanOrEqual}}; struct Conversion { @@ -264,32 +298,33 @@ std::ostream& operator<<(std::ostream& os, const Conversion& conv) { // ARM64 type conversion instructions. const Conversion kConversionInstructions[] = { {{&RawMachineAssembler::ChangeFloat32ToFloat64, "ChangeFloat32ToFloat64", - kArm64Float32ToFloat64, kMachFloat64}, - kMachFloat32}, + kArm64Float32ToFloat64, MachineType::Float64()}, + MachineType::Float32()}, {{&RawMachineAssembler::TruncateFloat64ToFloat32, - "TruncateFloat64ToFloat32", kArm64Float64ToFloat32, kMachFloat32}, - kMachFloat64}, + "TruncateFloat64ToFloat32", kArm64Float64ToFloat32, + MachineType::Float32()}, + MachineType::Float64()}, {{&RawMachineAssembler::ChangeInt32ToInt64, "ChangeInt32ToInt64", - kArm64Sxtw, kMachInt64}, - kMachInt32}, + kArm64Sxtw, MachineType::Int64()}, + MachineType::Int32()}, {{&RawMachineAssembler::ChangeUint32ToUint64, "ChangeUint32ToUint64", - kArm64Mov32, kMachUint64}, - kMachUint32}, + kArm64Mov32, MachineType::Uint64()}, + MachineType::Uint32()}, {{&RawMachineAssembler::TruncateInt64ToInt32, "TruncateInt64ToInt32", - kArm64Mov32, kMachInt32}, - kMachInt64}, + kArm64Mov32, MachineType::Int32()}, + MachineType::Int64()}, {{&RawMachineAssembler::ChangeInt32ToFloat64, "ChangeInt32ToFloat64", - kArm64Int32ToFloat64, kMachFloat64}, - kMachInt32}, + kArm64Int32ToFloat64, MachineType::Float64()}, + MachineType::Int32()}, {{&RawMachineAssembler::ChangeUint32ToFloat64, "ChangeUint32ToFloat64", - kArm64Uint32ToFloat64, kMachFloat64}, - kMachUint32}, + kArm64Uint32ToFloat64, MachineType::Float64()}, + MachineType::Uint32()}, {{&RawMachineAssembler::ChangeFloat64ToInt32, "ChangeFloat64ToInt32", - kArm64Float64ToInt32, kMachInt32}, - kMachFloat64}, + kArm64Float64ToInt32, MachineType::Int32()}, + MachineType::Float64()}, {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", - kArm64Float64ToUint32, kMachUint32}, - kMachFloat64}}; + kArm64Float64ToUint32, MachineType::Uint32()}, + MachineType::Float64()}}; } // namespace @@ -319,7 +354,7 @@ TEST_P(InstructionSelectorLogicalTest, Immediate) { const MachInst2 dpi = GetParam(); const MachineType type = dpi.machine_type; // TODO(all): Add support for testing 64-bit immediates. - if (type == kMachInt32) { + if (type == MachineType::Int32()) { // Immediate on the right. TRACED_FOREACH(int32_t, imm, kLogical32Immediates) { StreamBuilder m(this, type, type); @@ -356,7 +391,7 @@ TEST_P(InstructionSelectorLogicalTest, ShiftByImmediate) { // Only test 64-bit shifted operands with 64-bit instructions. if (shift.mi.machine_type != type) continue; - TRACED_FORRANGE(int, imm, 0, ((type == kMachInt32) ? 31 : 63)) { + TRACED_FORRANGE(int, imm, 0, ((type == MachineType::Int32()) ? 31 : 63)) { StreamBuilder m(this, type, type, type); m.Return((m.*dpi.constructor)( m.Parameter(0), @@ -371,7 +406,7 @@ TEST_P(InstructionSelectorLogicalTest, ShiftByImmediate) { EXPECT_EQ(1U, s[0]->OutputCount()); } - TRACED_FORRANGE(int, imm, 0, ((type == kMachInt32) ? 31 : 63)) { + TRACED_FORRANGE(int, imm, 0, ((type == MachineType::Int32()) ? 31 : 63)) { StreamBuilder m(this, type, type, type); m.Return((m.*dpi.constructor)( (m.*shift.mi.constructor)(m.Parameter(1), @@ -462,7 +497,7 @@ TEST_P(InstructionSelectorAddSubTest, ShiftByImmediateOnRight) { continue; } - TRACED_FORRANGE(int, imm, 0, ((type == kMachInt32) ? 31 : 63)) { + TRACED_FORRANGE(int, imm, 0, ((type == MachineType::Int32()) ? 31 : 63)) { StreamBuilder m(this, type, type, type); m.Return((m.*dpi.mi.constructor)( m.Parameter(0), @@ -552,7 +587,7 @@ TEST_F(InstructionSelectorTest, AddImmediateOnLeft) { { // 32-bit add. TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Int32Constant(imm), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -566,7 +601,7 @@ TEST_F(InstructionSelectorTest, AddImmediateOnLeft) { { // 64-bit add. TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Int64Add(m.Int64Constant(imm), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -583,7 +618,8 @@ TEST_F(InstructionSelectorTest, AddImmediateOnLeft) { TEST_F(InstructionSelectorTest, SubZeroOnLeft) { { // 32-bit subtract. - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Sub(m.Int32Constant(0), m.Parameter(0))); Stream s = m.Build(); @@ -596,7 +632,8 @@ TEST_F(InstructionSelectorTest, SubZeroOnLeft) { } { // 64-bit subtract. - StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return(m.Int64Sub(m.Int64Constant(0), m.Parameter(0))); Stream s = m.Build(); @@ -615,13 +652,14 @@ TEST_F(InstructionSelectorTest, SubZeroOnLeftWithShift) { { // Test 32-bit operations. Ignore ROR shifts, as subtract does not // support them. - if ((shift.mi.machine_type != kMachInt32) || + if ((shift.mi.machine_type != MachineType::Int32()) || (shift.mi.arch_opcode == kArm64Ror32) || (shift.mi.arch_opcode == kArm64Ror)) continue; TRACED_FORRANGE(int, imm, -32, 63) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Sub( m.Int32Constant(0), (m.*shift.mi.constructor)(m.Parameter(1), m.Int32Constant(imm)))); @@ -640,13 +678,14 @@ TEST_F(InstructionSelectorTest, SubZeroOnLeftWithShift) { { // Test 64-bit operations. Ignore ROR shifts, as subtract does not // support them. - if ((shift.mi.machine_type != kMachInt64) || + if ((shift.mi.machine_type != MachineType::Int64()) || (shift.mi.arch_opcode == kArm64Ror32) || (shift.mi.arch_opcode == kArm64Ror)) continue; TRACED_FORRANGE(int, imm, -32, 127) { - StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return(m.Int64Sub( m.Int64Constant(0), (m.*shift.mi.constructor)(m.Parameter(1), m.Int64Constant(imm)))); @@ -671,7 +710,7 @@ TEST_F(InstructionSelectorTest, AddNegImmediateOnLeft) { // 32-bit add. TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { if (imm == 0) continue; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Int32Constant(-imm), m.Parameter(0))); Stream s = m.Build(); @@ -687,7 +726,7 @@ TEST_F(InstructionSelectorTest, AddNegImmediateOnLeft) { // 64-bit add. TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { if (imm == 0) continue; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Int64Add(m.Int64Constant(-imm), m.Parameter(0))); Stream s = m.Build(); @@ -706,13 +745,14 @@ TEST_F(InstructionSelectorTest, AddShiftByImmediateOnLeft) { // 32-bit add. TRACED_FOREACH(Shift, shift, kShiftInstructions) { // Only test relevant shifted operands. - if (shift.mi.machine_type != kMachInt32) continue; + if (shift.mi.machine_type != MachineType::Int32()) continue; if (shift.mi.arch_opcode == kArm64Ror32) continue; // The available shift operand range is `0 <= imm < 32`, but we also test // that immediates outside this range are handled properly (modulo-32). TRACED_FORRANGE(int, imm, -32, 63) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return((m.Int32Add)( (m.*shift.mi.constructor)(m.Parameter(1), m.Int32Constant(imm)), m.Parameter(0))); @@ -729,13 +769,14 @@ TEST_F(InstructionSelectorTest, AddShiftByImmediateOnLeft) { // 64-bit add. TRACED_FOREACH(Shift, shift, kShiftInstructions) { // Only test relevant shifted operands. - if (shift.mi.machine_type != kMachInt64) continue; + if (shift.mi.machine_type != MachineType::Int64()) continue; if (shift.mi.arch_opcode == kArm64Ror) continue; // The available shift operand range is `0 <= imm < 64`, but we also test // that immediates outside this range are handled properly (modulo-64). TRACED_FORRANGE(int, imm, -64, 127) { - StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return((m.Int64Add)( (m.*shift.mi.constructor)(m.Parameter(1), m.Int64Constant(imm)), m.Parameter(0))); @@ -753,7 +794,8 @@ TEST_F(InstructionSelectorTest, AddShiftByImmediateOnLeft) { TEST_F(InstructionSelectorTest, AddUnsignedExtendByteOnLeft) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Add(m.Word32And(m.Parameter(0), m.Int32Constant(0xff)), m.Parameter(1))); Stream s = m.Build(); @@ -764,7 +806,8 @@ TEST_F(InstructionSelectorTest, AddUnsignedExtendByteOnLeft) { ASSERT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt64, kMachInt32, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int32(), + MachineType::Int64()); m.Return(m.Int64Add(m.Word32And(m.Parameter(0), m.Int32Constant(0xff)), m.Parameter(1))); Stream s = m.Build(); @@ -779,7 +822,8 @@ TEST_F(InstructionSelectorTest, AddUnsignedExtendByteOnLeft) { TEST_F(InstructionSelectorTest, AddUnsignedExtendHalfwordOnLeft) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Add(m.Word32And(m.Parameter(0), m.Int32Constant(0xffff)), m.Parameter(1))); Stream s = m.Build(); @@ -790,7 +834,8 @@ TEST_F(InstructionSelectorTest, AddUnsignedExtendHalfwordOnLeft) { ASSERT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt64, kMachInt32, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int32(), + MachineType::Int64()); m.Return(m.Int64Add(m.Word32And(m.Parameter(0), m.Int32Constant(0xffff)), m.Parameter(1))); Stream s = m.Build(); @@ -805,7 +850,8 @@ TEST_F(InstructionSelectorTest, AddUnsignedExtendHalfwordOnLeft) { TEST_F(InstructionSelectorTest, AddSignedExtendByteOnLeft) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Int32Add(m.Word32Sar(m.Word32Shl(m.Parameter(0), m.Int32Constant(24)), m.Int32Constant(24)), @@ -818,7 +864,8 @@ TEST_F(InstructionSelectorTest, AddSignedExtendByteOnLeft) { ASSERT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt64, kMachInt32, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int32(), + MachineType::Int64()); m.Return( m.Int64Add(m.Word32Sar(m.Word32Shl(m.Parameter(0), m.Int32Constant(24)), m.Int32Constant(24)), @@ -835,7 +882,8 @@ TEST_F(InstructionSelectorTest, AddSignedExtendByteOnLeft) { TEST_F(InstructionSelectorTest, AddSignedExtendHalfwordOnLeft) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Int32Add(m.Word32Sar(m.Word32Shl(m.Parameter(0), m.Int32Constant(16)), m.Int32Constant(16)), @@ -848,7 +896,8 @@ TEST_F(InstructionSelectorTest, AddSignedExtendHalfwordOnLeft) { ASSERT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt64, kMachInt32, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int32(), + MachineType::Int64()); m.Return( m.Int64Add(m.Word32Sar(m.Word32Shl(m.Parameter(0), m.Int32Constant(16)), m.Int32Constant(16)), @@ -899,7 +948,7 @@ TEST_F(InstructionSelectorTest, Word32AndBranchWithImmediateOnRight) { // Skip the cases where the instruction selector would use tbz/tbnz. if (base::bits::CountPopulation32(imm) == 1) continue; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Word32And(m.Parameter(0), m.Int32Constant(imm)), &a, &b); m.Bind(&a); @@ -922,7 +971,7 @@ TEST_F(InstructionSelectorTest, Word64AndBranchWithImmediateOnRight) { // Skip the cases where the instruction selector would use tbz/tbnz. if (base::bits::CountPopulation64(imm) == 1) continue; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); RawMachineLabel a, b; m.Branch(m.Word64And(m.Parameter(0), m.Int64Constant(imm)), &a, &b); m.Bind(&a); @@ -942,7 +991,7 @@ TEST_F(InstructionSelectorTest, Word64AndBranchWithImmediateOnRight) { TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnRight) { TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Int32Add(m.Parameter(0), m.Int32Constant(imm)), &a, &b); m.Bind(&a); @@ -960,7 +1009,7 @@ TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnRight) { TEST_F(InstructionSelectorTest, SubBranchWithImmediateOnRight) { TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Int32Sub(m.Parameter(0), m.Int32Constant(imm)), &a, &b); m.Bind(&a); @@ -981,7 +1030,7 @@ TEST_F(InstructionSelectorTest, Word32AndBranchWithImmediateOnLeft) { // Skip the cases where the instruction selector would use tbz/tbnz. if (base::bits::CountPopulation32(imm) == 1) continue; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Word32And(m.Int32Constant(imm), m.Parameter(0)), &a, &b); m.Bind(&a); @@ -1005,7 +1054,7 @@ TEST_F(InstructionSelectorTest, Word64AndBranchWithImmediateOnLeft) { // Skip the cases where the instruction selector would use tbz/tbnz. if (base::bits::CountPopulation64(imm) == 1) continue; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); RawMachineLabel a, b; m.Branch(m.Word64And(m.Int64Constant(imm), m.Parameter(0)), &a, &b); m.Bind(&a); @@ -1026,7 +1075,7 @@ TEST_F(InstructionSelectorTest, Word64AndBranchWithImmediateOnLeft) { TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnLeft) { TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Int32Add(m.Int32Constant(imm), m.Parameter(0)), &a, &b); m.Bind(&a); @@ -1046,7 +1095,7 @@ TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnLeft) { TEST_F(InstructionSelectorTest, Word32AndBranchWithOneBitMaskOnRight) { TRACED_FORRANGE(int, bit, 0, 31) { uint32_t mask = 1 << bit; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Word32And(m.Parameter(0), m.Int32Constant(mask)), &a, &b); m.Bind(&a); @@ -1064,7 +1113,7 @@ TEST_F(InstructionSelectorTest, Word32AndBranchWithOneBitMaskOnRight) { TRACED_FORRANGE(int, bit, 0, 31) { uint32_t mask = 1 << bit; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch( m.Word32BinaryNot(m.Word32And(m.Parameter(0), m.Int32Constant(mask))), @@ -1087,7 +1136,7 @@ TEST_F(InstructionSelectorTest, Word32AndBranchWithOneBitMaskOnRight) { TEST_F(InstructionSelectorTest, Word32AndBranchWithOneBitMaskOnLeft) { TRACED_FORRANGE(int, bit, 0, 31) { uint32_t mask = 1 << bit; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch(m.Word32And(m.Int32Constant(mask), m.Parameter(0)), &a, &b); m.Bind(&a); @@ -1105,7 +1154,7 @@ TEST_F(InstructionSelectorTest, Word32AndBranchWithOneBitMaskOnLeft) { TRACED_FORRANGE(int, bit, 0, 31) { uint32_t mask = 1 << bit; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; m.Branch( m.Word32BinaryNot(m.Word32And(m.Int32Constant(mask), m.Parameter(0))), @@ -1128,7 +1177,7 @@ TEST_F(InstructionSelectorTest, Word32AndBranchWithOneBitMaskOnLeft) { TEST_F(InstructionSelectorTest, Word64AndBranchWithOneBitMaskOnRight) { TRACED_FORRANGE(int, bit, 0, 63) { uint64_t mask = 1L << bit; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); RawMachineLabel a, b; m.Branch(m.Word64And(m.Parameter(0), m.Int64Constant(mask)), &a, &b); m.Bind(&a); @@ -1149,7 +1198,7 @@ TEST_F(InstructionSelectorTest, Word64AndBranchWithOneBitMaskOnRight) { TEST_F(InstructionSelectorTest, Word64AndBranchWithOneBitMaskOnLeft) { TRACED_FORRANGE(int, bit, 0, 63) { uint64_t mask = 1L << bit; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); RawMachineLabel a, b; m.Branch(m.Word64And(m.Int64Constant(mask), m.Parameter(0)), &a, &b); m.Bind(&a); @@ -1169,7 +1218,7 @@ TEST_F(InstructionSelectorTest, Word64AndBranchWithOneBitMaskOnLeft) { TEST_F(InstructionSelectorTest, CompareAgainstZeroAndBranch) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; Node* p0 = m.Parameter(0); m.Branch(p0, &a, &b); @@ -1186,7 +1235,7 @@ TEST_F(InstructionSelectorTest, CompareAgainstZeroAndBranch) { } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; Node* p0 = m.Parameter(0); m.Branch(m.Word32BinaryNot(p0), &a, &b); @@ -1366,7 +1415,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, OvfFlagAddImmediateOnLeft) { TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 1, m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0)))); Stream s = m.Build(); @@ -1384,7 +1433,7 @@ TEST_F(InstructionSelectorTest, OvfFlagAddImmediateOnLeft) { TEST_F(InstructionSelectorTest, OvfValAddImmediateOnLeft) { TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Projection( 0, m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0)))); Stream s = m.Build(); @@ -1401,7 +1450,7 @@ TEST_F(InstructionSelectorTest, OvfValAddImmediateOnLeft) { TEST_F(InstructionSelectorTest, OvfBothAddImmediateOnLeft) { TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* n = m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0)); m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); Stream s = m.Build(); @@ -1419,7 +1468,7 @@ TEST_F(InstructionSelectorTest, OvfBothAddImmediateOnLeft) { TEST_F(InstructionSelectorTest, OvfBranchWithImmediateOnLeft) { TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); RawMachineLabel a, b; Node* n = m.Int32AddWithOverflow(m.Int32Constant(imm), m.Parameter(0)); m.Branch(m.Projection(1, n), &a, &b); @@ -1463,7 +1512,8 @@ TEST_P(InstructionSelectorShiftTest, Parameter) { TEST_P(InstructionSelectorShiftTest, Immediate) { const Shift shift = GetParam(); const MachineType type = shift.mi.machine_type; - TRACED_FORRANGE(int32_t, imm, 0, (ElementSizeOf(type) * 8) - 1) { + TRACED_FORRANGE(int32_t, imm, 0, + ((1 << ElementSizeLog2Of(type.representation())) * 8) - 1) { StreamBuilder m(this, type, type); m.Return((m.*shift.mi.constructor)(m.Parameter(0), m.Int32Constant(imm))); Stream s = m.Build(); @@ -1483,7 +1533,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorShiftTest, TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) { TRACED_FORRANGE(int64_t, x, 32, 63) { - StreamBuilder m(this, kMachInt64, kMachInt32); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word64Shl(m.ChangeInt32ToInt64(p0), m.Int64Constant(x)); m.Return(n); @@ -1501,7 +1551,7 @@ TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) { TEST_F(InstructionSelectorTest, Word64ShlWithChangeUint32ToUint64) { TRACED_FORRANGE(int64_t, x, 32, 63) { - StreamBuilder m(this, kMachInt64, kMachUint32); + StreamBuilder m(this, MachineType::Int64(), MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word64Shl(m.ChangeUint32ToUint64(p0), m.Int64Constant(x)); m.Return(n); @@ -1518,7 +1568,7 @@ TEST_F(InstructionSelectorTest, Word64ShlWithChangeUint32ToUint64) { TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) { - StreamBuilder m(this, kMachInt32, kMachInt64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int64()); Node* const p = m.Parameter(0); Node* const t = m.TruncateInt64ToInt32(m.Word64Sar(p, m.Int64Constant(32))); m.Return(t); @@ -1535,7 +1585,7 @@ TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) { TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Shr) { TRACED_FORRANGE(int64_t, x, 32, 63) { - StreamBuilder m(this, kMachInt32, kMachInt64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int64()); Node* const p = m.Parameter(0); Node* const t = m.TruncateInt64ToInt32(m.Word64Shr(p, m.Int64Constant(x))); m.Return(t); @@ -1600,10 +1650,10 @@ std::ostream& operator<<(std::ostream& os, const MulDPInst& inst) { static const MulDPInst kMulDPInstructions[] = { {"Int32Mul", &RawMachineAssembler::Int32Mul, &RawMachineAssembler::Int32Add, &RawMachineAssembler::Int32Sub, kArm64Madd32, kArm64Msub32, kArm64Mneg32, - kMachInt32}, + MachineType::Int32()}, {"Int64Mul", &RawMachineAssembler::Int64Mul, &RawMachineAssembler::Int64Add, &RawMachineAssembler::Int64Sub, kArm64Madd, kArm64Msub, kArm64Mneg, - kMachInt64}}; + MachineType::Int64()}}; typedef InstructionSelectorTestWithParam @@ -1688,7 +1738,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { // x * (2^k + 1) -> x + (x << k) TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) + 1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1701,7 +1751,7 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // (2^k + 1) * x -> x + (x << k) TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1714,7 +1764,8 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // x * (2^k + 1) + c -> x + (x << k) + c TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Int32Add(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) + 1)), m.Parameter(1))); @@ -1730,7 +1781,8 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // (2^k + 1) * x + c -> x + (x << k) + c TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Int32Add(m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(0)), m.Parameter(1))); @@ -1746,7 +1798,8 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // c + x * (2^k + 1) -> c + x + (x << k) TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Int32Constant((1 << k) + 1)))); @@ -1762,7 +1815,8 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // c + (2^k + 1) * x -> c + x + (x << k) TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Int32Add(m.Parameter(0), m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(1)))); @@ -1778,7 +1832,8 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // c - x * (2^k + 1) -> c - x + (x << k) TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Int32Constant((1 << k) + 1)))); @@ -1794,7 +1849,8 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { } // c - (2^k + 1) * x -> c - x + (x << k) TRACED_FORRANGE(int32_t, k, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return( m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(1)))); @@ -1814,7 +1870,7 @@ TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { TEST_F(InstructionSelectorTest, Int64MulWithImmediate) { // x * (2^k + 1) -> x + (x << k) TRACED_FORRANGE(int64_t, k, 1, 62) { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Int64Mul(m.Parameter(0), m.Int64Constant((1L << k) + 1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1827,7 +1883,7 @@ TEST_F(InstructionSelectorTest, Int64MulWithImmediate) { } // (2^k + 1) * x -> x + (x << k) TRACED_FORRANGE(int64_t, k, 1, 62) { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Int64Mul(m.Int64Constant((1L << k) + 1), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1840,7 +1896,8 @@ TEST_F(InstructionSelectorTest, Int64MulWithImmediate) { } // x * (2^k + 1) + c -> x + (x << k) + c TRACED_FORRANGE(int64_t, k, 1, 62) { - StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return( m.Int64Add(m.Int64Mul(m.Parameter(0), m.Int64Constant((1L << k) + 1)), m.Parameter(1))); @@ -1856,7 +1913,8 @@ TEST_F(InstructionSelectorTest, Int64MulWithImmediate) { } // (2^k + 1) * x + c -> x + (x << k) + c TRACED_FORRANGE(int64_t, k, 1, 62) { - StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return( m.Int64Add(m.Int64Mul(m.Int64Constant((1L << k) + 1), m.Parameter(0)), m.Parameter(1))); @@ -1872,7 +1930,8 @@ TEST_F(InstructionSelectorTest, Int64MulWithImmediate) { } // c + x * (2^k + 1) -> c + x + (x << k) TRACED_FORRANGE(int64_t, k, 1, 62) { - StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return( m.Int64Add(m.Parameter(0), m.Int64Mul(m.Parameter(1), m.Int64Constant((1L << k) + 1)))); @@ -1888,7 +1947,8 @@ TEST_F(InstructionSelectorTest, Int64MulWithImmediate) { } // c + (2^k + 1) * x -> c + x + (x << k) TRACED_FORRANGE(int64_t, k, 1, 62) { - StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return( m.Int64Add(m.Parameter(0), m.Int64Mul(m.Int64Constant((1L << k) + 1), m.Parameter(1)))); @@ -1904,7 +1964,8 @@ TEST_F(InstructionSelectorTest, Int64MulWithImmediate) { } // c - x * (2^k + 1) -> c - x + (x << k) TRACED_FORRANGE(int64_t, k, 1, 62) { - StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return( m.Int64Sub(m.Parameter(0), m.Int64Mul(m.Parameter(1), m.Int64Constant((1L << k) + 1)))); @@ -1920,7 +1981,8 @@ TEST_F(InstructionSelectorTest, Int64MulWithImmediate) { } // c - (2^k + 1) * x -> c - x + (x << k) TRACED_FORRANGE(int64_t, k, 1, 62) { - StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), + MachineType::Int64()); m.Return( m.Int64Sub(m.Parameter(0), m.Int64Mul(m.Int64Constant((1L << k) + 1), m.Parameter(1)))); @@ -1965,7 +2027,8 @@ typedef InstructionSelectorTestWithParam InstructionSelectorFPCmpTest; TEST_P(InstructionSelectorFPCmpTest, Parameter) { const FPCmp cmp = GetParam(); - StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); + StreamBuilder m(this, MachineType::Int32(), cmp.mi.machine_type, + cmp.mi.machine_type); m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1979,8 +2042,8 @@ TEST_P(InstructionSelectorFPCmpTest, Parameter) { TEST_P(InstructionSelectorFPCmpTest, WithImmediateZeroOnRight) { const FPCmp cmp = GetParam(); - StreamBuilder m(this, kMachInt32, cmp.mi.machine_type); - if (cmp.mi.machine_type == kMachFloat64) { + StreamBuilder m(this, MachineType::Int32(), cmp.mi.machine_type); + if (cmp.mi.machine_type == MachineType::Float64()) { m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Float64Constant(0.0))); } else { m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Float32Constant(0.0f))); @@ -1998,8 +2061,8 @@ TEST_P(InstructionSelectorFPCmpTest, WithImmediateZeroOnRight) { TEST_P(InstructionSelectorFPCmpTest, WithImmediateZeroOnLeft) { const FPCmp cmp = GetParam(); - StreamBuilder m(this, kMachInt32, cmp.mi.machine_type); - if (cmp.mi.machine_type == kMachFloat64) { + StreamBuilder m(this, MachineType::Int32(), cmp.mi.machine_type); + if (cmp.mi.machine_type == MachineType::Float64()) { m.Return((m.*cmp.mi.constructor)(m.Float64Constant(0.0), m.Parameter(0))); } else { m.Return((m.*cmp.mi.constructor)(m.Float32Constant(0.0f), m.Parameter(0))); @@ -2065,52 +2128,52 @@ std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) { static const MemoryAccess kMemoryAccesses[] = { - {kMachInt8, + {MachineType::Int8(), kArm64Ldrsb, kArm64Strb, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 257, 258, 1000, 1001, 2121, 2442, 4093, 4094, 4095}}, - {kMachUint8, + {MachineType::Uint8(), kArm64Ldrb, kArm64Strb, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 257, 258, 1000, 1001, 2121, 2442, 4093, 4094, 4095}}, - {kMachInt16, + {MachineType::Int16(), kArm64Ldrsh, kArm64Strh, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 258, 260, 4096, 4098, 4100, 4242, 6786, 8188, 8190}}, - {kMachUint16, + {MachineType::Uint16(), kArm64Ldrh, kArm64Strh, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 258, 260, 4096, 4098, 4100, 4242, 6786, 8188, 8190}}, - {kMachInt32, + {MachineType::Int32(), kArm64LdrW, kArm64StrW, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 260, 4096, 4100, 8192, 8196, 3276, 3280, 16376, 16380}}, - {kMachUint32, + {MachineType::Uint32(), kArm64LdrW, kArm64StrW, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 260, 4096, 4100, 8192, 8196, 3276, 3280, 16376, 16380}}, - {kMachInt64, + {MachineType::Int64(), kArm64Ldr, kArm64Str, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 264, 4096, 4104, 8192, 8200, 16384, 16392, 32752, 32760}}, - {kMachUint64, + {MachineType::Uint64(), kArm64Ldr, kArm64Str, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 264, 4096, 4104, 8192, 8200, 16384, 16392, 32752, 32760}}, - {kMachFloat32, + {MachineType::Float32(), kArm64LdrS, kArm64StrS, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 260, 4096, 4100, 8192, 8196, 3276, 3280, 16376, 16380}}, - {kMachFloat64, + {MachineType::Float64(), kArm64LdrD, kArm64StrD, {-256, -255, -3, -2, -1, 0, 1, 2, 3, 255, 256, 264, 4096, 4104, 8192, 8200, @@ -2123,7 +2186,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32); + StreamBuilder m(this, memacc.type, MachineType::Pointer(), + MachineType::Int32()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2137,7 +2201,7 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) { const MemoryAccess memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, memacc.type, kMachPtr); + StreamBuilder m(this, memacc.type, MachineType::Pointer()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2153,7 +2217,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + MachineType::Int32(), memacc.type); m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -2169,7 +2234,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) { const MemoryAccess memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + memacc.type); m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -2194,8 +2260,10 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, // Comparison instructions. static const MachInst2 kComparisonInstructions[] = { - {&RawMachineAssembler::Word32Equal, "Word32Equal", kArm64Cmp32, kMachInt32}, - {&RawMachineAssembler::Word64Equal, "Word64Equal", kArm64Cmp, kMachInt64}, + {&RawMachineAssembler::Word32Equal, "Word32Equal", kArm64Cmp32, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Equal, "Word64Equal", kArm64Cmp, + MachineType::Int64()}, }; @@ -2260,7 +2328,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, Word32EqualWithZero) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2272,7 +2340,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) { EXPECT_EQ(kEqual, s[0]->flags_condition()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2288,7 +2356,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) { TEST_F(InstructionSelectorTest, Word64EqualWithZero) { { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Equal(m.Parameter(0), m.Int64Constant(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2300,7 +2368,7 @@ TEST_F(InstructionSelectorTest, Word64EqualWithZero) { EXPECT_EQ(kEqual, s[0]->flags_condition()); } { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Equal(m.Int64Constant(0), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2317,13 +2385,14 @@ TEST_F(InstructionSelectorTest, Word64EqualWithZero) { TEST_F(InstructionSelectorTest, Word32EqualWithWord32Shift) { TRACED_FOREACH(Shift, shift, kShiftInstructions) { // Skip non 32-bit shifts or ror operations. - if (shift.mi.machine_type != kMachInt32 || + if (shift.mi.machine_type != MachineType::Int32() || shift.mi.arch_opcode == kArm64Ror32) { continue; } TRACED_FORRANGE(int32_t, imm, -32, 63) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = (m.*shift.mi.constructor)(p1, m.Int32Constant(imm)); @@ -2339,7 +2408,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithWord32Shift) { ASSERT_EQ(1U, s[0]->OutputCount()); } TRACED_FORRANGE(int32_t, imm, -32, 63) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = (m.*shift.mi.constructor)(p1, m.Int32Constant(imm)); @@ -2360,7 +2430,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithWord32Shift) { TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendByte) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = m.Word32And(p1, m.Int32Constant(0xff)); @@ -2375,7 +2446,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendByte) { ASSERT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = m.Word32And(p1, m.Int32Constant(0xff)); @@ -2394,7 +2466,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendByte) { TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendHalfword) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = m.Word32And(p1, m.Int32Constant(0xffff)); @@ -2409,7 +2482,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendHalfword) { ASSERT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = m.Word32And(p1, m.Int32Constant(0xffff)); @@ -2428,7 +2502,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendHalfword) { TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendByte) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = @@ -2444,7 +2519,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendByte) { ASSERT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = @@ -2464,7 +2540,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendByte) { TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendHalfword) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = @@ -2480,7 +2557,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendHalfword) { ASSERT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = @@ -2500,7 +2578,8 @@ TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendHalfword) { TEST_F(InstructionSelectorTest, Word32EqualZeroWithWord32Equal) { { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); m.Return(m.Word32Equal(m.Word32Equal(p0, p1), m.Int32Constant(0))); @@ -2515,7 +2594,8 @@ TEST_F(InstructionSelectorTest, Word32EqualZeroWithWord32Equal) { EXPECT_EQ(kNotEqual, s[0]->flags_condition()); } { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); m.Return(m.Word32Equal(m.Int32Constant(0), m.Word32Equal(p0, p1))); @@ -2547,19 +2627,19 @@ std::ostream& operator<<(std::ostream& os, const IntegerCmp& cmp) { // ARM64 32-bit integer comparison instructions. const IntegerCmp kIntegerCmpInstructions[] = { {{&RawMachineAssembler::Word32Equal, "Word32Equal", kArm64Cmp32, - kMachInt32}, + MachineType::Int32()}, kEqual}, {{&RawMachineAssembler::Int32LessThan, "Int32LessThan", kArm64Cmp32, - kMachInt32}, + MachineType::Int32()}, kSignedLessThan}, {{&RawMachineAssembler::Int32LessThanOrEqual, "Int32LessThanOrEqual", - kArm64Cmp32, kMachInt32}, + kArm64Cmp32, MachineType::Int32()}, kSignedLessThanOrEqual}, {{&RawMachineAssembler::Uint32LessThan, "Uint32LessThan", kArm64Cmp32, - kMachUint32}, + MachineType::Uint32()}, kUnsignedLessThan}, {{&RawMachineAssembler::Uint32LessThanOrEqual, "Uint32LessThanOrEqual", - kArm64Cmp32, kMachUint32}, + kArm64Cmp32, MachineType::Uint32()}, kUnsignedLessThanOrEqual}}; } // namespace @@ -2570,13 +2650,14 @@ TEST_F(InstructionSelectorTest, Word32CompareNegateWithWord32Shift) { TRACED_FOREACH(Shift, shift, kShiftInstructions) { // Test 32-bit operations. Ignore ROR shifts, as compare-negate does not // support them. - if (shift.mi.machine_type != kMachInt32 || + if (shift.mi.machine_type != MachineType::Int32() || shift.mi.arch_opcode == kArm64Ror32) { continue; } TRACED_FORRANGE(int32_t, imm, -32, 63) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* r = (m.*shift.mi.constructor)(p1, m.Int32Constant(imm)); @@ -2602,12 +2683,18 @@ TEST_F(InstructionSelectorTest, Word32CompareNegateWithWord32Shift) { static const MachInst2 kLogicalWithNotRHSs[] = { - {&RawMachineAssembler::Word32And, "Word32And", kArm64Bic32, kMachInt32}, - {&RawMachineAssembler::Word64And, "Word64And", kArm64Bic, kMachInt64}, - {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Orn32, kMachInt32}, - {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Orn, kMachInt64}, - {&RawMachineAssembler::Word32Xor, "Word32Xor", kArm64Eon32, kMachInt32}, - {&RawMachineAssembler::Word64Xor, "Word64Xor", kArm64Eon, kMachInt64}}; + {&RawMachineAssembler::Word32And, "Word32And", kArm64Bic32, + MachineType::Int32()}, + {&RawMachineAssembler::Word64And, "Word64And", kArm64Bic, + MachineType::Int64()}, + {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Orn32, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Orn, + MachineType::Int64()}, + {&RawMachineAssembler::Word32Xor, "Word32Xor", kArm64Eon32, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Xor, "Word64Xor", kArm64Eon, + MachineType::Int64()}}; typedef InstructionSelectorTestWithParam @@ -2620,11 +2707,11 @@ TEST_P(InstructionSelectorLogicalWithNotRHSTest, Parameter) { // Test cases where RHS is Xor(x, -1). { StreamBuilder m(this, type, type, type); - if (type == kMachInt32) { + if (type == MachineType::Int32()) { m.Return((m.*inst.constructor)( m.Parameter(0), m.Word32Xor(m.Parameter(1), m.Int32Constant(-1)))); } else { - ASSERT_EQ(kMachInt64, type); + ASSERT_EQ(MachineType::Int64(), type); m.Return((m.*inst.constructor)( m.Parameter(0), m.Word64Xor(m.Parameter(1), m.Int64Constant(-1)))); } @@ -2636,11 +2723,11 @@ TEST_P(InstructionSelectorLogicalWithNotRHSTest, Parameter) { } { StreamBuilder m(this, type, type, type); - if (type == kMachInt32) { + if (type == MachineType::Int32()) { m.Return((m.*inst.constructor)( m.Word32Xor(m.Parameter(0), m.Int32Constant(-1)), m.Parameter(1))); } else { - ASSERT_EQ(kMachInt64, type); + ASSERT_EQ(MachineType::Int64(), type); m.Return((m.*inst.constructor)( m.Word64Xor(m.Parameter(0), m.Int64Constant(-1)), m.Parameter(1))); } @@ -2653,11 +2740,11 @@ TEST_P(InstructionSelectorLogicalWithNotRHSTest, Parameter) { // Test cases where RHS is Not(x). { StreamBuilder m(this, type, type, type); - if (type == kMachInt32) { + if (type == MachineType::Int32()) { m.Return( (m.*inst.constructor)(m.Parameter(0), m.Word32Not(m.Parameter(1)))); } else { - ASSERT_EQ(kMachInt64, type); + ASSERT_EQ(MachineType::Int64(), type); m.Return( (m.*inst.constructor)(m.Parameter(0), m.Word64Not(m.Parameter(1)))); } @@ -2669,11 +2756,11 @@ TEST_P(InstructionSelectorLogicalWithNotRHSTest, Parameter) { } { StreamBuilder m(this, type, type, type); - if (type == kMachInt32) { + if (type == MachineType::Int32()) { m.Return( (m.*inst.constructor)(m.Word32Not(m.Parameter(0)), m.Parameter(1))); } else { - ASSERT_EQ(kMachInt64, type); + ASSERT_EQ(MachineType::Int64(), type); m.Return( (m.*inst.constructor)(m.Word64Not(m.Parameter(0)), m.Parameter(1))); } @@ -2692,7 +2779,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, Word32NotWithParameter) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Not(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2703,7 +2790,7 @@ TEST_F(InstructionSelectorTest, Word32NotWithParameter) { TEST_F(InstructionSelectorTest, Word64NotWithParameter) { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Not(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2715,7 +2802,7 @@ TEST_F(InstructionSelectorTest, Word64NotWithParameter) { TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Parameter(0), m.Int32Constant(-1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2724,7 +2811,7 @@ TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Int32Constant(-1), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2737,7 +2824,7 @@ TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { TEST_F(InstructionSelectorTest, Word64XorMinusOneWithParameter) { { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Xor(m.Parameter(0), m.Int64Constant(-1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2746,7 +2833,7 @@ TEST_F(InstructionSelectorTest, Word64XorMinusOneWithParameter) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Xor(m.Int64Constant(-1), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -2766,7 +2853,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediate) { uint32_t jnk = rng()->NextInt(); jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), m.Int32Constant(shift))); Stream s = m.Build(); @@ -2783,7 +2870,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediate) { uint32_t jnk = rng()->NextInt(); jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), m.Int32Constant(shift))); Stream s = m.Build(); @@ -2807,7 +2894,7 @@ TEST_F(InstructionSelectorTest, Word64ShrWithWord64AndWithImmediate) { jnk = (lsb > 0) ? (jnk >> (64 - lsb)) : 0; uint64_t msk = ((V8_UINT64_C(0xffffffffffffffff) >> (64 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Shr(m.Word64And(m.Parameter(0), m.Int64Constant(msk)), m.Int64Constant(shift))); Stream s = m.Build(); @@ -2825,7 +2912,7 @@ TEST_F(InstructionSelectorTest, Word64ShrWithWord64AndWithImmediate) { jnk = (lsb > 0) ? (jnk >> (64 - lsb)) : 0; uint64_t msk = ((V8_UINT64_C(0xffffffffffffffff) >> (64 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Shr(m.Word64And(m.Int64Constant(msk), m.Parameter(0)), m.Int64Constant(shift))); Stream s = m.Build(); @@ -2846,7 +2933,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { int32_t lsb = shift & 0x1f; TRACED_FORRANGE(int32_t, width, 1, 31) { uint32_t msk = (1 << width) - 1; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(msk))); Stream s = m.Build(); @@ -2862,7 +2949,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { int32_t lsb = shift & 0x1f; TRACED_FORRANGE(int32_t, width, 1, 31) { uint32_t msk = (1 << width) - 1; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return( m.Word32And(m.Int32Constant(msk), m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); @@ -2885,7 +2972,7 @@ TEST_F(InstructionSelectorTest, Word64AndWithImmediateWithWord64Shr) { int64_t lsb = shift & 0x3f; TRACED_FORRANGE(int64_t, width, 1, 63) { uint64_t msk = (V8_UINT64_C(1) << width) - 1; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64And(m.Word64Shr(m.Parameter(0), m.Int64Constant(shift)), m.Int64Constant(msk))); Stream s = m.Build(); @@ -2901,7 +2988,7 @@ TEST_F(InstructionSelectorTest, Word64AndWithImmediateWithWord64Shr) { int64_t lsb = shift & 0x3f; TRACED_FORRANGE(int64_t, width, 1, 63) { uint64_t msk = (V8_UINT64_C(1) << width) - 1; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return( m.Word64And(m.Int64Constant(msk), m.Word64Shr(m.Parameter(0), m.Int64Constant(shift)))); @@ -2918,7 +3005,8 @@ TEST_F(InstructionSelectorTest, Word64AndWithImmediateWithWord64Shr) { TEST_F(InstructionSelectorTest, Int32MulHighWithParameters) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Int32MulHigh(p0, p1); @@ -2941,7 +3029,8 @@ TEST_F(InstructionSelectorTest, Int32MulHighWithParameters) { TEST_F(InstructionSelectorTest, Int32MulHighWithSar) { TRACED_FORRANGE(int32_t, shift, -32, 63) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Word32Sar(m.Int32MulHigh(p0, p1), m.Int32Constant(shift)); @@ -2964,7 +3053,8 @@ TEST_F(InstructionSelectorTest, Int32MulHighWithSar) { TEST_F(InstructionSelectorTest, Int32MulHighWithAdd) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const a = m.Int32Add(m.Int32MulHigh(p0, p1), p0); @@ -2997,7 +3087,8 @@ TEST_F(InstructionSelectorTest, Int32MulHighWithAdd) { TEST_F(InstructionSelectorTest, Uint32MulHighWithShr) { TRACED_FORRANGE(int32_t, shift, -32, 63) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = @@ -3022,7 +3113,7 @@ TEST_F(InstructionSelectorTest, Uint32MulHighWithShr) { TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) { TRACED_FORRANGE(int32_t, shift, 1, 31) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(shift)), m.Int32Constant(shift)); @@ -3036,7 +3127,7 @@ TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } TRACED_FORRANGE(int32_t, shift, 1, 31) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(shift + 32)), m.Int32Constant(shift + 64)); @@ -3054,7 +3145,7 @@ TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) { TEST_F(InstructionSelectorTest, Word32ShrWithWord32Shl) { TRACED_FORRANGE(int32_t, shift, 1, 31) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Shr(m.Word32Shl(p0, m.Int32Constant(shift)), m.Int32Constant(shift)); @@ -3068,7 +3159,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32Shl) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } TRACED_FORRANGE(int32_t, shift, 1, 31) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Shr(m.Word32Shl(p0, m.Int32Constant(shift + 32)), m.Int32Constant(shift + 64)); @@ -3086,7 +3177,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32Shl) { TEST_F(InstructionSelectorTest, Word32ShlWithWord32And) { TRACED_FORRANGE(int32_t, shift, 1, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Shl(m.Word32And(p0, m.Int32Constant((1 << (31 - shift)) - 1)), @@ -3101,7 +3192,7 @@ TEST_F(InstructionSelectorTest, Word32ShlWithWord32And) { EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); } TRACED_FORRANGE(int32_t, shift, 0, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Shl(m.Word32And(p0, m.Int32Constant((1 << (31 - shift)) - 1)), @@ -3119,7 +3210,7 @@ TEST_F(InstructionSelectorTest, Word32ShlWithWord32And) { TEST_F(InstructionSelectorTest, Word32Clz) { - StreamBuilder m(this, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32Clz(p0); m.Return(n); @@ -3134,7 +3225,7 @@ TEST_F(InstructionSelectorTest, Word32Clz) { TEST_F(InstructionSelectorTest, Float32Abs) { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Abs(p0); m.Return(n); @@ -3149,7 +3240,7 @@ TEST_F(InstructionSelectorTest, Float32Abs) { TEST_F(InstructionSelectorTest, Float64Abs) { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Abs(p0); m.Return(n); @@ -3164,7 +3255,7 @@ TEST_F(InstructionSelectorTest, Float64Abs) { TEST_F(InstructionSelectorTest, Float64SubWithMinusZero) { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); m.Return(n); @@ -3179,7 +3270,8 @@ TEST_F(InstructionSelectorTest, Float64SubWithMinusZero) { TEST_F(InstructionSelectorTest, Float32Max) { - StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), + MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float32Max(p0, p1); @@ -3197,7 +3289,8 @@ TEST_F(InstructionSelectorTest, Float32Max) { TEST_F(InstructionSelectorTest, Float32Min) { - StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), + MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float32Min(p0, p1); @@ -3215,7 +3308,8 @@ TEST_F(InstructionSelectorTest, Float32Min) { TEST_F(InstructionSelectorTest, Float64Max) { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float64Max(p0, p1); @@ -3233,7 +3327,8 @@ TEST_F(InstructionSelectorTest, Float64Max) { TEST_F(InstructionSelectorTest, Float64Min) { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float64Min(p0, p1); diff --git a/test/unittests/compiler/branch-elimination-unittest.cc b/test/unittests/compiler/branch-elimination-unittest.cc index efa490d7ec..fcd702c428 100644 --- a/test/unittests/compiler/branch-elimination-unittest.cc +++ b/test/unittests/compiler/branch-elimination-unittest.cc @@ -18,7 +18,8 @@ namespace compiler { class BranchEliminationTest : public TypedGraphTest { public: BranchEliminationTest() - : machine_(zone(), kMachPtr, MachineOperatorBuilder::kNoFlags) {} + : machine_(zone(), MachineType::PointerRepresentation(), + MachineOperatorBuilder::kNoFlags) {} MachineOperatorBuilder* machine() { return &machine_; } @@ -54,14 +55,15 @@ TEST_F(BranchEliminationTest, NestedBranchSameTrue) { Node* inner_merge = graph()->NewNode(common()->Merge(2), inner_if_true, inner_if_false); Node* inner_phi = - graph()->NewNode(common()->Phi(kMachInt32, 2), Int32Constant(1), - Int32Constant(2), inner_merge); + graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), + Int32Constant(1), Int32Constant(2), inner_merge); Node* outer_if_false = graph()->NewNode(common()->IfFalse(), outer_branch); Node* outer_merge = graph()->NewNode(common()->Merge(2), inner_merge, outer_if_false); - Node* outer_phi = graph()->NewNode(common()->Phi(kMachInt32, 2), inner_phi, - Int32Constant(3), outer_merge); + Node* outer_phi = + graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), + inner_phi, Int32Constant(3), outer_merge); Node* ret = graph()->NewNode(common()->Return(), outer_phi, graph()->start(), outer_merge); @@ -72,8 +74,8 @@ TEST_F(BranchEliminationTest, NestedBranchSameTrue) { // Outer branch should not be rewritten, the inner branch should be discarded. EXPECT_THAT(outer_branch, IsBranch(condition, graph()->start())); EXPECT_THAT(inner_phi, - IsPhi(kMachInt32, IsInt32Constant(1), IsInt32Constant(2), - IsMerge(outer_if_true, IsDead()))); + IsPhi(MachineRepresentation::kWord32, IsInt32Constant(1), + IsInt32Constant(2), IsMerge(outer_if_true, IsDead()))); } @@ -95,13 +97,14 @@ TEST_F(BranchEliminationTest, NestedBranchSameFalse) { Node* inner_merge = graph()->NewNode(common()->Merge(2), inner_if_true, inner_if_false); Node* inner_phi = - graph()->NewNode(common()->Phi(kMachInt32, 2), Int32Constant(2), - Int32Constant(3), inner_merge); + graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), + Int32Constant(2), Int32Constant(3), inner_merge); Node* outer_merge = graph()->NewNode(common()->Merge(2), outer_if_true, inner_merge); - Node* outer_phi = graph()->NewNode(common()->Phi(kMachInt32, 2), - Int32Constant(1), inner_phi, outer_merge); + Node* outer_phi = + graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), + Int32Constant(1), inner_phi, outer_merge); Node* ret = graph()->NewNode(common()->Return(), outer_phi, graph()->start(), outer_merge); @@ -112,8 +115,8 @@ TEST_F(BranchEliminationTest, NestedBranchSameFalse) { // Outer branch should not be rewritten, the inner branch should be discarded. EXPECT_THAT(outer_branch, IsBranch(condition, graph()->start())); EXPECT_THAT(inner_phi, - IsPhi(kMachInt32, IsInt32Constant(2), IsInt32Constant(3), - IsMerge(IsDead(), outer_if_false))); + IsPhi(MachineRepresentation::kWord32, IsInt32Constant(2), + IsInt32Constant(3), IsMerge(IsDead(), outer_if_false))); } @@ -127,15 +130,17 @@ TEST_F(BranchEliminationTest, BranchAfterDiamond) { Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1); Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1); - Node* phi1 = graph()->NewNode(common()->Phi(kMachInt32, 2), Int32Constant(1), - Int32Constant(2), merge1); + Node* phi1 = + graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), + Int32Constant(1), Int32Constant(2), merge1); Node* branch2 = graph()->NewNode(common()->Branch(), condition, merge1); Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2); Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2); Node* merge2 = graph()->NewNode(common()->Merge(2), if_true2, if_false2); - Node* phi2 = graph()->NewNode(common()->Phi(kMachInt32, 2), Int32Constant(3), - Int32Constant(4), merge1); + Node* phi2 = + graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), + Int32Constant(3), Int32Constant(4), merge1); Node* add = graph()->NewNode(machine()->Int32Add(), phi1, phi2); diff --git a/test/unittests/compiler/change-lowering-unittest.cc b/test/unittests/compiler/change-lowering-unittest.cc index a3e07b6c36..cd6ac5869a 100644 --- a/test/unittests/compiler/change-lowering-unittest.cc +++ b/test/unittests/compiler/change-lowering-unittest.cc @@ -27,11 +27,15 @@ class ChangeLoweringTest : public TypedGraphTest { public: ChangeLoweringTest() : simplified_(zone()) {} - virtual MachineType WordRepresentation() const = 0; + virtual MachineRepresentation WordRepresentation() const = 0; protected: - bool Is32() const { return WordRepresentation() == kRepWord32; } - bool Is64() const { return WordRepresentation() == kRepWord64; } + bool Is32() const { + return WordRepresentation() == MachineRepresentation::kWord32; + } + bool Is64() const { + return WordRepresentation() == MachineRepresentation::kWord64; + } Reduction Reduce(Node* node) { MachineOperatorBuilder machine(zone(), WordRepresentation()); @@ -67,7 +71,7 @@ class ChangeLoweringTest : public TypedGraphTest { } Matcher IsLoadHeapNumber(const Matcher& value_matcher, const Matcher& control_matcher) { - return IsLoad(kMachFloat64, value_matcher, + return IsLoad(MachineType::Float64(), value_matcher, IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), graph()->start(), control_matcher); } @@ -94,11 +98,11 @@ class ChangeLoweringTest : public TypedGraphTest { class ChangeLoweringCommonTest : public ChangeLoweringTest, - public ::testing::WithParamInterface { + public ::testing::WithParamInterface { public: ~ChangeLoweringCommonTest() override {} - MachineType WordRepresentation() const final { return GetParam(); } + MachineRepresentation WordRepresentation() const final { return GetParam(); } }; @@ -107,8 +111,8 @@ TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) { Reduction r = Reduce(graph()->NewNode(simplified()->ChangeBitToBool(), value)); ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsSelect(kMachAnyTagged, value, IsTrueConstant(), - IsFalseConstant())); + EXPECT_THAT(r.replacement(), IsSelect(MachineRepresentation::kTagged, value, + IsTrueConstant(), IsFalseConstant())); } @@ -179,7 +183,8 @@ TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToUint32WithTaggedPointer) { TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) { FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Handle::null(), Type::Any(), kMachAnyTagged}; + Handle::null(), Type::Any(), + MachineType::AnyTagged()}; Node* p0 = Parameter(Type::TaggedPointer()); Node* p1 = Parameter(Type::TaggedSigned()); Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, @@ -187,16 +192,18 @@ TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) { Reduction r = Reduce(store); ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsStore(StoreRepresentation(kMachAnyTagged, kNoWriteBarrier), p0, - IsIntPtrConstant(access.offset - access.tag()), p1, - graph()->start(), graph()->start())); + EXPECT_THAT( + r.replacement(), + IsStore(StoreRepresentation(MachineType::AnyTagged(), kNoWriteBarrier), + p0, IsIntPtrConstant(access.offset - access.tag()), p1, + graph()->start(), graph()->start())); } TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldTagged) { FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Handle::null(), Type::Any(), kMachAnyTagged}; + Handle::null(), Type::Any(), + MachineType::AnyTagged()}; Node* p0 = Parameter(Type::TaggedPointer()); Node* p1 = Parameter(Type::Tagged()); Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, @@ -204,16 +211,18 @@ TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldTagged) { Reduction r = Reduce(store); ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsStore(StoreRepresentation(kMachAnyTagged, kFullWriteBarrier), - p0, IsIntPtrConstant(access.offset - access.tag()), p1, - graph()->start(), graph()->start())); + EXPECT_THAT( + r.replacement(), + IsStore(StoreRepresentation(MachineType::AnyTagged(), kFullWriteBarrier), + p0, IsIntPtrConstant(access.offset - access.tag()), p1, + graph()->start(), graph()->start())); } TARGET_TEST_P(ChangeLoweringCommonTest, LoadField) { FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Handle::null(), Type::Any(), kMachAnyTagged}; + Handle::null(), Type::Any(), + MachineType::AnyTagged()}; Node* p0 = Parameter(Type::TaggedPointer()); Node* load = graph()->NewNode(simplified()->LoadField(access), p0, graph()->start(), graph()->start()); @@ -221,16 +230,16 @@ TARGET_TEST_P(ChangeLoweringCommonTest, LoadField) { ASSERT_TRUE(r.Changed()); Matcher index_match = IsIntPtrConstant(access.offset - access.tag()); - EXPECT_THAT( - r.replacement(), - IsLoad(kMachAnyTagged, p0, IsIntPtrConstant(access.offset - access.tag()), - graph()->start(), graph()->start())); + EXPECT_THAT(r.replacement(), + IsLoad(MachineType::AnyTagged(), p0, + IsIntPtrConstant(access.offset - access.tag()), + graph()->start(), graph()->start())); } TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) { ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachAnyTagged}; + MachineType::AnyTagged()}; Node* p0 = Parameter(Type::TaggedPointer()); Node* p1 = Parameter(Type::Signed32()); Node* p2 = Parameter(Type::Tagged()); @@ -238,7 +247,8 @@ TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) { graph()->start(), graph()->start()); Reduction r = Reduce(store); - const int element_size_shift = ElementSizeLog2Of(access.machine_type); + const int element_size_shift = + ElementSizeLog2Of(access.machine_type.representation()); ASSERT_TRUE(r.Changed()); Matcher index_match = IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)), @@ -247,15 +257,16 @@ TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) { index_match = IsChangeUint32ToUint64(index_match); } - EXPECT_THAT(r.replacement(), - IsStore(StoreRepresentation(kMachAnyTagged, kFullWriteBarrier), - p0, index_match, p2, graph()->start(), graph()->start())); + EXPECT_THAT( + r.replacement(), + IsStore(StoreRepresentation(MachineType::AnyTagged(), kFullWriteBarrier), + p0, index_match, p2, graph()->start(), graph()->start())); } TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementUint8) { ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Type::Signed32(), kMachUint8}; + Type::Signed32(), MachineType::Uint8()}; Node* p0 = Parameter(Type::TaggedPointer()); Node* p1 = Parameter(Type::Signed32()); Node* p2 = Parameter(Type::Signed32()); @@ -270,22 +281,24 @@ TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementUint8) { index_match = IsChangeUint32ToUint64(index_match); } - EXPECT_THAT(r.replacement(), - IsStore(StoreRepresentation(kMachUint8, kNoWriteBarrier), p0, - index_match, p2, graph()->start(), graph()->start())); + EXPECT_THAT( + r.replacement(), + IsStore(StoreRepresentation(MachineType::Uint8(), kNoWriteBarrier), p0, + index_match, p2, graph()->start(), graph()->start())); } TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementTagged) { ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachAnyTagged}; + MachineType::AnyTagged()}; Node* p0 = Parameter(Type::TaggedPointer()); Node* p1 = Parameter(Type::Signed32()); Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1, graph()->start(), graph()->start()); Reduction r = Reduce(load); - const int element_size_shift = ElementSizeLog2Of(access.machine_type); + const int element_size_shift = + ElementSizeLog2Of(access.machine_type.representation()); ASSERT_TRUE(r.Changed()); Matcher index_match = IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)), @@ -294,14 +307,14 @@ TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementTagged) { index_match = IsChangeUint32ToUint64(index_match); } - EXPECT_THAT(r.replacement(), IsLoad(kMachAnyTagged, p0, index_match, + EXPECT_THAT(r.replacement(), IsLoad(MachineType::AnyTagged(), p0, index_match, graph()->start(), graph()->start())); } TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementInt8) { ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Type::Signed32(), kMachInt8}; + Type::Signed32(), MachineType::Int8()}; Node* p0 = Parameter(Type::TaggedPointer()); Node* p1 = Parameter(Type::Signed32()); Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1, @@ -315,7 +328,7 @@ TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementInt8) { index_match = IsChangeUint32ToUint64(index_match); } - EXPECT_THAT(r.replacement(), IsLoad(kMachInt8, p0, index_match, + EXPECT_THAT(r.replacement(), IsLoad(MachineType::Int8(), p0, index_match, graph()->start(), graph()->start())); } @@ -333,7 +346,8 @@ TARGET_TEST_P(ChangeLoweringCommonTest, Allocate) { INSTANTIATE_TEST_CASE_P(ChangeLoweringTest, ChangeLoweringCommonTest, - ::testing::Values(kRepWord32, kRepWord64)); + ::testing::Values(MachineRepresentation::kWord32, + MachineRepresentation::kWord64)); // ----------------------------------------------------------------------------- @@ -343,7 +357,9 @@ INSTANTIATE_TEST_CASE_P(ChangeLoweringTest, ChangeLoweringCommonTest, class ChangeLowering32Test : public ChangeLoweringTest { public: ~ChangeLowering32Test() override {} - MachineType WordRepresentation() const final { return kRepWord32; } + MachineRepresentation WordRepresentation() const final { + return MachineRepresentation::kWord32; + } }; @@ -355,22 +371,23 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { Capture add, branch, heap_number, if_true; EXPECT_THAT( r.replacement(), - IsPhi(kMachAnyTagged, - IsFinishRegion( - AllOf(CaptureEq(&heap_number), - IsAllocateHeapNumber(_, CaptureEq(&if_true))), - IsStore( - StoreRepresentation(kMachFloat64, kNoWriteBarrier), - CaptureEq(&heap_number), - IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), - IsChangeInt32ToFloat64(value), CaptureEq(&heap_number), - CaptureEq(&if_true))), - IsProjection(0, AllOf(CaptureEq(&add), - IsInt32AddWithOverflow(value, value))), - IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), - IsIfFalse(AllOf(CaptureEq(&branch), - IsBranch(IsProjection(1, CaptureEq(&add)), - graph()->start())))))); + IsPhi( + MachineRepresentation::kTagged, + IsFinishRegion( + AllOf(CaptureEq(&heap_number), + IsAllocateHeapNumber(_, CaptureEq(&if_true))), + IsStore( + StoreRepresentation(MachineType::Float64(), kNoWriteBarrier), + CaptureEq(&heap_number), + IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), + IsChangeInt32ToFloat64(value), CaptureEq(&heap_number), + CaptureEq(&if_true))), + IsProjection( + 0, AllOf(CaptureEq(&add), IsInt32AddWithOverflow(value, value))), + IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), + IsIfFalse(AllOf(CaptureEq(&branch), + IsBranch(IsProjection(1, CaptureEq(&add)), + graph()->start())))))); } @@ -385,7 +402,8 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { Capture branch, if_true; EXPECT_THAT( r.replacement(), - IsPhi(kMachFloat64, IsLoadHeapNumber(value, CaptureEq(&if_true)), + IsPhi(MachineRepresentation::kFloat64, + IsLoadHeapNumber(value, CaptureEq(&if_true)), IsChangeInt32ToFloat64(IsWord32Sar( value, IsInt32Constant(kSmiTagSize + kSmiShiftSize))), IsMerge(AllOf(CaptureEq(&if_true), @@ -410,7 +428,7 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToInt32) { EXPECT_THAT( r.replacement(), IsPhi( - kMachInt32, + MachineRepresentation::kWord32, IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))), IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), @@ -433,7 +451,7 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) { EXPECT_THAT( r.replacement(), IsPhi( - kMachUint32, + MachineRepresentation::kWord32, IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))), IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), @@ -456,13 +474,13 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) { EXPECT_THAT( r.replacement(), IsPhi( - kMachAnyTagged, + MachineRepresentation::kTagged, IsWord32Shl(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), IsFinishRegion( AllOf(CaptureEq(&heap_number), IsAllocateHeapNumber(_, CaptureEq(&if_false))), IsStore( - StoreRepresentation(kMachFloat64, kNoWriteBarrier), + StoreRepresentation(MachineType::Float64(), kNoWriteBarrier), CaptureEq(&heap_number), IsInt32Constant(HeapNumber::kValueOffset - kHeapObjectTag), IsChangeUint32ToFloat64(value), CaptureEq(&heap_number), @@ -483,7 +501,9 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) { class ChangeLowering64Test : public ChangeLoweringTest { public: ~ChangeLowering64Test() override {} - MachineType WordRepresentation() const final { return kRepWord64; } + MachineRepresentation WordRepresentation() const final { + return MachineRepresentation::kWord64; + } }; @@ -507,7 +527,8 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) { Capture branch, if_true; EXPECT_THAT( r.replacement(), - IsPhi(kMachFloat64, IsLoadHeapNumber(value, CaptureEq(&if_true)), + IsPhi(MachineRepresentation::kFloat64, + IsLoadHeapNumber(value, CaptureEq(&if_true)), IsChangeInt32ToFloat64(IsTruncateInt64ToInt32(IsWord64Sar( value, IsInt64Constant(kSmiTagSize + kSmiShiftSize)))), IsMerge(AllOf(CaptureEq(&if_true), @@ -532,7 +553,7 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToInt32) { EXPECT_THAT( r.replacement(), IsPhi( - kMachInt32, + MachineRepresentation::kWord32, IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))), IsTruncateInt64ToInt32( IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))), @@ -556,7 +577,7 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) { EXPECT_THAT( r.replacement(), IsPhi( - kMachUint32, + MachineRepresentation::kWord32, IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))), IsTruncateInt64ToInt32( IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))), @@ -580,14 +601,14 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeUint32ToTagged) { EXPECT_THAT( r.replacement(), IsPhi( - kMachAnyTagged, + MachineRepresentation::kTagged, IsWord64Shl(IsChangeUint32ToUint64(value), IsInt64Constant(kSmiTagSize + kSmiShiftSize)), IsFinishRegion( AllOf(CaptureEq(&heap_number), IsAllocateHeapNumber(_, CaptureEq(&if_false))), IsStore( - StoreRepresentation(kMachFloat64, kNoWriteBarrier), + StoreRepresentation(MachineType::Float64(), kNoWriteBarrier), CaptureEq(&heap_number), IsInt64Constant(HeapNumber::kValueOffset - kHeapObjectTag), IsChangeUint32ToFloat64(value), CaptureEq(&heap_number), diff --git a/test/unittests/compiler/common-operator-reducer-unittest.cc b/test/unittests/compiler/common-operator-reducer-unittest.cc index 5aff78cf07..1c163706f2 100644 --- a/test/unittests/compiler/common-operator-reducer-unittest.cc +++ b/test/unittests/compiler/common-operator-reducer-unittest.cc @@ -28,7 +28,8 @@ class CommonOperatorReducerTest : public GraphTest { Reduction Reduce( AdvancedReducer::Editor* editor, Node* node, MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags) { - MachineOperatorBuilder machine(zone(), kMachPtr, flags); + MachineOperatorBuilder machine(zone(), MachineType::PointerRepresentation(), + flags); CommonOperatorReducer reducer(editor, graph(), common(), &machine); return reducer.Reduce(node); } @@ -54,11 +55,11 @@ const BranchHint kBranchHints[] = {BranchHint::kNone, BranchHint::kFalse, BranchHint::kTrue}; -const MachineType kMachineTypes[] = { - kMachFloat32, kMachFloat64, kMachInt8, kMachUint8, kMachInt16, - kMachUint16, kMachInt32, kMachUint32, kMachInt64, kMachUint64, - kMachPtr, kMachAnyTagged, kRepBit, kRepWord8, kRepWord16, - kRepWord32, kRepWord64, kRepFloat32, kRepFloat64, kRepTagged}; +const MachineRepresentation kMachineRepresentations[] = { + MachineRepresentation::kBit, MachineRepresentation::kWord8, + MachineRepresentation::kWord16, MachineRepresentation::kWord32, + MachineRepresentation::kWord64, MachineRepresentation::kFloat32, + MachineRepresentation::kFloat64, MachineRepresentation::kTagged}; const Operator kOp0(0, Operator::kNoProperties, "Op0", 0, 0, 0, 1, 1, 0); @@ -279,7 +280,7 @@ TEST_F(CommonOperatorReducerTest, PhiWithMerge) { Node* const input = graph()->NewNode(&kOp0); TRACED_FORRANGE(int, input_count, 2, kMaxInputs - 1) { int const value_input_count = input_count - 1; - TRACED_FOREACH(MachineType, type, kMachineTypes) { + TRACED_FOREACH(MachineRepresentation, rep, kMachineRepresentations) { for (int i = 0; i < value_input_count; ++i) { inputs[i] = graph()->start(); } @@ -292,7 +293,7 @@ TEST_F(CommonOperatorReducerTest, PhiWithMerge) { StrictMock editor; EXPECT_CALL(editor, Revisit(merge)); Reduction r = Reduce( - &editor, graph()->NewNode(common()->Phi(type, value_input_count), + &editor, graph()->NewNode(common()->Phi(rep, value_input_count), input_count, inputs)); ASSERT_TRUE(r.Changed()); EXPECT_EQ(input, r.replacement()); @@ -306,8 +307,8 @@ TEST_F(CommonOperatorReducerTest, PhiWithLoop) { Node* const loop = graph()->NewNode(common()->Loop(2), graph()->start(), graph()->start()); loop->ReplaceInput(1, loop); - Node* const phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); + Node* const phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), p0, p0, loop); phi->ReplaceInput(1, phi); StrictMock editor; EXPECT_CALL(editor, Revisit(loop)); @@ -327,8 +328,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat32Abs) { Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* vfalse = graph()->NewNode(machine()->Float32Sub(), c0, p0); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = - graph()->NewNode(common()->Phi(kMachFloat32, 2), vtrue, vfalse, merge); + Node* phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kFloat32, 2), vtrue, vfalse, merge); StrictMock editor; EXPECT_CALL(editor, Revisit(merge)); Reduction r = Reduce(&editor, phi); @@ -347,8 +348,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat64Abs) { Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* vfalse = graph()->NewNode(machine()->Float64Sub(), c0, p0); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = - graph()->NewNode(common()->Phi(kMachFloat64, 2), vtrue, vfalse, merge); + Node* phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kFloat64, 2), vtrue, vfalse, merge); StrictMock editor; EXPECT_CALL(editor, Revisit(merge)); Reduction r = Reduce(&editor, phi); @@ -365,7 +366,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat32Max) { Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = graph()->NewNode(common()->Phi(kMachFloat32, 2), p1, p0, merge); + Node* phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kFloat32, 2), p1, p0, merge); StrictMock editor; EXPECT_CALL(editor, Revisit(merge)); Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat32Max); @@ -382,7 +384,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat64Max) { Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p1, p0, merge); + Node* phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kFloat64, 2), p1, p0, merge); StrictMock editor; EXPECT_CALL(editor, Revisit(merge)); Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat64Max); @@ -399,7 +402,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat32Min) { Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = graph()->NewNode(common()->Phi(kMachFloat32, 2), p0, p1, merge); + Node* phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kFloat32, 2), p0, p1, merge); StrictMock editor; EXPECT_CALL(editor, Revisit(merge)); Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat32Min); @@ -416,7 +420,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat64Min) { Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); - Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p1, merge); + Node* phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kFloat64, 2), p0, p1, merge); StrictMock editor; EXPECT_CALL(editor, Revisit(merge)); Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat64Min); @@ -440,8 +445,8 @@ TEST_F(CommonOperatorReducerTest, ReturnWithPhiAndEffectPhiAndMerge) { Node* vfalse = Parameter(1); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); - Node* phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vtrue, vfalse, merge); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + vtrue, vfalse, merge); Node* ret = graph()->NewNode(common()->Return(), phi, ephi, merge); graph()->SetEnd(graph()->NewNode(common()->End(1), ret)); StrictMock editor; @@ -461,9 +466,9 @@ TEST_F(CommonOperatorReducerTest, ReturnWithPhiAndEffectPhiAndMerge) { TEST_F(CommonOperatorReducerTest, SelectWithSameThenAndElse) { Node* const input = graph()->NewNode(&kOp0); TRACED_FOREACH(BranchHint, hint, kBranchHints) { - TRACED_FOREACH(MachineType, type, kMachineTypes) { + TRACED_FOREACH(MachineRepresentation, rep, kMachineRepresentations) { Reduction r = Reduce( - graph()->NewNode(common()->Select(type, hint), input, input, input)); + graph()->NewNode(common()->Select(rep, hint), input, input, input)); ASSERT_TRUE(r.Changed()); EXPECT_EQ(input, r.replacement()); } @@ -474,8 +479,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithSameThenAndElse) { TEST_F(CommonOperatorReducerTest, SelectWithInt32ZeroConstant) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); - Node* select = graph()->NewNode(common()->Select(kMachAnyTagged), - Int32Constant(0), p0, p1); + Node* select = + graph()->NewNode(common()->Select(MachineRepresentation::kTagged), + Int32Constant(0), p0, p1); Reduction r = Reduce(select); ASSERT_TRUE(r.Changed()); EXPECT_EQ(p1, r.replacement()); @@ -485,8 +491,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithInt32ZeroConstant) { TEST_F(CommonOperatorReducerTest, SelectWithInt32OneConstant) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); - Node* select = graph()->NewNode(common()->Select(kMachAnyTagged), - Int32Constant(1), p0, p1); + Node* select = + graph()->NewNode(common()->Select(MachineRepresentation::kTagged), + Int32Constant(1), p0, p1); Reduction r = Reduce(select); ASSERT_TRUE(r.Changed()); EXPECT_EQ(p0, r.replacement()); @@ -496,8 +503,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithInt32OneConstant) { TEST_F(CommonOperatorReducerTest, SelectWithInt64ZeroConstant) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); - Node* select = graph()->NewNode(common()->Select(kMachAnyTagged), - Int64Constant(0), p0, p1); + Node* select = + graph()->NewNode(common()->Select(MachineRepresentation::kTagged), + Int64Constant(0), p0, p1); Reduction r = Reduce(select); ASSERT_TRUE(r.Changed()); EXPECT_EQ(p1, r.replacement()); @@ -507,8 +515,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithInt64ZeroConstant) { TEST_F(CommonOperatorReducerTest, SelectWithInt64OneConstant) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); - Node* select = graph()->NewNode(common()->Select(kMachAnyTagged), - Int64Constant(1), p0, p1); + Node* select = + graph()->NewNode(common()->Select(MachineRepresentation::kTagged), + Int64Constant(1), p0, p1); Reduction r = Reduce(select); ASSERT_TRUE(r.Changed()); EXPECT_EQ(p0, r.replacement()); @@ -518,8 +527,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithInt64OneConstant) { TEST_F(CommonOperatorReducerTest, SelectWithFalseConstant) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); - Node* select = graph()->NewNode(common()->Select(kMachAnyTagged), - FalseConstant(), p0, p1); + Node* select = + graph()->NewNode(common()->Select(MachineRepresentation::kTagged), + FalseConstant(), p0, p1); Reduction r = Reduce(select); ASSERT_TRUE(r.Changed()); EXPECT_EQ(p1, r.replacement()); @@ -529,8 +539,8 @@ TEST_F(CommonOperatorReducerTest, SelectWithFalseConstant) { TEST_F(CommonOperatorReducerTest, SelectWithTrueConstant) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); - Node* select = graph()->NewNode(common()->Select(kMachAnyTagged), - TrueConstant(), p0, p1); + Node* select = graph()->NewNode( + common()->Select(MachineRepresentation::kTagged), TrueConstant(), p0, p1); Reduction r = Reduce(select); ASSERT_TRUE(r.Changed()); EXPECT_EQ(p0, r.replacement()); @@ -542,8 +552,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat32Abs) { Node* c0 = Float32Constant(0.0); Node* check = graph()->NewNode(machine()->Float32LessThan(), c0, p0); Node* select = - graph()->NewNode(common()->Select(kMachFloat32), check, p0, - graph()->NewNode(machine()->Float32Sub(), c0, p0)); + graph()->NewNode(common()->Select(MachineRepresentation::kFloat32), check, + p0, graph()->NewNode(machine()->Float32Sub(), c0, p0)); Reduction r = Reduce(select); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsFloat32Abs(p0)); @@ -555,8 +565,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Abs) { Node* c0 = Float64Constant(0.0); Node* check = graph()->NewNode(machine()->Float64LessThan(), c0, p0); Node* select = - graph()->NewNode(common()->Select(kMachFloat64), check, p0, - graph()->NewNode(machine()->Float64Sub(), c0, p0)); + graph()->NewNode(common()->Select(MachineRepresentation::kFloat64), check, + p0, graph()->NewNode(machine()->Float64Sub(), c0, p0)); Reduction r = Reduce(select); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsFloat64Abs(p0)); @@ -567,8 +577,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat32Max) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); Node* check = graph()->NewNode(machine()->Float32LessThan(), p0, p1); - Node* select = - graph()->NewNode(common()->Select(kMachFloat32), check, p1, p0); + Node* select = graph()->NewNode( + common()->Select(MachineRepresentation::kFloat32), check, p1, p0); Reduction r = Reduce(select, MachineOperatorBuilder::kFloat32Max); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsFloat32Max(p1, p0)); @@ -579,8 +589,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Max) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); Node* check = graph()->NewNode(machine()->Float64LessThan(), p0, p1); - Node* select = - graph()->NewNode(common()->Select(kMachFloat64), check, p1, p0); + Node* select = graph()->NewNode( + common()->Select(MachineRepresentation::kFloat64), check, p1, p0); Reduction r = Reduce(select, MachineOperatorBuilder::kFloat64Max); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsFloat64Max(p1, p0)); @@ -591,8 +601,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat32Min) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); Node* check = graph()->NewNode(machine()->Float32LessThan(), p0, p1); - Node* select = - graph()->NewNode(common()->Select(kMachFloat32), check, p0, p1); + Node* select = graph()->NewNode( + common()->Select(MachineRepresentation::kFloat32), check, p0, p1); Reduction r = Reduce(select, MachineOperatorBuilder::kFloat32Min); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsFloat32Min(p0, p1)); @@ -603,8 +613,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Min) { Node* p0 = Parameter(0); Node* p1 = Parameter(1); Node* check = graph()->NewNode(machine()->Float64LessThan(), p0, p1); - Node* select = - graph()->NewNode(common()->Select(kMachFloat64), check, p0, p1); + Node* select = graph()->NewNode( + common()->Select(MachineRepresentation::kFloat64), check, p0, p1); Reduction r = Reduce(select, MachineOperatorBuilder::kFloat64Min); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1)); diff --git a/test/unittests/compiler/common-operator-unittest.cc b/test/unittests/compiler/common-operator-unittest.cc index 64c5f73d27..0a55a2e2a2 100644 --- a/test/unittests/compiler/common-operator-unittest.cc +++ b/test/unittests/compiler/common-operator-unittest.cc @@ -272,16 +272,19 @@ TEST_F(CommonOperatorTest, IfValue) { TEST_F(CommonOperatorTest, Select) { - static const MachineType kTypes[] = { - kMachInt8, kMachUint8, kMachInt16, kMachUint16, - kMachInt32, kMachUint32, kMachInt64, kMachUint64, - kMachFloat32, kMachFloat64, kMachAnyTagged}; - TRACED_FOREACH(MachineType, type, kTypes) { + static const MachineRepresentation kMachineRepresentations[] = { + MachineRepresentation::kBit, MachineRepresentation::kWord8, + MachineRepresentation::kWord16, MachineRepresentation::kWord32, + MachineRepresentation::kWord64, MachineRepresentation::kFloat32, + MachineRepresentation::kFloat64, MachineRepresentation::kTagged}; + + + TRACED_FOREACH(MachineRepresentation, rep, kMachineRepresentations) { TRACED_FOREACH(BranchHint, hint, kBranchHints) { - const Operator* const op = common()->Select(type, hint); + const Operator* const op = common()->Select(rep, hint); EXPECT_EQ(IrOpcode::kSelect, op->opcode()); EXPECT_EQ(Operator::kPure, op->properties()); - EXPECT_EQ(type, SelectParametersOf(op).type()); + EXPECT_EQ(rep, SelectParametersOf(op).representation()); EXPECT_EQ(hint, SelectParametersOf(op).hint()); EXPECT_EQ(3, op->ValueInputCount()); EXPECT_EQ(0, op->EffectInputCount()); diff --git a/test/unittests/compiler/control-flow-optimizer-unittest.cc b/test/unittests/compiler/control-flow-optimizer-unittest.cc index 444f5f5fee..a5a3c74be2 100644 --- a/test/unittests/compiler/control-flow-optimizer-unittest.cc +++ b/test/unittests/compiler/control-flow-optimizer-unittest.cc @@ -105,8 +105,8 @@ TEST_F(ControlFlowOptimizerTest, CloneBranch) { Node* control1 = graph()->NewNode(common()->IfTrue(), branch0); Node* control2 = graph()->NewNode(common()->IfFalse(), branch0); Node* merge0 = graph()->NewNode(common()->Merge(2), control1, control2); - Node* phi0 = - graph()->NewNode(common()->Phi(kRepBit, 2), cond1, cond2, merge0); + Node* phi0 = graph()->NewNode(common()->Phi(MachineRepresentation::kBit, 2), + cond1, cond2, merge0); Node* branch = graph()->NewNode(common()->Branch(), phi0, merge0); Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); diff --git a/test/unittests/compiler/dead-code-elimination-unittest.cc b/test/unittests/compiler/dead-code-elimination-unittest.cc index 8284fd8775..df93f25302 100644 --- a/test/unittests/compiler/dead-code-elimination-unittest.cc +++ b/test/unittests/compiler/dead-code-elimination-unittest.cc @@ -36,11 +36,11 @@ class DeadCodeEliminationTest : public GraphTest { namespace { -const MachineType kMachineTypes[] = { - kMachFloat32, kMachFloat64, kMachInt8, kMachUint8, kMachInt16, - kMachUint16, kMachInt32, kMachUint32, kMachInt64, kMachUint64, - kMachPtr, kMachAnyTagged, kRepBit, kRepWord8, kRepWord16, - kRepWord32, kRepWord64, kRepFloat32, kRepFloat64, kRepTagged}; +const MachineRepresentation kMachineRepresentations[] = { + MachineRepresentation::kBit, MachineRepresentation::kWord8, + MachineRepresentation::kWord16, MachineRepresentation::kWord32, + MachineRepresentation::kWord64, MachineRepresentation::kFloat32, + MachineRepresentation::kFloat64, MachineRepresentation::kTagged}; const int kMaxInputs = 16; @@ -190,8 +190,8 @@ TEST_F(DeadCodeEliminationTest, MergeWithOneLiveAndOneDeadInput) { Node* const e0 = graph()->NewNode(&kOp0, v0, graph()->start(), c0); Node* const e1 = graph()->NewNode(&kOp0, v1, graph()->start(), c1); Node* const merge = graph()->NewNode(common()->Merge(2), c0, c1); - Node* const phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), v0, v1, merge); + Node* const phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), v0, v1, merge); Node* const ephi = graph()->NewNode(common()->EffectPhi(2), e0, e1, merge); StrictMock editor; EXPECT_CALL(editor, Replace(phi, v0)); @@ -217,8 +217,8 @@ TEST_F(DeadCodeEliminationTest, MergeWithTwoLiveAndTwoDeadInputs) { Node* const e2 = graph()->NewNode(&kOp0, v2, e1, c0); Node* const e3 = graph()->NewNode(&kOp0, v3, graph()->start(), c3); Node* const merge = graph()->NewNode(common()->Merge(4), c0, c1, c2, c3); - Node* const phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 4), v0, v1, v2, v3, merge); + Node* const phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 4), v0, v1, v2, v3, merge); Node* const ephi = graph()->NewNode(common()->EffectPhi(4), e0, e1, e2, e3, merge); StrictMock editor; @@ -227,7 +227,8 @@ TEST_F(DeadCodeEliminationTest, MergeWithTwoLiveAndTwoDeadInputs) { Reduction const r = Reduce(&editor, merge); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsMerge(c0, c3)); - EXPECT_THAT(phi, IsPhi(kMachAnyTagged, v0, v3, r.replacement())); + EXPECT_THAT(phi, + IsPhi(MachineRepresentation::kTagged, v0, v3, r.replacement())); EXPECT_THAT(ephi, IsEffectPhi(e0, e3, r.replacement())); } @@ -274,8 +275,8 @@ TEST_F(DeadCodeEliminationTest, LoopWithOneLiveAndOneDeadInput) { Node* const e0 = graph()->NewNode(&kOp0, v0, graph()->start(), c0); Node* const e1 = graph()->NewNode(&kOp0, v1, graph()->start(), c1); Node* const loop = graph()->NewNode(common()->Loop(2), c0, c1); - Node* const phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), v0, v1, loop); + Node* const phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), v0, v1, loop); Node* const ephi = graph()->NewNode(common()->EffectPhi(2), e0, e1, loop); Node* const terminate = graph()->NewNode(common()->Terminate(), ephi, loop); StrictMock editor; @@ -303,8 +304,8 @@ TEST_F(DeadCodeEliminationTest, LoopWithTwoLiveAndTwoDeadInputs) { Node* const e2 = graph()->NewNode(&kOp0, v2, e1, c0); Node* const e3 = graph()->NewNode(&kOp0, v3, graph()->start(), c3); Node* const loop = graph()->NewNode(common()->Loop(4), c0, c1, c2, c3); - Node* const phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 4), v0, v1, v2, v3, loop); + Node* const phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 4), v0, v1, v2, v3, loop); Node* const ephi = graph()->NewNode(common()->EffectPhi(4), e0, e1, e2, e3, loop); StrictMock editor; @@ -313,7 +314,8 @@ TEST_F(DeadCodeEliminationTest, LoopWithTwoLiveAndTwoDeadInputs) { Reduction const r = Reduce(&editor, loop); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsLoop(c0, c3)); - EXPECT_THAT(phi, IsPhi(kMachAnyTagged, v0, v3, r.replacement())); + EXPECT_THAT(phi, + IsPhi(MachineRepresentation::kTagged, v0, v3, r.replacement())); EXPECT_THAT(ephi, IsEffectPhi(e0, e3, r.replacement())); } @@ -324,14 +326,14 @@ TEST_F(DeadCodeEliminationTest, LoopWithTwoLiveAndTwoDeadInputs) { TEST_F(DeadCodeEliminationTest, PhiWithDeadControlInput) { Node* inputs[kMaxInputs + 1]; - TRACED_FOREACH(MachineType, type, kMachineTypes) { + TRACED_FOREACH(MachineRepresentation, rep, kMachineRepresentations) { TRACED_FORRANGE(int, input_count, 1, kMaxInputs) { for (int i = 0; i < input_count; ++i) { inputs[i] = Parameter(i); } inputs[input_count] = graph()->NewNode(common()->Dead()); Reduction const r = Reduce(graph()->NewNode( - common()->Phi(type, input_count), input_count + 1, inputs)); + common()->Phi(rep, input_count), input_count + 1, inputs)); ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), IsDead()); } diff --git a/test/unittests/compiler/diamond-unittest.cc b/test/unittests/compiler/diamond-unittest.cc index 50c50d4e69..5b28a001ef 100644 --- a/test/unittests/compiler/diamond-unittest.cc +++ b/test/unittests/compiler/diamond-unittest.cc @@ -114,7 +114,8 @@ TEST_F(DiamondTest, DiamondPhis) { Node* p2 = Parameter(2); Diamond d(graph(), common(), p0); - MachineType types[] = {kMachAnyTagged, kMachUint32, kMachInt32}; + MachineRepresentation types[] = {MachineRepresentation::kTagged, + MachineRepresentation::kWord32}; for (size_t i = 0; i < arraysize(types); i++) { Node* phi = d.Phi(types[i], p1, p2); diff --git a/test/unittests/compiler/escape-analysis-unittest.cc b/test/unittests/compiler/escape-analysis-unittest.cc index fd84d72f31..17e0da44c9 100644 --- a/test/unittests/compiler/escape-analysis-unittest.cc +++ b/test/unittests/compiler/escape-analysis-unittest.cc @@ -133,7 +133,7 @@ class EscapeAnalysisTest : public GraphTest { FieldAccess AccessAtIndex(int offset) { FieldAccess access = {kTaggedBase, offset, MaybeHandle(), Type::Any(), - kMachAnyTagged}; + MachineType::AnyTagged()}; return access; } diff --git a/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc b/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc index 1e07d7a41b..92795c1bd4 100644 --- a/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc +++ b/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc @@ -19,7 +19,8 @@ const int32_t kImmediates[] = {kMinInt, -42, -1, 0, 1, 2, TEST_F(InstructionSelectorTest, Int32AddWithParameter) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Add(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -30,7 +31,7 @@ TEST_F(InstructionSelectorTest, Int32AddWithParameter) { TEST_F(InstructionSelectorTest, Int32AddWithImmediate) { TRACED_FOREACH(int32_t, imm, kImmediates) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Parameter(0), m.Int32Constant(imm))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -43,7 +44,7 @@ TEST_F(InstructionSelectorTest, Int32AddWithImmediate) { } } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Add(m.Int32Constant(imm), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -60,7 +61,8 @@ TEST_F(InstructionSelectorTest, Int32AddWithImmediate) { TEST_F(InstructionSelectorTest, Int32SubWithParameter) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); m.Return(m.Int32Sub(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -71,7 +73,7 @@ TEST_F(InstructionSelectorTest, Int32SubWithParameter) { TEST_F(InstructionSelectorTest, Int32SubWithImmediate) { TRACED_FOREACH(int32_t, imm, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(imm))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -87,7 +89,7 @@ TEST_F(InstructionSelectorTest, Int32SubWithImmediate) { TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { - StreamBuilder m(this, kMachFloat32, kMachFloat64); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float64()); m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -98,7 +100,7 @@ TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) { - StreamBuilder m(this, kMachFloat64, kMachFloat32); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float32()); m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -113,7 +115,8 @@ TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) { TEST_F(InstructionSelectorTest, BetterLeftOperandTestAddBinop) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* param1 = m.Parameter(0); Node* param2 = m.Parameter(1); Node* add = m.Int32Add(param1, param2); @@ -131,7 +134,8 @@ TEST_F(InstructionSelectorTest, BetterLeftOperandTestAddBinop) { TEST_F(InstructionSelectorTest, BetterLeftOperandTestMulBinop) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* param1 = m.Parameter(0); Node* param2 = m.Parameter(1); Node* mul = m.Int32Mul(param1, param2); @@ -151,7 +155,7 @@ TEST_F(InstructionSelectorTest, BetterLeftOperandTestMulBinop) { TEST_F(InstructionSelectorTest, ChangeUint32ToFloat64WithParameter) { - StreamBuilder m(this, kMachFloat64, kMachUint32); + StreamBuilder m(this, MachineType::Float64(), MachineType::Uint32()); m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -178,14 +182,14 @@ std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) { static const MemoryAccess kMemoryAccesses[] = { - {kMachInt8, kIA32Movsxbl, kIA32Movb}, - {kMachUint8, kIA32Movzxbl, kIA32Movb}, - {kMachInt16, kIA32Movsxwl, kIA32Movw}, - {kMachUint16, kIA32Movzxwl, kIA32Movw}, - {kMachInt32, kIA32Movl, kIA32Movl}, - {kMachUint32, kIA32Movl, kIA32Movl}, - {kMachFloat32, kIA32Movss, kIA32Movss}, - {kMachFloat64, kIA32Movsd, kIA32Movsd}}; + {MachineType::Int8(), kIA32Movsxbl, kIA32Movb}, + {MachineType::Uint8(), kIA32Movzxbl, kIA32Movb}, + {MachineType::Int16(), kIA32Movsxwl, kIA32Movw}, + {MachineType::Uint16(), kIA32Movzxwl, kIA32Movw}, + {MachineType::Int32(), kIA32Movl, kIA32Movl}, + {MachineType::Uint32(), kIA32Movl, kIA32Movl}, + {MachineType::Float32(), kIA32Movss, kIA32Movss}, + {MachineType::Float64(), kIA32Movsd, kIA32Movsd}}; } // namespace @@ -196,7 +200,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32); + StreamBuilder m(this, memacc.type, MachineType::Pointer(), + MachineType::Int32()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -209,7 +214,7 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateBase) { const MemoryAccess memacc = GetParam(); TRACED_FOREACH(int32_t, base, kImmediates) { - StreamBuilder m(this, memacc.type, kMachPtr); + StreamBuilder m(this, memacc.type, MachineType::Pointer()); m.Return(m.Load(memacc.type, m.Int32Constant(base), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -229,7 +234,7 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateBase) { TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) { const MemoryAccess memacc = GetParam(); TRACED_FOREACH(int32_t, index, kImmediates) { - StreamBuilder m(this, memacc.type, kMachPtr); + StreamBuilder m(this, memacc.type, MachineType::Pointer()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -248,7 +253,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + MachineType::Int32(), memacc.type); m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -263,7 +269,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateBase) { const MemoryAccess memacc = GetParam(); TRACED_FOREACH(int32_t, base, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachInt32, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + memacc.type); m.Store(memacc.type, m.Int32Constant(base), m.Parameter(0), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -285,7 +292,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateBase) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) { const MemoryAccess memacc = GetParam(); TRACED_FOREACH(int32_t, index, kImmediates) { - StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + memacc.type); m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -320,8 +328,8 @@ class AddressingModeUnitTest : public InstructionSelectorTest { void Run(Node* base, Node* load_index, Node* store_index, AddressingMode mode) { - Node* load = m->Load(kMachInt32, base, load_index); - m->Store(kMachInt32, base, store_index, load, kNoWriteBarrier); + Node* load = m->Load(MachineType::Int32(), base, load_index); + m->Store(MachineType::Int32(), base, store_index, load, kNoWriteBarrier); m->Return(m->Int32Constant(0)); Stream s = m->Build(); ASSERT_EQ(2U, s.size()); @@ -339,7 +347,8 @@ class AddressingModeUnitTest : public InstructionSelectorTest { void Reset() { delete m; - m = new StreamBuilder(this, kMachInt32, kMachInt32, kMachInt32); + m = new StreamBuilder(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); zero = m->Int32Constant(0); null_ptr = m->Int32Constant(0); non_zero = m->Int32Constant(127); @@ -565,7 +574,7 @@ static AddressingMode AddressingModeForAddMult(int32_t imm, TEST_P(InstructionSelectorMultTest, Mult32) { const MultParam m_param = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* param = m.Parameter(0); Node* mult = m.Int32Mul(param, m.Int32Constant(m_param.value)); m.Return(mult); @@ -586,7 +595,7 @@ TEST_P(InstructionSelectorMultTest, Mult32) { TEST_P(InstructionSelectorMultTest, MultAdd32) { TRACED_FOREACH(int32_t, imm, kImmediates) { const MultParam m_param = GetParam(); - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* param = m.Parameter(0); Node* mult = m.Int32Add(m.Int32Mul(param, m.Int32Constant(m_param.value)), m.Int32Constant(imm)); @@ -618,7 +627,8 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorMultTest, TEST_F(InstructionSelectorTest, Int32MulHigh) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Int32MulHigh(p0, p1); @@ -643,7 +653,7 @@ TEST_F(InstructionSelectorTest, Int32MulHigh) { TEST_F(InstructionSelectorTest, Float32Abs) { { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Abs(p0); m.Return(n); @@ -658,7 +668,7 @@ TEST_F(InstructionSelectorTest, Float32Abs) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Abs(p0); m.Return(n); @@ -676,7 +686,7 @@ TEST_F(InstructionSelectorTest, Float32Abs) { TEST_F(InstructionSelectorTest, Float64Abs) { { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Abs(p0); m.Return(n); @@ -691,7 +701,7 @@ TEST_F(InstructionSelectorTest, Float64Abs) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Abs(p0); m.Return(n); @@ -709,7 +719,8 @@ TEST_F(InstructionSelectorTest, Float64Abs) { TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); Node* mul = m.Float64Mul(add, m.Parameter(1)); Node* sub = m.Float64Sub(mul, add); @@ -723,7 +734,8 @@ TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { EXPECT_EQ(kAVXFloat64Div, s[3]->arch_opcode()); } { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); Node* mul = m.Float64Mul(add, m.Parameter(1)); Node* sub = m.Float64Sub(mul, add); @@ -741,7 +753,7 @@ TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); m.Return(n); @@ -755,7 +767,7 @@ TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); m.Return(n); @@ -773,7 +785,7 @@ TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); m.Return(n); @@ -787,7 +799,7 @@ TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); m.Return(n); @@ -808,9 +820,9 @@ TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { TEST_F(InstructionSelectorTest, Uint32LessThanWithLoadAndLoadStackPointer) { - StreamBuilder m(this, kMachBool); + StreamBuilder m(this, MachineType::Bool()); Node* const sl = m.Load( - kMachPtr, + MachineType::Pointer(), m.ExternalConstant(ExternalReference::address_of_stack_limit(isolate()))); Node* const sp = m.LoadStackPointer(); Node* const n = m.Uint32LessThan(sl, sp); @@ -827,7 +839,7 @@ TEST_F(InstructionSelectorTest, Uint32LessThanWithLoadAndLoadStackPointer) { TEST_F(InstructionSelectorTest, Word32Clz) { - StreamBuilder m(this, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32Clz(p0); m.Return(n); diff --git a/test/unittests/compiler/instruction-selector-unittest.cc b/test/unittests/compiler/instruction-selector-unittest.cc index 2ca71b8530..89c0a654e9 100644 --- a/test/unittests/compiler/instruction-selector-unittest.cc +++ b/test/unittests/compiler/instruction-selector-unittest.cc @@ -158,7 +158,7 @@ InstructionSelectorTest::StreamBuilder::GetFrameStateFunctionInfo( TARGET_TEST_F(InstructionSelectorTest, ReturnFloat32Constant) { const float kValue = 4.2f; - StreamBuilder m(this, kMachFloat32); + StreamBuilder m(this, MachineType::Float32()); m.Return(m.Float32Constant(kValue)); Stream s = m.Build(kAllInstructions); ASSERT_EQ(3U, s.size()); @@ -171,7 +171,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReturnFloat32Constant) { TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Parameter(0)); Stream s = m.Build(kAllInstructions); ASSERT_EQ(3U, s.size()); @@ -183,7 +183,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) { TARGET_TEST_F(InstructionSelectorTest, ReturnZero) { - StreamBuilder m(this, kMachInt32); + StreamBuilder m(this, MachineType::Int32()); m.Return(m.Int32Constant(0)); Stream s = m.Build(kAllInstructions); ASSERT_EQ(3U, s.size()); @@ -201,7 +201,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReturnZero) { TARGET_TEST_F(InstructionSelectorTest, TruncateFloat64ToInt32WithParameter) { - StreamBuilder m(this, kMachInt32, kMachFloat64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float64()); m.Return( m.TruncateFloat64ToInt32(TruncationMode::kJavaScript, m.Parameter(0))); Stream s = m.Build(kAllInstructions); @@ -219,7 +219,7 @@ TARGET_TEST_F(InstructionSelectorTest, TruncateFloat64ToInt32WithParameter) { TARGET_TEST_F(InstructionSelectorTest, DoubleParameter) { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* param = m.Parameter(0); m.Return(param); Stream s = m.Build(kAllInstructions); @@ -228,7 +228,7 @@ TARGET_TEST_F(InstructionSelectorTest, DoubleParameter) { TARGET_TEST_F(InstructionSelectorTest, ReferenceParameter) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged()); Node* param = m.Parameter(0); m.Return(param); Stream s = m.Build(kAllInstructions); @@ -241,7 +241,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReferenceParameter) { TARGET_TEST_F(InstructionSelectorTest, FinishRegion) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged()); Node* param = m.Parameter(0); Node* finish = m.AddNode(m.common()->FinishRegion(), param, m.graph()->start()); @@ -284,7 +284,7 @@ TARGET_TEST_P(InstructionSelectorPhiTest, Doubleness) { m.Bind(&b); m.Goto(&c); m.Bind(&c); - Node* phi = m.Phi(type, param0, param1); + Node* phi = m.Phi(type.representation(), param0, param1); m.Return(phi); Stream s = m.Build(kAllInstructions); EXPECT_EQ(s.IsDouble(phi), s.IsDouble(param0)); @@ -304,7 +304,7 @@ TARGET_TEST_P(InstructionSelectorPhiTest, Referenceness) { m.Bind(&b); m.Goto(&c); m.Bind(&c); - Node* phi = m.Phi(type, param0, param1); + Node* phi = m.Phi(type.representation(), param0, param1); m.Return(phi); Stream s = m.Build(kAllInstructions); EXPECT_EQ(s.IsReference(phi), s.IsReference(param0)); @@ -312,11 +312,14 @@ TARGET_TEST_P(InstructionSelectorPhiTest, Referenceness) { } -INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorPhiTest, - ::testing::Values(kMachFloat64, kMachInt8, kMachUint8, - kMachInt16, kMachUint16, kMachInt32, - kMachUint32, kMachInt64, kMachUint64, - kMachPtr, kMachAnyTagged)); +INSTANTIATE_TEST_CASE_P( + InstructionSelectorTest, InstructionSelectorPhiTest, + ::testing::Values(MachineType::Float64(), MachineType::Int8(), + MachineType::Uint8(), MachineType::Int16(), + MachineType::Uint16(), MachineType::Int32(), + MachineType::Uint32(), MachineType::Int64(), + MachineType::Uint64(), MachineType::Pointer(), + MachineType::AnyTagged())); // ----------------------------------------------------------------------------- @@ -324,15 +327,15 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorPhiTest, TARGET_TEST_F(InstructionSelectorTest, ValueEffect) { - StreamBuilder m1(this, kMachInt32, kMachPtr); + StreamBuilder m1(this, MachineType::Int32(), MachineType::Pointer()); Node* p1 = m1.Parameter(0); - m1.Return(m1.Load(kMachInt32, p1, m1.Int32Constant(0))); + m1.Return(m1.Load(MachineType::Int32(), p1, m1.Int32Constant(0))); Stream s1 = m1.Build(kAllInstructions); - StreamBuilder m2(this, kMachInt32, kMachPtr); + StreamBuilder m2(this, MachineType::Int32(), MachineType::Pointer()); Node* p2 = m2.Parameter(0); - m2.Return( - m2.AddNode(m2.machine()->Load(kMachInt32), p2, m2.Int32Constant(0), - m2.AddNode(m2.common()->BeginRegion(), m2.graph()->start()))); + m2.Return(m2.AddNode( + m2.machine()->Load(MachineType::Int32()), p2, m2.Int32Constant(0), + m2.AddNode(m2.common()->BeginRegion(), m2.graph()->start()))); Stream s2 = m2.Build(kAllInstructions); EXPECT_LE(3U, s1.size()); ASSERT_EQ(s1.size(), s2.size()); @@ -351,8 +354,8 @@ TARGET_TEST_F(InstructionSelectorTest, ValueEffect) { TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged, kMachAnyTagged, - kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged(), + MachineType::AnyTagged(), MachineType::AnyTagged()); BailoutId bailout_id(42); @@ -360,7 +363,7 @@ TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) { Node* receiver = m.Parameter(1); Node* context = m.Parameter(2); - ZoneVector int32_type(1, kMachInt32, zone()); + ZoneVector int32_type(1, MachineType::Int32(), zone()); ZoneVector empty_types(zone()); CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( @@ -402,8 +405,8 @@ TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) { TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged, kMachAnyTagged, - kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged(), + MachineType::AnyTagged(), MachineType::AnyTagged()); BailoutId bailout_id_before(42); @@ -412,9 +415,9 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { Node* receiver = m.Parameter(1); Node* context = m.Int32Constant(1); // Context is ignored. - ZoneVector int32_type(1, kMachInt32, zone()); - ZoneVector float64_type(1, kMachFloat64, zone()); - ZoneVector tagged_type(1, kMachAnyTagged, zone()); + ZoneVector int32_type(1, MachineType::Int32(), zone()); + ZoneVector float64_type(1, MachineType::Float64(), zone()); + ZoneVector tagged_type(1, MachineType::AnyTagged(), zone()); Callable callable = CodeFactory::ToObject(isolate()); CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( @@ -480,13 +483,15 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { // We inserted 0 here. EXPECT_EQ(0.5, s.ToFloat64(call_instr->InputAt(5))); EXPECT_TRUE(s.ToHeapObject(call_instr->InputAt(6))->IsUndefined()); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(0)); // function is always - // tagged/any. - EXPECT_EQ(kMachInt32, desc_before->GetType(1)); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(2)); // context is always - // tagged/any. - EXPECT_EQ(kMachFloat64, desc_before->GetType(3)); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(4)); + EXPECT_EQ(MachineType::AnyTagged(), + desc_before->GetType(0)); // function is always + // tagged/any. + EXPECT_EQ(MachineType::Int32(), desc_before->GetType(1)); + EXPECT_EQ(MachineType::AnyTagged(), + desc_before->GetType(2)); // context is always + // tagged/any. + EXPECT_EQ(MachineType::Float64(), desc_before->GetType(3)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before->GetType(4)); // Function. EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(7))); @@ -500,8 +505,8 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged, kMachAnyTagged, - kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged(), + MachineType::AnyTagged(), MachineType::AnyTagged()); BailoutId bailout_id_before(42); BailoutId bailout_id_parent(62); @@ -512,9 +517,9 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) { Node* context = m.Int32Constant(66); Node* context2 = m.Int32Constant(46); - ZoneVector int32_type(1, kMachInt32, zone()); - ZoneVector int32x2_type(2, kMachInt32, zone()); - ZoneVector float64_type(1, kMachFloat64, zone()); + ZoneVector int32_type(1, MachineType::Int32(), zone()); + ZoneVector int32x2_type(2, MachineType::Int32(), zone()); + ZoneVector float64_type(1, MachineType::Float64(), zone()); Callable callable = CodeFactory::ToObject(isolate()); CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( @@ -586,31 +591,31 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) { EXPECT_EQ(1u, desc_before_outer->locals_count()); EXPECT_EQ(1u, desc_before_outer->stack_count()); // Values from parent environment. - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(0)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before->GetType(0)); EXPECT_EQ(63, s.ToInt32(call_instr->InputAt(3))); - EXPECT_EQ(kMachInt32, desc_before_outer->GetType(1)); + EXPECT_EQ(MachineType::Int32(), desc_before_outer->GetType(1)); // Context: EXPECT_EQ(66, s.ToInt32(call_instr->InputAt(4))); - EXPECT_EQ(kMachAnyTagged, desc_before_outer->GetType(2)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before_outer->GetType(2)); EXPECT_EQ(64, s.ToInt32(call_instr->InputAt(5))); - EXPECT_EQ(kMachInt32, desc_before_outer->GetType(3)); + EXPECT_EQ(MachineType::Int32(), desc_before_outer->GetType(3)); EXPECT_EQ(65, s.ToInt32(call_instr->InputAt(6))); - EXPECT_EQ(kMachInt32, desc_before_outer->GetType(4)); + EXPECT_EQ(MachineType::Int32(), desc_before_outer->GetType(4)); // Values from the nested frame. EXPECT_EQ(1u, desc_before->parameters_count()); EXPECT_EQ(1u, desc_before->locals_count()); EXPECT_EQ(2u, desc_before->stack_count()); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(0)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before->GetType(0)); EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(8))); - EXPECT_EQ(kMachInt32, desc_before->GetType(1)); + EXPECT_EQ(MachineType::Int32(), desc_before->GetType(1)); EXPECT_EQ(46, s.ToInt32(call_instr->InputAt(9))); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(2)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before->GetType(2)); EXPECT_EQ(0.25, s.ToFloat64(call_instr->InputAt(10))); - EXPECT_EQ(kMachFloat64, desc_before->GetType(3)); + EXPECT_EQ(MachineType::Float64(), desc_before->GetType(3)); EXPECT_EQ(44, s.ToInt32(call_instr->InputAt(11))); - EXPECT_EQ(kMachInt32, desc_before->GetType(4)); + EXPECT_EQ(MachineType::Int32(), desc_before->GetType(4)); EXPECT_EQ(45, s.ToInt32(call_instr->InputAt(12))); - EXPECT_EQ(kMachInt32, desc_before->GetType(5)); + EXPECT_EQ(MachineType::Int32(), desc_before->GetType(5)); // Function. EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(13))); diff --git a/test/unittests/compiler/instruction-selector-unittest.h b/test/unittests/compiler/instruction-selector-unittest.h index 574864edf5..fc7c144939 100644 --- a/test/unittests/compiler/instruction-selector-unittest.h +++ b/test/unittests/compiler/instruction-selector-unittest.h @@ -37,17 +37,19 @@ class InstructionSelectorTest : public TestWithContext, class StreamBuilder final : public RawMachineAssembler { public: StreamBuilder(InstructionSelectorTest* test, MachineType return_type) - : RawMachineAssembler( - test->isolate(), new (test->zone()) Graph(test->zone()), - MakeCallDescriptor(test->zone(), return_type), kMachPtr, - MachineOperatorBuilder::kAllOptionalOps), + : RawMachineAssembler(test->isolate(), + new (test->zone()) Graph(test->zone()), + MakeCallDescriptor(test->zone(), return_type), + MachineType::PointerRepresentation(), + MachineOperatorBuilder::kAllOptionalOps), test_(test) {} StreamBuilder(InstructionSelectorTest* test, MachineType return_type, MachineType parameter0_type) : RawMachineAssembler( test->isolate(), new (test->zone()) Graph(test->zone()), MakeCallDescriptor(test->zone(), return_type, parameter0_type), - kMachPtr, MachineOperatorBuilder::kAllOptionalOps), + MachineType::PointerRepresentation(), + MachineOperatorBuilder::kAllOptionalOps), test_(test) {} StreamBuilder(InstructionSelectorTest* test, MachineType return_type, MachineType parameter0_type, MachineType parameter1_type) @@ -55,7 +57,8 @@ class InstructionSelectorTest : public TestWithContext, test->isolate(), new (test->zone()) Graph(test->zone()), MakeCallDescriptor(test->zone(), return_type, parameter0_type, parameter1_type), - kMachPtr, MachineOperatorBuilder::kAllOptionalOps), + MachineType::PointerRepresentation(), + MachineOperatorBuilder::kAllOptionalOps), test_(test) {} StreamBuilder(InstructionSelectorTest* test, MachineType return_type, MachineType parameter0_type, MachineType parameter1_type, @@ -64,7 +67,8 @@ class InstructionSelectorTest : public TestWithContext, test->isolate(), new (test->zone()) Graph(test->zone()), MakeCallDescriptor(test->zone(), return_type, parameter0_type, parameter1_type, parameter2_type), - kMachPtr, MachineOperatorBuilder::kAllOptionalOps), + MachineType::PointerRepresentation(), + MachineOperatorBuilder::kAllOptionalOps), test_(test) {} Stream Build(CpuFeature feature) { diff --git a/test/unittests/compiler/interpreter-assembler-unittest.cc b/test/unittests/compiler/interpreter-assembler-unittest.cc index 183795d477..e98a3595c1 100644 --- a/test/unittests/compiler/interpreter-assembler-unittest.cc +++ b/test/unittests/compiler/interpreter-assembler-unittest.cc @@ -96,7 +96,8 @@ Matcher InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperand( int offset) { return IsLoad( - kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), + MachineType::Uint8(), + IsParameter(Linkage::kInterpreterBytecodeArrayParameter), IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), IsInt32Constant(offset))); } @@ -105,7 +106,8 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperand( Matcher InterpreterAssemblerTest::InterpreterAssemblerForTest:: IsBytecodeOperandSignExtended(int offset) { Matcher load_matcher = IsLoad( - kMachInt8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), + MachineType::Int8(), + IsParameter(Linkage::kInterpreterBytecodeArrayParameter), IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), IsInt32Constant(offset))); if (kPointerSize == 8) { @@ -120,16 +122,19 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperandShort( int offset) { if (TargetSupportsUnalignedAccess()) { return IsLoad( - kMachUint16, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), + MachineType::Uint16(), + IsParameter(Linkage::kInterpreterBytecodeArrayParameter), IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), IsInt32Constant(offset))); } else { Matcher first_byte = IsLoad( - kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), + MachineType::Uint8(), + IsParameter(Linkage::kInterpreterBytecodeArrayParameter), IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), IsInt32Constant(offset))); Matcher second_byte = IsLoad( - kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), + MachineType::Uint8(), + IsParameter(Linkage::kInterpreterBytecodeArrayParameter), IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), IsInt32Constant(offset + 1))); #if V8_TARGET_LITTLE_ENDIAN @@ -158,13 +163,15 @@ TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) { Matcher next_bytecode_offset_matcher = IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), IsInt32Constant(interpreter::Bytecodes::Size(bytecode))); - Matcher target_bytecode_matcher = m.IsLoad( - kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), - next_bytecode_offset_matcher); - Matcher code_target_matcher = m.IsLoad( - kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter), - IsWord32Shl(target_bytecode_matcher, - IsInt32Constant(kPointerSizeLog2))); + Matcher target_bytecode_matcher = + m.IsLoad(MachineType::Uint8(), + IsParameter(Linkage::kInterpreterBytecodeArrayParameter), + next_bytecode_offset_matcher); + Matcher code_target_matcher = + m.IsLoad(MachineType::Pointer(), + IsParameter(Linkage::kInterpreterDispatchTableParameter), + IsWord32Shl(target_bytecode_matcher, + IsInt32Constant(kPointerSizeLog2))); EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); @@ -196,13 +203,15 @@ TARGET_TEST_F(InterpreterAssemblerTest, Jump) { Matcher next_bytecode_offset_matcher = IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), IsInt32Constant(jump_offset)); - Matcher target_bytecode_matcher = m.IsLoad( - kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), - next_bytecode_offset_matcher); - Matcher code_target_matcher = m.IsLoad( - kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter), - IsWord32Shl(target_bytecode_matcher, - IsInt32Constant(kPointerSizeLog2))); + Matcher target_bytecode_matcher = + m.IsLoad(MachineType::Uint8(), + IsParameter(Linkage::kInterpreterBytecodeArrayParameter), + next_bytecode_offset_matcher); + Matcher code_target_matcher = + m.IsLoad(MachineType::Pointer(), + IsParameter(Linkage::kInterpreterDispatchTableParameter), + IsWord32Shl(target_bytecode_matcher, + IsInt32Constant(kPointerSizeLog2))); EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); @@ -241,13 +250,15 @@ TARGET_TEST_F(InterpreterAssemblerTest, JumpIfWordEqual) { Matcher next_bytecode_offset_matcher = IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), IsInt32Constant(jump_offsets[i])); - Matcher target_bytecode_matcher = m.IsLoad( - kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), - next_bytecode_offset_matcher); - Matcher code_target_matcher = m.IsLoad( - kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter), - IsWord32Shl(target_bytecode_matcher, - IsInt32Constant(kPointerSizeLog2))); + Matcher target_bytecode_matcher = + m.IsLoad(MachineType::Uint8(), + IsParameter(Linkage::kInterpreterBytecodeArrayParameter), + next_bytecode_offset_matcher); + Matcher code_target_matcher = + m.IsLoad(MachineType::Pointer(), + IsParameter(Linkage::kInterpreterDispatchTableParameter), + IsWord32Shl(target_bytecode_matcher, + IsInt32Constant(kPointerSizeLog2))); EXPECT_THAT( end->InputAt(i), IsTailCall(m.call_descriptor(), code_target_matcher, @@ -383,7 +394,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) { Node* load_reg_node = m.LoadRegister(reg_index_node); EXPECT_THAT( load_reg_node, - m.IsLoad(kMachAnyTagged, + m.IsLoad(MachineType::AnyTagged(), IsParameter(Linkage::kInterpreterRegisterFileParameter), IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2)))); } @@ -398,10 +409,11 @@ TARGET_TEST_F(InterpreterAssemblerTest, StoreRegister) { Node* store_reg_node = m.StoreRegister(store_value, reg_index_node); EXPECT_THAT( store_reg_node, - m.IsStore(StoreRepresentation(kMachAnyTagged, kNoWriteBarrier), - IsParameter(Linkage::kInterpreterRegisterFileParameter), - IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2)), - store_value)); + m.IsStore( + StoreRepresentation(MachineType::AnyTagged(), kNoWriteBarrier), + IsParameter(Linkage::kInterpreterRegisterFileParameter), + IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2)), + store_value)); } } @@ -456,12 +468,12 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { Node* index = m.Int32Constant(2); Node* load_constant = m.LoadConstantPoolEntry(index); Matcher constant_pool_matcher = m.IsLoad( - kMachAnyTagged, + MachineType::AnyTagged(), IsParameter(Linkage::kInterpreterBytecodeArrayParameter), IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag)); EXPECT_THAT( load_constant, - m.IsLoad(kMachAnyTagged, constant_pool_matcher, + m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher, IsIntPtrAdd( IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), IsWordShl(index, IsInt32Constant(kPointerSizeLog2))))); @@ -477,7 +489,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadFixedArrayElement) { Node* load_element = m.LoadFixedArrayElement(fixed_array, index); EXPECT_THAT( load_element, - m.IsLoad(kMachAnyTagged, fixed_array, + m.IsLoad(MachineType::AnyTagged(), fixed_array, IsIntPtrAdd( IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), IsWordShl(IsInt32Constant(index), @@ -493,7 +505,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { int offset = 16; Node* load_field = m.LoadObjectField(object, offset); EXPECT_THAT(load_field, - m.IsLoad(kMachAnyTagged, object, + m.IsLoad(MachineType::AnyTagged(), object, IsIntPtrConstant(offset - kHeapObjectTag))); } } @@ -509,7 +521,8 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { Matcher offset = IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); - EXPECT_THAT(load_context_slot, m.IsLoad(kMachAnyTagged, context, offset)); + EXPECT_THAT(load_context_slot, + m.IsLoad(MachineType::AnyTagged(), context, offset)); } } @@ -525,10 +538,10 @@ TARGET_TEST_F(InterpreterAssemblerTest, StoreContextSlot) { Matcher offset = IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); - EXPECT_THAT( - store_context_slot, - m.IsStore(StoreRepresentation(kMachAnyTagged, kFullWriteBarrier), - context, offset, value)); + EXPECT_THAT(store_context_slot, + m.IsStore(StoreRepresentation(MachineType::AnyTagged(), + kFullWriteBarrier), + context, offset, value)); } } @@ -561,7 +574,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) { function_table, IsInt32Mul(function_id, IsInt32Constant(sizeof(Runtime::Function)))); Matcher function_entry = - m.IsLoad(kMachPtr, function, + m.IsLoad(MachineType::Pointer(), function, IsInt32Constant(offsetof(Runtime::Function, entry))); Node* call_runtime = m.CallRuntime(function_id, first_arg, arg_count); @@ -611,18 +624,19 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { InterpreterAssemblerForTest m(this, bytecode); Node* feedback_vector = m.LoadTypeFeedbackVector(); - Matcher load_function_matcher = m.IsLoad( - kMachAnyTagged, IsParameter(Linkage::kInterpreterRegisterFileParameter), - IsIntPtrConstant( - InterpreterFrameConstants::kFunctionFromRegisterPointer)); + Matcher load_function_matcher = + m.IsLoad(MachineType::AnyTagged(), + IsParameter(Linkage::kInterpreterRegisterFileParameter), + IsIntPtrConstant( + InterpreterFrameConstants::kFunctionFromRegisterPointer)); Matcher load_shared_function_info_matcher = - m.IsLoad(kMachAnyTagged, load_function_matcher, + m.IsLoad(MachineType::AnyTagged(), load_function_matcher, IsIntPtrConstant(JSFunction::kSharedFunctionInfoOffset - kHeapObjectTag)); EXPECT_THAT( feedback_vector, - m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, + m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher, IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - kHeapObjectTag))); } diff --git a/test/unittests/compiler/js-builtin-reducer-unittest.cc b/test/unittests/compiler/js-builtin-reducer-unittest.cc index ae367aa395..78e9253a17 100644 --- a/test/unittests/compiler/js-builtin-reducer-unittest.cc +++ b/test/unittests/compiler/js-builtin-reducer-unittest.cc @@ -26,7 +26,8 @@ class JSBuiltinReducerTest : public TypedGraphTest { protected: Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::Flag::kNoFlags) { - MachineOperatorBuilder machine(zone(), kMachPtr, flags); + MachineOperatorBuilder machine(zone(), MachineType::PointerRepresentation(), + flags); SimplifiedOperatorBuilder simplified(zone()); JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified, &machine); @@ -142,7 +143,8 @@ TEST_F(JSBuiltinReducerTest, MathMax2) { ASSERT_TRUE(r.Changed()); EXPECT_THAT(r.replacement(), - IsSelect(kMachNone, IsNumberLessThan(p1, p0), p0, p1)); + IsSelect(MachineRepresentation::kNone, + IsNumberLessThan(p1, p0), p0, p1)); } } } diff --git a/test/unittests/compiler/js-context-relaxation-unittest.cc b/test/unittests/compiler/js-context-relaxation-unittest.cc index 51283d8236..a44bd0278d 100644 --- a/test/unittests/compiler/js-context-relaxation-unittest.cc +++ b/test/unittests/compiler/js-context-relaxation-unittest.cc @@ -19,7 +19,8 @@ class JSContextRelaxationTest : public GraphTest { protected: Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags) { - MachineOperatorBuilder machine(zone(), kMachPtr, flags); + MachineOperatorBuilder machine(zone(), MachineType::PointerRepresentation(), + flags); JSGraph jsgraph(isolate(), graph(), common(), javascript(), nullptr, &machine); // TODO(titzer): mock the GraphReducer here for better unit testing. diff --git a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc index 5663086c1d..2b829fdca5 100644 --- a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc +++ b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc @@ -32,7 +32,8 @@ class JSIntrinsicLoweringTest : public TypedGraphTest { protected: Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags) { - MachineOperatorBuilder machine(zone(), kMachPtr, flags); + MachineOperatorBuilder machine(zone(), MachineType::PointerRepresentation(), + flags); SimplifiedOperatorBuilder simplified(zone()); JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified, &machine); @@ -148,7 +149,7 @@ TEST_F(JSIntrinsicLoweringTest, InlineIsArray) { EXPECT_THAT( phi, IsPhi( - static_cast(kTypeBool | kRepTagged), IsFalseConstant(), + MachineRepresentation::kTagged, IsFalseConstant(), IsWord32Equal(IsLoadField(AccessBuilder::ForMapInstanceType(), IsLoadField(AccessBuilder::ForMap(), input, effect, CaptureEq(&if_false)), @@ -179,7 +180,7 @@ TEST_F(JSIntrinsicLoweringTest, InlineIsDate) { EXPECT_THAT( phi, IsPhi( - static_cast(kTypeBool | kRepTagged), IsFalseConstant(), + MachineRepresentation::kTagged, IsFalseConstant(), IsWord32Equal(IsLoadField(AccessBuilder::ForMapInstanceType(), IsLoadField(AccessBuilder::ForMap(), input, effect, CaptureEq(&if_false)), @@ -210,7 +211,7 @@ TEST_F(JSIntrinsicLoweringTest, InlineIsTypedArray) { EXPECT_THAT( phi, IsPhi( - static_cast(kTypeBool | kRepTagged), IsFalseConstant(), + MachineRepresentation::kTagged, IsFalseConstant(), IsWord32Equal(IsLoadField(AccessBuilder::ForMapInstanceType(), IsLoadField(AccessBuilder::ForMap(), input, effect, CaptureEq(&if_false)), @@ -241,7 +242,7 @@ TEST_F(JSIntrinsicLoweringTest, InlineIsFunction) { EXPECT_THAT( phi, IsPhi( - static_cast(kTypeBool | kRepTagged), IsFalseConstant(), + MachineRepresentation::kTagged, IsFalseConstant(), IsWord32Equal(IsLoadField(AccessBuilder::ForMapInstanceType(), IsLoadField(AccessBuilder::ForMap(), input, effect, CaptureEq(&if_false)), @@ -272,7 +273,7 @@ TEST_F(JSIntrinsicLoweringTest, InlineIsRegExp) { EXPECT_THAT( phi, IsPhi( - static_cast(kTypeBool | kRepTagged), IsFalseConstant(), + MachineRepresentation::kTagged, IsFalseConstant(), IsWord32Equal(IsLoadField(AccessBuilder::ForMapInstanceType(), IsLoadField(AccessBuilder::ForMap(), input, effect, CaptureEq(&if_false)), @@ -303,7 +304,7 @@ TEST_F(JSIntrinsicLoweringTest, InlineIsJSReceiverWithAny) { EXPECT_THAT( phi, IsPhi( - kMachAnyTagged, IsFalseConstant(), + MachineRepresentation::kTagged, IsFalseConstant(), IsUint32LessThanOrEqual( IsInt32Constant(FIRST_JS_RECEIVER_TYPE), IsLoadField(AccessBuilder::ForMapInstanceType(), @@ -449,9 +450,10 @@ TEST_F(JSIntrinsicLoweringTest, InlineValueOf) { EXPECT_THAT( phi, IsPhi( - kMachAnyTagged, input, - IsPhi(kMachAnyTagged, IsLoadField(AccessBuilder::ForValue(), input, - effect, CaptureEq(&if_true1)), + MachineRepresentation::kTagged, input, + IsPhi(MachineRepresentation::kTagged, + IsLoadField(AccessBuilder::ForValue(), input, effect, + CaptureEq(&if_true1)), input, IsMerge( AllOf(CaptureEq(&if_true1), IsIfTrue(CaptureEq(&branch1))), diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc index 149c663fa9..5c6b52557d 100644 --- a/test/unittests/compiler/js-typed-lowering-unittest.cc +++ b/test/unittests/compiler/js-typed-lowering-unittest.cc @@ -357,7 +357,7 @@ TEST_F(JSTypedLoweringTest, JSToObjectWithAny) { Reduction r = Reduce(graph()->NewNode(javascript()->ToObject(), input, context, frame_state, effect, control)); ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsPhi(kMachAnyTagged, _, _, _)); + EXPECT_THAT(r.replacement(), IsPhi(MachineRepresentation::kTagged, _, _, _)); } @@ -387,10 +387,10 @@ TEST_F(JSTypedLoweringTest, JSToStringWithBoolean) { Reduction r = Reduce(graph()->NewNode(javascript()->ToString(), input, context, frame_state, effect, control)); ASSERT_TRUE(r.Changed()); - EXPECT_THAT( - r.replacement(), - IsSelect(kMachAnyTagged, input, IsHeapConstant(factory()->true_string()), - IsHeapConstant(factory()->false_string()))); + EXPECT_THAT(r.replacement(), + IsSelect(MachineRepresentation::kTagged, input, + IsHeapConstant(factory()->true_string()), + IsHeapConstant(factory()->false_string()))); } diff --git a/test/unittests/compiler/linkage-tail-call-unittest.cc b/test/unittests/compiler/linkage-tail-call-unittest.cc index 255c8a1150..597edde665 100644 --- a/test/unittests/compiler/linkage-tail-call-unittest.cc +++ b/test/unittests/compiler/linkage-tail-call-unittest.cc @@ -14,9 +14,11 @@ namespace compiler { namespace { -MachineType kMachineTypes[] = {kMachAnyTagged, kMachAnyTagged, kMachAnyTagged, - kMachAnyTagged, kMachAnyTagged, kMachAnyTagged, - kMachAnyTagged, kMachAnyTagged}; +MachineType kMachineTypes[] = { + MachineType::AnyTagged(), MachineType::AnyTagged(), + MachineType::AnyTagged(), MachineType::AnyTagged(), + MachineType::AnyTagged(), MachineType::AnyTagged(), + MachineType::AnyTagged(), MachineType::AnyTagged()}; } class LinkageTailCall : public TestWithZone { @@ -26,17 +28,17 @@ class LinkageTailCall : public TestWithZone { locations->return_count() + locations->parameter_count()); MachineSignature* types = new (zone()) MachineSignature( locations->return_count(), locations->parameter_count(), kMachineTypes); - return new (zone()) - CallDescriptor(CallDescriptor::kCallCodeObject, kMachAnyTagged, - LinkageLocation::ForAnyRegister(), - types, // machine_sig - locations, // location_sig - 0, // js_parameter_count - Operator::kNoProperties, // properties - 0, // callee-saved - 0, // callee-saved fp - CallDescriptor::kNoFlags, // flags, - ""); + return new (zone()) CallDescriptor(CallDescriptor::kCallCodeObject, + MachineType::AnyTagged(), + LinkageLocation::ForAnyRegister(), + types, // machine_sig + locations, // location_sig + 0, // js_parameter_count + Operator::kNoProperties, // properties + 0, // callee-saved + 0, // callee-saved fp + CallDescriptor::kNoFlags, // flags, + ""); } LinkageLocation StackLocation(int loc) { diff --git a/test/unittests/compiler/live-range-builder.h b/test/unittests/compiler/live-range-builder.h index e5f05ebbcb..4a5621fab7 100644 --- a/test/unittests/compiler/live-range-builder.h +++ b/test/unittests/compiler/live-range-builder.h @@ -40,7 +40,7 @@ class TestRangeBuilder { TopLevelLiveRange* Build() { TopLevelLiveRange* range = - new (zone_) TopLevelLiveRange(id_, MachineType::kRepTagged); + new (zone_) TopLevelLiveRange(id_, MachineRepresentation::kTagged); // Traverse the provided interval specifications backwards, because that is // what LiveRange expects. for (int i = static_cast(pairs_.size()) - 1; i >= 0; --i) { diff --git a/test/unittests/compiler/live-range-unittest.cc b/test/unittests/compiler/live-range-unittest.cc index e802aedff1..e4fc2ca151 100644 --- a/test/unittests/compiler/live-range-unittest.cc +++ b/test/unittests/compiler/live-range-unittest.cc @@ -33,8 +33,8 @@ class LiveRangeUnitTest : public TestWithZone { TopLevelLiveRange* Splinter(TopLevelLiveRange* top, int start, int end, int new_id = 0) { if (top->splinter() == nullptr) { - TopLevelLiveRange* ret = - new (zone()) TopLevelLiveRange(new_id, MachineType::kRepTagged); + TopLevelLiveRange* ret = new (zone()) + TopLevelLiveRange(new_id, MachineRepresentation::kTagged); top->SetSplinter(ret); } top->Splinter(LifetimePosition::FromInt(start), @@ -74,7 +74,7 @@ class LiveRangeUnitTest : public TestWithZone { TEST_F(LiveRangeUnitTest, InvalidConstruction) { // Build a range manually, because the builder guards against empty cases. TopLevelLiveRange* range = - new (zone()) TopLevelLiveRange(1, MachineType::kRepTagged); + new (zone()) TopLevelLiveRange(1, MachineRepresentation::kTagged); V8_ASSERT_DEBUG_DEATH( range->AddUseInterval(LifetimePosition::FromInt(0), LifetimePosition::FromInt(0), zone()), @@ -437,7 +437,7 @@ TEST_F(LiveRangeUnitTest, IDGeneration) { EXPECT_EQ(0, vreg->relative_id()); TopLevelLiveRange* splinter = - new (zone()) TopLevelLiveRange(101, MachineType::kRepTagged); + new (zone()) TopLevelLiveRange(101, MachineRepresentation::kTagged); vreg->SetSplinter(splinter); vreg->Splinter(LifetimePosition::FromInt(4), LifetimePosition::FromInt(12), zone()); diff --git a/test/unittests/compiler/liveness-analyzer-unittest.cc b/test/unittests/compiler/liveness-analyzer-unittest.cc index 3f6a658e82..b77830aa5e 100644 --- a/test/unittests/compiler/liveness-analyzer-unittest.cc +++ b/test/unittests/compiler/liveness-analyzer-unittest.cc @@ -23,7 +23,7 @@ class LivenessAnalysisTest : public GraphTest { public: explicit LivenessAnalysisTest(int locals_count = 4) : locals_count_(locals_count), - machine_(zone(), kRepWord32), + machine_(zone(), MachineRepresentation::kWord32), javascript_(zone()), jsgraph_(isolate(), graph(), common(), &javascript_, nullptr, &machine_), diff --git a/test/unittests/compiler/loop-peeling-unittest.cc b/test/unittests/compiler/loop-peeling-unittest.cc index f1dac8bb64..9dcec85ebf 100644 --- a/test/unittests/compiler/loop-peeling-unittest.cc +++ b/test/unittests/compiler/loop-peeling-unittest.cc @@ -119,7 +119,8 @@ class LoopPeelingTest : public GraphTest { a->loop->ReplaceInput(0, b->if_true); } Node* NewPhi(While* w, Node* a, Node* b) { - return graph()->NewNode(common()->Phi(kMachAnyTagged, 2), a, b, w->loop); + return graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), a, + b, w->loop); } Branch NewBranch(Node* cond, Node* control = nullptr) { @@ -133,8 +134,8 @@ class LoopPeelingTest : public GraphTest { Counter NewCounter(While* w, int32_t b, int32_t k) { Node* base = Int32Constant(b); Node* inc = Int32Constant(k); - Node* phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), base, base, w->loop); + Node* phi = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), base, base, w->loop); Node* add = graph()->NewNode(machine()->Int32Add(), phi, inc); phi->ReplaceInput(1, add); return {base, inc, phi, add}; @@ -183,7 +184,7 @@ TEST_F(LoopPeelingTest, SimpleLoopWithCounter) { Capture merge; EXPECT_THAT( - r, IsReturn(IsPhi(kMachAnyTagged, c.phi, c.base, + r, IsReturn(IsPhi(MachineRepresentation::kTagged, c.phi, c.base, AllOf(CaptureEq(&merge), IsMerge(w.exit, if_false1))), start(), CaptureEq(&merge))); } @@ -222,7 +223,7 @@ TEST_F(LoopPeelingTest, SimpleNestedLoopWithCounter_peel_outer) { Capture merge; EXPECT_THAT( r, - IsReturn(IsPhi(kMachAnyTagged, c.phi, c.base, + IsReturn(IsPhi(MachineRepresentation::kTagged, c.phi, c.base, AllOf(CaptureEq(&merge), IsMerge(outer.exit, if_falseo))), start(), CaptureEq(&merge))); } @@ -298,11 +299,11 @@ TEST_F(LoopPeelingTest, SimpleInnerCounter_peel_inner) { EXPECT_THAT(peeled->map(c.add), IsInt32Add(c.base, c.inc)); Node* back = phi->InputAt(1); - EXPECT_THAT(back, IsPhi(kMachAnyTagged, c.phi, c.base, + EXPECT_THAT(back, IsPhi(MachineRepresentation::kTagged, c.phi, c.base, IsMerge(inner.exit, if_falsei))); - EXPECT_THAT(phi, - IsPhi(kMachAnyTagged, IsInt32Constant(11), back, outer.loop)); + EXPECT_THAT(phi, IsPhi(MachineRepresentation::kTagged, IsInt32Constant(11), + back, outer.loop)); EXPECT_THAT(r, IsReturn(phi, start(), outer.exit)); } @@ -347,9 +348,9 @@ TEST_F(LoopPeelingTest, TwoBackedgeLoopWithPhi) { Node* loop = graph()->NewNode(common()->Loop(3), start(), start(), start()); Branch b1 = NewBranch(p0, loop); Branch b2 = NewBranch(p0, b1.if_true); - Node* phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 3), Int32Constant(0), - Int32Constant(1), Int32Constant(2), loop); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 3), + Int32Constant(0), Int32Constant(1), + Int32Constant(2), loop); loop->ReplaceInput(1, b2.if_true); loop->ReplaceInput(2, b2.if_false); @@ -376,14 +377,15 @@ TEST_F(LoopPeelingTest, TwoBackedgeLoopWithPhi) { EXPECT_THAT(loop, IsLoop(IsMerge(b2t, b2f), b2.if_true, b2.if_false)); - EXPECT_THAT( - phi, IsPhi(kMachAnyTagged, IsPhi(kMachAnyTagged, IsInt32Constant(1), - IsInt32Constant(2), IsMerge(b2t, b2f)), - IsInt32Constant(1), IsInt32Constant(2), loop)); + EXPECT_THAT(phi, + IsPhi(MachineRepresentation::kTagged, + IsPhi(MachineRepresentation::kTagged, IsInt32Constant(1), + IsInt32Constant(2), IsMerge(b2t, b2f)), + IsInt32Constant(1), IsInt32Constant(2), loop)); Capture merge; EXPECT_THAT( - r, IsReturn(IsPhi(kMachAnyTagged, phi, IsInt32Constant(0), + r, IsReturn(IsPhi(MachineRepresentation::kTagged, phi, IsInt32Constant(0), AllOf(CaptureEq(&merge), IsMerge(b1.if_false, b1f))), start(), CaptureEq(&merge))); } @@ -394,9 +396,9 @@ TEST_F(LoopPeelingTest, TwoBackedgeLoopWithCounter) { Node* loop = graph()->NewNode(common()->Loop(3), start(), start(), start()); Branch b1 = NewBranch(p0, loop); Branch b2 = NewBranch(p0, b1.if_true); - Node* phi = - graph()->NewNode(common()->Phi(kMachAnyTagged, 3), Int32Constant(0), - Int32Constant(1), Int32Constant(2), loop); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 3), + Int32Constant(0), Int32Constant(1), + Int32Constant(2), loop); phi->ReplaceInput( 1, graph()->NewNode(machine()->Int32Add(), phi, Int32Constant(1))); @@ -432,18 +434,18 @@ TEST_F(LoopPeelingTest, TwoBackedgeLoopWithCounter) { Node* eval = phi->InputAt(0); - EXPECT_THAT(eval, IsPhi(kMachAnyTagged, + EXPECT_THAT(eval, IsPhi(MachineRepresentation::kTagged, IsInt32Add(IsInt32Constant(0), IsInt32Constant(1)), IsInt32Add(IsInt32Constant(0), IsInt32Constant(2)), CaptureEq(&entry))); - EXPECT_THAT(phi, - IsPhi(kMachAnyTagged, eval, IsInt32Add(phi, IsInt32Constant(1)), - IsInt32Add(phi, IsInt32Constant(2)), loop)); + EXPECT_THAT(phi, IsPhi(MachineRepresentation::kTagged, eval, + IsInt32Add(phi, IsInt32Constant(1)), + IsInt32Add(phi, IsInt32Constant(2)), loop)); Capture merge; EXPECT_THAT( - r, IsReturn(IsPhi(kMachAnyTagged, phi, IsInt32Constant(0), + r, IsReturn(IsPhi(MachineRepresentation::kTagged, phi, IsInt32Constant(0), AllOf(CaptureEq(&merge), IsMerge(b1.if_false, b1f))), start(), CaptureEq(&merge))); } diff --git a/test/unittests/compiler/machine-operator-reducer-unittest.cc b/test/unittests/compiler/machine-operator-reducer-unittest.cc index 7ffdfe5bf0..34b3792c91 100644 --- a/test/unittests/compiler/machine-operator-reducer-unittest.cc +++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc @@ -447,11 +447,13 @@ TEST_F(MachineOperatorReducerTest, TruncateFloat64ToInt32WithPhi) { TRACED_FOREACH(TruncationMode, mode, kTruncationModes) { Reduction reduction = Reduce(graph()->NewNode( machine()->TruncateFloat64ToInt32(mode), - graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p1, merge))); + graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), p0, + p1, merge))); ASSERT_TRUE(reduction.Changed()); - EXPECT_THAT(reduction.replacement(), - IsPhi(kMachInt32, IsTruncateFloat64ToInt32(p0), - IsTruncateFloat64ToInt32(p1), merge)); + EXPECT_THAT( + reduction.replacement(), + IsPhi(MachineRepresentation::kWord32, IsTruncateFloat64ToInt32(p0), + IsTruncateFloat64ToInt32(p1), merge)); } } @@ -828,8 +830,8 @@ TEST_F(MachineOperatorReducerTest, Word32SarWithWord32ShlAndLoad) { Node* const p0 = Parameter(0); Node* const p1 = Parameter(1); { - Node* const l = graph()->NewNode(machine()->Load(kMachInt8), p0, p1, - graph()->start(), graph()->start()); + Node* const l = graph()->NewNode(machine()->Load(MachineType::Int8()), p0, + p1, graph()->start(), graph()->start()); Reduction const r = Reduce(graph()->NewNode( machine()->Word32Sar(), graph()->NewNode(machine()->Word32Shl(), l, Int32Constant(24)), @@ -838,8 +840,8 @@ TEST_F(MachineOperatorReducerTest, Word32SarWithWord32ShlAndLoad) { EXPECT_EQ(l, r.replacement()); } { - Node* const l = graph()->NewNode(machine()->Load(kMachInt16), p0, p1, - graph()->start(), graph()->start()); + Node* const l = graph()->NewNode(machine()->Load(MachineType::Int16()), p0, + p1, graph()->start(), graph()->start()); Reduction const r = Reduce(graph()->NewNode( machine()->Word32Sar(), graph()->NewNode(machine()->Word32Shl(), l, Int32Constant(16)), @@ -1142,7 +1144,8 @@ TEST_F(MachineOperatorReducerTest, Int32ModWithConstant) { ASSERT_TRUE(r.Changed()); EXPECT_THAT( r.replacement(), - IsSelect(kMachInt32, IsInt32LessThan(p0, IsInt32Constant(0)), + IsSelect(MachineRepresentation::kWord32, + IsInt32LessThan(p0, IsInt32Constant(0)), IsInt32Sub(IsInt32Constant(0), IsWord32And(IsInt32Sub(IsInt32Constant(0), p0), IsInt32Constant(mask))), @@ -1157,7 +1160,8 @@ TEST_F(MachineOperatorReducerTest, Int32ModWithConstant) { ASSERT_TRUE(r.Changed()); EXPECT_THAT( r.replacement(), - IsSelect(kMachInt32, IsInt32LessThan(p0, IsInt32Constant(0)), + IsSelect(MachineRepresentation::kWord32, + IsInt32LessThan(p0, IsInt32Constant(0)), IsInt32Sub(IsInt32Constant(0), IsWord32And(IsInt32Sub(IsInt32Constant(0), p0), IsInt32Constant(mask))), @@ -1556,7 +1560,7 @@ TEST_F(MachineOperatorReducerTest, Float64LessThanOrEqualWithFloat32Constant) { TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) { - const StoreRepresentation rep(kMachUint8, kNoWriteBarrier); + const StoreRepresentation rep(MachineType::Uint8(), kNoWriteBarrier); Node* const base = Parameter(0); Node* const index = Parameter(1); Node* const value = Parameter(2); @@ -1578,7 +1582,7 @@ TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) { TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32SarAndWord32Shl) { - const StoreRepresentation rep(kMachUint8, kNoWriteBarrier); + const StoreRepresentation rep(MachineType::Uint8(), kNoWriteBarrier); Node* const base = Parameter(0); Node* const index = Parameter(1); Node* const value = Parameter(2); @@ -1602,7 +1606,7 @@ TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32SarAndWord32Shl) { TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32And) { - const StoreRepresentation rep(kMachUint16, kNoWriteBarrier); + const StoreRepresentation rep(MachineType::Uint16(), kNoWriteBarrier); Node* const base = Parameter(0); Node* const index = Parameter(1); Node* const value = Parameter(2); @@ -1624,7 +1628,7 @@ TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32And) { TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32SarAndWord32Shl) { - const StoreRepresentation rep(kMachUint16, kNoWriteBarrier); + const StoreRepresentation rep(MachineType::Uint16(), kNoWriteBarrier); Node* const base = Parameter(0); Node* const index = Parameter(1); Node* const value = Parameter(2); diff --git a/test/unittests/compiler/machine-operator-unittest.cc b/test/unittests/compiler/machine-operator-unittest.cc index f49fbd7b03..c50db98115 100644 --- a/test/unittests/compiler/machine-operator-unittest.cc +++ b/test/unittests/compiler/machine-operator-unittest.cc @@ -17,25 +17,31 @@ namespace compiler { template class MachineOperatorTestWithParam : public TestWithZone, - public ::testing::WithParamInterface< ::testing::tuple > { + public ::testing::WithParamInterface< + ::testing::tuple > { protected: - MachineType type() const { return ::testing::get<0>(B::GetParam()); } + MachineRepresentation representation() const { + return ::testing::get<0>(B::GetParam()); + } const T& GetParam() const { return ::testing::get<1>(B::GetParam()); } private: - typedef ::testing::WithParamInterface< ::testing::tuple > B; + typedef ::testing::WithParamInterface< + ::testing::tuple > B; }; namespace { -const MachineType kMachineReps[] = {kRepWord32, kRepWord64}; +const MachineRepresentation kMachineReps[] = {MachineRepresentation::kWord32, + MachineRepresentation::kWord64}; const MachineType kMachineTypesForAccess[] = { - kMachFloat32, kMachFloat64, kMachInt8, kMachUint8, kMachInt16, - kMachUint16, kMachInt32, kMachUint32, kMachInt64, kMachUint64, - kMachPtr, kMachAnyTagged, kMachPtr}; + MachineType::Float32(), MachineType::Float64(), MachineType::Int8(), + MachineType::Uint8(), MachineType::Int16(), MachineType::Uint16(), + MachineType::Int32(), MachineType::Uint32(), MachineType::Int64(), + MachineType::Uint64(), MachineType::AnyTagged()}; } // namespace @@ -49,14 +55,14 @@ typedef MachineOperatorTestWithParam TEST_P(MachineLoadOperatorTest, InstancesAreGloballyShared) { - MachineOperatorBuilder machine1(zone(), type()); - MachineOperatorBuilder machine2(zone(), type()); + MachineOperatorBuilder machine1(zone(), representation()); + MachineOperatorBuilder machine2(zone(), representation()); EXPECT_EQ(machine1.Load(GetParam()), machine2.Load(GetParam())); } TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) { - MachineOperatorBuilder machine(zone(), type()); + MachineOperatorBuilder machine(zone(), representation()); const Operator* op = machine.Load(GetParam()); EXPECT_EQ(2, op->ValueInputCount()); @@ -71,13 +77,13 @@ TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) { TEST_P(MachineLoadOperatorTest, OpcodeIsCorrect) { - MachineOperatorBuilder machine(zone(), type()); + MachineOperatorBuilder machine(zone(), representation()); EXPECT_EQ(IrOpcode::kLoad, machine.Load(GetParam())->opcode()); } TEST_P(MachineLoadOperatorTest, ParameterIsCorrect) { - MachineOperatorBuilder machine(zone(), type()); + MachineOperatorBuilder machine(zone(), representation()); EXPECT_EQ(GetParam(), OpParameter(machine.Load(GetParam()))); } @@ -108,14 +114,14 @@ class MachineStoreOperatorTest TEST_P(MachineStoreOperatorTest, InstancesAreGloballyShared) { - MachineOperatorBuilder machine1(zone(), type()); - MachineOperatorBuilder machine2(zone(), type()); + MachineOperatorBuilder machine1(zone(), representation()); + MachineOperatorBuilder machine2(zone(), representation()); EXPECT_EQ(machine1.Store(GetParam()), machine2.Store(GetParam())); } TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) { - MachineOperatorBuilder machine(zone(), type()); + MachineOperatorBuilder machine(zone(), representation()); const Operator* op = machine.Store(GetParam()); EXPECT_EQ(3, op->ValueInputCount()); @@ -130,13 +136,13 @@ TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) { TEST_P(MachineStoreOperatorTest, OpcodeIsCorrect) { - MachineOperatorBuilder machine(zone(), type()); + MachineOperatorBuilder machine(zone(), representation()); EXPECT_EQ(IrOpcode::kStore, machine.Store(GetParam())->opcode()); } TEST_P(MachineStoreOperatorTest, ParameterIsCorrect) { - MachineOperatorBuilder machine(zone(), type()); + MachineOperatorBuilder machine(zone(), representation()); EXPECT_EQ(GetParam(), OpParameter(machine.Store(GetParam()))); } @@ -256,14 +262,16 @@ const PureOperator kPureOperators[] = { class MachinePureOperatorTest : public TestWithZone { protected: - MachineType word_type() { return kMachPtr; } + MachineRepresentation word_type() { + return MachineType::PointerRepresentation(); + } }; TEST_F(MachinePureOperatorTest, PureOperators) { - TRACED_FOREACH(MachineType, machine_rep1, kMachineReps) { + TRACED_FOREACH(MachineRepresentation, machine_rep1, kMachineReps) { MachineOperatorBuilder machine1(zone(), machine_rep1); - TRACED_FOREACH(MachineType, machine_rep2, kMachineReps) { + TRACED_FOREACH(MachineRepresentation, machine_rep2, kMachineReps) { MachineOperatorBuilder machine2(zone(), machine_rep2); TRACED_FOREACH(PureOperator, pop, kPureOperators) { const Operator* op1 = (machine1.*pop.constructor)(); @@ -317,15 +325,17 @@ const OptionalOperatorEntry kOptionalOperators[] = { class MachineOptionalOperatorTest : public TestWithZone { protected: - MachineType word_type() { return kMachPtr; } + MachineRepresentation word_rep() { + return MachineType::PointerRepresentation(); + } }; TEST_F(MachineOptionalOperatorTest, OptionalOperators) { TRACED_FOREACH(OptionalOperatorEntry, pop, kOptionalOperators) { - TRACED_FOREACH(MachineType, machine_rep1, kMachineReps) { + TRACED_FOREACH(MachineRepresentation, machine_rep1, kMachineReps) { MachineOperatorBuilder machine1(zone(), machine_rep1, pop.enabling_flag); - TRACED_FOREACH(MachineType, machine_rep2, kMachineReps) { + TRACED_FOREACH(MachineRepresentation, machine_rep2, kMachineReps) { MachineOperatorBuilder machine2(zone(), machine_rep2, pop.enabling_flag); const Operator* op1 = (machine1.*pop.constructor)().op(); @@ -335,7 +345,7 @@ TEST_F(MachineOptionalOperatorTest, OptionalOperators) { EXPECT_EQ(pop.control_input_count, op1->ControlInputCount()); EXPECT_EQ(pop.value_output_count, op1->ValueOutputCount()); - MachineOperatorBuilder machine3(zone(), word_type()); + MachineOperatorBuilder machine3(zone(), word_rep()); EXPECT_TRUE((machine1.*pop.constructor)().IsSupported()); EXPECT_FALSE((machine3.*pop.constructor)().IsSupported()); } @@ -356,7 +366,7 @@ typedef TestWithZone MachineOperatorTest; TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) { - MachineOperatorBuilder machine(zone(), kRepWord32); + MachineOperatorBuilder machine(zone(), MachineRepresentation::kWord32); EXPECT_EQ(machine.Word32And(), machine.WordAnd()); EXPECT_EQ(machine.Word32Or(), machine.WordOr()); EXPECT_EQ(machine.Word32Xor(), machine.WordXor()); @@ -378,7 +388,7 @@ TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) { TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs64Bit) { - MachineOperatorBuilder machine(zone(), kRepWord64); + MachineOperatorBuilder machine(zone(), MachineRepresentation::kWord64); EXPECT_EQ(machine.Word64And(), machine.WordAnd()); EXPECT_EQ(machine.Word64Or(), machine.WordOr()); EXPECT_EQ(machine.Word64Xor(), machine.WordXor()); diff --git a/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc b/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc index bc35e42744..decf1e1a32 100644 --- a/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc +++ b/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc @@ -41,19 +41,19 @@ struct FPCmp { const FPCmp kFPCmpInstructions[] = { {{&RawMachineAssembler::Float64Equal, "Float64Equal", kMipsCmpD, - kMachFloat64}, + MachineType::Float64()}, kEqual}, {{&RawMachineAssembler::Float64LessThan, "Float64LessThan", kMipsCmpD, - kMachFloat64}, + MachineType::Float64()}, kUnsignedLessThan}, {{&RawMachineAssembler::Float64LessThanOrEqual, "Float64LessThanOrEqual", - kMipsCmpD, kMachFloat64}, + kMipsCmpD, MachineType::Float64()}, kUnsignedLessThanOrEqual}, {{&RawMachineAssembler::Float64GreaterThan, "Float64GreaterThan", kMipsCmpD, - kMachFloat64}, + MachineType::Float64()}, kUnsignedLessThan}, {{&RawMachineAssembler::Float64GreaterThanOrEqual, - "Float64GreaterThanOrEqual", kMipsCmpD, kMachFloat64}, + "Float64GreaterThanOrEqual", kMipsCmpD, MachineType::Float64()}, kUnsignedLessThanOrEqual}}; struct Conversion { @@ -69,12 +69,14 @@ struct Conversion { const MachInst2 kLogicalInstructions[] = { - {&RawMachineAssembler::WordAnd, "WordAnd", kMipsAnd, kMachInt16}, - {&RawMachineAssembler::WordOr, "WordOr", kMipsOr, kMachInt16}, - {&RawMachineAssembler::WordXor, "WordXor", kMipsXor, kMachInt16}, - {&RawMachineAssembler::Word32And, "Word32And", kMipsAnd, kMachInt32}, - {&RawMachineAssembler::Word32Or, "Word32Or", kMipsOr, kMachInt32}, - {&RawMachineAssembler::Word32Xor, "Word32Xor", kMipsXor, kMachInt32}}; + {&RawMachineAssembler::WordAnd, "WordAnd", kMipsAnd, MachineType::Int16()}, + {&RawMachineAssembler::WordOr, "WordOr", kMipsOr, MachineType::Int16()}, + {&RawMachineAssembler::WordXor, "WordXor", kMipsXor, MachineType::Int16()}, + {&RawMachineAssembler::Word32And, "Word32And", kMipsAnd, + MachineType::Int32()}, + {&RawMachineAssembler::Word32Or, "Word32Or", kMipsOr, MachineType::Int32()}, + {&RawMachineAssembler::Word32Xor, "Word32Xor", kMipsXor, + MachineType::Int32()}}; // ---------------------------------------------------------------------------- @@ -83,14 +85,18 @@ const MachInst2 kLogicalInstructions[] = { const MachInst2 kShiftInstructions[] = { - {&RawMachineAssembler::WordShl, "WordShl", kMipsShl, kMachInt16}, - {&RawMachineAssembler::WordShr, "WordShr", kMipsShr, kMachInt16}, - {&RawMachineAssembler::WordSar, "WordSar", kMipsSar, kMachInt16}, - {&RawMachineAssembler::WordRor, "WordRor", kMipsRor, kMachInt16}, - {&RawMachineAssembler::Word32Shl, "Word32Shl", kMipsShl, kMachInt32}, - {&RawMachineAssembler::Word32Shr, "Word32Shr", kMipsShr, kMachInt32}, - {&RawMachineAssembler::Word32Sar, "Word32Sar", kMipsSar, kMachInt32}, - {&RawMachineAssembler::Word32Ror, "Word32Ror", kMipsRor, kMachInt32}}; + {&RawMachineAssembler::WordShl, "WordShl", kMipsShl, MachineType::Int16()}, + {&RawMachineAssembler::WordShr, "WordShr", kMipsShr, MachineType::Int16()}, + {&RawMachineAssembler::WordSar, "WordSar", kMipsSar, MachineType::Int16()}, + {&RawMachineAssembler::WordRor, "WordRor", kMipsRor, MachineType::Int16()}, + {&RawMachineAssembler::Word32Shl, "Word32Shl", kMipsShl, + MachineType::Int32()}, + {&RawMachineAssembler::Word32Shr, "Word32Shr", kMipsShr, + MachineType::Int32()}, + {&RawMachineAssembler::Word32Sar, "Word32Sar", kMipsSar, + MachineType::Int32()}, + {&RawMachineAssembler::Word32Ror, "Word32Ror", kMipsRor, + MachineType::Int32()}}; // ---------------------------------------------------------------------------- @@ -99,11 +105,16 @@ const MachInst2 kShiftInstructions[] = { const MachInst2 kMulDivInstructions[] = { - {&RawMachineAssembler::Int32Mul, "Int32Mul", kMipsMul, kMachInt32}, - {&RawMachineAssembler::Int32Div, "Int32Div", kMipsDiv, kMachInt32}, - {&RawMachineAssembler::Uint32Div, "Uint32Div", kMipsDivU, kMachUint32}, - {&RawMachineAssembler::Float64Mul, "Float64Mul", kMipsMulD, kMachFloat64}, - {&RawMachineAssembler::Float64Div, "Float64Div", kMipsDivD, kMachFloat64}}; + {&RawMachineAssembler::Int32Mul, "Int32Mul", kMipsMul, + MachineType::Int32()}, + {&RawMachineAssembler::Int32Div, "Int32Div", kMipsDiv, + MachineType::Int32()}, + {&RawMachineAssembler::Uint32Div, "Uint32Div", kMipsDivU, + MachineType::Uint32()}, + {&RawMachineAssembler::Float64Mul, "Float64Mul", kMipsMulD, + MachineType::Float64()}, + {&RawMachineAssembler::Float64Div, "Float64Div", kMipsDivD, + MachineType::Float64()}}; // ---------------------------------------------------------------------------- @@ -112,9 +123,12 @@ const MachInst2 kMulDivInstructions[] = { const MachInst2 kModInstructions[] = { - {&RawMachineAssembler::Int32Mod, "Int32Mod", kMipsMod, kMachInt32}, - {&RawMachineAssembler::Uint32Mod, "Int32UMod", kMipsModU, kMachInt32}, - {&RawMachineAssembler::Float64Mod, "Float64Mod", kMipsModD, kMachFloat64}}; + {&RawMachineAssembler::Int32Mod, "Int32Mod", kMipsMod, + MachineType::Int32()}, + {&RawMachineAssembler::Uint32Mod, "Int32UMod", kMipsModU, + MachineType::Int32()}, + {&RawMachineAssembler::Float64Mod, "Float64Mod", kMipsModD, + MachineType::Float64()}}; // ---------------------------------------------------------------------------- @@ -123,8 +137,10 @@ const MachInst2 kModInstructions[] = { const MachInst2 kFPArithInstructions[] = { - {&RawMachineAssembler::Float64Add, "Float64Add", kMipsAddD, kMachFloat64}, - {&RawMachineAssembler::Float64Sub, "Float64Sub", kMipsSubD, kMachFloat64}}; + {&RawMachineAssembler::Float64Add, "Float64Add", kMipsAddD, + MachineType::Float64()}, + {&RawMachineAssembler::Float64Sub, "Float64Sub", kMipsSubD, + MachineType::Float64()}}; // ---------------------------------------------------------------------------- @@ -133,12 +149,14 @@ const MachInst2 kFPArithInstructions[] = { const MachInst2 kAddSubInstructions[] = { - {&RawMachineAssembler::Int32Add, "Int32Add", kMipsAdd, kMachInt32}, - {&RawMachineAssembler::Int32Sub, "Int32Sub", kMipsSub, kMachInt32}, + {&RawMachineAssembler::Int32Add, "Int32Add", kMipsAdd, + MachineType::Int32()}, + {&RawMachineAssembler::Int32Sub, "Int32Sub", kMipsSub, + MachineType::Int32()}, {&RawMachineAssembler::Int32AddWithOverflow, "Int32AddWithOverflow", - kMipsAddOvf, kMachInt32}, + kMipsAddOvf, MachineType::Int32()}, {&RawMachineAssembler::Int32SubWithOverflow, "Int32SubWithOverflow", - kMipsSubOvf, kMachInt32}}; + kMipsSubOvf, MachineType::Int32()}}; // ---------------------------------------------------------------------------- @@ -147,9 +165,11 @@ const MachInst2 kAddSubInstructions[] = { const MachInst1 kAddSubOneInstructions[] = { - {&RawMachineAssembler::Int32Neg, "Int32Neg", kMipsSub, kMachInt32}, + {&RawMachineAssembler::Int32Neg, "Int32Neg", kMipsSub, + MachineType::Int32()}, // TODO(dusmil): check this ... - // {&RawMachineAssembler::WordEqual , "WordEqual" , kMipsTst, kMachInt32} + // {&RawMachineAssembler::WordEqual , "WordEqual" , kMipsTst, + // MachineType::Int32()} }; @@ -159,31 +179,35 @@ const MachInst1 kAddSubOneInstructions[] = { const IntCmp kCmpInstructions[] = { - {{&RawMachineAssembler::WordEqual, "WordEqual", kMipsCmp, kMachInt16}, 1U}, - {{&RawMachineAssembler::WordNotEqual, "WordNotEqual", kMipsCmp, kMachInt16}, + {{&RawMachineAssembler::WordEqual, "WordEqual", kMipsCmp, + MachineType::Int16()}, 1U}, - {{&RawMachineAssembler::Word32Equal, "Word32Equal", kMipsCmp, kMachInt32}, + {{&RawMachineAssembler::WordNotEqual, "WordNotEqual", kMipsCmp, + MachineType::Int16()}, + 1U}, + {{&RawMachineAssembler::Word32Equal, "Word32Equal", kMipsCmp, + MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Word32NotEqual, "Word32NotEqual", kMipsCmp, - kMachInt32}, + MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Int32LessThan, "Int32LessThan", kMipsCmp, - kMachInt32}, + MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Int32LessThanOrEqual, "Int32LessThanOrEqual", - kMipsCmp, kMachInt32}, + kMipsCmp, MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Int32GreaterThan, "Int32GreaterThan", kMipsCmp, - kMachInt32}, + MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Int32GreaterThanOrEqual, "Int32GreaterThanOrEqual", - kMipsCmp, kMachInt32}, + kMipsCmp, MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Uint32LessThan, "Uint32LessThan", kMipsCmp, - kMachUint32}, + MachineType::Uint32()}, 1U}, {{&RawMachineAssembler::Uint32LessThanOrEqual, "Uint32LessThanOrEqual", - kMipsCmp, kMachUint32}, + kMipsCmp, MachineType::Uint32()}, 1U}}; @@ -200,37 +224,37 @@ const Conversion kConversionInstructions[] = { // integers. // mips instruction: cvt_d_w {{&RawMachineAssembler::ChangeInt32ToFloat64, "ChangeInt32ToFloat64", - kMipsCvtDW, kMachFloat64}, - kMachInt32}, + kMipsCvtDW, MachineType::Float64()}, + MachineType::Int32()}, // mips instruction: cvt_d_uw {{&RawMachineAssembler::ChangeUint32ToFloat64, "ChangeUint32ToFloat64", - kMipsCvtDUw, kMachFloat64}, - kMachInt32}, + kMipsCvtDUw, MachineType::Float64()}, + MachineType::Int32()}, // mips instruction: trunc_w_d {{&RawMachineAssembler::ChangeFloat64ToInt32, "ChangeFloat64ToInt32", - kMipsTruncWD, kMachFloat64}, - kMachInt32}, + kMipsTruncWD, MachineType::Float64()}, + MachineType::Int32()}, // mips instruction: trunc_uw_d {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", - kMipsTruncUwD, kMachFloat64}, - kMachInt32}}; + kMipsTruncUwD, MachineType::Float64()}, + MachineType::Int32()}}; const Conversion kFloat64RoundInstructions[] = { {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMipsCeilWD, - kMachFloat64}, - kMachInt32}, + MachineType::Float64()}, + MachineType::Int32()}, {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", kMipsFloorWD, - kMachFloat64}, - kMachInt32}, + MachineType::Float64()}, + MachineType::Int32()}, {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", - kMipsRoundWD, kMachFloat64}, - kMachInt32}, + kMipsRoundWD, MachineType::Float64()}, + MachineType::Int32()}, {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", - kMipsTruncWD, kMachFloat64}, - kMachInt32}}; + kMipsTruncWD, MachineType::Float64()}, + MachineType::Int32()}}; } // namespace @@ -240,7 +264,8 @@ typedef InstructionSelectorTestWithParam InstructionSelectorFPCmpTest; TEST_P(InstructionSelectorFPCmpTest, Parameter) { const FPCmp cmp = GetParam(); - StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); + StreamBuilder m(this, MachineType::Int32(), cmp.mi.machine_type, + cmp.mi.machine_type); m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -292,7 +317,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorShiftTest, Immediate) { const MachInst2 dpi = GetParam(); const MachineType type = dpi.machine_type; - TRACED_FORRANGE(int32_t, imm, 0, (ElementSizeOf(type) * 8) - 1) { + TRACED_FORRANGE(int32_t, imm, 0, + ((1 << ElementSizeLog2Of(type.representation())) * 8) - 1) { StreamBuilder m(this, type, type); m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); Stream s = m.Build(); @@ -319,7 +345,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediate) { uint32_t jnk = rng()->NextInt(); jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), m.Int32Constant(shift))); Stream s = m.Build(); @@ -336,7 +362,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediate) { uint32_t jnk = rng()->NextInt(); jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), m.Int32Constant(shift))); Stream s = m.Build(); @@ -352,7 +378,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediate) { TEST_F(InstructionSelectorTest, Word32ShlWithWord32And) { TRACED_FORRANGE(int32_t, shift, 0, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Shl(m.Word32And(p0, m.Int32Constant((1 << (31 - shift)) - 1)), @@ -397,7 +423,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorLogicalTest, TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Parameter(0), m.Int32Constant(-1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -406,7 +432,7 @@ TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Int32Constant(-1), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -419,7 +445,7 @@ TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { TEST_F(InstructionSelectorTest, Word32XorMinusOneWithWord32Or) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Word32Or(m.Parameter(0), m.Parameter(0)), m.Int32Constant(-1))); Stream s = m.Build(); @@ -429,7 +455,7 @@ TEST_F(InstructionSelectorTest, Word32XorMinusOneWithWord32Or) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Int32Constant(-1), m.Word32Or(m.Parameter(0), m.Parameter(0)))); Stream s = m.Build(); @@ -448,7 +474,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { int32_t lsb = shift & 0x1f; TRACED_FORRANGE(int32_t, width, 1, 31) { uint32_t msk = (1 << width) - 1; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(msk))); Stream s = m.Build(); @@ -464,7 +490,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { int32_t lsb = shift & 0x1f; TRACED_FORRANGE(int32_t, width, 1, 31) { uint32_t msk = (1 << width) - 1; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return( m.Word32And(m.Int32Constant(msk), m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); @@ -483,7 +509,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { TEST_F(InstructionSelectorTest, Word32AndToClearBits) { TRACED_FORRANGE(int32_t, shift, 1, 31) { int32_t mask = ~((1 << shift) - 1); - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Parameter(0), m.Int32Constant(mask))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -494,7 +520,7 @@ TEST_F(InstructionSelectorTest, Word32AndToClearBits) { } TRACED_FORRANGE(int32_t, shift, 1, 31) { int32_t mask = ~((1 << shift) - 1); - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Int32Constant(mask), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -698,13 +724,13 @@ struct MemoryAccess { static const MemoryAccess kMemoryAccesses[] = { - {kMachInt8, kMipsLb, kMipsSb}, - {kMachUint8, kMipsLbu, kMipsSb}, - {kMachInt16, kMipsLh, kMipsSh}, - {kMachUint16, kMipsLhu, kMipsSh}, - {kMachInt32, kMipsLw, kMipsSw}, - {kMachFloat32, kMipsLwc1, kMipsSwc1}, - {kMachFloat64, kMipsLdc1, kMipsSdc1}}; + {MachineType::Int8(), kMipsLb, kMipsSb}, + {MachineType::Uint8(), kMipsLbu, kMipsSb}, + {MachineType::Int16(), kMipsLh, kMipsSh}, + {MachineType::Uint16(), kMipsLhu, kMipsSh}, + {MachineType::Int32(), kMipsLw, kMipsSw}, + {MachineType::Float32(), kMipsLwc1, kMipsSwc1}, + {MachineType::Float64(), kMipsLdc1, kMipsSdc1}}; struct MemoryAccessImm { @@ -743,49 +769,49 @@ std::ostream& operator<<(std::ostream& os, const MemoryAccessImm1& acc) { const MemoryAccessImm kMemoryAccessesImm[] = { - {kMachInt8, + {MachineType::Int8(), kMipsLb, kMipsSb, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachUint8, + {MachineType::Uint8(), kMipsLbu, kMipsSb, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachInt16, + {MachineType::Int16(), kMipsLh, kMipsSh, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachUint16, + {MachineType::Uint16(), kMipsLhu, kMipsSh, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachInt32, + {MachineType::Int32(), kMipsLw, kMipsSw, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachFloat32, + {MachineType::Float32(), kMipsLwc1, kMipsSwc1, &InstructionSelectorTest::Stream::IsDouble, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachFloat64, + {MachineType::Float64(), kMipsLdc1, kMipsSdc1, &InstructionSelectorTest::Stream::IsDouble, @@ -795,37 +821,37 @@ const MemoryAccessImm kMemoryAccessesImm[] = { const MemoryAccessImm1 kMemoryAccessImmMoreThan16bit[] = { - {kMachInt8, + {MachineType::Int8(), kMipsLb, kMipsSb, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachInt8, + {MachineType::Int8(), kMipsLbu, kMipsSb, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachInt16, + {MachineType::Int16(), kMipsLh, kMipsSh, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachInt16, + {MachineType::Int16(), kMipsLhu, kMipsSh, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachInt32, + {MachineType::Int32(), kMipsLw, kMipsSw, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachFloat32, + {MachineType::Float32(), kMipsLwc1, kMipsSwc1, &InstructionSelectorTest::Stream::IsDouble, {-65000, -55000, 32777, 55000, 65000}}, - {kMachFloat64, + {MachineType::Float64(), kMipsLdc1, kMipsSdc1, &InstructionSelectorTest::Stream::IsDouble, @@ -840,7 +866,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32); + StreamBuilder m(this, memacc.type, MachineType::Pointer(), + MachineType::Int32()); m.Return(m.Load(memacc.type, m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -851,7 +878,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + MachineType::Int32(), memacc.type); m.Store(memacc.type, m.Parameter(0), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); Stream s = m.Build(); @@ -878,7 +906,7 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorMemoryAccessImmTest, LoadWithImmediateIndex) { const MemoryAccessImm memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, memacc.type, kMachPtr); + StreamBuilder m(this, memacc.type, MachineType::Pointer()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -901,7 +929,8 @@ TEST_P(InstructionSelectorMemoryAccessImmTest, LoadWithImmediateIndex) { TEST_P(InstructionSelectorMemoryAccessImmTest, StoreWithImmediateIndex) { const MemoryAccessImm memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + memacc.type); m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -935,7 +964,7 @@ TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, LoadWithImmediateIndex) { const MemoryAccessImm1 memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, memacc.type, kMachPtr); + StreamBuilder m(this, memacc.type, MachineType::Pointer()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); Stream s = m.Build(); ASSERT_EQ(2U, s.size()); @@ -953,7 +982,8 @@ TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, StoreWithImmediateIndex) { const MemoryAccessImm1 memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + memacc.type); m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -981,7 +1011,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, Word32EqualWithZero) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -993,7 +1023,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) { EXPECT_EQ(kEqual, s[0]->flags_condition()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1008,7 +1038,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) { TEST_F(InstructionSelectorTest, Word32Clz) { - StreamBuilder m(this, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32Clz(p0); m.Return(n); @@ -1023,7 +1053,7 @@ TEST_F(InstructionSelectorTest, Word32Clz) { TEST_F(InstructionSelectorTest, Float32Abs) { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Abs(p0); m.Return(n); @@ -1038,7 +1068,7 @@ TEST_F(InstructionSelectorTest, Float32Abs) { TEST_F(InstructionSelectorTest, Float64Abs) { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Abs(p0); m.Return(n); @@ -1053,7 +1083,8 @@ TEST_F(InstructionSelectorTest, Float64Abs) { TEST_F(InstructionSelectorTest, Float32Max) { - StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), + MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float32Max(p0, p1); @@ -1069,7 +1100,8 @@ TEST_F(InstructionSelectorTest, Float32Max) { TEST_F(InstructionSelectorTest, Float32Min) { - StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), + MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float32Min(p0, p1); @@ -1085,7 +1117,8 @@ TEST_F(InstructionSelectorTest, Float32Min) { TEST_F(InstructionSelectorTest, Float64Max) { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float64Max(p0, p1); @@ -1101,7 +1134,8 @@ TEST_F(InstructionSelectorTest, Float64Max) { TEST_F(InstructionSelectorTest, Float64Min) { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float64Min(p0, p1); diff --git a/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc b/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc index 699491cb26..7d50c0789c 100644 --- a/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc +++ b/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc @@ -41,19 +41,19 @@ struct FPCmp { const FPCmp kFPCmpInstructions[] = { {{&RawMachineAssembler::Float64Equal, "Float64Equal", kMips64CmpD, - kMachFloat64}, + MachineType::Float64()}, kEqual}, {{&RawMachineAssembler::Float64LessThan, "Float64LessThan", kMips64CmpD, - kMachFloat64}, + MachineType::Float64()}, kUnsignedLessThan}, {{&RawMachineAssembler::Float64LessThanOrEqual, "Float64LessThanOrEqual", - kMips64CmpD, kMachFloat64}, + kMips64CmpD, MachineType::Float64()}, kUnsignedLessThanOrEqual}, {{&RawMachineAssembler::Float64GreaterThan, "Float64GreaterThan", - kMips64CmpD, kMachFloat64}, + kMips64CmpD, MachineType::Float64()}, kUnsignedLessThan}, {{&RawMachineAssembler::Float64GreaterThanOrEqual, - "Float64GreaterThanOrEqual", kMips64CmpD, kMachFloat64}, + "Float64GreaterThanOrEqual", kMips64CmpD, MachineType::Float64()}, kUnsignedLessThanOrEqual}}; struct Conversion { @@ -69,12 +69,18 @@ struct Conversion { const MachInst2 kLogicalInstructions[] = { - {&RawMachineAssembler::Word32And, "Word32And", kMips64And, kMachInt32}, - {&RawMachineAssembler::Word64And, "Word64And", kMips64And, kMachInt64}, - {&RawMachineAssembler::Word32Or, "Word32Or", kMips64Or, kMachInt32}, - {&RawMachineAssembler::Word64Or, "Word64Or", kMips64Or, kMachInt64}, - {&RawMachineAssembler::Word32Xor, "Word32Xor", kMips64Xor, kMachInt32}, - {&RawMachineAssembler::Word64Xor, "Word64Xor", kMips64Xor, kMachInt64}}; + {&RawMachineAssembler::Word32And, "Word32And", kMips64And, + MachineType::Int32()}, + {&RawMachineAssembler::Word64And, "Word64And", kMips64And, + MachineType::Int64()}, + {&RawMachineAssembler::Word32Or, "Word32Or", kMips64Or, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Or, "Word64Or", kMips64Or, + MachineType::Int64()}, + {&RawMachineAssembler::Word32Xor, "Word32Xor", kMips64Xor, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Xor, "Word64Xor", kMips64Xor, + MachineType::Int64()}}; // ---------------------------------------------------------------------------- @@ -83,14 +89,22 @@ const MachInst2 kLogicalInstructions[] = { const MachInst2 kShiftInstructions[] = { - {&RawMachineAssembler::Word32Shl, "Word32Shl", kMips64Shl, kMachInt32}, - {&RawMachineAssembler::Word64Shl, "Word64Shl", kMips64Dshl, kMachInt64}, - {&RawMachineAssembler::Word32Shr, "Word32Shr", kMips64Shr, kMachInt32}, - {&RawMachineAssembler::Word64Shr, "Word64Shr", kMips64Dshr, kMachInt64}, - {&RawMachineAssembler::Word32Sar, "Word32Sar", kMips64Sar, kMachInt32}, - {&RawMachineAssembler::Word64Sar, "Word64Sar", kMips64Dsar, kMachInt64}, - {&RawMachineAssembler::Word32Ror, "Word32Ror", kMips64Ror, kMachInt32}, - {&RawMachineAssembler::Word64Ror, "Word64Ror", kMips64Dror, kMachInt64}}; + {&RawMachineAssembler::Word32Shl, "Word32Shl", kMips64Shl, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Shl, "Word64Shl", kMips64Dshl, + MachineType::Int64()}, + {&RawMachineAssembler::Word32Shr, "Word32Shr", kMips64Shr, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Shr, "Word64Shr", kMips64Dshr, + MachineType::Int64()}, + {&RawMachineAssembler::Word32Sar, "Word32Sar", kMips64Sar, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Sar, "Word64Sar", kMips64Dsar, + MachineType::Int64()}, + {&RawMachineAssembler::Word32Ror, "Word32Ror", kMips64Ror, + MachineType::Int32()}, + {&RawMachineAssembler::Word64Ror, "Word64Ror", kMips64Dror, + MachineType::Int64()}}; // ---------------------------------------------------------------------------- @@ -99,15 +113,22 @@ const MachInst2 kShiftInstructions[] = { const MachInst2 kMulDivInstructions[] = { - {&RawMachineAssembler::Int32Mul, "Int32Mul", kMips64Mul, kMachInt32}, - {&RawMachineAssembler::Int32Div, "Int32Div", kMips64Div, kMachInt32}, - {&RawMachineAssembler::Uint32Div, "Uint32Div", kMips64DivU, kMachUint32}, - {&RawMachineAssembler::Int64Mul, "Int64Mul", kMips64Dmul, kMachInt64}, - {&RawMachineAssembler::Int64Div, "Int64Div", kMips64Ddiv, kMachInt64}, - {&RawMachineAssembler::Uint64Div, "Uint64Div", kMips64DdivU, kMachUint64}, - {&RawMachineAssembler::Float64Mul, "Float64Mul", kMips64MulD, kMachFloat64}, + {&RawMachineAssembler::Int32Mul, "Int32Mul", kMips64Mul, + MachineType::Int32()}, + {&RawMachineAssembler::Int32Div, "Int32Div", kMips64Div, + MachineType::Int32()}, + {&RawMachineAssembler::Uint32Div, "Uint32Div", kMips64DivU, + MachineType::Uint32()}, + {&RawMachineAssembler::Int64Mul, "Int64Mul", kMips64Dmul, + MachineType::Int64()}, + {&RawMachineAssembler::Int64Div, "Int64Div", kMips64Ddiv, + MachineType::Int64()}, + {&RawMachineAssembler::Uint64Div, "Uint64Div", kMips64DdivU, + MachineType::Uint64()}, + {&RawMachineAssembler::Float64Mul, "Float64Mul", kMips64MulD, + MachineType::Float64()}, {&RawMachineAssembler::Float64Div, "Float64Div", kMips64DivD, - kMachFloat64}}; + MachineType::Float64()}}; // ---------------------------------------------------------------------------- @@ -116,10 +137,12 @@ const MachInst2 kMulDivInstructions[] = { const MachInst2 kModInstructions[] = { - {&RawMachineAssembler::Int32Mod, "Int32Mod", kMips64Mod, kMachInt32}, - {&RawMachineAssembler::Uint32Mod, "Uint32Mod", kMips64ModU, kMachInt32}, + {&RawMachineAssembler::Int32Mod, "Int32Mod", kMips64Mod, + MachineType::Int32()}, + {&RawMachineAssembler::Uint32Mod, "Uint32Mod", kMips64ModU, + MachineType::Int32()}, {&RawMachineAssembler::Float64Mod, "Float64Mod", kMips64ModD, - kMachFloat64}}; + MachineType::Float64()}}; // ---------------------------------------------------------------------------- @@ -128,9 +151,10 @@ const MachInst2 kModInstructions[] = { const MachInst2 kFPArithInstructions[] = { - {&RawMachineAssembler::Float64Add, "Float64Add", kMips64AddD, kMachFloat64}, + {&RawMachineAssembler::Float64Add, "Float64Add", kMips64AddD, + MachineType::Float64()}, {&RawMachineAssembler::Float64Sub, "Float64Sub", kMips64SubD, - kMachFloat64}}; + MachineType::Float64()}}; // ---------------------------------------------------------------------------- @@ -139,10 +163,14 @@ const MachInst2 kFPArithInstructions[] = { const MachInst2 kAddSubInstructions[] = { - {&RawMachineAssembler::Int32Add, "Int32Add", kMips64Add, kMachInt32}, - {&RawMachineAssembler::Int64Add, "Int64Add", kMips64Dadd, kMachInt64}, - {&RawMachineAssembler::Int32Sub, "Int32Sub", kMips64Sub, kMachInt32}, - {&RawMachineAssembler::Int64Sub, "Int64Sub", kMips64Dsub, kMachInt64}}; + {&RawMachineAssembler::Int32Add, "Int32Add", kMips64Add, + MachineType::Int32()}, + {&RawMachineAssembler::Int64Add, "Int64Add", kMips64Dadd, + MachineType::Int64()}, + {&RawMachineAssembler::Int32Sub, "Int32Sub", kMips64Sub, + MachineType::Int32()}, + {&RawMachineAssembler::Int64Sub, "Int64Sub", kMips64Dsub, + MachineType::Int64()}}; // ---------------------------------------------------------------------------- @@ -151,8 +179,10 @@ const MachInst2 kAddSubInstructions[] = { const MachInst1 kAddSubOneInstructions[] = { - {&RawMachineAssembler::Int32Neg, "Int32Neg", kMips64Sub, kMachInt32}, - {&RawMachineAssembler::Int64Neg, "Int64Neg", kMips64Dsub, kMachInt64}}; + {&RawMachineAssembler::Int32Neg, "Int32Neg", kMips64Sub, + MachineType::Int32()}, + {&RawMachineAssembler::Int64Neg, "Int64Neg", kMips64Dsub, + MachineType::Int64()}}; // ---------------------------------------------------------------------------- @@ -161,33 +191,35 @@ const MachInst1 kAddSubOneInstructions[] = { const IntCmp kCmpInstructions[] = { - {{&RawMachineAssembler::WordEqual, "WordEqual", kMips64Cmp, kMachInt64}, + {{&RawMachineAssembler::WordEqual, "WordEqual", kMips64Cmp, + MachineType::Int64()}, 1U}, {{&RawMachineAssembler::WordNotEqual, "WordNotEqual", kMips64Cmp, - kMachInt64}, + MachineType::Int64()}, 1U}, - {{&RawMachineAssembler::Word32Equal, "Word32Equal", kMips64Cmp, kMachInt32}, + {{&RawMachineAssembler::Word32Equal, "Word32Equal", kMips64Cmp, + MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Word32NotEqual, "Word32NotEqual", kMips64Cmp, - kMachInt32}, + MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Int32LessThan, "Int32LessThan", kMips64Cmp, - kMachInt32}, + MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Int32LessThanOrEqual, "Int32LessThanOrEqual", - kMips64Cmp, kMachInt32}, + kMips64Cmp, MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Int32GreaterThan, "Int32GreaterThan", kMips64Cmp, - kMachInt32}, + MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Int32GreaterThanOrEqual, "Int32GreaterThanOrEqual", - kMips64Cmp, kMachInt32}, + kMips64Cmp, MachineType::Int32()}, 1U}, {{&RawMachineAssembler::Uint32LessThan, "Uint32LessThan", kMips64Cmp, - kMachUint32}, + MachineType::Uint32()}, 1U}, {{&RawMachineAssembler::Uint32LessThanOrEqual, "Uint32LessThanOrEqual", - kMips64Cmp, kMachUint32}, + kMips64Cmp, MachineType::Uint32()}, 1U}}; @@ -205,42 +237,42 @@ const Conversion kConversionInstructions[] = { // mips instructions: // mtc1, cvt.d.w {{&RawMachineAssembler::ChangeInt32ToFloat64, "ChangeInt32ToFloat64", - kMips64CvtDW, kMachFloat64}, - kMachInt32}, + kMips64CvtDW, MachineType::Float64()}, + MachineType::Int32()}, // mips instructions: // cvt.d.uw {{&RawMachineAssembler::ChangeUint32ToFloat64, "ChangeUint32ToFloat64", - kMips64CvtDUw, kMachFloat64}, - kMachInt32}, + kMips64CvtDUw, MachineType::Float64()}, + MachineType::Int32()}, // mips instructions: // mfc1, trunc double to word, for more details look at mips macro // asm and mips asm file {{&RawMachineAssembler::ChangeFloat64ToInt32, "ChangeFloat64ToInt32", - kMips64TruncWD, kMachFloat64}, - kMachInt32}, + kMips64TruncWD, MachineType::Float64()}, + MachineType::Int32()}, // mips instructions: // trunc double to unsigned word, for more details look at mips macro // asm and mips asm file {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", - kMips64TruncUwD, kMachFloat64}, - kMachInt32}}; + kMips64TruncUwD, MachineType::Float64()}, + MachineType::Int32()}}; const Conversion kFloat64RoundInstructions[] = { {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMips64CeilWD, - kMachFloat64}, - kMachInt32}, + MachineType::Float64()}, + MachineType::Int32()}, {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", - kMips64FloorWD, kMachFloat64}, - kMachInt32}, + kMips64FloorWD, MachineType::Float64()}, + MachineType::Int32()}, {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", - kMips64RoundWD, kMachFloat64}, - kMachInt32}, + kMips64RoundWD, MachineType::Float64()}, + MachineType::Int32()}, {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", - kMips64TruncWD, kMachFloat64}, - kMachInt32}}; + kMips64TruncWD, MachineType::Float64()}, + MachineType::Int32()}}; } // namespace @@ -249,7 +281,8 @@ typedef InstructionSelectorTestWithParam InstructionSelectorFPCmpTest; TEST_P(InstructionSelectorFPCmpTest, Parameter) { const FPCmp cmp = GetParam(); - StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); + StreamBuilder m(this, MachineType::Int32(), cmp.mi.machine_type, + cmp.mi.machine_type); m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -293,7 +326,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorShiftTest, Immediate) { const MachInst2 dpi = GetParam(); const MachineType type = dpi.machine_type; - TRACED_FORRANGE(int32_t, imm, 0, (ElementSizeOf(type) * 8) - 1) { + TRACED_FORRANGE(int32_t, imm, 0, + ((1 << ElementSizeLog2Of(type.representation())) * 8) - 1) { StreamBuilder m(this, type, type); m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); Stream s = m.Build(); @@ -318,7 +352,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediate) { uint32_t jnk = rng()->NextInt(); jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), m.Int32Constant(shift))); Stream s = m.Build(); @@ -335,7 +369,7 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediate) { uint32_t jnk = rng()->NextInt(); jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), m.Int32Constant(shift))); Stream s = m.Build(); @@ -359,7 +393,7 @@ TEST_F(InstructionSelectorTest, Word64ShrWithWord64AndWithImmediate) { jnk = (lsb > 0) ? (jnk >> (64 - lsb)) : 0; uint64_t msk = ((V8_UINT64_C(0xffffffffffffffff) >> (64 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Shr(m.Word64And(m.Parameter(0), m.Int64Constant(msk)), m.Int64Constant(shift))); Stream s = m.Build(); @@ -377,7 +411,7 @@ TEST_F(InstructionSelectorTest, Word64ShrWithWord64AndWithImmediate) { jnk = (lsb > 0) ? (jnk >> (64 - lsb)) : 0; uint64_t msk = ((V8_UINT64_C(0xffffffffffffffff) >> (64 - width)) << lsb) | jnk; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Shr(m.Word64And(m.Int64Constant(msk), m.Parameter(0)), m.Int64Constant(shift))); Stream s = m.Build(); @@ -394,7 +428,7 @@ TEST_F(InstructionSelectorTest, Word64ShrWithWord64AndWithImmediate) { TEST_F(InstructionSelectorTest, Word32AndToClearBits) { TRACED_FORRANGE(int32_t, shift, 1, 31) { int32_t mask = ~((1 << shift) - 1); - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Parameter(0), m.Int32Constant(mask))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -405,7 +439,7 @@ TEST_F(InstructionSelectorTest, Word32AndToClearBits) { } TRACED_FORRANGE(int32_t, shift, 1, 31) { int32_t mask = ~((1 << shift) - 1); - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Int32Constant(mask), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -420,7 +454,7 @@ TEST_F(InstructionSelectorTest, Word32AndToClearBits) { TEST_F(InstructionSelectorTest, Word64AndToClearBits) { TRACED_FORRANGE(int32_t, shift, 1, 31) { int64_t mask = ~((1 << shift) - 1); - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64And(m.Parameter(0), m.Int64Constant(mask))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -431,7 +465,7 @@ TEST_F(InstructionSelectorTest, Word64AndToClearBits) { } TRACED_FORRANGE(int32_t, shift, 1, 31) { int64_t mask = ~((1 << shift) - 1); - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64And(m.Int64Constant(mask), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -468,7 +502,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorLogicalTest, TEST_F(InstructionSelectorTest, Word64XorMinusOneWithParameter) { { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Xor(m.Parameter(0), m.Int64Constant(-1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -477,7 +511,7 @@ TEST_F(InstructionSelectorTest, Word64XorMinusOneWithParameter) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Xor(m.Int64Constant(-1), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -490,7 +524,7 @@ TEST_F(InstructionSelectorTest, Word64XorMinusOneWithParameter) { TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Parameter(0), m.Int32Constant(-1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -499,7 +533,7 @@ TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Int32Constant(-1), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -512,7 +546,7 @@ TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { TEST_F(InstructionSelectorTest, Word64XorMinusOneWithWord64Or) { { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Xor(m.Word64Or(m.Parameter(0), m.Parameter(0)), m.Int64Constant(-1))); Stream s = m.Build(); @@ -522,7 +556,7 @@ TEST_F(InstructionSelectorTest, Word64XorMinusOneWithWord64Or) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Xor(m.Int64Constant(-1), m.Word64Or(m.Parameter(0), m.Parameter(0)))); Stream s = m.Build(); @@ -536,7 +570,7 @@ TEST_F(InstructionSelectorTest, Word64XorMinusOneWithWord64Or) { TEST_F(InstructionSelectorTest, Word32XorMinusOneWithWord32Or) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Word32Or(m.Parameter(0), m.Parameter(0)), m.Int32Constant(-1))); Stream s = m.Build(); @@ -546,7 +580,7 @@ TEST_F(InstructionSelectorTest, Word32XorMinusOneWithWord32Or) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Xor(m.Int32Constant(-1), m.Word32Or(m.Parameter(0), m.Parameter(0)))); Stream s = m.Build(); @@ -565,7 +599,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { int32_t lsb = shift & 0x1f; TRACED_FORRANGE(int32_t, width, 1, 31) { uint32_t msk = (1 << width) - 1; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), m.Int32Constant(msk))); Stream s = m.Build(); @@ -581,7 +615,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { int32_t lsb = shift & 0x1f; TRACED_FORRANGE(int32_t, width, 1, 31) { uint32_t msk = (1 << width) - 1; - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return( m.Word32And(m.Int32Constant(msk), m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); @@ -604,7 +638,7 @@ TEST_F(InstructionSelectorTest, Word64AndWithImmediateWithWord64Shr) { int64_t lsb = shift & 0x3f; TRACED_FORRANGE(int64_t, width, 1, 63) { uint64_t msk = (V8_UINT64_C(1) << width) - 1; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64And(m.Word64Shr(m.Parameter(0), m.Int64Constant(shift)), m.Int64Constant(msk))); Stream s = m.Build(); @@ -620,7 +654,7 @@ TEST_F(InstructionSelectorTest, Word64AndWithImmediateWithWord64Shr) { int64_t lsb = shift & 0x3f; TRACED_FORRANGE(int64_t, width, 1, 63) { uint64_t msk = (V8_UINT64_C(1) << width) - 1; - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return( m.Word64And(m.Int64Constant(msk), m.Word64Shr(m.Parameter(0), m.Int64Constant(shift)))); @@ -638,7 +672,7 @@ TEST_F(InstructionSelectorTest, Word64AndWithImmediateWithWord64Shr) { TEST_F(InstructionSelectorTest, Word32ShlWithWord32And) { TRACED_FORRANGE(int32_t, shift, 0, 30) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const r = m.Word32Shl(m.Word32And(p0, m.Int32Constant((1 << (31 - shift)) - 1)), @@ -657,7 +691,7 @@ TEST_F(InstructionSelectorTest, Word32ShlWithWord32And) { TEST_F(InstructionSelectorTest, Word64ShlWithWord64And) { TRACED_FORRANGE(int32_t, shift, 0, 62) { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); Node* const p0 = m.Parameter(0); Node* const r = m.Word64Shl(m.Word64And(p0, m.Int64Constant((1L << (63 - shift)) - 1)), @@ -803,7 +837,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, ChangesFromToSmi) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.TruncateInt64ToInt32( m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); Stream s = m.Build(); @@ -814,7 +848,7 @@ TEST_F(InstructionSelectorTest, ChangesFromToSmi) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return( m.Word64Shl(m.ChangeInt32ToInt64(m.Parameter(0)), m.Int32Constant(32))); Stream s = m.Build(); @@ -850,7 +884,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, CombineShiftsWithMul) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Mul(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); Stream s = m.Build(); @@ -865,7 +899,7 @@ TEST_F(InstructionSelectorTest, CombineShiftsWithMul) { TEST_F(InstructionSelectorTest, CombineShiftsWithDivMod) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Div(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); Stream s = m.Build(); @@ -876,7 +910,7 @@ TEST_F(InstructionSelectorTest, CombineShiftsWithDivMod) { EXPECT_EQ(1U, s[0]->OutputCount()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Int32Mod(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); Stream s = m.Build(); @@ -903,14 +937,14 @@ struct MemoryAccess { }; static const MemoryAccess kMemoryAccesses[] = { - {kMachInt8, kMips64Lb, kMips64Sb}, - {kMachUint8, kMips64Lbu, kMips64Sb}, - {kMachInt16, kMips64Lh, kMips64Sh}, - {kMachUint16, kMips64Lhu, kMips64Sh}, - {kMachInt32, kMips64Lw, kMips64Sw}, - {kMachFloat32, kMips64Lwc1, kMips64Swc1}, - {kMachFloat64, kMips64Ldc1, kMips64Sdc1}, - {kMachInt64, kMips64Ld, kMips64Sd}}; + {MachineType::Int8(), kMips64Lb, kMips64Sb}, + {MachineType::Uint8(), kMips64Lbu, kMips64Sb}, + {MachineType::Int16(), kMips64Lh, kMips64Sh}, + {MachineType::Uint16(), kMips64Lhu, kMips64Sh}, + {MachineType::Int32(), kMips64Lw, kMips64Sw}, + {MachineType::Float32(), kMips64Lwc1, kMips64Swc1}, + {MachineType::Float64(), kMips64Ldc1, kMips64Sdc1}, + {MachineType::Int64(), kMips64Ld, kMips64Sd}}; struct MemoryAccessImm { @@ -949,56 +983,56 @@ std::ostream& operator<<(std::ostream& os, const MemoryAccessImm1& acc) { const MemoryAccessImm kMemoryAccessesImm[] = { - {kMachInt8, + {MachineType::Int8(), kMips64Lb, kMips64Sb, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachUint8, + {MachineType::Uint8(), kMips64Lbu, kMips64Sb, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachInt16, + {MachineType::Int16(), kMips64Lh, kMips64Sh, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachUint16, + {MachineType::Uint16(), kMips64Lhu, kMips64Sh, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachInt32, + {MachineType::Int32(), kMips64Lw, kMips64Sw, &InstructionSelectorTest::Stream::IsInteger, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachFloat32, + {MachineType::Float32(), kMips64Lwc1, kMips64Swc1, &InstructionSelectorTest::Stream::IsDouble, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachFloat64, + {MachineType::Float64(), kMips64Ldc1, kMips64Sdc1, &InstructionSelectorTest::Stream::IsDouble, {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, - {kMachInt64, + {MachineType::Int64(), kMips64Ld, kMips64Sd, &InstructionSelectorTest::Stream::IsInteger, @@ -1008,42 +1042,42 @@ const MemoryAccessImm kMemoryAccessesImm[] = { const MemoryAccessImm1 kMemoryAccessImmMoreThan16bit[] = { - {kMachInt8, + {MachineType::Int8(), kMips64Lb, kMips64Sb, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachInt8, + {MachineType::Int8(), kMips64Lbu, kMips64Sb, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachInt16, + {MachineType::Int16(), kMips64Lh, kMips64Sh, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachInt16, + {MachineType::Int16(), kMips64Lhu, kMips64Sh, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachInt32, + {MachineType::Int32(), kMips64Lw, kMips64Sw, &InstructionSelectorTest::Stream::IsInteger, {-65000, -55000, 32777, 55000, 65000}}, - {kMachFloat32, + {MachineType::Float32(), kMips64Lwc1, kMips64Swc1, &InstructionSelectorTest::Stream::IsDouble, {-65000, -55000, 32777, 55000, 65000}}, - {kMachFloat64, + {MachineType::Float64(), kMips64Ldc1, kMips64Sdc1, &InstructionSelectorTest::Stream::IsDouble, {-65000, -55000, 32777, 55000, 65000}}, - {kMachInt64, + {MachineType::Int64(), kMips64Ld, kMips64Sd, &InstructionSelectorTest::Stream::IsInteger, @@ -1057,7 +1091,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32); + StreamBuilder m(this, memacc.type, MachineType::Pointer(), + MachineType::Int32()); m.Return(m.Load(memacc.type, m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1068,7 +1103,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + MachineType::Int32(), memacc.type); m.Store(memacc.type, m.Parameter(0), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); Stream s = m.Build(); @@ -1093,7 +1129,7 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorMemoryAccessImmTest, LoadWithImmediateIndex) { const MemoryAccessImm memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, memacc.type, kMachPtr); + StreamBuilder m(this, memacc.type, MachineType::Pointer()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1116,7 +1152,8 @@ TEST_P(InstructionSelectorMemoryAccessImmTest, LoadWithImmediateIndex) { TEST_P(InstructionSelectorMemoryAccessImmTest, StoreWithImmediateIndex) { const MemoryAccessImm memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + memacc.type); m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -1148,7 +1185,7 @@ TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, LoadWithImmediateIndex) { const MemoryAccessImm1 memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, memacc.type, kMachPtr); + StreamBuilder m(this, memacc.type, MachineType::Pointer()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); Stream s = m.Build(); ASSERT_EQ(2U, s.size()); @@ -1165,7 +1202,8 @@ TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, StoreWithImmediateIndex) { const MemoryAccessImm1 memacc = GetParam(); TRACED_FOREACH(int32_t, index, memacc.immediates) { - StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + memacc.type); m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -1192,7 +1230,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, Word32EqualWithZero) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1204,7 +1242,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) { EXPECT_EQ(kEqual, s[0]->flags_condition()); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1220,7 +1258,7 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) { TEST_F(InstructionSelectorTest, Word64EqualWithZero) { { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Equal(m.Parameter(0), m.Int64Constant(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1232,7 +1270,7 @@ TEST_F(InstructionSelectorTest, Word64EqualWithZero) { EXPECT_EQ(kEqual, s[0]->flags_condition()); } { - StreamBuilder m(this, kMachInt64, kMachInt64); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); m.Return(m.Word64Equal(m.Int32Constant(0), m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -1247,7 +1285,7 @@ TEST_F(InstructionSelectorTest, Word64EqualWithZero) { TEST_F(InstructionSelectorTest, Word32Clz) { - StreamBuilder m(this, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32Clz(p0); m.Return(n); @@ -1262,7 +1300,7 @@ TEST_F(InstructionSelectorTest, Word32Clz) { TEST_F(InstructionSelectorTest, Word64Clz) { - StreamBuilder m(this, kMachUint64, kMachUint64); + StreamBuilder m(this, MachineType::Uint64(), MachineType::Uint64()); Node* const p0 = m.Parameter(0); Node* const n = m.Word64Clz(p0); m.Return(n); @@ -1277,7 +1315,7 @@ TEST_F(InstructionSelectorTest, Word64Clz) { TEST_F(InstructionSelectorTest, Float32Abs) { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Abs(p0); m.Return(n); @@ -1292,7 +1330,7 @@ TEST_F(InstructionSelectorTest, Float32Abs) { TEST_F(InstructionSelectorTest, Float64Abs) { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Abs(p0); m.Return(n); @@ -1307,7 +1345,8 @@ TEST_F(InstructionSelectorTest, Float64Abs) { TEST_F(InstructionSelectorTest, Float32Max) { - StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), + MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float32Max(p0, p1); @@ -1323,7 +1362,8 @@ TEST_F(InstructionSelectorTest, Float32Max) { TEST_F(InstructionSelectorTest, Float32Min) { - StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), + MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float32Min(p0, p1); @@ -1339,7 +1379,8 @@ TEST_F(InstructionSelectorTest, Float32Min) { TEST_F(InstructionSelectorTest, Float64Max) { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float64Max(p0, p1); @@ -1355,7 +1396,8 @@ TEST_F(InstructionSelectorTest, Float64Max) { TEST_F(InstructionSelectorTest, Float64Min) { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Float64Min(p0, p1); diff --git a/test/unittests/compiler/move-optimizer-unittest.cc b/test/unittests/compiler/move-optimizer-unittest.cc index 66eb9abc4f..413c58b6fe 100644 --- a/test/unittests/compiler/move-optimizer-unittest.cc +++ b/test/unittests/compiler/move-optimizer-unittest.cc @@ -67,16 +67,16 @@ class MoveOptimizerTest : public InstructionSequenceTest { case kConstant: return ConstantOperand(op.value_); case kFixedSlot: - return AllocatedOperand(LocationOperand::STACK_SLOT, kRepWord32, - op.value_); + return AllocatedOperand(LocationOperand::STACK_SLOT, + MachineRepresentation::kWord32, op.value_); case kFixedRegister: CHECK(0 <= op.value_ && op.value_ < num_general_registers()); - return AllocatedOperand(LocationOperand::REGISTER, kRepWord32, - op.value_); + return AllocatedOperand(LocationOperand::REGISTER, + MachineRepresentation::kWord32, op.value_); case kExplicit: CHECK(0 <= op.value_ && op.value_ < num_general_registers()); - return ExplicitOperand(LocationOperand::REGISTER, kRepWord32, - op.value_); + return ExplicitOperand(LocationOperand::REGISTER, + MachineRepresentation::kWord32, op.value_); default: break; } diff --git a/test/unittests/compiler/node-test-utils.cc b/test/unittests/compiler/node-test-utils.cc index 2f4d96d2db..2feba733ce 100644 --- a/test/unittests/compiler/node-test-utils.cc +++ b/test/unittests/compiler/node-test-utils.cc @@ -411,7 +411,7 @@ class IsConstantMatcher final : public NodeMatcher { class IsSelectMatcher final : public NodeMatcher { public: - IsSelectMatcher(const Matcher& type_matcher, + IsSelectMatcher(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& value2_matcher) @@ -423,7 +423,7 @@ class IsSelectMatcher final : public NodeMatcher { void DescribeTo(std::ostream* os) const final { NodeMatcher::DescribeTo(os); - *os << " whose type ("; + *os << " whose representation ("; type_matcher_.DescribeTo(os); *os << "), value0 ("; value0_matcher_.DescribeTo(os); @@ -435,19 +435,20 @@ class IsSelectMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter(node).type(), - "type", type_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), - "value0", value0_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), - "value1", value1_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), - "value2", value2_matcher_, listener)); + return ( + NodeMatcher::MatchAndExplain(node, listener) && + PrintMatchAndExplain(SelectParametersOf(node->op()).representation(), + "representation", type_matcher_, listener) && + PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value0", + value0_matcher_, listener) && + PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "value1", + value1_matcher_, listener) && + PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "value2", + value2_matcher_, listener)); } private: - const Matcher type_matcher_; + const Matcher type_matcher_; const Matcher value0_matcher_; const Matcher value1_matcher_; const Matcher value2_matcher_; @@ -456,7 +457,7 @@ class IsSelectMatcher final : public NodeMatcher { class IsPhiMatcher final : public NodeMatcher { public: - IsPhiMatcher(const Matcher& type_matcher, + IsPhiMatcher(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& control_matcher) @@ -468,7 +469,7 @@ class IsPhiMatcher final : public NodeMatcher { void DescribeTo(std::ostream* os) const final { NodeMatcher::DescribeTo(os); - *os << " whose type ("; + *os << " whose representation ("; type_matcher_.DescribeTo(os); *os << "), value0 ("; value0_matcher_.DescribeTo(os); @@ -481,8 +482,8 @@ class IsPhiMatcher final : public NodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter(node), "type", - type_matcher_, listener) && + PrintMatchAndExplain(PhiRepresentationOf(node->op()), + "representation", type_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value0", value0_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), @@ -492,7 +493,7 @@ class IsPhiMatcher final : public NodeMatcher { } private: - const Matcher type_matcher_; + const Matcher type_matcher_; const Matcher value0_matcher_; const Matcher value1_matcher_; const Matcher control_matcher_; @@ -501,7 +502,7 @@ class IsPhiMatcher final : public NodeMatcher { class IsPhi2Matcher final : public NodeMatcher { public: - IsPhi2Matcher(const Matcher& type_matcher, + IsPhi2Matcher(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& value2_matcher, @@ -515,7 +516,7 @@ class IsPhi2Matcher final : public NodeMatcher { void DescribeTo(std::ostream* os) const final { NodeMatcher::DescribeTo(os); - *os << " whose type ("; + *os << " whose representation ("; type_matcher_.DescribeTo(os); *os << "), value0 ("; value0_matcher_.DescribeTo(os); @@ -530,8 +531,8 @@ class IsPhi2Matcher final : public NodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter(node), "type", - type_matcher_, listener) && + PrintMatchAndExplain(PhiRepresentationOf(node->op()), + "representation", type_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value0", value0_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), @@ -543,7 +544,7 @@ class IsPhi2Matcher final : public NodeMatcher { } private: - const Matcher type_matcher_; + const Matcher type_matcher_; const Matcher value0_matcher_; const Matcher value1_matcher_; const Matcher value2_matcher_; @@ -1594,7 +1595,7 @@ Matcher IsNumberConstant(const Matcher& value_matcher) { } -Matcher IsSelect(const Matcher& type_matcher, +Matcher IsSelect(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& value2_matcher) { @@ -1603,7 +1604,7 @@ Matcher IsSelect(const Matcher& type_matcher, } -Matcher IsPhi(const Matcher& type_matcher, +Matcher IsPhi(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& merge_matcher) { @@ -1612,7 +1613,7 @@ Matcher IsPhi(const Matcher& type_matcher, } -Matcher IsPhi(const Matcher& type_matcher, +Matcher IsPhi(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& value2_matcher, diff --git a/test/unittests/compiler/node-test-utils.h b/test/unittests/compiler/node-test-utils.h index ff49ab3e9f..8592f30566 100644 --- a/test/unittests/compiler/node-test-utils.h +++ b/test/unittests/compiler/node-test-utils.h @@ -80,15 +80,15 @@ Matcher IsFloat64Constant(const Matcher& value_matcher); Matcher IsInt32Constant(const Matcher& value_matcher); Matcher IsInt64Constant(const Matcher& value_matcher); Matcher IsNumberConstant(const Matcher& value_matcher); -Matcher IsSelect(const Matcher& type_matcher, +Matcher IsSelect(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& value2_matcher); -Matcher IsPhi(const Matcher& type_matcher, +Matcher IsPhi(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& merge_matcher); -Matcher IsPhi(const Matcher& type_matcher, +Matcher IsPhi(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& value2_matcher, diff --git a/test/unittests/compiler/scheduler-unittest.cc b/test/unittests/compiler/scheduler-unittest.cc index af43b2efff..ac508581de 100644 --- a/test/unittests/compiler/scheduler-unittest.cc +++ b/test/unittests/compiler/scheduler-unittest.cc @@ -658,7 +658,8 @@ Node* CreateDiamond(Graph* graph, CommonOperatorBuilder* common, Node* cond) { Node* t = graph->NewNode(common->IfTrue(), br); Node* f = graph->NewNode(common->IfFalse(), br); Node* m = graph->NewNode(common->Merge(2), t, f); - Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), tv, fv, m); + Node* phi = + graph->NewNode(common->Phi(MachineRepresentation::kTagged, 2), tv, fv, m); return phi; } @@ -737,12 +738,13 @@ TARGET_TEST_F(SchedulerTest, NestedFloatingDiamonds) { Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); Node* ttrue = graph()->NewNode(common()->Int32Constant(1)); Node* ffalse = graph()->NewNode(common()->Int32Constant(0)); - Node* phi1 = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), ttrue, ffalse, m1); + Node* phi1 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), ttrue, ffalse, m1); Node* m = graph()->NewNode(common()->Merge(2), t, f); - Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fv, phi1, m); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + fv, phi1, m); Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), start, map, m); Node* ret = graph()->NewNode(common()->Return(), phi, ephi1, start); @@ -766,27 +768,29 @@ TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) { Node* tA1 = graph()->NewNode(common()->IfTrue(), brA1); Node* fA1 = graph()->NewNode(common()->IfFalse(), brA1); Node* mA1 = graph()->NewNode(common()->Merge(2), tA1, fA1); - Node* phiA1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p1, mA1); + Node* phiA1 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), p0, p1, mA1); Node* brB1 = graph()->NewNode(common()->Branch(), p1, graph()->start()); Node* tB1 = graph()->NewNode(common()->IfTrue(), brB1); Node* fB1 = graph()->NewNode(common()->IfFalse(), brB1); Node* mB1 = graph()->NewNode(common()->Merge(2), tB1, fB1); - Node* phiB1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p1, mB1); + Node* phiB1 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), p0, p1, mB1); Node* brA2 = graph()->NewNode(common()->Branch(), phiB1, mA1); Node* tA2 = graph()->NewNode(common()->IfTrue(), brA2); Node* fA2 = graph()->NewNode(common()->IfFalse(), brA2); Node* mA2 = graph()->NewNode(common()->Merge(2), tA2, fA2); - Node* phiA2 = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phiB1, c, mA2); + Node* phiA2 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), phiB1, c, mA2); Node* brB2 = graph()->NewNode(common()->Branch(), phiA1, mB1); Node* tB2 = graph()->NewNode(common()->IfTrue(), brB2); Node* fB2 = graph()->NewNode(common()->IfFalse(), brB2); Node* mB2 = graph()->NewNode(common()->Merge(2), tB2, fB2); - Node* phiB2 = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phiA1, c, mB2); + Node* phiB2 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), phiA1, c, mB2); Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2); Node* ret = graph()->NewNode(common()->Return(), add, start, start); @@ -810,7 +814,8 @@ TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) { Node* f = graph()->NewNode(common()->IfFalse(), br); Node* loop = graph()->NewNode(common()->Loop(2), f, start); - Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); + Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + p0, p0, loop); Node* add = graph()->NewNode(&kIntAdd, ind, fv); Node* br1 = graph()->NewNode(common()->Branch(), add, loop); @@ -821,7 +826,8 @@ TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) { ind->ReplaceInput(1, ind); // close induction variable. Node* m = graph()->NewNode(common()->Merge(2), t, f1); - Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fv, ind, m); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + fv, ind, m); Node* ret = graph()->NewNode(common()->Return(), phi, start, start); Node* end = graph()->NewNode(common()->End(1), ret); @@ -840,7 +846,8 @@ TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) { Node* c = graph()->NewNode(common()->Int32Constant(7)); Node* loop = graph()->NewNode(common()->Loop(2), start, start); - Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); + Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + p0, p0, loop); Node* add = graph()->NewNode(&kIntAdd, ind, c); Node* br = graph()->NewNode(common()->Branch(), add, loop); @@ -851,7 +858,8 @@ TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) { Node* t1 = graph()->NewNode(common()->IfTrue(), br1); Node* f1 = graph()->NewNode(common()->IfFalse(), br1); Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); - Node* phi1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), add, p0, m1); + Node* phi1 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), add, p0, m1); loop->ReplaceInput(1, t); // close loop. ind->ReplaceInput(1, phi1); // close induction variable. @@ -873,13 +881,15 @@ TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond2) { Node* c = graph()->NewNode(common()->Int32Constant(7)); Node* loop = graph()->NewNode(common()->Loop(2), start, start); - Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); + Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + p0, p0, loop); Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); Node* t1 = graph()->NewNode(common()->IfTrue(), br1); Node* f1 = graph()->NewNode(common()->IfFalse(), br1); Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); - Node* phi1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), c, ind, m1); + Node* phi1 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), c, ind, m1); Node* add = graph()->NewNode(&kIntAdd, ind, phi1); @@ -907,14 +917,16 @@ TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) { Node* c = graph()->NewNode(common()->Int32Constant(7)); Node* loop = graph()->NewNode(common()->Loop(2), start, start); - Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); + Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + p0, p0, loop); Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); Node* t1 = graph()->NewNode(common()->IfTrue(), br1); Node* f1 = graph()->NewNode(common()->IfFalse(), br1); Node* loop1 = graph()->NewNode(common()->Loop(2), t1, start); - Node* ind1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); + Node* ind1 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), p0, p0, loop); Node* add1 = graph()->NewNode(&kIntAdd, ind1, c); Node* br2 = graph()->NewNode(common()->Branch(), add1, loop1); @@ -925,7 +937,8 @@ TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) { ind1->ReplaceInput(1, ind1); // close inner induction variable. Node* m1 = graph()->NewNode(common()->Merge(2), f1, f2); - Node* phi1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), c, ind1, m1); + Node* phi1 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), c, ind1, m1); Node* add = graph()->NewNode(&kIntAdd, ind, phi1); @@ -960,15 +973,17 @@ TARGET_TEST_F(SchedulerTest, PhisPushedDownToDifferentBranches) { Node* t = graph()->NewNode(common()->IfTrue(), br); Node* f = graph()->NewNode(common()->IfFalse(), br); Node* m = graph()->NewNode(common()->Merge(2), t, f); - Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), v1, v2, m); - Node* phi2 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), v3, v4, m); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + v1, v2, m); + Node* phi2 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), v3, v4, m); Node* br2 = graph()->NewNode(common()->Branch(), p1, graph()->start()); Node* t2 = graph()->NewNode(common()->IfTrue(), br2); Node* f2 = graph()->NewNode(common()->IfFalse(), br2); Node* m2 = graph()->NewNode(common()->Merge(2), t2, f2); - Node* phi3 = - graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phi, phi2, m2); + Node* phi3 = graph()->NewNode( + common()->Phi(MachineRepresentation::kTagged, 2), phi, phi2, m2); Node* ret = graph()->NewNode(common()->Return(), phi3, start, start); Node* end = graph()->NewNode(common()->End(1), ret); @@ -990,7 +1005,8 @@ TARGET_TEST_F(SchedulerTest, BranchHintTrue) { Node* t = graph()->NewNode(common()->IfTrue(), br); Node* f = graph()->NewNode(common()->IfFalse(), br); Node* m = graph()->NewNode(common()->Merge(2), t, f); - Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + tv, fv, m); Node* ret = graph()->NewNode(common()->Return(), phi, start, start); Node* end = graph()->NewNode(common()->End(1), ret); @@ -1014,7 +1030,8 @@ TARGET_TEST_F(SchedulerTest, BranchHintFalse) { Node* t = graph()->NewNode(common()->IfTrue(), br); Node* f = graph()->NewNode(common()->IfFalse(), br); Node* m = graph()->NewNode(common()->Merge(2), t, f); - Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + tv, fv, m); Node* ret = graph()->NewNode(common()->Return(), phi, start, start); Node* end = graph()->NewNode(common()->End(1), ret); @@ -1042,7 +1059,8 @@ TARGET_TEST_F(SchedulerTest, CallException) { common()->IfException(IfExceptionHint::kLocallyUncaught), c2, c2); Node* hdl = graph()->NewNode(common()->Merge(2), ex1, ex2); Node* m = graph()->NewNode(common()->Merge(2), ok2, hdl); - Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), c2, p0, m); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), + c2, p0, m); Node* ret = graph()->NewNode(common()->Return(), phi, start, m); Node* end = graph()->NewNode(common()->End(1), ret); @@ -1084,7 +1102,8 @@ TARGET_TEST_F(SchedulerTest, Switch) { Node* d = graph()->NewNode(common()->IfDefault(), sw); Node* vd = graph()->NewNode(common()->Int32Constant(33)); Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); - Node* phi = graph()->NewNode(common()->Phi(kMachInt32, 3), v0, v1, vd, m); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3), + v0, v1, vd, m); Node* ret = graph()->NewNode(common()->Return(), phi, start, m); Node* end = graph()->NewNode(common()->End(1), ret); @@ -1107,7 +1126,8 @@ TARGET_TEST_F(SchedulerTest, FloatingSwitch) { Node* d = graph()->NewNode(common()->IfDefault(), sw); Node* vd = graph()->NewNode(common()->Int32Constant(33)); Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); - Node* phi = graph()->NewNode(common()->Phi(kMachInt32, 3), v0, v1, vd, m); + Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3), + v0, v1, vd, m); Node* ret = graph()->NewNode(common()->Return(), phi, start, start); Node* end = graph()->NewNode(common()->End(1), ret); diff --git a/test/unittests/compiler/select-lowering-unittest.cc b/test/unittests/compiler/select-lowering-unittest.cc index 51efc83f87..43cfd8484a 100644 --- a/test/unittests/compiler/select-lowering-unittest.cc +++ b/test/unittests/compiler/select-lowering-unittest.cc @@ -34,7 +34,8 @@ TEST_F(SelectLoweringTest, SelectWithSameConditions) { Node* const p2 = Parameter(2); Node* const p3 = Parameter(3); Node* const p4 = Parameter(4); - Node* const s0 = graph()->NewNode(common()->Select(kMachInt32), p0, p1, p2); + Node* const s0 = graph()->NewNode( + common()->Select(MachineRepresentation::kWord32), p0, p1, p2); Capture branch; Capture merge; @@ -44,26 +45,27 @@ TEST_F(SelectLoweringTest, SelectWithSameConditions) { EXPECT_THAT( r.replacement(), IsPhi( - kMachInt32, p1, p2, + MachineRepresentation::kWord32, p1, p2, AllOf(CaptureEq(&merge), IsMerge(IsIfTrue(CaptureEq(&branch)), IsIfFalse(AllOf(CaptureEq(&branch), IsBranch(p0, graph()->start()))))))); } { - Reduction const r = - Reduce(graph()->NewNode(common()->Select(kMachInt32), p0, p3, p4)); + Reduction const r = Reduce(graph()->NewNode( + common()->Select(MachineRepresentation::kWord32), p0, p3, p4)); ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsPhi(kMachInt32, p3, p4, CaptureEq(&merge))); + EXPECT_THAT(r.replacement(), IsPhi(MachineRepresentation::kWord32, p3, p4, + CaptureEq(&merge))); } { // We must not reuse the diamond if it is reachable from either else/then // values of the Select, because the resulting graph can not be scheduled. - Reduction const r = - Reduce(graph()->NewNode(common()->Select(kMachInt32), p0, s0, p0)); + Reduction const r = Reduce(graph()->NewNode( + common()->Select(MachineRepresentation::kWord32), p0, s0, p0)); ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsPhi(kMachInt32, s0, p0, Not(CaptureEq(&merge)))); + EXPECT_THAT(r.replacement(), IsPhi(MachineRepresentation::kWord32, s0, p0, + Not(CaptureEq(&merge)))); } } diff --git a/test/unittests/compiler/simplified-operator-unittest.cc b/test/unittests/compiler/simplified-operator-unittest.cc index b09840710a..871189ad79 100644 --- a/test/unittests/compiler/simplified-operator-unittest.cc +++ b/test/unittests/compiler/simplified-operator-unittest.cc @@ -200,37 +200,40 @@ INSTANTIATE_TEST_CASE_P(SimplifiedOperatorTest, namespace { const ElementAccess kElementAccesses[] = { - {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), kMachAnyTagged}, - {kUntaggedBase, 0, Type::Any(), kMachInt8}, - {kUntaggedBase, 0, Type::Any(), kMachInt16}, - {kUntaggedBase, 0, Type::Any(), kMachInt32}, - {kUntaggedBase, 0, Type::Any(), kMachUint8}, - {kUntaggedBase, 0, Type::Any(), kMachUint16}, - {kUntaggedBase, 0, Type::Any(), kMachUint32}, - {kUntaggedBase, 0, Type::Signed32(), kMachInt8}, - {kUntaggedBase, 0, Type::Unsigned32(), kMachUint8}, - {kUntaggedBase, 0, Type::Signed32(), kMachInt16}, - {kUntaggedBase, 0, Type::Unsigned32(), kMachUint16}, - {kUntaggedBase, 0, Type::Signed32(), kMachInt32}, - {kUntaggedBase, 0, Type::Unsigned32(), kMachUint32}, - {kUntaggedBase, 0, Type::Number(), kRepFloat32}, - {kUntaggedBase, 0, Type::Number(), kRepFloat64}, + {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), + MachineType::AnyTagged()}, + {kUntaggedBase, 0, Type::Any(), MachineType::Int8()}, + {kUntaggedBase, 0, Type::Any(), MachineType::Int16()}, + {kUntaggedBase, 0, Type::Any(), MachineType::Int32()}, + {kUntaggedBase, 0, Type::Any(), MachineType::Uint8()}, + {kUntaggedBase, 0, Type::Any(), MachineType::Uint16()}, + {kUntaggedBase, 0, Type::Any(), MachineType::Uint32()}, + {kUntaggedBase, 0, Type::Signed32(), MachineType::Int8()}, + {kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint8()}, + {kUntaggedBase, 0, Type::Signed32(), MachineType::Int16()}, + {kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint16()}, + {kUntaggedBase, 0, Type::Signed32(), MachineType::Int32()}, + {kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint32()}, + {kUntaggedBase, 0, Type::Number(), + MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone)}, + {kUntaggedBase, 0, Type::Number(), + MachineType(MachineRepresentation::kFloat64, MachineSemantic::kNone)}, {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(), - kMachInt8}, + MachineType::Int8()}, {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(), - kMachUint8}, + MachineType::Uint8()}, {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(), - kMachInt16}, + MachineType::Int16()}, {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(), - kMachUint16}, + MachineType::Uint16()}, {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(), - kMachInt32}, + MachineType::Int32()}, {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(), - kMachUint32}, + MachineType::Uint32()}, {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(), - kRepFloat32}, + MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone)}, {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(), - kRepFloat64}}; + MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone)}}; } // namespace diff --git a/test/unittests/compiler/tail-call-optimization-unittest.cc b/test/unittests/compiler/tail-call-optimization-unittest.cc index 7257cc9802..3441c68b96 100644 --- a/test/unittests/compiler/tail-call-optimization-unittest.cc +++ b/test/unittests/compiler/tail-call-optimization-unittest.cc @@ -26,11 +26,12 @@ class TailCallOptimizationTest : public GraphTest { TEST_F(TailCallOptimizationTest, CallCodeObject0) { - MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; + MachineType kMachineSignature[] = {MachineType::AnyTagged(), + MachineType::AnyTagged()}; LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0), LinkageLocation::ForRegister(1)}; const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( - CallDescriptor::kCallCodeObject, kMachAnyTagged, + CallDescriptor::kCallCodeObject, MachineType::AnyTagged(), LinkageLocation::ForRegister(0), new (zone()) MachineSignature(1, 1, kMachineSignature), new (zone()) LocationSignature(1, 1, kLocationSignature), 0, @@ -47,11 +48,12 @@ TEST_F(TailCallOptimizationTest, CallCodeObject0) { TEST_F(TailCallOptimizationTest, CallCodeObject1) { - MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; + MachineType kMachineSignature[] = {MachineType::AnyTagged(), + MachineType::AnyTagged()}; LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0), LinkageLocation::ForRegister(1)}; const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( - CallDescriptor::kCallCodeObject, kMachAnyTagged, + CallDescriptor::kCallCodeObject, MachineType::AnyTagged(), LinkageLocation::ForRegister(0), new (zone()) MachineSignature(1, 1, kMachineSignature), new (zone()) LocationSignature(1, 1, kLocationSignature), 0, @@ -72,11 +74,12 @@ TEST_F(TailCallOptimizationTest, CallCodeObject1) { TEST_F(TailCallOptimizationTest, CallCodeObject2) { - MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; + MachineType kMachineSignature[] = {MachineType::AnyTagged(), + MachineType::AnyTagged()}; LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0), LinkageLocation::ForRegister(1)}; const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( - CallDescriptor::kCallCodeObject, kMachAnyTagged, + CallDescriptor::kCallCodeObject, MachineType::AnyTagged(), LinkageLocation::ForRegister(0), new (zone()) MachineSignature(1, 1, kMachineSignature), new (zone()) LocationSignature(1, 1, kLocationSignature), 0, @@ -95,11 +98,12 @@ TEST_F(TailCallOptimizationTest, CallCodeObject2) { TEST_F(TailCallOptimizationTest, CallJSFunction0) { - MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; + MachineType kMachineSignature[] = {MachineType::AnyTagged(), + MachineType::AnyTagged()}; LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0), LinkageLocation::ForRegister(1)}; const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( - CallDescriptor::kCallJSFunction, kMachAnyTagged, + CallDescriptor::kCallJSFunction, MachineType::AnyTagged(), LinkageLocation::ForRegister(0), new (zone()) MachineSignature(1, 1, kMachineSignature), new (zone()) LocationSignature(1, 1, kLocationSignature), 0, @@ -116,11 +120,12 @@ TEST_F(TailCallOptimizationTest, CallJSFunction0) { TEST_F(TailCallOptimizationTest, CallJSFunction1) { - MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; + MachineType kMachineSignature[] = {MachineType::AnyTagged(), + MachineType::AnyTagged()}; LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0), LinkageLocation::ForRegister(1)}; const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( - CallDescriptor::kCallJSFunction, kMachAnyTagged, + CallDescriptor::kCallJSFunction, MachineType::AnyTagged(), LinkageLocation::ForRegister(0), new (zone()) MachineSignature(1, 1, kMachineSignature), new (zone()) LocationSignature(1, 1, kLocationSignature), 0, @@ -141,11 +146,12 @@ TEST_F(TailCallOptimizationTest, CallJSFunction1) { TEST_F(TailCallOptimizationTest, CallJSFunction2) { - MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; + MachineType kMachineSignature[] = {MachineType::AnyTagged(), + MachineType::AnyTagged()}; LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0), LinkageLocation::ForRegister(1)}; const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( - CallDescriptor::kCallJSFunction, kMachAnyTagged, + CallDescriptor::kCallJSFunction, MachineType::AnyTagged(), LinkageLocation::ForRegister(0), new (zone()) MachineSignature(1, 1, kMachineSignature), new (zone()) LocationSignature(1, 1, kLocationSignature), 0, diff --git a/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc b/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc index f28087c54c..a6b3514bc1 100644 --- a/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc +++ b/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc @@ -15,7 +15,7 @@ namespace compiler { TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { - StreamBuilder m(this, kMachFloat32, kMachFloat64); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float64()); m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -26,7 +26,7 @@ TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { TEST_F(InstructionSelectorTest, ChangeInt32ToInt64WithParameter) { - StreamBuilder m(this, kMachInt64, kMachInt32); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int32()); m.Return(m.ChangeInt32ToInt64(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -35,7 +35,7 @@ TEST_F(InstructionSelectorTest, ChangeInt32ToInt64WithParameter) { TEST_F(InstructionSelectorTest, ChangeUint32ToFloat64WithParameter) { - StreamBuilder m(this, kMachFloat64, kMachUint32); + StreamBuilder m(this, MachineType::Float64(), MachineType::Uint32()); m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -44,7 +44,7 @@ TEST_F(InstructionSelectorTest, ChangeUint32ToFloat64WithParameter) { TEST_F(InstructionSelectorTest, ChangeUint32ToUint64WithParameter) { - StreamBuilder m(this, kMachUint64, kMachUint32); + StreamBuilder m(this, MachineType::Uint64(), MachineType::Uint32()); m.Return(m.ChangeUint32ToUint64(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -53,7 +53,7 @@ TEST_F(InstructionSelectorTest, ChangeUint32ToUint64WithParameter) { TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) { - StreamBuilder m(this, kMachFloat64, kMachFloat32); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float32()); m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -64,7 +64,7 @@ TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) { TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) { - StreamBuilder m(this, kMachInt32, kMachInt64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int64()); m.Return(m.TruncateInt64ToInt32(m.Parameter(0))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -91,16 +91,16 @@ std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) { static const MemoryAccess kMemoryAccesses[] = { - {kMachInt8, kX64Movsxbl, kX64Movb}, - {kMachUint8, kX64Movzxbl, kX64Movb}, - {kMachInt16, kX64Movsxwl, kX64Movw}, - {kMachUint16, kX64Movzxwl, kX64Movw}, - {kMachInt32, kX64Movl, kX64Movl}, - {kMachUint32, kX64Movl, kX64Movl}, - {kMachInt64, kX64Movq, kX64Movq}, - {kMachUint64, kX64Movq, kX64Movq}, - {kMachFloat32, kX64Movss, kX64Movss}, - {kMachFloat64, kX64Movsd, kX64Movsd}}; + {MachineType::Int8(), kX64Movsxbl, kX64Movb}, + {MachineType::Uint8(), kX64Movzxbl, kX64Movb}, + {MachineType::Int16(), kX64Movsxwl, kX64Movw}, + {MachineType::Uint16(), kX64Movzxwl, kX64Movw}, + {MachineType::Int32(), kX64Movl, kX64Movl}, + {MachineType::Uint32(), kX64Movl, kX64Movl}, + {MachineType::Int64(), kX64Movq, kX64Movq}, + {MachineType::Uint64(), kX64Movq, kX64Movq}, + {MachineType::Float32(), kX64Movss, kX64Movss}, + {MachineType::Float64(), kX64Movsd, kX64Movsd}}; } // namespace @@ -111,7 +111,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32); + StreamBuilder m(this, memacc.type, MachineType::Pointer(), + MachineType::Int32()); m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1))); Stream s = m.Build(); ASSERT_EQ(1U, s.size()); @@ -123,7 +124,8 @@ TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { const MemoryAccess memacc = GetParam(); - StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type); + StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), + MachineType::Int32(), memacc.type); m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2), kNoWriteBarrier); m.Return(m.Int32Constant(0)); @@ -191,7 +193,8 @@ typedef InstructionSelectorTestWithParam TEST_P(InstructionSelectorChangeUint32ToUint64Test, ChangeUint32ToUint64) { const BinaryOperation& bop = GetParam(); - StreamBuilder m(this, kMachUint64, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Uint64(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); m.Return(m.ChangeUint32ToUint64((m.*bop.constructor)(p0, p1))); @@ -210,7 +213,7 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) { - StreamBuilder m(this, kMachInt32, kMachInt64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int64()); Node* const p = m.Parameter(0); Node* const t = m.TruncateInt64ToInt32(m.Word64Sar(p, m.Int64Constant(32))); m.Return(t); @@ -227,7 +230,7 @@ TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) { TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Shr) { - StreamBuilder m(this, kMachInt32, kMachInt64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int64()); Node* const p = m.Parameter(0); Node* const t = m.TruncateInt64ToInt32(m.Word64Shr(p, m.Int64Constant(32))); m.Return(t); @@ -248,7 +251,8 @@ TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Shr) { TEST_F(InstructionSelectorTest, Int32AddWithInt32ParametersLea) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const a0 = m.Int32Add(p0, p1); @@ -265,7 +269,7 @@ TEST_F(InstructionSelectorTest, Int32AddWithInt32ParametersLea) { TEST_F(InstructionSelectorTest, Int32AddConstantAsLeaSingle) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const c0 = m.Int32Constant(15); // If one of the add's operands is only used once, use an "leal", even though @@ -287,7 +291,7 @@ TEST_F(InstructionSelectorTest, Int32AddConstantAsLeaSingle) { TEST_F(InstructionSelectorTest, Int32AddConstantAsAdd) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const c0 = m.Int32Constant(1); // If there is only a single use of an add's input and the immediate constant @@ -305,7 +309,7 @@ TEST_F(InstructionSelectorTest, Int32AddConstantAsAdd) { TEST_F(InstructionSelectorTest, Int32AddConstantAsLeaDouble) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const c0 = m.Int32Constant(15); // A second use of an add's input uses lea @@ -322,7 +326,7 @@ TEST_F(InstructionSelectorTest, Int32AddConstantAsLeaDouble) { TEST_F(InstructionSelectorTest, Int32AddCommutedConstantAsLeaSingle) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const c0 = m.Int32Constant(15); // If one of the add's operands is only used once, use an "leal", even though @@ -343,7 +347,7 @@ TEST_F(InstructionSelectorTest, Int32AddCommutedConstantAsLeaSingle) { TEST_F(InstructionSelectorTest, Int32AddCommutedConstantAsLeaDouble) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const c0 = m.Int32Constant(15); // A second use of an add's input uses lea @@ -361,7 +365,8 @@ TEST_F(InstructionSelectorTest, Int32AddCommutedConstantAsLeaDouble) { TEST_F(InstructionSelectorTest, Int32AddSimpleAsAdd) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); // If one of the add's operands is only used once, use an "leal", even though @@ -382,7 +387,8 @@ TEST_F(InstructionSelectorTest, Int32AddSimpleAsAdd) { TEST_F(InstructionSelectorTest, Int32AddSimpleAsLea) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); // If all of of the add's operands are used multiple times, use an "leal". @@ -399,7 +405,8 @@ TEST_F(InstructionSelectorTest, Int32AddSimpleAsLea) { TEST_F(InstructionSelectorTest, Int32AddScaled2Mul) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(2)); @@ -415,7 +422,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2Mul) { TEST_F(InstructionSelectorTest, Int32AddCommutedScaled2Mul) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(2)); @@ -431,7 +439,8 @@ TEST_F(InstructionSelectorTest, Int32AddCommutedScaled2Mul) { TEST_F(InstructionSelectorTest, Int32AddScaled2Shl) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Word32Shl(p1, m.Int32Constant(1)); @@ -447,7 +456,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2Shl) { TEST_F(InstructionSelectorTest, Int32AddCommutedScaled2Shl) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Word32Shl(p1, m.Int32Constant(1)); @@ -463,7 +473,8 @@ TEST_F(InstructionSelectorTest, Int32AddCommutedScaled2Shl) { TEST_F(InstructionSelectorTest, Int32AddScaled4Mul) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(4)); @@ -479,7 +490,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled4Mul) { TEST_F(InstructionSelectorTest, Int32AddScaled4Shl) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Word32Shl(p1, m.Int32Constant(2)); @@ -495,7 +507,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled4Shl) { TEST_F(InstructionSelectorTest, Int32AddScaled8Mul) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(8)); @@ -511,7 +524,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled8Mul) { TEST_F(InstructionSelectorTest, Int32AddScaled8Shl) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Word32Shl(p1, m.Int32Constant(3)); @@ -527,7 +541,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled8Shl) { TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstant) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(2)); @@ -545,7 +560,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstant) { TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle1) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(2)); @@ -563,7 +579,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle1) { TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle2) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(2)); @@ -581,7 +598,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle2) { TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle3) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(2)); @@ -599,7 +617,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle3) { TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle4) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(2)); @@ -617,7 +636,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle4) { TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle5) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(2)); @@ -635,7 +655,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle5) { TEST_F(InstructionSelectorTest, Int32AddScaled2ShlWithConstant) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Word32Shl(p1, m.Int32Constant(1)); @@ -653,7 +674,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2ShlWithConstant) { TEST_F(InstructionSelectorTest, Int32AddScaled4MulWithConstant) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(4)); @@ -671,7 +693,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled4MulWithConstant) { TEST_F(InstructionSelectorTest, Int32AddScaled4ShlWithConstant) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Word32Shl(p1, m.Int32Constant(2)); @@ -689,7 +712,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled4ShlWithConstant) { TEST_F(InstructionSelectorTest, Int32AddScaled8MulWithConstant) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Int32Mul(p1, m.Int32Constant(8)); @@ -707,7 +731,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled8MulWithConstant) { TEST_F(InstructionSelectorTest, Int32AddScaled8ShlWithConstant) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const s0 = m.Word32Shl(p1, m.Int32Constant(3)); @@ -725,7 +750,7 @@ TEST_F(InstructionSelectorTest, Int32AddScaled8ShlWithConstant) { TEST_F(InstructionSelectorTest, Int32SubConstantAsSub) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const c0 = m.Int32Constant(-1); // If there is only a single use of on of the sub's non-constant input, use a @@ -742,7 +767,7 @@ TEST_F(InstructionSelectorTest, Int32SubConstantAsSub) { TEST_F(InstructionSelectorTest, Int32SubConstantAsLea) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const c0 = m.Int32Constant(-1); // If there are multiple uses of on of the sub's non-constant input, use a @@ -760,7 +785,8 @@ TEST_F(InstructionSelectorTest, Int32SubConstantAsLea) { TEST_F(InstructionSelectorTest, Int32AddScaled2Other) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const p2 = m.Parameter(2); @@ -789,7 +815,8 @@ TEST_F(InstructionSelectorTest, Int32AddScaled2Other) { TEST_F(InstructionSelectorTest, Int32MulWithInt32MulWithParameters) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const m0 = m.Int32Mul(p0, p1); @@ -810,7 +837,8 @@ TEST_F(InstructionSelectorTest, Int32MulWithInt32MulWithParameters) { TEST_F(InstructionSelectorTest, Int32MulHigh) { - StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), + MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Int32MulHigh(p0, p1); @@ -830,7 +858,8 @@ TEST_F(InstructionSelectorTest, Int32MulHigh) { TEST_F(InstructionSelectorTest, Uint32MulHigh) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const p1 = m.Parameter(1); Node* const n = m.Uint32MulHigh(p0, p1); @@ -850,7 +879,8 @@ TEST_F(InstructionSelectorTest, Uint32MulHigh) { TEST_F(InstructionSelectorTest, Int32Mul2BecomesLea) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const c1 = m.Int32Constant(2); Node* const n = m.Int32Mul(p0, c1); @@ -866,7 +896,8 @@ TEST_F(InstructionSelectorTest, Int32Mul2BecomesLea) { TEST_F(InstructionSelectorTest, Int32Mul3BecomesLea) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const c1 = m.Int32Constant(3); Node* const n = m.Int32Mul(p0, c1); @@ -882,7 +913,8 @@ TEST_F(InstructionSelectorTest, Int32Mul3BecomesLea) { TEST_F(InstructionSelectorTest, Int32Mul4BecomesLea) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const c1 = m.Int32Constant(4); Node* const n = m.Int32Mul(p0, c1); @@ -897,7 +929,8 @@ TEST_F(InstructionSelectorTest, Int32Mul4BecomesLea) { TEST_F(InstructionSelectorTest, Int32Mul5BecomesLea) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const c1 = m.Int32Constant(5); Node* const n = m.Int32Mul(p0, c1); @@ -913,7 +946,8 @@ TEST_F(InstructionSelectorTest, Int32Mul5BecomesLea) { TEST_F(InstructionSelectorTest, Int32Mul8BecomesLea) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const c1 = m.Int32Constant(8); Node* const n = m.Int32Mul(p0, c1); @@ -928,7 +962,8 @@ TEST_F(InstructionSelectorTest, Int32Mul8BecomesLea) { TEST_F(InstructionSelectorTest, Int32Mul9BecomesLea) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const c1 = m.Int32Constant(9); Node* const n = m.Int32Mul(p0, c1); @@ -948,7 +983,8 @@ TEST_F(InstructionSelectorTest, Int32Mul9BecomesLea) { TEST_F(InstructionSelectorTest, Int32Shl1BecomesLea) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const c1 = m.Int32Constant(1); Node* const n = m.Word32Shl(p0, c1); @@ -964,7 +1000,8 @@ TEST_F(InstructionSelectorTest, Int32Shl1BecomesLea) { TEST_F(InstructionSelectorTest, Int32Shl2BecomesLea) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const c1 = m.Int32Constant(2); Node* const n = m.Word32Shl(p0, c1); @@ -979,7 +1016,8 @@ TEST_F(InstructionSelectorTest, Int32Shl2BecomesLea) { TEST_F(InstructionSelectorTest, Int32Shl4BecomesLea) { - StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), + MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const c1 = m.Int32Constant(3); Node* const n = m.Word32Shl(p0, c1); @@ -999,7 +1037,7 @@ TEST_F(InstructionSelectorTest, Int32Shl4BecomesLea) { TEST_F(InstructionSelectorTest, Float32Abs) { { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Abs(p0); m.Return(n); @@ -1014,7 +1052,7 @@ TEST_F(InstructionSelectorTest, Float32Abs) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Abs(p0); m.Return(n); @@ -1032,7 +1070,7 @@ TEST_F(InstructionSelectorTest, Float32Abs) { TEST_F(InstructionSelectorTest, Float64Abs) { { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Abs(p0); m.Return(n); @@ -1047,7 +1085,7 @@ TEST_F(InstructionSelectorTest, Float64Abs) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Abs(p0); m.Return(n); @@ -1065,7 +1103,8 @@ TEST_F(InstructionSelectorTest, Float64Abs) { TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); Node* mul = m.Float64Mul(add, m.Parameter(1)); Node* sub = m.Float64Sub(mul, add); @@ -1079,7 +1118,8 @@ TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { EXPECT_EQ(kAVXFloat64Div, s[3]->arch_opcode()); } { - StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), + MachineType::Float64()); Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); Node* mul = m.Float64Mul(add, m.Parameter(1)); Node* sub = m.Float64Sub(mul, add); @@ -1097,7 +1137,7 @@ TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); m.Return(n); @@ -1111,7 +1151,7 @@ TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat32, kMachFloat32); + StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); Node* const p0 = m.Parameter(0); Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); m.Return(n); @@ -1129,7 +1169,7 @@ TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); m.Return(n); @@ -1143,7 +1183,7 @@ TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { EXPECT_EQ(kFlags_none, s[0]->flags_mode()); } { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* const p0 = m.Parameter(0); Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); m.Return(n); @@ -1164,9 +1204,9 @@ TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { TEST_F(InstructionSelectorTest, Uint64LessThanWithLoadAndLoadStackPointer) { - StreamBuilder m(this, kMachBool); + StreamBuilder m(this, MachineType::Bool()); Node* const sl = m.Load( - kMachPtr, + MachineType::Pointer(), m.ExternalConstant(ExternalReference::address_of_stack_limit(isolate()))); Node* const sp = m.LoadStackPointer(); Node* const n = m.Uint64LessThan(sl, sp); @@ -1184,7 +1224,7 @@ TEST_F(InstructionSelectorTest, Uint64LessThanWithLoadAndLoadStackPointer) { TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) { TRACED_FORRANGE(int64_t, x, 32, 63) { - StreamBuilder m(this, kMachInt64, kMachInt32); + StreamBuilder m(this, MachineType::Int64(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word64Shl(m.ChangeInt32ToInt64(p0), m.Int64Constant(x)); m.Return(n); @@ -1203,7 +1243,7 @@ TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) { TEST_F(InstructionSelectorTest, Word64ShlWithChangeUint32ToUint64) { TRACED_FORRANGE(int64_t, x, 32, 63) { - StreamBuilder m(this, kMachInt64, kMachUint32); + StreamBuilder m(this, MachineType::Int64(), MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word64Shl(m.ChangeUint32ToUint64(p0), m.Int64Constant(x)); m.Return(n); @@ -1222,7 +1262,7 @@ TEST_F(InstructionSelectorTest, Word64ShlWithChangeUint32ToUint64) { TEST_F(InstructionSelectorTest, Word32AndWith0xff) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32And(p0, m.Int32Constant(0xff)); m.Return(n); @@ -1235,7 +1275,7 @@ TEST_F(InstructionSelectorTest, Word32AndWith0xff) { EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32And(m.Int32Constant(0xff), p0); m.Return(n); @@ -1252,7 +1292,7 @@ TEST_F(InstructionSelectorTest, Word32AndWith0xff) { TEST_F(InstructionSelectorTest, Word32AndWith0xffff) { { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32And(p0, m.Int32Constant(0xffff)); m.Return(n); @@ -1265,7 +1305,7 @@ TEST_F(InstructionSelectorTest, Word32AndWith0xffff) { EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); } { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32And(m.Int32Constant(0xffff), p0); m.Return(n); @@ -1281,7 +1321,7 @@ TEST_F(InstructionSelectorTest, Word32AndWith0xffff) { TEST_F(InstructionSelectorTest, Word32Clz) { - StreamBuilder m(this, kMachUint32, kMachUint32); + StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32()); Node* const p0 = m.Parameter(0); Node* const n = m.Word32Clz(p0); m.Return(n);