Home | History | Annotate | Download | only in ir
      1 /*
      2  * Copyright (C) 2013 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 #include "sea.h"
     18 #include "dex_instruction.h"
     19 
     20 #ifndef ART_COMPILER_SEA_IR_IR_INSTRUCTION_TOOLS_H_
     21 #define ART_COMPILER_SEA_IR_IR_INSTRUCTION_TOOLS_H_
     22 
     23 
     24 // Note: This file has content cannibalized for SEA_IR from the MIR implementation,
     25 //       to avoid having a dependence on MIR.
     26 namespace sea_ir {
     27 
     28 #define DF_NOP                  0
     29 #define DF_UA                   (1 << kUA)
     30 #define DF_UB                   (1 << kUB)
     31 #define DF_UC                   (1 << kUC)
     32 #define DF_A_WIDE               (1 << kAWide)
     33 #define DF_B_WIDE               (1 << kBWide)
     34 #define DF_C_WIDE               (1 << kCWide)
     35 #define DF_DA                   (1 << kDA)
     36 #define DF_IS_MOVE              (1 << kIsMove)
     37 #define DF_SETS_CONST           (1 << kSetsConst)
     38 #define DF_FORMAT_35C           (1 << kFormat35c)
     39 #define DF_FORMAT_3RC           (1 << kFormat3rc)
     40 #define DF_NULL_CHK_0           (1 << kNullCheckSrc0)
     41 #define DF_NULL_CHK_1           (1 << kNullCheckSrc1)
     42 #define DF_NULL_CHK_2           (1 << kNullCheckSrc2)
     43 #define DF_NULL_CHK_OUT0        (1 << kNullCheckOut0)
     44 #define DF_NON_NULL_DST         (1 << kDstNonNull)
     45 #define DF_NON_NULL_RET         (1 << kRetNonNull)
     46 #define DF_NULL_TRANSFER_0      (1 << kNullTransferSrc0)
     47 #define DF_NULL_TRANSFER_N      (1 << kNullTransferSrcN)
     48 #define DF_RANGE_CHK_1          (1 << kRangeCheckSrc1)
     49 #define DF_RANGE_CHK_2          (1 << kRangeCheckSrc2)
     50 #define DF_RANGE_CHK_3          (1 << kRangeCheckSrc3)
     51 #define DF_FP_A                 (1 << kFPA)
     52 #define DF_FP_B                 (1 << kFPB)
     53 #define DF_FP_C                 (1 << kFPC)
     54 #define DF_CORE_A               (1 << kCoreA)
     55 #define DF_CORE_B               (1 << kCoreB)
     56 #define DF_CORE_C               (1 << kCoreC)
     57 #define DF_REF_A                (1 << kRefA)
     58 #define DF_REF_B                (1 << kRefB)
     59 #define DF_REF_C                (1 << kRefC)
     60 #define DF_UMS                  (1 << kUsesMethodStar)
     61 
     62 #define DF_HAS_USES             (DF_UA | DF_UB | DF_UC)
     63 
     64 #define DF_HAS_DEFS             (DF_DA)
     65 
     66 #define DF_HAS_NULL_CHKS        (DF_NULL_CHK_0 | \
     67                                  DF_NULL_CHK_1 | \
     68                                  DF_NULL_CHK_2 | \
     69                                  DF_NULL_CHK_OUT0)
     70 
     71 #define DF_HAS_RANGE_CHKS       (DF_RANGE_CHK_1 | \
     72                                  DF_RANGE_CHK_2 | \
     73                                  DF_RANGE_CHK_3)
     74 
     75 #define DF_HAS_NR_CHKS          (DF_HAS_NULL_CHKS | \
     76                                  DF_HAS_RANGE_CHKS)
     77 
     78 #define DF_A_IS_REG             (DF_UA | DF_DA)
     79 #define DF_B_IS_REG             (DF_UB)
     80 #define DF_C_IS_REG             (DF_UC)
     81 #define DF_IS_GETTER_OR_SETTER  (DF_IS_GETTER | DF_IS_SETTER)
     82 #define DF_USES_FP              (DF_FP_A | DF_FP_B | DF_FP_C)
     83 
     84 enum DataFlowAttributePos {
     85   kUA = 0,
     86   kUB,
     87   kUC,
     88   kAWide,
     89   kBWide,
     90   kCWide,
     91   kDA,
     92   kIsMove,
     93   kSetsConst,
     94   kFormat35c,
     95   kFormat3rc,
     96   kNullCheckSrc0,        // Null check of uses[0].
     97   kNullCheckSrc1,        // Null check of uses[1].
     98   kNullCheckSrc2,        // Null check of uses[2].
     99   kNullCheckOut0,        // Null check out outgoing arg0.
    100   kDstNonNull,           // May assume dst is non-null.
    101   kRetNonNull,           // May assume retval is non-null.
    102   kNullTransferSrc0,     // Object copy src[0] -> dst.
    103   kNullTransferSrcN,     // Phi null check state transfer.
    104   kRangeCheckSrc1,       // Range check of uses[1].
    105   kRangeCheckSrc2,       // Range check of uses[2].
    106   kRangeCheckSrc3,       // Range check of uses[3].
    107   kFPA,
    108   kFPB,
    109   kFPC,
    110   kCoreA,
    111   kCoreB,
    112   kCoreC,
    113   kRefA,
    114   kRefB,
    115   kRefC,
    116   kUsesMethodStar,       // Implicit use of Method*.
    117 };
    118 
    119 class InstructionTools {
    120  public:
    121   static bool IsDefinition(const art::Instruction* instruction);
    122   static const int instruction_attributes_[];
    123 };
    124 }  // namespace sea_ir
    125 #endif  // ART_COMPILER_SEA_IR_IR_INSTRUCTION_TOOLS_H_
    126