| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/opcodes.h" | 8 #include "src/compiler/opcodes.h" |
| 9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
| 10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 CommonOperatorBuilder* common() { return &common_; } | 126 CommonOperatorBuilder* common() { return &common_; } |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 CommonOperatorBuilder common_; | 129 CommonOperatorBuilder common_; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 | 132 |
| 133 const int kArguments[] = {1, 5, 6, 42, 100, 10000, 65000}; | 133 const int kArguments[] = {1, 5, 6, 42, 100, 10000, 65000}; |
| 134 | 134 |
| 135 | 135 |
| 136 const size_t kCases[] = {2, 3, 4, 100, 255}; |
| 137 |
| 138 |
| 136 const float kFloatValues[] = {-std::numeric_limits<float>::infinity(), | 139 const float kFloatValues[] = {-std::numeric_limits<float>::infinity(), |
| 137 std::numeric_limits<float>::min(), | 140 std::numeric_limits<float>::min(), |
| 138 -1.0f, | 141 -1.0f, |
| 139 -0.0f, | 142 -0.0f, |
| 140 0.0f, | 143 0.0f, |
| 141 1.0f, | 144 1.0f, |
| 142 std::numeric_limits<float>::max(), | 145 std::numeric_limits<float>::max(), |
| 143 std::numeric_limits<float>::infinity(), | 146 std::numeric_limits<float>::infinity(), |
| 144 std::numeric_limits<float>::quiet_NaN(), | 147 std::numeric_limits<float>::quiet_NaN(), |
| 145 std::numeric_limits<float>::signaling_NaN()}; | 148 std::numeric_limits<float>::signaling_NaN()}; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 173 EXPECT_EQ(0, op->EffectInputCount()); | 176 EXPECT_EQ(0, op->EffectInputCount()); |
| 174 EXPECT_EQ(1, op->ControlInputCount()); | 177 EXPECT_EQ(1, op->ControlInputCount()); |
| 175 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | 178 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
| 176 EXPECT_EQ(0, op->ValueOutputCount()); | 179 EXPECT_EQ(0, op->ValueOutputCount()); |
| 177 EXPECT_EQ(0, op->EffectOutputCount()); | 180 EXPECT_EQ(0, op->EffectOutputCount()); |
| 178 EXPECT_EQ(2, op->ControlOutputCount()); | 181 EXPECT_EQ(2, op->ControlOutputCount()); |
| 179 } | 182 } |
| 180 } | 183 } |
| 181 | 184 |
| 182 | 185 |
| 186 TEST_F(CommonOperatorTest, Switch) { |
| 187 TRACED_FOREACH(size_t, cases, kCases) { |
| 188 const Operator* const op = common()->Switch(cases); |
| 189 EXPECT_EQ(IrOpcode::kSwitch, op->opcode()); |
| 190 EXPECT_EQ(Operator::kFoldable, op->properties()); |
| 191 EXPECT_EQ(1, op->ValueInputCount()); |
| 192 EXPECT_EQ(0, op->EffectInputCount()); |
| 193 EXPECT_EQ(1, op->ControlInputCount()); |
| 194 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
| 195 EXPECT_EQ(0, op->ValueOutputCount()); |
| 196 EXPECT_EQ(0, op->EffectOutputCount()); |
| 197 EXPECT_EQ(static_cast<int>(cases), op->ControlOutputCount()); |
| 198 } |
| 199 } |
| 200 |
| 201 |
| 202 TEST_F(CommonOperatorTest, Case) { |
| 203 TRACED_FORRANGE(size_t, index, 0, 1024) { |
| 204 const Operator* const op = common()->Case(index); |
| 205 EXPECT_EQ(IrOpcode::kCase, op->opcode()); |
| 206 EXPECT_EQ(Operator::kFoldable, op->properties()); |
| 207 EXPECT_EQ(index, CaseIndexOf(op)); |
| 208 EXPECT_EQ(0, op->ValueInputCount()); |
| 209 EXPECT_EQ(0, op->EffectInputCount()); |
| 210 EXPECT_EQ(1, op->ControlInputCount()); |
| 211 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); |
| 212 EXPECT_EQ(0, op->ValueOutputCount()); |
| 213 EXPECT_EQ(0, op->EffectOutputCount()); |
| 214 EXPECT_EQ(1, op->ControlOutputCount()); |
| 215 } |
| 216 } |
| 217 |
| 218 |
| 183 TEST_F(CommonOperatorTest, Select) { | 219 TEST_F(CommonOperatorTest, Select) { |
| 184 static const MachineType kTypes[] = { | 220 static const MachineType kTypes[] = { |
| 185 kMachInt8, kMachUint8, kMachInt16, kMachUint16, | 221 kMachInt8, kMachUint8, kMachInt16, kMachUint16, |
| 186 kMachInt32, kMachUint32, kMachInt64, kMachUint64, | 222 kMachInt32, kMachUint32, kMachInt64, kMachUint64, |
| 187 kMachFloat32, kMachFloat64, kMachAnyTagged}; | 223 kMachFloat32, kMachFloat64, kMachAnyTagged}; |
| 188 TRACED_FOREACH(MachineType, type, kTypes) { | 224 TRACED_FOREACH(MachineType, type, kTypes) { |
| 189 TRACED_FOREACH(BranchHint, hint, kHints) { | 225 TRACED_FOREACH(BranchHint, hint, kHints) { |
| 190 const Operator* const op = common()->Select(type, hint); | 226 const Operator* const op = common()->Select(type, hint); |
| 191 EXPECT_EQ(IrOpcode::kSelect, op->opcode()); | 227 EXPECT_EQ(IrOpcode::kSelect, op->opcode()); |
| 192 EXPECT_EQ(Operator::kPure, op->properties()); | 228 EXPECT_EQ(Operator::kPure, op->properties()); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); | 323 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); |
| 288 EXPECT_EQ(0, op->ControlOutputCount()); | 324 EXPECT_EQ(0, op->ControlOutputCount()); |
| 289 EXPECT_EQ(0, op->EffectOutputCount()); | 325 EXPECT_EQ(0, op->EffectOutputCount()); |
| 290 EXPECT_EQ(1, op->ValueOutputCount()); | 326 EXPECT_EQ(1, op->ValueOutputCount()); |
| 291 } | 327 } |
| 292 } | 328 } |
| 293 | 329 |
| 294 } // namespace compiler | 330 } // namespace compiler |
| 295 } // namespace internal | 331 } // namespace internal |
| 296 } // namespace v8 | 332 } // namespace v8 |
| OLD | NEW |