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 { |
| 31 | kSelf, // Thread |
| 32 | kSuspend, // Used to reduce suspend checks |
| 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, |
| 73 | kHeapRef = 62, // Default memory reference type |
| 74 | kLiteral = 61, // Literal pool memory reference |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame^] | 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 | |
| 81 | /* Shared pseudo opcodes - must be < 0 */ |
| 82 | enum LIRPseudoOpcode { |
| 83 | kPseudoExportedPC = -18, |
| 84 | kPseudoSafepointPC = -17, |
| 85 | kPseudoIntrinsicRetry = -16, |
| 86 | kPseudoSuspendTarget = -15, |
| 87 | kPseudoThrowTarget = -14, |
| 88 | kPseudoCaseLabel = -13, |
| 89 | kPseudoMethodEntry = -12, |
| 90 | kPseudoMethodExit = -11, |
| 91 | kPseudoBarrier = -10, |
| 92 | kPseudoExtended = -9, |
| 93 | kPseudoSSARep = -8, |
| 94 | kPseudoEntryBlock = -7, |
| 95 | kPseudoExitBlock = -6, |
| 96 | kPseudoTargetLabel = -5, |
| 97 | kPseudoDalvikByteCodeBoundary = -4, |
| 98 | kPseudoPseudoAlign4 = -3, |
| 99 | kPseudoEHBlockLabel = -2, |
| 100 | kPseudoNormalBlockLabel = -1, |
| 101 | }; |
| 102 | |
| 103 | enum ExtendedMIROpcode { |
| 104 | kMirOpFirst = kNumPackedOpcodes, |
| 105 | kMirOpPhi = kMirOpFirst, |
| 106 | kMirOpCopy, |
| 107 | kMirOpFusedCmplFloat, |
| 108 | kMirOpFusedCmpgFloat, |
| 109 | kMirOpFusedCmplDouble, |
| 110 | kMirOpFusedCmpgDouble, |
| 111 | kMirOpFusedCmpLong, |
| 112 | kMirOpNop, |
| 113 | kMirOpNullCheck, |
| 114 | kMirOpRangeCheck, |
| 115 | kMirOpDivZeroCheck, |
| 116 | kMirOpCheck, |
| 117 | kMirOpLast, |
| 118 | }; |
| 119 | |
| 120 | enum MIROptimizationFlagPositons { |
| 121 | kMIRIgnoreNullCheck = 0, |
| 122 | kMIRNullCheckOnly, |
| 123 | kMIRIgnoreRangeCheck, |
| 124 | kMIRRangeCheckOnly, |
| 125 | kMIRInlined, // Invoke is inlined (ie dead) |
| 126 | kMIRInlinedPred, // Invoke is inlined via prediction |
| 127 | kMIRCallee, // Instruction is inlined from callee |
| 128 | kMIRIgnoreSuspendCheck, |
| 129 | kMIRDup, |
| 130 | kMIRMark, // Temporary node mark |
| 131 | }; |
| 132 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame^] | 133 | /* For successor_block_list */ |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 134 | enum BlockListType { |
| 135 | kNotUsed = 0, |
| 136 | kCatch, |
| 137 | kPackedSwitch, |
| 138 | kSparseSwitch, |
| 139 | }; |
| 140 | |
| 141 | enum AssemblerStatus { |
| 142 | kSuccess, |
| 143 | kRetryAll, |
| 144 | }; |
| 145 | |
| 146 | enum OpSize { |
| 147 | kWord, |
| 148 | kLong, |
| 149 | kSingle, |
| 150 | kDouble, |
| 151 | kUnsignedHalf, |
| 152 | kSignedHalf, |
| 153 | kUnsignedByte, |
| 154 | kSignedByte, |
| 155 | }; |
| 156 | |
| 157 | std::ostream& operator<<(std::ostream& os, const OpSize& kind); |
| 158 | |
| 159 | enum OpKind { |
| 160 | kOpMov, |
| 161 | kOpMvn, |
| 162 | kOpCmp, |
| 163 | kOpLsl, |
| 164 | kOpLsr, |
| 165 | kOpAsr, |
| 166 | kOpRor, |
| 167 | kOpNot, |
| 168 | kOpAnd, |
| 169 | kOpOr, |
| 170 | kOpXor, |
| 171 | kOpNeg, |
| 172 | kOpAdd, |
| 173 | kOpAdc, |
| 174 | kOpSub, |
| 175 | kOpSbc, |
| 176 | kOpRsub, |
| 177 | kOpMul, |
| 178 | kOpDiv, |
| 179 | kOpRem, |
| 180 | kOpBic, |
| 181 | kOpCmn, |
| 182 | kOpTst, |
| 183 | kOpBkpt, |
| 184 | kOpBlx, |
| 185 | kOpPush, |
| 186 | kOpPop, |
| 187 | kOp2Char, |
| 188 | kOp2Short, |
| 189 | kOp2Byte, |
| 190 | kOpCondBr, |
| 191 | kOpUncondBr, |
| 192 | kOpBx, |
| 193 | kOpInvalid, |
| 194 | }; |
| 195 | |
| 196 | std::ostream& operator<<(std::ostream& os, const OpKind& kind); |
| 197 | |
| 198 | enum ConditionCode { |
| 199 | kCondEq, // equal |
| 200 | kCondNe, // not equal |
| 201 | kCondCs, // carry set (unsigned less than) |
| 202 | kCondUlt = kCondCs, |
| 203 | kCondCc, // carry clear (unsigned greater than or same) |
| 204 | kCondUge = kCondCc, |
| 205 | kCondMi, // minus |
| 206 | kCondPl, // plus, positive or zero |
| 207 | kCondVs, // overflow |
| 208 | kCondVc, // no overflow |
| 209 | kCondHi, // unsigned greater than |
| 210 | kCondLs, // unsigned lower or same |
| 211 | kCondGe, // signed greater than or equal |
| 212 | kCondLt, // signed less than |
| 213 | kCondGt, // signed greater than |
| 214 | kCondLe, // signed less than or equal |
| 215 | kCondAl, // always |
| 216 | kCondNv, // never |
| 217 | }; |
| 218 | |
| 219 | std::ostream& operator<<(std::ostream& os, const ConditionCode& kind); |
| 220 | |
| 221 | // Target specific condition encodings |
| 222 | enum ArmConditionCode { |
| 223 | kArmCondEq = 0x0, // 0000 |
| 224 | kArmCondNe = 0x1, // 0001 |
| 225 | kArmCondCs = 0x2, // 0010 |
| 226 | kArmCondCc = 0x3, // 0011 |
| 227 | kArmCondMi = 0x4, // 0100 |
| 228 | kArmCondPl = 0x5, // 0101 |
| 229 | kArmCondVs = 0x6, // 0110 |
| 230 | kArmCondVc = 0x7, // 0111 |
| 231 | kArmCondHi = 0x8, // 1000 |
| 232 | kArmCondLs = 0x9, // 1001 |
| 233 | kArmCondGe = 0xa, // 1010 |
| 234 | kArmCondLt = 0xb, // 1011 |
| 235 | kArmCondGt = 0xc, // 1100 |
| 236 | kArmCondLe = 0xd, // 1101 |
| 237 | kArmCondAl = 0xe, // 1110 |
| 238 | kArmCondNv = 0xf, // 1111 |
| 239 | }; |
| 240 | |
| 241 | std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind); |
| 242 | |
| 243 | enum X86ConditionCode { |
| 244 | kX86CondO = 0x0, // overflow |
| 245 | kX86CondNo = 0x1, // not overflow |
| 246 | |
| 247 | kX86CondB = 0x2, // below |
| 248 | kX86CondNae = kX86CondB, // not-above-equal |
| 249 | kX86CondC = kX86CondB, // carry |
| 250 | |
| 251 | kX86CondNb = 0x3, // not-below |
| 252 | kX86CondAe = kX86CondNb, // above-equal |
| 253 | kX86CondNc = kX86CondNb, // not-carry |
| 254 | |
| 255 | kX86CondZ = 0x4, // zero |
| 256 | kX86CondEq = kX86CondZ, // equal |
| 257 | |
| 258 | kX86CondNz = 0x5, // not-zero |
| 259 | kX86CondNe = kX86CondNz, // not-equal |
| 260 | |
| 261 | kX86CondBe = 0x6, // below-equal |
| 262 | kX86CondNa = kX86CondBe, // not-above |
| 263 | |
| 264 | kX86CondNbe = 0x7, // not-below-equal |
| 265 | kX86CondA = kX86CondNbe,// above |
| 266 | |
| 267 | kX86CondS = 0x8, // sign |
| 268 | kX86CondNs = 0x9, // not-sign |
| 269 | |
| 270 | kX86CondP = 0xa, // 8-bit parity even |
| 271 | kX86CondPE = kX86CondP, |
| 272 | |
| 273 | kX86CondNp = 0xb, // 8-bit parity odd |
| 274 | kX86CondPo = kX86CondNp, |
| 275 | |
| 276 | kX86CondL = 0xc, // less-than |
| 277 | kX86CondNge = kX86CondL, // not-greater-equal |
| 278 | |
| 279 | kX86CondNl = 0xd, // not-less-than |
| 280 | kX86CondGe = kX86CondNl, // not-greater-equal |
| 281 | |
| 282 | kX86CondLe = 0xe, // less-than-equal |
| 283 | kX86CondNg = kX86CondLe, // not-greater |
| 284 | |
| 285 | kX86CondNle = 0xf, // not-less-than |
| 286 | kX86CondG = kX86CondNle,// greater |
| 287 | }; |
| 288 | |
| 289 | std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind); |
| 290 | |
| 291 | enum ThrowKind { |
| 292 | kThrowNullPointer, |
| 293 | kThrowDivZero, |
| 294 | kThrowArrayBounds, |
| 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 { |
| 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 |
| 337 | }; |
| 338 | |
| 339 | std::ostream& operator<<(std::ostream& os, const DataFlowAnalysisMode& mode); |
| 340 | |
buzbee | 1bc37c6 | 2012-11-20 13:35:41 -0800 | [diff] [blame] | 341 | // Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers") |
| 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 | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 351 | } // namespace art |
| 352 | |
| 353 | #endif // ART_SRC_COMPILER_COMPILERENUMS_H_ |