blob: 0acdd422df0b05a1b214e87e526c6e75e3f1dc5b [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};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070031std::ostream& operator<<(std::ostream& os, const RegisterClass& rhs);
buzbeecbd6d442012-11-17 14:11:25 -080032
buzbee091cc402014-03-31 10:14:40 -070033enum BitsUsed {
34 kSize32Bits,
35 kSize64Bits,
36 kSize128Bits,
37 kSize256Bits,
38 kSize512Bits,
39 kSize1024Bits,
40};
Ian Rogersb28c1c02014-11-08 11:21:21 -080041std::ostream& operator<<(std::ostream& os, const BitsUsed& rhs);
buzbee091cc402014-03-31 10:14:40 -070042
buzbeecbd6d442012-11-17 14:11:25 -080043enum SpecialTargetRegister {
buzbee02031b12012-11-23 09:41:35 -080044 kSelf, // Thread pointer.
45 kSuspend, // Used to reduce suspend checks for some targets.
buzbeecbd6d442012-11-17 14:11:25 -080046 kLr,
47 kPc,
48 kSp,
49 kArg0,
50 kArg1,
51 kArg2,
52 kArg3,
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070053 kArg4,
54 kArg5,
buzbee33ae5582014-06-12 14:56:32 -070055 kArg6,
56 kArg7,
buzbeecbd6d442012-11-17 14:11:25 -080057 kFArg0,
58 kFArg1,
59 kFArg2,
60 kFArg3,
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070061 kFArg4,
62 kFArg5,
63 kFArg6,
64 kFArg7,
Zheng Xu5667fdb2014-10-23 18:29:55 +080065 kFArg8,
66 kFArg9,
67 kFArg10,
68 kFArg11,
69 kFArg12,
70 kFArg13,
71 kFArg14,
72 kFArg15,
buzbeecbd6d442012-11-17 14:11:25 -080073 kRet0,
74 kRet1,
75 kInvokeTgt,
Jeff Hao88474b42013-10-23 16:24:40 -070076 kHiddenArg,
77 kHiddenFpArg,
buzbeecbd6d442012-11-17 14:11:25 -080078 kCount
79};
Ian Rogersb28c1c02014-11-08 11:21:21 -080080std::ostream& operator<<(std::ostream& os, const SpecialTargetRegister& code);
buzbeecbd6d442012-11-17 14:11:25 -080081
82enum RegLocationType {
Brian Carlstrom7934ac22013-07-26 10:54:15 -070083 kLocDalvikFrame = 0, // Normal Dalvik register
buzbeecbd6d442012-11-17 14:11:25 -080084 kLocPhysReg,
85 kLocCompilerTemp,
86 kLocInvalid
87};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070088std::ostream& operator<<(std::ostream& os, const RegLocationType& rhs);
buzbeecbd6d442012-11-17 14:11:25 -080089
90enum BBType {
buzbee0d829482013-10-11 15:24:55 -070091 kNullBlock,
buzbeecbd6d442012-11-17 14:11:25 -080092 kEntryBlock,
93 kDalvikByteCode,
94 kExitBlock,
95 kExceptionHandling,
96 kDead,
97};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070098std::ostream& operator<<(std::ostream& os, const BBType& code);
buzbeecbd6d442012-11-17 14:11:25 -080099
buzbee02031b12012-11-23 09:41:35 -0800100// Shared pseudo opcodes - must be < 0.
buzbeecbd6d442012-11-17 14:11:25 -0800101enum LIRPseudoOpcode {
David Srbecky6f715892015-03-30 14:21:42 +0100102 kPseudoPrologueBegin = -18,
103 kPseudoPrologueEnd = -17,
104 kPseudoEpilogueBegin = -16,
105 kPseudoEpilogueEnd = -15,
106 kPseudoExportedPC = -14,
107 kPseudoSafepointPC = -13,
108 kPseudoIntrinsicRetry = -12,
109 kPseudoSuspendTarget = -11,
110 kPseudoThrowTarget = -10,
111 kPseudoCaseLabel = -9,
buzbeea169e1d2012-12-05 14:26:44 -0800112 kPseudoBarrier = -8,
buzbeecbd6d442012-11-17 14:11:25 -0800113 kPseudoEntryBlock = -7,
114 kPseudoExitBlock = -6,
115 kPseudoTargetLabel = -5,
116 kPseudoDalvikByteCodeBoundary = -4,
117 kPseudoPseudoAlign4 = -3,
118 kPseudoEHBlockLabel = -2,
119 kPseudoNormalBlockLabel = -1,
120};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700121std::ostream& operator<<(std::ostream& os, const LIRPseudoOpcode& rhs);
buzbeecbd6d442012-11-17 14:11:25 -0800122
123enum ExtendedMIROpcode {
124 kMirOpFirst = kNumPackedOpcodes,
125 kMirOpPhi = kMirOpFirst,
Razvan A Lupusoru1500e6f2014-08-22 15:39:50 -0700126
127 // @brief Copy from one VR to another.
128 // @details
129 // vA: destination VR
130 // vB: source VR
buzbeecbd6d442012-11-17 14:11:25 -0800131 kMirOpCopy,
Razvan A Lupusoru1500e6f2014-08-22 15:39:50 -0700132
133 // @brief Used to do float comparison with less-than bias.
134 // @details Unlike cmpl-float, this does not store result of comparison in VR.
135 // vA: left-hand side VR for comparison.
136 // vB: right-hand side VR for comparison.
buzbeecbd6d442012-11-17 14:11:25 -0800137 kMirOpFusedCmplFloat,
Razvan A Lupusoru1500e6f2014-08-22 15:39:50 -0700138
139 // @brief Used to do float comparison with greater-than bias.
140 // @details Unlike cmpg-float, this does not store result of comparison in VR.
141 // vA: left-hand side VR for comparison.
142 // vB: right-hand side VR for comparison.
buzbeecbd6d442012-11-17 14:11:25 -0800143 kMirOpFusedCmpgFloat,
Razvan A Lupusoru1500e6f2014-08-22 15:39:50 -0700144
145 // @brief Used to do double comparison with less-than bias.
146 // @details Unlike cmpl-double, this does not store result of comparison in VR.
147 // vA: left-hand side wide VR for comparison.
148 // vB: right-hand side wide VR for comparison.
buzbeecbd6d442012-11-17 14:11:25 -0800149 kMirOpFusedCmplDouble,
Razvan A Lupusoru1500e6f2014-08-22 15:39:50 -0700150
151 // @brief Used to do double comparison with greater-than bias.
152 // @details Unlike cmpl-double, this does not store result of comparison in VR.
153 // vA: left-hand side wide VR for comparison.
154 // vB: right-hand side wide VR for comparison.
buzbeecbd6d442012-11-17 14:11:25 -0800155 kMirOpFusedCmpgDouble,
Razvan A Lupusoru1500e6f2014-08-22 15:39:50 -0700156
157 // @brief Used to do comparison of 64-bit long integers.
158 // @details Unlike cmp-long, this does not store result of comparison in VR.
159 // vA: left-hand side wide VR for comparison.
160 // vB: right-hand side wide VR for comparison.
buzbeecbd6d442012-11-17 14:11:25 -0800161 kMirOpFusedCmpLong,
Razvan A Lupusoru1500e6f2014-08-22 15:39:50 -0700162
163 // @brief This represents no-op.
buzbeecbd6d442012-11-17 14:11:25 -0800164 kMirOpNop,
Razvan A Lupusoru76423242014-08-04 09:38:46 -0700165
166 // @brief Do a null check on the object register.
167 // @details The backends may implement this implicitly or explicitly. This MIR is guaranteed
168 // to have the correct offset as an exception thrower.
169 // vA: object register
buzbeecbd6d442012-11-17 14:11:25 -0800170 kMirOpNullCheck,
Razvan A Lupusoru76423242014-08-04 09:38:46 -0700171
buzbeecbd6d442012-11-17 14:11:25 -0800172 kMirOpRangeCheck,
173 kMirOpDivZeroCheck,
174 kMirOpCheck,
buzbeea169e1d2012-12-05 14:26:44 -0800175 kMirOpCheckPart2,
buzbeef662a7c2013-02-12 16:19:43 -0800176 kMirOpSelect,
Mark Mendelld65c51a2014-04-29 16:55:20 -0400177
178 // Vector opcodes:
179 // TypeSize is an encoded field giving the element type and the vector size.
180 // It is encoded as OpSize << 16 | (number of bits in vector)
181 //
182 // Destination and source are integers that will be interpreted by the
183 // backend that supports Vector operations. Backends are permitted to support only
184 // certain vector register sizes.
185 //
186 // At this point, only two operand instructions are supported. Three operand instructions
187 // could be supported by using a bit in TypeSize and arg[0] where needed.
188
189 // @brief MIR to move constant data to a vector register
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700190 // vA: destination
191 // vB: number of bits in register
Mark Mendelld65c51a2014-04-29 16:55:20 -0400192 // args[0]~args[3]: up to 128 bits of data for initialization
193 kMirOpConstVector,
194
195 // @brief MIR to move a vectorized register to another
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700196 // vA: destination
197 // vB: source
198 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400199 kMirOpMoveVector,
200
201 // @brief Packed multiply of units in two vector registers: vB = vB .* vC using vA to know the type of the vector.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700202 // vA: destination and source
203 // vB: source
204 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400205 kMirOpPackedMultiply,
206
207 // @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the type of the vector.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700208 // vA: destination and source
209 // vB: source
210 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400211 kMirOpPackedAddition,
212
213 // @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the type of the vector.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700214 // vA: destination and source
215 // vB: source
216 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400217 kMirOpPackedSubtract,
218
219 // @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the type of the vector.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700220 // vA: destination and source
221 // vB: amount to shift
222 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400223 kMirOpPackedShiftLeft,
224
225 // @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to know the type of the vector.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700226 // vA: destination and source
227 // vB: amount to shift
228 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400229 kMirOpPackedSignedShiftRight,
230
231 // @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA to know the type of the vector.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700232 // vA: destination and source
233 // vB: amount to shift
234 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400235 kMirOpPackedUnsignedShiftRight,
236
237 // @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the type of the vector.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700238 // vA: destination and source
239 // vB: source
240 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400241 kMirOpPackedAnd,
242
243 // @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the type of the vector.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700244 // vA: destination and source
245 // vB: source
246 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400247 kMirOpPackedOr,
248
249 // @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the type of the vector.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700250 // vA: destination and source
251 // vB: source
252 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400253 kMirOpPackedXor,
254
255 // @brief Reduce a 128-bit packed element into a single VR by taking lower bits
256 // @details Instruction does a horizontal addition of the packed elements and then adds it to VR
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700257 // vA: destination and source VR (not vector register)
258 // vB: source (vector register)
259 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400260 kMirOpPackedAddReduce,
261
262 // @brief Extract a packed element into a single VR.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700263 // vA: destination VR (not vector register)
264 // vB: source (vector register)
265 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400266 // arg[0]: The index to use for extraction from vector register (which packed element)
267 kMirOpPackedReduce,
268
269 // @brief Create a vector value, with all TypeSize values equal to vC
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700270 // vA: destination vector register
271 // vB: source VR (not vector register)
272 // vC: TypeSize
Mark Mendelld65c51a2014-04-29 16:55:20 -0400273 kMirOpPackedSet,
274
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700275 // @brief Reserve a range of vector registers.
276 // vA: Start vector register to reserve.
277 // vB: Inclusive end vector register to reserve.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700278 // @note: The backend may choose to map vector numbers used in vector opcodes.
279 // Reserved registers are removed from the list of backend temporary pool.
280 kMirOpReserveVectorRegisters,
281
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700282 // @brief Free a range of reserved vector registers
283 // vA: Start vector register to unreserve.
284 // vB: Inclusive end vector register to unreserve.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700285 // @note: All currently reserved vector registers are returned to the temporary pool.
286 kMirOpReturnVectorRegisters,
287
Jean Christophe Beylerb5bce7c2014-07-25 12:32:18 -0700288 // @brief Create a memory barrier.
289 // vA: a constant defined by enum MemBarrierKind.
290 kMirOpMemBarrier,
291
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700292 // @brief Used to fill a vector register with array values.
293 // @details Just as with normal arrays, access on null object register must ensure NullPointerException
294 // and invalid index must ensure ArrayIndexOutOfBoundsException. Exception behavior must be the same
295 // as the aget it replaced and must happen at same index. Therefore, it is generally recommended that
296 // before using this MIR, it is proven that exception is guaranteed to not be thrown and marked with
297 // MIR_IGNORE_NULL_CHECK and MIR_IGNORE_RANGE_CHECK.
298 // vA: destination vector register
299 // vB: array register
300 // vC: index register
301 // arg[0]: TypeSize (most other vector opcodes have this in vC)
302 kMirOpPackedArrayGet,
303
304 // @brief Used to store a vector register into array.
305 // @details Just as with normal arrays, access on null object register must ensure NullPointerException
306 // and invalid index must ensure ArrayIndexOutOfBoundsException. Exception behavior must be the same
307 // as the aget it replaced and must happen at same index. Therefore, it is generally recommended that
308 // before using this MIR, it is proven that exception is guaranteed to not be thrown and marked with
309 // MIR_IGNORE_NULL_CHECK and MIR_IGNORE_RANGE_CHECK.
310 // vA: source vector register
311 // vB: array register
312 // vC: index register
313 // arg[0]: TypeSize (most other vector opcodes have this in vC)
314 kMirOpPackedArrayPut,
315
Ningsheng Jiana262f772014-11-25 16:48:07 +0800316 // @brief Multiply-add integer.
317 // vA: destination
318 // vB: multiplicand
319 // vC: multiplier
320 // arg[0]: addend
321 kMirOpMaddInt,
322
323 // @brief Multiply-subtract integer.
324 // vA: destination
325 // vB: multiplicand
326 // vC: multiplier
327 // arg[0]: minuend
328 kMirOpMsubInt,
329
330 // @brief Multiply-add long.
331 // vA: destination
332 // vB: multiplicand
333 // vC: multiplier
334 // arg[0]: addend
335 kMirOpMaddLong,
336
337 // @brief Multiply-subtract long.
338 // vA: destination
339 // vB: multiplicand
340 // vC: multiplier
341 // arg[0]: minuend
342 kMirOpMsubLong,
343
buzbeecbd6d442012-11-17 14:11:25 -0800344 kMirOpLast,
345};
346
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700347enum MIROptimizationFlagPositions {
buzbeecbd6d442012-11-17 14:11:25 -0800348 kMIRIgnoreNullCheck = 0,
buzbeecbd6d442012-11-17 14:11:25 -0800349 kMIRIgnoreRangeCheck,
Vladimir Marko22fe45d2015-03-18 11:33:58 +0000350 kMIRIgnoreCheckCast,
Vladimir Marko743b98c2014-11-24 19:45:41 +0000351 kMIRStoreNonNullValue, // Storing non-null value, always mark GC card.
Vladimir Marko66c6d7b2014-10-16 15:41:48 +0100352 kMIRClassIsInitialized,
353 kMIRClassIsInDexCache,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700354 kMirIgnoreDivZeroCheck,
buzbee02031b12012-11-23 09:41:35 -0800355 kMIRInlined, // Invoke is inlined (ie dead).
356 kMIRInlinedPred, // Invoke is inlined via prediction.
357 kMIRCallee, // Instruction is inlined from callee.
buzbeecbd6d442012-11-17 14:11:25 -0800358 kMIRIgnoreSuspendCheck,
359 kMIRDup,
Yevgeny Rouban423b1372014-10-15 17:32:25 +0700360 kMIRMark, // Temporary node mark can be used by
361 // opt passes for their private needs.
Jean Christophe Beylerb5bce7c2014-07-25 12:32:18 -0700362 kMIRStoreNonTemporal,
Jean Christophe Beyler89fde262014-04-30 11:40:07 -0700363 kMIRLastMIRFlag,
buzbeecbd6d442012-11-17 14:11:25 -0800364};
365
buzbee02031b12012-11-23 09:41:35 -0800366// For successor_block_list.
buzbeecbd6d442012-11-17 14:11:25 -0800367enum BlockListType {
368 kNotUsed = 0,
369 kCatch,
370 kPackedSwitch,
371 kSparseSwitch,
372};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700373std::ostream& operator<<(std::ostream& os, const BlockListType& rhs);
buzbeecbd6d442012-11-17 14:11:25 -0800374
375enum AssemblerStatus {
376 kSuccess,
377 kRetryAll,
378};
Ian Rogersb28c1c02014-11-08 11:21:21 -0800379std::ostream& operator<<(std::ostream& os, const AssemblerStatus& rhs);
buzbeecbd6d442012-11-17 14:11:25 -0800380
381enum OpSize {
buzbee695d13a2014-04-19 13:32:20 -0700382 kWord, // Natural word size of target (32/64).
383 k32,
384 k64,
385 kReference, // Object reference; compressed on 64-bit targets.
buzbeecbd6d442012-11-17 14:11:25 -0800386 kSingle,
387 kDouble,
388 kUnsignedHalf,
389 kSignedHalf,
390 kUnsignedByte,
391 kSignedByte,
392};
buzbeecbd6d442012-11-17 14:11:25 -0800393std::ostream& operator<<(std::ostream& os, const OpSize& kind);
394
395enum OpKind {
396 kOpMov,
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800397 kOpCmov,
buzbeecbd6d442012-11-17 14:11:25 -0800398 kOpMvn,
399 kOpCmp,
400 kOpLsl,
401 kOpLsr,
402 kOpAsr,
403 kOpRor,
404 kOpNot,
405 kOpAnd,
406 kOpOr,
407 kOpXor,
408 kOpNeg,
409 kOpAdd,
410 kOpAdc,
411 kOpSub,
412 kOpSbc,
413 kOpRsub,
414 kOpMul,
415 kOpDiv,
416 kOpRem,
417 kOpBic,
418 kOpCmn,
419 kOpTst,
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100420 kOpRev,
421 kOpRevsh,
buzbeecbd6d442012-11-17 14:11:25 -0800422 kOpBkpt,
423 kOpBlx,
424 kOpPush,
425 kOpPop,
426 kOp2Char,
427 kOp2Short,
428 kOp2Byte,
429 kOpCondBr,
430 kOpUncondBr,
431 kOpBx,
432 kOpInvalid,
433};
Ian Rogersb28c1c02014-11-08 11:21:21 -0800434std::ostream& operator<<(std::ostream& os, const OpKind& rhs);
buzbeecbd6d442012-11-17 14:11:25 -0800435
Razvan A Lupusoru2c498d12014-01-29 16:02:57 -0800436enum MoveType {
437 kMov8GP, // Move 8-bit general purpose register.
438 kMov16GP, // Move 16-bit general purpose register.
439 kMov32GP, // Move 32-bit general purpose register.
440 kMov64GP, // Move 64-bit general purpose register.
441 kMov32FP, // Move 32-bit FP register.
442 kMov64FP, // Move 64-bit FP register.
443 kMovLo64FP, // Move low 32-bits of 64-bit FP register.
444 kMovHi64FP, // Move high 32-bits of 64-bit FP register.
445 kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region.
446 kMov128FP = kMovU128FP,
447 kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes.
448 kMovLo128FP, // Move low 64-bits of 128-bit FP register.
449 kMovHi128FP, // Move high 64-bits of 128-bit FP register.
450};
Ian Rogersb28c1c02014-11-08 11:21:21 -0800451std::ostream& operator<<(std::ostream& os, const MoveType& kind);
buzbeecbd6d442012-11-17 14:11:25 -0800452
453enum ConditionCode {
454 kCondEq, // equal
455 kCondNe, // not equal
Vladimir Marko58af1f92013-12-19 13:31:15 +0000456 kCondCs, // carry set
457 kCondCc, // carry clear
Vladimir Marko459f4df2013-12-20 17:03:09 +0000458 kCondUlt, // unsigned less than
459 kCondUge, // unsigned greater than or same
buzbeecbd6d442012-11-17 14:11:25 -0800460 kCondMi, // minus
461 kCondPl, // plus, positive or zero
462 kCondVs, // overflow
463 kCondVc, // no overflow
464 kCondHi, // unsigned greater than
465 kCondLs, // unsigned lower or same
466 kCondGe, // signed greater than or equal
467 kCondLt, // signed less than
468 kCondGt, // signed greater than
469 kCondLe, // signed less than or equal
470 kCondAl, // always
471 kCondNv, // never
472};
buzbeecbd6d442012-11-17 14:11:25 -0800473std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
474
475// Target specific condition encodings
476enum ArmConditionCode {
477 kArmCondEq = 0x0, // 0000
478 kArmCondNe = 0x1, // 0001
479 kArmCondCs = 0x2, // 0010
480 kArmCondCc = 0x3, // 0011
481 kArmCondMi = 0x4, // 0100
482 kArmCondPl = 0x5, // 0101
483 kArmCondVs = 0x6, // 0110
484 kArmCondVc = 0x7, // 0111
485 kArmCondHi = 0x8, // 1000
486 kArmCondLs = 0x9, // 1001
487 kArmCondGe = 0xa, // 1010
488 kArmCondLt = 0xb, // 1011
489 kArmCondGt = 0xc, // 1100
490 kArmCondLe = 0xd, // 1101
491 kArmCondAl = 0xe, // 1110
492 kArmCondNv = 0xf, // 1111
493};
buzbeecbd6d442012-11-17 14:11:25 -0800494std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
495
496enum X86ConditionCode {
497 kX86CondO = 0x0, // overflow
498 kX86CondNo = 0x1, // not overflow
499
500 kX86CondB = 0x2, // below
501 kX86CondNae = kX86CondB, // not-above-equal
502 kX86CondC = kX86CondB, // carry
503
504 kX86CondNb = 0x3, // not-below
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700505 kX86CondAe = kX86CondNb, // above-equal
506 kX86CondNc = kX86CondNb, // not-carry
buzbeecbd6d442012-11-17 14:11:25 -0800507
508 kX86CondZ = 0x4, // zero
509 kX86CondEq = kX86CondZ, // equal
510
511 kX86CondNz = 0x5, // not-zero
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700512 kX86CondNe = kX86CondNz, // not-equal
buzbeecbd6d442012-11-17 14:11:25 -0800513
514 kX86CondBe = 0x6, // below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700515 kX86CondNa = kX86CondBe, // not-above
buzbeecbd6d442012-11-17 14:11:25 -0800516
517 kX86CondNbe = 0x7, // not-below-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700518 kX86CondA = kX86CondNbe, // above
buzbeecbd6d442012-11-17 14:11:25 -0800519
520 kX86CondS = 0x8, // sign
521 kX86CondNs = 0x9, // not-sign
522
523 kX86CondP = 0xa, // 8-bit parity even
524 kX86CondPE = kX86CondP,
525
526 kX86CondNp = 0xb, // 8-bit parity odd
527 kX86CondPo = kX86CondNp,
528
529 kX86CondL = 0xc, // less-than
530 kX86CondNge = kX86CondL, // not-greater-equal
531
532 kX86CondNl = 0xd, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700533 kX86CondGe = kX86CondNl, // not-greater-equal
buzbeecbd6d442012-11-17 14:11:25 -0800534
535 kX86CondLe = 0xe, // less-than-equal
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700536 kX86CondNg = kX86CondLe, // not-greater
buzbeecbd6d442012-11-17 14:11:25 -0800537
538 kX86CondNle = 0xf, // not-less-than
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700539 kX86CondG = kX86CondNle, // greater
buzbeecbd6d442012-11-17 14:11:25 -0800540};
buzbeecbd6d442012-11-17 14:11:25 -0800541std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
542
buzbeecbd6d442012-11-17 14:11:25 -0800543enum DividePattern {
544 DivideNone,
545 Divide3,
546 Divide5,
547 Divide7,
548};
buzbeecbd6d442012-11-17 14:11:25 -0800549std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
550
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800551/**
552 * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
Hans Boehm48f5c472014-06-27 14:50:10 -0700553 * @details We define the combined barrier types that are actually required
554 * by the Java Memory Model, rather than using exactly the terminology from
555 * the JSR-133 cookbook. These should, in many cases, be replaced by acquire/release
556 * primitives. Note that the JSR-133 cookbook generally does not deal with
557 * store atomicity issues, and the recipes there are not always entirely sufficient.
558 * The current recipe is as follows:
559 * -# Use AnyStore ~= (LoadStore | StoreStore) ~= release barrier before volatile store.
560 * -# Use AnyAny barrier after volatile store. (StoreLoad is as expensive.)
Calin Juravle52c48962014-12-16 17:02:57 +0000561 * -# Use LoadAny barrier ~= (LoadLoad | LoadStore) ~= acquire barrier after each volatile load.
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800562 * -# Use StoreStore barrier after all stores but before return from any constructor whose
Hans Boehm48f5c472014-06-27 14:50:10 -0700563 * class has final fields.
Jean Christophe Beylerb5bce7c2014-07-25 12:32:18 -0700564 * -# Use NTStoreStore to order non-temporal stores with respect to all later
565 * store-to-memory instructions. Only generated together with non-temporal stores.
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800566 */
buzbee1bc37c62012-11-20 13:35:41 -0800567enum MemBarrierKind {
Hans Boehm48f5c472014-06-27 14:50:10 -0700568 kAnyStore,
569 kLoadAny,
buzbee1bc37c62012-11-20 13:35:41 -0800570 kStoreStore,
Jean Christophe Beylerb5bce7c2014-07-25 12:32:18 -0700571 kAnyAny,
572 kNTStoreStore,
buzbee1bc37c62012-11-20 13:35:41 -0800573};
buzbee1bc37c62012-11-20 13:35:41 -0800574std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
575
buzbee02031b12012-11-23 09:41:35 -0800576enum OpFeatureFlags {
577 kIsBranch = 0,
578 kNoOperand,
579 kIsUnaryOp,
580 kIsBinaryOp,
581 kIsTertiaryOp,
582 kIsQuadOp,
583 kIsQuinOp,
584 kIsSextupleOp,
585 kIsIT,
Serban Constantinescu63999682014-07-15 17:44:21 +0100586 kIsMoveOp,
buzbee02031b12012-11-23 09:41:35 -0800587 kMemLoad,
588 kMemStore,
Serban Constantinescu63999682014-07-15 17:44:21 +0100589 kMemVolatile,
590 kMemScaledx0,
591 kMemScaledx2,
592 kMemScaledx4,
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700593 kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
buzbee02031b12012-11-23 09:41:35 -0800594 kRegDef0,
595 kRegDef1,
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800596 kRegDef2,
buzbee02031b12012-11-23 09:41:35 -0800597 kRegDefA,
598 kRegDefD,
599 kRegDefFPCSList0,
600 kRegDefFPCSList2,
601 kRegDefList0,
602 kRegDefList1,
603 kRegDefList2,
604 kRegDefLR,
605 kRegDefSP,
606 kRegUse0,
607 kRegUse1,
608 kRegUse2,
609 kRegUse3,
610 kRegUse4,
611 kRegUseA,
612 kRegUseC,
613 kRegUseD,
Vladimir Marko70b797d2013-12-03 15:25:24 +0000614 kRegUseB,
buzbee02031b12012-11-23 09:41:35 -0800615 kRegUseFPCSList0,
616 kRegUseFPCSList2,
617 kRegUseList0,
618 kRegUseList1,
619 kRegUseLR,
620 kRegUsePC,
621 kRegUseSP,
622 kSetsCCodes,
Serguei Katkove90501d2014-03-12 15:56:54 +0700623 kUsesCCodes,
buzbee9da5c102014-03-28 12:59:18 -0700624 kUseFpStack,
625 kUseHi,
626 kUseLo,
627 kDefHi,
628 kDefLo
buzbee02031b12012-11-23 09:41:35 -0800629};
Ian Rogersb28c1c02014-11-08 11:21:21 -0800630std::ostream& operator<<(std::ostream& os, const OpFeatureFlags& rhs);
buzbee02031b12012-11-23 09:41:35 -0800631
buzbeef662a7c2013-02-12 16:19:43 -0800632enum SelectInstructionKind {
633 kSelectNone,
634 kSelectConst,
635 kSelectMove,
636 kSelectGoto
637};
buzbeea5abf702013-04-12 14:39:29 -0700638std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
639
Mark Mendell27dee8b2014-12-01 19:06:12 -0500640// LIR fixup kinds for Arm and X86.
buzbeeb48819d2013-09-14 16:15:25 -0700641enum FixupKind {
642 kFixupNone,
Matteo Franchin65420b22014-10-27 13:29:30 +0000643 kFixupLabel, // For labels we just adjust the offset.
644 kFixupLoad, // Mostly for immediates.
645 kFixupVLoad, // FP load which *may* be pc-relative.
646 kFixupCBxZ, // Cbz, Cbnz.
647 kFixupTBxZ, // Tbz, Tbnz.
Matteo Franchin65420b22014-10-27 13:29:30 +0000648 kFixupCondBranch, // Conditional branch
649 kFixupT1Branch, // Thumb1 Unconditional branch
650 kFixupT2Branch, // Thumb2 Unconditional branch
651 kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair).
652 kFixupBl1, // Bl1 (start of Bl1/Bl2 pair).
653 kFixupAdr, // Adr.
654 kFixupMovImmLST, // kThumb2MovImm16LST.
655 kFixupMovImmHST, // kThumb2MovImm16HST.
656 kFixupAlign4, // Align to 4-byte boundary.
657 kFixupA53Erratum835769, // Cortex A53 Erratum 835769.
Mark Mendell27dee8b2014-12-01 19:06:12 -0500658 kFixupSwitchTable, // X86_64 packed switch table.
buzbeeb48819d2013-09-14 16:15:25 -0700659};
buzbeeb48819d2013-09-14 16:15:25 -0700660std::ostream& operator<<(std::ostream& os, const FixupKind& kind);
661
Andreas Gampe3c12c512014-06-24 18:46:29 +0000662enum VolatileKind {
663 kNotVolatile, // Load/Store is not volatile
664 kVolatile // Load/Store is volatile
665};
Andreas Gampe3c12c512014-06-24 18:46:29 +0000666std::ostream& operator<<(std::ostream& os, const VolatileKind& kind);
667
Andreas Gampeccc60262014-07-04 18:02:38 -0700668enum WideKind {
669 kNotWide, // Non-wide view
670 kWide, // Wide view
671 kRef // Ref width
672};
Andreas Gampeccc60262014-07-04 18:02:38 -0700673std::ostream& operator<<(std::ostream& os, const WideKind& kind);
674
buzbeecbd6d442012-11-17 14:11:25 -0800675} // namespace art
676
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700677#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_