Home | History | Annotate | Download | only in dex
      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_COMPILER_DEX_COMPILER_ENUMS_H_
     18 #define ART_COMPILER_DEX_COMPILER_ENUMS_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 pointer.
     32   kSuspend,         // Used to reduce suspend checks for some targets.
     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 /*
     66  * Def/Use encoding in 64-bit use_mask/def_mask.  Low positions used for target-specific
     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.
     75   kDalvikReg = 60,        // Dalvik v_reg memory reference.
     76   kFPStatus = 59,
     77   kCCode = 58,
     78   kLowestCommonResource = kCCode
     79 };
     80 
     81 // Shared pseudo opcodes - must be < 0.
     82 enum LIRPseudoOpcode {
     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,
     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,
    115   kMirOpCheckPart2,
    116   kMirOpSelect,
    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 
    133 // For successor_block_list.
    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   kThrowConstantArrayBounds,
    296   kThrowNoSuchMethod,
    297   kThrowStackOverflow,
    298 };
    299 
    300 enum SpecialCaseHandler {
    301   kNoHandler,
    302   kNullMethod,
    303   kConstFunction,
    304   kIGet,
    305   kIGetBoolean,
    306   kIGetObject,
    307   kIGetByte,
    308   kIGetChar,
    309   kIGetShort,
    310   kIGetWide,
    311   kIPut,
    312   kIPutBoolean,
    313   kIPutObject,
    314   kIPutByte,
    315   kIPutChar,
    316   kIPutShort,
    317   kIPutWide,
    318   kIdentity,
    319 };
    320 
    321 enum DividePattern {
    322   DivideNone,
    323   Divide3,
    324   Divide5,
    325   Divide7,
    326 };
    327 
    328 std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
    329 
    330 // Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers").
    331 enum MemBarrierKind {
    332   kLoadStore,
    333   kLoadLoad,
    334   kStoreStore,
    335   kStoreLoad
    336 };
    337 
    338 std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
    339 
    340 enum OpFeatureFlags {
    341   kIsBranch = 0,
    342   kNoOperand,
    343   kIsUnaryOp,
    344   kIsBinaryOp,
    345   kIsTertiaryOp,
    346   kIsQuadOp,
    347   kIsQuinOp,
    348   kIsSextupleOp,
    349   kIsIT,
    350   kMemLoad,
    351   kMemStore,
    352   kPCRelFixup,  // x86 FIXME: add NEEDS_FIXUP to instruction attributes.
    353   kRegDef0,
    354   kRegDef1,
    355   kRegDefA,
    356   kRegDefD,
    357   kRegDefFPCSList0,
    358   kRegDefFPCSList2,
    359   kRegDefList0,
    360   kRegDefList1,
    361   kRegDefList2,
    362   kRegDefLR,
    363   kRegDefSP,
    364   kRegUse0,
    365   kRegUse1,
    366   kRegUse2,
    367   kRegUse3,
    368   kRegUse4,
    369   kRegUseA,
    370   kRegUseC,
    371   kRegUseD,
    372   kRegUseFPCSList0,
    373   kRegUseFPCSList2,
    374   kRegUseList0,
    375   kRegUseList1,
    376   kRegUseLR,
    377   kRegUsePC,
    378   kRegUseSP,
    379   kSetsCCodes,
    380   kUsesCCodes
    381 };
    382 
    383 enum SelectInstructionKind {
    384   kSelectNone,
    385   kSelectConst,
    386   kSelectMove,
    387   kSelectGoto
    388 };
    389 
    390 std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
    391 
    392 // Type of growable bitmap for memory tuning.
    393 enum OatBitMapKind {
    394   kBitMapMisc = 0,
    395   kBitMapUse,
    396   kBitMapDef,
    397   kBitMapLiveIn,
    398   kBitMapBMatrix,
    399   kBitMapDominators,
    400   kBitMapIDominated,
    401   kBitMapDomFrontier,
    402   kBitMapPhi,
    403   kBitMapTmpBlocks,
    404   kBitMapInputBlocks,
    405   kBitMapRegisterV,
    406   kBitMapTempSSARegisterV,
    407   kBitMapNullCheck,
    408   kBitMapTmpBlockV,
    409   kBitMapPredecessors,
    410   kNumBitMapKinds
    411 };
    412 
    413 std::ostream& operator<<(std::ostream& os, const OatBitMapKind& kind);
    414 
    415 }  // namespace art
    416 
    417 #endif  // ART_COMPILER_DEX_COMPILER_ENUMS_H_
    418