blob: eb48cc378370855db634a1e9183a4d7694148e91 [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,
buzbeea0cd2d72014-06-01 09:33:49 -070028 kRefReg,
buzbeecbd6d442012-11-17 14:11:25 -080029 kAnyReg,
30};
31
buzbee091cc402014-03-31 10:14:40 -070032enum BitsUsed {
33 kSize32Bits,
34 kSize64Bits,
35 kSize128Bits,
36 kSize256Bits,
37 kSize512Bits,
38 kSize1024Bits,
39};
40
buzbeecbd6d442012-11-17 14:11:25 -080041enum SpecialTargetRegister {
buzbee02031b12012-11-23 09:41:35 -080042 kSelf, // Thread pointer.
43 kSuspend, // Used to reduce suspend checks for some targets.
buzbeecbd6d442012-11-17 14:11:25 -080044 kLr,
45 kPc,
46 kSp,
47 kArg0,
48 kArg1,
49 kArg2,
50 kArg3,
51 kFArg0,
52 kFArg1,
53 kFArg2,
54 kFArg3,
55 kRet0,
56 kRet1,
57 kInvokeTgt,
Jeff Hao88474b42013-10-23 16:24:40 -070058 kHiddenArg,
59 kHiddenFpArg,
buzbeecbd6d442012-11-17 14:11:25 -080060 kCount
61};
62
63enum RegLocationType {
Brian Carlstrom7934ac22013-07-26 10:54:15 -070064 kLocDalvikFrame = 0, // Normal Dalvik register
buzbeecbd6d442012-11-17 14:11:25 -080065 kLocPhysReg,
66 kLocCompilerTemp,
67 kLocInvalid
68};
69
70enum 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,
Mark Mendelld65c51a2014-04-29 16:55:20 -0400131
132 // Vector opcodes:
133 // TypeSize is an encoded field giving the element type and the vector size.
134 // It is encoded as OpSize << 16 | (number of bits in vector)
135 //
136 // Destination and source are integers that will be interpreted by the
137 // backend that supports Vector operations. Backends are permitted to support only
138 // certain vector register sizes.
139 //
140 // At this point, only two operand instructions are supported. Three operand instructions
141 // could be supported by using a bit in TypeSize and arg[0] where needed.
142
143 // @brief MIR to move constant data to a vector register
144 // vA: number of bits in register
145 // vB: destination
146 // args[0]~args[3]: up to 128 bits of data for initialization
147 kMirOpConstVector,
148
149 // @brief MIR to move a vectorized register to another
150 // vA: TypeSize
151 // vB: destination
152 // vC: source
153 kMirOpMoveVector,
154
155 // @brief Packed multiply of units in two vector registers: vB = vB .* vC using vA to know the type of the vector.
156 // vA: TypeSize
157 // vB: destination and source
158 // vC: source
159 kMirOpPackedMultiply,
160
161 // @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the type of the vector.
162 // vA: TypeSize
163 // vB: destination and source
164 // vC: source
165 kMirOpPackedAddition,
166
167 // @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the type of the vector.
168 // vA: TypeSize
169 // vB: destination and source
170 // vC: source
171 kMirOpPackedSubtract,
172
173 // @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the type of the vector.
174 // vA: TypeSize
175 // vB: destination and source
176 // vC: immediate
177 kMirOpPackedShiftLeft,
178
179 // @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to know the type of the vector.
180 // vA: TypeSize
181 // vB: destination and source
182 // vC: immediate
183 kMirOpPackedSignedShiftRight,
184
185 // @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA to know the type of the vector.
186 // vA: TypeSize
187 // vB: destination and source
188 // vC: immediate
189 kMirOpPackedUnsignedShiftRight,
190
191 // @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the type of the vector.
192 // vA: TypeSize
193 // vB: destination and source
194 // vC: source
195 kMirOpPackedAnd,
196
197 // @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the type of the vector.
198 // vA: TypeSize
199 // vB: destination and source
200 // vC: source
201 kMirOpPackedOr,
202
203 // @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the type of the vector.
204 // vA: TypeSize
205 // vB: destination and source
206 // vC: source
207 kMirOpPackedXor,
208
209 // @brief Reduce a 128-bit packed element into a single VR by taking lower bits
210 // @details Instruction does a horizontal addition of the packed elements and then adds it to VR
211 // vA: TypeSize
212 // vB: destination and source VR (not vector register)
213 // vC: source (vector register)
214 kMirOpPackedAddReduce,
215
216 // @brief Extract a packed element into a single VR.
217 // vA: TypeSize
218 // vB: destination VR (not vector register)
219 // vC: source (vector register)
220 // arg[0]: The index to use for extraction from vector register (which packed element)
221 kMirOpPackedReduce,
222
223 // @brief Create a vector value, with all TypeSize values equal to vC
224 // vA: TypeSize
225 // vB: destination vector register
226 // vC: source VR (not vector register)
227 kMirOpPackedSet,
228
buzbeecbd6d442012-11-17 14:11:25 -0800229 kMirOpLast,
230};
231
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700232enum MIROptimizationFlagPositions {
buzbeecbd6d442012-11-17 14:11:25 -0800233 kMIRIgnoreNullCheck = 0,
234 kMIRNullCheckOnly,
235 kMIRIgnoreRangeCheck,
236 kMIRRangeCheckOnly,
Vladimir Markobfea9c22014-01-17 17:49:33 +0000237 kMIRIgnoreClInitCheck,
buzbee02031b12012-11-23 09:41:35 -0800238 kMIRInlined, // Invoke is inlined (ie dead).
239 kMIRInlinedPred, // Invoke is inlined via prediction.
240 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800241 kMIRIgnoreSuspendCheck,
242 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800243 kMIRMark, // Temporary node mark.
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700244 kMIRLastMIRFlag,
buzbeecbd6d442012-11-17 14:11:25 -0800245};
246
buzbee02031b12012-11-23 09:41:35 -0800247// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800248enum BlockListType {
249 kNotUsed = 0,
250 kCatch,
251 kPackedSwitch,
252 kSparseSwitch,
253};
254
255enum AssemblerStatus {
256 kSuccess,
257 kRetryAll,
258};
259
260enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700261 kWord, // Natural word size of target (32/64).
262 k32,
263 k64,
264 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800265 kSingle,
266 kDouble,
267 kUnsignedHalf,
268 kSignedHalf,
269 kUnsignedByte,
270 kSignedByte,
271};
272
273std::ostream& operator<<(std::ostream& os, const OpSize& kind);
274
275enum OpKind {
276 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800277 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800278 kOpMvn,
279 kOpCmp,
280 kOpLsl,
281 kOpLsr,
282 kOpAsr,
283 kOpRor,
284 kOpNot,
285 kOpAnd,
286 kOpOr,
287 kOpXor,
288 kOpNeg,
289 kOpAdd,
290 kOpAdc,
291 kOpSub,
292 kOpSbc,
293 kOpRsub,
294 kOpMul,
295 kOpDiv,
296 kOpRem,
297 kOpBic,
298 kOpCmn,
299 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100300 kOpRev,
301 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800302 kOpBkpt,
303 kOpBlx,
304 kOpPush,
305 kOpPop,
306 kOp2Char,
307 kOp2Short,
308 kOp2Byte,
309 kOpCondBr,
310 kOpUncondBr,
311 kOpBx,
312 kOpInvalid,
313};
314
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800315enum MoveType {
316 kMov8GP, // Move 8-bit general purpose register.
317 kMov16GP, // Move 16-bit general purpose register.
318 kMov32GP, // Move 32-bit general purpose register.
319 kMov64GP, // Move 64-bit general purpose register.
320 kMov32FP, // Move 32-bit FP register.
321 kMov64FP, // Move 64-bit FP register.
322 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
323 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
324 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
325 kMov128FP = kMovU128FP,
326 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
327 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
328 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
329};
330
buzbeecbd6d442012-11-17 14:11:25 -0800331std::ostream& operator<<(std::ostream& os, const OpKind& kind);
332
333enum ConditionCode {
334 kCondEq, // equal
335 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000336 kCondCs, // carry set
337 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000338 kCondUlt, // unsigned less than
339 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800340 kCondMi, // minus
341 kCondPl, // plus, positive or zero
342 kCondVs, // overflow
343 kCondVc, // no overflow
344 kCondHi, // unsigned greater than
345 kCondLs, // unsigned lower or same
346 kCondGe, // signed greater than or equal
347 kCondLt, // signed less than
348 kCondGt, // signed greater than
349 kCondLe, // signed less than or equal
350 kCondAl, // always
351 kCondNv, // never
352};
353
354std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
355
356// Target specific condition encodings
357enum ArmConditionCode {
358 kArmCondEq = 0x0, // 0000
359 kArmCondNe = 0x1, // 0001
360 kArmCondCs = 0x2, // 0010
361 kArmCondCc = 0x3, // 0011
362 kArmCondMi = 0x4, // 0100
363 kArmCondPl = 0x5, // 0101
364 kArmCondVs = 0x6, // 0110
365 kArmCondVc = 0x7, // 0111
366 kArmCondHi = 0x8, // 1000
367 kArmCondLs = 0x9, // 1001
368 kArmCondGe = 0xa, // 1010
369 kArmCondLt = 0xb, // 1011
370 kArmCondGt = 0xc, // 1100
371 kArmCondLe = 0xd, // 1101
372 kArmCondAl = 0xe, // 1110
373 kArmCondNv = 0xf, // 1111
374};
375
376std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
377
378enum X86ConditionCode {
379 kX86CondO = 0x0, // overflow
380 kX86CondNo = 0x1, // not overflow
381
382 kX86CondB = 0x2, // below
383 kX86CondNae = kX86CondB, // not-above-equal
384 kX86CondC = kX86CondB, // carry
385
386 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700387 kX86CondAe = kX86CondNb, // above-equal
388 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800389
390 kX86CondZ = 0x4, // zero
391 kX86CondEq = kX86CondZ, // equal
392
393 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700394 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800395
396 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700397 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800398
399 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700400 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800401
402 kX86CondS = 0x8, // sign
403 kX86CondNs = 0x9, // not-sign
404
405 kX86CondP = 0xa, // 8-bit parity even
406 kX86CondPE = kX86CondP,
407
408 kX86CondNp = 0xb, // 8-bit parity odd
409 kX86CondPo = kX86CondNp,
410
411 kX86CondL = 0xc, // less-than
412 kX86CondNge = kX86CondL, // not-greater-equal
413
414 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700415 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800416
417 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700418 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800419
420 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700421 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800422};
423
424std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
425
426enum ThrowKind {
buzbeecbd6d442012-11-17 14:11:25 -0800427 kThrowNoSuchMethod,
buzbeecbd6d442012-11-17 14:11:25 -0800428};
429
buzbeecbd6d442012-11-17 14:11:25 -0800430enum DividePattern {
431 DivideNone,
432 Divide3,
433 Divide5,
434 Divide7,
435};
436
437std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
438
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800439/**
440 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
441 * @details Without context sensitive analysis, the most conservative set of barriers
442 * must be issued to ensure the Java Memory Model. Thus the recipe is as follows:
443 * -# Use StoreStore barrier before volatile store.
444 * -# Use StoreLoad barrier after volatile store.
445 * -# Use LoadLoad and LoadStore barrier after each volatile load.
446 * -# Use StoreStore barrier after all stores but before return from any constructor whose
447 * class has final fields.
448 */
buzbee1bc37c62012-11-20 13:35:41 -0800449enum MemBarrierKind {
450 kLoadStore,
451 kLoadLoad,
452 kStoreStore,
453 kStoreLoad
454};
455
456std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
457
buzbee02031b12012-11-23 09:41:35 -0800458enum OpFeatureFlags {
459 kIsBranch = 0,
460 kNoOperand,
461 kIsUnaryOp,
462 kIsBinaryOp,
463 kIsTertiaryOp,
464 kIsQuadOp,
465 kIsQuinOp,
466 kIsSextupleOp,
467 kIsIT,
468 kMemLoad,
469 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700470 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800471 kRegDef0,
472 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800473 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800474 kRegDefA,
475 kRegDefD,
476 kRegDefFPCSList0,
477 kRegDefFPCSList2,
478 kRegDefList0,
479 kRegDefList1,
480 kRegDefList2,
481 kRegDefLR,
482 kRegDefSP,
483 kRegUse0,
484 kRegUse1,
485 kRegUse2,
486 kRegUse3,
487 kRegUse4,
488 kRegUseA,
489 kRegUseC,
490 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000491 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800492 kRegUseFPCSList0,
493 kRegUseFPCSList2,
494 kRegUseList0,
495 kRegUseList1,
496 kRegUseLR,
497 kRegUsePC,
498 kRegUseSP,
499 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700500 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700501 kUseFpStack,
502 kUseHi,
503 kUseLo,
504 kDefHi,
505 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800506};
507
buzbeef662a7c2013-02-12 16:19:43 -0800508enum SelectInstructionKind {
509 kSelectNone,
510 kSelectConst,
511 kSelectMove,
512 kSelectGoto
513};
514
buzbeea5abf702013-04-12 14:39:29 -0700515std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
516
buzbeeb48819d2013-09-14 16:15:25 -0700517// LIR fixup kinds for Arm
518enum FixupKind {
519 kFixupNone,
520 kFixupLabel, // For labels we just adjust the offset.
Vladimir Marko306f0172014-01-07 18:21:20 +0000521 kFixupLoad, // Mostly for immediates.
buzbeeb48819d2013-09-14 16:15:25 -0700522 kFixupVLoad, // FP load which *may* be pc-relative.
523 kFixupCBxZ, // Cbz, Cbnz.
524 kFixupPushPop, // Not really pc relative, but changes size based on args.
525 kFixupCondBranch, // Conditional branch
526 kFixupT1Branch, // Thumb1 Unconditional branch
527 kFixupT2Branch, // Thumb2 Unconditional branch
528 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
529 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
530 kFixupAdr, // Adr.
531 kFixupMovImmLST, // kThumb2MovImm16LST.
532 kFixupMovImmHST, // kThumb2MovImm16HST.
533 kFixupAlign4, // Align to 4-byte boundary.
534};
535
536std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
537
buzbeecbd6d442012-11-17 14:11:25 -0800538} // namespace art
539
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700540#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_