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) \
24 #define CONTROL_OP_LIST(V) \
25 INNER_CONTROL_OP_LIST(V) \
29 // Opcodes for constant operators.
30 #define CONSTANT_OP_LIST(V) \
39 #define INNER_OP_LIST(V) \
53 #define COMMON_OP_LIST(V) \
58 // Opcodes for JavaScript operators.
59 #define JS_COMPARE_BINOP_LIST(V) \
66 V(JSLessThanOrEqual) \
67 V(JSGreaterThanOrEqual)
69 #define JS_BITWISE_BINOP_LIST(V) \
75 V(JSShiftRightLogical)
77 #define JS_ARITH_BINOP_LIST(V) \
84 #define JS_SIMPLE_BINOP_LIST(V) \
85 JS_COMPARE_BINOP_LIST(V) \
86 JS_BITWISE_BINOP_LIST(V) \
87 JS_ARITH_BINOP_LIST(V)
89 #define JS_LOGIC_UNOP_LIST(V) V(JSUnaryNot)
91 #define JS_CONVERSION_UNOP_LIST(V) \
98 #define JS_OTHER_UNOP_LIST(V) \
101 #define JS_SIMPLE_UNOP_LIST(V) \
102 JS_LOGIC_UNOP_LIST(V) \
103 JS_CONVERSION_UNOP_LIST(V) \
104 JS_OTHER_UNOP_LIST(V)
106 #define JS_OBJECT_OP_LIST(V) \
112 V(JSDeleteProperty) \
116 #define JS_CONTEXT_OP_LIST(V) \
119 V(JSCreateFunctionContext) \
120 V(JSCreateCatchContext) \
121 V(JSCreateWithContext) \
122 V(JSCreateBlockContext) \
123 V(JSCreateModuleContext) \
124 V(JSCreateScriptContext)
126 #define JS_OTHER_OP_LIST(V) \
133 #define JS_OP_LIST(V) \
134 JS_SIMPLE_BINOP_LIST(V) \
135 JS_SIMPLE_UNOP_LIST(V) \
136 JS_OBJECT_OP_LIST(V) \
137 JS_CONTEXT_OP_LIST(V) \
140 // Opcodes for VirtuaMachine-level operators.
141 #define SIMPLIFIED_OP_LIST(V) \
147 V(NumberLessThanOrEqual) \
155 V(PlainPrimitiveToNumber) \
159 V(StringLessThanOrEqual) \
161 V(ChangeTaggedToInt32) \
162 V(ChangeTaggedToUint32) \
163 V(ChangeTaggedToFloat64) \
164 V(ChangeInt32ToTagged) \
165 V(ChangeUint32ToTagged) \
166 V(ChangeFloat64ToTagged) \
176 V(ObjectIsNonNegativeSmi)
178 // Opcodes for Machine-level operators.
179 #define MACHINE_OP_LIST(V) \
199 V(Int32AddWithOverflow) \
201 V(Int32SubWithOverflow) \
207 V(Int32LessThanOrEqual) \
210 V(Uint32LessThanOrEqual) \
219 V(Int64LessThanOrEqual) \
223 V(ChangeFloat32ToFloat64) \
224 V(ChangeFloat64ToInt32) \
225 V(ChangeFloat64ToUint32) \
226 V(ChangeInt32ToFloat64) \
227 V(ChangeInt32ToInt64) \
228 V(ChangeUint32ToFloat64) \
229 V(ChangeUint32ToUint64) \
230 V(TruncateFloat64ToFloat32) \
231 V(TruncateFloat64ToInt32) \
232 V(TruncateInt64ToInt32) \
241 V(Float64LessThanOrEqual) \
244 V(Float64RoundTruncate) \
245 V(Float64RoundTiesAway) \
246 V(LoadStackPointer) \
250 #define VALUE_OP_LIST(V) \
252 SIMPLIFIED_OP_LIST(V) \
256 // The combination of all operators at all levels and the common operators.
257 #define ALL_OP_LIST(V) \
265 // Declare an enumeration with all the opcodes at all levels so that they
266 // can be globally, uniquely numbered.
270 #define DECLARE_OPCODE(x) k##x,
271 ALL_OP_LIST(DECLARE_OPCODE)
272 #undef DECLARE_OPCODE
274 #define COUNT_OPCODE(x) +1
275 ALL_OP_LIST(COUNT_OPCODE)
279 // Returns the mnemonic name of an opcode.
280 static char const* Mnemonic(Value value);
282 // Returns true if opcode for common operator.
283 static bool IsCommonOpcode(Value value) {
284 return kDead <= value && value <= kAlways;
287 // Returns true if opcode for control operator.
288 static bool IsControlOpcode(Value value) {
289 return kDead <= value && value <= kEnd;
292 // Returns true if opcode for JavaScript operator.
293 static bool IsJsOpcode(Value value) {
294 return kJSEqual <= value && value <= kJSDebugger;
297 // Returns true if opcode for constant operator.
298 static bool IsConstantOpcode(Value value) {
299 return kInt32Constant <= value && value <= kHeapConstant;
302 static bool IsPhiOpcode(Value val) {
303 return val == kPhi || val == kEffectPhi;
307 } // namespace compiler
308 } // namespace internal
311 #endif // V8_COMPILER_OPCODES_H_