buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 1 | /* |
| 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 Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_DEX_COMPILER_ENUMS_H_ |
| 18 | #define ART_COMPILER_DEX_COMPILER_ENUMS_H_ |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 19 | |
| 20 | #include "dex_instruction.h" |
| 21 | |
| 22 | namespace art { |
| 23 | |
| 24 | enum RegisterClass { |
Serban Constantinescu | 032d377 | 2014-05-23 17:38:18 +0100 | [diff] [blame] | 25 | kInvalidRegClass, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 26 | kCoreReg, |
| 27 | kFPReg, |
buzbee | a0cd2d7 | 2014-06-01 09:33:49 -0700 | [diff] [blame] | 28 | kRefReg, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 29 | kAnyReg, |
| 30 | }; |
| 31 | |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 32 | enum BitsUsed { |
| 33 | kSize32Bits, |
| 34 | kSize64Bits, |
| 35 | kSize128Bits, |
| 36 | kSize256Bits, |
| 37 | kSize512Bits, |
| 38 | kSize1024Bits, |
| 39 | }; |
| 40 | |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 41 | enum SpecialTargetRegister { |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 42 | kSelf, // Thread pointer. |
| 43 | kSuspend, // Used to reduce suspend checks for some targets. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 44 | kLr, |
| 45 | kPc, |
| 46 | kSp, |
| 47 | kArg0, |
| 48 | kArg1, |
| 49 | kArg2, |
| 50 | kArg3, |
Dmitry Petrochenko | 58994cd | 2014-05-17 01:02:18 +0700 | [diff] [blame] | 51 | kArg4, |
| 52 | kArg5, |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 53 | kArg6, |
| 54 | kArg7, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 55 | kFArg0, |
| 56 | kFArg1, |
| 57 | kFArg2, |
| 58 | kFArg3, |
Dmitry Petrochenko | 58994cd | 2014-05-17 01:02:18 +0700 | [diff] [blame] | 59 | kFArg4, |
| 60 | kFArg5, |
| 61 | kFArg6, |
| 62 | kFArg7, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 63 | kRet0, |
| 64 | kRet1, |
| 65 | kInvokeTgt, |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 66 | kHiddenArg, |
| 67 | kHiddenFpArg, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 68 | kCount |
| 69 | }; |
| 70 | |
| 71 | enum RegLocationType { |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 72 | kLocDalvikFrame = 0, // Normal Dalvik register |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 73 | kLocPhysReg, |
| 74 | kLocCompilerTemp, |
| 75 | kLocInvalid |
| 76 | }; |
| 77 | |
| 78 | enum BBType { |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 79 | kNullBlock, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 80 | kEntryBlock, |
| 81 | kDalvikByteCode, |
| 82 | kExitBlock, |
| 83 | kExceptionHandling, |
| 84 | kDead, |
| 85 | }; |
| 86 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 87 | // Shared pseudo opcodes - must be < 0. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 88 | enum LIRPseudoOpcode { |
buzbee | a169e1d | 2012-12-05 14:26:44 -0800 | [diff] [blame] | 89 | 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, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 98 | kPseudoEntryBlock = -7, |
| 99 | kPseudoExitBlock = -6, |
| 100 | kPseudoTargetLabel = -5, |
| 101 | kPseudoDalvikByteCodeBoundary = -4, |
| 102 | kPseudoPseudoAlign4 = -3, |
| 103 | kPseudoEHBlockLabel = -2, |
| 104 | kPseudoNormalBlockLabel = -1, |
| 105 | }; |
| 106 | |
| 107 | enum ExtendedMIROpcode { |
| 108 | kMirOpFirst = kNumPackedOpcodes, |
| 109 | kMirOpPhi = kMirOpFirst, |
Razvan A Lupusoru | 1500e6f | 2014-08-22 15:39:50 -0700 | [diff] [blame] | 110 | |
| 111 | // @brief Copy from one VR to another. |
| 112 | // @details |
| 113 | // vA: destination VR |
| 114 | // vB: source VR |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 115 | kMirOpCopy, |
Razvan A Lupusoru | 1500e6f | 2014-08-22 15:39:50 -0700 | [diff] [blame] | 116 | |
| 117 | // @brief Used to do float comparison with less-than bias. |
| 118 | // @details Unlike cmpl-float, this does not store result of comparison in VR. |
| 119 | // vA: left-hand side VR for comparison. |
| 120 | // vB: right-hand side VR for comparison. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 121 | kMirOpFusedCmplFloat, |
Razvan A Lupusoru | 1500e6f | 2014-08-22 15:39:50 -0700 | [diff] [blame] | 122 | |
| 123 | // @brief Used to do float comparison with greater-than bias. |
| 124 | // @details Unlike cmpg-float, this does not store result of comparison in VR. |
| 125 | // vA: left-hand side VR for comparison. |
| 126 | // vB: right-hand side VR for comparison. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 127 | kMirOpFusedCmpgFloat, |
Razvan A Lupusoru | 1500e6f | 2014-08-22 15:39:50 -0700 | [diff] [blame] | 128 | |
| 129 | // @brief Used to do double comparison with less-than bias. |
| 130 | // @details Unlike cmpl-double, this does not store result of comparison in VR. |
| 131 | // vA: left-hand side wide VR for comparison. |
| 132 | // vB: right-hand side wide VR for comparison. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 133 | kMirOpFusedCmplDouble, |
Razvan A Lupusoru | 1500e6f | 2014-08-22 15:39:50 -0700 | [diff] [blame] | 134 | |
| 135 | // @brief Used to do double comparison with greater-than bias. |
| 136 | // @details Unlike cmpl-double, this does not store result of comparison in VR. |
| 137 | // vA: left-hand side wide VR for comparison. |
| 138 | // vB: right-hand side wide VR for comparison. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 139 | kMirOpFusedCmpgDouble, |
Razvan A Lupusoru | 1500e6f | 2014-08-22 15:39:50 -0700 | [diff] [blame] | 140 | |
| 141 | // @brief Used to do comparison of 64-bit long integers. |
| 142 | // @details Unlike cmp-long, this does not store result of comparison in VR. |
| 143 | // vA: left-hand side wide VR for comparison. |
| 144 | // vB: right-hand side wide VR for comparison. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 145 | kMirOpFusedCmpLong, |
Razvan A Lupusoru | 1500e6f | 2014-08-22 15:39:50 -0700 | [diff] [blame] | 146 | |
| 147 | // @brief This represents no-op. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 148 | kMirOpNop, |
Razvan A Lupusoru | 7642324 | 2014-08-04 09:38:46 -0700 | [diff] [blame] | 149 | |
| 150 | // @brief Do a null check on the object register. |
| 151 | // @details The backends may implement this implicitly or explicitly. This MIR is guaranteed |
| 152 | // to have the correct offset as an exception thrower. |
| 153 | // vA: object register |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 154 | kMirOpNullCheck, |
Razvan A Lupusoru | 7642324 | 2014-08-04 09:38:46 -0700 | [diff] [blame] | 155 | |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 156 | kMirOpRangeCheck, |
| 157 | kMirOpDivZeroCheck, |
| 158 | kMirOpCheck, |
buzbee | a169e1d | 2012-12-05 14:26:44 -0800 | [diff] [blame] | 159 | kMirOpCheckPart2, |
buzbee | f662a7c | 2013-02-12 16:19:43 -0800 | [diff] [blame] | 160 | kMirOpSelect, |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 161 | |
| 162 | // Vector opcodes: |
| 163 | // TypeSize is an encoded field giving the element type and the vector size. |
| 164 | // It is encoded as OpSize << 16 | (number of bits in vector) |
| 165 | // |
| 166 | // Destination and source are integers that will be interpreted by the |
| 167 | // backend that supports Vector operations. Backends are permitted to support only |
| 168 | // certain vector register sizes. |
| 169 | // |
| 170 | // At this point, only two operand instructions are supported. Three operand instructions |
| 171 | // could be supported by using a bit in TypeSize and arg[0] where needed. |
| 172 | |
| 173 | // @brief MIR to move constant data to a vector register |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 174 | // vA: destination |
| 175 | // vB: number of bits in register |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 176 | // args[0]~args[3]: up to 128 bits of data for initialization |
| 177 | kMirOpConstVector, |
| 178 | |
| 179 | // @brief MIR to move a vectorized register to another |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 180 | // vA: destination |
| 181 | // vB: source |
| 182 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 183 | kMirOpMoveVector, |
| 184 | |
| 185 | // @brief Packed multiply of units in two vector registers: vB = vB .* vC using vA to know the type of the vector. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 186 | // vA: destination and source |
| 187 | // vB: source |
| 188 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 189 | kMirOpPackedMultiply, |
| 190 | |
| 191 | // @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the type of the vector. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 192 | // vA: destination and source |
| 193 | // vB: source |
| 194 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 195 | kMirOpPackedAddition, |
| 196 | |
| 197 | // @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the type of the vector. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 198 | // vA: destination and source |
| 199 | // vB: source |
| 200 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 201 | kMirOpPackedSubtract, |
| 202 | |
| 203 | // @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the type of the vector. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 204 | // vA: destination and source |
| 205 | // vB: amount to shift |
| 206 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 207 | kMirOpPackedShiftLeft, |
| 208 | |
| 209 | // @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to know the type of the vector. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 210 | // vA: destination and source |
| 211 | // vB: amount to shift |
| 212 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 213 | kMirOpPackedSignedShiftRight, |
| 214 | |
| 215 | // @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA to know the type of the vector. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 216 | // vA: destination and source |
| 217 | // vB: amount to shift |
| 218 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 219 | kMirOpPackedUnsignedShiftRight, |
| 220 | |
| 221 | // @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the type of the vector. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 222 | // vA: destination and source |
| 223 | // vB: source |
| 224 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 225 | kMirOpPackedAnd, |
| 226 | |
| 227 | // @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the type of the vector. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 228 | // vA: destination and source |
| 229 | // vB: source |
| 230 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 231 | kMirOpPackedOr, |
| 232 | |
| 233 | // @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the type of the vector. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 234 | // vA: destination and source |
| 235 | // vB: source |
| 236 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 237 | kMirOpPackedXor, |
| 238 | |
| 239 | // @brief Reduce a 128-bit packed element into a single VR by taking lower bits |
| 240 | // @details Instruction does a horizontal addition of the packed elements and then adds it to VR |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 241 | // vA: destination and source VR (not vector register) |
| 242 | // vB: source (vector register) |
| 243 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 244 | kMirOpPackedAddReduce, |
| 245 | |
| 246 | // @brief Extract a packed element into a single VR. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 247 | // vA: destination VR (not vector register) |
| 248 | // vB: source (vector register) |
| 249 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 250 | // arg[0]: The index to use for extraction from vector register (which packed element) |
| 251 | kMirOpPackedReduce, |
| 252 | |
| 253 | // @brief Create a vector value, with all TypeSize values equal to vC |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 254 | // vA: destination vector register |
| 255 | // vB: source VR (not vector register) |
| 256 | // vC: TypeSize |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 257 | kMirOpPackedSet, |
| 258 | |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 259 | // @brief Reserve a range of vector registers. |
| 260 | // vA: Start vector register to reserve. |
| 261 | // vB: Inclusive end vector register to reserve. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 262 | // @note: The backend may choose to map vector numbers used in vector opcodes. |
| 263 | // Reserved registers are removed from the list of backend temporary pool. |
| 264 | kMirOpReserveVectorRegisters, |
| 265 | |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 266 | // @brief Free a range of reserved vector registers |
| 267 | // vA: Start vector register to unreserve. |
| 268 | // vB: Inclusive end vector register to unreserve. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 269 | // @note: All currently reserved vector registers are returned to the temporary pool. |
| 270 | kMirOpReturnVectorRegisters, |
| 271 | |
Jean Christophe Beyler | b5bce7c | 2014-07-25 12:32:18 -0700 | [diff] [blame] | 272 | // @brief Create a memory barrier. |
| 273 | // vA: a constant defined by enum MemBarrierKind. |
| 274 | kMirOpMemBarrier, |
| 275 | |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 276 | // @brief Used to fill a vector register with array values. |
| 277 | // @details Just as with normal arrays, access on null object register must ensure NullPointerException |
| 278 | // and invalid index must ensure ArrayIndexOutOfBoundsException. Exception behavior must be the same |
| 279 | // as the aget it replaced and must happen at same index. Therefore, it is generally recommended that |
| 280 | // before using this MIR, it is proven that exception is guaranteed to not be thrown and marked with |
| 281 | // MIR_IGNORE_NULL_CHECK and MIR_IGNORE_RANGE_CHECK. |
| 282 | // vA: destination vector register |
| 283 | // vB: array register |
| 284 | // vC: index register |
| 285 | // arg[0]: TypeSize (most other vector opcodes have this in vC) |
| 286 | kMirOpPackedArrayGet, |
| 287 | |
| 288 | // @brief Used to store a vector register into array. |
| 289 | // @details Just as with normal arrays, access on null object register must ensure NullPointerException |
| 290 | // and invalid index must ensure ArrayIndexOutOfBoundsException. Exception behavior must be the same |
| 291 | // as the aget it replaced and must happen at same index. Therefore, it is generally recommended that |
| 292 | // before using this MIR, it is proven that exception is guaranteed to not be thrown and marked with |
| 293 | // MIR_IGNORE_NULL_CHECK and MIR_IGNORE_RANGE_CHECK. |
| 294 | // vA: source vector register |
| 295 | // vB: array register |
| 296 | // vC: index register |
| 297 | // arg[0]: TypeSize (most other vector opcodes have this in vC) |
| 298 | kMirOpPackedArrayPut, |
| 299 | |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 300 | kMirOpLast, |
| 301 | }; |
| 302 | |
Jean Christophe Beyler | 89fde26 | 2014-04-30 11:40:07 -0700 | [diff] [blame] | 303 | enum MIROptimizationFlagPositions { |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 304 | kMIRIgnoreNullCheck = 0, |
| 305 | kMIRNullCheckOnly, |
| 306 | kMIRIgnoreRangeCheck, |
| 307 | kMIRRangeCheckOnly, |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 308 | kMIRIgnoreClInitCheck, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame^] | 309 | kMirIgnoreDivZeroCheck, |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 310 | kMIRInlined, // Invoke is inlined (ie dead). |
| 311 | kMIRInlinedPred, // Invoke is inlined via prediction. |
| 312 | kMIRCallee, // Instruction is inlined from callee. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 313 | kMIRIgnoreSuspendCheck, |
| 314 | kMIRDup, |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 315 | kMIRMark, // Temporary node mark. |
Jean Christophe Beyler | b5bce7c | 2014-07-25 12:32:18 -0700 | [diff] [blame] | 316 | kMIRStoreNonTemporal, |
Jean Christophe Beyler | 89fde26 | 2014-04-30 11:40:07 -0700 | [diff] [blame] | 317 | kMIRLastMIRFlag, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 318 | }; |
| 319 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 320 | // For successor_block_list. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 321 | enum BlockListType { |
| 322 | kNotUsed = 0, |
| 323 | kCatch, |
| 324 | kPackedSwitch, |
| 325 | kSparseSwitch, |
| 326 | }; |
| 327 | |
| 328 | enum AssemblerStatus { |
| 329 | kSuccess, |
| 330 | kRetryAll, |
| 331 | }; |
| 332 | |
| 333 | enum OpSize { |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 334 | kWord, // Natural word size of target (32/64). |
| 335 | k32, |
| 336 | k64, |
| 337 | kReference, // Object reference; compressed on 64-bit targets. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 338 | kSingle, |
| 339 | kDouble, |
| 340 | kUnsignedHalf, |
| 341 | kSignedHalf, |
| 342 | kUnsignedByte, |
| 343 | kSignedByte, |
| 344 | }; |
| 345 | |
| 346 | std::ostream& operator<<(std::ostream& os, const OpSize& kind); |
| 347 | |
| 348 | enum OpKind { |
| 349 | kOpMov, |
Razvan A Lupusoru | bd288c2 | 2013-12-20 17:27:23 -0800 | [diff] [blame] | 350 | kOpCmov, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 351 | kOpMvn, |
| 352 | kOpCmp, |
| 353 | kOpLsl, |
| 354 | kOpLsr, |
| 355 | kOpAsr, |
| 356 | kOpRor, |
| 357 | kOpNot, |
| 358 | kOpAnd, |
| 359 | kOpOr, |
| 360 | kOpXor, |
| 361 | kOpNeg, |
| 362 | kOpAdd, |
| 363 | kOpAdc, |
| 364 | kOpSub, |
| 365 | kOpSbc, |
| 366 | kOpRsub, |
| 367 | kOpMul, |
| 368 | kOpDiv, |
| 369 | kOpRem, |
| 370 | kOpBic, |
| 371 | kOpCmn, |
| 372 | kOpTst, |
Vladimir Marko | a8b4caf | 2013-10-24 15:08:57 +0100 | [diff] [blame] | 373 | kOpRev, |
| 374 | kOpRevsh, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 375 | kOpBkpt, |
| 376 | kOpBlx, |
| 377 | kOpPush, |
| 378 | kOpPop, |
| 379 | kOp2Char, |
| 380 | kOp2Short, |
| 381 | kOp2Byte, |
| 382 | kOpCondBr, |
| 383 | kOpUncondBr, |
| 384 | kOpBx, |
| 385 | kOpInvalid, |
| 386 | }; |
| 387 | |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 388 | enum MoveType { |
| 389 | kMov8GP, // Move 8-bit general purpose register. |
| 390 | kMov16GP, // Move 16-bit general purpose register. |
| 391 | kMov32GP, // Move 32-bit general purpose register. |
| 392 | kMov64GP, // Move 64-bit general purpose register. |
| 393 | kMov32FP, // Move 32-bit FP register. |
| 394 | kMov64FP, // Move 64-bit FP register. |
| 395 | kMovLo64FP, // Move low 32-bits of 64-bit FP register. |
| 396 | kMovHi64FP, // Move high 32-bits of 64-bit FP register. |
| 397 | kMovU128FP, // Move 128-bit FP register to/from possibly unaligned region. |
| 398 | kMov128FP = kMovU128FP, |
| 399 | kMovA128FP, // Move 128-bit FP register to/from region surely aligned to 16-bytes. |
| 400 | kMovLo128FP, // Move low 64-bits of 128-bit FP register. |
| 401 | kMovHi128FP, // Move high 64-bits of 128-bit FP register. |
| 402 | }; |
| 403 | |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 404 | std::ostream& operator<<(std::ostream& os, const OpKind& kind); |
| 405 | |
| 406 | enum ConditionCode { |
| 407 | kCondEq, // equal |
| 408 | kCondNe, // not equal |
Vladimir Marko | 58af1f9 | 2013-12-19 13:31:15 +0000 | [diff] [blame] | 409 | kCondCs, // carry set |
| 410 | kCondCc, // carry clear |
Vladimir Marko | 459f4df | 2013-12-20 17:03:09 +0000 | [diff] [blame] | 411 | kCondUlt, // unsigned less than |
| 412 | kCondUge, // unsigned greater than or same |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 413 | kCondMi, // minus |
| 414 | kCondPl, // plus, positive or zero |
| 415 | kCondVs, // overflow |
| 416 | kCondVc, // no overflow |
| 417 | kCondHi, // unsigned greater than |
| 418 | kCondLs, // unsigned lower or same |
| 419 | kCondGe, // signed greater than or equal |
| 420 | kCondLt, // signed less than |
| 421 | kCondGt, // signed greater than |
| 422 | kCondLe, // signed less than or equal |
| 423 | kCondAl, // always |
| 424 | kCondNv, // never |
| 425 | }; |
| 426 | |
| 427 | std::ostream& operator<<(std::ostream& os, const ConditionCode& kind); |
| 428 | |
| 429 | // Target specific condition encodings |
| 430 | enum ArmConditionCode { |
| 431 | kArmCondEq = 0x0, // 0000 |
| 432 | kArmCondNe = 0x1, // 0001 |
| 433 | kArmCondCs = 0x2, // 0010 |
| 434 | kArmCondCc = 0x3, // 0011 |
| 435 | kArmCondMi = 0x4, // 0100 |
| 436 | kArmCondPl = 0x5, // 0101 |
| 437 | kArmCondVs = 0x6, // 0110 |
| 438 | kArmCondVc = 0x7, // 0111 |
| 439 | kArmCondHi = 0x8, // 1000 |
| 440 | kArmCondLs = 0x9, // 1001 |
| 441 | kArmCondGe = 0xa, // 1010 |
| 442 | kArmCondLt = 0xb, // 1011 |
| 443 | kArmCondGt = 0xc, // 1100 |
| 444 | kArmCondLe = 0xd, // 1101 |
| 445 | kArmCondAl = 0xe, // 1110 |
| 446 | kArmCondNv = 0xf, // 1111 |
| 447 | }; |
| 448 | |
| 449 | std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind); |
| 450 | |
| 451 | enum X86ConditionCode { |
| 452 | kX86CondO = 0x0, // overflow |
| 453 | kX86CondNo = 0x1, // not overflow |
| 454 | |
| 455 | kX86CondB = 0x2, // below |
| 456 | kX86CondNae = kX86CondB, // not-above-equal |
| 457 | kX86CondC = kX86CondB, // carry |
| 458 | |
| 459 | kX86CondNb = 0x3, // not-below |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 460 | kX86CondAe = kX86CondNb, // above-equal |
| 461 | kX86CondNc = kX86CondNb, // not-carry |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 462 | |
| 463 | kX86CondZ = 0x4, // zero |
| 464 | kX86CondEq = kX86CondZ, // equal |
| 465 | |
| 466 | kX86CondNz = 0x5, // not-zero |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 467 | kX86CondNe = kX86CondNz, // not-equal |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 468 | |
| 469 | kX86CondBe = 0x6, // below-equal |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 470 | kX86CondNa = kX86CondBe, // not-above |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 471 | |
| 472 | kX86CondNbe = 0x7, // not-below-equal |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 473 | kX86CondA = kX86CondNbe, // above |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 474 | |
| 475 | kX86CondS = 0x8, // sign |
| 476 | kX86CondNs = 0x9, // not-sign |
| 477 | |
| 478 | kX86CondP = 0xa, // 8-bit parity even |
| 479 | kX86CondPE = kX86CondP, |
| 480 | |
| 481 | kX86CondNp = 0xb, // 8-bit parity odd |
| 482 | kX86CondPo = kX86CondNp, |
| 483 | |
| 484 | kX86CondL = 0xc, // less-than |
| 485 | kX86CondNge = kX86CondL, // not-greater-equal |
| 486 | |
| 487 | kX86CondNl = 0xd, // not-less-than |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 488 | kX86CondGe = kX86CondNl, // not-greater-equal |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 489 | |
| 490 | kX86CondLe = 0xe, // less-than-equal |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 491 | kX86CondNg = kX86CondLe, // not-greater |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 492 | |
| 493 | kX86CondNle = 0xf, // not-less-than |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 494 | kX86CondG = kX86CondNle, // greater |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 495 | }; |
| 496 | |
| 497 | std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind); |
| 498 | |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 499 | enum DividePattern { |
| 500 | DivideNone, |
| 501 | Divide3, |
| 502 | Divide5, |
| 503 | Divide7, |
| 504 | }; |
| 505 | |
| 506 | std::ostream& operator<<(std::ostream& os, const DividePattern& pattern); |
| 507 | |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 508 | /** |
| 509 | * @brief Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers"). |
Hans Boehm | 48f5c47 | 2014-06-27 14:50:10 -0700 | [diff] [blame] | 510 | * @details We define the combined barrier types that are actually required |
| 511 | * by the Java Memory Model, rather than using exactly the terminology from |
| 512 | * the JSR-133 cookbook. These should, in many cases, be replaced by acquire/release |
| 513 | * primitives. Note that the JSR-133 cookbook generally does not deal with |
| 514 | * store atomicity issues, and the recipes there are not always entirely sufficient. |
| 515 | * The current recipe is as follows: |
| 516 | * -# Use AnyStore ~= (LoadStore | StoreStore) ~= release barrier before volatile store. |
| 517 | * -# Use AnyAny barrier after volatile store. (StoreLoad is as expensive.) |
| 518 | * -# Use LoadAny barrier ~= (LoadLoad | LoadStore) ~= acquire barrierafter each volatile load. |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 519 | * -# Use StoreStore barrier after all stores but before return from any constructor whose |
Hans Boehm | 48f5c47 | 2014-06-27 14:50:10 -0700 | [diff] [blame] | 520 | * class has final fields. |
Jean Christophe Beyler | b5bce7c | 2014-07-25 12:32:18 -0700 | [diff] [blame] | 521 | * -# Use NTStoreStore to order non-temporal stores with respect to all later |
| 522 | * store-to-memory instructions. Only generated together with non-temporal stores. |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 523 | */ |
buzbee | 1bc37c6 | 2012-11-20 13:35:41 -0800 | [diff] [blame] | 524 | enum MemBarrierKind { |
Hans Boehm | 48f5c47 | 2014-06-27 14:50:10 -0700 | [diff] [blame] | 525 | kAnyStore, |
| 526 | kLoadAny, |
buzbee | 1bc37c6 | 2012-11-20 13:35:41 -0800 | [diff] [blame] | 527 | kStoreStore, |
Jean Christophe Beyler | b5bce7c | 2014-07-25 12:32:18 -0700 | [diff] [blame] | 528 | kAnyAny, |
| 529 | kNTStoreStore, |
buzbee | 1bc37c6 | 2012-11-20 13:35:41 -0800 | [diff] [blame] | 530 | }; |
| 531 | |
| 532 | std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind); |
| 533 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 534 | enum OpFeatureFlags { |
| 535 | kIsBranch = 0, |
| 536 | kNoOperand, |
| 537 | kIsUnaryOp, |
| 538 | kIsBinaryOp, |
| 539 | kIsTertiaryOp, |
| 540 | kIsQuadOp, |
| 541 | kIsQuinOp, |
| 542 | kIsSextupleOp, |
| 543 | kIsIT, |
Serban Constantinescu | 6399968 | 2014-07-15 17:44:21 +0100 | [diff] [blame] | 544 | kIsMoveOp, |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 545 | kMemLoad, |
| 546 | kMemStore, |
Serban Constantinescu | 6399968 | 2014-07-15 17:44:21 +0100 | [diff] [blame] | 547 | kMemVolatile, |
| 548 | kMemScaledx0, |
| 549 | kMemScaledx2, |
| 550 | kMemScaledx4, |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 551 | kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes. |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 552 | kRegDef0, |
| 553 | kRegDef1, |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 554 | kRegDef2, |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 555 | kRegDefA, |
| 556 | kRegDefD, |
| 557 | kRegDefFPCSList0, |
| 558 | kRegDefFPCSList2, |
| 559 | kRegDefList0, |
| 560 | kRegDefList1, |
| 561 | kRegDefList2, |
| 562 | kRegDefLR, |
| 563 | kRegDefSP, |
| 564 | kRegUse0, |
| 565 | kRegUse1, |
| 566 | kRegUse2, |
| 567 | kRegUse3, |
| 568 | kRegUse4, |
| 569 | kRegUseA, |
| 570 | kRegUseC, |
| 571 | kRegUseD, |
Vladimir Marko | 70b797d | 2013-12-03 15:25:24 +0000 | [diff] [blame] | 572 | kRegUseB, |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 573 | kRegUseFPCSList0, |
| 574 | kRegUseFPCSList2, |
| 575 | kRegUseList0, |
| 576 | kRegUseList1, |
| 577 | kRegUseLR, |
| 578 | kRegUsePC, |
| 579 | kRegUseSP, |
| 580 | kSetsCCodes, |
Serguei Katkov | e90501d | 2014-03-12 15:56:54 +0700 | [diff] [blame] | 581 | kUsesCCodes, |
buzbee | 9da5c10 | 2014-03-28 12:59:18 -0700 | [diff] [blame] | 582 | kUseFpStack, |
| 583 | kUseHi, |
| 584 | kUseLo, |
| 585 | kDefHi, |
| 586 | kDefLo |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 587 | }; |
| 588 | |
buzbee | f662a7c | 2013-02-12 16:19:43 -0800 | [diff] [blame] | 589 | enum SelectInstructionKind { |
| 590 | kSelectNone, |
| 591 | kSelectConst, |
| 592 | kSelectMove, |
| 593 | kSelectGoto |
| 594 | }; |
| 595 | |
buzbee | a5abf70 | 2013-04-12 14:39:29 -0700 | [diff] [blame] | 596 | std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind); |
| 597 | |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 598 | // LIR fixup kinds for Arm |
| 599 | enum FixupKind { |
| 600 | kFixupNone, |
| 601 | kFixupLabel, // For labels we just adjust the offset. |
Vladimir Marko | 306f017 | 2014-01-07 18:21:20 +0000 | [diff] [blame] | 602 | kFixupLoad, // Mostly for immediates. |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 603 | kFixupVLoad, // FP load which *may* be pc-relative. |
| 604 | kFixupCBxZ, // Cbz, Cbnz. |
Zheng Xu | 5d7cdec | 2014-08-18 17:28:22 +0800 | [diff] [blame] | 605 | kFixupTBxZ, // Tbz, Tbnz. |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 606 | kFixupPushPop, // Not really pc relative, but changes size based on args. |
| 607 | kFixupCondBranch, // Conditional branch |
| 608 | kFixupT1Branch, // Thumb1 Unconditional branch |
| 609 | kFixupT2Branch, // Thumb2 Unconditional branch |
| 610 | kFixupBlx1, // Blx1 (start of Blx1/Blx2 pair). |
| 611 | kFixupBl1, // Bl1 (start of Bl1/Bl2 pair). |
| 612 | kFixupAdr, // Adr. |
| 613 | kFixupMovImmLST, // kThumb2MovImm16LST. |
| 614 | kFixupMovImmHST, // kThumb2MovImm16HST. |
| 615 | kFixupAlign4, // Align to 4-byte boundary. |
| 616 | }; |
| 617 | |
| 618 | std::ostream& operator<<(std::ostream& os, const FixupKind& kind); |
| 619 | |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 620 | enum VolatileKind { |
| 621 | kNotVolatile, // Load/Store is not volatile |
| 622 | kVolatile // Load/Store is volatile |
| 623 | }; |
| 624 | |
| 625 | std::ostream& operator<<(std::ostream& os, const VolatileKind& kind); |
| 626 | |
Andreas Gampe | ccc6026 | 2014-07-04 18:02:38 -0700 | [diff] [blame] | 627 | enum WideKind { |
| 628 | kNotWide, // Non-wide view |
| 629 | kWide, // Wide view |
| 630 | kRef // Ref width |
| 631 | }; |
| 632 | |
| 633 | std::ostream& operator<<(std::ostream& os, const WideKind& kind); |
| 634 | |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 635 | } // namespace art |
| 636 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 637 | #endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_ |