OSDN Git Service

Implement SSA-based loop optimizations.
[android-x86/dalvik.git] / vm / compiler / Dataflow.h
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
18 #define _DALVIK_VM_DATAFLOW
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 } DataFlowAttributes;
42
43 #define DF_NOP                  0
44 #define DF_UA                   (1 << kUA)
45 #define DF_UB                   (1 << kUB)
46 #define DF_UC                   (1 << kUC)
47 #define DF_UA_WIDE              (1 << kUAWide)
48 #define DF_UB_WIDE              (1 << kUBWide)
49 #define DF_UC_WIDE              (1 << kUCWide)
50 #define DF_DA                   (1 << kDA)
51 #define DF_DA_WIDE              (1 << kDAWide)
52 #define DF_IS_MOVE              (1 << kIsMove)
53 #define DF_IS_LINEAR            (1 << kIsLinear)
54 #define DF_SETS_CONST           (1 << kSetsConst)
55 #define DF_FORMAT_35C           (1 << kFormat35c)
56 #define DF_FORMAT_3RC           (1 << kFormat3rc)
57 #define DF_PHI                  (1 << kPhi)
58 #define DF_NULL_N_RANGE_CHECK_0 (1 << kNullNRangeCheck0)
59 #define DF_NULL_N_RANGE_CHECK_1 (1 << kNullNRangeCheck1)
60 #define DF_NULL_N_RANGE_CHECK_2 (1 << kNullNRangeCheck2)
61
62 #define DF_HAS_USES             (DF_UA | DF_UB | DF_UC | DF_UA_WIDE | \
63                                  DF_UB_WIDE | DF_UC_WIDE)
64
65 #define DF_HAS_DEFS             (DF_DA | DF_DA_WIDE)
66
67 #define DF_HAS_NR_CHECKS        (DF_NULL_N_RANGE_CHECK_0 | \
68                                  DF_NULL_N_RANGE_CHECK_1 | \
69                                  DF_NULL_N_RANGE_CHECK_2)
70
71 extern int dvmCompilerDataFlowAttributes[MIR_OP_LAST];
72
73 typedef struct BasicBlockDataFlow {
74     BitVector *useV;
75     BitVector *defV;
76     BitVector *liveInV;
77     BitVector *phiV;
78     int *dalvikToSSAMap;
79 } BasicBlockDataFlow;
80
81 typedef struct SSARepresentation {
82     int numUses;
83     int *uses;
84     int numDefs;
85     int *defs;
86 } SSARepresentation;
87
88 typedef struct InductionVariableInfo {
89     int ssaReg;
90     int basicSSAReg;
91     int m;
92     int c;
93     int inc;
94 } InductionVariableInfo;
95
96 typedef struct ArrayAccessInfo {
97     int arrayReg;
98     int ivReg;
99     int maxC;                   // For DIV - will affect upper bound checking
100     int minC;                   // For DIV - will affect lower bound checking
101 } ArrayAccessInfo;
102
103 #define ENCODE_REG_SUB(r,s)             ((s<<16) | r)
104 #define DECODE_REG(v)                   (v & 0xffff)
105 #define DECODE_SUB(v)                   (((unsigned int) v) >> 16)
106
107 #endif /* _DALVIK_VM_DATAFLOW */