blob: cd2b1cb5ccc0b3551d86b76929b015c32bb94a6d [file] [log] [blame]
buzbee67bf8852011-08-17 17:51:35 -07001/*
2 * Copyright (C) 2011 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_DATAFLOW_H_
18#define ART_SRC_COMPILER_DATAFLOW_H_
19
20#include "Dalvik.h"
21#include "CompilerInternals.h"
22
Elliott Hughes11d1b0c2012-01-23 16:57:47 -080023namespace art {
24
buzbee67bf8852011-08-17 17:51:35 -070025typedef enum DataFlowAttributePos {
26 kUA = 0,
27 kUB,
28 kUC,
29 kUAWide,
30 kUBWide,
31 kUCWide,
32 kDA,
33 kDAWide,
34 kIsMove,
35 kIsLinear,
36 kSetsConst,
37 kFormat35c,
38 kFormat3rc,
39 kPhi,
buzbee43a36422011-09-14 14:00:13 -070040 kNullCheckSrc0, // Null check of src[0]
41 kNullCheckSrc1, // Null check of src[1]
42 kNullCheckOut0, // Null check out outgoing arg0
43 kDstNonNull, // May assume dst is non-null
44 kRetNonNull, // May assume retval is non-null
45 kNullTransferSrc0, // Object copy src[0] -> dst
46 kNullTransferSrcN, // Phi null check state transfer
47 kRangeCheckSrc1, // Range check of src[1]
48 kRangeCheckSrc2, // Range check of src[2]
buzbee67bf8852011-08-17 17:51:35 -070049 kFPA,
50 kFPB,
51 kFPC,
buzbee67bc2362011-10-11 18:08:40 -070052 kCoreA,
53 kCoreB,
54 kCoreC,
buzbee67bf8852011-08-17 17:51:35 -070055 kGetter,
56 kSetter,
57} DataFlowAttributes;
58
59#define DF_NOP 0
60#define DF_UA (1 << kUA)
61#define DF_UB (1 << kUB)
62#define DF_UC (1 << kUC)
63#define DF_UA_WIDE (1 << kUAWide)
64#define DF_UB_WIDE (1 << kUBWide)
65#define DF_UC_WIDE (1 << kUCWide)
66#define DF_DA (1 << kDA)
67#define DF_DA_WIDE (1 << kDAWide)
68#define DF_IS_MOVE (1 << kIsMove)
69#define DF_IS_LINEAR (1 << kIsLinear)
70#define DF_SETS_CONST (1 << kSetsConst)
71#define DF_FORMAT_35C (1 << kFormat35c)
72#define DF_FORMAT_3RC (1 << kFormat3rc)
73#define DF_PHI (1 << kPhi)
buzbee43a36422011-09-14 14:00:13 -070074#define DF_NULL_CHK_0 (1 << kNullCheckSrc0)
75#define DF_NULL_CHK_1 (1 << kNullCheckSrc1)
76#define DF_NULL_CHK_OUT0 (1 << kNullCheckOut0)
77#define DF_NON_NULL_DST (1 << kDstNonNull)
78#define DF_NON_NULL_RET (1 << kRetNonNull)
79#define DF_NULL_TRANSFER_0 (1 << kNullTransferSrc0)
80#define DF_NULL_TRANSFER_N (1 << kNullTransferSrcN)
81#define DF_RANGE_CHK_1 (1 << kRangeCheckSrc1)
82#define DF_RANGE_CHK_2 (1 << kRangeCheckSrc2)
buzbee67bf8852011-08-17 17:51:35 -070083#define DF_FP_A (1 << kFPA)
84#define DF_FP_B (1 << kFPB)
85#define DF_FP_C (1 << kFPC)
buzbee67bc2362011-10-11 18:08:40 -070086#define DF_CORE_A (1 << kCoreA)
87#define DF_CORE_B (1 << kCoreB)
88#define DF_CORE_C (1 << kCoreC)
buzbee67bf8852011-08-17 17:51:35 -070089#define DF_IS_GETTER (1 << kGetter)
90#define DF_IS_SETTER (1 << kSetter)
91
92#define DF_HAS_USES (DF_UA | DF_UB | DF_UC | DF_UA_WIDE | \
93 DF_UB_WIDE | DF_UC_WIDE)
94
95#define DF_HAS_DEFS (DF_DA | DF_DA_WIDE)
96
buzbee43a36422011-09-14 14:00:13 -070097#define DF_HAS_NULL_CHKS (DF_NULL_CHK_0 | \
98 DF_NULL_CHK_1 | \
99 DF_NULL_CHK_OUT0)
100
101#define DF_HAS_NR_CHKS (DF_HAS_NULL_CHKS | \
102 DF_RANGE_CHK_1 | \
103 DF_RANGE_CHK_2)
buzbee67bf8852011-08-17 17:51:35 -0700104
105#define DF_A_IS_REG (DF_UA | DF_UA_WIDE | DF_DA | DF_DA_WIDE)
106#define DF_B_IS_REG (DF_UB | DF_UB_WIDE)
107#define DF_C_IS_REG (DF_UC | DF_UC_WIDE)
108#define DF_IS_GETTER_OR_SETTER (DF_IS_GETTER | DF_IS_SETTER)
buzbee99ba9642012-01-25 14:23:14 -0800109#define DF_USES_FP (DF_FP_A | DF_FP_B | DF_FP_C)
buzbee67bf8852011-08-17 17:51:35 -0700110
111extern int oatDataFlowAttributes[kMirOpLast];
112
113typedef struct BasicBlockDataFlow {
114 ArenaBitVector* useV;
115 ArenaBitVector* defV;
116 ArenaBitVector* liveInV;
117 ArenaBitVector* phiV;
118 int* dalvikToSSAMap;
buzbee43a36422011-09-14 14:00:13 -0700119 ArenaBitVector* endingNullCheckV;
buzbee67bf8852011-08-17 17:51:35 -0700120} BasicBlockDataFlow;
121
122typedef struct SSARepresentation {
123 int numUses;
124 int* uses;
125 bool* fpUse;
126 int numDefs;
127 int* defs;
128 bool* fpDef;
129} SSARepresentation;
130
131/*
132 * An induction variable is represented by "m*i + c", where i is a basic
133 * induction variable.
134 */
135typedef struct InductionVariableInfo {
136 int ssaReg;
137 int basicSSAReg;
138 int m; // multiplier
139 int c; // constant
Ian Rogers408f79a2011-08-23 18:22:33 -0700140 int inc; // loop increment
buzbee67bf8852011-08-17 17:51:35 -0700141} InductionVariableInfo;
142
143typedef struct ArrayAccessInfo {
144 int arrayReg;
145 int ivReg;
146 int maxC; // For DIV - will affect upper bound checking
147 int minC; // For DIV - will affect lower bound checking
148} ArrayAccessInfo;
149
150#define ENCODE_REG_SUB(r,s) ((s<<16) | r)
151#define DECODE_REG(v) (v & 0xffff)
152#define DECODE_SUB(v) (((unsigned int) v) >> 16)
153
buzbee43a36422011-09-14 14:00:13 -0700154
155void oatMethodNullCheckElimination(CompilationUnit*);
156
Elliott Hughes11d1b0c2012-01-23 16:57:47 -0800157} // namespace art
158
buzbee67bf8852011-08-17 17:51:35 -0700159#endif // ART_SRC_COMPILER_DATAFLOW_H_