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 | #include "Dalvik.h" |
| 18 | #include "Dataflow.h" |
| 19 | #include "Loop.h" |
Andy McFadden | c6b25c7 | 2010-06-22 11:01:20 -0700 | [diff] [blame] | 20 | #include "libdex/OpCodeNames.h" |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 21 | |
| 22 | /* |
Dan Bornstein | 675b642 | 2010-11-19 16:01:25 -0800 | [diff] [blame] | 23 | * Main table containing data flow attributes for each bytecode. The |
| 24 | * first kNumDalvikInstructions entries are for Dalvik bytecode |
| 25 | * instructions, where extended opcode at the MIR level are appended |
| 26 | * afterwards. |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 27 | * |
| 28 | * TODO - many optimization flags are incomplete - they will only limit the |
| 29 | * scope of optimizations but will not cause mis-optimizations. |
| 30 | */ |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 31 | int dvmCompilerDataFlowAttributes[kMirOpLast] = { |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 32 | // 00 OP_NOP |
| 33 | DF_NOP, |
| 34 | |
| 35 | // 01 OP_MOVE vA, vB |
| 36 | DF_DA | DF_UB | DF_IS_MOVE, |
| 37 | |
| 38 | // 02 OP_MOVE_FROM16 vAA, vBBBB |
| 39 | DF_DA | DF_UB | DF_IS_MOVE, |
| 40 | |
| 41 | // 03 OP_MOVE_16 vAAAA, vBBBB |
| 42 | DF_DA | DF_UB | DF_IS_MOVE, |
| 43 | |
| 44 | // 04 OP_MOVE_WIDE vA, vB |
| 45 | DF_DA_WIDE | DF_UB_WIDE | DF_IS_MOVE, |
| 46 | |
| 47 | // 05 OP_MOVE_WIDE_FROM16 vAA, vBBBB |
| 48 | DF_DA_WIDE | DF_UB_WIDE | DF_IS_MOVE, |
| 49 | |
| 50 | // 06 OP_MOVE_WIDE_16 vAAAA, vBBBB |
| 51 | DF_DA_WIDE | DF_UB_WIDE | DF_IS_MOVE, |
| 52 | |
| 53 | // 07 OP_MOVE_OBJECT vA, vB |
| 54 | DF_DA | DF_UB | DF_IS_MOVE, |
| 55 | |
| 56 | // 08 OP_MOVE_OBJECT_FROM16 vAA, vBBBB |
| 57 | DF_DA | DF_UB | DF_IS_MOVE, |
| 58 | |
| 59 | // 09 OP_MOVE_OBJECT_16 vAAAA, vBBBB |
| 60 | DF_DA | DF_UB | DF_IS_MOVE, |
| 61 | |
| 62 | // 0A OP_MOVE_RESULT vAA |
| 63 | DF_DA, |
| 64 | |
| 65 | // 0B OP_MOVE_RESULT_WIDE vAA |
| 66 | DF_DA_WIDE, |
| 67 | |
| 68 | // 0C OP_MOVE_RESULT_OBJECT vAA |
| 69 | DF_DA, |
| 70 | |
| 71 | // 0D OP_MOVE_EXCEPTION vAA |
| 72 | DF_DA, |
| 73 | |
| 74 | // 0E OP_RETURN_VOID |
| 75 | DF_NOP, |
| 76 | |
| 77 | // 0F OP_RETURN vAA |
| 78 | DF_UA, |
| 79 | |
| 80 | // 10 OP_RETURN_WIDE vAA |
| 81 | DF_UA_WIDE, |
| 82 | |
| 83 | // 11 OP_RETURN_OBJECT vAA |
| 84 | DF_UA, |
| 85 | |
| 86 | // 12 OP_CONST_4 vA, #+B |
| 87 | DF_DA | DF_SETS_CONST, |
| 88 | |
| 89 | // 13 OP_CONST_16 vAA, #+BBBB |
| 90 | DF_DA | DF_SETS_CONST, |
| 91 | |
| 92 | // 14 OP_CONST vAA, #+BBBBBBBB |
| 93 | DF_DA | DF_SETS_CONST, |
| 94 | |
| 95 | // 15 OP_CONST_HIGH16 VAA, #+BBBB0000 |
| 96 | DF_DA | DF_SETS_CONST, |
| 97 | |
| 98 | // 16 OP_CONST_WIDE_16 vAA, #+BBBB |
| 99 | DF_DA_WIDE | DF_SETS_CONST, |
| 100 | |
| 101 | // 17 OP_CONST_WIDE_32 vAA, #+BBBBBBBB |
| 102 | DF_DA_WIDE | DF_SETS_CONST, |
| 103 | |
| 104 | // 18 OP_CONST_WIDE vAA, #+BBBBBBBBBBBBBBBB |
| 105 | DF_DA_WIDE | DF_SETS_CONST, |
| 106 | |
| 107 | // 19 OP_CONST_WIDE_HIGH16 vAA, #+BBBB000000000000 |
| 108 | DF_DA_WIDE | DF_SETS_CONST, |
| 109 | |
| 110 | // 1A OP_CONST_STRING vAA, string@BBBB |
| 111 | DF_DA, |
| 112 | |
| 113 | // 1B OP_CONST_STRING_JUMBO vAA, string@BBBBBBBB |
| 114 | DF_DA, |
| 115 | |
| 116 | // 1C OP_CONST_CLASS vAA, type@BBBB |
| 117 | DF_DA, |
| 118 | |
| 119 | // 1D OP_MONITOR_ENTER vAA |
| 120 | DF_UA, |
| 121 | |
| 122 | // 1E OP_MONITOR_EXIT vAA |
| 123 | DF_UA, |
| 124 | |
| 125 | // 1F OP_CHECK_CAST vAA, type@BBBB |
| 126 | DF_UA, |
| 127 | |
| 128 | // 20 OP_INSTANCE_OF vA, vB, type@CCCC |
| 129 | DF_DA | DF_UB, |
| 130 | |
| 131 | // 21 OP_ARRAY_LENGTH vA, vB |
| 132 | DF_DA | DF_UB, |
| 133 | |
| 134 | // 22 OP_NEW_INSTANCE vAA, type@BBBB |
| 135 | DF_DA, |
| 136 | |
| 137 | // 23 OP_NEW_ARRAY vA, vB, type@CCCC |
| 138 | DF_DA | DF_UB, |
| 139 | |
| 140 | // 24 OP_FILLED_NEW_ARRAY {vD, vE, vF, vG, vA} |
| 141 | DF_FORMAT_35C, |
| 142 | |
| 143 | // 25 OP_FILLED_NEW_ARRAY_RANGE {vCCCC .. vNNNN}, type@BBBB |
| 144 | DF_FORMAT_3RC, |
| 145 | |
| 146 | // 26 OP_FILL_ARRAY_DATA vAA, +BBBBBBBB |
| 147 | DF_UA, |
| 148 | |
| 149 | // 27 OP_THROW vAA |
| 150 | DF_UA, |
| 151 | |
| 152 | // 28 OP_GOTO |
| 153 | DF_NOP, |
| 154 | |
| 155 | // 29 OP_GOTO_16 |
| 156 | DF_NOP, |
| 157 | |
| 158 | // 2A OP_GOTO_32 |
| 159 | DF_NOP, |
| 160 | |
| 161 | // 2B OP_PACKED_SWITCH vAA, +BBBBBBBB |
| 162 | DF_UA, |
| 163 | |
| 164 | // 2C OP_SPARSE_SWITCH vAA, +BBBBBBBB |
| 165 | DF_UA, |
| 166 | |
| 167 | // 2D OP_CMPL_FLOAT vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 168 | DF_DA | DF_UB | DF_UC | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 169 | |
| 170 | // 2E OP_CMPG_FLOAT vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 171 | DF_DA | DF_UB | DF_UC | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 172 | |
| 173 | // 2F OP_CMPL_DOUBLE vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 174 | DF_DA | DF_UB_WIDE | DF_UC_WIDE | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 175 | |
| 176 | // 30 OP_CMPG_DOUBLE vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 177 | DF_DA | DF_UB_WIDE | DF_UC_WIDE | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 178 | |
| 179 | // 31 OP_CMP_LONG vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 180 | DF_DA | DF_UB_WIDE | DF_UC_WIDE, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 181 | |
| 182 | // 32 OP_IF_EQ vA, vB, +CCCC |
| 183 | DF_UA | DF_UB, |
| 184 | |
| 185 | // 33 OP_IF_NE vA, vB, +CCCC |
| 186 | DF_UA | DF_UB, |
| 187 | |
| 188 | // 34 OP_IF_LT vA, vB, +CCCC |
| 189 | DF_UA | DF_UB, |
| 190 | |
| 191 | // 35 OP_IF_GE vA, vB, +CCCC |
| 192 | DF_UA | DF_UB, |
| 193 | |
| 194 | // 36 OP_IF_GT vA, vB, +CCCC |
| 195 | DF_UA | DF_UB, |
| 196 | |
| 197 | // 37 OP_IF_LE vA, vB, +CCCC |
| 198 | DF_UA | DF_UB, |
| 199 | |
| 200 | |
| 201 | // 38 OP_IF_EQZ vAA, +BBBB |
| 202 | DF_UA, |
| 203 | |
| 204 | // 39 OP_IF_NEZ vAA, +BBBB |
| 205 | DF_UA, |
| 206 | |
| 207 | // 3A OP_IF_LTZ vAA, +BBBB |
| 208 | DF_UA, |
| 209 | |
| 210 | // 3B OP_IF_GEZ vAA, +BBBB |
| 211 | DF_UA, |
| 212 | |
| 213 | // 3C OP_IF_GTZ vAA, +BBBB |
| 214 | DF_UA, |
| 215 | |
| 216 | // 3D OP_IF_LEZ vAA, +BBBB |
| 217 | DF_UA, |
| 218 | |
| 219 | // 3E OP_UNUSED_3E |
| 220 | DF_NOP, |
| 221 | |
| 222 | // 3F OP_UNUSED_3F |
| 223 | DF_NOP, |
| 224 | |
| 225 | // 40 OP_UNUSED_40 |
| 226 | DF_NOP, |
| 227 | |
| 228 | // 41 OP_UNUSED_41 |
| 229 | DF_NOP, |
| 230 | |
| 231 | // 42 OP_UNUSED_42 |
| 232 | DF_NOP, |
| 233 | |
| 234 | // 43 OP_UNUSED_43 |
| 235 | DF_NOP, |
| 236 | |
| 237 | // 44 OP_AGET vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 238 | DF_DA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_0 | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 239 | |
| 240 | // 45 OP_AGET_WIDE vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 241 | DF_DA_WIDE | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_0 | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 242 | |
| 243 | // 46 OP_AGET_OBJECT vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 244 | DF_DA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_0 | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 245 | |
| 246 | // 47 OP_AGET_BOOLEAN vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 247 | DF_DA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_0 | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 248 | |
| 249 | // 48 OP_AGET_BYTE vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 250 | DF_DA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_0 | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 251 | |
| 252 | // 49 OP_AGET_CHAR vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 253 | DF_DA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_0 | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 254 | |
| 255 | // 4A OP_AGET_SHORT vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 256 | DF_DA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_0 | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 257 | |
| 258 | // 4B OP_APUT vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 259 | DF_UA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_1 | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 260 | |
| 261 | // 4C OP_APUT_WIDE vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 262 | DF_UA_WIDE | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_2 | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 263 | |
| 264 | // 4D OP_APUT_OBJECT vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 265 | DF_UA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_1 | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 266 | |
| 267 | // 4E OP_APUT_BOOLEAN vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 268 | DF_UA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_1 | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 269 | |
| 270 | // 4F OP_APUT_BYTE vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 271 | DF_UA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_1 | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 272 | |
| 273 | // 50 OP_APUT_CHAR vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 274 | DF_UA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_1 | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 275 | |
| 276 | // 51 OP_APUT_SHORT vAA, vBB, vCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 277 | DF_UA | DF_UB | DF_UC | DF_NULL_N_RANGE_CHECK_1 | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 278 | |
| 279 | // 52 OP_IGET vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 280 | DF_DA | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 281 | |
| 282 | // 53 OP_IGET_WIDE vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 283 | DF_DA_WIDE | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 284 | |
| 285 | // 54 OP_IGET_OBJECT vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 286 | DF_DA | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 287 | |
| 288 | // 55 OP_IGET_BOOLEAN vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 289 | DF_DA | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 290 | |
| 291 | // 56 OP_IGET_BYTE vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 292 | DF_DA | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 293 | |
| 294 | // 57 OP_IGET_CHAR vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 295 | DF_DA | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 296 | |
| 297 | // 58 OP_IGET_SHORT vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 298 | DF_DA | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 299 | |
| 300 | // 59 OP_IPUT vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 301 | DF_UA | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 302 | |
| 303 | // 5A OP_IPUT_WIDE vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 304 | DF_UA_WIDE | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 305 | |
| 306 | // 5B OP_IPUT_OBJECT vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 307 | DF_UA | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 308 | |
| 309 | // 5C OP_IPUT_BOOLEAN vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 310 | DF_UA | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 311 | |
| 312 | // 5D OP_IPUT_BYTE vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 313 | DF_UA | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 314 | |
| 315 | // 5E OP_IPUT_CHAR vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 316 | DF_UA | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 317 | |
| 318 | // 5F OP_IPUT_SHORT vA, vB, field@CCCC |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 319 | DF_UA | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 320 | |
| 321 | // 60 OP_SGET vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 322 | DF_DA | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 323 | |
| 324 | // 61 OP_SGET_WIDE vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 325 | DF_DA_WIDE | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 326 | |
| 327 | // 62 OP_SGET_OBJECT vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 328 | DF_DA | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 329 | |
| 330 | // 63 OP_SGET_BOOLEAN vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 331 | DF_DA | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 332 | |
| 333 | // 64 OP_SGET_BYTE vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 334 | DF_DA | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 335 | |
| 336 | // 65 OP_SGET_CHAR vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 337 | DF_DA | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 338 | |
| 339 | // 66 OP_SGET_SHORT vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 340 | DF_DA | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 341 | |
| 342 | // 67 OP_SPUT vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 343 | DF_UA | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 344 | |
| 345 | // 68 OP_SPUT_WIDE vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 346 | DF_UA_WIDE | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 347 | |
| 348 | // 69 OP_SPUT_OBJECT vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 349 | DF_UA | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 350 | |
| 351 | // 6A OP_SPUT_BOOLEAN vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 352 | DF_UA | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 353 | |
| 354 | // 6B OP_SPUT_BYTE vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 355 | DF_UA | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 356 | |
| 357 | // 6C OP_SPUT_CHAR vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 358 | DF_UA | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 359 | |
| 360 | // 6D OP_SPUT_SHORT vAA, field@BBBB |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 361 | DF_UA | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 362 | |
| 363 | // 6E OP_INVOKE_VIRTUAL {vD, vE, vF, vG, vA} |
| 364 | DF_FORMAT_35C, |
| 365 | |
| 366 | // 6F OP_INVOKE_SUPER {vD, vE, vF, vG, vA} |
| 367 | DF_FORMAT_35C, |
| 368 | |
| 369 | // 70 OP_INVOKE_DIRECT {vD, vE, vF, vG, vA} |
| 370 | DF_FORMAT_35C, |
| 371 | |
| 372 | // 71 OP_INVOKE_STATIC {vD, vE, vF, vG, vA} |
| 373 | DF_FORMAT_35C, |
| 374 | |
| 375 | // 72 OP_INVOKE_INTERFACE {vD, vE, vF, vG, vA} |
| 376 | DF_FORMAT_35C, |
| 377 | |
| 378 | // 73 OP_UNUSED_73 |
| 379 | DF_NOP, |
| 380 | |
| 381 | // 74 OP_INVOKE_VIRTUAL_RANGE {vCCCC .. vNNNN} |
| 382 | DF_FORMAT_3RC, |
| 383 | |
| 384 | // 75 OP_INVOKE_SUPER_RANGE {vCCCC .. vNNNN} |
| 385 | DF_FORMAT_3RC, |
| 386 | |
| 387 | // 76 OP_INVOKE_DIRECT_RANGE {vCCCC .. vNNNN} |
| 388 | DF_FORMAT_3RC, |
| 389 | |
| 390 | // 77 OP_INVOKE_STATIC_RANGE {vCCCC .. vNNNN} |
| 391 | DF_FORMAT_3RC, |
| 392 | |
| 393 | // 78 OP_INVOKE_INTERFACE_RANGE {vCCCC .. vNNNN} |
| 394 | DF_FORMAT_3RC, |
| 395 | |
| 396 | // 79 OP_UNUSED_79 |
| 397 | DF_NOP, |
| 398 | |
| 399 | // 7A OP_UNUSED_7A |
| 400 | DF_NOP, |
| 401 | |
| 402 | // 7B OP_NEG_INT vA, vB |
| 403 | DF_DA | DF_UB, |
| 404 | |
| 405 | // 7C OP_NOT_INT vA, vB |
| 406 | DF_DA | DF_UB, |
| 407 | |
| 408 | // 7D OP_NEG_LONG vA, vB |
| 409 | DF_DA_WIDE | DF_UB_WIDE, |
| 410 | |
| 411 | // 7E OP_NOT_LONG vA, vB |
| 412 | DF_DA_WIDE | DF_UB_WIDE, |
| 413 | |
| 414 | // 7F OP_NEG_FLOAT vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 415 | DF_DA | DF_UB | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 416 | |
| 417 | // 80 OP_NEG_DOUBLE vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 418 | DF_DA_WIDE | DF_UB_WIDE | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 419 | |
| 420 | // 81 OP_INT_TO_LONG vA, vB |
| 421 | DF_DA_WIDE | DF_UB, |
| 422 | |
| 423 | // 82 OP_INT_TO_FLOAT vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 424 | DF_DA | DF_UB | DF_FP_A, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 425 | |
| 426 | // 83 OP_INT_TO_DOUBLE vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 427 | DF_DA_WIDE | DF_UB | DF_FP_A, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 428 | |
| 429 | // 84 OP_LONG_TO_INT vA, vB |
| 430 | DF_DA | DF_UB_WIDE, |
| 431 | |
| 432 | // 85 OP_LONG_TO_FLOAT vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 433 | DF_DA | DF_UB_WIDE | DF_FP_A, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 434 | |
| 435 | // 86 OP_LONG_TO_DOUBLE vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 436 | DF_DA_WIDE | DF_UB_WIDE | DF_FP_A, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 437 | |
| 438 | // 87 OP_FLOAT_TO_INT vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 439 | DF_DA | DF_UB | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 440 | |
| 441 | // 88 OP_FLOAT_TO_LONG vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 442 | DF_DA_WIDE | DF_UB | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 443 | |
| 444 | // 89 OP_FLOAT_TO_DOUBLE vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 445 | DF_DA_WIDE | DF_UB | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 446 | |
| 447 | // 8A OP_DOUBLE_TO_INT vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 448 | DF_DA | DF_UB_WIDE | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 449 | |
| 450 | // 8B OP_DOUBLE_TO_LONG vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 451 | DF_DA_WIDE | DF_UB_WIDE | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 452 | |
| 453 | // 8C OP_DOUBLE_TO_FLOAT vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 454 | DF_DA | DF_UB_WIDE | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 455 | |
| 456 | // 8D OP_INT_TO_BYTE vA, vB |
| 457 | DF_DA | DF_UB, |
| 458 | |
| 459 | // 8E OP_INT_TO_CHAR vA, vB |
| 460 | DF_DA | DF_UB, |
| 461 | |
| 462 | // 8F OP_INT_TO_SHORT vA, vB |
| 463 | DF_DA | DF_UB, |
| 464 | |
| 465 | // 90 OP_ADD_INT vAA, vBB, vCC |
| 466 | DF_DA | DF_UB | DF_UC | DF_IS_LINEAR, |
| 467 | |
| 468 | // 91 OP_SUB_INT vAA, vBB, vCC |
| 469 | DF_DA | DF_UB | DF_UC | DF_IS_LINEAR, |
| 470 | |
| 471 | // 92 OP_MUL_INT vAA, vBB, vCC |
| 472 | DF_DA | DF_UB | DF_UC, |
| 473 | |
| 474 | // 93 OP_DIV_INT vAA, vBB, vCC |
| 475 | DF_DA | DF_UB | DF_UC, |
| 476 | |
| 477 | // 94 OP_REM_INT vAA, vBB, vCC |
| 478 | DF_DA | DF_UB | DF_UC, |
| 479 | |
| 480 | // 95 OP_AND_INT vAA, vBB, vCC |
| 481 | DF_DA | DF_UB | DF_UC, |
| 482 | |
| 483 | // 96 OP_OR_INT vAA, vBB, vCC |
| 484 | DF_DA | DF_UB | DF_UC, |
| 485 | |
| 486 | // 97 OP_XOR_INT vAA, vBB, vCC |
| 487 | DF_DA | DF_UB | DF_UC, |
| 488 | |
| 489 | // 98 OP_SHL_INT vAA, vBB, vCC |
| 490 | DF_DA | DF_UB | DF_UC, |
| 491 | |
| 492 | // 99 OP_SHR_INT vAA, vBB, vCC |
| 493 | DF_DA | DF_UB | DF_UC, |
| 494 | |
| 495 | // 9A OP_USHR_INT vAA, vBB, vCC |
| 496 | DF_DA | DF_UB | DF_UC, |
| 497 | |
| 498 | // 9B OP_ADD_LONG vAA, vBB, vCC |
| 499 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE, |
| 500 | |
| 501 | // 9C OP_SUB_LONG vAA, vBB, vCC |
| 502 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE, |
| 503 | |
| 504 | // 9D OP_MUL_LONG vAA, vBB, vCC |
| 505 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE, |
| 506 | |
| 507 | // 9E OP_DIV_LONG vAA, vBB, vCC |
| 508 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE, |
| 509 | |
| 510 | // 9F OP_REM_LONG vAA, vBB, vCC |
| 511 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE, |
| 512 | |
| 513 | // A0 OP_AND_LONG vAA, vBB, vCC |
| 514 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE, |
| 515 | |
| 516 | // A1 OP_OR_LONG vAA, vBB, vCC |
| 517 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE, |
| 518 | |
| 519 | // A2 OP_XOR_LONG vAA, vBB, vCC |
| 520 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE, |
| 521 | |
| 522 | // A3 OP_SHL_LONG vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 523 | DF_DA_WIDE | DF_UB_WIDE | DF_UC, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 524 | |
| 525 | // A4 OP_SHR_LONG vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 526 | DF_DA_WIDE | DF_UB_WIDE | DF_UC, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 527 | |
| 528 | // A5 OP_USHR_LONG vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 529 | DF_DA_WIDE | DF_UB_WIDE | DF_UC, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 530 | |
| 531 | // A6 OP_ADD_FLOAT vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 532 | DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 533 | |
| 534 | // A7 OP_SUB_FLOAT vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 535 | DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 536 | |
| 537 | // A8 OP_MUL_FLOAT vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 538 | DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 539 | |
| 540 | // A9 OP_DIV_FLOAT vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 541 | DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 542 | |
| 543 | // AA OP_REM_FLOAT vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 544 | DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 545 | |
| 546 | // AB OP_ADD_DOUBLE vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 547 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 548 | |
| 549 | // AC OP_SUB_DOUBLE vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 550 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 551 | |
| 552 | // AD OP_MUL_DOUBLE vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 553 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 554 | |
| 555 | // AE OP_DIV_DOUBLE vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 556 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 557 | |
| 558 | // AF OP_REM_DOUBLE vAA, vBB, vCC |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 559 | DF_DA_WIDE | DF_UB_WIDE | DF_UC_WIDE | DF_FP_A | DF_FP_B | DF_FP_C, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 560 | |
| 561 | // B0 OP_ADD_INT_2ADDR vA, vB |
| 562 | DF_DA | DF_UA | DF_UB, |
| 563 | |
| 564 | // B1 OP_SUB_INT_2ADDR vA, vB |
| 565 | DF_DA | DF_UA | DF_UB, |
| 566 | |
| 567 | // B2 OP_MUL_INT_2ADDR vA, vB |
| 568 | DF_DA | DF_UA | DF_UB, |
| 569 | |
| 570 | // B3 OP_DIV_INT_2ADDR vA, vB |
| 571 | DF_DA | DF_UA | DF_UB, |
| 572 | |
| 573 | // B4 OP_REM_INT_2ADDR vA, vB |
| 574 | DF_DA | DF_UA | DF_UB, |
| 575 | |
| 576 | // B5 OP_AND_INT_2ADDR vA, vB |
| 577 | DF_DA | DF_UA | DF_UB, |
| 578 | |
| 579 | // B6 OP_OR_INT_2ADDR vA, vB |
| 580 | DF_DA | DF_UA | DF_UB, |
| 581 | |
| 582 | // B7 OP_XOR_INT_2ADDR vA, vB |
| 583 | DF_DA | DF_UA | DF_UB, |
| 584 | |
| 585 | // B8 OP_SHL_INT_2ADDR vA, vB |
| 586 | DF_DA | DF_UA | DF_UB, |
| 587 | |
| 588 | // B9 OP_SHR_INT_2ADDR vA, vB |
| 589 | DF_DA | DF_UA | DF_UB, |
| 590 | |
| 591 | // BA OP_USHR_INT_2ADDR vA, vB |
| 592 | DF_DA | DF_UA | DF_UB, |
| 593 | |
| 594 | // BB OP_ADD_LONG_2ADDR vA, vB |
| 595 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE, |
| 596 | |
| 597 | // BC OP_SUB_LONG_2ADDR vA, vB |
| 598 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE, |
| 599 | |
| 600 | // BD OP_MUL_LONG_2ADDR vA, vB |
| 601 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE, |
| 602 | |
| 603 | // BE OP_DIV_LONG_2ADDR vA, vB |
| 604 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE, |
| 605 | |
| 606 | // BF OP_REM_LONG_2ADDR vA, vB |
| 607 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE, |
| 608 | |
| 609 | // C0 OP_AND_LONG_2ADDR vA, vB |
| 610 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE, |
| 611 | |
| 612 | // C1 OP_OR_LONG_2ADDR vA, vB |
| 613 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE, |
| 614 | |
| 615 | // C2 OP_XOR_LONG_2ADDR vA, vB |
| 616 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE, |
| 617 | |
| 618 | // C3 OP_SHL_LONG_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 619 | DF_DA_WIDE | DF_UA_WIDE | DF_UB, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 620 | |
| 621 | // C4 OP_SHR_LONG_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 622 | DF_DA_WIDE | DF_UA_WIDE | DF_UB, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 623 | |
| 624 | // C5 OP_USHR_LONG_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 625 | DF_DA_WIDE | DF_UA_WIDE | DF_UB, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 626 | |
| 627 | // C6 OP_ADD_FLOAT_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 628 | DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 629 | |
| 630 | // C7 OP_SUB_FLOAT_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 631 | DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 632 | |
| 633 | // C8 OP_MUL_FLOAT_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 634 | DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 635 | |
| 636 | // C9 OP_DIV_FLOAT_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 637 | DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 638 | |
| 639 | // CA OP_REM_FLOAT_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 640 | DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 641 | |
| 642 | // CB OP_ADD_DOUBLE_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 643 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 644 | |
| 645 | // CC OP_SUB_DOUBLE_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 646 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 647 | |
| 648 | // CD OP_MUL_DOUBLE_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 649 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 650 | |
| 651 | // CE OP_DIV_DOUBLE_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 652 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 653 | |
| 654 | // CF OP_REM_DOUBLE_2ADDR vA, vB |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 655 | DF_DA_WIDE | DF_UA_WIDE | DF_UB_WIDE | DF_FP_A | DF_FP_B, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 656 | |
| 657 | // D0 OP_ADD_INT_LIT16 vA, vB, #+CCCC |
| 658 | DF_DA | DF_UB, |
| 659 | |
| 660 | // D1 OP_RSUB_INT vA, vB, #+CCCC |
| 661 | DF_DA | DF_UB, |
| 662 | |
| 663 | // D2 OP_MUL_INT_LIT16 vA, vB, #+CCCC |
| 664 | DF_DA | DF_UB, |
| 665 | |
| 666 | // D3 OP_DIV_INT_LIT16 vA, vB, #+CCCC |
| 667 | DF_DA | DF_UB, |
| 668 | |
| 669 | // D4 OP_REM_INT_LIT16 vA, vB, #+CCCC |
| 670 | DF_DA | DF_UB, |
| 671 | |
| 672 | // D5 OP_AND_INT_LIT16 vA, vB, #+CCCC |
| 673 | DF_DA | DF_UB, |
| 674 | |
| 675 | // D6 OP_OR_INT_LIT16 vA, vB, #+CCCC |
| 676 | DF_DA | DF_UB, |
| 677 | |
| 678 | // D7 OP_XOR_INT_LIT16 vA, vB, #+CCCC |
| 679 | DF_DA | DF_UB, |
| 680 | |
| 681 | // D8 OP_ADD_INT_LIT8 vAA, vBB, #+CC |
| 682 | DF_DA | DF_UB | DF_IS_LINEAR, |
| 683 | |
| 684 | // D9 OP_RSUB_INT_LIT8 vAA, vBB, #+CC |
| 685 | DF_DA | DF_UB, |
| 686 | |
| 687 | // DA OP_MUL_INT_LIT8 vAA, vBB, #+CC |
| 688 | DF_DA | DF_UB, |
| 689 | |
| 690 | // DB OP_DIV_INT_LIT8 vAA, vBB, #+CC |
| 691 | DF_DA | DF_UB, |
| 692 | |
| 693 | // DC OP_REM_INT_LIT8 vAA, vBB, #+CC |
| 694 | DF_DA | DF_UB, |
| 695 | |
| 696 | // DD OP_AND_INT_LIT8 vAA, vBB, #+CC |
| 697 | DF_DA | DF_UB, |
| 698 | |
| 699 | // DE OP_OR_INT_LIT8 vAA, vBB, #+CC |
| 700 | DF_DA | DF_UB, |
| 701 | |
| 702 | // DF OP_XOR_INT_LIT8 vAA, vBB, #+CC |
| 703 | DF_DA | DF_UB, |
| 704 | |
| 705 | // E0 OP_SHL_INT_LIT8 vAA, vBB, #+CC |
| 706 | DF_DA | DF_UB, |
| 707 | |
| 708 | // E1 OP_SHR_INT_LIT8 vAA, vBB, #+CC |
| 709 | DF_DA | DF_UB, |
| 710 | |
| 711 | // E2 OP_USHR_INT_LIT8 vAA, vBB, #+CC |
| 712 | DF_DA | DF_UB, |
| 713 | |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 714 | // E3 OP_IGET_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 715 | DF_DA | DF_UB, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 716 | |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 717 | // E4 OP_IPUT_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 718 | DF_UA | DF_UB, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 719 | |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 720 | // E5 OP_SGET_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 721 | DF_DA, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 722 | |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 723 | // E6 OP_SPUT_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 724 | DF_UA, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 725 | |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 726 | // E7 OP_IGET_OBJECT_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 727 | DF_DA | DF_UB, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 728 | |
Andy McFadden | 5387824 | 2010-03-05 07:24:27 -0800 | [diff] [blame] | 729 | // E8 OP_IGET_WIDE_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 730 | DF_DA_WIDE | DF_UB, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 731 | |
Andy McFadden | 5387824 | 2010-03-05 07:24:27 -0800 | [diff] [blame] | 732 | // E9 OP_IPUT_WIDE_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 733 | DF_UA_WIDE | DF_UB, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 734 | |
Andy McFadden | 5387824 | 2010-03-05 07:24:27 -0800 | [diff] [blame] | 735 | // EA OP_SGET_WIDE_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 736 | DF_DA_WIDE, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 737 | |
Andy McFadden | 5387824 | 2010-03-05 07:24:27 -0800 | [diff] [blame] | 738 | // EB OP_SPUT_WIDE_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 739 | DF_UA_WIDE, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 740 | |
Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 741 | // EC OP_BREAKPOINT |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 742 | DF_NOP, |
| 743 | |
| 744 | // ED OP_THROW_VERIFICATION_ERROR |
| 745 | DF_NOP, |
| 746 | |
| 747 | // EE OP_EXECUTE_INLINE |
| 748 | DF_FORMAT_35C, |
| 749 | |
Andy McFadden | b0a0541 | 2009-11-19 10:23:41 -0800 | [diff] [blame] | 750 | // EF OP_EXECUTE_INLINE_RANGE |
Bill Buzbee | ce46c94 | 2009-11-20 15:41:34 -0800 | [diff] [blame] | 751 | DF_FORMAT_3RC, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 752 | |
| 753 | // F0 OP_INVOKE_DIRECT_EMPTY |
| 754 | DF_NOP, |
| 755 | |
Andy McFadden | 291758c | 2010-09-10 08:04:52 -0700 | [diff] [blame] | 756 | // F1 OP_RETURN_VOID_BARRIER |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 757 | DF_NOP, |
| 758 | |
| 759 | // F2 OP_IGET_QUICK |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 760 | DF_DA | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 761 | |
| 762 | // F3 OP_IGET_WIDE_QUICK |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 763 | DF_DA_WIDE | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 764 | |
| 765 | // F4 OP_IGET_OBJECT_QUICK |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 766 | DF_DA | DF_UB | DF_IS_GETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 767 | |
| 768 | // F5 OP_IPUT_QUICK |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 769 | DF_UA | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 770 | |
| 771 | // F6 OP_IPUT_WIDE_QUICK |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 772 | DF_UA_WIDE | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 773 | |
| 774 | // F7 OP_IPUT_OBJECT_QUICK |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 775 | DF_UA | DF_UB | DF_IS_SETTER, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 776 | |
| 777 | // F8 OP_INVOKE_VIRTUAL_QUICK |
| 778 | DF_FORMAT_35C, |
| 779 | |
| 780 | // F9 OP_INVOKE_VIRTUAL_QUICK_RANGE |
| 781 | DF_FORMAT_3RC, |
| 782 | |
| 783 | // FA OP_INVOKE_SUPER_QUICK |
| 784 | DF_FORMAT_35C, |
| 785 | |
| 786 | // FB OP_INVOKE_SUPER_QUICK_RANGE |
| 787 | DF_FORMAT_3RC, |
| 788 | |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 789 | // FC OP_IPUT_OBJECT_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 790 | DF_UA | DF_UB, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 791 | |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 792 | // FD OP_SGET_OBJECT_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 793 | DF_DA, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 794 | |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 795 | // FE OP_SPUT_OBJECT_VOLATILE |
buzbee | 35ff69b | 2010-07-29 13:17:35 -0700 | [diff] [blame] | 796 | DF_UA, |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 797 | |
| 798 | // FF OP_UNUSED_FF |
| 799 | DF_NOP, |
| 800 | |
| 801 | // Beginning of extended MIR opcodes |
| 802 | // 100 OP_MIR_PHI |
| 803 | DF_PHI | DF_DA, |
| 804 | |
| 805 | /* |
| 806 | * For extended MIR inserted at the MIR2LIR stage, it is okay to have |
| 807 | * undefined values here. |
| 808 | */ |
| 809 | }; |
| 810 | |
| 811 | /* Return the Dalvik register/subscript pair of a given SSA register */ |
| 812 | int dvmConvertSSARegToDalvik(CompilationUnit *cUnit, int ssaReg) |
| 813 | { |
| 814 | return GET_ELEM_N(cUnit->ssaToDalvikMap, int, ssaReg); |
| 815 | } |
| 816 | |
| 817 | /* |
| 818 | * Utility function to convert encoded SSA register value into Dalvik register |
| 819 | * and subscript pair. Each SSA register can be used to index the |
| 820 | * ssaToDalvikMap list to get the subscript[31..16]/dalvik_reg[15..0] mapping. |
| 821 | */ |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 822 | char *dvmCompilerGetDalvikDisassembly(DecodedInstruction *insn, |
| 823 | char *note) |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 824 | { |
| 825 | char buffer[256]; |
| 826 | int opcode = insn->opCode; |
| 827 | int dfAttributes = dvmCompilerDataFlowAttributes[opcode]; |
| 828 | char *ret; |
| 829 | |
| 830 | buffer[0] = 0; |
Andy McFadden | c6b25c7 | 2010-06-22 11:01:20 -0700 | [diff] [blame] | 831 | strcpy(buffer, dexGetOpcodeName(opcode)); |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 832 | |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 833 | if (note) |
| 834 | strcat(buffer, note); |
| 835 | |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 836 | if (dfAttributes & DF_FORMAT_35C) { |
| 837 | unsigned int i; |
| 838 | for (i = 0; i < insn->vA; i++) { |
| 839 | if (i != 0) strcat(buffer, ","); |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 840 | snprintf(buffer + strlen(buffer), 256, " v%d", insn->arg[i]); |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 841 | } |
| 842 | } |
| 843 | else if (dfAttributes & DF_FORMAT_3RC) { |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 844 | snprintf(buffer + strlen(buffer), 256, |
| 845 | " v%d..v%d", insn->vC, insn->vC + insn->vA - 1); |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 846 | } |
| 847 | else { |
| 848 | if (dfAttributes & DF_A_IS_REG) { |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 849 | snprintf(buffer + strlen(buffer), 256, " v%d", insn->vA); |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 850 | } |
| 851 | if (dfAttributes & DF_B_IS_REG) { |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 852 | snprintf(buffer + strlen(buffer), 256, ", v%d", insn->vB); |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 853 | } |
| 854 | else { |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 855 | snprintf(buffer + strlen(buffer), 256, ", (#%d)", insn->vB); |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 856 | } |
| 857 | if (dfAttributes & DF_C_IS_REG) { |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 858 | snprintf(buffer + strlen(buffer), 256, ", v%d", insn->vC); |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 859 | } |
| 860 | else { |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 861 | snprintf(buffer + strlen(buffer), 256, ", (#%d)", insn->vC); |
Ben Cheng | ccd6c01 | 2009-10-15 14:52:45 -0700 | [diff] [blame] | 862 | } |
| 863 | } |
| 864 | int length = strlen(buffer) + 1; |
| 865 | ret = dvmCompilerNew(length, false); |
| 866 | memcpy(ret, buffer, length); |
| 867 | return ret; |
| 868 | } |
| 869 | |
| 870 | /* |
| 871 | * Utility function to convert encoded SSA register value into Dalvik register |
| 872 | * and subscript pair. Each SSA register can be used to index the |
| 873 | * ssaToDalvikMap list to get the subscript[31..16]/dalvik_reg[15..0] mapping. |
| 874 | */ |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 875 | char *dvmCompilerGetSSAString(CompilationUnit *cUnit, SSARepresentation *ssaRep) |
| 876 | { |
| 877 | char buffer[256]; |
| 878 | char *ret; |
| 879 | int i; |
| 880 | |
| 881 | buffer[0] = 0; |
| 882 | for (i = 0; i < ssaRep->numDefs; i++) { |
| 883 | int ssa2DalvikValue = dvmConvertSSARegToDalvik(cUnit, ssaRep->defs[i]); |
| 884 | |
| 885 | sprintf(buffer + strlen(buffer), "s%d(v%d_%d) ", |
| 886 | ssaRep->defs[i], DECODE_REG(ssa2DalvikValue), |
| 887 | DECODE_SUB(ssa2DalvikValue)); |
| 888 | } |
| 889 | |
| 890 | if (ssaRep->numDefs) { |
| 891 | strcat(buffer, "<- "); |
| 892 | } |
| 893 | |
| 894 | for (i = 0; i < ssaRep->numUses; i++) { |
| 895 | int ssa2DalvikValue = dvmConvertSSARegToDalvik(cUnit, ssaRep->uses[i]); |
| 896 | int len = strlen(buffer); |
| 897 | |
| 898 | if (snprintf(buffer + len, 250 - len, "s%d(v%d_%d) ", |
| 899 | ssaRep->uses[i], DECODE_REG(ssa2DalvikValue), |
| 900 | DECODE_SUB(ssa2DalvikValue)) >= (250 - len)) { |
| 901 | strcat(buffer, "..."); |
| 902 | break; |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | int length = strlen(buffer) + 1; |
| 907 | ret = dvmCompilerNew(length, false); |
| 908 | memcpy(ret, buffer, length); |
| 909 | return ret; |
| 910 | } |
| 911 | |
| 912 | /* Any register that is used before being defined is considered live-in */ |
| 913 | static inline void handleLiveInUse(BitVector *useV, BitVector *defV, |
| 914 | BitVector *liveInV, int dalvikRegId) |
| 915 | { |
| 916 | dvmCompilerSetBit(useV, dalvikRegId); |
| 917 | if (!dvmIsBitSet(defV, dalvikRegId)) { |
| 918 | dvmCompilerSetBit(liveInV, dalvikRegId); |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | /* Mark a reg as being defined */ |
| 923 | static inline void handleLiveInDef(BitVector *defV, int dalvikRegId) |
| 924 | { |
| 925 | dvmCompilerSetBit(defV, dalvikRegId); |
| 926 | } |
| 927 | |
| 928 | /* |
| 929 | * Find out live-in variables for natural loops. Variables that are live-in in |
| 930 | * the main loop body are considered to be defined in the entry block. |
| 931 | */ |
| 932 | void dvmCompilerFindLiveIn(CompilationUnit *cUnit, BasicBlock *bb) |
| 933 | { |
| 934 | MIR *mir; |
| 935 | BitVector *useV, *defV, *liveInV; |
| 936 | |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 937 | if (bb->blockType != kDalvikByteCode && |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 938 | bb->blockType != kTraceEntryBlock) { |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 939 | return; |
| 940 | } |
| 941 | |
| 942 | useV = bb->dataFlowInfo->useV = |
| 943 | dvmCompilerAllocBitVector(cUnit->method->registersSize, false); |
| 944 | defV = bb->dataFlowInfo->defV = |
| 945 | dvmCompilerAllocBitVector(cUnit->method->registersSize, false); |
| 946 | liveInV = bb->dataFlowInfo->liveInV = |
| 947 | dvmCompilerAllocBitVector(cUnit->method->registersSize, false); |
| 948 | |
| 949 | for (mir = bb->firstMIRInsn; mir; mir = mir->next) { |
| 950 | int dfAttributes = |
| 951 | dvmCompilerDataFlowAttributes[mir->dalvikInsn.opCode]; |
| 952 | DecodedInstruction *dInsn = &mir->dalvikInsn; |
| 953 | |
| 954 | if (dfAttributes & DF_HAS_USES) { |
| 955 | if (dfAttributes & DF_UA) { |
| 956 | handleLiveInUse(useV, defV, liveInV, dInsn->vA); |
| 957 | } else if (dfAttributes & DF_UA_WIDE) { |
| 958 | handleLiveInUse(useV, defV, liveInV, dInsn->vA); |
| 959 | handleLiveInUse(useV, defV, liveInV, dInsn->vA+1); |
| 960 | } |
| 961 | if (dfAttributes & DF_UB) { |
| 962 | handleLiveInUse(useV, defV, liveInV, dInsn->vB); |
| 963 | } else if (dfAttributes & DF_UB_WIDE) { |
| 964 | handleLiveInUse(useV, defV, liveInV, dInsn->vB); |
| 965 | handleLiveInUse(useV, defV, liveInV, dInsn->vB+1); |
| 966 | } |
| 967 | if (dfAttributes & DF_UC) { |
| 968 | handleLiveInUse(useV, defV, liveInV, dInsn->vC); |
| 969 | } else if (dfAttributes & DF_UC_WIDE) { |
| 970 | handleLiveInUse(useV, defV, liveInV, dInsn->vC); |
| 971 | handleLiveInUse(useV, defV, liveInV, dInsn->vC+1); |
| 972 | } |
| 973 | } |
| 974 | if (dfAttributes & DF_HAS_DEFS) { |
| 975 | handleLiveInDef(defV, dInsn->vA); |
| 976 | if (dfAttributes & DF_DA_WIDE) { |
| 977 | handleLiveInDef(defV, dInsn->vA+1); |
| 978 | } |
| 979 | } |
| 980 | } |
| 981 | } |
| 982 | |
| 983 | /* Find out the latest SSA register for a given Dalvik register */ |
| 984 | static void handleSSAUse(CompilationUnit *cUnit, int *uses, int dalvikReg, |
| 985 | int regIndex) |
| 986 | { |
| 987 | int encodedValue = cUnit->dalvikToSSAMap[dalvikReg]; |
| 988 | int ssaReg = DECODE_REG(encodedValue); |
| 989 | uses[regIndex] = ssaReg; |
| 990 | } |
| 991 | |
| 992 | /* Setup a new SSA register for a given Dalvik register */ |
| 993 | static void handleSSADef(CompilationUnit *cUnit, int *defs, int dalvikReg, |
| 994 | int regIndex) |
| 995 | { |
| 996 | int encodedValue = cUnit->dalvikToSSAMap[dalvikReg]; |
| 997 | int ssaReg = cUnit->numSSARegs++; |
| 998 | /* Bump up the subscript */ |
| 999 | int dalvikSub = DECODE_SUB(encodedValue) + 1; |
| 1000 | int newD2SMapping = ENCODE_REG_SUB(ssaReg, dalvikSub); |
| 1001 | |
| 1002 | cUnit->dalvikToSSAMap[dalvikReg] = newD2SMapping; |
| 1003 | |
| 1004 | int newS2DMapping = ENCODE_REG_SUB(dalvikReg, dalvikSub); |
| 1005 | dvmInsertGrowableList(cUnit->ssaToDalvikMap, (void *) newS2DMapping); |
| 1006 | |
| 1007 | defs[regIndex] = ssaReg; |
| 1008 | } |
| 1009 | |
| 1010 | /* Loop up new SSA names for format_35c instructions */ |
| 1011 | static void dataFlowSSAFormat35C(CompilationUnit *cUnit, MIR *mir) |
| 1012 | { |
| 1013 | DecodedInstruction *dInsn = &mir->dalvikInsn; |
| 1014 | int numUses = dInsn->vA; |
| 1015 | int i; |
| 1016 | |
| 1017 | mir->ssaRep->numUses = numUses; |
| 1018 | mir->ssaRep->uses = dvmCompilerNew(sizeof(int) * numUses, false); |
| 1019 | |
| 1020 | for (i = 0; i < numUses; i++) { |
| 1021 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->arg[i], i); |
| 1022 | } |
| 1023 | } |
| 1024 | |
| 1025 | /* Loop up new SSA names for format_3rc instructions */ |
| 1026 | static void dataFlowSSAFormat3RC(CompilationUnit *cUnit, MIR *mir) |
| 1027 | { |
| 1028 | DecodedInstruction *dInsn = &mir->dalvikInsn; |
| 1029 | int numUses = dInsn->vA; |
| 1030 | int i; |
| 1031 | |
| 1032 | mir->ssaRep->numUses = numUses; |
| 1033 | mir->ssaRep->uses = dvmCompilerNew(sizeof(int) * numUses, false); |
| 1034 | |
| 1035 | for (i = 0; i < numUses; i++) { |
| 1036 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vC+i, i); |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | /* Entry function to convert a block into SSA representation */ |
| 1041 | void dvmCompilerDoSSAConversion(CompilationUnit *cUnit, BasicBlock *bb) |
| 1042 | { |
| 1043 | MIR *mir; |
| 1044 | |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 1045 | if (bb->blockType != kDalvikByteCode && bb->blockType != kTraceEntryBlock) { |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1046 | return; |
| 1047 | } |
| 1048 | |
| 1049 | for (mir = bb->firstMIRInsn; mir; mir = mir->next) { |
| 1050 | mir->ssaRep = dvmCompilerNew(sizeof(SSARepresentation), true); |
| 1051 | |
| 1052 | int dfAttributes = |
| 1053 | dvmCompilerDataFlowAttributes[mir->dalvikInsn.opCode]; |
| 1054 | |
| 1055 | int numUses = 0; |
| 1056 | |
| 1057 | if (dfAttributes & DF_FORMAT_35C) { |
| 1058 | dataFlowSSAFormat35C(cUnit, mir); |
| 1059 | continue; |
| 1060 | } |
| 1061 | |
| 1062 | if (dfAttributes & DF_FORMAT_3RC) { |
| 1063 | dataFlowSSAFormat3RC(cUnit, mir); |
| 1064 | continue; |
| 1065 | } |
| 1066 | |
| 1067 | if (dfAttributes & DF_HAS_USES) { |
| 1068 | if (dfAttributes & DF_UA) { |
| 1069 | numUses++; |
| 1070 | } else if (dfAttributes & DF_UA_WIDE) { |
| 1071 | numUses += 2; |
| 1072 | } |
| 1073 | if (dfAttributes & DF_UB) { |
| 1074 | numUses++; |
| 1075 | } else if (dfAttributes & DF_UB_WIDE) { |
| 1076 | numUses += 2; |
| 1077 | } |
| 1078 | if (dfAttributes & DF_UC) { |
| 1079 | numUses++; |
| 1080 | } else if (dfAttributes & DF_UC_WIDE) { |
| 1081 | numUses += 2; |
| 1082 | } |
| 1083 | } |
| 1084 | |
| 1085 | if (numUses) { |
| 1086 | mir->ssaRep->numUses = numUses; |
| 1087 | mir->ssaRep->uses = dvmCompilerNew(sizeof(int) * numUses, false); |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1088 | mir->ssaRep->fpUse = dvmCompilerNew(sizeof(bool) * numUses, false); |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1089 | } |
| 1090 | |
| 1091 | int numDefs = 0; |
| 1092 | |
| 1093 | if (dfAttributes & DF_HAS_DEFS) { |
| 1094 | numDefs++; |
| 1095 | if (dfAttributes & DF_DA_WIDE) { |
| 1096 | numDefs++; |
| 1097 | } |
| 1098 | } |
| 1099 | |
| 1100 | if (numDefs) { |
| 1101 | mir->ssaRep->numDefs = numDefs; |
| 1102 | mir->ssaRep->defs = dvmCompilerNew(sizeof(int) * numDefs, false); |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1103 | mir->ssaRep->fpDef = dvmCompilerNew(sizeof(bool) * numDefs, false); |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1104 | } |
| 1105 | |
| 1106 | DecodedInstruction *dInsn = &mir->dalvikInsn; |
| 1107 | |
| 1108 | if (dfAttributes & DF_HAS_USES) { |
| 1109 | numUses = 0; |
| 1110 | if (dfAttributes & DF_UA) { |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1111 | mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_A; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1112 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vA, numUses++); |
| 1113 | } else if (dfAttributes & DF_UA_WIDE) { |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1114 | mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_A; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1115 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vA, numUses++); |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1116 | mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_A; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1117 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vA+1, numUses++); |
| 1118 | } |
| 1119 | if (dfAttributes & DF_UB) { |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1120 | mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_B; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1121 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vB, numUses++); |
| 1122 | } else if (dfAttributes & DF_UB_WIDE) { |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1123 | mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_B; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1124 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vB, numUses++); |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1125 | mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_B; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1126 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vB+1, numUses++); |
| 1127 | } |
| 1128 | if (dfAttributes & DF_UC) { |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1129 | mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_C; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1130 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vC, numUses++); |
| 1131 | } else if (dfAttributes & DF_UC_WIDE) { |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1132 | mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_C; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1133 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vC, numUses++); |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1134 | mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_C; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1135 | handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vC+1, numUses++); |
| 1136 | } |
| 1137 | } |
| 1138 | if (dfAttributes & DF_HAS_DEFS) { |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1139 | mir->ssaRep->fpDef[0] = dfAttributes & DF_FP_A; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1140 | handleSSADef(cUnit, mir->ssaRep->defs, dInsn->vA, 0); |
| 1141 | if (dfAttributes & DF_DA_WIDE) { |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1142 | mir->ssaRep->fpDef[1] = dfAttributes & DF_FP_A; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1143 | handleSSADef(cUnit, mir->ssaRep->defs, dInsn->vA+1, 1); |
| 1144 | } |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | bb->dataFlowInfo->dalvikToSSAMap = |
| 1149 | dvmCompilerNew(sizeof(int) * cUnit->method->registersSize, false); |
| 1150 | |
| 1151 | /* Take a snapshot of Dalvik->SSA mapping at the end of each block */ |
| 1152 | memcpy(bb->dataFlowInfo->dalvikToSSAMap, cUnit->dalvikToSSAMap, |
| 1153 | sizeof(int) * cUnit->method->registersSize); |
| 1154 | } |
| 1155 | |
| 1156 | /* Setup a constant value for opcodes thare have the DF_SETS_CONST attribute */ |
| 1157 | static void setConstant(CompilationUnit *cUnit, int ssaReg, int value) |
| 1158 | { |
| 1159 | dvmSetBit(cUnit->isConstantV, ssaReg); |
| 1160 | cUnit->constantValues[ssaReg] = value; |
| 1161 | } |
| 1162 | |
| 1163 | void dvmCompilerDoConstantPropagation(CompilationUnit *cUnit, BasicBlock *bb) |
| 1164 | { |
| 1165 | MIR *mir; |
| 1166 | BitVector *isConstantV = cUnit->isConstantV; |
| 1167 | |
| 1168 | for (mir = bb->firstMIRInsn; mir; mir = mir->next) { |
| 1169 | int dfAttributes = |
| 1170 | dvmCompilerDataFlowAttributes[mir->dalvikInsn.opCode]; |
| 1171 | |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1172 | DecodedInstruction *dInsn = &mir->dalvikInsn; |
| 1173 | |
| 1174 | if (!(dfAttributes & DF_HAS_DEFS)) continue; |
| 1175 | |
| 1176 | /* Handle instructions that set up constants directly */ |
| 1177 | if (dfAttributes & DF_SETS_CONST) { |
| 1178 | if (dfAttributes & DF_DA) { |
| 1179 | switch (dInsn->opCode) { |
| 1180 | case OP_CONST_4: |
| 1181 | case OP_CONST_16: |
| 1182 | case OP_CONST: |
| 1183 | setConstant(cUnit, mir->ssaRep->defs[0], dInsn->vB); |
| 1184 | break; |
| 1185 | case OP_CONST_HIGH16: |
| 1186 | setConstant(cUnit, mir->ssaRep->defs[0], |
| 1187 | dInsn->vB << 16); |
| 1188 | break; |
| 1189 | default: |
| 1190 | break; |
| 1191 | } |
| 1192 | } else if (dfAttributes & DF_DA_WIDE) { |
| 1193 | switch (dInsn->opCode) { |
| 1194 | case OP_CONST_WIDE_16: |
| 1195 | case OP_CONST_WIDE_32: |
| 1196 | setConstant(cUnit, mir->ssaRep->defs[0], dInsn->vB); |
| 1197 | setConstant(cUnit, mir->ssaRep->defs[1], 0); |
| 1198 | break; |
| 1199 | case OP_CONST_WIDE: |
| 1200 | setConstant(cUnit, mir->ssaRep->defs[0], |
| 1201 | (int) dInsn->vB_wide); |
| 1202 | setConstant(cUnit, mir->ssaRep->defs[1], |
| 1203 | (int) (dInsn->vB_wide >> 32)); |
| 1204 | break; |
| 1205 | case OP_CONST_WIDE_HIGH16: |
| 1206 | setConstant(cUnit, mir->ssaRep->defs[0], 0); |
| 1207 | setConstant(cUnit, mir->ssaRep->defs[1], |
| 1208 | dInsn->vB << 16); |
| 1209 | break; |
| 1210 | default: |
| 1211 | break; |
| 1212 | } |
| 1213 | } |
| 1214 | /* Handle instructions that set up constants directly */ |
| 1215 | } else if (dfAttributes & DF_IS_MOVE) { |
| 1216 | int i; |
| 1217 | |
| 1218 | for (i = 0; i < mir->ssaRep->numUses; i++) { |
| 1219 | if (!dvmIsBitSet(isConstantV, mir->ssaRep->uses[i])) break; |
| 1220 | } |
| 1221 | /* Move a register holding a constant to another register */ |
| 1222 | if (i == mir->ssaRep->numUses) { |
| 1223 | setConstant(cUnit, mir->ssaRep->defs[0], |
| 1224 | cUnit->constantValues[mir->ssaRep->uses[0]]); |
| 1225 | if (dfAttributes & DF_DA_WIDE) { |
| 1226 | setConstant(cUnit, mir->ssaRep->defs[1], |
| 1227 | cUnit->constantValues[mir->ssaRep->uses[1]]); |
| 1228 | } |
| 1229 | } |
| 1230 | } |
| 1231 | } |
| 1232 | /* TODO: implement code to handle arithmetic operations */ |
| 1233 | } |
| 1234 | |
| 1235 | void dvmCompilerFindInductionVariables(struct CompilationUnit *cUnit, |
| 1236 | struct BasicBlock *bb) |
| 1237 | { |
| 1238 | BitVector *isIndVarV = cUnit->loopAnalysis->isIndVarV; |
| 1239 | BitVector *isConstantV = cUnit->isConstantV; |
| 1240 | GrowableList *ivList = cUnit->loopAnalysis->ivList; |
| 1241 | MIR *mir; |
| 1242 | |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1243 | if (bb->blockType != kDalvikByteCode && |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 1244 | bb->blockType != kTraceEntryBlock) { |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1245 | return; |
| 1246 | } |
| 1247 | |
| 1248 | /* If the bb doesn't have a phi it cannot contain an induction variable */ |
| 1249 | if (bb->firstMIRInsn == NULL || |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1250 | bb->firstMIRInsn->dalvikInsn.opCode != kMirOpPhi) { |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1251 | return; |
| 1252 | } |
| 1253 | |
| 1254 | /* Find basic induction variable first */ |
| 1255 | for (mir = bb->firstMIRInsn; mir; mir = mir->next) { |
| 1256 | int dfAttributes = |
| 1257 | dvmCompilerDataFlowAttributes[mir->dalvikInsn.opCode]; |
| 1258 | |
| 1259 | if (!(dfAttributes & DF_IS_LINEAR)) continue; |
| 1260 | |
| 1261 | /* |
| 1262 | * For a basic induction variable: |
| 1263 | * 1) use[0] should belong to the output of a phi node |
| 1264 | * 2) def[0] should belong to the input of the same phi node |
| 1265 | * 3) the value added/subtracted is a constant |
| 1266 | */ |
| 1267 | MIR *phi; |
| 1268 | for (phi = bb->firstMIRInsn; phi; phi = phi->next) { |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1269 | if (phi->dalvikInsn.opCode != kMirOpPhi) break; |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1270 | |
| 1271 | if (phi->ssaRep->defs[0] == mir->ssaRep->uses[0] && |
| 1272 | phi->ssaRep->uses[1] == mir->ssaRep->defs[0]) { |
| 1273 | bool deltaIsConstant = false; |
| 1274 | int deltaValue; |
| 1275 | |
| 1276 | switch (mir->dalvikInsn.opCode) { |
| 1277 | case OP_ADD_INT: |
| 1278 | if (dvmIsBitSet(isConstantV, |
| 1279 | mir->ssaRep->uses[1])) { |
| 1280 | deltaValue = |
| 1281 | cUnit->constantValues[mir->ssaRep->uses[1]]; |
| 1282 | deltaIsConstant = true; |
| 1283 | } |
| 1284 | break; |
| 1285 | case OP_SUB_INT: |
| 1286 | if (dvmIsBitSet(isConstantV, |
| 1287 | mir->ssaRep->uses[1])) { |
| 1288 | deltaValue = |
| 1289 | -cUnit->constantValues[mir->ssaRep->uses[1]]; |
| 1290 | deltaIsConstant = true; |
| 1291 | } |
| 1292 | break; |
| 1293 | case OP_ADD_INT_LIT8: |
| 1294 | deltaValue = mir->dalvikInsn.vC; |
| 1295 | deltaIsConstant = true; |
| 1296 | break; |
| 1297 | default: |
| 1298 | break; |
| 1299 | } |
| 1300 | if (deltaIsConstant) { |
| 1301 | dvmSetBit(isIndVarV, mir->ssaRep->uses[0]); |
| 1302 | InductionVariableInfo *ivInfo = |
| 1303 | dvmCompilerNew(sizeof(InductionVariableInfo), |
| 1304 | false); |
| 1305 | |
| 1306 | ivInfo->ssaReg = mir->ssaRep->uses[0]; |
| 1307 | ivInfo->basicSSAReg = mir->ssaRep->uses[0]; |
| 1308 | ivInfo->m = 1; // always 1 to basic iv |
| 1309 | ivInfo->c = 0; // N/A to basic iv |
| 1310 | ivInfo->inc = deltaValue; |
| 1311 | dvmInsertGrowableList(ivList, (void *) ivInfo); |
| 1312 | cUnit->loopAnalysis->numBasicIV++; |
| 1313 | break; |
| 1314 | } |
| 1315 | } |
| 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | /* Find dependent induction variable now */ |
| 1320 | for (mir = bb->firstMIRInsn; mir; mir = mir->next) { |
| 1321 | int dfAttributes = |
| 1322 | dvmCompilerDataFlowAttributes[mir->dalvikInsn.opCode]; |
| 1323 | |
| 1324 | if (!(dfAttributes & DF_IS_LINEAR)) continue; |
| 1325 | |
| 1326 | /* Skip already identified induction variables */ |
| 1327 | if (dvmIsBitSet(isIndVarV, mir->ssaRep->defs[0])) continue; |
| 1328 | |
| 1329 | /* |
| 1330 | * For a dependent induction variable: |
| 1331 | * 1) use[0] should be an induction variable (basic/dependent) |
| 1332 | * 2) operand2 should be a constant |
| 1333 | */ |
| 1334 | if (dvmIsBitSet(isIndVarV, mir->ssaRep->uses[0])) { |
| 1335 | int srcDalvikReg = dvmConvertSSARegToDalvik(cUnit, |
| 1336 | mir->ssaRep->uses[0]); |
| 1337 | int dstDalvikReg = dvmConvertSSARegToDalvik(cUnit, |
| 1338 | mir->ssaRep->defs[0]); |
| 1339 | |
| 1340 | bool cIsConstant = false; |
| 1341 | int c = 0; |
| 1342 | |
| 1343 | switch (mir->dalvikInsn.opCode) { |
| 1344 | case OP_ADD_INT: |
| 1345 | if (dvmIsBitSet(isConstantV, |
| 1346 | mir->ssaRep->uses[1])) { |
| 1347 | c = cUnit->constantValues[mir->ssaRep->uses[1]]; |
| 1348 | cIsConstant = true; |
| 1349 | } |
| 1350 | break; |
| 1351 | case OP_SUB_INT: |
| 1352 | if (dvmIsBitSet(isConstantV, |
| 1353 | mir->ssaRep->uses[1])) { |
| 1354 | c = -cUnit->constantValues[mir->ssaRep->uses[1]]; |
| 1355 | cIsConstant = true; |
| 1356 | } |
| 1357 | break; |
| 1358 | case OP_ADD_INT_LIT8: |
| 1359 | c = mir->dalvikInsn.vC; |
| 1360 | cIsConstant = true; |
| 1361 | break; |
| 1362 | default: |
| 1363 | break; |
| 1364 | } |
| 1365 | |
| 1366 | /* Ignore the update to the basic induction variable itself */ |
| 1367 | if (DECODE_REG(srcDalvikReg) == DECODE_REG(dstDalvikReg)) { |
| 1368 | cUnit->loopAnalysis->ssaBIV = mir->ssaRep->defs[0]; |
| 1369 | cIsConstant = false; |
| 1370 | } |
| 1371 | |
| 1372 | if (cIsConstant) { |
| 1373 | unsigned int i; |
| 1374 | dvmSetBit(isIndVarV, mir->ssaRep->defs[0]); |
| 1375 | InductionVariableInfo *ivInfo = |
| 1376 | dvmCompilerNew(sizeof(InductionVariableInfo), |
| 1377 | false); |
| 1378 | InductionVariableInfo *ivInfoOld = NULL ; |
| 1379 | |
| 1380 | for (i = 0; i < ivList->numUsed; i++) { |
| 1381 | ivInfoOld = ivList->elemList[i]; |
| 1382 | if (ivInfoOld->ssaReg == mir->ssaRep->uses[0]) break; |
| 1383 | } |
| 1384 | |
| 1385 | /* Guaranteed to find an element */ |
| 1386 | assert(i < ivList->numUsed); |
| 1387 | |
| 1388 | ivInfo->ssaReg = mir->ssaRep->defs[0]; |
| 1389 | ivInfo->basicSSAReg = ivInfoOld->basicSSAReg; |
| 1390 | ivInfo->m = ivInfoOld->m; |
| 1391 | ivInfo->c = c + ivInfoOld->c; |
| 1392 | ivInfo->inc = ivInfoOld->inc; |
| 1393 | dvmInsertGrowableList(ivList, (void *) ivInfo); |
| 1394 | } |
| 1395 | } |
| 1396 | } |
| 1397 | } |
| 1398 | |
| 1399 | /* Setup the basic data structures for SSA conversion */ |
| 1400 | void dvmInitializeSSAConversion(CompilationUnit *cUnit) |
| 1401 | { |
| 1402 | int i; |
| 1403 | int numDalvikReg = cUnit->method->registersSize; |
| 1404 | |
| 1405 | cUnit->ssaToDalvikMap = dvmCompilerNew(sizeof(GrowableList), false); |
| 1406 | dvmInitGrowableList(cUnit->ssaToDalvikMap, numDalvikReg); |
| 1407 | |
| 1408 | /* |
| 1409 | * Initial number of SSA registers is equal to the number of Dalvik |
| 1410 | * registers. |
| 1411 | */ |
| 1412 | cUnit->numSSARegs = numDalvikReg; |
| 1413 | |
| 1414 | /* |
| 1415 | * Initialize the SSA2Dalvik map list. For the first numDalvikReg elements, |
| 1416 | * the subscript is 0 so we use the ENCODE_REG_SUB macro to encode the value |
| 1417 | * into "(0 << 16) | i" |
| 1418 | */ |
| 1419 | for (i = 0; i < numDalvikReg; i++) { |
| 1420 | dvmInsertGrowableList(cUnit->ssaToDalvikMap, |
| 1421 | (void *) ENCODE_REG_SUB(i, 0)); |
| 1422 | } |
| 1423 | |
| 1424 | /* |
| 1425 | * Initialize the DalvikToSSAMap map. The low 16 bit is the SSA register id, |
| 1426 | * while the high 16 bit is the current subscript. The original Dalvik |
| 1427 | * register N is mapped to SSA register N with subscript 0. |
| 1428 | */ |
| 1429 | cUnit->dalvikToSSAMap = dvmCompilerNew(sizeof(int) * numDalvikReg, false); |
| 1430 | for (i = 0; i < numDalvikReg; i++) { |
| 1431 | cUnit->dalvikToSSAMap[i] = i; |
| 1432 | } |
| 1433 | |
| 1434 | /* |
| 1435 | * Allocate the BasicBlockDataFlow structure for the entry and code blocks |
| 1436 | */ |
| 1437 | for (i = 0; i < cUnit->numBlocks; i++) { |
| 1438 | BasicBlock *bb = cUnit->blockList[i]; |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 1439 | if (bb->blockType == kDalvikByteCode || |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 1440 | bb->blockType == kTraceEntryBlock) { |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 1441 | bb->dataFlowInfo = dvmCompilerNew(sizeof(BasicBlockDataFlow), true); |
| 1442 | } |
| 1443 | } |
| 1444 | } |
| 1445 | |
| 1446 | void dvmCompilerDataFlowAnalysisDispatcher(CompilationUnit *cUnit, |
| 1447 | void (*func)(CompilationUnit *, BasicBlock *)) |
| 1448 | { |
| 1449 | int i; |
| 1450 | for (i = 0; i < cUnit->numBlocks; i++) { |
| 1451 | BasicBlock *bb = cUnit->blockList[i]; |
| 1452 | (*func)(cUnit, bb); |
| 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | /* Main entry point to do SSA conversion for non-loop traces */ |
| 1457 | void dvmCompilerNonLoopAnalysis(CompilationUnit *cUnit) |
| 1458 | { |
| 1459 | dvmCompilerDataFlowAnalysisDispatcher(cUnit, dvmCompilerDoSSAConversion); |
| 1460 | } |