blob: ab0e3e53ffea4fd5bbcc692fecf74b00bd9aa1bb [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,
Jeff Hao88474b42013-10-23 16:24:40 -070047 kHiddenArg,
48 kHiddenFpArg,
buzbeecbd6d442012-11-17 14:11:25 -080049 kCount
50};
51
52enum RegLocationType {
Brian Carlstrom7934ac22013-07-26 10:54:15 -070053 kLocDalvikFrame = 0, // Normal Dalvik register
buzbeecbd6d442012-11-17 14:11:25 -080054 kLocPhysReg,
55 kLocCompilerTemp,
56 kLocInvalid
57};
58
Bill Buzbeed61ba4b2014-01-13 21:44:01 +000059/**
60 * Support for vector registers. Initially used for x86 floats. This will be used
61 * to replace the assumption that a double takes up 2 single FP registers
62 */
63enum VectorLengthType {
64 kVectorNotUsed = 0, // This value is NOT in a vector register.
65 kVectorLength4, // The value occupies 4 bytes in a vector register.
66 kVectorLength8, // The value occupies 8 bytes in a vector register.
67 kVectorLength16 // The value occupies 16 bytes in a vector register (unused now).
68};
69
buzbeecbd6d442012-11-17 14:11:25 -080070enum BBType {
buzbee0d829482013-10-11 15:24:55 -070071 kNullBlock,
buzbeecbd6d442012-11-17 14:11:25 -080072 kEntryBlock,
73 kDalvikByteCode,
74 kExitBlock,
75 kExceptionHandling,
76 kDead,
77};
78
79/*
buzbeefa57c472012-11-21 12:06:18 -080080 * Def/Use encoding in 64-bit use_mask/def_mask. Low positions used for target-specific
buzbeecbd6d442012-11-17 14:11:25 -080081 * registers (and typically use the register number as the position). High positions
82 * reserved for common and abstract resources.
83 */
84
85enum ResourceEncodingPos {
86 kMustNotAlias = 63,
buzbee02031b12012-11-23 09:41:35 -080087 kHeapRef = 62, // Default memory reference type.
88 kLiteral = 61, // Literal pool memory reference.
89 kDalvikReg = 60, // Dalvik v_reg memory reference.
buzbeecbd6d442012-11-17 14:11:25 -080090 kFPStatus = 59,
91 kCCode = 58,
92 kLowestCommonResource = kCCode
93};
94
buzbee02031b12012-11-23 09:41:35 -080095// Shared pseudo opcodes - must be < 0.
buzbeecbd6d442012-11-17 14:11:25 -080096enum LIRPseudoOpcode {
buzbeea169e1d2012-12-05 14:26:44 -080097 kPseudoExportedPC = -16,
98 kPseudoSafepointPC = -15,
99 kPseudoIntrinsicRetry = -14,
100 kPseudoSuspendTarget = -13,
101 kPseudoThrowTarget = -12,
102 kPseudoCaseLabel = -11,
103 kPseudoMethodEntry = -10,
104 kPseudoMethodExit = -9,
105 kPseudoBarrier = -8,
buzbeecbd6d442012-11-17 14:11:25 -0800106 kPseudoEntryBlock = -7,
107 kPseudoExitBlock = -6,
108 kPseudoTargetLabel = -5,
109 kPseudoDalvikByteCodeBoundary = -4,
110 kPseudoPseudoAlign4 = -3,
111 kPseudoEHBlockLabel = -2,
112 kPseudoNormalBlockLabel = -1,
113};
114
115enum ExtendedMIROpcode {
116 kMirOpFirst = kNumPackedOpcodes,
117 kMirOpPhi = kMirOpFirst,
118 kMirOpCopy,
119 kMirOpFusedCmplFloat,
120 kMirOpFusedCmpgFloat,
121 kMirOpFusedCmplDouble,
122 kMirOpFusedCmpgDouble,
123 kMirOpFusedCmpLong,
124 kMirOpNop,
125 kMirOpNullCheck,
126 kMirOpRangeCheck,
127 kMirOpDivZeroCheck,
128 kMirOpCheck,
buzbeea169e1d2012-12-05 14:26:44 -0800129 kMirOpCheckPart2,
buzbeef662a7c2013-02-12 16:19:43 -0800130 kMirOpSelect,
buzbeecbd6d442012-11-17 14:11:25 -0800131 kMirOpLast,
132};
133
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700134enum MIROptimizationFlagPositions {
buzbeecbd6d442012-11-17 14:11:25 -0800135 kMIRIgnoreNullCheck = 0,
136 kMIRNullCheckOnly,
137 kMIRIgnoreRangeCheck,
138 kMIRRangeCheckOnly,
Vladimir Markobfea9c22014-01-17 17:49:33 +0000139 kMIRIgnoreClInitCheck,
buzbee02031b12012-11-23 09:41:35 -0800140 kMIRInlined, // Invoke is inlined (ie dead).
141 kMIRInlinedPred, // Invoke is inlined via prediction.
142 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800143 kMIRIgnoreSuspendCheck,
144 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800145 kMIRMark, // Temporary node mark.
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700146 kMIRLastMIRFlag,
buzbeecbd6d442012-11-17 14:11:25 -0800147};
148
buzbee02031b12012-11-23 09:41:35 -0800149// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800150enum BlockListType {
151 kNotUsed = 0,
152 kCatch,
153 kPackedSwitch,
154 kSparseSwitch,
155};
156
157enum AssemblerStatus {
158 kSuccess,
159 kRetryAll,
160};
161
162enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700163 kWord, // Natural word size of target (32/64).
164 k32,
165 k64,
166 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800167 kSingle,
168 kDouble,
169 kUnsignedHalf,
170 kSignedHalf,
171 kUnsignedByte,
172 kSignedByte,
173};
174
175std::ostream& operator<<(std::ostream& os, const OpSize& kind);
176
177enum OpKind {
178 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800179 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800180 kOpMvn,
181 kOpCmp,
182 kOpLsl,
183 kOpLsr,
184 kOpAsr,
185 kOpRor,
186 kOpNot,
187 kOpAnd,
188 kOpOr,
189 kOpXor,
190 kOpNeg,
191 kOpAdd,
192 kOpAdc,
193 kOpSub,
194 kOpSbc,
195 kOpRsub,
196 kOpMul,
197 kOpDiv,
198 kOpRem,
199 kOpBic,
200 kOpCmn,
201 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100202 kOpRev,
203 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800204 kOpBkpt,
205 kOpBlx,
206 kOpPush,
207 kOpPop,
208 kOp2Char,
209 kOp2Short,
210 kOp2Byte,
211 kOpCondBr,
212 kOpUncondBr,
213 kOpBx,
214 kOpInvalid,
215};
216
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800217enum MoveType {
218 kMov8GP, // Move 8-bit general purpose register.
219 kMov16GP, // Move 16-bit general purpose register.
220 kMov32GP, // Move 32-bit general purpose register.
221 kMov64GP, // Move 64-bit general purpose register.
222 kMov32FP, // Move 32-bit FP register.
223 kMov64FP, // Move 64-bit FP register.
224 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
225 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
226 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
227 kMov128FP = kMovU128FP,
228 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
229 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
230 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
231};
232
buzbeecbd6d442012-11-17 14:11:25 -0800233std::ostream& operator<<(std::ostream& os, const OpKind& kind);
234
235enum ConditionCode {
236 kCondEq, // equal
237 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000238 kCondCs, // carry set
239 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000240 kCondUlt, // unsigned less than
241 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800242 kCondMi, // minus
243 kCondPl, // plus, positive or zero
244 kCondVs, // overflow
245 kCondVc, // no overflow
246 kCondHi, // unsigned greater than
247 kCondLs, // unsigned lower or same
248 kCondGe, // signed greater than or equal
249 kCondLt, // signed less than
250 kCondGt, // signed greater than
251 kCondLe, // signed less than or equal
252 kCondAl, // always
253 kCondNv, // never
254};
255
256std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
257
258// Target specific condition encodings
259enum ArmConditionCode {
260 kArmCondEq = 0x0, // 0000
261 kArmCondNe = 0x1, // 0001
262 kArmCondCs = 0x2, // 0010
263 kArmCondCc = 0x3, // 0011
264 kArmCondMi = 0x4, // 0100
265 kArmCondPl = 0x5, // 0101
266 kArmCondVs = 0x6, // 0110
267 kArmCondVc = 0x7, // 0111
268 kArmCondHi = 0x8, // 1000
269 kArmCondLs = 0x9, // 1001
270 kArmCondGe = 0xa, // 1010
271 kArmCondLt = 0xb, // 1011
272 kArmCondGt = 0xc, // 1100
273 kArmCondLe = 0xd, // 1101
274 kArmCondAl = 0xe, // 1110
275 kArmCondNv = 0xf, // 1111
276};
277
278std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
279
280enum X86ConditionCode {
281 kX86CondO = 0x0, // overflow
282 kX86CondNo = 0x1, // not overflow
283
284 kX86CondB = 0x2, // below
285 kX86CondNae = kX86CondB, // not-above-equal
286 kX86CondC = kX86CondB, // carry
287
288 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700289 kX86CondAe = kX86CondNb, // above-equal
290 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800291
292 kX86CondZ = 0x4, // zero
293 kX86CondEq = kX86CondZ, // equal
294
295 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700296 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800297
298 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700299 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800300
301 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700302 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800303
304 kX86CondS = 0x8, // sign
305 kX86CondNs = 0x9, // not-sign
306
307 kX86CondP = 0xa, // 8-bit parity even
308 kX86CondPE = kX86CondP,
309
310 kX86CondNp = 0xb, // 8-bit parity odd
311 kX86CondPo = kX86CondNp,
312
313 kX86CondL = 0xc, // less-than
314 kX86CondNge = kX86CondL, // not-greater-equal
315
316 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700317 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800318
319 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700320 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800321
322 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700323 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800324};
325
326std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
327
328enum ThrowKind {
buzbeecbd6d442012-11-17 14:11:25 -0800329 kThrowNoSuchMethod,
buzbeecbd6d442012-11-17 14:11:25 -0800330};
331
buzbeecbd6d442012-11-17 14:11:25 -0800332enum DividePattern {
333 DivideNone,
334 Divide3,
335 Divide5,
336 Divide7,
337};
338
339std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
340
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800341/**
342 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
343 * @details Without context sensitive analysis, the most conservative set of barriers
344 * must be issued to ensure the Java Memory Model. Thus the recipe is as follows:
345 * -# Use StoreStore barrier before volatile store.
346 * -# Use StoreLoad barrier after volatile store.
347 * -# Use LoadLoad and LoadStore barrier after each volatile load.
348 * -# Use StoreStore barrier after all stores but before return from any constructor whose
349 * class has final fields.
350 */
buzbee1bc37c62012-11-20 13:35:41 -0800351enum MemBarrierKind {
352 kLoadStore,
353 kLoadLoad,
354 kStoreStore,
355 kStoreLoad
356};
357
358std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
359
buzbee02031b12012-11-23 09:41:35 -0800360enum OpFeatureFlags {
361 kIsBranch = 0,
362 kNoOperand,
363 kIsUnaryOp,
364 kIsBinaryOp,
365 kIsTertiaryOp,
366 kIsQuadOp,
367 kIsQuinOp,
368 kIsSextupleOp,
369 kIsIT,
370 kMemLoad,
371 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700372 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800373 kRegDef0,
374 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800375 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800376 kRegDefA,
377 kRegDefD,
378 kRegDefFPCSList0,
379 kRegDefFPCSList2,
380 kRegDefList0,
381 kRegDefList1,
382 kRegDefList2,
383 kRegDefLR,
384 kRegDefSP,
385 kRegUse0,
386 kRegUse1,
387 kRegUse2,
388 kRegUse3,
389 kRegUse4,
390 kRegUseA,
391 kRegUseC,
392 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000393 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800394 kRegUseFPCSList0,
395 kRegUseFPCSList2,
396 kRegUseList0,
397 kRegUseList1,
398 kRegUseLR,
399 kRegUsePC,
400 kRegUseSP,
401 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700402 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700403 kUseFpStack,
404 kUseHi,
405 kUseLo,
406 kDefHi,
407 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800408};
409
buzbeef662a7c2013-02-12 16:19:43 -0800410enum SelectInstructionKind {
411 kSelectNone,
412 kSelectConst,
413 kSelectMove,
414 kSelectGoto
415};
416
buzbeea5abf702013-04-12 14:39:29 -0700417std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
418
buzbeeb48819d2013-09-14 16:15:25 -0700419// LIR fixup kinds for Arm
420enum FixupKind {
421 kFixupNone,
422 kFixupLabel, // For labels we just adjust the offset.
Vladimir Marko306f0172014-01-07 18:21:20 +0000423 kFixupLoad, // Mostly for immediates.
buzbeeb48819d2013-09-14 16:15:25 -0700424 kFixupVLoad, // FP load which *may* be pc-relative.
425 kFixupCBxZ, // Cbz, Cbnz.
426 kFixupPushPop, // Not really pc relative, but changes size based on args.
427 kFixupCondBranch, // Conditional branch
428 kFixupT1Branch, // Thumb1 Unconditional branch
429 kFixupT2Branch, // Thumb2 Unconditional branch
430 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
431 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
432 kFixupAdr, // Adr.
433 kFixupMovImmLST, // kThumb2MovImm16LST.
434 kFixupMovImmHST, // kThumb2MovImm16HST.
435 kFixupAlign4, // Align to 4-byte boundary.
436};
437
438std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
439
buzbeecbd6d442012-11-17 14:11:25 -0800440} // namespace art
441
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700442#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_