blob: 97a682f2aa9c098c64b98950e3c12e5a0ee1db34 [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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_DEX_COMPILER_ENUMS_H_
18#define ART_COMPILER_DEX_COMPILER_ENUMS_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 {
Brian Carlstrom7934ac22013-07-26 10:54:15 -070051 kLocDalvikFrame = 0, // Normal Dalvik register
buzbeecbd6d442012-11-17 14:11:25 -080052 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
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700252 kX86CondAe = kX86CondNb, // above-equal
253 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800254
255 kX86CondZ = 0x4, // zero
256 kX86CondEq = kX86CondZ, // equal
257
258 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700259 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800260
261 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700262 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800263
264 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700265 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800266
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
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700280 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800281
282 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700283 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800284
285 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700286 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800287};
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
buzbee02031b12012-11-23 09:41:35 -0800330// Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
buzbee1bc37c62012-11-20 13:35:41 -0800331enum MemBarrierKind {
332 kLoadStore,
333 kLoadLoad,
334 kStoreStore,
335 kStoreLoad
336};
337
338std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
339
buzbee02031b12012-11-23 09:41:35 -0800340enum OpFeatureFlags {
341 kIsBranch = 0,
342 kNoOperand,
343 kIsUnaryOp,
344 kIsBinaryOp,
345 kIsTertiaryOp,
346 kIsQuadOp,
347 kIsQuinOp,
348 kIsSextupleOp,
349 kIsIT,
350 kMemLoad,
351 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700352 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800353 kRegDef0,
354 kRegDef1,
355 kRegDefA,
356 kRegDefD,
357 kRegDefFPCSList0,
358 kRegDefFPCSList2,
359 kRegDefList0,
360 kRegDefList1,
361 kRegDefList2,
362 kRegDefLR,
363 kRegDefSP,
364 kRegUse0,
365 kRegUse1,
366 kRegUse2,
367 kRegUse3,
368 kRegUse4,
369 kRegUseA,
370 kRegUseC,
371 kRegUseD,
372 kRegUseFPCSList0,
373 kRegUseFPCSList2,
374 kRegUseList0,
375 kRegUseList1,
376 kRegUseLR,
377 kRegUsePC,
378 kRegUseSP,
379 kSetsCCodes,
380 kUsesCCodes
381};
382
buzbeef662a7c2013-02-12 16:19:43 -0800383enum SelectInstructionKind {
384 kSelectNone,
385 kSelectConst,
386 kSelectMove,
387 kSelectGoto
388};
389
buzbeea5abf702013-04-12 14:39:29 -0700390std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
391
392// Type of growable bitmap for memory tuning.
393enum OatBitMapKind {
394 kBitMapMisc = 0,
395 kBitMapUse,
396 kBitMapDef,
397 kBitMapLiveIn,
398 kBitMapBMatrix,
399 kBitMapDominators,
400 kBitMapIDominated,
401 kBitMapDomFrontier,
402 kBitMapPhi,
403 kBitMapTmpBlocks,
404 kBitMapInputBlocks,
405 kBitMapRegisterV,
406 kBitMapTempSSARegisterV,
407 kBitMapNullCheck,
408 kBitMapTmpBlockV,
409 kBitMapPredecessors,
410 kNumBitMapKinds
411};
412
413std::ostream& operator<<(std::ostream& os, const OatBitMapKind& kind);
buzbee02031b12012-11-23 09:41:35 -0800414
buzbeecbd6d442012-11-17 14:11:25 -0800415} // namespace art
416
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700417#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_