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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/instruction-selector.h ('k') | src/compiler/machine-operator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_ 5 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_
6 #define V8_COMPILER_MACHINE_OPERATOR_H_ 6 #define V8_COMPILER_MACHINE_OPERATOR_H_
7 7
8 #include "src/base/flags.h"
8 #include "src/compiler/machine-type.h" 9 #include "src/compiler/machine-type.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 namespace compiler { 13 namespace compiler {
13 14
14 // Forward declarations. 15 // Forward declarations.
15 struct MachineOperatorBuilderImpl; 16 struct MachineOperatorBuilderImpl;
16 class Operator; 17 class Operator;
17 18
(...skipping 26 matching lines...) Expand all
44 45
45 bool operator==(StoreRepresentation, StoreRepresentation); 46 bool operator==(StoreRepresentation, StoreRepresentation);
46 bool operator!=(StoreRepresentation, StoreRepresentation); 47 bool operator!=(StoreRepresentation, StoreRepresentation);
47 48
48 size_t hash_value(StoreRepresentation); 49 size_t hash_value(StoreRepresentation);
49 50
50 std::ostream& operator<<(std::ostream&, StoreRepresentation); 51 std::ostream& operator<<(std::ostream&, StoreRepresentation);
51 52
52 StoreRepresentation const& StoreRepresentationOf(Operator const*); 53 StoreRepresentation const& StoreRepresentationOf(Operator const*);
53 54
55 // Rounding mode for double rounding.
56 enum Float64RoundMode {
57 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
58 kRoundUp,
59 kRoundAway, // Rounding, tie: away from zero.
60 kRoundTowards // Rounding, tie: towards zero.
61 };
62
63 #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.
64 V(Float64Floor, 0) \
65 V(Float64Ceil, 1) \
66 V(Float64RoundTiesAway, 2) \
67 V(Float64RoundTiesTowards, 3)
68
69 enum SupportedOperator {
70 kNoSupportedOperators = 0
71 #define ENUMDEF(Name, Ordinal) , kSupports##Name = 1 << Ordinal
72 BACKEND_SPECIFIC_OPS(ENUMDEF)
73 #undef ENUMDEF
74 };
75
76 typedef base::Flags<SupportedOperator, uint8_t> SupportedOperators;
77 DEFINE_OPERATORS_FOR_FLAGS(SupportedOperators)
54 78
55 // Interface for building machine-level operators. These operators are 79 // Interface for building machine-level operators. These operators are
56 // machine-level but machine-independent and thus define a language suitable 80 // machine-level but machine-independent and thus define a language suitable
57 // for generating code to run on architectures such as ia32, x64, arm, etc. 81 // for generating code to run on architectures such as ia32, x64, arm, etc.
58 class MachineOperatorBuilder FINAL { 82 class MachineOperatorBuilder FINAL {
59 public: 83 public:
60 explicit MachineOperatorBuilder(MachineType word = kMachPtr); 84 explicit MachineOperatorBuilder(
85 MachineType word = kMachPtr,
86 SupportedOperators supportedOperators = kNoSupportedOperators);
61 87
62 const Operator* Word32And(); 88 const Operator* Word32And();
63 const Operator* Word32Or(); 89 const Operator* Word32Or();
64 const Operator* Word32Xor(); 90 const Operator* Word32Xor();
65 const Operator* Word32Shl(); 91 const Operator* Word32Shl();
66 const Operator* Word32Shr(); 92 const Operator* Word32Shr();
67 const Operator* Word32Sar(); 93 const Operator* Word32Sar();
68 const Operator* Word32Ror(); 94 const Operator* Word32Ror();
69 const Operator* Word32Equal(); 95 const Operator* Word32Equal();
70 96
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const Operator* ChangeInt32ToInt64(); 141 const Operator* ChangeInt32ToInt64();
116 const Operator* ChangeUint32ToFloat64(); 142 const Operator* ChangeUint32ToFloat64();
117 const Operator* ChangeUint32ToUint64(); 143 const Operator* ChangeUint32ToUint64();
118 144
119 // These operators truncate numbers, both changing the representation of 145 // These operators truncate numbers, both changing the representation of
120 // the number and mapping multiple input values onto the same output value. 146 // the number and mapping multiple input values onto the same output value.
121 const Operator* TruncateFloat64ToFloat32(); 147 const Operator* TruncateFloat64ToFloat32();
122 const Operator* TruncateFloat64ToInt32(); // JavaScript semantics. 148 const Operator* TruncateFloat64ToInt32(); // JavaScript semantics.
123 const Operator* TruncateInt64ToInt32(); 149 const Operator* TruncateInt64ToInt32();
124 150
151 // Rounds a number depending on rounding mode.
152 const Operator* Float64Round(Float64RoundMode mode);
153
125 // Floating point operators always operate with IEEE 754 round-to-nearest. 154 // Floating point operators always operate with IEEE 754 round-to-nearest.
126 const Operator* Float64Add(); 155 const Operator* Float64Add();
127 const Operator* Float64Sub(); 156 const Operator* Float64Sub();
128 const Operator* Float64Mul(); 157 const Operator* Float64Mul();
129 const Operator* Float64Div(); 158 const Operator* Float64Div();
130 const Operator* Float64Mod(); 159 const Operator* Float64Mod();
131 const Operator* Float64Sqrt(); 160 const Operator* Float64Sqrt();
132 161
133 // Floating point comparisons complying to IEEE 754. 162 // Floating point comparisons complying to IEEE 754.
134 const Operator* Float64Equal(); 163 const Operator* Float64Equal();
135 const Operator* Float64LessThan(); 164 const Operator* Float64LessThan();
136 const Operator* Float64LessThanOrEqual(); 165 const Operator* Float64LessThanOrEqual();
137 166
138 // load [base + index] 167 // load [base + index]
139 const Operator* Load(LoadRepresentation rep); 168 const Operator* Load(LoadRepresentation rep);
140 169
141 // store [base + index], value 170 // store [base + index], value
142 const Operator* Store(StoreRepresentation rep); 171 const Operator* Store(StoreRepresentation rep);
143 172
144 // Access to the machine stack. 173 // Access to the machine stack.
145 const Operator* LoadStackPointer(); 174 const Operator* LoadStackPointer();
146 175
147 // Target machine word-size assumed by this builder. 176 // Target machine word-size assumed by this builder.
148 bool Is32() const { return word() == kRepWord32; } 177 bool Is32() const { return word() == kRepWord32; }
149 bool Is64() const { return word() == kRepWord64; } 178 bool Is64() const { return word() == kRepWord64; }
150 MachineType word() const { return word_; } 179 MachineType word() const { return word_; }
151 180
181 // Getters to test if backend specific operation is available.
182 #define GETTER(Name, Ordinal) \
183 bool Has##Name() { return supportedOperators_ & kSupports##Name; }
184 BACKEND_SPECIFIC_OPS(GETTER)
185 #undef GETTER
186
152 // Pseudo operators that translate to 32/64-bit operators depending on the 187 // Pseudo operators that translate to 32/64-bit operators depending on the
153 // word-size of the target machine assumed by this builder. 188 // word-size of the target machine assumed by this builder.
154 #define PSEUDO_OP_LIST(V) \ 189 #define PSEUDO_OP_LIST(V) \
155 V(Word, And) \ 190 V(Word, And) \
156 V(Word, Or) \ 191 V(Word, Or) \
157 V(Word, Xor) \ 192 V(Word, Xor) \
158 V(Word, Shl) \ 193 V(Word, Shl) \
159 V(Word, Shr) \ 194 V(Word, Shr) \
160 V(Word, Sar) \ 195 V(Word, Sar) \
161 V(Word, Ror) \ 196 V(Word, Ror) \
(...skipping 12 matching lines...) Expand all
174 const Operator* Prefix##Suffix() { \ 209 const Operator* Prefix##Suffix() { \
175 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ 210 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \
176 } 211 }
177 PSEUDO_OP_LIST(PSEUDO_OP) 212 PSEUDO_OP_LIST(PSEUDO_OP)
178 #undef PSEUDO_OP 213 #undef PSEUDO_OP
179 #undef PSEUDO_OP_LIST 214 #undef PSEUDO_OP_LIST
180 215
181 private: 216 private:
182 const MachineOperatorBuilderImpl& impl_; 217 const MachineOperatorBuilderImpl& impl_;
183 const MachineType word_; 218 const MachineType word_;
219 const SupportedOperators supportedOperators_;
184 }; 220 };
185 221
186 } // namespace compiler 222 } // namespace compiler
187 } // namespace internal 223 } // namespace internal
188 } // namespace v8 224 } // namespace v8
189 225
190 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ 226 #endif // V8_COMPILER_MACHINE_OPERATOR_H_
OLDNEW
« 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