Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: src/compiler/machine-operator.cc

Issue 1225993002: [turbofan] Add TruncationMode for TruncateFloat64ToInt32. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/machine-operator.h ('k') | src/compiler/machine-operator-reducer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) \
« no previous file with comments | « src/compiler/machine-operator.h ('k') | src/compiler/machine-operator-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698