Revision: 24874
Author: [email protected]
Date: Fri Oct 24 13:06:48 2014 UTC
Log: Add Float64Floor, Float64Ceil, Float64RoundTruncate,
Float64RoundTiesAway operators.
These operators are not supported by any backends yet, and a backend is
free to not support them.
[email protected]
TEST=unittest/machine-operator
Review URL: https://codereview.chromium.org/668173002
https://code.google.com/p/v8/source/detail?r=24874
Modified:
/branches/bleeding_edge/src/base/flags.h
/branches/bleeding_edge/src/compiler/arm/instruction-selector-arm.cc
/branches/bleeding_edge/src/compiler/arm64/instruction-selector-arm64.cc
/branches/bleeding_edge/src/compiler/ia32/instruction-selector-ia32.cc
/branches/bleeding_edge/src/compiler/instruction-selector.h
/branches/bleeding_edge/src/compiler/machine-operator.cc
/branches/bleeding_edge/src/compiler/machine-operator.h
/branches/bleeding_edge/src/compiler/mips/instruction-selector-mips.cc
/branches/bleeding_edge/src/compiler/opcodes.h
/branches/bleeding_edge/src/compiler/pipeline.cc
/branches/bleeding_edge/src/compiler/simplified-lowering.cc
/branches/bleeding_edge/src/compiler/typer.cc
/branches/bleeding_edge/src/compiler/verifier.cc
/branches/bleeding_edge/src/compiler/x64/instruction-selector-x64.cc
/branches/bleeding_edge/test/unittests/compiler/machine-operator-unittest.cc
=======================================
--- /branches/bleeding_edge/src/base/flags.h Wed Oct 1 06:32:05 2014 UTC
+++ /branches/bleeding_edge/src/base/flags.h Fri Oct 24 13:06:48 2014 UTC
@@ -26,8 +26,9 @@
typedef S mask_type;
Flags() : mask_(0) {}
- Flags(flag_type flag) : mask_(flag) {} // NOLINT(runtime/explicit)
- explicit Flags(mask_type mask) : mask_(mask) {}
+ Flags(flag_type flag) // NOLINT(runtime/explicit)
+ : mask_(static_cast<S>(flag)) {}
+ explicit Flags(mask_type mask) : mask_(static_cast<S>(mask)) {}
Flags& operator&=(const Flags& flags) {
mask_ &= flags.mask_;
=======================================
--- /branches/bleeding_edge/src/compiler/arm/instruction-selector-arm.cc
Thu Oct 23 10:22:06 2014 UTC
+++ /branches/bleeding_edge/src/compiler/arm/instruction-selector-arm.cc
Fri Oct 24 13:06:48 2014 UTC
@@ -1135,6 +1135,12 @@
VisitFloat64Compare(this, node, &cont);
}
+
+// static
+MachineOperatorBuilder::Flags
+InstructionSelector::SupportedMachineOperatorFlags() {
+ return MachineOperatorBuilder::Flag::kNoFlags;
+}
} // namespace compiler
} // namespace internal
} // namespace v8
=======================================
---
/branches/bleeding_edge/src/compiler/arm64/instruction-selector-arm64.cc
Fri Oct 17 11:26:26 2014 UTC
+++
/branches/bleeding_edge/src/compiler/arm64/instruction-selector-arm64.cc
Fri Oct 24 13:06:48 2014 UTC
@@ -1285,6 +1285,12 @@
VisitFloat64Compare(this, node, &cont);
}
+
+// static
+MachineOperatorBuilder::Flags
+InstructionSelector::SupportedMachineOperatorFlags() {
+ return MachineOperatorBuilder::Flag::kNoFlags;
+}
} // namespace compiler
} // namespace internal
} // namespace v8
=======================================
--- /branches/bleeding_edge/src/compiler/ia32/instruction-selector-ia32.cc
Fri Oct 24 09:36:40 2014 UTC
+++ /branches/bleeding_edge/src/compiler/ia32/instruction-selector-ia32.cc
Fri Oct 24 13:06:48 2014 UTC
@@ -877,6 +877,12 @@
VisitFloat64Compare(this, node, &cont);
}
+
+// static
+MachineOperatorBuilder::Flags
+InstructionSelector::SupportedMachineOperatorFlags() {
+ return MachineOperatorBuilder::Flag::kNoFlags;
+}
} // namespace compiler
} // namespace internal
} // namespace v8
=======================================
--- /branches/bleeding_edge/src/compiler/instruction-selector.h Thu Oct 23
10:22:06 2014 UTC
+++ /branches/bleeding_edge/src/compiler/instruction-selector.h Fri Oct 24
13:06:48 2014 UTC
@@ -84,6 +84,9 @@
static Features SupportedFeatures() {
return Features(CpuFeatures::SupportedFeatures());
}
+
+ // TODO(sigurds) This should take a CpuFeatures argument.
+ static MachineOperatorBuilder::Flags SupportedMachineOperatorFlags();
//
===========================================================================
// ============ Architecture-independent graph covering methods.
=============
=======================================
--- /branches/bleeding_edge/src/compiler/machine-operator.cc Tue Oct 14
11:57:06 2014 UTC
+++ /branches/bleeding_edge/src/compiler/machine-operator.cc Fri Oct 24
13:06:48 2014 UTC
@@ -110,6 +110,10 @@
V(Float64Div, Operator::kNoProperties, 2,
1) \
V(Float64Mod, Operator::kNoProperties, 2,
1) \
V(Float64Sqrt, Operator::kNoProperties, 1,
1) \
+ V(Float64Ceil, Operator::kNoProperties, 1,
1) \
+ V(Float64Floor, Operator::kNoProperties, 1,
1) \
+ V(Float64RoundTruncate, Operator::kNoProperties, 1,
1) \
+ V(Float64RoundTiesAway, Operator::kNoProperties, 1,
1) \
V(Float64Equal, Operator::kCommutative, 2,
1) \
V(Float64LessThan, Operator::kNoProperties, 2,
1) \
V(Float64LessThanOrEqual, Operator::kNoProperties, 2,
1) \
@@ -188,8 +192,8 @@
LAZY_INSTANCE_INITIALIZER;
-MachineOperatorBuilder::MachineOperatorBuilder(MachineType word)
- : impl_(kImpl.Get()), word_(word) {
+MachineOperatorBuilder::MachineOperatorBuilder(MachineType word, Flags
flags)
+ : impl_(kImpl.Get()), word_(word), flags_(flags) {
DCHECK(word == kRepWord32 || word == kRepWord64);
}
@@ -236,7 +240,6 @@
UNREACHABLE();
return NULL;
}
-
} // namespace compiler
} // namespace internal
} // namespace v8
=======================================
--- /branches/bleeding_edge/src/compiler/machine-operator.h Tue Oct 14
11:57:06 2014 UTC
+++ /branches/bleeding_edge/src/compiler/machine-operator.h Fri Oct 24
13:06:48 2014 UTC
@@ -5,6 +5,7 @@
#ifndef V8_COMPILER_MACHINE_OPERATOR_H_
#define V8_COMPILER_MACHINE_OPERATOR_H_
+#include "src/base/flags.h"
#include "src/compiler/machine-type.h"
namespace v8 {
@@ -57,7 +58,19 @@
// for generating code to run on architectures such as ia32, x64, arm, etc.
class MachineOperatorBuilder FINAL {
public:
- explicit MachineOperatorBuilder(MachineType word = kMachPtr);
+ // Flags that specify which operations are available. This is useful
+ // for operations that are unsupported by some back-ends.
+ enum class Flag : unsigned {
+ kNoFlags = 0,
+ kFloat64Floor = 1 << 0,
+ kFloat64Ceil = 1 << 1,
+ kFloat64RoundTruncate = 1 << 2,
+ kFloat64RoundTiesAway = 1 << 3
+ };
+ typedef base::Flags<Flag, unsigned> Flags;
+
+ explicit MachineOperatorBuilder(MachineType word = kMachPtr,
+ Flags supportedOperators =
Flag::kNoFlags);
const Operator* Word32And();
const Operator* Word32Or();
@@ -134,6 +147,20 @@
const Operator* Float64Equal();
const Operator* Float64LessThan();
const Operator* Float64LessThanOrEqual();
+
+ // Floating point rounding.
+ const Operator* Float64Floor();
+ const Operator* Float64Ceil();
+ const Operator* Float64RoundTruncate();
+ const Operator* Float64RoundTiesAway();
+ bool HasFloat64Floor() { return flags_ & Flag::kFloat64Floor; }
+ bool HasFloat64Ceil() { return flags_ & Flag::kFloat64Ceil; }
+ bool HasFloat64RoundTruncate() {
+ return flags_ & Flag::kFloat64RoundTruncate;
+ }
+ bool HasFloat64RoundTiesAway() {
+ return flags_ & Flag::kFloat64RoundTiesAway;
+ }
// load [base + index]
const Operator* Load(LoadRepresentation rep);
@@ -181,8 +208,11 @@
private:
const MachineOperatorBuilderImpl& impl_;
const MachineType word_;
+ const Flags flags_;
};
+
+DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags)
} // namespace compiler
} // namespace internal
} // namespace v8
=======================================
--- /branches/bleeding_edge/src/compiler/mips/instruction-selector-mips.cc
Fri Oct 17 11:26:26 2014 UTC
+++ /branches/bleeding_edge/src/compiler/mips/instruction-selector-mips.cc
Fri Oct 24 13:06:48 2014 UTC
@@ -647,6 +647,12 @@
VisitFloat64Compare(this, node, &cont);
}
+
+// static
+MachineOperatorBuilder::Flags
+InstructionSelector::SupportedMachineOperatorFlags() {
+ return MachineOperatorBuilder::Flag::kNoFlags;
+}
} // namespace compiler
} // namespace internal
} // namespace v8
=======================================
--- /branches/bleeding_edge/src/compiler/opcodes.h Wed Oct 22 17:15:38 2014
UTC
+++ /branches/bleeding_edge/src/compiler/opcodes.h Fri Oct 24 13:06:48 2014
UTC
@@ -226,6 +226,10 @@
V(Float64Equal) \
V(Float64LessThan) \
V(Float64LessThanOrEqual) \
+ V(Float64Floor) \
+ V(Float64Ceil) \
+ V(Float64RoundTruncate) \
+ V(Float64RoundTiesAway) \
V(LoadStackPointer)
#define VALUE_OP_LIST(V) \
=======================================
--- /branches/bleeding_edge/src/compiler/pipeline.cc Thu Oct 23 11:56:26
2014 UTC
+++ /branches/bleeding_edge/src/compiler/pipeline.cc Fri Oct 24 13:06:48
2014 UTC
@@ -178,7 +178,8 @@
// construction. This is currently only needed for the node cache,
which the
// typer could sweep over later.
Typer typer(&graph, info()->context());
- MachineOperatorBuilder machine;
+ MachineOperatorBuilder machine(
+ kMachPtr, InstructionSelector::SupportedMachineOperatorFlags());
CommonOperatorBuilder common(zone());
JSOperatorBuilder javascript(zone());
JSGraph jsgraph(&graph, &common, &javascript, &machine);
=======================================
--- /branches/bleeding_edge/src/compiler/simplified-lowering.cc Thu Oct 23
15:09:38 2014 UTC
+++ /branches/bleeding_edge/src/compiler/simplified-lowering.cc Fri Oct 24
13:06:48 2014 UTC
@@ -915,6 +915,10 @@
case IrOpcode::kFloat64Mod:
return VisitFloat64Binop(node);
case IrOpcode::kFloat64Sqrt:
+ case IrOpcode::kFloat64Floor:
+ case IrOpcode::kFloat64Ceil:
+ case IrOpcode::kFloat64RoundTruncate:
+ case IrOpcode::kFloat64RoundTiesAway:
return VisitUnop(node, kMachFloat64, kMachFloat64);
case IrOpcode::kFloat64Equal:
case IrOpcode::kFloat64LessThan:
=======================================
--- /branches/bleeding_edge/src/compiler/typer.cc Thu Oct 23 14:40:43 2014
UTC
+++ /branches/bleeding_edge/src/compiler/typer.cc Fri Oct 24 13:06:48 2014
UTC
@@ -1768,6 +1768,30 @@
Bounds Typer::Visitor::TypeFloat64LessThanOrEqual(Node* node) {
return Bounds(Type::Boolean());
}
+
+
+Bounds Typer::Visitor::TypeFloat64Floor(Node* node) {
+ // TODO(sigurds): We could have a tighter bound here.
+ return Bounds(Type::Number());
+}
+
+
+Bounds Typer::Visitor::TypeFloat64Ceil(Node* node) {
+ // TODO(sigurds): We could have a tighter bound here.
+ return Bounds(Type::Number());
+}
+
+
+Bounds Typer::Visitor::TypeFloat64RoundTruncate(Node* node) {
+ // TODO(sigurds): We could have a tighter bound here.
+ return Bounds(Type::Number());
+}
+
+
+Bounds Typer::Visitor::TypeFloat64RoundTiesAway(Node* node) {
+ // TODO(sigurds): We could have a tighter bound here.
+ return Bounds(Type::Number());
+}
Bounds Typer::Visitor::TypeLoadStackPointer(Node* node) {
=======================================
--- /branches/bleeding_edge/src/compiler/verifier.cc Wed Oct 22 17:15:38
2014 UTC
+++ /branches/bleeding_edge/src/compiler/verifier.cc Fri Oct 24 13:06:48
2014 UTC
@@ -702,6 +702,10 @@
case IrOpcode::kFloat64Div:
case IrOpcode::kFloat64Mod:
case IrOpcode::kFloat64Sqrt:
+ case IrOpcode::kFloat64Floor:
+ case IrOpcode::kFloat64Ceil:
+ case IrOpcode::kFloat64RoundTruncate:
+ case IrOpcode::kFloat64RoundTiesAway:
case IrOpcode::kFloat64Equal:
case IrOpcode::kFloat64LessThan:
case IrOpcode::kFloat64LessThanOrEqual:
=======================================
--- /branches/bleeding_edge/src/compiler/x64/instruction-selector-x64.cc
Fri Oct 24 09:36:40 2014 UTC
+++ /branches/bleeding_edge/src/compiler/x64/instruction-selector-x64.cc
Fri Oct 24 13:06:48 2014 UTC
@@ -1108,6 +1108,12 @@
VisitFloat64Compare(this, node, &cont);
}
+
+// static
+MachineOperatorBuilder::Flags
+InstructionSelector::SupportedMachineOperatorFlags() {
+ return MachineOperatorBuilder::Flag::kNoFlags;
+}
} // namespace compiler
} // namespace internal
} // namespace v8
=======================================
---
/branches/bleeding_edge/test/unittests/compiler/machine-operator-unittest.cc
Tue Oct 14 11:57:06 2014 UTC
+++
/branches/bleeding_edge/test/unittests/compiler/machine-operator-unittest.cc
Fri Oct 24 13:06:48 2014 UTC
@@ -202,7 +202,9 @@
PURE(Float64Div, 2, 1), PURE(Float64Mod, 2, 1),
PURE(Float64Sqrt, 1, 1), PURE(Float64Equal, 2, 1),
PURE(Float64LessThan, 2, 1), PURE(Float64LessThanOrEqual, 2,
1),
- PURE(LoadStackPointer, 0, 1)
+ PURE(LoadStackPointer, 0, 1), PURE(Float64Floor, 1, 1),
+ PURE(Float64Ceil, 1, 1), PURE(Float64RoundTruncate, 1, 1),
+ PURE(Float64RoundTiesAway, 1, 1),
#undef PURE
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.