blob: bdf7a8bd5cb5cfe3a7a4f5580dd955ef4c301e21 [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
17#ifndef ART_SRC_COMPILER_COMPILERENUMS_H_
18#define ART_SRC_COMPILER_COMPILERENUMS_H_
19
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,
buzbeecbd6d442012-11-17 14:11:25 -0800116 kMirOpLast,
117};
118
119enum MIROptimizationFlagPositons {
120 kMIRIgnoreNullCheck = 0,
121 kMIRNullCheckOnly,
122 kMIRIgnoreRangeCheck,
123 kMIRRangeCheckOnly,
buzbee02031b12012-11-23 09:41:35 -0800124 kMIRInlined, // Invoke is inlined (ie dead).
125 kMIRInlinedPred, // Invoke is inlined via prediction.
126 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800127 kMIRIgnoreSuspendCheck,
128 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800129 kMIRMark, // Temporary node mark.
buzbeecbd6d442012-11-17 14:11:25 -0800130};
131
buzbee02031b12012-11-23 09:41:35 -0800132// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800133enum BlockListType {
134 kNotUsed = 0,
135 kCatch,
136 kPackedSwitch,
137 kSparseSwitch,
138};
139
140enum AssemblerStatus {
141 kSuccess,
142 kRetryAll,
143};
144
145enum OpSize {
146 kWord,
147 kLong,
148 kSingle,
149 kDouble,
150 kUnsignedHalf,
151 kSignedHalf,
152 kUnsignedByte,
153 kSignedByte,
154};
155
156std::ostream& operator<<(std::ostream& os, const OpSize& kind);
157
158enum OpKind {
159 kOpMov,
160 kOpMvn,
161 kOpCmp,
162 kOpLsl,
163 kOpLsr,
164 kOpAsr,
165 kOpRor,
166 kOpNot,
167 kOpAnd,
168 kOpOr,
169 kOpXor,
170 kOpNeg,
171 kOpAdd,
172 kOpAdc,
173 kOpSub,
174 kOpSbc,
175 kOpRsub,
176 kOpMul,
177 kOpDiv,
178 kOpRem,
179 kOpBic,
180 kOpCmn,
181 kOpTst,
182 kOpBkpt,
183 kOpBlx,
184 kOpPush,
185 kOpPop,
186 kOp2Char,
187 kOp2Short,
188 kOp2Byte,
189 kOpCondBr,
190 kOpUncondBr,
191 kOpBx,
192 kOpInvalid,
193};
194
195std::ostream& operator<<(std::ostream& os, const OpKind& kind);
196
197enum ConditionCode {
198 kCondEq, // equal
199 kCondNe, // not equal
200 kCondCs, // carry set (unsigned less than)
201 kCondUlt = kCondCs,
202 kCondCc, // carry clear (unsigned greater than or same)
203 kCondUge = kCondCc,
204 kCondMi, // minus
205 kCondPl, // plus, positive or zero
206 kCondVs, // overflow
207 kCondVc, // no overflow
208 kCondHi, // unsigned greater than
209 kCondLs, // unsigned lower or same
210 kCondGe, // signed greater than or equal
211 kCondLt, // signed less than
212 kCondGt, // signed greater than
213 kCondLe, // signed less than or equal
214 kCondAl, // always
215 kCondNv, // never
216};
217
218std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
219
220// Target specific condition encodings
221enum ArmConditionCode {
222 kArmCondEq = 0x0, // 0000
223 kArmCondNe = 0x1, // 0001
224 kArmCondCs = 0x2, // 0010
225 kArmCondCc = 0x3, // 0011
226 kArmCondMi = 0x4, // 0100
227 kArmCondPl = 0x5, // 0101
228 kArmCondVs = 0x6, // 0110
229 kArmCondVc = 0x7, // 0111
230 kArmCondHi = 0x8, // 1000
231 kArmCondLs = 0x9, // 1001
232 kArmCondGe = 0xa, // 1010
233 kArmCondLt = 0xb, // 1011
234 kArmCondGt = 0xc, // 1100
235 kArmCondLe = 0xd, // 1101
236 kArmCondAl = 0xe, // 1110
237 kArmCondNv = 0xf, // 1111
238};
239
240std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
241
242enum X86ConditionCode {
243 kX86CondO = 0x0, // overflow
244 kX86CondNo = 0x1, // not overflow
245
246 kX86CondB = 0x2, // below
247 kX86CondNae = kX86CondB, // not-above-equal
248 kX86CondC = kX86CondB, // carry
249
250 kX86CondNb = 0x3, // not-below
251 kX86CondAe = kX86CondNb, // above-equal
252 kX86CondNc = kX86CondNb, // not-carry
253
254 kX86CondZ = 0x4, // zero
255 kX86CondEq = kX86CondZ, // equal
256
257 kX86CondNz = 0x5, // not-zero
258 kX86CondNe = kX86CondNz, // not-equal
259
260 kX86CondBe = 0x6, // below-equal
261 kX86CondNa = kX86CondBe, // not-above
262
263 kX86CondNbe = 0x7, // not-below-equal
264 kX86CondA = kX86CondNbe,// above
265
266 kX86CondS = 0x8, // sign
267 kX86CondNs = 0x9, // not-sign
268
269 kX86CondP = 0xa, // 8-bit parity even
270 kX86CondPE = kX86CondP,
271
272 kX86CondNp = 0xb, // 8-bit parity odd
273 kX86CondPo = kX86CondNp,
274
275 kX86CondL = 0xc, // less-than
276 kX86CondNge = kX86CondL, // not-greater-equal
277
278 kX86CondNl = 0xd, // not-less-than
279 kX86CondGe = kX86CondNl, // not-greater-equal
280
281 kX86CondLe = 0xe, // less-than-equal
282 kX86CondNg = kX86CondLe, // not-greater
283
284 kX86CondNle = 0xf, // not-less-than
285 kX86CondG = kX86CondNle,// greater
286};
287
288std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
289
290enum ThrowKind {
291 kThrowNullPointer,
292 kThrowDivZero,
293 kThrowArrayBounds,
294 kThrowNoSuchMethod,
295 kThrowStackOverflow,
296};
297
298enum SpecialCaseHandler {
299 kNoHandler,
300 kNullMethod,
301 kConstFunction,
302 kIGet,
303 kIGetBoolean,
304 kIGetObject,
305 kIGetByte,
306 kIGetChar,
307 kIGetShort,
308 kIGetWide,
309 kIPut,
310 kIPutBoolean,
311 kIPutObject,
312 kIPutByte,
313 kIPutChar,
314 kIPutShort,
315 kIPutWide,
316 kIdentity,
317};
318
319enum DividePattern {
320 DivideNone,
321 Divide3,
322 Divide5,
323 Divide7,
324};
325
326std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
327
328/* Customized node traversal orders for different needs */
329enum DataFlowAnalysisMode {
buzbee02031b12012-11-23 09:41:35 -0800330 kAllNodes = 0, // All nodes.
331 kReachableNodes, // All reachable nodes.
332 kPreOrderDFSTraversal, // Depth-First-Search / Pre-Order.
333 kPostOrderDFSTraversal, // Depth-First-Search / Post-Order.
334 kPostOrderDOMTraversal, // Dominator tree / Post-Order.
335 kReversePostOrderTraversal, // Depth-First-Search / reverse Post-Order.
buzbeecbd6d442012-11-17 14:11:25 -0800336};
337
338std::ostream& operator<<(std::ostream& os, const DataFlowAnalysisMode& mode);
339
buzbee02031b12012-11-23 09:41:35 -0800340// Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
buzbee1bc37c62012-11-20 13:35:41 -0800341enum MemBarrierKind {
342 kLoadStore,
343 kLoadLoad,
344 kStoreStore,
345 kStoreLoad
346};
347
348std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
349
buzbee02031b12012-11-23 09:41:35 -0800350enum OpFeatureFlags {
351 kIsBranch = 0,
352 kNoOperand,
353 kIsUnaryOp,
354 kIsBinaryOp,
355 kIsTertiaryOp,
356 kIsQuadOp,
357 kIsQuinOp,
358 kIsSextupleOp,
359 kIsIT,
360 kMemLoad,
361 kMemStore,
362 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
363 kRegDef0,
364 kRegDef1,
365 kRegDefA,
366 kRegDefD,
367 kRegDefFPCSList0,
368 kRegDefFPCSList2,
369 kRegDefList0,
370 kRegDefList1,
371 kRegDefList2,
372 kRegDefLR,
373 kRegDefSP,
374 kRegUse0,
375 kRegUse1,
376 kRegUse2,
377 kRegUse3,
378 kRegUse4,
379 kRegUseA,
380 kRegUseC,
381 kRegUseD,
382 kRegUseFPCSList0,
383 kRegUseFPCSList2,
384 kRegUseList0,
385 kRegUseList1,
386 kRegUseLR,
387 kRegUsePC,
388 kRegUseSP,
389 kSetsCCodes,
390 kUsesCCodes
391};
392
393std::ostream& operator<<(std::ostream& os, const OpFeatureFlags& flag);
394
buzbeecbd6d442012-11-17 14:11:25 -0800395} // namespace art
396
397#endif // ART_SRC_COMPILER_COMPILERENUMS_H_