blob: 767ffbf432f3fd540f6bc22bedc8e253269d9d49 [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 {
Serban Constantinescu032d3772014-05-23 17:38:18 +010025 kInvalidRegClass,
buzbeecbd6d442012-11-17 14:11:25 -080026 kCoreReg,
27 kFPReg,
28 kAnyReg,
29};
30
buzbee091cc402014-03-31 10:14:40 -070031enum BitsUsed {
32 kSize32Bits,
33 kSize64Bits,
34 kSize128Bits,
35 kSize256Bits,
36 kSize512Bits,
37 kSize1024Bits,
38};
39
buzbeecbd6d442012-11-17 14:11:25 -080040enum SpecialTargetRegister {
buzbee02031b12012-11-23 09:41:35 -080041 kSelf, // Thread pointer.
42 kSuspend, // Used to reduce suspend checks for some targets.
buzbeecbd6d442012-11-17 14:11:25 -080043 kLr,
44 kPc,
45 kSp,
46 kArg0,
47 kArg1,
48 kArg2,
49 kArg3,
50 kFArg0,
51 kFArg1,
52 kFArg2,
53 kFArg3,
54 kRet0,
55 kRet1,
56 kInvokeTgt,
Jeff Hao88474b42013-10-23 16:24:40 -070057 kHiddenArg,
58 kHiddenFpArg,
buzbeecbd6d442012-11-17 14:11:25 -080059 kCount
60};
61
62enum RegLocationType {
Brian Carlstrom7934ac22013-07-26 10:54:15 -070063 kLocDalvikFrame = 0, // Normal Dalvik register
buzbeecbd6d442012-11-17 14:11:25 -080064 kLocPhysReg,
65 kLocCompilerTemp,
66 kLocInvalid
67};
68
69enum BBType {
buzbee0d829482013-10-11 15:24:55 -070070 kNullBlock,
buzbeecbd6d442012-11-17 14:11:25 -080071 kEntryBlock,
72 kDalvikByteCode,
73 kExitBlock,
74 kExceptionHandling,
75 kDead,
76};
77
78/*
buzbeefa57c472012-11-21 12:06:18 -080079 * Def/Use encoding in 64-bit use_mask/def_mask. Low positions used for target-specific
buzbeecbd6d442012-11-17 14:11:25 -080080 * registers (and typically use the register number as the position). High positions
81 * reserved for common and abstract resources.
82 */
83
84enum ResourceEncodingPos {
85 kMustNotAlias = 63,
buzbee02031b12012-11-23 09:41:35 -080086 kHeapRef = 62, // Default memory reference type.
87 kLiteral = 61, // Literal pool memory reference.
88 kDalvikReg = 60, // Dalvik v_reg memory reference.
buzbeecbd6d442012-11-17 14:11:25 -080089 kFPStatus = 59,
90 kCCode = 58,
91 kLowestCommonResource = kCCode
92};
93
buzbee02031b12012-11-23 09:41:35 -080094// Shared pseudo opcodes - must be < 0.
buzbeecbd6d442012-11-17 14:11:25 -080095enum LIRPseudoOpcode {
buzbeea169e1d2012-12-05 14:26:44 -080096 kPseudoExportedPC = -16,
97 kPseudoSafepointPC = -15,
98 kPseudoIntrinsicRetry = -14,
99 kPseudoSuspendTarget = -13,
100 kPseudoThrowTarget = -12,
101 kPseudoCaseLabel = -11,
102 kPseudoMethodEntry = -10,
103 kPseudoMethodExit = -9,
104 kPseudoBarrier = -8,
buzbeecbd6d442012-11-17 14:11:25 -0800105 kPseudoEntryBlock = -7,
106 kPseudoExitBlock = -6,
107 kPseudoTargetLabel = -5,
108 kPseudoDalvikByteCodeBoundary = -4,
109 kPseudoPseudoAlign4 = -3,
110 kPseudoEHBlockLabel = -2,
111 kPseudoNormalBlockLabel = -1,
112};
113
114enum ExtendedMIROpcode {
115 kMirOpFirst = kNumPackedOpcodes,
116 kMirOpPhi = kMirOpFirst,
117 kMirOpCopy,
118 kMirOpFusedCmplFloat,
119 kMirOpFusedCmpgFloat,
120 kMirOpFusedCmplDouble,
121 kMirOpFusedCmpgDouble,
122 kMirOpFusedCmpLong,
123 kMirOpNop,
124 kMirOpNullCheck,
125 kMirOpRangeCheck,
126 kMirOpDivZeroCheck,
127 kMirOpCheck,
buzbeea169e1d2012-12-05 14:26:44 -0800128 kMirOpCheckPart2,
buzbeef662a7c2013-02-12 16:19:43 -0800129 kMirOpSelect,
Mark Mendelld65c51a2014-04-29 16:55:20 -0400130
131 // Vector opcodes:
132 // TypeSize is an encoded field giving the element type and the vector size.
133 // It is encoded as OpSize << 16 | (number of bits in vector)
134 //
135 // Destination and source are integers that will be interpreted by the
136 // backend that supports Vector operations. Backends are permitted to support only
137 // certain vector register sizes.
138 //
139 // At this point, only two operand instructions are supported. Three operand instructions
140 // could be supported by using a bit in TypeSize and arg[0] where needed.
141
142 // @brief MIR to move constant data to a vector register
143 // vA: number of bits in register
144 // vB: destination
145 // args[0]~args[3]: up to 128 bits of data for initialization
146 kMirOpConstVector,
147
148 // @brief MIR to move a vectorized register to another
149 // vA: TypeSize
150 // vB: destination
151 // vC: source
152 kMirOpMoveVector,
153
154 // @brief Packed multiply of units in two vector registers: vB = vB .* vC using vA to know the type of the vector.
155 // vA: TypeSize
156 // vB: destination and source
157 // vC: source
158 kMirOpPackedMultiply,
159
160 // @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the type of the vector.
161 // vA: TypeSize
162 // vB: destination and source
163 // vC: source
164 kMirOpPackedAddition,
165
166 // @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the type of the vector.
167 // vA: TypeSize
168 // vB: destination and source
169 // vC: source
170 kMirOpPackedSubtract,
171
172 // @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the type of the vector.
173 // vA: TypeSize
174 // vB: destination and source
175 // vC: immediate
176 kMirOpPackedShiftLeft,
177
178 // @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to know the type of the vector.
179 // vA: TypeSize
180 // vB: destination and source
181 // vC: immediate
182 kMirOpPackedSignedShiftRight,
183
184 // @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA to know the type of the vector.
185 // vA: TypeSize
186 // vB: destination and source
187 // vC: immediate
188 kMirOpPackedUnsignedShiftRight,
189
190 // @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the type of the vector.
191 // vA: TypeSize
192 // vB: destination and source
193 // vC: source
194 kMirOpPackedAnd,
195
196 // @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the type of the vector.
197 // vA: TypeSize
198 // vB: destination and source
199 // vC: source
200 kMirOpPackedOr,
201
202 // @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the type of the vector.
203 // vA: TypeSize
204 // vB: destination and source
205 // vC: source
206 kMirOpPackedXor,
207
208 // @brief Reduce a 128-bit packed element into a single VR by taking lower bits
209 // @details Instruction does a horizontal addition of the packed elements and then adds it to VR
210 // vA: TypeSize
211 // vB: destination and source VR (not vector register)
212 // vC: source (vector register)
213 kMirOpPackedAddReduce,
214
215 // @brief Extract a packed element into a single VR.
216 // vA: TypeSize
217 // vB: destination VR (not vector register)
218 // vC: source (vector register)
219 // arg[0]: The index to use for extraction from vector register (which packed element)
220 kMirOpPackedReduce,
221
222 // @brief Create a vector value, with all TypeSize values equal to vC
223 // vA: TypeSize
224 // vB: destination vector register
225 // vC: source VR (not vector register)
226 kMirOpPackedSet,
227
buzbeecbd6d442012-11-17 14:11:25 -0800228 kMirOpLast,
229};
230
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700231enum MIROptimizationFlagPositions {
buzbeecbd6d442012-11-17 14:11:25 -0800232 kMIRIgnoreNullCheck = 0,
233 kMIRNullCheckOnly,
234 kMIRIgnoreRangeCheck,
235 kMIRRangeCheckOnly,
Vladimir Markobfea9c22014-01-17 17:49:33 +0000236 kMIRIgnoreClInitCheck,
buzbee02031b12012-11-23 09:41:35 -0800237 kMIRInlined, // Invoke is inlined (ie dead).
238 kMIRInlinedPred, // Invoke is inlined via prediction.
239 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800240 kMIRIgnoreSuspendCheck,
241 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800242 kMIRMark, // Temporary node mark.
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700243 kMIRLastMIRFlag,
buzbeecbd6d442012-11-17 14:11:25 -0800244};
245
buzbee02031b12012-11-23 09:41:35 -0800246// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800247enum BlockListType {
248 kNotUsed = 0,
249 kCatch,
250 kPackedSwitch,
251 kSparseSwitch,
252};
253
254enum AssemblerStatus {
255 kSuccess,
256 kRetryAll,
257};
258
259enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700260 kWord, // Natural word size of target (32/64).
261 k32,
262 k64,
263 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800264 kSingle,
265 kDouble,
266 kUnsignedHalf,
267 kSignedHalf,
268 kUnsignedByte,
269 kSignedByte,
270};
271
272std::ostream& operator<<(std::ostream& os, const OpSize& kind);
273
274enum OpKind {
275 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800276 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800277 kOpMvn,
278 kOpCmp,
279 kOpLsl,
280 kOpLsr,
281 kOpAsr,
282 kOpRor,
283 kOpNot,
284 kOpAnd,
285 kOpOr,
286 kOpXor,
287 kOpNeg,
288 kOpAdd,
289 kOpAdc,
290 kOpSub,
291 kOpSbc,
292 kOpRsub,
293 kOpMul,
294 kOpDiv,
295 kOpRem,
296 kOpBic,
297 kOpCmn,
298 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100299 kOpRev,
300 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800301 kOpBkpt,
302 kOpBlx,
303 kOpPush,
304 kOpPop,
305 kOp2Char,
306 kOp2Short,
307 kOp2Byte,
308 kOpCondBr,
309 kOpUncondBr,
310 kOpBx,
311 kOpInvalid,
312};
313
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800314enum MoveType {
315 kMov8GP, // Move 8-bit general purpose register.
316 kMov16GP, // Move 16-bit general purpose register.
317 kMov32GP, // Move 32-bit general purpose register.
318 kMov64GP, // Move 64-bit general purpose register.
319 kMov32FP, // Move 32-bit FP register.
320 kMov64FP, // Move 64-bit FP register.
321 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
322 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
323 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
324 kMov128FP = kMovU128FP,
325 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
326 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
327 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
328};
329
buzbeecbd6d442012-11-17 14:11:25 -0800330std::ostream& operator<<(std::ostream& os, const OpKind& kind);
331
332enum ConditionCode {
333 kCondEq, // equal
334 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000335 kCondCs, // carry set
336 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000337 kCondUlt, // unsigned less than
338 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800339 kCondMi, // minus
340 kCondPl, // plus, positive or zero
341 kCondVs, // overflow
342 kCondVc, // no overflow
343 kCondHi, // unsigned greater than
344 kCondLs, // unsigned lower or same
345 kCondGe, // signed greater than or equal
346 kCondLt, // signed less than
347 kCondGt, // signed greater than
348 kCondLe, // signed less than or equal
349 kCondAl, // always
350 kCondNv, // never
351};
352
353std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
354
355// Target specific condition encodings
356enum ArmConditionCode {
357 kArmCondEq = 0x0, // 0000
358 kArmCondNe = 0x1, // 0001
359 kArmCondCs = 0x2, // 0010
360 kArmCondCc = 0x3, // 0011
361 kArmCondMi = 0x4, // 0100
362 kArmCondPl = 0x5, // 0101
363 kArmCondVs = 0x6, // 0110
364 kArmCondVc = 0x7, // 0111
365 kArmCondHi = 0x8, // 1000
366 kArmCondLs = 0x9, // 1001
367 kArmCondGe = 0xa, // 1010
368 kArmCondLt = 0xb, // 1011
369 kArmCondGt = 0xc, // 1100
370 kArmCondLe = 0xd, // 1101
371 kArmCondAl = 0xe, // 1110
372 kArmCondNv = 0xf, // 1111
373};
374
375std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
376
377enum X86ConditionCode {
378 kX86CondO = 0x0, // overflow
379 kX86CondNo = 0x1, // not overflow
380
381 kX86CondB = 0x2, // below
382 kX86CondNae = kX86CondB, // not-above-equal
383 kX86CondC = kX86CondB, // carry
384
385 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700386 kX86CondAe = kX86CondNb, // above-equal
387 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800388
389 kX86CondZ = 0x4, // zero
390 kX86CondEq = kX86CondZ, // equal
391
392 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700393 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800394
395 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700396 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800397
398 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700399 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800400
401 kX86CondS = 0x8, // sign
402 kX86CondNs = 0x9, // not-sign
403
404 kX86CondP = 0xa, // 8-bit parity even
405 kX86CondPE = kX86CondP,
406
407 kX86CondNp = 0xb, // 8-bit parity odd
408 kX86CondPo = kX86CondNp,
409
410 kX86CondL = 0xc, // less-than
411 kX86CondNge = kX86CondL, // not-greater-equal
412
413 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700414 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800415
416 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700417 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800418
419 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700420 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800421};
422
423std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
424
425enum ThrowKind {
buzbeecbd6d442012-11-17 14:11:25 -0800426 kThrowNoSuchMethod,
buzbeecbd6d442012-11-17 14:11:25 -0800427};
428
buzbeecbd6d442012-11-17 14:11:25 -0800429enum DividePattern {
430 DivideNone,
431 Divide3,
432 Divide5,
433 Divide7,
434};
435
436std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
437
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800438/**
439 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
440 * @details Without context sensitive analysis, the most conservative set of barriers
441 * must be issued to ensure the Java Memory Model. Thus the recipe is as follows:
442 * -# Use StoreStore barrier before volatile store.
443 * -# Use StoreLoad barrier after volatile store.
444 * -# Use LoadLoad and LoadStore barrier after each volatile load.
445 * -# Use StoreStore barrier after all stores but before return from any constructor whose
446 * class has final fields.
447 */
buzbee1bc37c62012-11-20 13:35:41 -0800448enum MemBarrierKind {
449 kLoadStore,
450 kLoadLoad,
451 kStoreStore,
452 kStoreLoad
453};
454
455std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
456
buzbee02031b12012-11-23 09:41:35 -0800457enum OpFeatureFlags {
458 kIsBranch = 0,
459 kNoOperand,
460 kIsUnaryOp,
461 kIsBinaryOp,
462 kIsTertiaryOp,
463 kIsQuadOp,
464 kIsQuinOp,
465 kIsSextupleOp,
466 kIsIT,
467 kMemLoad,
468 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700469 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800470 kRegDef0,
471 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800472 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800473 kRegDefA,
474 kRegDefD,
475 kRegDefFPCSList0,
476 kRegDefFPCSList2,
477 kRegDefList0,
478 kRegDefList1,
479 kRegDefList2,
480 kRegDefLR,
481 kRegDefSP,
482 kRegUse0,
483 kRegUse1,
484 kRegUse2,
485 kRegUse3,
486 kRegUse4,
487 kRegUseA,
488 kRegUseC,
489 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000490 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800491 kRegUseFPCSList0,
492 kRegUseFPCSList2,
493 kRegUseList0,
494 kRegUseList1,
495 kRegUseLR,
496 kRegUsePC,
497 kRegUseSP,
498 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700499 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700500 kUseFpStack,
501 kUseHi,
502 kUseLo,
503 kDefHi,
504 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800505};
506
buzbeef662a7c2013-02-12 16:19:43 -0800507enum SelectInstructionKind {
508 kSelectNone,
509 kSelectConst,
510 kSelectMove,
511 kSelectGoto
512};
513
buzbeea5abf702013-04-12 14:39:29 -0700514std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
515
buzbeeb48819d2013-09-14 16:15:25 -0700516// LIR fixup kinds for Arm
517enum FixupKind {
518 kFixupNone,
519 kFixupLabel, // For labels we just adjust the offset.
Vladimir Marko306f0172014-01-07 18:21:20 +0000520 kFixupLoad, // Mostly for immediates.
buzbeeb48819d2013-09-14 16:15:25 -0700521 kFixupVLoad, // FP load which *may* be pc-relative.
522 kFixupCBxZ, // Cbz, Cbnz.
523 kFixupPushPop, // Not really pc relative, but changes size based on args.
524 kFixupCondBranch, // Conditional branch
525 kFixupT1Branch, // Thumb1 Unconditional branch
526 kFixupT2Branch, // Thumb2 Unconditional branch
527 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
528 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
529 kFixupAdr, // Adr.
530 kFixupMovImmLST, // kThumb2MovImm16LST.
531 kFixupMovImmHST, // kThumb2MovImm16HST.
532 kFixupAlign4, // Align to 4-byte boundary.
533};
534
535std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
536
buzbeecbd6d442012-11-17 14:11:25 -0800537} // namespace art
538
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700539#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_