blob: 3eb862fe37e648ff24537f6a5f662b7f7ad87196 [file] [log] [blame]
buzbeecbd6d442012-11-17 14:11:25 -08001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
buzbee395116c2013-02-27 14:30:25 -080017#ifndef ART_SRC_COMPILER_DEX_COMPILERENUMS_H_
18#define ART_SRC_COMPILER_DEX_COMPILERENUMS_H_
buzbeecbd6d442012-11-17 14:11:25 -080019
20#include "dex_instruction.h"
21
22namespace art {
23
24enum RegisterClass {
25 kCoreReg,
26 kFPReg,
27 kAnyReg,
28};
29
30enum SpecialTargetRegister {
buzbee02031b12012-11-23 09:41:35 -080031 kSelf, // Thread pointer.
32 kSuspend, // Used to reduce suspend checks for some targets.
buzbeecbd6d442012-11-17 14:11:25 -080033 kLr,
34 kPc,
35 kSp,
36 kArg0,
37 kArg1,
38 kArg2,
39 kArg3,
40 kFArg0,
41 kFArg1,
42 kFArg2,
43 kFArg3,
44 kRet0,
45 kRet1,
46 kInvokeTgt,
47 kCount
48};
49
50enum RegLocationType {
51 kLocDalvikFrame = 0, // Normal Dalvik register
52 kLocPhysReg,
53 kLocCompilerTemp,
54 kLocInvalid
55};
56
57enum BBType {
58 kEntryBlock,
59 kDalvikByteCode,
60 kExitBlock,
61 kExceptionHandling,
62 kDead,
63};
64
65/*
buzbeefa57c472012-11-21 12:06:18 -080066 * Def/Use encoding in 64-bit use_mask/def_mask. Low positions used for target-specific
buzbeecbd6d442012-11-17 14:11:25 -080067 * registers (and typically use the register number as the position). High positions
68 * reserved for common and abstract resources.
69 */
70
71enum ResourceEncodingPos {
72 kMustNotAlias = 63,
buzbee02031b12012-11-23 09:41:35 -080073 kHeapRef = 62, // Default memory reference type.
74 kLiteral = 61, // Literal pool memory reference.
75 kDalvikReg = 60, // Dalvik v_reg memory reference.
buzbeecbd6d442012-11-17 14:11:25 -080076 kFPStatus = 59,
77 kCCode = 58,
78 kLowestCommonResource = kCCode
79};
80
buzbee02031b12012-11-23 09:41:35 -080081// Shared pseudo opcodes - must be < 0.
buzbeecbd6d442012-11-17 14:11:25 -080082enum LIRPseudoOpcode {
buzbeea169e1d2012-12-05 14:26:44 -080083 kPseudoExportedPC = -16,
84 kPseudoSafepointPC = -15,
85 kPseudoIntrinsicRetry = -14,
86 kPseudoSuspendTarget = -13,
87 kPseudoThrowTarget = -12,
88 kPseudoCaseLabel = -11,
89 kPseudoMethodEntry = -10,
90 kPseudoMethodExit = -9,
91 kPseudoBarrier = -8,
buzbeecbd6d442012-11-17 14:11:25 -080092 kPseudoEntryBlock = -7,
93 kPseudoExitBlock = -6,
94 kPseudoTargetLabel = -5,
95 kPseudoDalvikByteCodeBoundary = -4,
96 kPseudoPseudoAlign4 = -3,
97 kPseudoEHBlockLabel = -2,
98 kPseudoNormalBlockLabel = -1,
99};
100
101enum ExtendedMIROpcode {
102 kMirOpFirst = kNumPackedOpcodes,
103 kMirOpPhi = kMirOpFirst,
104 kMirOpCopy,
105 kMirOpFusedCmplFloat,
106 kMirOpFusedCmpgFloat,
107 kMirOpFusedCmplDouble,
108 kMirOpFusedCmpgDouble,
109 kMirOpFusedCmpLong,
110 kMirOpNop,
111 kMirOpNullCheck,
112 kMirOpRangeCheck,
113 kMirOpDivZeroCheck,
114 kMirOpCheck,
buzbeea169e1d2012-12-05 14:26:44 -0800115 kMirOpCheckPart2,
buzbeef662a7c2013-02-12 16:19:43 -0800116 kMirOpSelect,
buzbeecbd6d442012-11-17 14:11:25 -0800117 kMirOpLast,
118};
119
120enum MIROptimizationFlagPositons {
121 kMIRIgnoreNullCheck = 0,
122 kMIRNullCheckOnly,
123 kMIRIgnoreRangeCheck,
124 kMIRRangeCheckOnly,
buzbee02031b12012-11-23 09:41:35 -0800125 kMIRInlined, // Invoke is inlined (ie dead).
126 kMIRInlinedPred, // Invoke is inlined via prediction.
127 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800128 kMIRIgnoreSuspendCheck,
129 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800130 kMIRMark, // Temporary node mark.
buzbeecbd6d442012-11-17 14:11:25 -0800131};
132
buzbee02031b12012-11-23 09:41:35 -0800133// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800134enum BlockListType {
135 kNotUsed = 0,
136 kCatch,
137 kPackedSwitch,
138 kSparseSwitch,
139};
140
141enum AssemblerStatus {
142 kSuccess,
143 kRetryAll,
144};
145
146enum OpSize {
147 kWord,
148 kLong,
149 kSingle,
150 kDouble,
151 kUnsignedHalf,
152 kSignedHalf,
153 kUnsignedByte,
154 kSignedByte,
155};
156
157std::ostream& operator<<(std::ostream& os, const OpSize& kind);
158
159enum OpKind {
160 kOpMov,
161 kOpMvn,
162 kOpCmp,
163 kOpLsl,
164 kOpLsr,
165 kOpAsr,
166 kOpRor,
167 kOpNot,
168 kOpAnd,
169 kOpOr,
170 kOpXor,
171 kOpNeg,
172 kOpAdd,
173 kOpAdc,
174 kOpSub,
175 kOpSbc,
176 kOpRsub,
177 kOpMul,
178 kOpDiv,
179 kOpRem,
180 kOpBic,
181 kOpCmn,
182 kOpTst,
183 kOpBkpt,
184 kOpBlx,
185 kOpPush,
186 kOpPop,
187 kOp2Char,
188 kOp2Short,
189 kOp2Byte,
190 kOpCondBr,
191 kOpUncondBr,
192 kOpBx,
193 kOpInvalid,
194};
195
196std::ostream& operator<<(std::ostream& os, const OpKind& kind);
197
198enum ConditionCode {
199 kCondEq, // equal
200 kCondNe, // not equal
201 kCondCs, // carry set (unsigned less than)
202 kCondUlt = kCondCs,
203 kCondCc, // carry clear (unsigned greater than or same)
204 kCondUge = kCondCc,
205 kCondMi, // minus
206 kCondPl, // plus, positive or zero
207 kCondVs, // overflow
208 kCondVc, // no overflow
209 kCondHi, // unsigned greater than
210 kCondLs, // unsigned lower or same
211 kCondGe, // signed greater than or equal
212 kCondLt, // signed less than
213 kCondGt, // signed greater than
214 kCondLe, // signed less than or equal
215 kCondAl, // always
216 kCondNv, // never
217};
218
219std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
220
221// Target specific condition encodings
222enum ArmConditionCode {
223 kArmCondEq = 0x0, // 0000
224 kArmCondNe = 0x1, // 0001
225 kArmCondCs = 0x2, // 0010
226 kArmCondCc = 0x3, // 0011
227 kArmCondMi = 0x4, // 0100
228 kArmCondPl = 0x5, // 0101
229 kArmCondVs = 0x6, // 0110
230 kArmCondVc = 0x7, // 0111
231 kArmCondHi = 0x8, // 1000
232 kArmCondLs = 0x9, // 1001
233 kArmCondGe = 0xa, // 1010
234 kArmCondLt = 0xb, // 1011
235 kArmCondGt = 0xc, // 1100
236 kArmCondLe = 0xd, // 1101
237 kArmCondAl = 0xe, // 1110
238 kArmCondNv = 0xf, // 1111
239};
240
241std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
242
243enum X86ConditionCode {
244 kX86CondO = 0x0, // overflow
245 kX86CondNo = 0x1, // not overflow
246
247 kX86CondB = 0x2, // below
248 kX86CondNae = kX86CondB, // not-above-equal
249 kX86CondC = kX86CondB, // carry
250
251 kX86CondNb = 0x3, // not-below
252 kX86CondAe = kX86CondNb, // above-equal
253 kX86CondNc = kX86CondNb, // not-carry
254
255 kX86CondZ = 0x4, // zero
256 kX86CondEq = kX86CondZ, // equal
257
258 kX86CondNz = 0x5, // not-zero
259 kX86CondNe = kX86CondNz, // not-equal
260
261 kX86CondBe = 0x6, // below-equal
262 kX86CondNa = kX86CondBe, // not-above
263
264 kX86CondNbe = 0x7, // not-below-equal
265 kX86CondA = kX86CondNbe,// above
266
267 kX86CondS = 0x8, // sign
268 kX86CondNs = 0x9, // not-sign
269
270 kX86CondP = 0xa, // 8-bit parity even
271 kX86CondPE = kX86CondP,
272
273 kX86CondNp = 0xb, // 8-bit parity odd
274 kX86CondPo = kX86CondNp,
275
276 kX86CondL = 0xc, // less-than
277 kX86CondNge = kX86CondL, // not-greater-equal
278
279 kX86CondNl = 0xd, // not-less-than
280 kX86CondGe = kX86CondNl, // not-greater-equal
281
282 kX86CondLe = 0xe, // less-than-equal
283 kX86CondNg = kX86CondLe, // not-greater
284
285 kX86CondNle = 0xf, // not-less-than
286 kX86CondG = kX86CondNle,// greater
287};
288
289std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
290
291enum ThrowKind {
292 kThrowNullPointer,
293 kThrowDivZero,
294 kThrowArrayBounds,
buzbee4ef3e452012-12-14 13:35:28 -0800295 kThrowConstantArrayBounds,
buzbeecbd6d442012-11-17 14:11:25 -0800296 kThrowNoSuchMethod,
297 kThrowStackOverflow,
298};
299
300enum SpecialCaseHandler {
301 kNoHandler,
302 kNullMethod,
303 kConstFunction,
304 kIGet,
305 kIGetBoolean,
306 kIGetObject,
307 kIGetByte,
308 kIGetChar,
309 kIGetShort,
310 kIGetWide,
311 kIPut,
312 kIPutBoolean,
313 kIPutObject,
314 kIPutByte,
315 kIPutChar,
316 kIPutShort,
317 kIPutWide,
318 kIdentity,
319};
320
321enum DividePattern {
322 DivideNone,
323 Divide3,
324 Divide5,
325 Divide7,
326};
327
328std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
329
330/* Customized node traversal orders for different needs */
331enum DataFlowAnalysisMode {
buzbee02031b12012-11-23 09:41:35 -0800332 kAllNodes = 0, // All nodes.
333 kReachableNodes, // All reachable nodes.
334 kPreOrderDFSTraversal, // Depth-First-Search / Pre-Order.
335 kPostOrderDFSTraversal, // Depth-First-Search / Post-Order.
336 kPostOrderDOMTraversal, // Dominator tree / Post-Order.
337 kReversePostOrderTraversal, // Depth-First-Search / reverse Post-Order.
buzbeecbd6d442012-11-17 14:11:25 -0800338};
339
340std::ostream& operator<<(std::ostream& os, const DataFlowAnalysisMode& mode);
341
buzbee02031b12012-11-23 09:41:35 -0800342// Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
buzbee1bc37c62012-11-20 13:35:41 -0800343enum MemBarrierKind {
344 kLoadStore,
345 kLoadLoad,
346 kStoreStore,
347 kStoreLoad
348};
349
350std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
351
buzbee02031b12012-11-23 09:41:35 -0800352enum OpFeatureFlags {
353 kIsBranch = 0,
354 kNoOperand,
355 kIsUnaryOp,
356 kIsBinaryOp,
357 kIsTertiaryOp,
358 kIsQuadOp,
359 kIsQuinOp,
360 kIsSextupleOp,
361 kIsIT,
362 kMemLoad,
363 kMemStore,
364 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
365 kRegDef0,
366 kRegDef1,
367 kRegDefA,
368 kRegDefD,
369 kRegDefFPCSList0,
370 kRegDefFPCSList2,
371 kRegDefList0,
372 kRegDefList1,
373 kRegDefList2,
374 kRegDefLR,
375 kRegDefSP,
376 kRegUse0,
377 kRegUse1,
378 kRegUse2,
379 kRegUse3,
380 kRegUse4,
381 kRegUseA,
382 kRegUseC,
383 kRegUseD,
384 kRegUseFPCSList0,
385 kRegUseFPCSList2,
386 kRegUseList0,
387 kRegUseList1,
388 kRegUseLR,
389 kRegUsePC,
390 kRegUseSP,
391 kSetsCCodes,
392 kUsesCCodes
393};
394
buzbeef662a7c2013-02-12 16:19:43 -0800395enum SelectInstructionKind {
396 kSelectNone,
397 kSelectConst,
398 kSelectMove,
399 kSelectGoto
400};
401
buzbee02031b12012-11-23 09:41:35 -0800402std::ostream& operator<<(std::ostream& os, const OpFeatureFlags& flag);
403
buzbeecbd6d442012-11-17 14:11:25 -0800404} // namespace art
405
buzbee395116c2013-02-27 14:30:25 -0800406#endif // ART_SRC_COMPILER_DEX_COMPILERENUMS_H_