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

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

Issue 668173002: Add Float64Round operator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove comma at end of enumerator list. Created 6 years, 2 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/instruction-selector.h ('k') | src/compiler/machine-operator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/machine-operator.h
diff --git a/src/compiler/machine-operator.h b/src/compiler/machine-operator.h
index 568d3eb2b89acc163584aea605375772ccfed1f0..e4a06f28f3df28ade3520b380d05d6861a77a1c8 100644
--- a/src/compiler/machine-operator.h
+++ b/src/compiler/machine-operator.h
@@ -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 {
@@ -51,13 +52,38 @@ std::ostream& operator<<(std::ostream&, StoreRepresentation);
StoreRepresentation const& StoreRepresentationOf(Operator const*);
+// Rounding mode for double rounding.
+enum Float64RoundMode {
+ kRoundDown,
titzer 2014/10/22 14:05:42 A little confusing here. These rounding modes map
sigurds 2014/10/22 14:24:50 I thought it was cleaner to have one op + rounding
+ kRoundUp,
+ kRoundAway, // Rounding, tie: away from zero.
+ kRoundTowards // Rounding, tie: towards zero.
+};
+
+#define BACKEND_SPECIFIC_OPS(V) \
titzer 2014/10/22 14:05:42 Can we try to avoid the higher order macro stuff h
sigurds 2014/10/22 14:24:50 Done.
+ V(Float64Floor, 0) \
+ V(Float64Ceil, 1) \
+ V(Float64RoundTiesAway, 2) \
+ V(Float64RoundTiesTowards, 3)
+
+enum SupportedOperator {
+ kNoSupportedOperators = 0
+#define ENUMDEF(Name, Ordinal) , kSupports##Name = 1 << Ordinal
+ BACKEND_SPECIFIC_OPS(ENUMDEF)
+#undef ENUMDEF
+};
+
+typedef base::Flags<SupportedOperator, uint8_t> SupportedOperators;
+DEFINE_OPERATORS_FOR_FLAGS(SupportedOperators)
// Interface for building machine-level operators. These operators are
// machine-level but machine-independent and thus define a language suitable
// for generating code to run on architectures such as ia32, x64, arm, etc.
class MachineOperatorBuilder FINAL {
public:
- explicit MachineOperatorBuilder(MachineType word = kMachPtr);
+ explicit MachineOperatorBuilder(
+ MachineType word = kMachPtr,
+ SupportedOperators supportedOperators = kNoSupportedOperators);
const Operator* Word32And();
const Operator* Word32Or();
@@ -122,6 +148,9 @@ class MachineOperatorBuilder FINAL {
const Operator* TruncateFloat64ToInt32(); // JavaScript semantics.
const Operator* TruncateInt64ToInt32();
+ // Rounds a number depending on rounding mode.
+ const Operator* Float64Round(Float64RoundMode mode);
+
// Floating point operators always operate with IEEE 754 round-to-nearest.
const Operator* Float64Add();
const Operator* Float64Sub();
@@ -149,6 +178,12 @@ class MachineOperatorBuilder FINAL {
bool Is64() const { return word() == kRepWord64; }
MachineType word() const { return word_; }
+// Getters to test if backend specific operation is available.
+#define GETTER(Name, Ordinal) \
+ bool Has##Name() { return supportedOperators_ & kSupports##Name; }
+ BACKEND_SPECIFIC_OPS(GETTER)
+#undef GETTER
+
// Pseudo operators that translate to 32/64-bit operators depending on the
// word-size of the target machine assumed by this builder.
#define PSEUDO_OP_LIST(V) \
@@ -181,6 +216,7 @@ class MachineOperatorBuilder FINAL {
private:
const MachineOperatorBuilderImpl& impl_;
const MachineType word_;
+ const SupportedOperators supportedOperators_;
};
} // namespace compiler
« no previous file with comments | « src/compiler/instruction-selector.h ('k') | src/compiler/machine-operator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698