blob: de9ac4bd018bbca61f76873a7b7c08da403546ee [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,
buzbee33ae5582014-06-12 14:56:32 -070053 kArg6,
54 kArg7,
buzbeecbd6d442012-11-17 14:11:25 -080055 kFArg0,
56 kFArg1,
57 kFArg2,
58 kFArg3,
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070059 kFArg4,
60 kFArg5,
61 kFArg6,
62 kFArg7,
buzbeecbd6d442012-11-17 14:11:25 -080063 kRet0,
64 kRet1,
65 kInvokeTgt,
Jeff Hao88474b42013-10-23 16:24:40 -070066 kHiddenArg,
67 kHiddenFpArg,
buzbeecbd6d442012-11-17 14:11:25 -080068 kCount
69};
70
71enum RegLocationType {
Brian Carlstrom7934ac22013-07-26 10:54:15 -070072 kLocDalvikFrame = 0, // Normal Dalvik register
buzbeecbd6d442012-11-17 14:11:25 -080073 kLocPhysReg,
74 kLocCompilerTemp,
75 kLocInvalid
76};
77
78enum BBType {
buzbee0d829482013-10-11 15:24:55 -070079 kNullBlock,
buzbeecbd6d442012-11-17 14:11:25 -080080 kEntryBlock,
81 kDalvikByteCode,
82 kExitBlock,
83 kExceptionHandling,
84 kDead,
85};
86
buzbee02031b12012-11-23 09:41:35 -080087// Shared pseudo opcodes - must be < 0.
buzbeecbd6d442012-11-17 14:11:25 -080088enum LIRPseudoOpcode {
buzbeea169e1d2012-12-05 14:26:44 -080089 kPseudoExportedPC = -16,
90 kPseudoSafepointPC = -15,
91 kPseudoIntrinsicRetry = -14,
92 kPseudoSuspendTarget = -13,
93 kPseudoThrowTarget = -12,
94 kPseudoCaseLabel = -11,
95 kPseudoMethodEntry = -10,
96 kPseudoMethodExit = -9,
97 kPseudoBarrier = -8,
buzbeecbd6d442012-11-17 14:11:25 -080098 kPseudoEntryBlock = -7,
99 kPseudoExitBlock = -6,
100 kPseudoTargetLabel = -5,
101 kPseudoDalvikByteCodeBoundary = -4,
102 kPseudoPseudoAlign4 = -3,
103 kPseudoEHBlockLabel = -2,
104 kPseudoNormalBlockLabel = -1,
105};
106
107enum ExtendedMIROpcode {
108 kMirOpFirst = kNumPackedOpcodes,
109 kMirOpPhi = kMirOpFirst,
110 kMirOpCopy,
111 kMirOpFusedCmplFloat,
112 kMirOpFusedCmpgFloat,
113 kMirOpFusedCmplDouble,
114 kMirOpFusedCmpgDouble,
115 kMirOpFusedCmpLong,
116 kMirOpNop,
117 kMirOpNullCheck,
118 kMirOpRangeCheck,
119 kMirOpDivZeroCheck,
120 kMirOpCheck,
buzbeea169e1d2012-12-05 14:26:44 -0800121 kMirOpCheckPart2,
buzbeef662a7c2013-02-12 16:19:43 -0800122 kMirOpSelect,
Mark Mendelld65c51a2014-04-29 16:55:20 -0400123
124 // Vector opcodes:
125 // TypeSize is an encoded field giving the element type and the vector size.
126 // It is encoded as OpSize << 16 | (number of bits in vector)
127 //
128 // Destination and source are integers that will be interpreted by the
129 // backend that supports Vector operations. Backends are permitted to support only
130 // certain vector register sizes.
131 //
132 // At this point, only two operand instructions are supported. Three operand instructions
133 // could be supported by using a bit in TypeSize and arg[0] where needed.
134
135 // @brief MIR to move constant data to a vector register
136 // vA: number of bits in register
137 // vB: destination
138 // args[0]~args[3]: up to 128 bits of data for initialization
139 kMirOpConstVector,
140
141 // @brief MIR to move a vectorized register to another
142 // vA: TypeSize
143 // vB: destination
144 // vC: source
145 kMirOpMoveVector,
146
147 // @brief Packed multiply of units in two vector registers: vB = vB .* vC using vA to know the type of the vector.
148 // vA: TypeSize
149 // vB: destination and source
150 // vC: source
151 kMirOpPackedMultiply,
152
153 // @brief Packed addition 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 kMirOpPackedAddition,
158
159 // @brief Packed subtraction 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 kMirOpPackedSubtract,
164
165 // @brief Packed shift left 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: immediate
169 kMirOpPackedShiftLeft,
170
171 // @brief Packed signed shift right 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 kMirOpPackedSignedShiftRight,
176
177 // @brief Packed unsigned 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 kMirOpPackedUnsignedShiftRight,
182
183 // @brief Packed bitwise and 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: source
187 kMirOpPackedAnd,
188
189 // @brief Packed bitwise or 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 kMirOpPackedOr,
194
195 // @brief Packed bitwise xor 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 kMirOpPackedXor,
200
201 // @brief Reduce a 128-bit packed element into a single VR by taking lower bits
202 // @details Instruction does a horizontal addition of the packed elements and then adds it to VR
203 // vA: TypeSize
204 // vB: destination and source VR (not vector register)
205 // vC: source (vector register)
206 kMirOpPackedAddReduce,
207
208 // @brief Extract a packed element into a single VR.
209 // vA: TypeSize
210 // vB: destination VR (not vector register)
211 // vC: source (vector register)
212 // arg[0]: The index to use for extraction from vector register (which packed element)
213 kMirOpPackedReduce,
214
215 // @brief Create a vector value, with all TypeSize values equal to vC
216 // vA: TypeSize
217 // vB: destination vector register
218 // vC: source VR (not vector register)
219 kMirOpPackedSet,
220
buzbeecbd6d442012-11-17 14:11:25 -0800221 kMirOpLast,
222};
223
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700224enum MIROptimizationFlagPositions {
buzbeecbd6d442012-11-17 14:11:25 -0800225 kMIRIgnoreNullCheck = 0,
226 kMIRNullCheckOnly,
227 kMIRIgnoreRangeCheck,
228 kMIRRangeCheckOnly,
Vladimir Markobfea9c22014-01-17 17:49:33 +0000229 kMIRIgnoreClInitCheck,
buzbee02031b12012-11-23 09:41:35 -0800230 kMIRInlined, // Invoke is inlined (ie dead).
231 kMIRInlinedPred, // Invoke is inlined via prediction.
232 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800233 kMIRIgnoreSuspendCheck,
234 kMIRDup,
buzbee02031b12012-11-23 09:41:35 -0800235 kMIRMark, // Temporary node mark.
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700236 kMIRLastMIRFlag,
buzbeecbd6d442012-11-17 14:11:25 -0800237};
238
buzbee02031b12012-11-23 09:41:35 -0800239// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800240enum BlockListType {
241 kNotUsed = 0,
242 kCatch,
243 kPackedSwitch,
244 kSparseSwitch,
245};
246
247enum AssemblerStatus {
248 kSuccess,
249 kRetryAll,
250};
251
252enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700253 kWord, // Natural word size of target (32/64).
254 k32,
255 k64,
256 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800257 kSingle,
258 kDouble,
259 kUnsignedHalf,
260 kSignedHalf,
261 kUnsignedByte,
262 kSignedByte,
263};
264
265std::ostream& operator<<(std::ostream& os, const OpSize& kind);
266
267enum OpKind {
268 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800269 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800270 kOpMvn,
271 kOpCmp,
272 kOpLsl,
273 kOpLsr,
274 kOpAsr,
275 kOpRor,
276 kOpNot,
277 kOpAnd,
278 kOpOr,
279 kOpXor,
280 kOpNeg,
281 kOpAdd,
282 kOpAdc,
283 kOpSub,
284 kOpSbc,
285 kOpRsub,
286 kOpMul,
287 kOpDiv,
288 kOpRem,
289 kOpBic,
290 kOpCmn,
291 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100292 kOpRev,
293 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800294 kOpBkpt,
295 kOpBlx,
296 kOpPush,
297 kOpPop,
298 kOp2Char,
299 kOp2Short,
300 kOp2Byte,
301 kOpCondBr,
302 kOpUncondBr,
303 kOpBx,
304 kOpInvalid,
305};
306
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800307enum MoveType {
308 kMov8GP, // Move 8-bit general purpose register.
309 kMov16GP, // Move 16-bit general purpose register.
310 kMov32GP, // Move 32-bit general purpose register.
311 kMov64GP, // Move 64-bit general purpose register.
312 kMov32FP, // Move 32-bit FP register.
313 kMov64FP, // Move 64-bit FP register.
314 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
315 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
316 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
317 kMov128FP = kMovU128FP,
318 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
319 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
320 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
321};
322
buzbeecbd6d442012-11-17 14:11:25 -0800323std::ostream& operator<<(std::ostream& os, const OpKind& kind);
324
325enum ConditionCode {
326 kCondEq, // equal
327 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000328 kCondCs, // carry set
329 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000330 kCondUlt, // unsigned less than
331 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800332 kCondMi, // minus
333 kCondPl, // plus, positive or zero
334 kCondVs, // overflow
335 kCondVc, // no overflow
336 kCondHi, // unsigned greater than
337 kCondLs, // unsigned lower or same
338 kCondGe, // signed greater than or equal
339 kCondLt, // signed less than
340 kCondGt, // signed greater than
341 kCondLe, // signed less than or equal
342 kCondAl, // always
343 kCondNv, // never
344};
345
346std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
347
348// Target specific condition encodings
349enum ArmConditionCode {
350 kArmCondEq = 0x0, // 0000
351 kArmCondNe = 0x1, // 0001
352 kArmCondCs = 0x2, // 0010
353 kArmCondCc = 0x3, // 0011
354 kArmCondMi = 0x4, // 0100
355 kArmCondPl = 0x5, // 0101
356 kArmCondVs = 0x6, // 0110
357 kArmCondVc = 0x7, // 0111
358 kArmCondHi = 0x8, // 1000
359 kArmCondLs = 0x9, // 1001
360 kArmCondGe = 0xa, // 1010
361 kArmCondLt = 0xb, // 1011
362 kArmCondGt = 0xc, // 1100
363 kArmCondLe = 0xd, // 1101
364 kArmCondAl = 0xe, // 1110
365 kArmCondNv = 0xf, // 1111
366};
367
368std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
369
370enum X86ConditionCode {
371 kX86CondO = 0x0, // overflow
372 kX86CondNo = 0x1, // not overflow
373
374 kX86CondB = 0x2, // below
375 kX86CondNae = kX86CondB, // not-above-equal
376 kX86CondC = kX86CondB, // carry
377
378 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700379 kX86CondAe = kX86CondNb, // above-equal
380 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800381
382 kX86CondZ = 0x4, // zero
383 kX86CondEq = kX86CondZ, // equal
384
385 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700386 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800387
388 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700389 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800390
391 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700392 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800393
394 kX86CondS = 0x8, // sign
395 kX86CondNs = 0x9, // not-sign
396
397 kX86CondP = 0xa, // 8-bit parity even
398 kX86CondPE = kX86CondP,
399
400 kX86CondNp = 0xb, // 8-bit parity odd
401 kX86CondPo = kX86CondNp,
402
403 kX86CondL = 0xc, // less-than
404 kX86CondNge = kX86CondL, // not-greater-equal
405
406 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700407 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800408
409 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700410 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800411
412 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700413 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800414};
415
416std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
417
418enum ThrowKind {
buzbeecbd6d442012-11-17 14:11:25 -0800419 kThrowNoSuchMethod,
buzbeecbd6d442012-11-17 14:11:25 -0800420};
421
buzbeecbd6d442012-11-17 14:11:25 -0800422enum DividePattern {
423 DivideNone,
424 Divide3,
425 Divide5,
426 Divide7,
427};
428
429std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
430
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800431/**
432 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
433 * @details Without context sensitive analysis, the most conservative set of barriers
434 * must be issued to ensure the Java Memory Model. Thus the recipe is as follows:
435 * -# Use StoreStore barrier before volatile store.
436 * -# Use StoreLoad barrier after volatile store.
437 * -# Use LoadLoad and LoadStore barrier after each volatile load.
438 * -# Use StoreStore barrier after all stores but before return from any constructor whose
439 * class has final fields.
440 */
buzbee1bc37c62012-11-20 13:35:41 -0800441enum MemBarrierKind {
442 kLoadStore,
443 kLoadLoad,
444 kStoreStore,
445 kStoreLoad
446};
447
448std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
449
buzbee02031b12012-11-23 09:41:35 -0800450enum OpFeatureFlags {
451 kIsBranch = 0,
452 kNoOperand,
453 kIsUnaryOp,
454 kIsBinaryOp,
455 kIsTertiaryOp,
456 kIsQuadOp,
457 kIsQuinOp,
458 kIsSextupleOp,
459 kIsIT,
460 kMemLoad,
461 kMemStore,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700462 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800463 kRegDef0,
464 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800465 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800466 kRegDefA,
467 kRegDefD,
468 kRegDefFPCSList0,
469 kRegDefFPCSList2,
470 kRegDefList0,
471 kRegDefList1,
472 kRegDefList2,
473 kRegDefLR,
474 kRegDefSP,
475 kRegUse0,
476 kRegUse1,
477 kRegUse2,
478 kRegUse3,
479 kRegUse4,
480 kRegUseA,
481 kRegUseC,
482 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000483 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800484 kRegUseFPCSList0,
485 kRegUseFPCSList2,
486 kRegUseList0,
487 kRegUseList1,
488 kRegUseLR,
489 kRegUsePC,
490 kRegUseSP,
491 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700492 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700493 kUseFpStack,
494 kUseHi,
495 kUseLo,
496 kDefHi,
497 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800498};
499
buzbeef662a7c2013-02-12 16:19:43 -0800500enum SelectInstructionKind {
501 kSelectNone,
502 kSelectConst,
503 kSelectMove,
504 kSelectGoto
505};
506
buzbeea5abf702013-04-12 14:39:29 -0700507std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
508
buzbeeb48819d2013-09-14 16:15:25 -0700509// LIR fixup kinds for Arm
510enum FixupKind {
511 kFixupNone,
512 kFixupLabel, // For labels we just adjust the offset.
Vladimir Marko306f0172014-01-07 18:21:20 +0000513 kFixupLoad, // Mostly for immediates.
buzbeeb48819d2013-09-14 16:15:25 -0700514 kFixupVLoad, // FP load which *may* be pc-relative.
515 kFixupCBxZ, // Cbz, Cbnz.
516 kFixupPushPop, // Not really pc relative, but changes size based on args.
517 kFixupCondBranch, // Conditional branch
518 kFixupT1Branch, // Thumb1 Unconditional branch
519 kFixupT2Branch, // Thumb2 Unconditional branch
520 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
521 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
522 kFixupAdr, // Adr.
523 kFixupMovImmLST, // kThumb2MovImm16LST.
524 kFixupMovImmHST, // kThumb2MovImm16HST.
525 kFixupAlign4, // Align to 4-byte boundary.
526};
527
528std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
529
buzbeecbd6d442012-11-17 14:11:25 -0800530} // namespace art
531
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700532#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_