Home | History | Annotate | Download | only in compiler
      1 /*
      2  * Copyright (C) 2009 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 DALVIK_VM_DATAFLOW_H_
     18 #define DALVIK_VM_DATAFLOW_H_
     19 
     20 #include "Dalvik.h"
     21 #include "CompilerInternals.h"
     22 
     23 typedef enum DataFlowAttributePos {
     24     kUA = 0,
     25     kUB,
     26     kUC,
     27     kUAWide,
     28     kUBWide,
     29     kUCWide,
     30     kDA,
     31     kDAWide,
     32     kIsMove,
     33     kIsLinear,
     34     kSetsConst,
     35     kFormat35c,
     36     kFormat3rc,
     37     kPhi,
     38     kNullNRangeCheck0,
     39     kNullNRangeCheck1,
     40     kNullNRangeCheck2,
     41     kFPA,
     42     kFPB,
     43     kFPC,
     44     kGetter,
     45     kSetter,
     46 } DataFlowAttributes;
     47 
     48 #define DF_NOP                  0
     49 #define DF_UA                   (1 << kUA)
     50 #define DF_UB                   (1 << kUB)
     51 #define DF_UC                   (1 << kUC)
     52 #define DF_UA_WIDE              (1 << kUAWide)
     53 #define DF_UB_WIDE              (1 << kUBWide)
     54 #define DF_UC_WIDE              (1 << kUCWide)
     55 #define DF_DA                   (1 << kDA)
     56 #define DF_DA_WIDE              (1 << kDAWide)
     57 #define DF_IS_MOVE              (1 << kIsMove)
     58 #define DF_IS_LINEAR            (1 << kIsLinear)
     59 #define DF_SETS_CONST           (1 << kSetsConst)
     60 #define DF_FORMAT_35C           (1 << kFormat35c)
     61 #define DF_FORMAT_3RC           (1 << kFormat3rc)
     62 #define DF_PHI                  (1 << kPhi)
     63 #define DF_NULL_N_RANGE_CHECK_0 (1 << kNullNRangeCheck0)
     64 #define DF_NULL_N_RANGE_CHECK_1 (1 << kNullNRangeCheck1)
     65 #define DF_NULL_N_RANGE_CHECK_2 (1 << kNullNRangeCheck2)
     66 #define DF_FP_A                 (1 << kFPA)
     67 #define DF_FP_B                 (1 << kFPB)
     68 #define DF_FP_C                 (1 << kFPC)
     69 #define DF_IS_GETTER            (1 << kGetter)
     70 #define DF_IS_SETTER            (1 << kSetter)
     71 
     72 #define DF_HAS_USES             (DF_UA | DF_UB | DF_UC | DF_UA_WIDE | \
     73                                  DF_UB_WIDE | DF_UC_WIDE)
     74 
     75 #define DF_HAS_DEFS             (DF_DA | DF_DA_WIDE)
     76 
     77 #define DF_HAS_NR_CHECKS        (DF_NULL_N_RANGE_CHECK_0 | \
     78                                  DF_NULL_N_RANGE_CHECK_1 | \
     79                                  DF_NULL_N_RANGE_CHECK_2)
     80 
     81 #define DF_A_IS_REG             (DF_UA | DF_UA_WIDE | DF_DA | DF_DA_WIDE)
     82 #define DF_B_IS_REG             (DF_UB | DF_UB_WIDE)
     83 #define DF_C_IS_REG             (DF_UC | DF_UC_WIDE)
     84 #define DF_IS_GETTER_OR_SETTER  (DF_IS_GETTER | DF_IS_SETTER)
     85 
     86 extern int dvmCompilerDataFlowAttributes[kMirOpLast];
     87 
     88 typedef struct BasicBlockDataFlow {
     89     BitVector *useV;
     90     BitVector *defV;
     91     BitVector *liveInV;
     92     BitVector *phiV;
     93     int *dalvikToSSAMap;
     94 } BasicBlockDataFlow;
     95 
     96 typedef struct SSARepresentation {
     97     int numUses;
     98     int *uses;
     99     bool *fpUse;
    100     int numDefs;
    101     int *defs;
    102     bool *fpDef;
    103 } SSARepresentation;
    104 
    105 /*
    106  * An induction variable is represented by "m*i + c", where i is a basic
    107  * induction variable.
    108  */
    109 typedef struct InductionVariableInfo {
    110     int ssaReg;
    111     int basicSSAReg;
    112     int m;      // multiplier
    113     int c;      // constant
    114     int inc;    // loop incriment
    115 } InductionVariableInfo;
    116 
    117 typedef struct ArrayAccessInfo {
    118     int arrayReg;
    119     int ivReg;
    120     int maxC;                   // For DIV - will affect upper bound checking
    121     int minC;                   // For DIV - will affect lower bound checking
    122 } ArrayAccessInfo;
    123 
    124 #define ENCODE_REG_SUB(r,s)             ((s<<16) | r)
    125 #define DECODE_REG(v)                   (v & 0xffff)
    126 #define DECODE_SUB(v)                   (((unsigned int) v) >> 16)
    127 
    128 #endif  // DALVIK_VM_DATAFLOW_H_
    129