blob: f0b47878e6b468f4875bcf0cf1c6782c2b0470b5 [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,
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070051 kArg4,
52 kArg5,
buzbeecbd6d442012-11-17 14:11:25 -080053 kFArg0,
54 kFArg1,
55 kFArg2,
56 kFArg3,
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070057 kFArg4,
58 kFArg5,
59 kFArg6,
60 kFArg7,
buzbeecbd6d442012-11-17 14:11:25 -080061 kRet0,
62 kRet1,
63 kInvokeTgt,
Jeff Hao88474b42013-10-23 16:24:40 -070064 kHiddenArg,
65 kHiddenFpArg,
buzbeecbd6d442012-11-17 14:11:25 -080066 kCount
67};
68
69enum RegLocationType {
Brian Carlstrom7934ac22013-07-26 10:54:15 -070070 kLocDalvikFrame = 0, // Normal Dalvik register
buzbeecbd6d442012-11-17 14:11:25 -080071 kLocPhysReg,
72 kLocCompilerTemp,
73 kLocInvalid
74};
75
76enum BBType {
buzbee0d829482013-10-11 15:24:55 -070077 kNullBlock,
buzbeecbd6d442012-11-17 14:11:25 -080078 kEntryBlock,
79 kDalvikByteCode,
80 kExitBlock,
81 kExceptionHandling,
82 kDead,
83};
84
85/*
buzbeefa57c472012-11-21 12:06:18 -080086 * Def/Use encoding in 64-bit use_mask/def_mask. Low positions used for target-specific
buzbeecbd6d442012-11-17 14:11:25 -080087 * registers (and typically use the register number as the position). High positions
88 * reserved for common and abstract resources.
89 */
90
91enum ResourceEncodingPos {
92 kMustNotAlias = 63,
buzbee02031b12012-11-23 09:41:35 -080093 kHeapRef = 62, // Default memory reference type.
94 kLiteral = 61, // Literal pool memory reference.
95 kDalvikReg = 60, // Dalvik v_reg memory reference.
buzbeecbd6d442012-11-17 14:11:25 -080096 kFPStatus = 59,
97 kCCode = 58,
98 kLowestCommonResource = kCCode
99};
100
buzbee02031b12012-11-23 09:41:35 -0800101// Shared pseudo opcodes - must be < 0.
buzbeecbd6d442012-11-17 14:11:25 -0800102enum LIRPseudoOpcode {
buzbeea169e1d2012-12-05 14:26:44 -0800103 kPseudoExportedPC = -16,
104 kPseudoSafepointPC = -15,
105 kPseudoIntrinsicRetry = -14,
106 kPseudoSuspendTarget = -13,
107 kPseudoThrowTarget = -12,
108 kPseudoCaseLabel = -11,
109 kPseudoMethodEntry = -10,
110 kPseudoMethodExit = -9,
111 kPseudoBarrier = -8,
buzbeecbd6d442012-11-17 14:11:25 -0800112 kPseudoEntryBlock = -7,
113 kPseudoExitBlock = -6,
114 kPseudoTargetLabel = -5,
115 kPseudoDalvikByteCodeBoundary = -4,
116 kPseudoPseudoAlign4 = -3,
117 kPseudoEHBlockLabel = -2,
118 kPseudoNormalBlockLabel = -1,
119};
120
121enum ExtendedMIROpcode {
122 kMirOpFirst = kNumPackedOpcodes,
123 kMirOpPhi = kMirOpFirst,
124 kMirOpCopy,
125 kMirOpFusedCmplFloat,
126 kMirOpFusedCmpgFloat,
127 kMirOpFusedCmplDouble,
128 kMirOpFusedCmpgDouble,
129 kMirOpFusedCmpLong,
130 kMirOpNop,
131 kMirOpNullCheck,
132 kMirOpRangeCheck,
133 kMirOpDivZeroCheck,
134 kMirOpCheck,
buzbeea169e1d2012-12-05 14:26:44 -0800135 kMirOpCheckPart2,
buzbeef662a7c2013-02-12 16:19:43 -0800136 kMirOpSelect,
Mark Mendelld65c51a2014-04-29 16:55:20 -0400137
138 // Vector opcodes:
139 // TypeSize is an encoded field giving the element type and the vector size.
140 // It is encoded as OpSize << 16 | (number of bits in vector)
141 //
142 // Destination and source are integers that will be interpreted by the
143 // backend that supports Vector operations. Backends are permitted to support only
144 // certain vector register sizes.
145 //
146 // At this point, only two operand instructions are supported. Three operand instructions
147 // could be supported by using a bit in TypeSize and arg[0] where needed.
148
149 // @brief MIR to move constant data to a vector register
150 // vA: number of bits in register
151 // vB: destination
152 // args[0]~args[3]: up to 128 bits of data for initialization
153 kMirOpConstVector,
154
155 // @brief MIR to move a vectorized register to another
156 // vA: TypeSize
157 // vB: destination
158 // vC: source
159 kMirOpMoveVector,
160
161 // @brief Packed multiply 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 kMirOpPackedMultiply,
166
167 // @brief Packed addition 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 kMirOpPackedAddition,
172
173 // @brief Packed subtraction 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: source
177 kMirOpPackedSubtract,
178
179 // @brief Packed shift left 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 kMirOpPackedShiftLeft,
184
185 // @brief Packed signed 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 kMirOpPackedSignedShiftRight,
190
191 // @brief Packed unsigned shift right 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: immediate
195 kMirOpPackedUnsignedShiftRight,
196
197 // @brief Packed bitwise and 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 kMirOpPackedAnd,
202
203 // @brief Packed bitwise or 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 kMirOpPackedOr,
208
209 // @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the type of the vector.
210 // vA: TypeSize
211 // vB: destination and source
212 // vC: source
213 kMirOpPackedXor,
214
215 // @brief Reduce a 128-bit packed element into a single VR by taking lower bits
216 // @details Instruction does a horizontal addition of the packed elements and then adds it to VR
217 // vA: TypeSize
218 // vB: destination and source VR (not vector register)
219 // vC: source (vector register)
220 kMirOpPackedAddReduce,
221
222 // @brief Extract a packed element into a single VR.
223 // vA: TypeSize
224 // vB: destination VR (not vector register)
225 // vC: source (vector register)
226 // arg[0]: The index to use for extraction from vector register (which packed element)
227 kMirOpPackedReduce,
228
229 // @brief Create a vector value, with all TypeSize values equal to vC
230 // vA: TypeSize
231 // vB: destination vector register
232 // vC: source VR (not vector register)
233 kMirOpPackedSet,
234
buzbeecbd6d442012-11-17 14:11:25 -0800235 kMirOpLast,
236};
237
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700238enum MIROptimizationFlagPositions {
buzbeecbd6d442012-11-17 14:11:25 -0800239 kMIRIgnoreNullCheck = 0,
240 kMIRNullCheckOnly,
241 kMIRIgnoreRangeCheck,
242 kMIRRangeCheckOnly,
Vladimir Markobfea9c22014-01-17 17:49:33 +0000243 kMIRIgnoreClInitCheck,
buzbee02031b12012-11-23 09:41:35 -0800244 kMIRInlined, // Invoke is inlined (ie dead).
245 kMIRInlinedPred, // Invoke is inlined via prediction.
246 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800247 kMIRIgnoreSuspendCheck,
248 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800249 kMIRMark, // Temporary node mark.
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700250 kMIRLastMIRFlag,
buzbeecbd6d442012-11-17 14:11:25 -0800251};
252
buzbee02031b12012-11-23 09:41:35 -0800253// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800254enum BlockListType {
255 kNotUsed = 0,
256 kCatch,
257 kPackedSwitch,
258 kSparseSwitch,
259};
260
261enum AssemblerStatus {
262 kSuccess,
263 kRetryAll,
264};
265
266enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700267 kWord, // Natural word size of target (32/64).
268 k32,
269 k64,
270 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800271 kSingle,
272 kDouble,
273 kUnsignedHalf,
274 kSignedHalf,
275 kUnsignedByte,
276 kSignedByte,
277};
278
279std::ostream& operator<<(std::ostream& os, const OpSize& kind);
280
281enum OpKind {
282 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800283 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800284 kOpMvn,
285 kOpCmp,
286 kOpLsl,
287 kOpLsr,
288 kOpAsr,
289 kOpRor,
290 kOpNot,
291 kOpAnd,
292 kOpOr,
293 kOpXor,
294 kOpNeg,
295 kOpAdd,
296 kOpAdc,
297 kOpSub,
298 kOpSbc,
299 kOpRsub,
300 kOpMul,
301 kOpDiv,
302 kOpRem,
303 kOpBic,
304 kOpCmn,
305 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100306 kOpRev,
307 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800308 kOpBkpt,
309 kOpBlx,
310 kOpPush,
311 kOpPop,
312 kOp2Char,
313 kOp2Short,
314 kOp2Byte,
315 kOpCondBr,
316 kOpUncondBr,
317 kOpBx,
318 kOpInvalid,
319};
320
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800321enum MoveType {
322 kMov8GP, // Move 8-bit general purpose register.
323 kMov16GP, // Move 16-bit general purpose register.
324 kMov32GP, // Move 32-bit general purpose register.
325 kMov64GP, // Move 64-bit general purpose register.
326 kMov32FP, // Move 32-bit FP register.
327 kMov64FP, // Move 64-bit FP register.
328 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
329 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
330 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
331 kMov128FP = kMovU128FP,
332 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
333 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
334 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
335};
336
buzbeecbd6d442012-11-17 14:11:25 -0800337std::ostream& operator<<(std::ostream& os, const OpKind& kind);
338
339enum ConditionCode {
340 kCondEq, // equal
341 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000342 kCondCs, // carry set
343 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000344 kCondUlt, // unsigned less than
345 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800346 kCondMi, // minus
347 kCondPl, // plus, positive or zero
348 kCondVs, // overflow
349 kCondVc, // no overflow
350 kCondHi, // unsigned greater than
351 kCondLs, // unsigned lower or same
352 kCondGe, // signed greater than or equal
353 kCondLt, // signed less than
354 kCondGt, // signed greater than
355 kCondLe, // signed less than or equal
356 kCondAl, // always
357 kCondNv, // never
358};
359
360std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
361
362// Target specific condition encodings
363enum ArmConditionCode {
364 kArmCondEq = 0x0, // 0000
365 kArmCondNe = 0x1, // 0001
366 kArmCondCs = 0x2, // 0010
367 kArmCondCc = 0x3, // 0011
368 kArmCondMi = 0x4, // 0100
369 kArmCondPl = 0x5, // 0101
370 kArmCondVs = 0x6, // 0110
371 kArmCondVc = 0x7, // 0111
372 kArmCondHi = 0x8, // 1000
373 kArmCondLs = 0x9, // 1001
374 kArmCondGe = 0xa, // 1010
375 kArmCondLt = 0xb, // 1011
376 kArmCondGt = 0xc, // 1100
377 kArmCondLe = 0xd, // 1101
378 kArmCondAl = 0xe, // 1110
379 kArmCondNv = 0xf, // 1111
380};
381
382std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
383
384enum X86ConditionCode {
385 kX86CondO = 0x0, // overflow
386 kX86CondNo = 0x1, // not overflow
387
388 kX86CondB = 0x2, // below
389 kX86CondNae = kX86CondB, // not-above-equal
390 kX86CondC = kX86CondB, // carry
391
392 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700393 kX86CondAe = kX86CondNb, // above-equal
394 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800395
396 kX86CondZ = 0x4, // zero
397 kX86CondEq = kX86CondZ, // equal
398
399 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700400 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800401
402 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700403 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800404
405 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700406 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800407
408 kX86CondS = 0x8, // sign
409 kX86CondNs = 0x9, // not-sign
410
411 kX86CondP = 0xa, // 8-bit parity even
412 kX86CondPE = kX86CondP,
413
414 kX86CondNp = 0xb, // 8-bit parity odd
415 kX86CondPo = kX86CondNp,
416
417 kX86CondL = 0xc, // less-than
418 kX86CondNge = kX86CondL, // not-greater-equal
419
420 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700421 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800422
423 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700424 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800425
426 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700427 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800428};
429
430std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
431
432enum ThrowKind {
buzbeecbd6d442012-11-17 14:11:25 -0800433 kThrowNoSuchMethod,
buzbeecbd6d442012-11-17 14:11:25 -0800434};
435
buzbeecbd6d442012-11-17 14:11:25 -0800436enum DividePattern {
437 DivideNone,
438 Divide3,
439 Divide5,
440 Divide7,
441};
442
443std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
444
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800445/**
446 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
447 * @details Without context sensitive analysis, the most conservative set of barriers
448 * must be issued to ensure the Java Memory Model. Thus the recipe is as follows:
449 * -# Use StoreStore barrier before volatile store.
450 * -# Use StoreLoad barrier after volatile store.
451 * -# Use LoadLoad and LoadStore barrier after each volatile load.
452 * -# Use StoreStore barrier after all stores but before return from any constructor whose
453 * class has final fields.
454 */
buzbee1bc37c62012-11-20 13:35:41 -0800455enum MemBarrierKind {
456 kLoadStore,
457 kLoadLoad,
458 kStoreStore,
459 kStoreLoad
460};
461
462std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
463
buzbee02031b12012-11-23 09:41:35 -0800464enum OpFeatureFlags {
465 kIsBranch = 0,
466 kNoOperand,
467 kIsUnaryOp,
468 kIsBinaryOp,
469 kIsTertiaryOp,
470 kIsQuadOp,
471 kIsQuinOp,
472 kIsSextupleOp,
473 kIsIT,
474 kMemLoad,
475 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700476 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800477 kRegDef0,
478 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800479 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800480 kRegDefA,
481 kRegDefD,
482 kRegDefFPCSList0,
483 kRegDefFPCSList2,
484 kRegDefList0,
485 kRegDefList1,
486 kRegDefList2,
487 kRegDefLR,
488 kRegDefSP,
489 kRegUse0,
490 kRegUse1,
491 kRegUse2,
492 kRegUse3,
493 kRegUse4,
494 kRegUseA,
495 kRegUseC,
496 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000497 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800498 kRegUseFPCSList0,
499 kRegUseFPCSList2,
500 kRegUseList0,
501 kRegUseList1,
502 kRegUseLR,
503 kRegUsePC,
504 kRegUseSP,
505 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700506 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700507 kUseFpStack,
508 kUseHi,
509 kUseLo,
510 kDefHi,
511 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800512};
513
buzbeef662a7c2013-02-12 16:19:43 -0800514enum SelectInstructionKind {
515 kSelectNone,
516 kSelectConst,
517 kSelectMove,
518 kSelectGoto
519};
520
buzbeea5abf702013-04-12 14:39:29 -0700521std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
522
buzbeeb48819d2013-09-14 16:15:25 -0700523// LIR fixup kinds for Arm
524enum FixupKind {
525 kFixupNone,
526 kFixupLabel, // For labels we just adjust the offset.
Vladimir Marko306f0172014-01-07 18:21:20 +0000527 kFixupLoad, // Mostly for immediates.
buzbeeb48819d2013-09-14 16:15:25 -0700528 kFixupVLoad, // FP load which *may* be pc-relative.
529 kFixupCBxZ, // Cbz, Cbnz.
530 kFixupPushPop, // Not really pc relative, but changes size based on args.
531 kFixupCondBranch, // Conditional branch
532 kFixupT1Branch, // Thumb1 Unconditional branch
533 kFixupT2Branch, // Thumb2 Unconditional branch
534 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
535 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
536 kFixupAdr, // Adr.
537 kFixupMovImmLST, // kThumb2MovImm16LST.
538 kFixupMovImmHST, // kThumb2MovImm16HST.
539 kFixupAlign4, // Align to 4-byte boundary.
540};
541
542std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
543
buzbeecbd6d442012-11-17 14:11:25 -0800544} // namespace art
545
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700546#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_