buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 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, |
buzbee | 43a3642 | 2011-09-14 14:00:13 -0700 | [diff] [blame] | 38 | kNullCheckSrc0, // Null check of src[0] |
| 39 | kNullCheckSrc1, // Null check of src[1] |
| 40 | kNullCheckOut0, // Null check out outgoing arg0 |
| 41 | kDstNonNull, // May assume dst is non-null |
| 42 | kRetNonNull, // May assume retval is non-null |
| 43 | kNullTransferSrc0, // Object copy src[0] -> dst |
| 44 | kNullTransferSrcN, // Phi null check state transfer |
| 45 | kRangeCheckSrc1, // Range check of src[1] |
| 46 | kRangeCheckSrc2, // Range check of src[2] |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 47 | kFPA, |
| 48 | kFPB, |
| 49 | kFPC, |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame^] | 50 | kCoreA, |
| 51 | kCoreB, |
| 52 | kCoreC, |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 53 | kGetter, |
| 54 | kSetter, |
| 55 | } DataFlowAttributes; |
| 56 | |
| 57 | #define DF_NOP 0 |
| 58 | #define DF_UA (1 << kUA) |
| 59 | #define DF_UB (1 << kUB) |
| 60 | #define DF_UC (1 << kUC) |
| 61 | #define DF_UA_WIDE (1 << kUAWide) |
| 62 | #define DF_UB_WIDE (1 << kUBWide) |
| 63 | #define DF_UC_WIDE (1 << kUCWide) |
| 64 | #define DF_DA (1 << kDA) |
| 65 | #define DF_DA_WIDE (1 << kDAWide) |
| 66 | #define DF_IS_MOVE (1 << kIsMove) |
| 67 | #define DF_IS_LINEAR (1 << kIsLinear) |
| 68 | #define DF_SETS_CONST (1 << kSetsConst) |
| 69 | #define DF_FORMAT_35C (1 << kFormat35c) |
| 70 | #define DF_FORMAT_3RC (1 << kFormat3rc) |
| 71 | #define DF_PHI (1 << kPhi) |
buzbee | 43a3642 | 2011-09-14 14:00:13 -0700 | [diff] [blame] | 72 | #define DF_NULL_CHK_0 (1 << kNullCheckSrc0) |
| 73 | #define DF_NULL_CHK_1 (1 << kNullCheckSrc1) |
| 74 | #define DF_NULL_CHK_OUT0 (1 << kNullCheckOut0) |
| 75 | #define DF_NON_NULL_DST (1 << kDstNonNull) |
| 76 | #define DF_NON_NULL_RET (1 << kRetNonNull) |
| 77 | #define DF_NULL_TRANSFER_0 (1 << kNullTransferSrc0) |
| 78 | #define DF_NULL_TRANSFER_N (1 << kNullTransferSrcN) |
| 79 | #define DF_RANGE_CHK_1 (1 << kRangeCheckSrc1) |
| 80 | #define DF_RANGE_CHK_2 (1 << kRangeCheckSrc2) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 81 | #define DF_FP_A (1 << kFPA) |
| 82 | #define DF_FP_B (1 << kFPB) |
| 83 | #define DF_FP_C (1 << kFPC) |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame^] | 84 | #define DF_CORE_A (1 << kCoreA) |
| 85 | #define DF_CORE_B (1 << kCoreB) |
| 86 | #define DF_CORE_C (1 << kCoreC) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 87 | #define DF_IS_GETTER (1 << kGetter) |
| 88 | #define DF_IS_SETTER (1 << kSetter) |
| 89 | |
| 90 | #define DF_HAS_USES (DF_UA | DF_UB | DF_UC | DF_UA_WIDE | \ |
| 91 | DF_UB_WIDE | DF_UC_WIDE) |
| 92 | |
| 93 | #define DF_HAS_DEFS (DF_DA | DF_DA_WIDE) |
| 94 | |
buzbee | 43a3642 | 2011-09-14 14:00:13 -0700 | [diff] [blame] | 95 | #define DF_HAS_NULL_CHKS (DF_NULL_CHK_0 | \ |
| 96 | DF_NULL_CHK_1 | \ |
| 97 | DF_NULL_CHK_OUT0) |
| 98 | |
| 99 | #define DF_HAS_NR_CHKS (DF_HAS_NULL_CHKS | \ |
| 100 | DF_RANGE_CHK_1 | \ |
| 101 | DF_RANGE_CHK_2) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 102 | |
| 103 | #define DF_A_IS_REG (DF_UA | DF_UA_WIDE | DF_DA | DF_DA_WIDE) |
| 104 | #define DF_B_IS_REG (DF_UB | DF_UB_WIDE) |
| 105 | #define DF_C_IS_REG (DF_UC | DF_UC_WIDE) |
| 106 | #define DF_IS_GETTER_OR_SETTER (DF_IS_GETTER | DF_IS_SETTER) |
| 107 | |
| 108 | extern int oatDataFlowAttributes[kMirOpLast]; |
| 109 | |
| 110 | typedef struct BasicBlockDataFlow { |
| 111 | ArenaBitVector* useV; |
| 112 | ArenaBitVector* defV; |
| 113 | ArenaBitVector* liveInV; |
| 114 | ArenaBitVector* phiV; |
| 115 | int* dalvikToSSAMap; |
buzbee | 43a3642 | 2011-09-14 14:00:13 -0700 | [diff] [blame] | 116 | ArenaBitVector* endingNullCheckV; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 117 | } BasicBlockDataFlow; |
| 118 | |
| 119 | typedef struct SSARepresentation { |
| 120 | int numUses; |
| 121 | int* uses; |
| 122 | bool* fpUse; |
| 123 | int numDefs; |
| 124 | int* defs; |
| 125 | bool* fpDef; |
| 126 | } SSARepresentation; |
| 127 | |
| 128 | /* |
| 129 | * An induction variable is represented by "m*i + c", where i is a basic |
| 130 | * induction variable. |
| 131 | */ |
| 132 | typedef struct InductionVariableInfo { |
| 133 | int ssaReg; |
| 134 | int basicSSAReg; |
| 135 | int m; // multiplier |
| 136 | int c; // constant |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 137 | int inc; // loop increment |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 138 | } InductionVariableInfo; |
| 139 | |
| 140 | typedef struct ArrayAccessInfo { |
| 141 | int arrayReg; |
| 142 | int ivReg; |
| 143 | int maxC; // For DIV - will affect upper bound checking |
| 144 | int minC; // For DIV - will affect lower bound checking |
| 145 | } ArrayAccessInfo; |
| 146 | |
| 147 | #define ENCODE_REG_SUB(r,s) ((s<<16) | r) |
| 148 | #define DECODE_REG(v) (v & 0xffff) |
| 149 | #define DECODE_SUB(v) (((unsigned int) v) >> 16) |
| 150 | |
buzbee | 43a3642 | 2011-09-14 14:00:13 -0700 | [diff] [blame] | 151 | |
| 152 | void oatMethodNullCheckElimination(CompilationUnit*); |
| 153 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 154 | #endif // ART_SRC_COMPILER_DATAFLOW_H_ |