| Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 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, |
| Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 41 | kFPA, |
| 42 | kFPB, |
| 43 | kFPC, |
| Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 44 | } DataFlowAttributes; |
| 45 | |
| 46 | #define DF_NOP 0 |
| 47 | #define DF_UA (1 << kUA) |
| 48 | #define DF_UB (1 << kUB) |
| 49 | #define DF_UC (1 << kUC) |
| 50 | #define DF_UA_WIDE (1 << kUAWide) |
| 51 | #define DF_UB_WIDE (1 << kUBWide) |
| 52 | #define DF_UC_WIDE (1 << kUCWide) |
| 53 | #define DF_DA (1 << kDA) |
| 54 | #define DF_DA_WIDE (1 << kDAWide) |
| 55 | #define DF_IS_MOVE (1 << kIsMove) |
| 56 | #define DF_IS_LINEAR (1 << kIsLinear) |
| 57 | #define DF_SETS_CONST (1 << kSetsConst) |
| 58 | #define DF_FORMAT_35C (1 << kFormat35c) |
| 59 | #define DF_FORMAT_3RC (1 << kFormat3rc) |
| 60 | #define DF_PHI (1 << kPhi) |
| 61 | #define DF_NULL_N_RANGE_CHECK_0 (1 << kNullNRangeCheck0) |
| 62 | #define DF_NULL_N_RANGE_CHECK_1 (1 << kNullNRangeCheck1) |
| 63 | #define DF_NULL_N_RANGE_CHECK_2 (1 << kNullNRangeCheck2) |
| Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 64 | #define DF_FP_A (1 << kFPA) |
| 65 | #define DF_FP_B (1 << kFPB) |
| 66 | #define DF_FP_C (1 << kFPC) |
| Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 67 | |
| 68 | #define DF_HAS_USES (DF_UA | DF_UB | DF_UC | DF_UA_WIDE | \ |
| 69 | DF_UB_WIDE | DF_UC_WIDE) |
| 70 | |
| 71 | #define DF_HAS_DEFS (DF_DA | DF_DA_WIDE) |
| 72 | |
| 73 | #define DF_HAS_NR_CHECKS (DF_NULL_N_RANGE_CHECK_0 | \ |
| 74 | DF_NULL_N_RANGE_CHECK_1 | \ |
| 75 | DF_NULL_N_RANGE_CHECK_2) |
| 76 | |
| Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 77 | #define DF_A_IS_REG (DF_UA | DF_UA_WIDE | DF_DA | DF_DA_WIDE) |
| 78 | #define DF_B_IS_REG (DF_UB | DF_UB_WIDE) |
| 79 | #define DF_C_IS_REG (DF_UC | DF_UC_WIDE) |
| 80 | |
| Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 81 | extern int dvmCompilerDataFlowAttributes[kMirOpLast]; |
| Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 82 | |
| 83 | typedef struct BasicBlockDataFlow { |
| 84 | BitVector *useV; |
| 85 | BitVector *defV; |
| 86 | BitVector *liveInV; |
| 87 | BitVector *phiV; |
| 88 | int *dalvikToSSAMap; |
| 89 | } BasicBlockDataFlow; |
| 90 | |
| 91 | typedef struct SSARepresentation { |
| 92 | int numUses; |
| 93 | int *uses; |
| Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 94 | bool *fpUse; |
| Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 95 | int numDefs; |
| 96 | int *defs; |
| Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 97 | bool *fpDef; |
| Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 98 | } SSARepresentation; |
| 99 | |
| 100 | typedef struct InductionVariableInfo { |
| 101 | int ssaReg; |
| 102 | int basicSSAReg; |
| 103 | int m; |
| 104 | int c; |
| 105 | int inc; |
| 106 | } InductionVariableInfo; |
| 107 | |
| 108 | typedef struct ArrayAccessInfo { |
| 109 | int arrayReg; |
| 110 | int ivReg; |
| 111 | int maxC; // For DIV - will affect upper bound checking |
| 112 | int minC; // For DIV - will affect lower bound checking |
| 113 | } ArrayAccessInfo; |
| 114 | |
| 115 | #define ENCODE_REG_SUB(r,s) ((s<<16) | r) |
| 116 | #define DECODE_REG(v) (v & 0xffff) |
| 117 | #define DECODE_SUB(v) (((unsigned int) v) >> 16) |
| 118 | |
| 119 | #endif /* _DALVIK_VM_DATAFLOW */ |