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
3 // found in the LICENSE file.
5 #ifndef V8_COMPILER_OPCODES_H_
6 #define V8_COMPILER_OPCODES_H_
8 // Opcodes for control operators.
9 #define INNER_CONTROL_OP_LIST(V) \
27 #define CONTROL_OP_LIST(V) \
28 INNER_CONTROL_OP_LIST(V) \
32 // Opcodes for constant operators.
33 #define CONSTANT_OP_LIST(V) \
42 #define INNER_OP_LIST(V) \
57 #define COMMON_OP_LIST(V) \
62 // Opcodes for JavaScript operators.
63 #define JS_COMPARE_BINOP_LIST(V) \
70 V(JSLessThanOrEqual) \
71 V(JSGreaterThanOrEqual)
73 #define JS_BITWISE_BINOP_LIST(V) \
79 V(JSShiftRightLogical)
81 #define JS_ARITH_BINOP_LIST(V) \
88 #define JS_SIMPLE_BINOP_LIST(V) \
89 JS_COMPARE_BINOP_LIST(V) \
90 JS_BITWISE_BINOP_LIST(V) \
91 JS_ARITH_BINOP_LIST(V)
93 #define JS_LOGIC_UNOP_LIST(V) V(JSUnaryNot)
95 #define JS_CONVERSION_UNOP_LIST(V) \
102 #define JS_OTHER_UNOP_LIST(V) \
105 #define JS_SIMPLE_UNOP_LIST(V) \
106 JS_LOGIC_UNOP_LIST(V) \
107 JS_CONVERSION_UNOP_LIST(V) \
108 JS_OTHER_UNOP_LIST(V)
110 #define JS_OBJECT_OP_LIST(V) \
116 V(JSDeleteProperty) \
120 #define JS_CONTEXT_OP_LIST(V) \
123 V(JSCreateFunctionContext) \
124 V(JSCreateCatchContext) \
125 V(JSCreateWithContext) \
126 V(JSCreateBlockContext) \
127 V(JSCreateModuleContext) \
128 V(JSCreateScriptContext)
130 #define JS_OTHER_OP_LIST(V) \
137 #define JS_OP_LIST(V) \
138 JS_SIMPLE_BINOP_LIST(V) \
139 JS_SIMPLE_UNOP_LIST(V) \
140 JS_OBJECT_OP_LIST(V) \
141 JS_CONTEXT_OP_LIST(V) \
144 // Opcodes for VirtuaMachine-level operators.
145 #define SIMPLIFIED_COMPARE_BINOP_LIST(V) \
148 V(NumberLessThanOrEqual) \
152 V(StringLessThanOrEqual)
154 #define SIMPLIFIED_OP_LIST(V) \
155 SIMPLIFIED_COMPARE_BINOP_LIST(V) \
165 V(PlainPrimitiveToNumber) \
167 V(ChangeTaggedToInt32) \
168 V(ChangeTaggedToUint32) \
169 V(ChangeTaggedToFloat64) \
170 V(ChangeInt32ToTagged) \
171 V(ChangeUint32ToTagged) \
172 V(ChangeFloat64ToTagged) \
182 V(ObjectIsNonNegativeSmi)
184 // Opcodes for Machine-level operators.
185 #define MACHINE_COMPARE_BINOP_LIST(V) \
189 V(Int32LessThanOrEqual) \
191 V(Uint32LessThanOrEqual) \
193 V(Int64LessThanOrEqual) \
197 V(Float64LessThanOrEqual)
199 #define MACHINE_OP_LIST(V) \
200 MACHINE_COMPARE_BINOP_LIST(V) \
219 V(Int32AddWithOverflow) \
221 V(Int32SubWithOverflow) \
236 V(ChangeFloat32ToFloat64) \
237 V(ChangeFloat64ToInt32) \
238 V(ChangeFloat64ToUint32) \
239 V(ChangeInt32ToFloat64) \
240 V(ChangeInt32ToInt64) \
241 V(ChangeUint32ToFloat64) \
242 V(ChangeUint32ToUint64) \
243 V(TruncateFloat64ToFloat32) \
244 V(TruncateFloat64ToInt32) \
245 V(TruncateInt64ToInt32) \
254 V(Float64RoundDown) \
255 V(Float64RoundTruncate) \
256 V(Float64RoundTiesAway) \
257 V(Float64ExtractLowWord32) \
258 V(Float64ExtractHighWord32) \
259 V(Float64InsertLowWord32) \
260 V(Float64InsertHighWord32) \
261 V(LoadStackPointer) \
265 #define VALUE_OP_LIST(V) \
267 SIMPLIFIED_OP_LIST(V) \
271 // The combination of all operators at all levels and the common operators.
272 #define ALL_OP_LIST(V) \
280 // Declare an enumeration with all the opcodes at all levels so that they
281 // can be globally, uniquely numbered.
285 #define DECLARE_OPCODE(x) k##x,
286 ALL_OP_LIST(DECLARE_OPCODE)
287 #undef DECLARE_OPCODE
289 #define COUNT_OPCODE(x) +1
290 ALL_OP_LIST(COUNT_OPCODE)
294 // Returns the mnemonic name of an opcode.
295 static char const* Mnemonic(Value value);
297 // Returns true if opcode for common operator.
298 static bool IsCommonOpcode(Value value) {
299 return kDead <= value && value <= kAlways;
302 // Returns true if opcode for control operator.
303 static bool IsControlOpcode(Value value) {
304 return kDead <= value && value <= kEnd;
307 // Returns true if opcode for JavaScript operator.
308 static bool IsJsOpcode(Value value) {
309 return kJSEqual <= value && value <= kJSStackCheck;
312 // Returns true if opcode for constant operator.
313 static bool IsConstantOpcode(Value value) {
314 return kInt32Constant <= value && value <= kHeapConstant;
317 static bool IsPhiOpcode(Value value) {
318 return value == kPhi || value == kEffectPhi;
321 static bool IsMergeOpcode(Value value) {
322 return value == kMerge || value == kLoop;
325 static bool IsIfProjectionOpcode(Value value) {
326 return kIfTrue <= value && value <= kIfDefault;
329 // Returns true if opcode for comparison operator.
330 static bool IsComparisonOpcode(Value value) {
331 return (kJSEqual <= value && value <= kJSGreaterThanOrEqual) ||
332 (kNumberEqual <= value && value <= kStringLessThanOrEqual) ||
333 (kWord32Equal <= value && value <= kFloat64LessThanOrEqual);
337 } // namespace compiler
338 } // namespace internal
341 #endif // V8_COMPILER_OPCODES_H_