blob: 55a4c7815e7e27cfc0fbb07ab88aa0b1452f4bae [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
buzbee02031b12012-11-23 09:41:35 -080085// Shared pseudo opcodes - must be < 0.
buzbeecbd6d442012-11-17 14:11:25 -080086enum LIRPseudoOpcode {
buzbeea169e1d2012-12-05 14:26:44 -080087 kPseudoExportedPC = -16,
88 kPseudoSafepointPC = -15,
89 kPseudoIntrinsicRetry = -14,
90 kPseudoSuspendTarget = -13,
91 kPseudoThrowTarget = -12,
92 kPseudoCaseLabel = -11,
93 kPseudoMethodEntry = -10,
94 kPseudoMethodExit = -9,
95 kPseudoBarrier = -8,
buzbeecbd6d442012-11-17 14:11:25 -080096 kPseudoEntryBlock = -7,
97 kPseudoExitBlock = -6,
98 kPseudoTargetLabel = -5,
99 kPseudoDalvikByteCodeBoundary = -4,
100 kPseudoPseudoAlign4 = -3,
101 kPseudoEHBlockLabel = -2,
102 kPseudoNormalBlockLabel = -1,
103};
104
105enum ExtendedMIROpcode {
106 kMirOpFirst = kNumPackedOpcodes,
107 kMirOpPhi = kMirOpFirst,
108 kMirOpCopy,
109 kMirOpFusedCmplFloat,
110 kMirOpFusedCmpgFloat,
111 kMirOpFusedCmplDouble,
112 kMirOpFusedCmpgDouble,
113 kMirOpFusedCmpLong,
114 kMirOpNop,
115 kMirOpNullCheck,
116 kMirOpRangeCheck,
117 kMirOpDivZeroCheck,
118 kMirOpCheck,
buzbeea169e1d2012-12-05 14:26:44 -0800119 kMirOpCheckPart2,
buzbeef662a7c2013-02-12 16:19:43 -0800120 kMirOpSelect,
Mark Mendelld65c51a2014-04-29 16:55:20 -0400121
122 // Vector opcodes:
123 // TypeSize is an encoded field giving the element type and the vector size.
124 // It is encoded as OpSize << 16 | (number of bits in vector)
125 //
126 // Destination and source are integers that will be interpreted by the
127 // backend that supports Vector operations. Backends are permitted to support only
128 // certain vector register sizes.
129 //
130 // At this point, only two operand instructions are supported. Three operand instructions
131 // could be supported by using a bit in TypeSize and arg[0] where needed.
132
133 // @brief MIR to move constant data to a vector register
134 // vA: number of bits in register
135 // vB: destination
136 // args[0]~args[3]: up to 128 bits of data for initialization
137 kMirOpConstVector,
138
139 // @brief MIR to move a vectorized register to another
140 // vA: TypeSize
141 // vB: destination
142 // vC: source
143 kMirOpMoveVector,
144
145 // @brief Packed multiply of units in two vector registers: vB = vB .* vC using vA to know the type of the vector.
146 // vA: TypeSize
147 // vB: destination and source
148 // vC: source
149 kMirOpPackedMultiply,
150
151 // @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the type of the vector.
152 // vA: TypeSize
153 // vB: destination and source
154 // vC: source
155 kMirOpPackedAddition,
156
157 // @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the type of the vector.
158 // vA: TypeSize
159 // vB: destination and source
160 // vC: source
161 kMirOpPackedSubtract,
162
163 // @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the type of the vector.
164 // vA: TypeSize
165 // vB: destination and source
166 // vC: immediate
167 kMirOpPackedShiftLeft,
168
169 // @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to know the type of the vector.
170 // vA: TypeSize
171 // vB: destination and source
172 // vC: immediate
173 kMirOpPackedSignedShiftRight,
174
175 // @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA to know the type of the vector.
176 // vA: TypeSize
177 // vB: destination and source
178 // vC: immediate
179 kMirOpPackedUnsignedShiftRight,
180
181 // @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the type of the vector.
182 // vA: TypeSize
183 // vB: destination and source
184 // vC: source
185 kMirOpPackedAnd,
186
187 // @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the type of the vector.
188 // vA: TypeSize
189 // vB: destination and source
190 // vC: source
191 kMirOpPackedOr,
192
193 // @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the type of the vector.
194 // vA: TypeSize
195 // vB: destination and source
196 // vC: source
197 kMirOpPackedXor,
198
199 // @brief Reduce a 128-bit packed element into a single VR by taking lower bits
200 // @details Instruction does a horizontal addition of the packed elements and then adds it to VR
201 // vA: TypeSize
202 // vB: destination and source VR (not vector register)
203 // vC: source (vector register)
204 kMirOpPackedAddReduce,
205
206 // @brief Extract a packed element into a single VR.
207 // vA: TypeSize
208 // vB: destination VR (not vector register)
209 // vC: source (vector register)
210 // arg[0]: The index to use for extraction from vector register (which packed element)
211 kMirOpPackedReduce,
212
213 // @brief Create a vector value, with all TypeSize values equal to vC
214 // vA: TypeSize
215 // vB: destination vector register
216 // vC: source VR (not vector register)
217 kMirOpPackedSet,
218
buzbeecbd6d442012-11-17 14:11:25 -0800219 kMirOpLast,
220};
221
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700222enum MIROptimizationFlagPositions {
buzbeecbd6d442012-11-17 14:11:25 -0800223 kMIRIgnoreNullCheck = 0,
224 kMIRNullCheckOnly,
225 kMIRIgnoreRangeCheck,
226 kMIRRangeCheckOnly,
Vladimir Markobfea9c22014-01-17 17:49:33 +0000227 kMIRIgnoreClInitCheck,
buzbee02031b12012-11-23 09:41:35 -0800228 kMIRInlined, // Invoke is inlined (ie dead).
229 kMIRInlinedPred, // Invoke is inlined via prediction.
230 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800231 kMIRIgnoreSuspendCheck,
232 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800233 kMIRMark, // Temporary node mark.
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700234 kMIRLastMIRFlag,
buzbeecbd6d442012-11-17 14:11:25 -0800235};
236
buzbee02031b12012-11-23 09:41:35 -0800237// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800238enum BlockListType {
239 kNotUsed = 0,
240 kCatch,
241 kPackedSwitch,
242 kSparseSwitch,
243};
244
245enum AssemblerStatus {
246 kSuccess,
247 kRetryAll,
248};
249
250enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700251 kWord, // Natural word size of target (32/64).
252 k32,
253 k64,
254 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800255 kSingle,
256 kDouble,
257 kUnsignedHalf,
258 kSignedHalf,
259 kUnsignedByte,
260 kSignedByte,
261};
262
263std::ostream& operator<<(std::ostream& os, const OpSize& kind);
264
265enum OpKind {
266 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800267 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800268 kOpMvn,
269 kOpCmp,
270 kOpLsl,
271 kOpLsr,
272 kOpAsr,
273 kOpRor,
274 kOpNot,
275 kOpAnd,
276 kOpOr,
277 kOpXor,
278 kOpNeg,
279 kOpAdd,
280 kOpAdc,
281 kOpSub,
282 kOpSbc,
283 kOpRsub,
284 kOpMul,
285 kOpDiv,
286 kOpRem,
287 kOpBic,
288 kOpCmn,
289 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100290 kOpRev,
291 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800292 kOpBkpt,
293 kOpBlx,
294 kOpPush,
295 kOpPop,
296 kOp2Char,
297 kOp2Short,
298 kOp2Byte,
299 kOpCondBr,
300 kOpUncondBr,
301 kOpBx,
302 kOpInvalid,
303};
304
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800305enum MoveType {
306 kMov8GP, // Move 8-bit general purpose register.
307 kMov16GP, // Move 16-bit general purpose register.
308 kMov32GP, // Move 32-bit general purpose register.
309 kMov64GP, // Move 64-bit general purpose register.
310 kMov32FP, // Move 32-bit FP register.
311 kMov64FP, // Move 64-bit FP register.
312 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
313 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
314 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
315 kMov128FP = kMovU128FP,
316 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
317 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
318 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
319};
320
buzbeecbd6d442012-11-17 14:11:25 -0800321std::ostream& operator<<(std::ostream& os, const OpKind& kind);
322
323enum ConditionCode {
324 kCondEq, // equal
325 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000326 kCondCs, // carry set
327 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000328 kCondUlt, // unsigned less than
329 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800330 kCondMi, // minus
331 kCondPl, // plus, positive or zero
332 kCondVs, // overflow
333 kCondVc, // no overflow
334 kCondHi, // unsigned greater than
335 kCondLs, // unsigned lower or same
336 kCondGe, // signed greater than or equal
337 kCondLt, // signed less than
338 kCondGt, // signed greater than
339 kCondLe, // signed less than or equal
340 kCondAl, // always
341 kCondNv, // never
342};
343
344std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
345
346// Target specific condition encodings
347enum ArmConditionCode {
348 kArmCondEq = 0x0, // 0000
349 kArmCondNe = 0x1, // 0001
350 kArmCondCs = 0x2, // 0010
351 kArmCondCc = 0x3, // 0011
352 kArmCondMi = 0x4, // 0100
353 kArmCondPl = 0x5, // 0101
354 kArmCondVs = 0x6, // 0110
355 kArmCondVc = 0x7, // 0111
356 kArmCondHi = 0x8, // 1000
357 kArmCondLs = 0x9, // 1001
358 kArmCondGe = 0xa, // 1010
359 kArmCondLt = 0xb, // 1011
360 kArmCondGt = 0xc, // 1100
361 kArmCondLe = 0xd, // 1101
362 kArmCondAl = 0xe, // 1110
363 kArmCondNv = 0xf, // 1111
364};
365
366std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
367
368enum X86ConditionCode {
369 kX86CondO = 0x0, // overflow
370 kX86CondNo = 0x1, // not overflow
371
372 kX86CondB = 0x2, // below
373 kX86CondNae = kX86CondB, // not-above-equal
374 kX86CondC = kX86CondB, // carry
375
376 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700377 kX86CondAe = kX86CondNb, // above-equal
378 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800379
380 kX86CondZ = 0x4, // zero
381 kX86CondEq = kX86CondZ, // equal
382
383 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700384 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800385
386 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700387 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800388
389 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700390 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800391
392 kX86CondS = 0x8, // sign
393 kX86CondNs = 0x9, // not-sign
394
395 kX86CondP = 0xa, // 8-bit parity even
396 kX86CondPE = kX86CondP,
397
398 kX86CondNp = 0xb, // 8-bit parity odd
399 kX86CondPo = kX86CondNp,
400
401 kX86CondL = 0xc, // less-than
402 kX86CondNge = kX86CondL, // not-greater-equal
403
404 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700405 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800406
407 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700408 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800409
410 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700411 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800412};
413
414std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
415
416enum ThrowKind {
buzbeecbd6d442012-11-17 14:11:25 -0800417 kThrowNoSuchMethod,
buzbeecbd6d442012-11-17 14:11:25 -0800418};
419
buzbeecbd6d442012-11-17 14:11:25 -0800420enum DividePattern {
421 DivideNone,
422 Divide3,
423 Divide5,
424 Divide7,
425};
426
427std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
428
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800429/**
430 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
431 * @details Without context sensitive analysis, the most conservative set of barriers
432 * must be issued to ensure the Java Memory Model. Thus the recipe is as follows:
433 * -# Use StoreStore barrier before volatile store.
434 * -# Use StoreLoad barrier after volatile store.
435 * -# Use LoadLoad and LoadStore barrier after each volatile load.
436 * -# Use StoreStore barrier after all stores but before return from any constructor whose
437 * class has final fields.
438 */
buzbee1bc37c62012-11-20 13:35:41 -0800439enum MemBarrierKind {
440 kLoadStore,
441 kLoadLoad,
442 kStoreStore,
443 kStoreLoad
444};
445
446std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
447
buzbee02031b12012-11-23 09:41:35 -0800448enum OpFeatureFlags {
449 kIsBranch = 0,
450 kNoOperand,
451 kIsUnaryOp,
452 kIsBinaryOp,
453 kIsTertiaryOp,
454 kIsQuadOp,
455 kIsQuinOp,
456 kIsSextupleOp,
457 kIsIT,
458 kMemLoad,
459 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700460 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800461 kRegDef0,
462 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800463 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800464 kRegDefA,
465 kRegDefD,
466 kRegDefFPCSList0,
467 kRegDefFPCSList2,
468 kRegDefList0,
469 kRegDefList1,
470 kRegDefList2,
471 kRegDefLR,
472 kRegDefSP,
473 kRegUse0,
474 kRegUse1,
475 kRegUse2,
476 kRegUse3,
477 kRegUse4,
478 kRegUseA,
479 kRegUseC,
480 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000481 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800482 kRegUseFPCSList0,
483 kRegUseFPCSList2,
484 kRegUseList0,
485 kRegUseList1,
486 kRegUseLR,
487 kRegUsePC,
488 kRegUseSP,
489 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700490 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700491 kUseFpStack,
492 kUseHi,
493 kUseLo,
494 kDefHi,
495 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800496};
497
buzbeef662a7c2013-02-12 16:19:43 -0800498enum SelectInstructionKind {
499 kSelectNone,
500 kSelectConst,
501 kSelectMove,
502 kSelectGoto
503};
504
buzbeea5abf702013-04-12 14:39:29 -0700505std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
506
buzbeeb48819d2013-09-14 16:15:25 -0700507// LIR fixup kinds for Arm
508enum FixupKind {
509 kFixupNone,
510 kFixupLabel, // For labels we just adjust the offset.
Vladimir Marko306f0172014-01-07 18:21:20 +0000511 kFixupLoad, // Mostly for immediates.
buzbeeb48819d2013-09-14 16:15:25 -0700512 kFixupVLoad, // FP load which *may* be pc-relative.
513 kFixupCBxZ, // Cbz, Cbnz.
514 kFixupPushPop, // Not really pc relative, but changes size based on args.
515 kFixupCondBranch, // Conditional branch
516 kFixupT1Branch, // Thumb1 Unconditional branch
517 kFixupT2Branch, // Thumb2 Unconditional branch
518 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
519 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
520 kFixupAdr, // Adr.
521 kFixupMovImmLST, // kThumb2MovImm16LST.
522 kFixupMovImmHST, // kThumb2MovImm16HST.
523 kFixupAlign4, // Align to 4-byte boundary.
524};
525
526std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
527
buzbeecbd6d442012-11-17 14:11:25 -0800528} // namespace art
529
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700530#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_