blob: 5b4492f48c04bb47101bc11e8805792078b018c9 [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,
Mark Mendelld65c51a2014-04-29 16:55:20 -0400129
130 // Vector opcodes:
131 // TypeSize is an encoded field giving the element type and the vector size.
132 // It is encoded as OpSize << 16 | (number of bits in vector)
133 //
134 // Destination and source are integers that will be interpreted by the
135 // backend that supports Vector operations. Backends are permitted to support only
136 // certain vector register sizes.
137 //
138 // At this point, only two operand instructions are supported. Three operand instructions
139 // could be supported by using a bit in TypeSize and arg[0] where needed.
140
141 // @brief MIR to move constant data to a vector register
142 // vA: number of bits in register
143 // vB: destination
144 // args[0]~args[3]: up to 128 bits of data for initialization
145 kMirOpConstVector,
146
147 // @brief MIR to move a vectorized register to another
148 // vA: TypeSize
149 // vB: destination
150 // vC: source
151 kMirOpMoveVector,
152
153 // @brief Packed multiply of units in two vector registers: vB = vB .* vC using vA to know the type of the vector.
154 // vA: TypeSize
155 // vB: destination and source
156 // vC: source
157 kMirOpPackedMultiply,
158
159 // @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the type of the vector.
160 // vA: TypeSize
161 // vB: destination and source
162 // vC: source
163 kMirOpPackedAddition,
164
165 // @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the type of the vector.
166 // vA: TypeSize
167 // vB: destination and source
168 // vC: source
169 kMirOpPackedSubtract,
170
171 // @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the type of the vector.
172 // vA: TypeSize
173 // vB: destination and source
174 // vC: immediate
175 kMirOpPackedShiftLeft,
176
177 // @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to know the type of the vector.
178 // vA: TypeSize
179 // vB: destination and source
180 // vC: immediate
181 kMirOpPackedSignedShiftRight,
182
183 // @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA to know the type of the vector.
184 // vA: TypeSize
185 // vB: destination and source
186 // vC: immediate
187 kMirOpPackedUnsignedShiftRight,
188
189 // @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the type of the vector.
190 // vA: TypeSize
191 // vB: destination and source
192 // vC: source
193 kMirOpPackedAnd,
194
195 // @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the type of the vector.
196 // vA: TypeSize
197 // vB: destination and source
198 // vC: source
199 kMirOpPackedOr,
200
201 // @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the type of the vector.
202 // vA: TypeSize
203 // vB: destination and source
204 // vC: source
205 kMirOpPackedXor,
206
207 // @brief Reduce a 128-bit packed element into a single VR by taking lower bits
208 // @details Instruction does a horizontal addition of the packed elements and then adds it to VR
209 // vA: TypeSize
210 // vB: destination and source VR (not vector register)
211 // vC: source (vector register)
212 kMirOpPackedAddReduce,
213
214 // @brief Extract a packed element into a single VR.
215 // vA: TypeSize
216 // vB: destination VR (not vector register)
217 // vC: source (vector register)
218 // arg[0]: The index to use for extraction from vector register (which packed element)
219 kMirOpPackedReduce,
220
221 // @brief Create a vector value, with all TypeSize values equal to vC
222 // vA: TypeSize
223 // vB: destination vector register
224 // vC: source VR (not vector register)
225 kMirOpPackedSet,
226
buzbeecbd6d442012-11-17 14:11:25 -0800227 kMirOpLast,
228};
229
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700230enum MIROptimizationFlagPositions {
buzbeecbd6d442012-11-17 14:11:25 -0800231 kMIRIgnoreNullCheck = 0,
232 kMIRNullCheckOnly,
233 kMIRIgnoreRangeCheck,
234 kMIRRangeCheckOnly,
Vladimir Markobfea9c22014-01-17 17:49:33 +0000235 kMIRIgnoreClInitCheck,
buzbee02031b12012-11-23 09:41:35 -0800236 kMIRInlined, // Invoke is inlined (ie dead).
237 kMIRInlinedPred, // Invoke is inlined via prediction.
238 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800239 kMIRIgnoreSuspendCheck,
240 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800241 kMIRMark, // Temporary node mark.
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700242 kMIRLastMIRFlag,
buzbeecbd6d442012-11-17 14:11:25 -0800243};
244
buzbee02031b12012-11-23 09:41:35 -0800245// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800246enum BlockListType {
247 kNotUsed = 0,
248 kCatch,
249 kPackedSwitch,
250 kSparseSwitch,
251};
252
253enum AssemblerStatus {
254 kSuccess,
255 kRetryAll,
256};
257
258enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700259 kWord, // Natural word size of target (32/64).
260 k32,
261 k64,
262 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800263 kSingle,
264 kDouble,
265 kUnsignedHalf,
266 kSignedHalf,
267 kUnsignedByte,
268 kSignedByte,
269};
270
271std::ostream& operator<<(std::ostream& os, const OpSize& kind);
272
273enum OpKind {
274 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800275 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800276 kOpMvn,
277 kOpCmp,
278 kOpLsl,
279 kOpLsr,
280 kOpAsr,
281 kOpRor,
282 kOpNot,
283 kOpAnd,
284 kOpOr,
285 kOpXor,
286 kOpNeg,
287 kOpAdd,
288 kOpAdc,
289 kOpSub,
290 kOpSbc,
291 kOpRsub,
292 kOpMul,
293 kOpDiv,
294 kOpRem,
295 kOpBic,
296 kOpCmn,
297 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100298 kOpRev,
299 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800300 kOpBkpt,
301 kOpBlx,
302 kOpPush,
303 kOpPop,
304 kOp2Char,
305 kOp2Short,
306 kOp2Byte,
307 kOpCondBr,
308 kOpUncondBr,
309 kOpBx,
310 kOpInvalid,
311};
312
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800313enum MoveType {
314 kMov8GP, // Move 8-bit general purpose register.
315 kMov16GP, // Move 16-bit general purpose register.
316 kMov32GP, // Move 32-bit general purpose register.
317 kMov64GP, // Move 64-bit general purpose register.
318 kMov32FP, // Move 32-bit FP register.
319 kMov64FP, // Move 64-bit FP register.
320 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
321 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
322 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
323 kMov128FP = kMovU128FP,
324 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
325 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
326 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
327};
328
buzbeecbd6d442012-11-17 14:11:25 -0800329std::ostream& operator<<(std::ostream& os, const OpKind& kind);
330
331enum ConditionCode {
332 kCondEq, // equal
333 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000334 kCondCs, // carry set
335 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000336 kCondUlt, // unsigned less than
337 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800338 kCondMi, // minus
339 kCondPl, // plus, positive or zero
340 kCondVs, // overflow
341 kCondVc, // no overflow
342 kCondHi, // unsigned greater than
343 kCondLs, // unsigned lower or same
344 kCondGe, // signed greater than or equal
345 kCondLt, // signed less than
346 kCondGt, // signed greater than
347 kCondLe, // signed less than or equal
348 kCondAl, // always
349 kCondNv, // never
350};
351
352std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
353
354// Target specific condition encodings
355enum ArmConditionCode {
356 kArmCondEq = 0x0, // 0000
357 kArmCondNe = 0x1, // 0001
358 kArmCondCs = 0x2, // 0010
359 kArmCondCc = 0x3, // 0011
360 kArmCondMi = 0x4, // 0100
361 kArmCondPl = 0x5, // 0101
362 kArmCondVs = 0x6, // 0110
363 kArmCondVc = 0x7, // 0111
364 kArmCondHi = 0x8, // 1000
365 kArmCondLs = 0x9, // 1001
366 kArmCondGe = 0xa, // 1010
367 kArmCondLt = 0xb, // 1011
368 kArmCondGt = 0xc, // 1100
369 kArmCondLe = 0xd, // 1101
370 kArmCondAl = 0xe, // 1110
371 kArmCondNv = 0xf, // 1111
372};
373
374std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
375
376enum X86ConditionCode {
377 kX86CondO = 0x0, // overflow
378 kX86CondNo = 0x1, // not overflow
379
380 kX86CondB = 0x2, // below
381 kX86CondNae = kX86CondB, // not-above-equal
382 kX86CondC = kX86CondB, // carry
383
384 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700385 kX86CondAe = kX86CondNb, // above-equal
386 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800387
388 kX86CondZ = 0x4, // zero
389 kX86CondEq = kX86CondZ, // equal
390
391 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700392 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800393
394 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700395 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800396
397 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700398 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800399
400 kX86CondS = 0x8, // sign
401 kX86CondNs = 0x9, // not-sign
402
403 kX86CondP = 0xa, // 8-bit parity even
404 kX86CondPE = kX86CondP,
405
406 kX86CondNp = 0xb, // 8-bit parity odd
407 kX86CondPo = kX86CondNp,
408
409 kX86CondL = 0xc, // less-than
410 kX86CondNge = kX86CondL, // not-greater-equal
411
412 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700413 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800414
415 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700416 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800417
418 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700419 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800420};
421
422std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
423
424enum ThrowKind {
buzbeecbd6d442012-11-17 14:11:25 -0800425 kThrowNoSuchMethod,
buzbeecbd6d442012-11-17 14:11:25 -0800426};
427
buzbeecbd6d442012-11-17 14:11:25 -0800428enum DividePattern {
429 DivideNone,
430 Divide3,
431 Divide5,
432 Divide7,
433};
434
435std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
436
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800437/**
438 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
439 * @details Without context sensitive analysis, the most conservative set of barriers
440 * must be issued to ensure the Java Memory Model. Thus the recipe is as follows:
441 * -# Use StoreStore barrier before volatile store.
442 * -# Use StoreLoad barrier after volatile store.
443 * -# Use LoadLoad and LoadStore barrier after each volatile load.
444 * -# Use StoreStore barrier after all stores but before return from any constructor whose
445 * class has final fields.
446 */
buzbee1bc37c62012-11-20 13:35:41 -0800447enum MemBarrierKind {
448 kLoadStore,
449 kLoadLoad,
450 kStoreStore,
451 kStoreLoad
452};
453
454std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
455
buzbee02031b12012-11-23 09:41:35 -0800456enum OpFeatureFlags {
457 kIsBranch = 0,
458 kNoOperand,
459 kIsUnaryOp,
460 kIsBinaryOp,
461 kIsTertiaryOp,
462 kIsQuadOp,
463 kIsQuinOp,
464 kIsSextupleOp,
465 kIsIT,
466 kMemLoad,
467 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700468 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800469 kRegDef0,
470 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800471 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800472 kRegDefA,
473 kRegDefD,
474 kRegDefFPCSList0,
475 kRegDefFPCSList2,
476 kRegDefList0,
477 kRegDefList1,
478 kRegDefList2,
479 kRegDefLR,
480 kRegDefSP,
481 kRegUse0,
482 kRegUse1,
483 kRegUse2,
484 kRegUse3,
485 kRegUse4,
486 kRegUseA,
487 kRegUseC,
488 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000489 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800490 kRegUseFPCSList0,
491 kRegUseFPCSList2,
492 kRegUseList0,
493 kRegUseList1,
494 kRegUseLR,
495 kRegUsePC,
496 kRegUseSP,
497 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700498 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700499 kUseFpStack,
500 kUseHi,
501 kUseLo,
502 kDefHi,
503 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800504};
505
buzbeef662a7c2013-02-12 16:19:43 -0800506enum SelectInstructionKind {
507 kSelectNone,
508 kSelectConst,
509 kSelectMove,
510 kSelectGoto
511};
512
buzbeea5abf702013-04-12 14:39:29 -0700513std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
514
buzbeeb48819d2013-09-14 16:15:25 -0700515// LIR fixup kinds for Arm
516enum FixupKind {
517 kFixupNone,
518 kFixupLabel, // For labels we just adjust the offset.
Vladimir Marko306f0172014-01-07 18:21:20 +0000519 kFixupLoad, // Mostly for immediates.
buzbeeb48819d2013-09-14 16:15:25 -0700520 kFixupVLoad, // FP load which *may* be pc-relative.
521 kFixupCBxZ, // Cbz, Cbnz.
522 kFixupPushPop, // Not really pc relative, but changes size based on args.
523 kFixupCondBranch, // Conditional branch
524 kFixupT1Branch, // Thumb1 Unconditional branch
525 kFixupT2Branch, // Thumb2 Unconditional branch
526 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
527 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
528 kFixupAdr, // Adr.
529 kFixupMovImmLST, // kThumb2MovImm16LST.
530 kFixupMovImmHST, // kThumb2MovImm16HST.
531 kFixupAlign4, // Align to 4-byte boundary.
532};
533
534std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
535
buzbeecbd6d442012-11-17 14:11:25 -0800536} // namespace art
537
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700538#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_