Index: src/compiler/machine-operator.cc |
diff --git a/src/compiler/machine-operator.cc b/src/compiler/machine-operator.cc |
index f34fc8673345893f93d749fa2999c3a0bb1692c1..2e2229032c0a52d8f603134923eab04203003296 100644 |
--- a/src/compiler/machine-operator.cc |
+++ b/src/compiler/machine-operator.cc |
@@ -12,6 +12,24 @@ namespace v8 { |
namespace internal { |
namespace compiler { |
+std::ostream& operator<<(std::ostream& os, TruncationMode mode) { |
+ switch (mode) { |
+ case TruncationMode::kJavaScript: |
+ return os << "JavaScript"; |
+ case TruncationMode::kRoundToZero: |
+ return os << "RoundToZero"; |
+ } |
+ UNREACHABLE(); |
+ return os; |
+} |
+ |
+ |
+TruncationMode TruncationModeOf(Operator const* op) { |
+ DCHECK_EQ(IrOpcode::kTruncateFloat64ToInt32, op->opcode()); |
+ return OpParameter<TruncationMode>(op); |
+} |
+ |
+ |
std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) { |
switch (kind) { |
case kNoWriteBarrier: |
@@ -117,7 +135,6 @@ CheckedStoreRepresentation CheckedStoreRepresentationOf(Operator const* op) { |
V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ |
V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \ |
V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \ |
- V(TruncateFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \ |
V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1) \ |
V(Float32Abs, Operator::kNoProperties, 1, 0, 1) \ |
V(Float32Add, Operator::kCommutative, 2, 0, 1) \ |
@@ -191,6 +208,19 @@ struct MachineOperatorGlobalCache { |
PURE_OPTIONAL_OP_LIST(PURE) |
#undef PURE |
+ template <TruncationMode kMode> |
+ struct TruncateFloat64ToInt32Operator final |
+ : public Operator1<TruncationMode> { |
+ TruncateFloat64ToInt32Operator() |
+ : Operator1<TruncationMode>(IrOpcode::kTruncateFloat64ToInt32, |
+ Operator::kPure, "TruncateFloat64ToInt32", |
+ 1, 0, 0, 1, 0, 0, kMode) {} |
+ }; |
+ TruncateFloat64ToInt32Operator<TruncationMode::kJavaScript> |
+ kTruncateFloat64ToInt32JavaScript; |
+ TruncateFloat64ToInt32Operator<TruncationMode::kRoundToZero> |
+ kTruncateFloat64ToInt32RoundToZero; |
+ |
#define LOAD(Type) \ |
struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ |
Load##Type##Operator() \ |
@@ -268,6 +298,20 @@ PURE_OP_LIST(PURE) |
PURE_OPTIONAL_OP_LIST(PURE) |
#undef PURE |
+ |
+const Operator* MachineOperatorBuilder::TruncateFloat64ToInt32( |
+ TruncationMode mode) { |
+ switch (mode) { |
+ case TruncationMode::kJavaScript: |
+ return &cache_.kTruncateFloat64ToInt32JavaScript; |
+ case TruncationMode::kRoundToZero: |
+ return &cache_.kTruncateFloat64ToInt32RoundToZero; |
+ } |
+ UNREACHABLE(); |
+ return nullptr; |
+} |
+ |
+ |
const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { |
switch (rep) { |
#define LOAD(Type) \ |