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 | |
| 17 | #ifndef ART_SRC_COMPILER_COMPILERENUMS_H_ |
| 18 | #define ART_SRC_COMPILER_COMPILERENUMS_H_ |
| 19 | |
| 20 | #include "dex_instruction.h" |
| 21 | |
| 22 | namespace art { |
| 23 | |
| 24 | enum RegisterClass { |
| 25 | kCoreReg, |
| 26 | kFPReg, |
| 27 | kAnyReg, |
| 28 | }; |
| 29 | |
| 30 | enum SpecialTargetRegister { |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 31 | kSelf, // Thread pointer. |
| 32 | kSuspend, // Used to reduce suspend checks for some targets. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 33 | kLr, |
| 34 | kPc, |
| 35 | kSp, |
| 36 | kArg0, |
| 37 | kArg1, |
| 38 | kArg2, |
| 39 | kArg3, |
| 40 | kFArg0, |
| 41 | kFArg1, |
| 42 | kFArg2, |
| 43 | kFArg3, |
| 44 | kRet0, |
| 45 | kRet1, |
| 46 | kInvokeTgt, |
| 47 | kCount |
| 48 | }; |
| 49 | |
| 50 | enum RegLocationType { |
| 51 | kLocDalvikFrame = 0, // Normal Dalvik register |
| 52 | kLocPhysReg, |
| 53 | kLocCompilerTemp, |
| 54 | kLocInvalid |
| 55 | }; |
| 56 | |
| 57 | enum BBType { |
| 58 | kEntryBlock, |
| 59 | kDalvikByteCode, |
| 60 | kExitBlock, |
| 61 | kExceptionHandling, |
| 62 | kDead, |
| 63 | }; |
| 64 | |
| 65 | /* |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 66 | * Def/Use encoding in 64-bit use_mask/def_mask. Low positions used for target-specific |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 67 | * registers (and typically use the register number as the position). High positions |
| 68 | * reserved for common and abstract resources. |
| 69 | */ |
| 70 | |
| 71 | enum ResourceEncodingPos { |
| 72 | kMustNotAlias = 63, |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 73 | kHeapRef = 62, // Default memory reference type. |
| 74 | kLiteral = 61, // Literal pool memory reference. |
| 75 | kDalvikReg = 60, // Dalvik v_reg memory reference. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 76 | kFPStatus = 59, |
| 77 | kCCode = 58, |
| 78 | kLowestCommonResource = kCCode |
| 79 | }; |
| 80 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 81 | // Shared pseudo opcodes - must be < 0. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 82 | enum LIRPseudoOpcode { |
buzbee | a169e1d | 2012-12-05 14:26:44 -0800 | [diff] [blame] | 83 | kPseudoExportedPC = -16, |
| 84 | kPseudoSafepointPC = -15, |
| 85 | kPseudoIntrinsicRetry = -14, |
| 86 | kPseudoSuspendTarget = -13, |
| 87 | kPseudoThrowTarget = -12, |
| 88 | kPseudoCaseLabel = -11, |
| 89 | kPseudoMethodEntry = -10, |
| 90 | kPseudoMethodExit = -9, |
| 91 | kPseudoBarrier = -8, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 92 | kPseudoEntryBlock = -7, |
| 93 | kPseudoExitBlock = -6, |
| 94 | kPseudoTargetLabel = -5, |
| 95 | kPseudoDalvikByteCodeBoundary = -4, |
| 96 | kPseudoPseudoAlign4 = -3, |
| 97 | kPseudoEHBlockLabel = -2, |
| 98 | kPseudoNormalBlockLabel = -1, |
| 99 | }; |
| 100 | |
| 101 | enum ExtendedMIROpcode { |
| 102 | kMirOpFirst = kNumPackedOpcodes, |
| 103 | kMirOpPhi = kMirOpFirst, |
| 104 | kMirOpCopy, |
| 105 | kMirOpFusedCmplFloat, |
| 106 | kMirOpFusedCmpgFloat, |
| 107 | kMirOpFusedCmplDouble, |
| 108 | kMirOpFusedCmpgDouble, |
| 109 | kMirOpFusedCmpLong, |
| 110 | kMirOpNop, |
| 111 | kMirOpNullCheck, |
| 112 | kMirOpRangeCheck, |
| 113 | kMirOpDivZeroCheck, |
| 114 | kMirOpCheck, |
buzbee | a169e1d | 2012-12-05 14:26:44 -0800 | [diff] [blame] | 115 | kMirOpCheckPart2, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 116 | kMirOpLast, |
| 117 | }; |
| 118 | |
| 119 | enum MIROptimizationFlagPositons { |
| 120 | kMIRIgnoreNullCheck = 0, |
| 121 | kMIRNullCheckOnly, |
| 122 | kMIRIgnoreRangeCheck, |
| 123 | kMIRRangeCheckOnly, |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 124 | kMIRInlined, // Invoke is inlined (ie dead). |
| 125 | kMIRInlinedPred, // Invoke is inlined via prediction. |
| 126 | kMIRCallee, // Instruction is inlined from callee. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 127 | kMIRIgnoreSuspendCheck, |
| 128 | kMIRDup, |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 129 | kMIRMark, // Temporary node mark. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 130 | }; |
| 131 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 132 | // For successor_block_list. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 133 | enum BlockListType { |
| 134 | kNotUsed = 0, |
| 135 | kCatch, |
| 136 | kPackedSwitch, |
| 137 | kSparseSwitch, |
| 138 | }; |
| 139 | |
| 140 | enum AssemblerStatus { |
| 141 | kSuccess, |
| 142 | kRetryAll, |
| 143 | }; |
| 144 | |
| 145 | enum OpSize { |
| 146 | kWord, |
| 147 | kLong, |
| 148 | kSingle, |
| 149 | kDouble, |
| 150 | kUnsignedHalf, |
| 151 | kSignedHalf, |
| 152 | kUnsignedByte, |
| 153 | kSignedByte, |
| 154 | }; |
| 155 | |
| 156 | std::ostream& operator<<(std::ostream& os, const OpSize& kind); |
| 157 | |
| 158 | enum OpKind { |
| 159 | kOpMov, |
| 160 | kOpMvn, |
| 161 | kOpCmp, |
| 162 | kOpLsl, |
| 163 | kOpLsr, |
| 164 | kOpAsr, |
| 165 | kOpRor, |
| 166 | kOpNot, |
| 167 | kOpAnd, |
| 168 | kOpOr, |
| 169 | kOpXor, |
| 170 | kOpNeg, |
| 171 | kOpAdd, |
| 172 | kOpAdc, |
| 173 | kOpSub, |
| 174 | kOpSbc, |
| 175 | kOpRsub, |
| 176 | kOpMul, |
| 177 | kOpDiv, |
| 178 | kOpRem, |
| 179 | kOpBic, |
| 180 | kOpCmn, |
| 181 | kOpTst, |
| 182 | kOpBkpt, |
| 183 | kOpBlx, |
| 184 | kOpPush, |
| 185 | kOpPop, |
| 186 | kOp2Char, |
| 187 | kOp2Short, |
| 188 | kOp2Byte, |
| 189 | kOpCondBr, |
| 190 | kOpUncondBr, |
| 191 | kOpBx, |
| 192 | kOpInvalid, |
| 193 | }; |
| 194 | |
| 195 | std::ostream& operator<<(std::ostream& os, const OpKind& kind); |
| 196 | |
| 197 | enum ConditionCode { |
| 198 | kCondEq, // equal |
| 199 | kCondNe, // not equal |
| 200 | kCondCs, // carry set (unsigned less than) |
| 201 | kCondUlt = kCondCs, |
| 202 | kCondCc, // carry clear (unsigned greater than or same) |
| 203 | kCondUge = kCondCc, |
| 204 | kCondMi, // minus |
| 205 | kCondPl, // plus, positive or zero |
| 206 | kCondVs, // overflow |
| 207 | kCondVc, // no overflow |
| 208 | kCondHi, // unsigned greater than |
| 209 | kCondLs, // unsigned lower or same |
| 210 | kCondGe, // signed greater than or equal |
| 211 | kCondLt, // signed less than |
| 212 | kCondGt, // signed greater than |
| 213 | kCondLe, // signed less than or equal |
| 214 | kCondAl, // always |
| 215 | kCondNv, // never |
| 216 | }; |
| 217 | |
| 218 | std::ostream& operator<<(std::ostream& os, const ConditionCode& kind); |
| 219 | |
| 220 | // Target specific condition encodings |
| 221 | enum ArmConditionCode { |
| 222 | kArmCondEq = 0x0, // 0000 |
| 223 | kArmCondNe = 0x1, // 0001 |
| 224 | kArmCondCs = 0x2, // 0010 |
| 225 | kArmCondCc = 0x3, // 0011 |
| 226 | kArmCondMi = 0x4, // 0100 |
| 227 | kArmCondPl = 0x5, // 0101 |
| 228 | kArmCondVs = 0x6, // 0110 |
| 229 | kArmCondVc = 0x7, // 0111 |
| 230 | kArmCondHi = 0x8, // 1000 |
| 231 | kArmCondLs = 0x9, // 1001 |
| 232 | kArmCondGe = 0xa, // 1010 |
| 233 | kArmCondLt = 0xb, // 1011 |
| 234 | kArmCondGt = 0xc, // 1100 |
| 235 | kArmCondLe = 0xd, // 1101 |
| 236 | kArmCondAl = 0xe, // 1110 |
| 237 | kArmCondNv = 0xf, // 1111 |
| 238 | }; |
| 239 | |
| 240 | std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind); |
| 241 | |
| 242 | enum X86ConditionCode { |
| 243 | kX86CondO = 0x0, // overflow |
| 244 | kX86CondNo = 0x1, // not overflow |
| 245 | |
| 246 | kX86CondB = 0x2, // below |
| 247 | kX86CondNae = kX86CondB, // not-above-equal |
| 248 | kX86CondC = kX86CondB, // carry |
| 249 | |
| 250 | kX86CondNb = 0x3, // not-below |
| 251 | kX86CondAe = kX86CondNb, // above-equal |
| 252 | kX86CondNc = kX86CondNb, // not-carry |
| 253 | |
| 254 | kX86CondZ = 0x4, // zero |
| 255 | kX86CondEq = kX86CondZ, // equal |
| 256 | |
| 257 | kX86CondNz = 0x5, // not-zero |
| 258 | kX86CondNe = kX86CondNz, // not-equal |
| 259 | |
| 260 | kX86CondBe = 0x6, // below-equal |
| 261 | kX86CondNa = kX86CondBe, // not-above |
| 262 | |
| 263 | kX86CondNbe = 0x7, // not-below-equal |
| 264 | kX86CondA = kX86CondNbe,// above |
| 265 | |
| 266 | kX86CondS = 0x8, // sign |
| 267 | kX86CondNs = 0x9, // not-sign |
| 268 | |
| 269 | kX86CondP = 0xa, // 8-bit parity even |
| 270 | kX86CondPE = kX86CondP, |
| 271 | |
| 272 | kX86CondNp = 0xb, // 8-bit parity odd |
| 273 | kX86CondPo = kX86CondNp, |
| 274 | |
| 275 | kX86CondL = 0xc, // less-than |
| 276 | kX86CondNge = kX86CondL, // not-greater-equal |
| 277 | |
| 278 | kX86CondNl = 0xd, // not-less-than |
| 279 | kX86CondGe = kX86CondNl, // not-greater-equal |
| 280 | |
| 281 | kX86CondLe = 0xe, // less-than-equal |
| 282 | kX86CondNg = kX86CondLe, // not-greater |
| 283 | |
| 284 | kX86CondNle = 0xf, // not-less-than |
| 285 | kX86CondG = kX86CondNle,// greater |
| 286 | }; |
| 287 | |
| 288 | std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind); |
| 289 | |
| 290 | enum ThrowKind { |
| 291 | kThrowNullPointer, |
| 292 | kThrowDivZero, |
| 293 | kThrowArrayBounds, |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame^] | 294 | kThrowConstantArrayBounds, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 295 | kThrowNoSuchMethod, |
| 296 | kThrowStackOverflow, |
| 297 | }; |
| 298 | |
| 299 | enum SpecialCaseHandler { |
| 300 | kNoHandler, |
| 301 | kNullMethod, |
| 302 | kConstFunction, |
| 303 | kIGet, |
| 304 | kIGetBoolean, |
| 305 | kIGetObject, |
| 306 | kIGetByte, |
| 307 | kIGetChar, |
| 308 | kIGetShort, |
| 309 | kIGetWide, |
| 310 | kIPut, |
| 311 | kIPutBoolean, |
| 312 | kIPutObject, |
| 313 | kIPutByte, |
| 314 | kIPutChar, |
| 315 | kIPutShort, |
| 316 | kIPutWide, |
| 317 | kIdentity, |
| 318 | }; |
| 319 | |
| 320 | enum DividePattern { |
| 321 | DivideNone, |
| 322 | Divide3, |
| 323 | Divide5, |
| 324 | Divide7, |
| 325 | }; |
| 326 | |
| 327 | std::ostream& operator<<(std::ostream& os, const DividePattern& pattern); |
| 328 | |
| 329 | /* Customized node traversal orders for different needs */ |
| 330 | enum DataFlowAnalysisMode { |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 331 | kAllNodes = 0, // All nodes. |
| 332 | kReachableNodes, // All reachable nodes. |
| 333 | kPreOrderDFSTraversal, // Depth-First-Search / Pre-Order. |
| 334 | kPostOrderDFSTraversal, // Depth-First-Search / Post-Order. |
| 335 | kPostOrderDOMTraversal, // Dominator tree / Post-Order. |
| 336 | kReversePostOrderTraversal, // Depth-First-Search / reverse Post-Order. |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 337 | }; |
| 338 | |
| 339 | std::ostream& operator<<(std::ostream& os, const DataFlowAnalysisMode& mode); |
| 340 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 341 | // Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers"). |
buzbee | 1bc37c6 | 2012-11-20 13:35:41 -0800 | [diff] [blame] | 342 | enum MemBarrierKind { |
| 343 | kLoadStore, |
| 344 | kLoadLoad, |
| 345 | kStoreStore, |
| 346 | kStoreLoad |
| 347 | }; |
| 348 | |
| 349 | std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind); |
| 350 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 351 | enum OpFeatureFlags { |
| 352 | kIsBranch = 0, |
| 353 | kNoOperand, |
| 354 | kIsUnaryOp, |
| 355 | kIsBinaryOp, |
| 356 | kIsTertiaryOp, |
| 357 | kIsQuadOp, |
| 358 | kIsQuinOp, |
| 359 | kIsSextupleOp, |
| 360 | kIsIT, |
| 361 | kMemLoad, |
| 362 | kMemStore, |
| 363 | kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes. |
| 364 | kRegDef0, |
| 365 | kRegDef1, |
| 366 | kRegDefA, |
| 367 | kRegDefD, |
| 368 | kRegDefFPCSList0, |
| 369 | kRegDefFPCSList2, |
| 370 | kRegDefList0, |
| 371 | kRegDefList1, |
| 372 | kRegDefList2, |
| 373 | kRegDefLR, |
| 374 | kRegDefSP, |
| 375 | kRegUse0, |
| 376 | kRegUse1, |
| 377 | kRegUse2, |
| 378 | kRegUse3, |
| 379 | kRegUse4, |
| 380 | kRegUseA, |
| 381 | kRegUseC, |
| 382 | kRegUseD, |
| 383 | kRegUseFPCSList0, |
| 384 | kRegUseFPCSList2, |
| 385 | kRegUseList0, |
| 386 | kRegUseList1, |
| 387 | kRegUseLR, |
| 388 | kRegUsePC, |
| 389 | kRegUseSP, |
| 390 | kSetsCCodes, |
| 391 | kUsesCCodes |
| 392 | }; |
| 393 | |
| 394 | std::ostream& operator<<(std::ostream& os, const OpFeatureFlags& flag); |
| 395 | |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 396 | } // namespace art |
| 397 | |
| 398 | #endif // ART_SRC_COMPILER_COMPILERENUMS_H_ |