2014-08-19 08:48:41 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "src/compiler/machine-operator.h"
|
2015-01-02 07:43:34 +00:00
|
|
|
#include "src/compiler/opcodes.h"
|
|
|
|
#include "src/compiler/operator.h"
|
|
|
|
#include "src/compiler/operator-properties.h"
|
|
|
|
#include "test/unittests/test-utils.h"
|
2014-08-19 08:48:41 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
2017-10-18 17:01:45 +00:00
|
|
|
namespace machine_operator_unittest {
|
2014-08-19 08:48:41 +00:00
|
|
|
|
2014-09-11 10:37:49 +00:00
|
|
|
#if GTEST_HAS_COMBINE
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
class MachineOperatorTestWithParam
|
2015-01-02 07:43:34 +00:00
|
|
|
: public TestWithZone,
|
2015-12-10 09:03:30 +00:00
|
|
|
public ::testing::WithParamInterface<
|
|
|
|
::testing::tuple<MachineRepresentation, T> > {
|
2014-08-19 08:48:41 +00:00
|
|
|
protected:
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineRepresentation representation() const {
|
|
|
|
return ::testing::get<0>(B::GetParam());
|
|
|
|
}
|
2014-09-11 10:37:49 +00:00
|
|
|
const T& GetParam() const { return ::testing::get<1>(B::GetParam()); }
|
2014-08-19 08:48:41 +00:00
|
|
|
|
|
|
|
private:
|
2015-12-10 09:03:30 +00:00
|
|
|
typedef ::testing::WithParamInterface<
|
|
|
|
::testing::tuple<MachineRepresentation, T> > B;
|
2014-08-19 08:48:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-12-10 09:03:30 +00:00
|
|
|
const MachineRepresentation kMachineReps[] = {MachineRepresentation::kWord32,
|
|
|
|
MachineRepresentation::kWord64};
|
2014-09-11 10:37:49 +00:00
|
|
|
|
|
|
|
|
2015-09-15 05:45:20 +00:00
|
|
|
const MachineType kMachineTypesForAccess[] = {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineType::Float32(), MachineType::Float64(), MachineType::Int8(),
|
|
|
|
MachineType::Uint8(), MachineType::Int16(), MachineType::Uint16(),
|
|
|
|
MachineType::Int32(), MachineType::Uint32(), MachineType::Int64(),
|
|
|
|
MachineType::Uint64(), MachineType::AnyTagged()};
|
2014-09-11 10:37:49 +00:00
|
|
|
|
2015-12-11 15:34:00 +00:00
|
|
|
|
|
|
|
const MachineRepresentation kRepresentationsForStore[] = {
|
|
|
|
MachineRepresentation::kFloat32, MachineRepresentation::kFloat64,
|
|
|
|
MachineRepresentation::kWord8, MachineRepresentation::kWord16,
|
|
|
|
MachineRepresentation::kWord32, MachineRepresentation::kWord64,
|
|
|
|
MachineRepresentation::kTagged};
|
|
|
|
|
2014-09-11 10:37:49 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Load operator.
|
|
|
|
|
|
|
|
|
|
|
|
typedef MachineOperatorTestWithParam<LoadRepresentation>
|
|
|
|
MachineLoadOperatorTest;
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(MachineLoadOperatorTest, InstancesAreGloballyShared) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine1(zone(), representation());
|
|
|
|
MachineOperatorBuilder machine2(zone(), representation());
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(machine1.Load(GetParam()), machine2.Load(GetParam()));
|
2014-08-19 08:48:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-11 10:37:49 +00:00
|
|
|
TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine(zone(), representation());
|
2014-09-11 10:37:49 +00:00
|
|
|
const Operator* op = machine.Load(GetParam());
|
|
|
|
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(2, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(1, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(1, op->ControlInputCount());
|
2014-10-01 11:08:37 +00:00
|
|
|
EXPECT_EQ(4, OperatorProperties::GetTotalInputCount(op));
|
2014-09-11 10:37:49 +00:00
|
|
|
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(1, op->ValueOutputCount());
|
|
|
|
EXPECT_EQ(1, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
2014-08-19 08:48:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-11 10:37:49 +00:00
|
|
|
TEST_P(MachineLoadOperatorTest, OpcodeIsCorrect) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine(zone(), representation());
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(IrOpcode::kLoad, machine.Load(GetParam())->opcode());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(MachineLoadOperatorTest, ParameterIsCorrect) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine(zone(), representation());
|
2018-03-21 16:21:56 +00:00
|
|
|
EXPECT_EQ(GetParam(), LoadRepresentationOf(machine.Load(GetParam())));
|
2014-08-20 04:01:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-15 05:45:20 +00:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
MachineOperatorTest, MachineLoadOperatorTest,
|
|
|
|
::testing::Combine(::testing::ValuesIn(kMachineReps),
|
|
|
|
::testing::ValuesIn(kMachineTypesForAccess)));
|
2014-09-11 10:37:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Store operator.
|
|
|
|
|
|
|
|
|
|
|
|
class MachineStoreOperatorTest
|
|
|
|
: public MachineOperatorTestWithParam<
|
2015-12-11 15:34:00 +00:00
|
|
|
::testing::tuple<MachineRepresentation, WriteBarrierKind> > {
|
2014-09-11 10:37:49 +00:00
|
|
|
protected:
|
|
|
|
StoreRepresentation GetParam() const {
|
|
|
|
return StoreRepresentation(
|
2015-12-11 15:34:00 +00:00
|
|
|
::testing::get<0>(
|
|
|
|
MachineOperatorTestWithParam< ::testing::tuple<
|
|
|
|
MachineRepresentation, WriteBarrierKind> >::GetParam()),
|
|
|
|
::testing::get<1>(
|
|
|
|
MachineOperatorTestWithParam< ::testing::tuple<
|
|
|
|
MachineRepresentation, WriteBarrierKind> >::GetParam()));
|
2014-09-11 10:37:49 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(MachineStoreOperatorTest, InstancesAreGloballyShared) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine1(zone(), representation());
|
|
|
|
MachineOperatorBuilder machine2(zone(), representation());
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(machine1.Store(GetParam()), machine2.Store(GetParam()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine(zone(), representation());
|
2014-09-11 10:37:49 +00:00
|
|
|
const Operator* op = machine.Store(GetParam());
|
|
|
|
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(3, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(1, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(1, op->ControlInputCount());
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(5, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(0, op->ValueOutputCount());
|
|
|
|
EXPECT_EQ(1, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
2014-09-11 10:37:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(MachineStoreOperatorTest, OpcodeIsCorrect) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine(zone(), representation());
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(IrOpcode::kStore, machine.Store(GetParam())->opcode());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(MachineStoreOperatorTest, ParameterIsCorrect) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine(zone(), representation());
|
2018-03-21 16:21:56 +00:00
|
|
|
EXPECT_EQ(GetParam(), StoreRepresentationOf(machine.Store(GetParam())));
|
2014-09-11 10:37:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
MachineOperatorTest, MachineStoreOperatorTest,
|
|
|
|
::testing::Combine(
|
|
|
|
::testing::ValuesIn(kMachineReps),
|
2015-12-11 15:34:00 +00:00
|
|
|
::testing::Combine(::testing::ValuesIn(kRepresentationsForStore),
|
2014-09-11 10:37:49 +00:00
|
|
|
::testing::Values(kNoWriteBarrier,
|
|
|
|
kFullWriteBarrier))));
|
2015-06-23 10:35:33 +00:00
|
|
|
#endif
|
2014-09-11 10:37:49 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Pure operators.
|
|
|
|
|
|
|
|
struct PureOperator {
|
2014-09-22 09:48:26 +00:00
|
|
|
const Operator* (MachineOperatorBuilder::*constructor)();
|
2015-06-23 10:35:33 +00:00
|
|
|
char const* const constructor_name;
|
2014-09-11 10:37:49 +00:00
|
|
|
int value_input_count;
|
2014-10-28 13:56:26 +00:00
|
|
|
int control_input_count;
|
2014-09-11 10:37:49 +00:00
|
|
|
int value_output_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-06-23 10:35:33 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, PureOperator const& pop) {
|
|
|
|
return os << pop.constructor_name;
|
2014-09-11 10:37:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const PureOperator kPureOperators[] = {
|
2014-10-28 13:56:26 +00:00
|
|
|
#define PURE(Name, value_input_count, control_input_count, value_output_count) \
|
|
|
|
{ \
|
2015-06-23 10:35:33 +00:00
|
|
|
&MachineOperatorBuilder::Name, #Name, value_input_count, \
|
2014-10-28 13:56:26 +00:00
|
|
|
control_input_count, value_output_count \
|
2014-09-11 10:37:49 +00:00
|
|
|
}
|
2015-06-23 10:35:33 +00:00
|
|
|
PURE(Word32And, 2, 0, 1), // --
|
|
|
|
PURE(Word32Or, 2, 0, 1), // --
|
|
|
|
PURE(Word32Xor, 2, 0, 1), // --
|
|
|
|
PURE(Word32Shl, 2, 0, 1), // --
|
|
|
|
PURE(Word32Shr, 2, 0, 1), // --
|
|
|
|
PURE(Word32Sar, 2, 0, 1), // --
|
|
|
|
PURE(Word32Ror, 2, 0, 1), // --
|
|
|
|
PURE(Word32Equal, 2, 0, 1), // --
|
|
|
|
PURE(Word32Clz, 1, 0, 1), // --
|
|
|
|
PURE(Word64And, 2, 0, 1), // --
|
|
|
|
PURE(Word64Or, 2, 0, 1), // --
|
|
|
|
PURE(Word64Xor, 2, 0, 1), // --
|
|
|
|
PURE(Word64Shl, 2, 0, 1), // --
|
|
|
|
PURE(Word64Shr, 2, 0, 1), // --
|
|
|
|
PURE(Word64Sar, 2, 0, 1), // --
|
|
|
|
PURE(Word64Ror, 2, 0, 1), // --
|
|
|
|
PURE(Word64Equal, 2, 0, 1), // --
|
|
|
|
PURE(Int32Add, 2, 0, 1), // --
|
|
|
|
PURE(Int32Sub, 2, 0, 1), // --
|
|
|
|
PURE(Int32Mul, 2, 0, 1), // --
|
|
|
|
PURE(Int32MulHigh, 2, 0, 1), // --
|
|
|
|
PURE(Int32Div, 2, 1, 1), // --
|
|
|
|
PURE(Uint32Div, 2, 1, 1), // --
|
|
|
|
PURE(Int32Mod, 2, 1, 1), // --
|
|
|
|
PURE(Uint32Mod, 2, 1, 1), // --
|
|
|
|
PURE(Int32LessThan, 2, 0, 1), // --
|
|
|
|
PURE(Int32LessThanOrEqual, 2, 0, 1), // --
|
|
|
|
PURE(Uint32LessThan, 2, 0, 1), // --
|
|
|
|
PURE(Uint32LessThanOrEqual, 2, 0, 1), // --
|
|
|
|
PURE(Int64Add, 2, 0, 1), // --
|
|
|
|
PURE(Int64Sub, 2, 0, 1), // --
|
|
|
|
PURE(Int64Mul, 2, 0, 1), // --
|
2015-07-03 05:13:57 +00:00
|
|
|
PURE(Int64Div, 2, 1, 1), // --
|
|
|
|
PURE(Uint64Div, 2, 1, 1), // --
|
|
|
|
PURE(Int64Mod, 2, 1, 1), // --
|
|
|
|
PURE(Uint64Mod, 2, 1, 1), // --
|
2015-06-23 10:35:33 +00:00
|
|
|
PURE(Int64LessThan, 2, 0, 1), // --
|
|
|
|
PURE(Int64LessThanOrEqual, 2, 0, 1), // --
|
|
|
|
PURE(Uint64LessThan, 2, 0, 1), // --
|
2015-07-03 05:13:57 +00:00
|
|
|
PURE(Uint64LessThanOrEqual, 2, 0, 1), // --
|
2015-06-23 10:35:33 +00:00
|
|
|
PURE(ChangeFloat32ToFloat64, 1, 0, 1), // --
|
|
|
|
PURE(ChangeFloat64ToInt32, 1, 0, 1), // --
|
|
|
|
PURE(ChangeFloat64ToUint32, 1, 0, 1), // --
|
|
|
|
PURE(ChangeInt32ToInt64, 1, 0, 1), // --
|
|
|
|
PURE(ChangeUint32ToFloat64, 1, 0, 1), // --
|
|
|
|
PURE(ChangeUint32ToUint64, 1, 0, 1), // --
|
|
|
|
PURE(TruncateFloat64ToFloat32, 1, 0, 1), // --
|
|
|
|
PURE(TruncateInt64ToInt32, 1, 0, 1), // --
|
|
|
|
PURE(Float32Abs, 1, 0, 1), // --
|
|
|
|
PURE(Float32Add, 2, 0, 1), // --
|
|
|
|
PURE(Float32Sub, 2, 0, 1), // --
|
|
|
|
PURE(Float32Mul, 2, 0, 1), // --
|
|
|
|
PURE(Float32Div, 2, 0, 1), // --
|
|
|
|
PURE(Float32Sqrt, 1, 0, 1), // --
|
|
|
|
PURE(Float32Equal, 2, 0, 1), // --
|
|
|
|
PURE(Float32LessThan, 2, 0, 1), // --
|
|
|
|
PURE(Float32LessThanOrEqual, 2, 0, 1), // --
|
2016-08-05 18:49:15 +00:00
|
|
|
PURE(Float32Neg, 1, 0, 1), // --
|
2015-06-23 10:35:33 +00:00
|
|
|
PURE(Float64Abs, 1, 0, 1), // --
|
|
|
|
PURE(Float64Add, 2, 0, 1), // --
|
|
|
|
PURE(Float64Sub, 2, 0, 1), // --
|
|
|
|
PURE(Float64Mul, 2, 0, 1), // --
|
|
|
|
PURE(Float64Div, 2, 0, 1), // --
|
|
|
|
PURE(Float64Mod, 2, 0, 1), // --
|
|
|
|
PURE(Float64Sqrt, 1, 0, 1), // --
|
2016-07-22 08:22:05 +00:00
|
|
|
PURE(Float64Max, 2, 0, 1), // --
|
|
|
|
PURE(Float64Min, 2, 0, 1), // --
|
2015-06-23 10:35:33 +00:00
|
|
|
PURE(Float64Equal, 2, 0, 1), // --
|
|
|
|
PURE(Float64LessThan, 2, 0, 1), // --
|
|
|
|
PURE(Float64LessThanOrEqual, 2, 0, 1), // --
|
|
|
|
PURE(LoadStackPointer, 0, 0, 1), // --
|
|
|
|
PURE(Float64ExtractLowWord32, 1, 0, 1), // --
|
|
|
|
PURE(Float64ExtractHighWord32, 1, 0, 1), // --
|
|
|
|
PURE(Float64InsertLowWord32, 2, 0, 1), // --
|
|
|
|
PURE(Float64InsertHighWord32, 2, 0, 1), // --
|
2016-08-05 18:49:15 +00:00
|
|
|
PURE(Float64Neg, 1, 0, 1), // --
|
2014-09-11 10:37:49 +00:00
|
|
|
#undef PURE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-06-23 10:35:33 +00:00
|
|
|
class MachinePureOperatorTest : public TestWithZone {
|
|
|
|
protected:
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineRepresentation word_type() {
|
|
|
|
return MachineType::PointerRepresentation();
|
|
|
|
}
|
2015-06-23 10:35:33 +00:00
|
|
|
};
|
2014-09-11 10:37:49 +00:00
|
|
|
|
2015-06-23 10:35:33 +00:00
|
|
|
|
|
|
|
TEST_F(MachinePureOperatorTest, PureOperators) {
|
2015-12-10 09:03:30 +00:00
|
|
|
TRACED_FOREACH(MachineRepresentation, machine_rep1, kMachineReps) {
|
2015-06-23 10:35:33 +00:00
|
|
|
MachineOperatorBuilder machine1(zone(), machine_rep1);
|
2015-12-10 09:03:30 +00:00
|
|
|
TRACED_FOREACH(MachineRepresentation, machine_rep2, kMachineReps) {
|
2015-06-23 10:35:33 +00:00
|
|
|
MachineOperatorBuilder machine2(zone(), machine_rep2);
|
|
|
|
TRACED_FOREACH(PureOperator, pop, kPureOperators) {
|
|
|
|
const Operator* op1 = (machine1.*pop.constructor)();
|
|
|
|
const Operator* op2 = (machine2.*pop.constructor)();
|
|
|
|
EXPECT_EQ(op1, op2);
|
|
|
|
EXPECT_EQ(pop.value_input_count, op1->ValueInputCount());
|
|
|
|
EXPECT_EQ(pop.control_input_count, op1->ControlInputCount());
|
|
|
|
EXPECT_EQ(pop.value_output_count, op1->ValueOutputCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-11 10:37:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-23 10:35:33 +00:00
|
|
|
// Optional operators.
|
2014-09-11 10:37:49 +00:00
|
|
|
|
2015-06-23 10:35:33 +00:00
|
|
|
struct OptionalOperatorEntry {
|
|
|
|
const OptionalOperator (MachineOperatorBuilder::*constructor)();
|
|
|
|
MachineOperatorBuilder::Flag enabling_flag;
|
|
|
|
char const* const constructor_name;
|
|
|
|
int value_input_count;
|
|
|
|
int control_input_count;
|
|
|
|
int value_output_count;
|
|
|
|
};
|
2014-09-11 10:37:49 +00:00
|
|
|
|
|
|
|
|
2015-06-23 10:35:33 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, OptionalOperatorEntry const& pop) {
|
|
|
|
return os << pop.constructor_name;
|
2014-08-19 08:48:41 +00:00
|
|
|
}
|
|
|
|
|
2015-06-23 10:35:33 +00:00
|
|
|
const OptionalOperatorEntry kOptionalOperators[] = {
|
|
|
|
#define OPTIONAL_ENTRY(Name, value_input_count, control_input_count, \
|
|
|
|
value_output_count) \
|
|
|
|
{ \
|
|
|
|
&MachineOperatorBuilder::Name, MachineOperatorBuilder::k##Name, #Name, \
|
|
|
|
value_input_count, control_input_count, value_output_count \
|
|
|
|
}
|
|
|
|
OPTIONAL_ENTRY(Float64RoundDown, 1, 0, 1), // --
|
|
|
|
OPTIONAL_ENTRY(Float64RoundTruncate, 1, 0, 1), // --
|
|
|
|
OPTIONAL_ENTRY(Float64RoundTiesAway, 1, 0, 1), // --
|
|
|
|
#undef OPTIONAL_ENTRY
|
|
|
|
};
|
2014-08-19 08:48:41 +00:00
|
|
|
|
2014-09-11 10:37:49 +00:00
|
|
|
|
2015-06-23 10:35:33 +00:00
|
|
|
class MachineOptionalOperatorTest : public TestWithZone {
|
|
|
|
protected:
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineRepresentation word_rep() {
|
|
|
|
return MachineType::PointerRepresentation();
|
|
|
|
}
|
2015-06-23 10:35:33 +00:00
|
|
|
};
|
2014-09-11 10:37:49 +00:00
|
|
|
|
|
|
|
|
2015-06-23 10:35:33 +00:00
|
|
|
TEST_F(MachineOptionalOperatorTest, OptionalOperators) {
|
|
|
|
TRACED_FOREACH(OptionalOperatorEntry, pop, kOptionalOperators) {
|
2015-12-10 09:03:30 +00:00
|
|
|
TRACED_FOREACH(MachineRepresentation, machine_rep1, kMachineReps) {
|
2015-06-23 10:35:33 +00:00
|
|
|
MachineOperatorBuilder machine1(zone(), machine_rep1, pop.enabling_flag);
|
2015-12-10 09:03:30 +00:00
|
|
|
TRACED_FOREACH(MachineRepresentation, machine_rep2, kMachineReps) {
|
2015-06-23 10:35:33 +00:00
|
|
|
MachineOperatorBuilder machine2(zone(), machine_rep2,
|
|
|
|
pop.enabling_flag);
|
|
|
|
const Operator* op1 = (machine1.*pop.constructor)().op();
|
|
|
|
const Operator* op2 = (machine2.*pop.constructor)().op();
|
|
|
|
EXPECT_EQ(op1, op2);
|
|
|
|
EXPECT_EQ(pop.value_input_count, op1->ValueInputCount());
|
|
|
|
EXPECT_EQ(pop.control_input_count, op1->ControlInputCount());
|
|
|
|
EXPECT_EQ(pop.value_output_count, op1->ValueOutputCount());
|
|
|
|
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine3(zone(), word_rep());
|
2015-06-23 10:35:33 +00:00
|
|
|
EXPECT_TRUE((machine1.*pop.constructor)().IsSupported());
|
|
|
|
EXPECT_FALSE((machine3.*pop.constructor)().IsSupported());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-11 10:37:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Pseudo operators.
|
|
|
|
|
|
|
|
|
2015-01-02 07:43:34 +00:00
|
|
|
typedef TestWithZone MachineOperatorTest;
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine(zone(), MachineRepresentation::kWord32);
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(machine.Word32And(), machine.WordAnd());
|
|
|
|
EXPECT_EQ(machine.Word32Or(), machine.WordOr());
|
|
|
|
EXPECT_EQ(machine.Word32Xor(), machine.WordXor());
|
|
|
|
EXPECT_EQ(machine.Word32Shl(), machine.WordShl());
|
|
|
|
EXPECT_EQ(machine.Word32Shr(), machine.WordShr());
|
|
|
|
EXPECT_EQ(machine.Word32Sar(), machine.WordSar());
|
|
|
|
EXPECT_EQ(machine.Word32Ror(), machine.WordRor());
|
|
|
|
EXPECT_EQ(machine.Word32Equal(), machine.WordEqual());
|
|
|
|
EXPECT_EQ(machine.Int32Add(), machine.IntAdd());
|
|
|
|
EXPECT_EQ(machine.Int32Sub(), machine.IntSub());
|
|
|
|
EXPECT_EQ(machine.Int32Mul(), machine.IntMul());
|
|
|
|
EXPECT_EQ(machine.Int32Div(), machine.IntDiv());
|
2014-10-01 10:39:11 +00:00
|
|
|
EXPECT_EQ(machine.Uint32Div(), machine.UintDiv());
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(machine.Int32Mod(), machine.IntMod());
|
2014-10-01 10:39:11 +00:00
|
|
|
EXPECT_EQ(machine.Uint32Mod(), machine.UintMod());
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(machine.Int32LessThan(), machine.IntLessThan());
|
|
|
|
EXPECT_EQ(machine.Int32LessThanOrEqual(), machine.IntLessThanOrEqual());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-02 07:43:34 +00:00
|
|
|
TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs64Bit) {
|
2015-12-10 09:03:30 +00:00
|
|
|
MachineOperatorBuilder machine(zone(), MachineRepresentation::kWord64);
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(machine.Word64And(), machine.WordAnd());
|
|
|
|
EXPECT_EQ(machine.Word64Or(), machine.WordOr());
|
|
|
|
EXPECT_EQ(machine.Word64Xor(), machine.WordXor());
|
|
|
|
EXPECT_EQ(machine.Word64Shl(), machine.WordShl());
|
|
|
|
EXPECT_EQ(machine.Word64Shr(), machine.WordShr());
|
|
|
|
EXPECT_EQ(machine.Word64Sar(), machine.WordSar());
|
|
|
|
EXPECT_EQ(machine.Word64Ror(), machine.WordRor());
|
|
|
|
EXPECT_EQ(machine.Word64Equal(), machine.WordEqual());
|
|
|
|
EXPECT_EQ(machine.Int64Add(), machine.IntAdd());
|
|
|
|
EXPECT_EQ(machine.Int64Sub(), machine.IntSub());
|
|
|
|
EXPECT_EQ(machine.Int64Mul(), machine.IntMul());
|
|
|
|
EXPECT_EQ(machine.Int64Div(), machine.IntDiv());
|
2014-10-01 10:39:11 +00:00
|
|
|
EXPECT_EQ(machine.Uint64Div(), machine.UintDiv());
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(machine.Int64Mod(), machine.IntMod());
|
2014-10-01 10:39:11 +00:00
|
|
|
EXPECT_EQ(machine.Uint64Mod(), machine.UintMod());
|
2014-09-11 10:37:49 +00:00
|
|
|
EXPECT_EQ(machine.Int64LessThan(), machine.IntLessThan());
|
|
|
|
EXPECT_EQ(machine.Int64LessThanOrEqual(), machine.IntLessThanOrEqual());
|
|
|
|
}
|
2014-08-19 08:48:41 +00:00
|
|
|
|
2017-10-18 17:01:45 +00:00
|
|
|
} // namespace machine_operator_unittest
|
2014-08-19 08:48:41 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|