blob: 05ab8ca3fb4b70a16e1f8b72c008d61ef95177d7 [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
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700132enum MIROptimizationFlagPositions {
buzbeecbd6d442012-11-17 14:11:25 -0800133 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.
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700144 kMIRLastMIRFlag,
buzbeecbd6d442012-11-17 14:11:25 -0800145};
146
buzbee02031b12012-11-23 09:41:35 -0800147// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800148enum BlockListType {
149 kNotUsed = 0,
150 kCatch,
151 kPackedSwitch,
152 kSparseSwitch,
153};
154
155enum AssemblerStatus {
156 kSuccess,
157 kRetryAll,
158};
159
160enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700161 kWord, // Natural word size of target (32/64).
162 k32,
163 k64,
164 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800165 kSingle,
166 kDouble,
167 kUnsignedHalf,
168 kSignedHalf,
169 kUnsignedByte,
170 kSignedByte,
171};
172
173std::ostream& operator<<(std::ostream& os, const OpSize& kind);
174
175enum OpKind {
176 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800177 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800178 kOpMvn,
179 kOpCmp,
180 kOpLsl,
181 kOpLsr,
182 kOpAsr,
183 kOpRor,
184 kOpNot,
185 kOpAnd,
186 kOpOr,
187 kOpXor,
188 kOpNeg,
189 kOpAdd,
190 kOpAdc,
191 kOpSub,
192 kOpSbc,
193 kOpRsub,
194 kOpMul,
195 kOpDiv,
196 kOpRem,
197 kOpBic,
198 kOpCmn,
199 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100200 kOpRev,
201 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800202 kOpBkpt,
203 kOpBlx,
204 kOpPush,
205 kOpPop,
206 kOp2Char,
207 kOp2Short,
208 kOp2Byte,
209 kOpCondBr,
210 kOpUncondBr,
211 kOpBx,
212 kOpInvalid,
213};
214
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800215enum MoveType {
216 kMov8GP, // Move 8-bit general purpose register.
217 kMov16GP, // Move 16-bit general purpose register.
218 kMov32GP, // Move 32-bit general purpose register.
219 kMov64GP, // Move 64-bit general purpose register.
220 kMov32FP, // Move 32-bit FP register.
221 kMov64FP, // Move 64-bit FP register.
222 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
223 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
224 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
225 kMov128FP = kMovU128FP,
226 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
227 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
228 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
229};
230
buzbeecbd6d442012-11-17 14:11:25 -0800231std::ostream& operator<<(std::ostream& os, const OpKind& kind);
232
233enum ConditionCode {
234 kCondEq, // equal
235 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000236 kCondCs, // carry set
237 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000238 kCondUlt, // unsigned less than
239 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800240 kCondMi, // minus
241 kCondPl, // plus, positive or zero
242 kCondVs, // overflow
243 kCondVc, // no overflow
244 kCondHi, // unsigned greater than
245 kCondLs, // unsigned lower or same
246 kCondGe, // signed greater than or equal
247 kCondLt, // signed less than
248 kCondGt, // signed greater than
249 kCondLe, // signed less than or equal
250 kCondAl, // always
251 kCondNv, // never
252};
253
254std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
255
256// Target specific condition encodings
257enum ArmConditionCode {
258 kArmCondEq = 0x0, // 0000
259 kArmCondNe = 0x1, // 0001
260 kArmCondCs = 0x2, // 0010
261 kArmCondCc = 0x3, // 0011
262 kArmCondMi = 0x4, // 0100
263 kArmCondPl = 0x5, // 0101
264 kArmCondVs = 0x6, // 0110
265 kArmCondVc = 0x7, // 0111
266 kArmCondHi = 0x8, // 1000
267 kArmCondLs = 0x9, // 1001
268 kArmCondGe = 0xa, // 1010
269 kArmCondLt = 0xb, // 1011
270 kArmCondGt = 0xc, // 1100
271 kArmCondLe = 0xd, // 1101
272 kArmCondAl = 0xe, // 1110
273 kArmCondNv = 0xf, // 1111
274};
275
276std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
277
278enum X86ConditionCode {
279 kX86CondO = 0x0, // overflow
280 kX86CondNo = 0x1, // not overflow
281
282 kX86CondB = 0x2, // below
283 kX86CondNae = kX86CondB, // not-above-equal
284 kX86CondC = kX86CondB, // carry
285
286 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700287 kX86CondAe = kX86CondNb, // above-equal
288 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800289
290 kX86CondZ = 0x4, // zero
291 kX86CondEq = kX86CondZ, // equal
292
293 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700294 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800295
296 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700297 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800298
299 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700300 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800301
302 kX86CondS = 0x8, // sign
303 kX86CondNs = 0x9, // not-sign
304
305 kX86CondP = 0xa, // 8-bit parity even
306 kX86CondPE = kX86CondP,
307
308 kX86CondNp = 0xb, // 8-bit parity odd
309 kX86CondPo = kX86CondNp,
310
311 kX86CondL = 0xc, // less-than
312 kX86CondNge = kX86CondL, // not-greater-equal
313
314 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700315 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800316
317 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700318 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800319
320 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700321 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800322};
323
324std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
325
326enum ThrowKind {
buzbeecbd6d442012-11-17 14:11:25 -0800327 kThrowNoSuchMethod,
buzbeecbd6d442012-11-17 14:11:25 -0800328};
329
buzbeecbd6d442012-11-17 14:11:25 -0800330enum DividePattern {
331 DivideNone,
332 Divide3,
333 Divide5,
334 Divide7,
335};
336
337std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
338
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800339/**
340 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
341 * @details Without context sensitive analysis, the most conservative set of barriers
342 * must be issued to ensure the Java Memory Model. Thus the recipe is as follows:
343 * -# Use StoreStore barrier before volatile store.
344 * -# Use StoreLoad barrier after volatile store.
345 * -# Use LoadLoad and LoadStore barrier after each volatile load.
346 * -# Use StoreStore barrier after all stores but before return from any constructor whose
347 * class has final fields.
348 */
buzbee1bc37c62012-11-20 13:35:41 -0800349enum MemBarrierKind {
350 kLoadStore,
351 kLoadLoad,
352 kStoreStore,
353 kStoreLoad
354};
355
356std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
357
buzbee02031b12012-11-23 09:41:35 -0800358enum OpFeatureFlags {
359 kIsBranch = 0,
360 kNoOperand,
361 kIsUnaryOp,
362 kIsBinaryOp,
363 kIsTertiaryOp,
364 kIsQuadOp,
365 kIsQuinOp,
366 kIsSextupleOp,
367 kIsIT,
368 kMemLoad,
369 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700370 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800371 kRegDef0,
372 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800373 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800374 kRegDefA,
375 kRegDefD,
376 kRegDefFPCSList0,
377 kRegDefFPCSList2,
378 kRegDefList0,
379 kRegDefList1,
380 kRegDefList2,
381 kRegDefLR,
382 kRegDefSP,
383 kRegUse0,
384 kRegUse1,
385 kRegUse2,
386 kRegUse3,
387 kRegUse4,
388 kRegUseA,
389 kRegUseC,
390 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000391 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800392 kRegUseFPCSList0,
393 kRegUseFPCSList2,
394 kRegUseList0,
395 kRegUseList1,
396 kRegUseLR,
397 kRegUsePC,
398 kRegUseSP,
399 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700400 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700401 kUseFpStack,
402 kUseHi,
403 kUseLo,
404 kDefHi,
405 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800406};
407
buzbeef662a7c2013-02-12 16:19:43 -0800408enum SelectInstructionKind {
409 kSelectNone,
410 kSelectConst,
411 kSelectMove,
412 kSelectGoto
413};
414
buzbeea5abf702013-04-12 14:39:29 -0700415std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
416
buzbeeb48819d2013-09-14 16:15:25 -0700417// LIR fixup kinds for Arm
418enum FixupKind {
419 kFixupNone,
420 kFixupLabel, // For labels we just adjust the offset.
Vladimir Marko306f0172014-01-07 18:21:20 +0000421 kFixupLoad, // Mostly for immediates.
buzbeeb48819d2013-09-14 16:15:25 -0700422 kFixupVLoad, // FP load which *may* be pc-relative.
423 kFixupCBxZ, // Cbz, Cbnz.
424 kFixupPushPop, // Not really pc relative, but changes size based on args.
425 kFixupCondBranch, // Conditional branch
426 kFixupT1Branch, // Thumb1 Unconditional branch
427 kFixupT2Branch, // Thumb2 Unconditional branch
428 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
429 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
430 kFixupAdr, // Adr.
431 kFixupMovImmLST, // kThumb2MovImm16LST.
432 kFixupMovImmHST, // kThumb2MovImm16HST.
433 kFixupAlign4, // Align to 4-byte boundary.
434};
435
436std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
437
buzbeecbd6d442012-11-17 14:11:25 -0800438} // namespace art
439
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700440#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_