blob: cbb2c300f232dec3954c2fbc0bf30626b23dc0d2 [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
buzbee091cc402014-03-31 10:14:40 -070030enum BitsUsed {
31 kSize32Bits,
32 kSize64Bits,
33 kSize128Bits,
34 kSize256Bits,
35 kSize512Bits,
36 kSize1024Bits,
37};
38
buzbeecbd6d442012-11-17 14:11:25 -080039enum SpecialTargetRegister {
buzbee02031b12012-11-23 09:41:35 -080040 kSelf, // Thread pointer.
41 kSuspend, // Used to reduce suspend checks for some targets.
buzbeecbd6d442012-11-17 14:11:25 -080042 kLr,
43 kPc,
44 kSp,
45 kArg0,
46 kArg1,
47 kArg2,
48 kArg3,
49 kFArg0,
50 kFArg1,
51 kFArg2,
52 kFArg3,
53 kRet0,
54 kRet1,
55 kInvokeTgt,
Jeff Hao88474b42013-10-23 16:24:40 -070056 kHiddenArg,
57 kHiddenFpArg,
buzbeecbd6d442012-11-17 14:11:25 -080058 kCount
59};
60
61enum RegLocationType {
Brian Carlstrom7934ac22013-07-26 10:54:15 -070062 kLocDalvikFrame = 0, // Normal Dalvik register
buzbeecbd6d442012-11-17 14:11:25 -080063 kLocPhysReg,
64 kLocCompilerTemp,
65 kLocInvalid
66};
67
68enum BBType {
buzbee0d829482013-10-11 15:24:55 -070069 kNullBlock,
buzbeecbd6d442012-11-17 14:11:25 -080070 kEntryBlock,
71 kDalvikByteCode,
72 kExitBlock,
73 kExceptionHandling,
74 kDead,
75};
76
77/*
buzbeefa57c472012-11-21 12:06:18 -080078 * Def/Use encoding in 64-bit use_mask/def_mask. Low positions used for target-specific
buzbeecbd6d442012-11-17 14:11:25 -080079 * registers (and typically use the register number as the position). High positions
80 * reserved for common and abstract resources.
81 */
82
83enum ResourceEncodingPos {
84 kMustNotAlias = 63,
buzbee02031b12012-11-23 09:41:35 -080085 kHeapRef = 62, // Default memory reference type.
86 kLiteral = 61, // Literal pool memory reference.
87 kDalvikReg = 60, // Dalvik v_reg memory reference.
buzbeecbd6d442012-11-17 14:11:25 -080088 kFPStatus = 59,
89 kCCode = 58,
90 kLowestCommonResource = kCCode
91};
92
buzbee02031b12012-11-23 09:41:35 -080093// Shared pseudo opcodes - must be < 0.
buzbeecbd6d442012-11-17 14:11:25 -080094enum LIRPseudoOpcode {
buzbeea169e1d2012-12-05 14:26:44 -080095 kPseudoExportedPC = -16,
96 kPseudoSafepointPC = -15,
97 kPseudoIntrinsicRetry = -14,
98 kPseudoSuspendTarget = -13,
99 kPseudoThrowTarget = -12,
100 kPseudoCaseLabel = -11,
101 kPseudoMethodEntry = -10,
102 kPseudoMethodExit = -9,
103 kPseudoBarrier = -8,
buzbeecbd6d442012-11-17 14:11:25 -0800104 kPseudoEntryBlock = -7,
105 kPseudoExitBlock = -6,
106 kPseudoTargetLabel = -5,
107 kPseudoDalvikByteCodeBoundary = -4,
108 kPseudoPseudoAlign4 = -3,
109 kPseudoEHBlockLabel = -2,
110 kPseudoNormalBlockLabel = -1,
111};
112
113enum ExtendedMIROpcode {
114 kMirOpFirst = kNumPackedOpcodes,
115 kMirOpPhi = kMirOpFirst,
116 kMirOpCopy,
117 kMirOpFusedCmplFloat,
118 kMirOpFusedCmpgFloat,
119 kMirOpFusedCmplDouble,
120 kMirOpFusedCmpgDouble,
121 kMirOpFusedCmpLong,
122 kMirOpNop,
123 kMirOpNullCheck,
124 kMirOpRangeCheck,
125 kMirOpDivZeroCheck,
126 kMirOpCheck,
buzbeea169e1d2012-12-05 14:26:44 -0800127 kMirOpCheckPart2,
buzbeef662a7c2013-02-12 16:19:43 -0800128 kMirOpSelect,
buzbeecbd6d442012-11-17 14:11:25 -0800129 kMirOpLast,
130};
131
132enum MIROptimizationFlagPositons {
133 kMIRIgnoreNullCheck = 0,
134 kMIRNullCheckOnly,
135 kMIRIgnoreRangeCheck,
136 kMIRRangeCheckOnly,
Vladimir Markobfea9c22014-01-17 17:49:33 +0000137 kMIRIgnoreClInitCheck,
buzbee02031b12012-11-23 09:41:35 -0800138 kMIRInlined, // Invoke is inlined (ie dead).
139 kMIRInlinedPred, // Invoke is inlined via prediction.
140 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800141 kMIRIgnoreSuspendCheck,
142 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800143 kMIRMark, // Temporary node mark.
buzbeecbd6d442012-11-17 14:11:25 -0800144};
145
buzbee02031b12012-11-23 09:41:35 -0800146// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800147enum BlockListType {
148 kNotUsed = 0,
149 kCatch,
150 kPackedSwitch,
151 kSparseSwitch,
152};
153
154enum AssemblerStatus {
155 kSuccess,
156 kRetryAll,
157};
158
159enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700160 kWord, // Natural word size of target (32/64).
161 k32,
162 k64,
163 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800164 kSingle,
165 kDouble,
166 kUnsignedHalf,
167 kSignedHalf,
168 kUnsignedByte,
169 kSignedByte,
170};
171
172std::ostream& operator<<(std::ostream& os, const OpSize& kind);
173
174enum OpKind {
175 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800176 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800177 kOpMvn,
178 kOpCmp,
179 kOpLsl,
180 kOpLsr,
181 kOpAsr,
182 kOpRor,
183 kOpNot,
184 kOpAnd,
185 kOpOr,
186 kOpXor,
187 kOpNeg,
188 kOpAdd,
189 kOpAdc,
190 kOpSub,
191 kOpSbc,
192 kOpRsub,
193 kOpMul,
194 kOpDiv,
195 kOpRem,
196 kOpBic,
197 kOpCmn,
198 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100199 kOpRev,
200 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800201 kOpBkpt,
202 kOpBlx,
203 kOpPush,
204 kOpPop,
205 kOp2Char,
206 kOp2Short,
207 kOp2Byte,
208 kOpCondBr,
209 kOpUncondBr,
210 kOpBx,
211 kOpInvalid,
212};
213
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800214enum MoveType {
215 kMov8GP, // Move 8-bit general purpose register.
216 kMov16GP, // Move 16-bit general purpose register.
217 kMov32GP, // Move 32-bit general purpose register.
218 kMov64GP, // Move 64-bit general purpose register.
219 kMov32FP, // Move 32-bit FP register.
220 kMov64FP, // Move 64-bit FP register.
221 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
222 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
223 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
224 kMov128FP = kMovU128FP,
225 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
226 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
227 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
228};
229
buzbeecbd6d442012-11-17 14:11:25 -0800230std::ostream& operator<<(std::ostream& os, const OpKind& kind);
231
232enum ConditionCode {
233 kCondEq, // equal
234 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000235 kCondCs, // carry set
236 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000237 kCondUlt, // unsigned less than
238 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800239 kCondMi, // minus
240 kCondPl, // plus, positive or zero
241 kCondVs, // overflow
242 kCondVc, // no overflow
243 kCondHi, // unsigned greater than
244 kCondLs, // unsigned lower or same
245 kCondGe, // signed greater than or equal
246 kCondLt, // signed less than
247 kCondGt, // signed greater than
248 kCondLe, // signed less than or equal
249 kCondAl, // always
250 kCondNv, // never
251};
252
253std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
254
255// Target specific condition encodings
256enum ArmConditionCode {
257 kArmCondEq = 0x0, // 0000
258 kArmCondNe = 0x1, // 0001
259 kArmCondCs = 0x2, // 0010
260 kArmCondCc = 0x3, // 0011
261 kArmCondMi = 0x4, // 0100
262 kArmCondPl = 0x5, // 0101
263 kArmCondVs = 0x6, // 0110
264 kArmCondVc = 0x7, // 0111
265 kArmCondHi = 0x8, // 1000
266 kArmCondLs = 0x9, // 1001
267 kArmCondGe = 0xa, // 1010
268 kArmCondLt = 0xb, // 1011
269 kArmCondGt = 0xc, // 1100
270 kArmCondLe = 0xd, // 1101
271 kArmCondAl = 0xe, // 1110
272 kArmCondNv = 0xf, // 1111
273};
274
275std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
276
277enum X86ConditionCode {
278 kX86CondO = 0x0, // overflow
279 kX86CondNo = 0x1, // not overflow
280
281 kX86CondB = 0x2, // below
282 kX86CondNae = kX86CondB, // not-above-equal
283 kX86CondC = kX86CondB, // carry
284
285 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700286 kX86CondAe = kX86CondNb, // above-equal
287 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800288
289 kX86CondZ = 0x4, // zero
290 kX86CondEq = kX86CondZ, // equal
291
292 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700293 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800294
295 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700296 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800297
298 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700299 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800300
301 kX86CondS = 0x8, // sign
302 kX86CondNs = 0x9, // not-sign
303
304 kX86CondP = 0xa, // 8-bit parity even
305 kX86CondPE = kX86CondP,
306
307 kX86CondNp = 0xb, // 8-bit parity odd
308 kX86CondPo = kX86CondNp,
309
310 kX86CondL = 0xc, // less-than
311 kX86CondNge = kX86CondL, // not-greater-equal
312
313 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700314 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800315
316 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700317 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800318
319 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700320 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800321};
322
323std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
324
325enum ThrowKind {
buzbeecbd6d442012-11-17 14:11:25 -0800326 kThrowNoSuchMethod,
buzbeecbd6d442012-11-17 14:11:25 -0800327};
328
buzbeecbd6d442012-11-17 14:11:25 -0800329enum DividePattern {
330 DivideNone,
331 Divide3,
332 Divide5,
333 Divide7,
334};
335
336std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
337
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800338/**
339 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
340 * @details Without context sensitive analysis, the most conservative set of barriers
341 * must be issued to ensure the Java Memory Model. Thus the recipe is as follows:
342 * -# Use StoreStore barrier before volatile store.
343 * -# Use StoreLoad barrier after volatile store.
344 * -# Use LoadLoad and LoadStore barrier after each volatile load.
345 * -# Use StoreStore barrier after all stores but before return from any constructor whose
346 * class has final fields.
347 */
buzbee1bc37c62012-11-20 13:35:41 -0800348enum MemBarrierKind {
349 kLoadStore,
350 kLoadLoad,
351 kStoreStore,
352 kStoreLoad
353};
354
355std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
356
buzbee02031b12012-11-23 09:41:35 -0800357enum OpFeatureFlags {
358 kIsBranch = 0,
359 kNoOperand,
360 kIsUnaryOp,
361 kIsBinaryOp,
362 kIsTertiaryOp,
363 kIsQuadOp,
364 kIsQuinOp,
365 kIsSextupleOp,
366 kIsIT,
367 kMemLoad,
368 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700369 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800370 kRegDef0,
371 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800372 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800373 kRegDefA,
374 kRegDefD,
375 kRegDefFPCSList0,
376 kRegDefFPCSList2,
377 kRegDefList0,
378 kRegDefList1,
379 kRegDefList2,
380 kRegDefLR,
381 kRegDefSP,
382 kRegUse0,
383 kRegUse1,
384 kRegUse2,
385 kRegUse3,
386 kRegUse4,
387 kRegUseA,
388 kRegUseC,
389 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000390 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800391 kRegUseFPCSList0,
392 kRegUseFPCSList2,
393 kRegUseList0,
394 kRegUseList1,
395 kRegUseLR,
396 kRegUsePC,
397 kRegUseSP,
398 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700399 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700400 kUseFpStack,
401 kUseHi,
402 kUseLo,
403 kDefHi,
404 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800405};
406
buzbeef662a7c2013-02-12 16:19:43 -0800407enum SelectInstructionKind {
408 kSelectNone,
409 kSelectConst,
410 kSelectMove,
411 kSelectGoto
412};
413
buzbeea5abf702013-04-12 14:39:29 -0700414std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
415
buzbeeb48819d2013-09-14 16:15:25 -0700416// LIR fixup kinds for Arm
417enum FixupKind {
418 kFixupNone,
419 kFixupLabel, // For labels we just adjust the offset.
Vladimir Marko306f0172014-01-07 18:21:20 +0000420 kFixupLoad, // Mostly for immediates.
buzbeeb48819d2013-09-14 16:15:25 -0700421 kFixupVLoad, // FP load which *may* be pc-relative.
422 kFixupCBxZ, // Cbz, Cbnz.
423 kFixupPushPop, // Not really pc relative, but changes size based on args.
424 kFixupCondBranch, // Conditional branch
425 kFixupT1Branch, // Thumb1 Unconditional branch
426 kFixupT2Branch, // Thumb2 Unconditional branch
427 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
428 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
429 kFixupAdr, // Adr.
430 kFixupMovImmLST, // kThumb2MovImm16LST.
431 kFixupMovImmHST, // kThumb2MovImm16HST.
432 kFixupAlign4, // Align to 4-byte boundary.
433};
434
435std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
436
buzbeecbd6d442012-11-17 14:11:25 -0800437} // namespace art
438
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700439#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_