blob: 3483d5bc4502acb6d0a41385a9f777ad45d13124 [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#include "Dalvik.h"
18#include "Dataflow.h"
buzbee67bf8852011-08-17 17:51:35 -070019
Elliott Hughes11d1b0c2012-01-23 16:57:47 -080020namespace art {
21
buzbee67bf8852011-08-17 17:51:35 -070022/*
23 * Main table containing data flow attributes for each bytecode. The
24 * first kNumPackedOpcodes entries are for Dalvik bytecode
25 * instructions, where extended opcode at the MIR level are appended
26 * afterwards.
27 *
28 * TODO - many optimization flags are incomplete - they will only limit the
29 * scope of optimizations but will not cause mis-optimizations.
30 */
buzbeeba938cb2012-02-03 14:47:55 -080031const int oatDataFlowAttributes[kMirOpLast] = {
Bill Buzbeea114add2012-05-03 15:00:40 -070032 // 00 NOP
33 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -070034
Bill Buzbeea114add2012-05-03 15:00:40 -070035 // 01 MOVE vA, vB
36 DF_DA | DF_UB | DF_IS_MOVE,
buzbee67bf8852011-08-17 17:51:35 -070037
Bill Buzbeea114add2012-05-03 15:00:40 -070038 // 02 MOVE_FROM16 vAA, vBBBB
39 DF_DA | DF_UB | DF_IS_MOVE,
buzbee67bf8852011-08-17 17:51:35 -070040
Bill Buzbeea114add2012-05-03 15:00:40 -070041 // 03 MOVE_16 vAAAA, vBBBB
42 DF_DA | DF_UB | DF_IS_MOVE,
buzbee67bf8852011-08-17 17:51:35 -070043
Bill Buzbeea114add2012-05-03 15:00:40 -070044 // 04 MOVE_WIDE vA, vB
buzbeebff24652012-05-06 16:22:05 -070045 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_IS_MOVE,
buzbee67bf8852011-08-17 17:51:35 -070046
Bill Buzbeea114add2012-05-03 15:00:40 -070047 // 05 MOVE_WIDE_FROM16 vAA, vBBBB
buzbeebff24652012-05-06 16:22:05 -070048 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_IS_MOVE,
buzbee67bf8852011-08-17 17:51:35 -070049
Bill Buzbeea114add2012-05-03 15:00:40 -070050 // 06 MOVE_WIDE_16 vAAAA, vBBBB
buzbeebff24652012-05-06 16:22:05 -070051 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_IS_MOVE,
buzbee67bf8852011-08-17 17:51:35 -070052
Bill Buzbeea114add2012-05-03 15:00:40 -070053 // 07 MOVE_OBJECT vA, vB
buzbeebff24652012-05-06 16:22:05 -070054 DF_DA | DF_UB | DF_NULL_TRANSFER_0 | DF_IS_MOVE | DF_REF_A | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -070055
Bill Buzbeea114add2012-05-03 15:00:40 -070056 // 08 MOVE_OBJECT_FROM16 vAA, vBBBB
buzbeebff24652012-05-06 16:22:05 -070057 DF_DA | DF_UB | DF_NULL_TRANSFER_0 | DF_IS_MOVE | DF_REF_A | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -070058
Bill Buzbeea114add2012-05-03 15:00:40 -070059 // 09 MOVE_OBJECT_16 vAAAA, vBBBB
buzbeebff24652012-05-06 16:22:05 -070060 DF_DA | DF_UB | DF_NULL_TRANSFER_0 | DF_IS_MOVE | DF_REF_A | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -070061
Bill Buzbeea114add2012-05-03 15:00:40 -070062 // 0A MOVE_RESULT vAA
63 DF_DA,
buzbee67bf8852011-08-17 17:51:35 -070064
Bill Buzbeea114add2012-05-03 15:00:40 -070065 // 0B MOVE_RESULT_WIDE vAA
buzbeebff24652012-05-06 16:22:05 -070066 DF_DA | DF_A_WIDE,
buzbee67bf8852011-08-17 17:51:35 -070067
Bill Buzbeea114add2012-05-03 15:00:40 -070068 // 0C MOVE_RESULT_OBJECT vAA
buzbeebff24652012-05-06 16:22:05 -070069 DF_DA | DF_REF_A,
buzbee67bf8852011-08-17 17:51:35 -070070
Bill Buzbeea114add2012-05-03 15:00:40 -070071 // 0D MOVE_EXCEPTION vAA
72 DF_DA | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -070073
Bill Buzbeea114add2012-05-03 15:00:40 -070074 // 0E RETURN_VOID
75 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -070076
Bill Buzbeea114add2012-05-03 15:00:40 -070077 // 0F RETURN vAA
78 DF_UA,
buzbee67bf8852011-08-17 17:51:35 -070079
Bill Buzbeea114add2012-05-03 15:00:40 -070080 // 10 RETURN_WIDE vAA
buzbeebff24652012-05-06 16:22:05 -070081 DF_UA | DF_A_WIDE,
buzbee67bf8852011-08-17 17:51:35 -070082
Bill Buzbeea114add2012-05-03 15:00:40 -070083 // 11 RETURN_OBJECT vAA
buzbeebff24652012-05-06 16:22:05 -070084 DF_UA | DF_REF_A,
buzbee67bf8852011-08-17 17:51:35 -070085
Bill Buzbeea114add2012-05-03 15:00:40 -070086 // 12 CONST_4 vA, #+B
87 DF_DA | DF_SETS_CONST,
buzbee67bf8852011-08-17 17:51:35 -070088
Bill Buzbeea114add2012-05-03 15:00:40 -070089 // 13 CONST_16 vAA, #+BBBB
90 DF_DA | DF_SETS_CONST,
buzbee67bf8852011-08-17 17:51:35 -070091
Bill Buzbeea114add2012-05-03 15:00:40 -070092 // 14 CONST vAA, #+BBBBBBBB
93 DF_DA | DF_SETS_CONST,
buzbee67bf8852011-08-17 17:51:35 -070094
Bill Buzbeea114add2012-05-03 15:00:40 -070095 // 15 CONST_HIGH16 VAA, #+BBBB0000
96 DF_DA | DF_SETS_CONST,
buzbee67bf8852011-08-17 17:51:35 -070097
Bill Buzbeea114add2012-05-03 15:00:40 -070098 // 16 CONST_WIDE_16 vAA, #+BBBB
buzbeebff24652012-05-06 16:22:05 -070099 DF_DA | DF_A_WIDE | DF_SETS_CONST,
buzbee67bf8852011-08-17 17:51:35 -0700100
Bill Buzbeea114add2012-05-03 15:00:40 -0700101 // 17 CONST_WIDE_32 vAA, #+BBBBBBBB
buzbeebff24652012-05-06 16:22:05 -0700102 DF_DA | DF_A_WIDE | DF_SETS_CONST,
buzbee67bf8852011-08-17 17:51:35 -0700103
Bill Buzbeea114add2012-05-03 15:00:40 -0700104 // 18 CONST_WIDE vAA, #+BBBBBBBBBBBBBBBB
buzbeebff24652012-05-06 16:22:05 -0700105 DF_DA | DF_A_WIDE | DF_SETS_CONST,
buzbee67bf8852011-08-17 17:51:35 -0700106
Bill Buzbeea114add2012-05-03 15:00:40 -0700107 // 19 CONST_WIDE_HIGH16 vAA, #+BBBB000000000000
buzbeebff24652012-05-06 16:22:05 -0700108 DF_DA | DF_A_WIDE | DF_SETS_CONST,
buzbee67bf8852011-08-17 17:51:35 -0700109
Bill Buzbeea114add2012-05-03 15:00:40 -0700110 // 1A CONST_STRING vAA, string@BBBB
buzbeebff24652012-05-06 16:22:05 -0700111 DF_DA | DF_REF_A,
buzbee67bf8852011-08-17 17:51:35 -0700112
Bill Buzbeea114add2012-05-03 15:00:40 -0700113 // 1B CONST_STRING_JUMBO vAA, string@BBBBBBBB
buzbeebff24652012-05-06 16:22:05 -0700114 DF_DA | DF_REF_A,
buzbee67bf8852011-08-17 17:51:35 -0700115
Bill Buzbeea114add2012-05-03 15:00:40 -0700116 // 1C CONST_CLASS vAA, type@BBBB
buzbeebff24652012-05-06 16:22:05 -0700117 DF_DA | DF_REF_A,
buzbee67bf8852011-08-17 17:51:35 -0700118
Bill Buzbeea114add2012-05-03 15:00:40 -0700119 // 1D MONITOR_ENTER vAA
buzbeebff24652012-05-06 16:22:05 -0700120 DF_UA | DF_NULL_CHK_0 | DF_REF_A,
buzbee67bf8852011-08-17 17:51:35 -0700121
Bill Buzbeea114add2012-05-03 15:00:40 -0700122 // 1E MONITOR_EXIT vAA
buzbeebff24652012-05-06 16:22:05 -0700123 DF_UA | DF_NULL_CHK_0 | DF_REF_A,
buzbee67bf8852011-08-17 17:51:35 -0700124
Bill Buzbeea114add2012-05-03 15:00:40 -0700125 // 1F CHK_CAST vAA, type@BBBB
buzbeebff24652012-05-06 16:22:05 -0700126 DF_UA | DF_REF_A | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700127
Bill Buzbeea114add2012-05-03 15:00:40 -0700128 // 20 INSTANCE_OF vA, vB, type@CCCC
buzbeebff24652012-05-06 16:22:05 -0700129 DF_DA | DF_UB | DF_CORE_A | DF_REF_B | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700130
Bill Buzbeea114add2012-05-03 15:00:40 -0700131 // 21 ARRAY_LENGTH vA, vB
buzbeebff24652012-05-06 16:22:05 -0700132 DF_DA | DF_UB | DF_NULL_CHK_0 | DF_CORE_A | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700133
Bill Buzbeea114add2012-05-03 15:00:40 -0700134 // 22 NEW_INSTANCE vAA, type@BBBB
buzbeebff24652012-05-06 16:22:05 -0700135 DF_DA | DF_NON_NULL_DST | DF_REF_A | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700136
Bill Buzbeea114add2012-05-03 15:00:40 -0700137 // 23 NEW_ARRAY vA, vB, type@CCCC
buzbeebff24652012-05-06 16:22:05 -0700138 DF_DA | DF_UB | DF_NON_NULL_DST | DF_REF_A | DF_CORE_B | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700139
Bill Buzbeea114add2012-05-03 15:00:40 -0700140 // 24 FILLED_NEW_ARRAY {vD, vE, vF, vG, vA}
141 DF_FORMAT_35C | DF_NON_NULL_RET | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700142
Bill Buzbeea114add2012-05-03 15:00:40 -0700143 // 25 FILLED_NEW_ARRAY_RANGE {vCCCC .. vNNNN}, type@BBBB
144 DF_FORMAT_3RC | DF_NON_NULL_RET | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700145
Bill Buzbeea114add2012-05-03 15:00:40 -0700146 // 26 FILL_ARRAY_DATA vAA, +BBBBBBBB
buzbeebff24652012-05-06 16:22:05 -0700147 DF_UA | DF_REF_A | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700148
Bill Buzbeea114add2012-05-03 15:00:40 -0700149 // 27 THROW vAA
buzbeebff24652012-05-06 16:22:05 -0700150 DF_UA | DF_REF_A | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700151
Bill Buzbeea114add2012-05-03 15:00:40 -0700152 // 28 GOTO
153 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700154
Bill Buzbeea114add2012-05-03 15:00:40 -0700155 // 29 GOTO_16
156 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700157
Bill Buzbeea114add2012-05-03 15:00:40 -0700158 // 2A GOTO_32
159 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700160
Bill Buzbeea114add2012-05-03 15:00:40 -0700161 // 2B PACKED_SWITCH vAA, +BBBBBBBB
162 DF_UA,
buzbee67bf8852011-08-17 17:51:35 -0700163
Bill Buzbeea114add2012-05-03 15:00:40 -0700164 // 2C SPARSE_SWITCH vAA, +BBBBBBBB
165 DF_UA,
buzbee67bf8852011-08-17 17:51:35 -0700166
Bill Buzbeea114add2012-05-03 15:00:40 -0700167 // 2D CMPL_FLOAT vAA, vBB, vCC
168 DF_DA | DF_UB | DF_UC | DF_FP_B | DF_FP_C | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700169
Bill Buzbeea114add2012-05-03 15:00:40 -0700170 // 2E CMPG_FLOAT vAA, vBB, vCC
171 DF_DA | DF_UB | DF_UC | DF_FP_B | DF_FP_C | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700172
Bill Buzbeea114add2012-05-03 15:00:40 -0700173 // 2F CMPL_DOUBLE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700174 DF_DA | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_FP_B | DF_FP_C | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700175
Bill Buzbeea114add2012-05-03 15:00:40 -0700176 // 30 CMPG_DOUBLE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700177 DF_DA | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_FP_B | DF_FP_C | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700178
Bill Buzbeea114add2012-05-03 15:00:40 -0700179 // 31 CMP_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700180 DF_DA | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700181
Bill Buzbeea114add2012-05-03 15:00:40 -0700182 // 32 IF_EQ vA, vB, +CCCC
183 DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700184
Bill Buzbeea114add2012-05-03 15:00:40 -0700185 // 33 IF_NE vA, vB, +CCCC
186 DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700187
Bill Buzbeea114add2012-05-03 15:00:40 -0700188 // 34 IF_LT vA, vB, +CCCC
189 DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700190
Bill Buzbeea114add2012-05-03 15:00:40 -0700191 // 35 IF_GE vA, vB, +CCCC
192 DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700193
Bill Buzbeea114add2012-05-03 15:00:40 -0700194 // 36 IF_GT vA, vB, +CCCC
195 DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700196
Bill Buzbeea114add2012-05-03 15:00:40 -0700197 // 37 IF_LE vA, vB, +CCCC
198 DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700199
200
Bill Buzbeea114add2012-05-03 15:00:40 -0700201 // 38 IF_EQZ vAA, +BBBB
202 DF_UA | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700203
Bill Buzbeea114add2012-05-03 15:00:40 -0700204 // 39 IF_NEZ vAA, +BBBB
205 DF_UA | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700206
Bill Buzbeea114add2012-05-03 15:00:40 -0700207 // 3A IF_LTZ vAA, +BBBB
208 DF_UA | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700209
Bill Buzbeea114add2012-05-03 15:00:40 -0700210 // 3B IF_GEZ vAA, +BBBB
211 DF_UA | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700212
Bill Buzbeea114add2012-05-03 15:00:40 -0700213 // 3C IF_GTZ vAA, +BBBB
214 DF_UA | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700215
Bill Buzbeea114add2012-05-03 15:00:40 -0700216 // 3D IF_LEZ vAA, +BBBB
217 DF_UA | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700218
Bill Buzbeea114add2012-05-03 15:00:40 -0700219 // 3E UNUSED_3E
220 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700221
Bill Buzbeea114add2012-05-03 15:00:40 -0700222 // 3F UNUSED_3F
223 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700224
Bill Buzbeea114add2012-05-03 15:00:40 -0700225 // 40 UNUSED_40
226 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700227
Bill Buzbeea114add2012-05-03 15:00:40 -0700228 // 41 UNUSED_41
229 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700230
Bill Buzbeea114add2012-05-03 15:00:40 -0700231 // 42 UNUSED_42
232 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700233
Bill Buzbeea114add2012-05-03 15:00:40 -0700234 // 43 UNUSED_43
235 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700236
Bill Buzbeea114add2012-05-03 15:00:40 -0700237 // 44 AGET vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700238 DF_DA | DF_UB | DF_UC | DF_NULL_CHK_0 | DF_RANGE_CHK_1 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700239
Bill Buzbeea114add2012-05-03 15:00:40 -0700240 // 45 AGET_WIDE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700241 DF_DA | DF_A_WIDE | DF_UB | DF_UC | DF_NULL_CHK_0 | DF_RANGE_CHK_1 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700242
Bill Buzbeea114add2012-05-03 15:00:40 -0700243 // 46 AGET_OBJECT vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700244 DF_DA | DF_UB | DF_UC | DF_NULL_CHK_0 | DF_RANGE_CHK_1 | DF_REF_A | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700245
Bill Buzbeea114add2012-05-03 15:00:40 -0700246 // 47 AGET_BOOLEAN vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700247 DF_DA | DF_UB | DF_UC | DF_NULL_CHK_0 | DF_RANGE_CHK_1 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700248
Bill Buzbeea114add2012-05-03 15:00:40 -0700249 // 48 AGET_BYTE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700250 DF_DA | DF_UB | DF_UC | DF_NULL_CHK_0 | DF_RANGE_CHK_1 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700251
Bill Buzbeea114add2012-05-03 15:00:40 -0700252 // 49 AGET_CHAR vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700253 DF_DA | DF_UB | DF_UC | DF_NULL_CHK_0 | DF_RANGE_CHK_1 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700254
Bill Buzbeea114add2012-05-03 15:00:40 -0700255 // 4A AGET_SHORT vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700256 DF_DA | DF_UB | DF_UC | DF_NULL_CHK_0 | DF_RANGE_CHK_1 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700257
Bill Buzbeea114add2012-05-03 15:00:40 -0700258 // 4B APUT vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700259 DF_UA | DF_UB | DF_UC | DF_NULL_CHK_1 | DF_RANGE_CHK_2 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700260
Bill Buzbeea114add2012-05-03 15:00:40 -0700261 // 4C APUT_WIDE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700262 DF_UA | DF_A_WIDE | DF_UB | DF_UC | DF_NULL_CHK_2 | DF_RANGE_CHK_3 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700263
Bill Buzbeea114add2012-05-03 15:00:40 -0700264 // 4D APUT_OBJECT vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700265 DF_UA | DF_UB | DF_UC | DF_NULL_CHK_1 | DF_RANGE_CHK_2 | DF_REF_A | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700266
Bill Buzbeea114add2012-05-03 15:00:40 -0700267 // 4E APUT_BOOLEAN vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700268 DF_UA | DF_UB | DF_UC | DF_NULL_CHK_1 | DF_RANGE_CHK_2 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700269
Bill Buzbeea114add2012-05-03 15:00:40 -0700270 // 4F APUT_BYTE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700271 DF_UA | DF_UB | DF_UC | DF_NULL_CHK_1 | DF_RANGE_CHK_2 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700272
Bill Buzbeea114add2012-05-03 15:00:40 -0700273 // 50 APUT_CHAR vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700274 DF_UA | DF_UB | DF_UC | DF_NULL_CHK_1 | DF_RANGE_CHK_2 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700275
Bill Buzbeea114add2012-05-03 15:00:40 -0700276 // 51 APUT_SHORT vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700277 DF_UA | DF_UB | DF_UC | DF_NULL_CHK_1 | DF_RANGE_CHK_2 | DF_REF_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700278
Bill Buzbeea114add2012-05-03 15:00:40 -0700279 // 52 IGET vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700280 DF_DA | DF_UB | DF_NULL_CHK_0 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700281
Bill Buzbeea114add2012-05-03 15:00:40 -0700282 // 53 IGET_WIDE vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700283 DF_DA | DF_A_WIDE | DF_UB | DF_NULL_CHK_0 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700284
Bill Buzbeea114add2012-05-03 15:00:40 -0700285 // 54 IGET_OBJECT vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700286 DF_DA | DF_UB | DF_NULL_CHK_0 | DF_REF_A | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700287
Bill Buzbeea114add2012-05-03 15:00:40 -0700288 // 55 IGET_BOOLEAN vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700289 DF_DA | DF_UB | DF_NULL_CHK_0 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700290
Bill Buzbeea114add2012-05-03 15:00:40 -0700291 // 56 IGET_BYTE vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700292 DF_DA | DF_UB | DF_NULL_CHK_0 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700293
Bill Buzbeea114add2012-05-03 15:00:40 -0700294 // 57 IGET_CHAR vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700295 DF_DA | DF_UB | DF_NULL_CHK_0 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700296
Bill Buzbeea114add2012-05-03 15:00:40 -0700297 // 58 IGET_SHORT vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700298 DF_DA | DF_UB | DF_NULL_CHK_0 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700299
Bill Buzbeea114add2012-05-03 15:00:40 -0700300 // 59 IPUT vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700301 DF_UA | DF_UB | DF_NULL_CHK_1 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700302
Bill Buzbeea114add2012-05-03 15:00:40 -0700303 // 5A IPUT_WIDE vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700304 DF_UA | DF_A_WIDE | DF_UB | DF_NULL_CHK_2 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700305
Bill Buzbeea114add2012-05-03 15:00:40 -0700306 // 5B IPUT_OBJECT vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700307 DF_UA | DF_UB | DF_NULL_CHK_1 | DF_REF_A | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700308
Bill Buzbeea114add2012-05-03 15:00:40 -0700309 // 5C IPUT_BOOLEAN vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700310 DF_UA | DF_UB | DF_NULL_CHK_1 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700311
Bill Buzbeea114add2012-05-03 15:00:40 -0700312 // 5D IPUT_BYTE vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700313 DF_UA | DF_UB | DF_NULL_CHK_1 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700314
Bill Buzbeea114add2012-05-03 15:00:40 -0700315 // 5E IPUT_CHAR vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700316 DF_UA | DF_UB | DF_NULL_CHK_1 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700317
Bill Buzbeea114add2012-05-03 15:00:40 -0700318 // 5F IPUT_SHORT vA, vB, field@CCCC
buzbeebff24652012-05-06 16:22:05 -0700319 DF_UA | DF_UB | DF_NULL_CHK_1 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700320
Bill Buzbeea114add2012-05-03 15:00:40 -0700321 // 60 SGET vAA, field@BBBB
322 DF_DA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700323
Bill Buzbeea114add2012-05-03 15:00:40 -0700324 // 61 SGET_WIDE vAA, field@BBBB
buzbeebff24652012-05-06 16:22:05 -0700325 DF_DA | DF_A_WIDE | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700326
Bill Buzbeea114add2012-05-03 15:00:40 -0700327 // 62 SGET_OBJECT vAA, field@BBBB
buzbeebff24652012-05-06 16:22:05 -0700328 DF_DA | DF_REF_A | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700329
Bill Buzbeea114add2012-05-03 15:00:40 -0700330 // 63 SGET_BOOLEAN vAA, field@BBBB
331 DF_DA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700332
Bill Buzbeea114add2012-05-03 15:00:40 -0700333 // 64 SGET_BYTE vAA, field@BBBB
334 DF_DA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700335
Bill Buzbeea114add2012-05-03 15:00:40 -0700336 // 65 SGET_CHAR vAA, field@BBBB
337 DF_DA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700338
Bill Buzbeea114add2012-05-03 15:00:40 -0700339 // 66 SGET_SHORT vAA, field@BBBB
340 DF_DA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700341
Bill Buzbeea114add2012-05-03 15:00:40 -0700342 // 67 SPUT vAA, field@BBBB
343 DF_UA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700344
Bill Buzbeea114add2012-05-03 15:00:40 -0700345 // 68 SPUT_WIDE vAA, field@BBBB
buzbeebff24652012-05-06 16:22:05 -0700346 DF_UA | DF_A_WIDE | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700347
Bill Buzbeea114add2012-05-03 15:00:40 -0700348 // 69 SPUT_OBJECT vAA, field@BBBB
buzbeebff24652012-05-06 16:22:05 -0700349 DF_UA | DF_REF_A | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700350
Bill Buzbeea114add2012-05-03 15:00:40 -0700351 // 6A SPUT_BOOLEAN vAA, field@BBBB
352 DF_UA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700353
Bill Buzbeea114add2012-05-03 15:00:40 -0700354 // 6B SPUT_BYTE vAA, field@BBBB
355 DF_UA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700356
Bill Buzbeea114add2012-05-03 15:00:40 -0700357 // 6C SPUT_CHAR vAA, field@BBBB
358 DF_UA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700359
Bill Buzbeea114add2012-05-03 15:00:40 -0700360 // 6D SPUT_SHORT vAA, field@BBBB
361 DF_UA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700362
Bill Buzbeea114add2012-05-03 15:00:40 -0700363 // 6E INVOKE_VIRTUAL {vD, vE, vF, vG, vA}
364 DF_FORMAT_35C | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700365
Bill Buzbeea114add2012-05-03 15:00:40 -0700366 // 6F INVOKE_SUPER {vD, vE, vF, vG, vA}
367 DF_FORMAT_35C | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700368
Bill Buzbeea114add2012-05-03 15:00:40 -0700369 // 70 INVOKE_DIRECT {vD, vE, vF, vG, vA}
370 DF_FORMAT_35C | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700371
Bill Buzbeea114add2012-05-03 15:00:40 -0700372 // 71 INVOKE_STATIC {vD, vE, vF, vG, vA}
373 DF_FORMAT_35C | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700374
Bill Buzbeea114add2012-05-03 15:00:40 -0700375 // 72 INVOKE_INTERFACE {vD, vE, vF, vG, vA}
376 DF_FORMAT_35C | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700377
Bill Buzbeea114add2012-05-03 15:00:40 -0700378 // 73 UNUSED_73
379 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700380
Bill Buzbeea114add2012-05-03 15:00:40 -0700381 // 74 INVOKE_VIRTUAL_RANGE {vCCCC .. vNNNN}
382 DF_FORMAT_3RC | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700383
Bill Buzbeea114add2012-05-03 15:00:40 -0700384 // 75 INVOKE_SUPER_RANGE {vCCCC .. vNNNN}
385 DF_FORMAT_3RC | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700386
Bill Buzbeea114add2012-05-03 15:00:40 -0700387 // 76 INVOKE_DIRECT_RANGE {vCCCC .. vNNNN}
388 DF_FORMAT_3RC | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700389
Bill Buzbeea114add2012-05-03 15:00:40 -0700390 // 77 INVOKE_STATIC_RANGE {vCCCC .. vNNNN}
391 DF_FORMAT_3RC | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700392
Bill Buzbeea114add2012-05-03 15:00:40 -0700393 // 78 INVOKE_INTERFACE_RANGE {vCCCC .. vNNNN}
394 DF_FORMAT_3RC | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700395
Bill Buzbeea114add2012-05-03 15:00:40 -0700396 // 79 UNUSED_79
397 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700398
Bill Buzbeea114add2012-05-03 15:00:40 -0700399 // 7A UNUSED_7A
400 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700401
Bill Buzbeea114add2012-05-03 15:00:40 -0700402 // 7B NEG_INT vA, vB
403 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700404
Bill Buzbeea114add2012-05-03 15:00:40 -0700405 // 7C NOT_INT vA, vB
406 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700407
Bill Buzbeea114add2012-05-03 15:00:40 -0700408 // 7D NEG_LONG vA, vB
buzbeebff24652012-05-06 16:22:05 -0700409 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700410
Bill Buzbeea114add2012-05-03 15:00:40 -0700411 // 7E NOT_LONG vA, vB
buzbeebff24652012-05-06 16:22:05 -0700412 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700413
Bill Buzbeea114add2012-05-03 15:00:40 -0700414 // 7F NEG_FLOAT vA, vB
415 DF_DA | DF_UB | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700416
Bill Buzbeea114add2012-05-03 15:00:40 -0700417 // 80 NEG_DOUBLE vA, vB
buzbeebff24652012-05-06 16:22:05 -0700418 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700419
Bill Buzbeea114add2012-05-03 15:00:40 -0700420 // 81 INT_TO_LONG vA, vB
buzbeebff24652012-05-06 16:22:05 -0700421 DF_DA | DF_A_WIDE | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700422
Bill Buzbeea114add2012-05-03 15:00:40 -0700423 // 82 INT_TO_FLOAT vA, vB
424 DF_DA | DF_UB | DF_FP_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700425
Bill Buzbeea114add2012-05-03 15:00:40 -0700426 // 83 INT_TO_DOUBLE vA, vB
buzbeebff24652012-05-06 16:22:05 -0700427 DF_DA | DF_A_WIDE | DF_UB | DF_FP_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700428
Bill Buzbeea114add2012-05-03 15:00:40 -0700429 // 84 LONG_TO_INT vA, vB
buzbeebff24652012-05-06 16:22:05 -0700430 DF_DA | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700431
Bill Buzbeea114add2012-05-03 15:00:40 -0700432 // 85 LONG_TO_FLOAT vA, vB
buzbeebff24652012-05-06 16:22:05 -0700433 DF_DA | DF_UB | DF_B_WIDE | DF_FP_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700434
Bill Buzbeea114add2012-05-03 15:00:40 -0700435 // 86 LONG_TO_DOUBLE vA, vB
buzbeebff24652012-05-06 16:22:05 -0700436 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_FP_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700437
Bill Buzbeea114add2012-05-03 15:00:40 -0700438 // 87 FLOAT_TO_INT vA, vB
439 DF_DA | DF_UB | DF_FP_B | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700440
Bill Buzbeea114add2012-05-03 15:00:40 -0700441 // 88 FLOAT_TO_LONG vA, vB
buzbeebff24652012-05-06 16:22:05 -0700442 DF_DA | DF_A_WIDE | DF_UB | DF_FP_B | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700443
Bill Buzbeea114add2012-05-03 15:00:40 -0700444 // 89 FLOAT_TO_DOUBLE vA, vB
buzbeebff24652012-05-06 16:22:05 -0700445 DF_DA | DF_A_WIDE | DF_UB | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700446
Bill Buzbeea114add2012-05-03 15:00:40 -0700447 // 8A DOUBLE_TO_INT vA, vB
buzbeebff24652012-05-06 16:22:05 -0700448 DF_DA | DF_UB | DF_B_WIDE | DF_FP_B | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700449
Bill Buzbeea114add2012-05-03 15:00:40 -0700450 // 8B DOUBLE_TO_LONG vA, vB
buzbeebff24652012-05-06 16:22:05 -0700451 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_FP_B | DF_CORE_A,
buzbee67bf8852011-08-17 17:51:35 -0700452
Bill Buzbeea114add2012-05-03 15:00:40 -0700453 // 8C DOUBLE_TO_FLOAT vA, vB
buzbeebff24652012-05-06 16:22:05 -0700454 DF_DA | DF_UB | DF_B_WIDE | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700455
Bill Buzbeea114add2012-05-03 15:00:40 -0700456 // 8D INT_TO_BYTE vA, vB
457 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700458
Bill Buzbeea114add2012-05-03 15:00:40 -0700459 // 8E INT_TO_CHAR vA, vB
460 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700461
Bill Buzbeea114add2012-05-03 15:00:40 -0700462 // 8F INT_TO_SHORT vA, vB
463 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700464
Bill Buzbeea114add2012-05-03 15:00:40 -0700465 // 90 ADD_INT vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700466 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700467
Bill Buzbeea114add2012-05-03 15:00:40 -0700468 // 91 SUB_INT vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700469 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700470
Bill Buzbeea114add2012-05-03 15:00:40 -0700471 // 92 MUL_INT vAA, vBB, vCC
472 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700473
Bill Buzbeea114add2012-05-03 15:00:40 -0700474 // 93 DIV_INT vAA, vBB, vCC
475 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700476
Bill Buzbeea114add2012-05-03 15:00:40 -0700477 // 94 REM_INT vAA, vBB, vCC
478 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700479
Bill Buzbeea114add2012-05-03 15:00:40 -0700480 // 95 AND_INT vAA, vBB, vCC
481 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700482
Bill Buzbeea114add2012-05-03 15:00:40 -0700483 // 96 OR_INT vAA, vBB, vCC
484 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700485
Bill Buzbeea114add2012-05-03 15:00:40 -0700486 // 97 XOR_INT vAA, vBB, vCC
487 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700488
Bill Buzbeea114add2012-05-03 15:00:40 -0700489 // 98 SHL_INT vAA, vBB, vCC
490 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700491
Bill Buzbeea114add2012-05-03 15:00:40 -0700492 // 99 SHR_INT vAA, vBB, vCC
493 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700494
Bill Buzbeea114add2012-05-03 15:00:40 -0700495 // 9A USHR_INT vAA, vBB, vCC
496 DF_DA | DF_UB | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700497
Bill Buzbeea114add2012-05-03 15:00:40 -0700498 // 9B ADD_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700499 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700500
Bill Buzbeea114add2012-05-03 15:00:40 -0700501 // 9C SUB_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700502 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700503
Bill Buzbeea114add2012-05-03 15:00:40 -0700504 // 9D MUL_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700505 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700506
Bill Buzbeea114add2012-05-03 15:00:40 -0700507 // 9E DIV_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700508 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700509
Bill Buzbeea114add2012-05-03 15:00:40 -0700510 // 9F REM_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700511 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700512
Bill Buzbeea114add2012-05-03 15:00:40 -0700513 // A0 AND_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700514 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700515
Bill Buzbeea114add2012-05-03 15:00:40 -0700516 // A1 OR_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700517 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700518
Bill Buzbeea114add2012-05-03 15:00:40 -0700519 // A2 XOR_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700520 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700521
Bill Buzbeea114add2012-05-03 15:00:40 -0700522 // A3 SHL_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700523 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700524
Bill Buzbeea114add2012-05-03 15:00:40 -0700525 // A4 SHR_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700526 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700527
Bill Buzbeea114add2012-05-03 15:00:40 -0700528 // A5 USHR_LONG vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700529 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_CORE_A | DF_CORE_B | DF_CORE_C,
buzbee67bf8852011-08-17 17:51:35 -0700530
Bill Buzbeea114add2012-05-03 15:00:40 -0700531 // A6 ADD_FLOAT vAA, vBB, vCC
532 DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700533
Bill Buzbeea114add2012-05-03 15:00:40 -0700534 // A7 SUB_FLOAT vAA, vBB, vCC
535 DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700536
Bill Buzbeea114add2012-05-03 15:00:40 -0700537 // A8 MUL_FLOAT vAA, vBB, vCC
538 DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700539
Bill Buzbeea114add2012-05-03 15:00:40 -0700540 // A9 DIV_FLOAT vAA, vBB, vCC
541 DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700542
Bill Buzbeea114add2012-05-03 15:00:40 -0700543 // AA REM_FLOAT vAA, vBB, vCC
544 DF_DA | DF_UB | DF_UC | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700545
Bill Buzbeea114add2012-05-03 15:00:40 -0700546 // AB ADD_DOUBLE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700547 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700548
Bill Buzbeea114add2012-05-03 15:00:40 -0700549 // AC SUB_DOUBLE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700550 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700551
Bill Buzbeea114add2012-05-03 15:00:40 -0700552 // AD MUL_DOUBLE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700553 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700554
Bill Buzbeea114add2012-05-03 15:00:40 -0700555 // AE DIV_DOUBLE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700556 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700557
Bill Buzbeea114add2012-05-03 15:00:40 -0700558 // AF REM_DOUBLE vAA, vBB, vCC
buzbeebff24652012-05-06 16:22:05 -0700559 DF_DA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_UC | DF_C_WIDE | DF_FP_A | DF_FP_B | DF_FP_C,
buzbee67bf8852011-08-17 17:51:35 -0700560
Bill Buzbeea114add2012-05-03 15:00:40 -0700561 // B0 ADD_INT_2ADDR vA, vB
562 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700563
Bill Buzbeea114add2012-05-03 15:00:40 -0700564 // B1 SUB_INT_2ADDR vA, vB
565 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700566
Bill Buzbeea114add2012-05-03 15:00:40 -0700567 // B2 MUL_INT_2ADDR vA, vB
568 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700569
Bill Buzbeea114add2012-05-03 15:00:40 -0700570 // B3 DIV_INT_2ADDR vA, vB
571 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700572
Bill Buzbeea114add2012-05-03 15:00:40 -0700573 // B4 REM_INT_2ADDR vA, vB
574 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700575
Bill Buzbeea114add2012-05-03 15:00:40 -0700576 // B5 AND_INT_2ADDR vA, vB
577 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700578
Bill Buzbeea114add2012-05-03 15:00:40 -0700579 // B6 OR_INT_2ADDR vA, vB
580 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700581
Bill Buzbeea114add2012-05-03 15:00:40 -0700582 // B7 XOR_INT_2ADDR vA, vB
583 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700584
Bill Buzbeea114add2012-05-03 15:00:40 -0700585 // B8 SHL_INT_2ADDR vA, vB
586 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700587
Bill Buzbeea114add2012-05-03 15:00:40 -0700588 // B9 SHR_INT_2ADDR vA, vB
589 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700590
Bill Buzbeea114add2012-05-03 15:00:40 -0700591 // BA USHR_INT_2ADDR vA, vB
592 DF_DA | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700593
Bill Buzbeea114add2012-05-03 15:00:40 -0700594 // BB ADD_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700595 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700596
Bill Buzbeea114add2012-05-03 15:00:40 -0700597 // BC SUB_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700598 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700599
Bill Buzbeea114add2012-05-03 15:00:40 -0700600 // BD MUL_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700601 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700602
Bill Buzbeea114add2012-05-03 15:00:40 -0700603 // BE DIV_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700604 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700605
Bill Buzbeea114add2012-05-03 15:00:40 -0700606 // BF REM_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700607 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700608
Bill Buzbeea114add2012-05-03 15:00:40 -0700609 // C0 AND_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700610 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700611
Bill Buzbeea114add2012-05-03 15:00:40 -0700612 // C1 OR_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700613 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700614
Bill Buzbeea114add2012-05-03 15:00:40 -0700615 // C2 XOR_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700616 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700617
Bill Buzbeea114add2012-05-03 15:00:40 -0700618 // C3 SHL_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700619 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700620
Bill Buzbeea114add2012-05-03 15:00:40 -0700621 // C4 SHR_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700622 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700623
Bill Buzbeea114add2012-05-03 15:00:40 -0700624 // C5 USHR_LONG_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700625 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700626
Bill Buzbeea114add2012-05-03 15:00:40 -0700627 // C6 ADD_FLOAT_2ADDR vA, vB
628 DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700629
Bill Buzbeea114add2012-05-03 15:00:40 -0700630 // C7 SUB_FLOAT_2ADDR vA, vB
631 DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700632
Bill Buzbeea114add2012-05-03 15:00:40 -0700633 // C8 MUL_FLOAT_2ADDR vA, vB
634 DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700635
Bill Buzbeea114add2012-05-03 15:00:40 -0700636 // C9 DIV_FLOAT_2ADDR vA, vB
637 DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700638
Bill Buzbeea114add2012-05-03 15:00:40 -0700639 // CA REM_FLOAT_2ADDR vA, vB
640 DF_DA | DF_UA | DF_UB | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700641
Bill Buzbeea114add2012-05-03 15:00:40 -0700642 // CB ADD_DOUBLE_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700643 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700644
Bill Buzbeea114add2012-05-03 15:00:40 -0700645 // CC SUB_DOUBLE_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700646 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700647
Bill Buzbeea114add2012-05-03 15:00:40 -0700648 // CD MUL_DOUBLE_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700649 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700650
Bill Buzbeea114add2012-05-03 15:00:40 -0700651 // CE DIV_DOUBLE_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700652 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700653
Bill Buzbeea114add2012-05-03 15:00:40 -0700654 // CF REM_DOUBLE_2ADDR vA, vB
buzbeebff24652012-05-06 16:22:05 -0700655 DF_DA | DF_A_WIDE | DF_UA | DF_UB | DF_B_WIDE | DF_FP_A | DF_FP_B,
buzbee67bf8852011-08-17 17:51:35 -0700656
Bill Buzbeea114add2012-05-03 15:00:40 -0700657 // D0 ADD_INT_LIT16 vA, vB, #+CCCC
658 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700659
Bill Buzbeea114add2012-05-03 15:00:40 -0700660 // D1 RSUB_INT vA, vB, #+CCCC
661 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700662
Bill Buzbeea114add2012-05-03 15:00:40 -0700663 // D2 MUL_INT_LIT16 vA, vB, #+CCCC
664 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700665
Bill Buzbeea114add2012-05-03 15:00:40 -0700666 // D3 DIV_INT_LIT16 vA, vB, #+CCCC
667 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700668
Bill Buzbeea114add2012-05-03 15:00:40 -0700669 // D4 REM_INT_LIT16 vA, vB, #+CCCC
670 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700671
Bill Buzbeea114add2012-05-03 15:00:40 -0700672 // D5 AND_INT_LIT16 vA, vB, #+CCCC
673 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700674
Bill Buzbeea114add2012-05-03 15:00:40 -0700675 // D6 OR_INT_LIT16 vA, vB, #+CCCC
676 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700677
Bill Buzbeea114add2012-05-03 15:00:40 -0700678 // D7 XOR_INT_LIT16 vA, vB, #+CCCC
679 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700680
Bill Buzbeea114add2012-05-03 15:00:40 -0700681 // D8 ADD_INT_LIT8 vAA, vBB, #+CC
buzbeebff24652012-05-06 16:22:05 -0700682 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700683
Bill Buzbeea114add2012-05-03 15:00:40 -0700684 // D9 RSUB_INT_LIT8 vAA, vBB, #+CC
685 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700686
Bill Buzbeea114add2012-05-03 15:00:40 -0700687 // DA MUL_INT_LIT8 vAA, vBB, #+CC
688 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700689
Bill Buzbeea114add2012-05-03 15:00:40 -0700690 // DB DIV_INT_LIT8 vAA, vBB, #+CC
691 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700692
Bill Buzbeea114add2012-05-03 15:00:40 -0700693 // DC REM_INT_LIT8 vAA, vBB, #+CC
694 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700695
Bill Buzbeea114add2012-05-03 15:00:40 -0700696 // DD AND_INT_LIT8 vAA, vBB, #+CC
697 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700698
Bill Buzbeea114add2012-05-03 15:00:40 -0700699 // DE OR_INT_LIT8 vAA, vBB, #+CC
700 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700701
Bill Buzbeea114add2012-05-03 15:00:40 -0700702 // DF XOR_INT_LIT8 vAA, vBB, #+CC
703 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700704
Bill Buzbeea114add2012-05-03 15:00:40 -0700705 // E0 SHL_INT_LIT8 vAA, vBB, #+CC
706 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700707
Bill Buzbeea114add2012-05-03 15:00:40 -0700708 // E1 SHR_INT_LIT8 vAA, vBB, #+CC
709 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700710
Bill Buzbeea114add2012-05-03 15:00:40 -0700711 // E2 USHR_INT_LIT8 vAA, vBB, #+CC
712 DF_DA | DF_UB | DF_CORE_A | DF_CORE_B,
buzbee67bf8852011-08-17 17:51:35 -0700713
Bill Buzbeea114add2012-05-03 15:00:40 -0700714 // E3 IGET_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700715 DF_DA | DF_UB | DF_NULL_CHK_0 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700716
Bill Buzbeea114add2012-05-03 15:00:40 -0700717 // E4 IPUT_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700718 DF_UA | DF_UB | DF_NULL_CHK_1 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700719
Bill Buzbeea114add2012-05-03 15:00:40 -0700720 // E5 SGET_VOLATILE
721 DF_DA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700722
Bill Buzbeea114add2012-05-03 15:00:40 -0700723 // E6 SPUT_VOLATILE
724 DF_UA | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700725
Bill Buzbeea114add2012-05-03 15:00:40 -0700726 // E7 IGET_OBJECT_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700727 DF_DA | DF_UB | DF_NULL_CHK_0 | DF_REF_A | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700728
Bill Buzbeea114add2012-05-03 15:00:40 -0700729 // E8 IGET_WIDE_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700730 DF_DA | DF_A_WIDE | DF_UB | DF_NULL_CHK_0 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700731
Bill Buzbeea114add2012-05-03 15:00:40 -0700732 // E9 IPUT_WIDE_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700733 DF_UA | DF_A_WIDE | DF_UB | DF_NULL_CHK_2 | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700734
Bill Buzbeea114add2012-05-03 15:00:40 -0700735 // EA SGET_WIDE_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700736 DF_DA | DF_A_WIDE | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700737
Bill Buzbeea114add2012-05-03 15:00:40 -0700738 // EB SPUT_WIDE_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700739 DF_UA | DF_A_WIDE | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700740
Bill Buzbeea114add2012-05-03 15:00:40 -0700741 // EC BREAKPOINT
742 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700743
Bill Buzbeea114add2012-05-03 15:00:40 -0700744 // ED THROW_VERIFICATION_ERROR
745 DF_NOP | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700746
Bill Buzbeea114add2012-05-03 15:00:40 -0700747 // EE EXECUTE_INLINE
748 DF_FORMAT_35C,
buzbee67bf8852011-08-17 17:51:35 -0700749
Bill Buzbeea114add2012-05-03 15:00:40 -0700750 // EF EXECUTE_INLINE_RANGE
751 DF_FORMAT_3RC,
buzbee67bf8852011-08-17 17:51:35 -0700752
Bill Buzbeea114add2012-05-03 15:00:40 -0700753 // F0 INVOKE_OBJECT_INIT_RANGE
754 DF_NOP | DF_NULL_CHK_0,
buzbee67bf8852011-08-17 17:51:35 -0700755
Bill Buzbeea114add2012-05-03 15:00:40 -0700756 // F1 RETURN_VOID_BARRIER
757 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700758
Bill Buzbeea114add2012-05-03 15:00:40 -0700759 // F2 IGET_QUICK
760 DF_DA | DF_UB | DF_NULL_CHK_0,
buzbee67bf8852011-08-17 17:51:35 -0700761
Bill Buzbeea114add2012-05-03 15:00:40 -0700762 // F3 IGET_WIDE_QUICK
buzbeebff24652012-05-06 16:22:05 -0700763 DF_DA | DF_A_WIDE | DF_UB | DF_NULL_CHK_0,
buzbee67bf8852011-08-17 17:51:35 -0700764
Bill Buzbeea114add2012-05-03 15:00:40 -0700765 // F4 IGET_OBJECT_QUICK
766 DF_DA | DF_UB | DF_NULL_CHK_0,
buzbee67bf8852011-08-17 17:51:35 -0700767
Bill Buzbeea114add2012-05-03 15:00:40 -0700768 // F5 IPUT_QUICK
769 DF_UA | DF_UB | DF_NULL_CHK_1,
buzbee67bf8852011-08-17 17:51:35 -0700770
Bill Buzbeea114add2012-05-03 15:00:40 -0700771 // F6 IPUT_WIDE_QUICK
buzbeebff24652012-05-06 16:22:05 -0700772 DF_UA | DF_A_WIDE | DF_UB | DF_NULL_CHK_2,
buzbee67bf8852011-08-17 17:51:35 -0700773
Bill Buzbeea114add2012-05-03 15:00:40 -0700774 // F7 IPUT_OBJECT_QUICK
775 DF_UA | DF_UB | DF_NULL_CHK_1,
buzbee67bf8852011-08-17 17:51:35 -0700776
Bill Buzbeea114add2012-05-03 15:00:40 -0700777 // F8 INVOKE_VIRTUAL_QUICK
778 DF_FORMAT_35C | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700779
Bill Buzbeea114add2012-05-03 15:00:40 -0700780 // F9 INVOKE_VIRTUAL_QUICK_RANGE
781 DF_FORMAT_3RC | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700782
Bill Buzbeea114add2012-05-03 15:00:40 -0700783 // FA INVOKE_SUPER_QUICK
784 DF_FORMAT_35C | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700785
Bill Buzbeea114add2012-05-03 15:00:40 -0700786 // FB INVOKE_SUPER_QUICK_RANGE
787 DF_FORMAT_3RC | DF_NULL_CHK_OUT0 | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700788
Bill Buzbeea114add2012-05-03 15:00:40 -0700789 // FC IPUT_OBJECT_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700790 DF_UA | DF_UB | DF_NULL_CHK_1 | DF_REF_A | DF_REF_B,
buzbee67bf8852011-08-17 17:51:35 -0700791
Bill Buzbeea114add2012-05-03 15:00:40 -0700792 // FD SGET_OBJECT_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700793 DF_DA | DF_REF_A | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700794
Bill Buzbeea114add2012-05-03 15:00:40 -0700795 // FE SPUT_OBJECT_VOLATILE
buzbeebff24652012-05-06 16:22:05 -0700796 DF_UA | DF_REF_A | DF_UMS,
buzbee67bf8852011-08-17 17:51:35 -0700797
Bill Buzbeea114add2012-05-03 15:00:40 -0700798 // FF UNUSED_FF
799 DF_NOP,
buzbee67bf8852011-08-17 17:51:35 -0700800
Bill Buzbeea114add2012-05-03 15:00:40 -0700801 // Beginning of extended MIR opcodes
802 // 100 MIR_PHI
buzbeebff24652012-05-06 16:22:05 -0700803 DF_DA | DF_NULL_TRANSFER_N,
buzbee84fd6932012-03-29 16:44:16 -0700804
Bill Buzbeea114add2012-05-03 15:00:40 -0700805 // 101 MIR_COPY
806 DF_DA | DF_UB | DF_IS_MOVE,
buzbee84fd6932012-03-29 16:44:16 -0700807
Bill Buzbeea114add2012-05-03 15:00:40 -0700808 // 102 MIR_FUSED_CMPL_FLOAT
809 DF_UA | DF_UB | DF_FP_A | DF_FP_B,
buzbee84fd6932012-03-29 16:44:16 -0700810
Bill Buzbeea114add2012-05-03 15:00:40 -0700811 // 103 MIR_FUSED_CMPG_FLOAT
812 DF_UA | DF_UB | DF_FP_A | DF_FP_B,
buzbee84fd6932012-03-29 16:44:16 -0700813
Bill Buzbeea114add2012-05-03 15:00:40 -0700814 // 104 MIR_FUSED_CMPL_DOUBLE
buzbeebff24652012-05-06 16:22:05 -0700815 DF_UA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_FP_A | DF_FP_B,
buzbee84fd6932012-03-29 16:44:16 -0700816
Bill Buzbeea114add2012-05-03 15:00:40 -0700817 // 105 MIR_FUSED_CMPG_DOUBLE
buzbeebff24652012-05-06 16:22:05 -0700818 DF_UA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_FP_A | DF_FP_B,
buzbee84fd6932012-03-29 16:44:16 -0700819
Bill Buzbeea114add2012-05-03 15:00:40 -0700820 // 106 MIR_FUSED_CMP_LONG
buzbeebff24652012-05-06 16:22:05 -0700821 DF_UA | DF_A_WIDE | DF_UB | DF_B_WIDE | DF_CORE_A | DF_CORE_B,
buzbee84fd6932012-03-29 16:44:16 -0700822
Bill Buzbeea114add2012-05-03 15:00:40 -0700823 // 107 MIR_NOP
824 DF_NOP,
buzbee84fd6932012-03-29 16:44:16 -0700825
Bill Buzbeea114add2012-05-03 15:00:40 -0700826 // 108 MIR_NULL_RANGE_UP_CHECK
827 0,
buzbee84fd6932012-03-29 16:44:16 -0700828
Bill Buzbeea114add2012-05-03 15:00:40 -0700829 // 109 MIR_NULL_RANGE_DOWN_CHECK
830 0,
buzbee84fd6932012-03-29 16:44:16 -0700831
Bill Buzbeea114add2012-05-03 15:00:40 -0700832 // 110 MIR_LOWER_BOUND
833 0,
buzbee67bf8852011-08-17 17:51:35 -0700834};
835
buzbeee1965672012-03-11 18:39:19 -0700836/* Return the base virtual register for a SSA name */
837int SRegToVReg(const CompilationUnit* cUnit, int ssaReg)
buzbee67bf8852011-08-17 17:51:35 -0700838{
Bill Buzbeea114add2012-05-03 15:00:40 -0700839 DCHECK_LT(ssaReg, (int)cUnit->ssaBaseVRegs->numUsed);
840 return GET_ELEM_N(cUnit->ssaBaseVRegs, int, ssaReg);
buzbee67bf8852011-08-17 17:51:35 -0700841}
842
buzbeee1965672012-03-11 18:39:19 -0700843int SRegToSubscript(const CompilationUnit* cUnit, int ssaReg)
844{
Bill Buzbeea114add2012-05-03 15:00:40 -0700845 DCHECK(ssaReg < (int)cUnit->ssaSubscripts->numUsed);
846 return GET_ELEM_N(cUnit->ssaSubscripts, int, ssaReg);
buzbeee1965672012-03-11 18:39:19 -0700847}
848
buzbee84fd6932012-03-29 16:44:16 -0700849int getSSAUseCount(CompilationUnit* cUnit, int sReg)
850{
Bill Buzbeea114add2012-05-03 15:00:40 -0700851 DCHECK(sReg < (int)cUnit->rawUseCounts.numUsed);
852 return cUnit->rawUseCounts.elemList[sReg];
buzbee84fd6932012-03-29 16:44:16 -0700853}
854
855
buzbeeba938cb2012-02-03 14:47:55 -0800856char* oatGetDalvikDisassembly(CompilationUnit* cUnit,
Elliott Hughesadb8c672012-03-06 16:49:32 -0800857 const DecodedInstruction& insn, const char* note)
buzbee67bf8852011-08-17 17:51:35 -0700858{
Bill Buzbeea114add2012-05-03 15:00:40 -0700859 char buffer[256];
860 Instruction::Code opcode = insn.opcode;
861 int dfAttributes = oatDataFlowAttributes[opcode];
862 int flags;
863 char* ret;
buzbee67bf8852011-08-17 17:51:35 -0700864
Bill Buzbeea114add2012-05-03 15:00:40 -0700865 buffer[0] = 0;
866 if ((int)opcode >= (int)kMirOpFirst) {
867 if ((int)opcode == (int)kMirOpPhi) {
868 strcpy(buffer, "PHI");
buzbee67bf8852011-08-17 17:51:35 -0700869 } else {
Bill Buzbeea114add2012-05-03 15:00:40 -0700870 sprintf(buffer, "Opcode %#x", opcode);
buzbee67bf8852011-08-17 17:51:35 -0700871 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700872 flags = 0;
873 } else {
874 strcpy(buffer, Instruction::Name(opcode));
875 flags = Instruction::Flags(opcode);
876 }
buzbee67bf8852011-08-17 17:51:35 -0700877
Bill Buzbeea114add2012-05-03 15:00:40 -0700878 if (note)
879 strcat(buffer, note);
buzbee67bf8852011-08-17 17:51:35 -0700880
Bill Buzbeea114add2012-05-03 15:00:40 -0700881 /* For branches, decode the instructions to print out the branch targets */
882 if (flags & Instruction::kBranch) {
883 Instruction::Format dalvikFormat = Instruction::FormatOf(insn.opcode);
884 int offset = 0;
885 switch (dalvikFormat) {
886 case Instruction::k21t:
887 snprintf(buffer + strlen(buffer), 256, " v%d,", insn.vA);
888 offset = (int) insn.vB;
889 break;
890 case Instruction::k22t:
891 snprintf(buffer + strlen(buffer), 256, " v%d, v%d,", insn.vA, insn.vB);
892 offset = (int) insn.vC;
893 break;
894 case Instruction::k10t:
895 case Instruction::k20t:
896 case Instruction::k30t:
897 offset = (int) insn.vA;
898 break;
899 default:
900 LOG(FATAL) << "Unexpected branch format " << (int)dalvikFormat
901 << " / opcode " << (int)opcode;
buzbee67bf8852011-08-17 17:51:35 -0700902 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700903 snprintf(buffer + strlen(buffer), 256, " (%c%x)",
904 offset > 0 ? '+' : '-',
905 offset > 0 ? offset : -offset);
906 } else if (dfAttributes & DF_FORMAT_35C) {
907 unsigned int i;
908 for (i = 0; i < insn.vA; i++) {
909 if (i != 0) strcat(buffer, ",");
910 snprintf(buffer + strlen(buffer), 256, " v%d", insn.arg[i]);
buzbee67bf8852011-08-17 17:51:35 -0700911 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700912 }
913 else if (dfAttributes & DF_FORMAT_3RC) {
914 snprintf(buffer + strlen(buffer), 256,
915 " v%d..v%d", insn.vC, insn.vC + insn.vA - 1);
916 } else {
917 if (dfAttributes & DF_A_IS_REG) {
918 snprintf(buffer + strlen(buffer), 256, " v%d", insn.vA);
buzbee67bf8852011-08-17 17:51:35 -0700919 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700920 if (dfAttributes & DF_B_IS_REG) {
921 snprintf(buffer + strlen(buffer), 256, ", v%d", insn.vB);
922 } else if ((int)opcode < (int)kMirOpFirst) {
923 snprintf(buffer + strlen(buffer), 256, ", (#%d)", insn.vB);
924 }
925 if (dfAttributes & DF_C_IS_REG) {
926 snprintf(buffer + strlen(buffer), 256, ", v%d", insn.vC);
927 } else if ((int)opcode < (int)kMirOpFirst) {
928 snprintf(buffer + strlen(buffer), 256, ", (#%d)", insn.vC);
929 }
930 }
931 int length = strlen(buffer) + 1;
932 ret = (char*)oatNew(cUnit, length, false, kAllocDFInfo);
933 memcpy(ret, buffer, length);
934 return ret;
buzbee67bf8852011-08-17 17:51:35 -0700935}
936
Elliott Hughesc1f143d2011-12-01 17:31:10 -0800937char* getSSAName(const CompilationUnit* cUnit, int ssaReg, char* name)
buzbee67bf8852011-08-17 17:51:35 -0700938{
Bill Buzbeea114add2012-05-03 15:00:40 -0700939 sprintf(name, "v%d_%d", SRegToVReg(cUnit, ssaReg),
940 SRegToSubscript(cUnit, ssaReg));
941 return name;
buzbee67bf8852011-08-17 17:51:35 -0700942}
943
944/*
945 * Dalvik instruction disassembler with optional SSA printing.
946 */
buzbee31a4a6f2012-02-28 15:36:15 -0800947char* oatFullDisassembler(CompilationUnit* cUnit, const MIR* mir)
buzbee67bf8852011-08-17 17:51:35 -0700948{
Bill Buzbeea114add2012-05-03 15:00:40 -0700949 char buffer[256];
950 char operand0[32], operand1[32];
951 const DecodedInstruction* insn = &mir->dalvikInsn;
952 Instruction::Code opcode = insn->opcode;
953 int dfAttributes = oatDataFlowAttributes[opcode];
954 char* ret;
955 int length;
buzbee67bf8852011-08-17 17:51:35 -0700956
Bill Buzbeea114add2012-05-03 15:00:40 -0700957 buffer[0] = 0;
958 if (static_cast<int>(opcode) >= static_cast<int>(kMirOpFirst)) {
959 if (static_cast<int>(opcode) == static_cast<int>(kMirOpPhi)) {
960 snprintf(buffer, 256, "PHI %s = (%s",
961 getSSAName(cUnit, mir->ssaRep->defs[0], operand0),
962 getSSAName(cUnit, mir->ssaRep->uses[0], operand1));
963 int i;
964 for (i = 1; i < mir->ssaRep->numUses; i++) {
965 snprintf(buffer + strlen(buffer), 256, ", %s",
966 getSSAName(cUnit, mir->ssaRep->uses[i], operand0));
967 }
968 snprintf(buffer + strlen(buffer), 256, ")");
buzbee67bf8852011-08-17 17:51:35 -0700969 } else {
Bill Buzbeea114add2012-05-03 15:00:40 -0700970 sprintf(buffer, "Opcode %#x", opcode);
buzbee67bf8852011-08-17 17:51:35 -0700971 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700972 goto done;
973 } else {
974 strcpy(buffer, Instruction::Name(opcode));
975 }
buzbee67bf8852011-08-17 17:51:35 -0700976
Bill Buzbeea114add2012-05-03 15:00:40 -0700977 /* For branches, decode the instructions to print out the branch targets */
978 if (Instruction::Flags(insn->opcode) & Instruction::kBranch) {
979 Instruction::Format dalvikFormat = Instruction::FormatOf(insn->opcode);
980 int delta = 0;
981 switch (dalvikFormat) {
982 case Instruction::k21t:
983 snprintf(buffer + strlen(buffer), 256, " %s, ",
984 getSSAName(cUnit, mir->ssaRep->uses[0], operand0));
985 delta = (int) insn->vB;
986 break;
987 case Instruction::k22t:
988 snprintf(buffer + strlen(buffer), 256, " %s, %s, ",
989 getSSAName(cUnit, mir->ssaRep->uses[0], operand0),
990 getSSAName(cUnit, mir->ssaRep->uses[1], operand1));
991 delta = (int) insn->vC;
992 break;
993 case Instruction::k10t:
994 case Instruction::k20t:
995 case Instruction::k30t:
996 delta = (int) insn->vA;
997 break;
998 default:
999 LOG(FATAL) << "Unexpected branch format: " << (int)dalvikFormat;
1000 }
1001 snprintf(buffer + strlen(buffer), 256, " %04x",
1002 mir->offset + delta);
1003 } else if (dfAttributes & (DF_FORMAT_35C | DF_FORMAT_3RC)) {
1004 unsigned int i;
1005 for (i = 0; i < insn->vA; i++) {
1006 if (i != 0) strcat(buffer, ",");
1007 snprintf(buffer + strlen(buffer), 256, " %s",
1008 getSSAName(cUnit, mir->ssaRep->uses[i], operand0));
1009 }
1010 } else {
1011 int udIdx;
1012 if (mir->ssaRep->numDefs) {
1013
1014 for (udIdx = 0; udIdx < mir->ssaRep->numDefs; udIdx++) {
1015 snprintf(buffer + strlen(buffer), 256, " %s",
1016 getSSAName(cUnit, mir->ssaRep->defs[udIdx], operand0));
1017 }
1018 strcat(buffer, ",");
1019 }
1020 if (mir->ssaRep->numUses) {
1021 /* No leading ',' for the first use */
1022 snprintf(buffer + strlen(buffer), 256, " %s",
1023 getSSAName(cUnit, mir->ssaRep->uses[0], operand0));
1024 for (udIdx = 1; udIdx < mir->ssaRep->numUses; udIdx++) {
1025 snprintf(buffer + strlen(buffer), 256, ", %s",
1026 getSSAName(cUnit, mir->ssaRep->uses[udIdx], operand0));
1027 }
1028 }
1029 if (static_cast<int>(opcode) < static_cast<int>(kMirOpFirst)) {
1030 Instruction::Format dalvikFormat = Instruction::FormatOf(opcode);
buzbee67bf8852011-08-17 17:51:35 -07001031 switch (dalvikFormat) {
Bill Buzbeea114add2012-05-03 15:00:40 -07001032 case Instruction::k11n: // op vA, #+B
1033 case Instruction::k21s: // op vAA, #+BBBB
1034 case Instruction::k21h: // op vAA, #+BBBB00000[00000000]
1035 case Instruction::k31i: // op vAA, #+BBBBBBBB
1036 case Instruction::k51l: // op vAA, #+BBBBBBBBBBBBBBBB
1037 snprintf(buffer + strlen(buffer), 256, " #%#x", insn->vB);
1038 break;
1039 case Instruction::k21c: // op vAA, thing@BBBB
1040 case Instruction::k31c: // op vAA, thing@BBBBBBBB
1041 snprintf(buffer + strlen(buffer), 256, " @%#x", insn->vB);
1042 break;
1043 case Instruction::k22b: // op vAA, vBB, #+CC
1044 case Instruction::k22s: // op vA, vB, #+CCCC
1045 snprintf(buffer + strlen(buffer), 256, " #%#x", insn->vC);
1046 break;
1047 case Instruction::k22c: // op vA, vB, thing@CCCC
1048 snprintf(buffer + strlen(buffer), 256, " @%#x", insn->vC);
1049 break;
1050 /* No need for special printing */
1051 default:
1052 break;
buzbee67bf8852011-08-17 17:51:35 -07001053 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001054 }
1055 }
buzbee67bf8852011-08-17 17:51:35 -07001056
1057done:
Bill Buzbeea114add2012-05-03 15:00:40 -07001058 length = strlen(buffer) + 1;
1059 ret = (char*) oatNew(cUnit, length, false, kAllocDFInfo);
1060 memcpy(ret, buffer, length);
1061 return ret;
buzbee67bf8852011-08-17 17:51:35 -07001062}
1063
Elliott Hughesc1f143d2011-12-01 17:31:10 -08001064char* oatGetSSAString(CompilationUnit* cUnit, SSARepresentation* ssaRep)
buzbee67bf8852011-08-17 17:51:35 -07001065{
Bill Buzbeea114add2012-05-03 15:00:40 -07001066 char buffer[256];
1067 char* ret;
1068 int i;
buzbee67bf8852011-08-17 17:51:35 -07001069
Bill Buzbeea114add2012-05-03 15:00:40 -07001070 buffer[0] = 0;
1071 for (i = 0; i < ssaRep->numDefs; i++) {
1072 int ssaReg = ssaRep->defs[i];
1073 sprintf(buffer + strlen(buffer), "s%d(v%d_%d) ", ssaReg,
1074 SRegToVReg(cUnit, ssaReg), SRegToSubscript(cUnit, ssaReg));
1075 }
1076
1077 if (ssaRep->numDefs) {
1078 strcat(buffer, "<- ");
1079 }
1080
1081 for (i = 0; i < ssaRep->numUses; i++) {
1082 int len = strlen(buffer);
1083 int ssaReg = ssaRep->uses[i];
1084
1085 if (snprintf(buffer + len, 250 - len, "s%d(v%d_%d) ", ssaReg,
1086 SRegToVReg(cUnit, ssaReg),
1087 SRegToSubscript(cUnit, ssaReg))) {
1088 strcat(buffer, "...");
1089 break;
buzbee67bf8852011-08-17 17:51:35 -07001090 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001091 }
buzbee67bf8852011-08-17 17:51:35 -07001092
Bill Buzbeea114add2012-05-03 15:00:40 -07001093 int length = strlen(buffer) + 1;
1094 ret = (char*)oatNew(cUnit, length, false, kAllocDFInfo);
1095 memcpy(ret, buffer, length);
1096 return ret;
buzbee67bf8852011-08-17 17:51:35 -07001097}
1098
1099/* Any register that is used before being defined is considered live-in */
buzbee31a4a6f2012-02-28 15:36:15 -08001100inline void handleLiveInUse(CompilationUnit* cUnit, ArenaBitVector* useV,
1101 ArenaBitVector* defV, ArenaBitVector* liveInV,
1102 int dalvikRegId)
buzbee67bf8852011-08-17 17:51:35 -07001103{
Bill Buzbeea114add2012-05-03 15:00:40 -07001104 oatSetBit(cUnit, useV, dalvikRegId);
1105 if (!oatIsBitSet(defV, dalvikRegId)) {
1106 oatSetBit(cUnit, liveInV, dalvikRegId);
1107 }
buzbee67bf8852011-08-17 17:51:35 -07001108}
1109
1110/* Mark a reg as being defined */
buzbee31a4a6f2012-02-28 15:36:15 -08001111inline void handleDef(CompilationUnit* cUnit, ArenaBitVector* defV,
1112 int dalvikRegId)
buzbee67bf8852011-08-17 17:51:35 -07001113{
Bill Buzbeea114add2012-05-03 15:00:40 -07001114 oatSetBit(cUnit, defV, dalvikRegId);
buzbee67bf8852011-08-17 17:51:35 -07001115}
1116
1117/*
1118 * Find out live-in variables for natural loops. Variables that are live-in in
1119 * the main loop body are considered to be defined in the entry block.
1120 */
1121bool oatFindLocalLiveIn(CompilationUnit* cUnit, BasicBlock* bb)
1122{
Bill Buzbeea114add2012-05-03 15:00:40 -07001123 MIR* mir;
1124 ArenaBitVector *useV, *defV, *liveInV;
buzbee67bf8852011-08-17 17:51:35 -07001125
Bill Buzbeea114add2012-05-03 15:00:40 -07001126 if (bb->dataFlowInfo == NULL) return false;
buzbee67bf8852011-08-17 17:51:35 -07001127
Bill Buzbeea114add2012-05-03 15:00:40 -07001128 useV = bb->dataFlowInfo->useV =
1129 oatAllocBitVector(cUnit, cUnit->numDalvikRegisters, false, kBitMapUse);
1130 defV = bb->dataFlowInfo->defV =
1131 oatAllocBitVector(cUnit, cUnit->numDalvikRegisters, false, kBitMapDef);
1132 liveInV = bb->dataFlowInfo->liveInV =
1133 oatAllocBitVector(cUnit, cUnit->numDalvikRegisters, false,
1134 kBitMapLiveIn);
buzbee67bf8852011-08-17 17:51:35 -07001135
Bill Buzbeea114add2012-05-03 15:00:40 -07001136 for (mir = bb->firstMIRInsn; mir; mir = mir->next) {
1137 int dfAttributes = oatDataFlowAttributes[mir->dalvikInsn.opcode];
1138 DecodedInstruction *dInsn = &mir->dalvikInsn;
buzbee67bf8852011-08-17 17:51:35 -07001139
Bill Buzbeea114add2012-05-03 15:00:40 -07001140 if (dfAttributes & DF_HAS_USES) {
1141 if (dfAttributes & DF_UA) {
1142 handleLiveInUse(cUnit, useV, defV, liveInV, dInsn->vA);
buzbeebff24652012-05-06 16:22:05 -07001143 if (dfAttributes & DF_A_WIDE) {
1144 handleLiveInUse(cUnit, useV, defV, liveInV, dInsn->vA+1);
1145 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001146 }
1147 if (dfAttributes & DF_UB) {
1148 handleLiveInUse(cUnit, useV, defV, liveInV, dInsn->vB);
buzbeebff24652012-05-06 16:22:05 -07001149 if (dfAttributes & DF_B_WIDE) {
1150 handleLiveInUse(cUnit, useV, defV, liveInV, dInsn->vB+1);
1151 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001152 }
1153 if (dfAttributes & DF_UC) {
1154 handleLiveInUse(cUnit, useV, defV, liveInV, dInsn->vC);
buzbeebff24652012-05-06 16:22:05 -07001155 if (dfAttributes & DF_C_WIDE) {
1156 handleLiveInUse(cUnit, useV, defV, liveInV, dInsn->vC+1);
1157 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001158 }
buzbee67bf8852011-08-17 17:51:35 -07001159 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001160 if (dfAttributes & DF_FORMAT_35C) {
1161 for (unsigned int i = 0; i < dInsn->vA; i++) {
1162 handleLiveInUse(cUnit, useV, defV, liveInV, dInsn->arg[i]);
1163 }
1164 }
1165 if (dfAttributes & DF_FORMAT_3RC) {
1166 for (unsigned int i = 0; i < dInsn->vA; i++) {
1167 handleLiveInUse(cUnit, useV, defV, liveInV, dInsn->vC+i);
1168 }
1169 }
1170 if (dfAttributes & DF_HAS_DEFS) {
1171 handleDef(cUnit, defV, dInsn->vA);
buzbeebff24652012-05-06 16:22:05 -07001172 if (dfAttributes & DF_A_WIDE) {
Bill Buzbeea114add2012-05-03 15:00:40 -07001173 handleDef(cUnit, defV, dInsn->vA+1);
1174 }
1175 }
1176 }
1177 return true;
buzbee67bf8852011-08-17 17:51:35 -07001178}
1179
buzbeee1965672012-03-11 18:39:19 -07001180int addNewSReg(CompilationUnit* cUnit, int vReg)
1181{
Bill Buzbeea114add2012-05-03 15:00:40 -07001182 // Compiler temps always have a subscript of 0
1183 int subscript = (vReg < 0) ? 0 : ++cUnit->SSALastDefs[vReg];
1184 int ssaReg = cUnit->numSSARegs++;
1185 oatInsertGrowableList(cUnit, cUnit->ssaBaseVRegs, vReg);
1186 oatInsertGrowableList(cUnit, cUnit->ssaSubscripts, subscript);
buzbee2cfc6392012-05-07 14:51:40 -07001187 char* name = (char*)oatNew(cUnit, SSA_NAME_MAX, true, kAllocDFInfo);
1188 oatInsertGrowableList(cUnit, cUnit->ssaStrings, (intptr_t)getSSAName(cUnit, ssaReg, name));
Bill Buzbeea114add2012-05-03 15:00:40 -07001189 DCHECK_EQ(cUnit->ssaBaseVRegs->numUsed, cUnit->ssaSubscripts->numUsed);
1190 return ssaReg;
buzbeee1965672012-03-11 18:39:19 -07001191}
1192
buzbee67bf8852011-08-17 17:51:35 -07001193/* Find out the latest SSA register for a given Dalvik register */
buzbee31a4a6f2012-02-28 15:36:15 -08001194void handleSSAUse(CompilationUnit* cUnit, int* uses, int dalvikReg,
1195 int regIndex)
buzbee67bf8852011-08-17 17:51:35 -07001196{
Bill Buzbeea114add2012-05-03 15:00:40 -07001197 DCHECK((dalvikReg >= 0) && (dalvikReg < cUnit->numDalvikRegisters));
1198 uses[regIndex] = cUnit->vRegToSSAMap[dalvikReg];
buzbee67bf8852011-08-17 17:51:35 -07001199}
1200
1201/* Setup a new SSA register for a given Dalvik register */
buzbee31a4a6f2012-02-28 15:36:15 -08001202void handleSSADef(CompilationUnit* cUnit, int* defs, int dalvikReg,
1203 int regIndex)
buzbee67bf8852011-08-17 17:51:35 -07001204{
Bill Buzbeea114add2012-05-03 15:00:40 -07001205 DCHECK((dalvikReg >= 0) && (dalvikReg < cUnit->numDalvikRegisters));
1206 int ssaReg = addNewSReg(cUnit, dalvikReg);
1207 cUnit->vRegToSSAMap[dalvikReg] = ssaReg;
1208 defs[regIndex] = ssaReg;
buzbee67bf8852011-08-17 17:51:35 -07001209}
1210
buzbeeec5adf32011-09-11 15:25:43 -07001211/* Look up new SSA names for format_35c instructions */
buzbee31a4a6f2012-02-28 15:36:15 -08001212void dataFlowSSAFormat35C(CompilationUnit* cUnit, MIR* mir)
buzbee67bf8852011-08-17 17:51:35 -07001213{
Bill Buzbeea114add2012-05-03 15:00:40 -07001214 DecodedInstruction *dInsn = &mir->dalvikInsn;
1215 int numUses = dInsn->vA;
1216 int i;
buzbee67bf8852011-08-17 17:51:35 -07001217
Bill Buzbeea114add2012-05-03 15:00:40 -07001218 mir->ssaRep->numUses = numUses;
1219 mir->ssaRep->uses = (int *)oatNew(cUnit, sizeof(int) * numUses, true,
1220 kAllocDFInfo);
1221 // NOTE: will be filled in during type & size inference pass
1222 mir->ssaRep->fpUse = (bool *)oatNew(cUnit, sizeof(bool) * numUses, true,
buzbee5abfa3e2012-01-31 17:01:43 -08001223 kAllocDFInfo);
buzbee67bf8852011-08-17 17:51:35 -07001224
Bill Buzbeea114add2012-05-03 15:00:40 -07001225 for (i = 0; i < numUses; i++) {
1226 handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->arg[i], i);
1227 }
buzbee67bf8852011-08-17 17:51:35 -07001228}
1229
buzbeeec5adf32011-09-11 15:25:43 -07001230/* Look up new SSA names for format_3rc instructions */
buzbee31a4a6f2012-02-28 15:36:15 -08001231void dataFlowSSAFormat3RC(CompilationUnit* cUnit, MIR* mir)
buzbee67bf8852011-08-17 17:51:35 -07001232{
Bill Buzbeea114add2012-05-03 15:00:40 -07001233 DecodedInstruction *dInsn = &mir->dalvikInsn;
1234 int numUses = dInsn->vA;
1235 int i;
buzbee67bf8852011-08-17 17:51:35 -07001236
Bill Buzbeea114add2012-05-03 15:00:40 -07001237 mir->ssaRep->numUses = numUses;
1238 mir->ssaRep->uses = (int *)oatNew(cUnit, sizeof(int) * numUses, true,
1239 kAllocDFInfo);
1240 // NOTE: will be filled in during type & size inference pass
1241 mir->ssaRep->fpUse = (bool *)oatNew(cUnit, sizeof(bool) * numUses, true,
buzbee5abfa3e2012-01-31 17:01:43 -08001242 kAllocDFInfo);
buzbee67bf8852011-08-17 17:51:35 -07001243
Bill Buzbeea114add2012-05-03 15:00:40 -07001244 for (i = 0; i < numUses; i++) {
1245 handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vC+i, i);
1246 }
buzbee67bf8852011-08-17 17:51:35 -07001247}
1248
1249/* Entry function to convert a block into SSA representation */
1250bool oatDoSSAConversion(CompilationUnit* cUnit, BasicBlock* bb)
1251{
Bill Buzbeea114add2012-05-03 15:00:40 -07001252 MIR* mir;
buzbee67bf8852011-08-17 17:51:35 -07001253
Bill Buzbeea114add2012-05-03 15:00:40 -07001254 if (bb->dataFlowInfo == NULL) return false;
buzbee67bf8852011-08-17 17:51:35 -07001255
Bill Buzbeea114add2012-05-03 15:00:40 -07001256 for (mir = bb->firstMIRInsn; mir; mir = mir->next) {
1257 mir->ssaRep = (struct SSARepresentation *)
1258 oatNew(cUnit, sizeof(SSARepresentation), true, kAllocDFInfo);
buzbee67bf8852011-08-17 17:51:35 -07001259
Bill Buzbeea114add2012-05-03 15:00:40 -07001260 int dfAttributes = oatDataFlowAttributes[mir->dalvikInsn.opcode];
buzbee67bf8852011-08-17 17:51:35 -07001261
Bill Buzbeea114add2012-05-03 15:00:40 -07001262 // If not a pseudo-op, note non-leaf or can throw
1263 if (static_cast<int>(mir->dalvikInsn.opcode) <
1264 static_cast<int>(kNumPackedOpcodes)) {
1265 int flags = Instruction::Flags(mir->dalvikInsn.opcode);
buzbeecefd1872011-09-09 09:59:52 -07001266
Bill Buzbeea114add2012-05-03 15:00:40 -07001267 if (flags & Instruction::kThrow) {
1268 cUnit->attrs &= ~METHOD_IS_THROW_FREE;
1269 }
buzbeecefd1872011-09-09 09:59:52 -07001270
Bill Buzbeea114add2012-05-03 15:00:40 -07001271 if (flags & Instruction::kInvoke) {
1272 cUnit->attrs &= ~METHOD_IS_LEAF;
1273 }
buzbee67bf8852011-08-17 17:51:35 -07001274 }
1275
Bill Buzbeea114add2012-05-03 15:00:40 -07001276 int numUses = 0;
buzbee67bf8852011-08-17 17:51:35 -07001277
Bill Buzbeea114add2012-05-03 15:00:40 -07001278 if (dfAttributes & DF_FORMAT_35C) {
1279 dataFlowSSAFormat35C(cUnit, mir);
1280 continue;
buzbee5abfa3e2012-01-31 17:01:43 -08001281 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001282
1283 if (dfAttributes & DF_FORMAT_3RC) {
1284 dataFlowSSAFormat3RC(cUnit, mir);
1285 continue;
1286 }
1287
1288 if (dfAttributes & DF_HAS_USES) {
1289 if (dfAttributes & DF_UA) {
1290 numUses++;
buzbeebff24652012-05-06 16:22:05 -07001291 if (dfAttributes & DF_A_WIDE) {
1292 numUses ++;
1293 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001294 }
1295 if (dfAttributes & DF_UB) {
1296 numUses++;
buzbeebff24652012-05-06 16:22:05 -07001297 if (dfAttributes & DF_B_WIDE) {
1298 numUses ++;
1299 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001300 }
1301 if (dfAttributes & DF_UC) {
1302 numUses++;
buzbeebff24652012-05-06 16:22:05 -07001303 if (dfAttributes & DF_C_WIDE) {
1304 numUses ++;
1305 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001306 }
1307 }
1308
1309 if (numUses) {
1310 mir->ssaRep->numUses = numUses;
1311 mir->ssaRep->uses = (int *)oatNew(cUnit, sizeof(int) * numUses,
1312 false, kAllocDFInfo);
1313 mir->ssaRep->fpUse = (bool *)oatNew(cUnit, sizeof(bool) * numUses,
1314 false, kAllocDFInfo);
1315 }
1316
1317 int numDefs = 0;
1318
1319 if (dfAttributes & DF_HAS_DEFS) {
1320 numDefs++;
buzbeebff24652012-05-06 16:22:05 -07001321 if (dfAttributes & DF_A_WIDE) {
Bill Buzbeea114add2012-05-03 15:00:40 -07001322 numDefs++;
1323 }
1324 }
1325
1326 if (numDefs) {
1327 mir->ssaRep->numDefs = numDefs;
1328 mir->ssaRep->defs = (int *)oatNew(cUnit, sizeof(int) * numDefs,
1329 false, kAllocDFInfo);
1330 mir->ssaRep->fpDef = (bool *)oatNew(cUnit, sizeof(bool) * numDefs,
1331 false, kAllocDFInfo);
1332 }
1333
1334 DecodedInstruction *dInsn = &mir->dalvikInsn;
1335
1336 if (dfAttributes & DF_HAS_USES) {
1337 numUses = 0;
1338 if (dfAttributes & DF_UA) {
1339 mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_A;
1340 handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vA, numUses++);
buzbeebff24652012-05-06 16:22:05 -07001341 if (dfAttributes & DF_A_WIDE) {
1342 mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_A;
1343 handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vA+1, numUses++);
1344 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001345 }
1346 if (dfAttributes & DF_UB) {
1347 mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_B;
1348 handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vB, numUses++);
buzbeebff24652012-05-06 16:22:05 -07001349 if (dfAttributes & DF_B_WIDE) {
1350 mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_B;
1351 handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vB+1, numUses++);
1352 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001353 }
1354 if (dfAttributes & DF_UC) {
1355 mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_C;
1356 handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vC, numUses++);
buzbeebff24652012-05-06 16:22:05 -07001357 if (dfAttributes & DF_C_WIDE) {
1358 mir->ssaRep->fpUse[numUses] = dfAttributes & DF_FP_C;
1359 handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vC+1, numUses++);
1360 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001361 }
1362 }
1363 if (dfAttributes & DF_HAS_DEFS) {
1364 mir->ssaRep->fpDef[0] = dfAttributes & DF_FP_A;
1365 handleSSADef(cUnit, mir->ssaRep->defs, dInsn->vA, 0);
buzbeebff24652012-05-06 16:22:05 -07001366 if (dfAttributes & DF_A_WIDE) {
Bill Buzbeea114add2012-05-03 15:00:40 -07001367 mir->ssaRep->fpDef[1] = dfAttributes & DF_FP_A;
1368 handleSSADef(cUnit, mir->ssaRep->defs, dInsn->vA+1, 1);
1369 }
1370 }
1371 }
1372
1373 if (!cUnit->disableDataflow) {
1374 /*
1375 * Take a snapshot of Dalvik->SSA mapping at the end of each block. The
1376 * input to PHI nodes can be derived from the snapshot of all
1377 * predecessor blocks.
1378 */
1379 bb->dataFlowInfo->vRegToSSAMap =
1380 (int *)oatNew(cUnit, sizeof(int) * cUnit->numDalvikRegisters, false,
1381 kAllocDFInfo);
1382
1383 memcpy(bb->dataFlowInfo->vRegToSSAMap, cUnit->vRegToSSAMap,
1384 sizeof(int) * cUnit->numDalvikRegisters);
1385 }
1386 return true;
buzbee67bf8852011-08-17 17:51:35 -07001387}
1388
1389/* Setup a constant value for opcodes thare have the DF_SETS_CONST attribute */
buzbee31a4a6f2012-02-28 15:36:15 -08001390void setConstant(CompilationUnit* cUnit, int ssaReg, int value)
buzbee67bf8852011-08-17 17:51:35 -07001391{
Bill Buzbeea114add2012-05-03 15:00:40 -07001392 oatSetBit(cUnit, cUnit->isConstantV, ssaReg);
1393 cUnit->constantValues[ssaReg] = value;
buzbee67bf8852011-08-17 17:51:35 -07001394}
1395
1396bool oatDoConstantPropagation(CompilationUnit* cUnit, BasicBlock* bb)
1397{
Bill Buzbeea114add2012-05-03 15:00:40 -07001398 MIR* mir;
1399 ArenaBitVector *isConstantV = cUnit->isConstantV;
buzbee67bf8852011-08-17 17:51:35 -07001400
Bill Buzbeea114add2012-05-03 15:00:40 -07001401 for (mir = bb->firstMIRInsn; mir; mir = mir->next) {
1402 int dfAttributes = oatDataFlowAttributes[mir->dalvikInsn.opcode];
buzbee67bf8852011-08-17 17:51:35 -07001403
Bill Buzbeea114add2012-05-03 15:00:40 -07001404 DecodedInstruction *dInsn = &mir->dalvikInsn;
buzbee67bf8852011-08-17 17:51:35 -07001405
Bill Buzbeea114add2012-05-03 15:00:40 -07001406 if (!(dfAttributes & DF_HAS_DEFS)) continue;
buzbee67bf8852011-08-17 17:51:35 -07001407
Bill Buzbeea114add2012-05-03 15:00:40 -07001408 /* Handle instructions that set up constants directly */
1409 if (dfAttributes & DF_SETS_CONST) {
1410 if (dfAttributes & DF_DA) {
1411 switch (dInsn->opcode) {
1412 case Instruction::CONST_4:
1413 case Instruction::CONST_16:
1414 case Instruction::CONST:
1415 setConstant(cUnit, mir->ssaRep->defs[0], dInsn->vB);
1416 break;
1417 case Instruction::CONST_HIGH16:
1418 setConstant(cUnit, mir->ssaRep->defs[0], dInsn->vB << 16);
1419 break;
buzbeebff24652012-05-06 16:22:05 -07001420 case Instruction::CONST_WIDE_16:
1421 case Instruction::CONST_WIDE_32:
1422 setConstant(cUnit, mir->ssaRep->defs[0], dInsn->vB);
1423 setConstant(cUnit, mir->ssaRep->defs[1], 0);
1424 break;
1425 case Instruction::CONST_WIDE:
1426 setConstant(cUnit, mir->ssaRep->defs[0], (int) dInsn->vB_wide);
1427 setConstant(cUnit, mir->ssaRep->defs[1],
1428 (int) (dInsn->vB_wide >> 32));
1429 break;
1430 case Instruction::CONST_WIDE_HIGH16:
1431 setConstant(cUnit, mir->ssaRep->defs[0], 0);
1432 setConstant(cUnit, mir->ssaRep->defs[1], dInsn->vB << 16);
1433 break;
Bill Buzbeea114add2012-05-03 15:00:40 -07001434 default:
1435 break;
buzbeebff24652012-05-06 16:22:05 -07001436 }
buzbee2cfc6392012-05-07 14:51:40 -07001437 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001438 /* Handle instructions that set up constants directly */
buzbee2cfc6392012-05-07 14:51:40 -07001439 } else if (dfAttributes & DF_IS_MOVE) {
1440 int i;
buzbee67bf8852011-08-17 17:51:35 -07001441
buzbee2cfc6392012-05-07 14:51:40 -07001442 for (i = 0; i < mir->ssaRep->numUses; i++) {
1443 if (!oatIsBitSet(isConstantV, mir->ssaRep->uses[i])) break;
Bill Buzbeea114add2012-05-03 15:00:40 -07001444 }
1445 /* Move a register holding a constant to another register */
1446 if (i == mir->ssaRep->numUses) {
1447 setConstant(cUnit, mir->ssaRep->defs[0],
1448 cUnit->constantValues[mir->ssaRep->uses[0]]);
buzbeebff24652012-05-06 16:22:05 -07001449 if (dfAttributes & DF_A_WIDE) {
Bill Buzbeea114add2012-05-03 15:00:40 -07001450 setConstant(cUnit, mir->ssaRep->defs[1],
1451 cUnit->constantValues[mir->ssaRep->uses[1]]);
buzbee67bf8852011-08-17 17:51:35 -07001452 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001453 }
buzbee67bf8852011-08-17 17:51:35 -07001454 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001455 }
1456 /* TODO: implement code to handle arithmetic operations */
1457 return true;
buzbee67bf8852011-08-17 17:51:35 -07001458}
1459
1460/* Setup the basic data structures for SSA conversion */
1461void oatInitializeSSAConversion(CompilationUnit* cUnit)
1462{
Bill Buzbeea114add2012-05-03 15:00:40 -07001463 int i;
1464 int numDalvikReg = cUnit->numDalvikRegisters;
buzbee67bf8852011-08-17 17:51:35 -07001465
Bill Buzbeea114add2012-05-03 15:00:40 -07001466 cUnit->ssaBaseVRegs = (GrowableList *)oatNew(cUnit, sizeof(GrowableList),
1467 false, kAllocDFInfo);
1468 cUnit->ssaSubscripts = (GrowableList *)oatNew(cUnit, sizeof(GrowableList),
1469 false, kAllocDFInfo);
buzbee2cfc6392012-05-07 14:51:40 -07001470 cUnit->ssaStrings = (GrowableList *)oatNew(cUnit, sizeof(GrowableList),
1471 false, kAllocDFInfo);
Bill Buzbeea114add2012-05-03 15:00:40 -07001472 // Create the ssa mappings, estimating the max size
1473 oatInitGrowableList(cUnit, cUnit->ssaBaseVRegs,
1474 numDalvikReg + cUnit->defCount + 128,
1475 kListSSAtoDalvikMap);
1476 oatInitGrowableList(cUnit, cUnit->ssaSubscripts,
1477 numDalvikReg + cUnit->defCount + 128,
1478 kListSSAtoDalvikMap);
buzbee2cfc6392012-05-07 14:51:40 -07001479 oatInitGrowableList(cUnit, cUnit->ssaStrings,
1480 numDalvikReg + cUnit->defCount + 128,
1481 kListSSAtoDalvikMap);
Bill Buzbeea114add2012-05-03 15:00:40 -07001482 /*
1483 * Initial number of SSA registers is equal to the number of Dalvik
1484 * registers.
1485 */
1486 cUnit->numSSARegs = numDalvikReg;
buzbee67bf8852011-08-17 17:51:35 -07001487
Bill Buzbeea114add2012-05-03 15:00:40 -07001488 /*
1489 * Initialize the SSA2Dalvik map list. For the first numDalvikReg elements,
1490 * the subscript is 0 so we use the ENCODE_REG_SUB macro to encode the value
1491 * into "(0 << 16) | i"
1492 */
1493 for (i = 0; i < numDalvikReg; i++) {
1494 oatInsertGrowableList(cUnit, cUnit->ssaBaseVRegs, i);
1495 oatInsertGrowableList(cUnit, cUnit->ssaSubscripts, 0);
buzbee2cfc6392012-05-07 14:51:40 -07001496 char* name = (char*)oatNew(cUnit, SSA_NAME_MAX, true, kAllocDFInfo);
1497 oatInsertGrowableList(cUnit, cUnit->ssaStrings, (intptr_t)getSSAName(cUnit, i, name));
Bill Buzbeea114add2012-05-03 15:00:40 -07001498 }
buzbee67bf8852011-08-17 17:51:35 -07001499
Bill Buzbeea114add2012-05-03 15:00:40 -07001500 /*
1501 * Initialize the DalvikToSSAMap map. There is one entry for each
1502 * Dalvik register, and the SSA names for those are the same.
1503 */
1504 cUnit->vRegToSSAMap = (int *)oatNew(cUnit, sizeof(int) * numDalvikReg,
1505 false, kAllocDFInfo);
1506 /* Keep track of the higest def for each dalvik reg */
1507 cUnit->SSALastDefs = (int *)oatNew(cUnit, sizeof(int) * numDalvikReg,
1508 false, kAllocDFInfo);
buzbeef0cde542011-09-13 14:55:02 -07001509
Bill Buzbeea114add2012-05-03 15:00:40 -07001510 for (i = 0; i < numDalvikReg; i++) {
1511 cUnit->vRegToSSAMap[i] = i;
1512 cUnit->SSALastDefs[i] = 0;
1513 }
buzbee67bf8852011-08-17 17:51:35 -07001514
Bill Buzbeea114add2012-05-03 15:00:40 -07001515 /* Add ssa reg for Method* */
1516 cUnit->methodSReg = addNewSReg(cUnit, SSA_METHOD_BASEREG);
buzbeee1965672012-03-11 18:39:19 -07001517
Bill Buzbeea114add2012-05-03 15:00:40 -07001518 /*
1519 * Allocate the BasicBlockDataFlow structure for the entry and code blocks
1520 */
1521 GrowableListIterator iterator;
buzbee67bf8852011-08-17 17:51:35 -07001522
Bill Buzbeea114add2012-05-03 15:00:40 -07001523 oatGrowableListIteratorInit(&cUnit->blockList, &iterator);
buzbee67bf8852011-08-17 17:51:35 -07001524
Bill Buzbeea114add2012-05-03 15:00:40 -07001525 while (true) {
1526 BasicBlock* bb = (BasicBlock *) oatGrowableListIteratorNext(&iterator);
1527 if (bb == NULL) break;
1528 if (bb->hidden == true) continue;
1529 if (bb->blockType == kDalvikByteCode ||
1530 bb->blockType == kEntryBlock ||
1531 bb->blockType == kExitBlock) {
1532 bb->dataFlowInfo = (BasicBlockDataFlow *)
1533 oatNew(cUnit, sizeof(BasicBlockDataFlow), true, kAllocDFInfo);
1534 }
1535 }
buzbee67bf8852011-08-17 17:51:35 -07001536}
1537
1538/* Clear the visited flag for each BB */
buzbee31a4a6f2012-02-28 15:36:15 -08001539bool oatClearVisitedFlag(struct CompilationUnit* cUnit, struct BasicBlock* bb)
buzbee67bf8852011-08-17 17:51:35 -07001540{
Bill Buzbeea114add2012-05-03 15:00:40 -07001541 bb->visited = false;
1542 return true;
buzbee67bf8852011-08-17 17:51:35 -07001543}
1544
1545void oatDataFlowAnalysisDispatcher(CompilationUnit* cUnit,
Bill Buzbeea114add2012-05-03 15:00:40 -07001546 bool (*func)(CompilationUnit*, BasicBlock*),
1547 DataFlowAnalysisMode dfaMode,
1548 bool isIterative)
buzbee67bf8852011-08-17 17:51:35 -07001549{
Bill Buzbeea114add2012-05-03 15:00:40 -07001550 bool change = true;
buzbee67bf8852011-08-17 17:51:35 -07001551
Bill Buzbeea114add2012-05-03 15:00:40 -07001552 while (change) {
1553 change = false;
buzbee67bf8852011-08-17 17:51:35 -07001554
Bill Buzbeea114add2012-05-03 15:00:40 -07001555 switch (dfaMode) {
1556 /* Scan all blocks and perform the operations specified in func */
1557 case kAllNodes:
1558 {
1559 GrowableListIterator iterator;
1560 oatGrowableListIteratorInit(&cUnit->blockList, &iterator);
1561 while (true) {
1562 BasicBlock* bb =
1563 (BasicBlock *) oatGrowableListIteratorNext(&iterator);
1564 if (bb == NULL) break;
1565 if (bb->hidden == true) continue;
1566 change |= (*func)(cUnit, bb);
1567 }
buzbee67bf8852011-08-17 17:51:35 -07001568 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001569 break;
1570 /* Scan reachable blocks and perform the ops specified in func. */
1571 case kReachableNodes:
1572 {
1573 int numReachableBlocks = cUnit->numReachableBlocks;
1574 int idx;
1575 const GrowableList *blockList = &cUnit->blockList;
1576
1577 for (idx = 0; idx < numReachableBlocks; idx++) {
1578 int blockIdx = cUnit->dfsOrder.elemList[idx];
1579 BasicBlock* bb = (BasicBlock *)
1580 oatGrowableListGetElement(blockList, blockIdx);
1581 change |= (*func)(cUnit, bb);
1582 }
1583 }
1584 break;
1585
1586 /* Scan reachable blocks by pre-order dfs and invoke func on each. */
1587 case kPreOrderDFSTraversal:
1588 {
1589 int numReachableBlocks = cUnit->numReachableBlocks;
1590 int idx;
1591 const GrowableList *blockList = &cUnit->blockList;
1592
1593 for (idx = 0; idx < numReachableBlocks; idx++) {
1594 int dfsIdx = cUnit->dfsOrder.elemList[idx];
1595 BasicBlock* bb = (BasicBlock *)
1596 oatGrowableListGetElement(blockList, dfsIdx);
1597 change |= (*func)(cUnit, bb);
1598 }
1599 }
1600 break;
1601 /* Scan reachable blocks post-order dfs and invoke func on each. */
1602 case kPostOrderDFSTraversal:
1603 {
1604 int numReachableBlocks = cUnit->numReachableBlocks;
1605 int idx;
1606 const GrowableList *blockList = &cUnit->blockList;
1607
1608 for (idx = numReachableBlocks - 1; idx >= 0; idx--) {
1609 int dfsIdx = cUnit->dfsOrder.elemList[idx];
1610 BasicBlock* bb = (BasicBlock *)
1611 oatGrowableListGetElement(blockList, dfsIdx);
1612 change |= (*func)(cUnit, bb);
1613 }
1614 }
1615 break;
1616 /* Scan reachable post-order dom tree and invoke func on each. */
1617 case kPostOrderDOMTraversal:
1618 {
1619 int numReachableBlocks = cUnit->numReachableBlocks;
1620 int idx;
1621 const GrowableList *blockList = &cUnit->blockList;
1622
1623 for (idx = 0; idx < numReachableBlocks; idx++) {
1624 int domIdx = cUnit->domPostOrderTraversal.elemList[idx];
1625 BasicBlock* bb = (BasicBlock *)
1626 oatGrowableListGetElement(blockList, domIdx);
1627 change |= (*func)(cUnit, bb);
1628 }
1629 }
1630 break;
1631 /* Scan reachable blocks reverse post-order dfs, invoke func on each */
1632 case kReversePostOrderTraversal:
1633 {
1634 int numReachableBlocks = cUnit->numReachableBlocks;
1635 int idx;
1636 const GrowableList *blockList = &cUnit->blockList;
1637
1638 for (idx = numReachableBlocks - 1; idx >= 0; idx--) {
1639 int revIdx = cUnit->dfsPostOrder.elemList[idx];
1640 BasicBlock* bb = (BasicBlock *)
1641 oatGrowableListGetElement(blockList, revIdx);
1642 change |= (*func)(cUnit, bb);
1643 }
1644 }
1645 break;
1646 default:
1647 LOG(FATAL) << "Unknown traversal mode " << (int)dfaMode;
buzbee67bf8852011-08-17 17:51:35 -07001648 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001649 /* If isIterative is false, exit the loop after the first iteration */
1650 change &= isIterative;
1651 }
buzbee67bf8852011-08-17 17:51:35 -07001652}
buzbee43a36422011-09-14 14:00:13 -07001653
buzbeee1965672012-03-11 18:39:19 -07001654/* Advance to next strictly dominated MIR node in an extended basic block */
Bill Buzbeea114add2012-05-03 15:00:40 -07001655MIR* advanceMIR(CompilationUnit* cUnit, BasicBlock** pBb, MIR* mir,
1656 ArenaBitVector* bv, bool clearMark) {
1657 BasicBlock* bb = *pBb;
1658 if (mir != NULL) {
1659 mir = mir->next;
1660 if (mir == NULL) {
1661 bb = bb->fallThrough;
1662 if ((bb == NULL) || bb->predecessors->numUsed != 1) {
1663 mir = NULL;
1664 } else {
1665 if (bv) {
1666 oatSetBit(cUnit, bv, bb->id);
buzbeee1965672012-03-11 18:39:19 -07001667 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001668 *pBb = bb;
1669 mir = bb->firstMIRInsn;
1670 }
buzbeee1965672012-03-11 18:39:19 -07001671 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001672 }
1673 if (mir && clearMark) {
1674 mir->optimizationFlags &= ~MIR_MARK;
1675 }
1676 return mir;
buzbeee1965672012-03-11 18:39:19 -07001677}
1678
buzbeefc9e6fa2012-03-23 15:14:29 -07001679/*
1680 * To be used at an invoke mir. If the logically next mir node represents
1681 * a move-result, return it. Else, return NULL. If a move-result exists,
1682 * it is required to immediately follow the invoke with no intervening
1683 * opcodes or incoming arcs. However, if the result of the invoke is not
1684 * used, a move-result may not be present.
1685 */
1686MIR* oatFindMoveResult(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir,
Bill Buzbeea114add2012-05-03 15:00:40 -07001687 bool wide)
buzbeefc9e6fa2012-03-23 15:14:29 -07001688{
Bill Buzbeea114add2012-05-03 15:00:40 -07001689 BasicBlock* tbb = bb;
1690 mir = advanceMIR(cUnit, &tbb, mir, NULL, false);
1691 while (mir != NULL) {
1692 if (!wide && mir->dalvikInsn.opcode == Instruction::MOVE_RESULT) {
1693 break;
buzbeefc9e6fa2012-03-23 15:14:29 -07001694 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001695 if (wide && mir->dalvikInsn.opcode == Instruction::MOVE_RESULT_WIDE) {
1696 break;
1697 }
1698 // Keep going if pseudo op, otherwise terminate
1699 if (mir->dalvikInsn.opcode <
1700 static_cast<Instruction::Code>(kNumPackedOpcodes)) {
1701 mir = NULL;
1702 } else {
1703 mir = advanceMIR(cUnit, &tbb, mir, NULL, false);
1704 }
1705 }
1706 return mir;
buzbeefc9e6fa2012-03-23 15:14:29 -07001707}
1708
buzbee239c4e72012-03-16 08:42:29 -07001709void squashDupRangeChecks(CompilationUnit* cUnit, BasicBlock** pBp, MIR* mir,
Bill Buzbeea114add2012-05-03 15:00:40 -07001710 int arraySreg, int indexSreg)
buzbee239c4e72012-03-16 08:42:29 -07001711{
Bill Buzbeea114add2012-05-03 15:00:40 -07001712 while (true) {
1713 mir = advanceMIR(cUnit, pBp, mir, NULL, false);
1714 if (!mir) {
1715 break;
buzbee239c4e72012-03-16 08:42:29 -07001716 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001717 if ((mir->ssaRep == NULL) ||
1718 (mir->optimizationFlags & MIR_IGNORE_RANGE_CHECK)) {
1719 continue;
1720 }
1721 int checkArray = INVALID_SREG;
1722 int checkIndex = INVALID_SREG;
1723 switch (mir->dalvikInsn.opcode) {
1724 case Instruction::AGET:
1725 case Instruction::AGET_OBJECT:
1726 case Instruction::AGET_BOOLEAN:
1727 case Instruction::AGET_BYTE:
1728 case Instruction::AGET_CHAR:
1729 case Instruction::AGET_SHORT:
1730 case Instruction::AGET_WIDE:
1731 checkArray = mir->ssaRep->uses[0];
1732 checkIndex = mir->ssaRep->uses[1];
1733 break;
1734 case Instruction::APUT:
1735 case Instruction::APUT_OBJECT:
1736 case Instruction::APUT_SHORT:
1737 case Instruction::APUT_CHAR:
1738 case Instruction::APUT_BYTE:
1739 case Instruction::APUT_BOOLEAN:
1740 checkArray = mir->ssaRep->uses[1];
1741 checkIndex = mir->ssaRep->uses[2];
1742 break;
1743 case Instruction::APUT_WIDE:
1744 checkArray = mir->ssaRep->uses[2];
1745 checkIndex = mir->ssaRep->uses[3];
1746 default:
1747 break;
1748 }
1749 if (checkArray == INVALID_SREG) {
1750 continue;
1751 }
1752 if ((arraySreg == checkArray) && (indexSreg == checkIndex)) {
1753 if (cUnit->printMe) {
1754 LOG(INFO) << "Squashing range check @ 0x" << std::hex << mir->offset;
1755 }
1756 mir->optimizationFlags |= MIR_IGNORE_RANGE_CHECK;
1757 }
1758 }
buzbee239c4e72012-03-16 08:42:29 -07001759}
1760
buzbeee1965672012-03-11 18:39:19 -07001761/* Allocate a compiler temp, return Sreg. Reuse existing if no conflict */
1762int allocCompilerTempSreg(CompilationUnit* cUnit, ArenaBitVector* bv)
1763{
Bill Buzbeea114add2012-05-03 15:00:40 -07001764 for (int i = 0; i < cUnit->numCompilerTemps; i++) {
1765 CompilerTemp* ct = (CompilerTemp*)cUnit->compilerTemps.elemList[i];
1766 ArenaBitVector* tBv = ct->bv;
1767 if (!oatTestBitVectors(bv, tBv)) {
1768 // Combine live maps and reuse existing temp
1769 oatUnifyBitVectors(tBv, tBv, bv);
1770 return ct->sReg;
buzbeee1965672012-03-11 18:39:19 -07001771 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001772 }
buzbeee1965672012-03-11 18:39:19 -07001773
Bill Buzbeea114add2012-05-03 15:00:40 -07001774 // Create a new compiler temp & associated live bitmap
1775 CompilerTemp* ct = (CompilerTemp*)oatNew(cUnit, sizeof(CompilerTemp),
1776 true, kAllocMisc);
1777 ArenaBitVector *nBv = oatAllocBitVector(cUnit, cUnit->numBlocks, true,
1778 kBitMapMisc);
1779 oatCopyBitVector(nBv, bv);
1780 ct->bv = nBv;
1781 ct->sReg = addNewSReg(cUnit, SSA_CTEMP_BASEREG - cUnit->numCompilerTemps);
1782 cUnit->numCompilerTemps++;
1783 oatInsertGrowableList(cUnit, &cUnit->compilerTemps, (intptr_t)ct);
1784 DCHECK_EQ(cUnit->numCompilerTemps, (int)cUnit->compilerTemps.numUsed);
1785 return ct->sReg;
buzbeee1965672012-03-11 18:39:19 -07001786}
1787
1788/* Creata a new MIR node for a new pseudo op. */
Bill Buzbeea114add2012-05-03 15:00:40 -07001789MIR* rawMIR(CompilationUnit* cUnit, Instruction::Code opcode, int defs,
1790 int uses)
buzbeee1965672012-03-11 18:39:19 -07001791{
Bill Buzbeea114add2012-05-03 15:00:40 -07001792 MIR* res = (MIR*)oatNew( cUnit, sizeof(MIR), true, kAllocMIR);
1793 res->ssaRep =(struct SSARepresentation *)
1794 oatNew(cUnit, sizeof(SSARepresentation), true, kAllocDFInfo);
1795 if (uses) {
1796 res->ssaRep->numUses = uses;
1797 res->ssaRep->uses = (int*)oatNew(cUnit, sizeof(int) * uses, false,
1798 kAllocDFInfo);
1799 }
1800 if (defs) {
1801 res->ssaRep->numDefs = defs;
1802 res->ssaRep->defs = (int*)oatNew(cUnit, sizeof(int) * defs, false,
1803 kAllocDFInfo);
1804 res->ssaRep->fpDef = (bool*)oatNew(cUnit, sizeof(bool) * defs, true,
1805 kAllocDFInfo);
1806 }
1807 res->dalvikInsn.opcode = opcode;
1808 return res;
buzbeee1965672012-03-11 18:39:19 -07001809}
1810
1811/* Do some MIR-level basic block optimizations */
1812bool basicBlockOpt(CompilationUnit* cUnit, BasicBlock* bb)
1813{
Bill Buzbeea114add2012-05-03 15:00:40 -07001814 int numTemps = 0;
buzbeee1965672012-03-11 18:39:19 -07001815
Bill Buzbeea114add2012-05-03 15:00:40 -07001816 for (MIR* mir = bb->firstMIRInsn; mir; mir = mir->next) {
1817 // Look for interesting opcodes, skip otherwise
1818 Instruction::Code opcode = mir->dalvikInsn.opcode;
1819 switch (opcode) {
1820 case Instruction::AGET:
1821 case Instruction::AGET_OBJECT:
1822 case Instruction::AGET_BOOLEAN:
1823 case Instruction::AGET_BYTE:
1824 case Instruction::AGET_CHAR:
1825 case Instruction::AGET_SHORT:
1826 case Instruction::AGET_WIDE:
1827 if (!(mir->optimizationFlags & MIR_IGNORE_RANGE_CHECK)) {
1828 int arrSreg = mir->ssaRep->uses[0];
1829 int idxSreg = mir->ssaRep->uses[1];
1830 BasicBlock* tbb = bb;
1831 squashDupRangeChecks(cUnit, &tbb, mir, arrSreg, idxSreg);
buzbeee1965672012-03-11 18:39:19 -07001832 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001833 break;
1834 case Instruction::APUT:
1835 case Instruction::APUT_OBJECT:
1836 case Instruction::APUT_SHORT:
1837 case Instruction::APUT_CHAR:
1838 case Instruction::APUT_BYTE:
1839 case Instruction::APUT_BOOLEAN:
1840 case Instruction::APUT_WIDE:
1841 if (!(mir->optimizationFlags & MIR_IGNORE_RANGE_CHECK)) {
1842 int start = (opcode == Instruction::APUT_WIDE) ? 2 : 1;
1843 int arrSreg = mir->ssaRep->uses[start];
1844 int idxSreg = mir->ssaRep->uses[start + 1];
1845 BasicBlock* tbb = bb;
1846 squashDupRangeChecks(cUnit, &tbb, mir, arrSreg, idxSreg);
1847 }
1848 break;
1849 case Instruction::CMPL_FLOAT:
1850 case Instruction::CMPL_DOUBLE:
1851 case Instruction::CMPG_FLOAT:
1852 case Instruction::CMPG_DOUBLE:
1853 case Instruction::CMP_LONG:
1854 if (mir->next != NULL) {
1855 MIR* mirNext = mir->next;
1856 Instruction::Code brOpcode = mirNext->dalvikInsn.opcode;
1857 ConditionCode ccode = kCondNv;
1858 switch(brOpcode) {
1859 case Instruction::IF_EQZ:
1860 ccode = kCondEq;
1861 break;
1862 case Instruction::IF_NEZ:
1863 ccode = kCondNe;
1864 break;
1865 case Instruction::IF_LTZ:
1866 ccode = kCondLt;
1867 break;
1868 case Instruction::IF_GEZ:
1869 ccode = kCondGe;
1870 break;
1871 case Instruction::IF_GTZ:
1872 ccode = kCondGt;
1873 break;
1874 case Instruction::IF_LEZ:
1875 ccode = kCondLe;
1876 break;
1877 default:
1878 break;
1879 }
1880 // Make sure result of cmp is used by next insn and nowhere else
1881 if ((ccode != kCondNv) &&
1882 (mir->ssaRep->defs[0] == mirNext->ssaRep->uses[0]) &&
1883 (getSSAUseCount(cUnit, mir->ssaRep->defs[0]) == 1)) {
1884 mirNext->dalvikInsn.arg[0] = ccode;
1885 switch(opcode) {
1886 case Instruction::CMPL_FLOAT:
1887 mirNext->dalvikInsn.opcode =
1888 static_cast<Instruction::Code>(kMirOpFusedCmplFloat);
1889 break;
1890 case Instruction::CMPL_DOUBLE:
1891 mirNext->dalvikInsn.opcode =
1892 static_cast<Instruction::Code>(kMirOpFusedCmplDouble);
1893 break;
1894 case Instruction::CMPG_FLOAT:
1895 mirNext->dalvikInsn.opcode =
1896 static_cast<Instruction::Code>(kMirOpFusedCmpgFloat);
1897 break;
1898 case Instruction::CMPG_DOUBLE:
1899 mirNext->dalvikInsn.opcode =
1900 static_cast<Instruction::Code>(kMirOpFusedCmpgDouble);
1901 break;
1902 case Instruction::CMP_LONG:
1903 mirNext->dalvikInsn.opcode =
1904 static_cast<Instruction::Code>(kMirOpFusedCmpLong);
1905 break;
1906 default: LOG(ERROR) << "Unexpected opcode: " << (int)opcode;
1907 }
1908 mir->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpNop);
1909 mirNext->ssaRep->numUses = mir->ssaRep->numUses;
1910 mirNext->ssaRep->uses = mir->ssaRep->uses;
1911 mirNext->ssaRep->fpUse = mir->ssaRep->fpUse;
1912 mirNext->ssaRep->numDefs = 0;
1913 mir->ssaRep->numUses = 0;
1914 mir->ssaRep->numDefs = 0;
1915 }
1916 }
1917 break;
1918 default:
1919 break;
buzbeee1965672012-03-11 18:39:19 -07001920 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001921 }
buzbeee1965672012-03-11 18:39:19 -07001922
Bill Buzbeea114add2012-05-03 15:00:40 -07001923 if (numTemps > cUnit->numCompilerTemps) {
1924 cUnit->numCompilerTemps = numTemps;
1925 }
1926 return true;
buzbeee1965672012-03-11 18:39:19 -07001927}
1928
buzbee31a4a6f2012-02-28 15:36:15 -08001929bool nullCheckEliminationInit(struct CompilationUnit* cUnit,
1930 struct BasicBlock* bb)
buzbee43a36422011-09-14 14:00:13 -07001931{
Bill Buzbeea114add2012-05-03 15:00:40 -07001932 if (bb->dataFlowInfo == NULL) return false;
1933 bb->dataFlowInfo->endingNullCheckV =
1934 oatAllocBitVector(cUnit, cUnit->numSSARegs, false, kBitMapNullCheck);
1935 oatClearAllBits(bb->dataFlowInfo->endingNullCheckV);
1936 return true;
buzbee43a36422011-09-14 14:00:13 -07001937}
1938
1939/* Eliminate unnecessary null checks for a basic block. */
buzbee31a4a6f2012-02-28 15:36:15 -08001940bool eliminateNullChecks( struct CompilationUnit* cUnit, struct BasicBlock* bb)
buzbee43a36422011-09-14 14:00:13 -07001941{
Bill Buzbeea114add2012-05-03 15:00:40 -07001942 if (bb->dataFlowInfo == NULL) return false;
1943
1944 /*
1945 * Set initial state. Be conservative with catch
1946 * blocks and start with no assumptions about null check
1947 * status (except for "this").
1948 */
1949 if ((bb->blockType == kEntryBlock) | bb->catchEntry) {
1950 oatClearAllBits(cUnit->tempSSARegisterV);
1951 if ((cUnit->access_flags & kAccStatic) == 0) {
1952 // If non-static method, mark "this" as non-null
1953 int thisReg = cUnit->numDalvikRegisters - cUnit->numIns;
1954 oatSetBit(cUnit, cUnit->tempSSARegisterV, thisReg);
1955 }
1956 } else {
1957 // Starting state is intesection of all incoming arcs
1958 GrowableListIterator iter;
1959 oatGrowableListIteratorInit(bb->predecessors, &iter);
1960 BasicBlock* predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter);
1961 DCHECK(predBB != NULL);
1962 oatCopyBitVector(cUnit->tempSSARegisterV,
1963 predBB->dataFlowInfo->endingNullCheckV);
1964 while (true) {
1965 predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter);
1966 if (!predBB) break;
1967 if ((predBB->dataFlowInfo == NULL) ||
1968 (predBB->dataFlowInfo->endingNullCheckV == NULL)) {
1969 continue;
1970 }
1971 oatIntersectBitVectors(cUnit->tempSSARegisterV,
1972 cUnit->tempSSARegisterV,
1973 predBB->dataFlowInfo->endingNullCheckV);
1974 }
1975 }
1976
1977 // Walk through the instruction in the block, updating as necessary
1978 for (MIR* mir = bb->firstMIRInsn; mir; mir = mir->next) {
1979 if (mir->ssaRep == NULL) {
1980 continue;
1981 }
1982 int dfAttributes = oatDataFlowAttributes[mir->dalvikInsn.opcode];
1983
1984 // Mark target of NEW* as non-null
1985 if (dfAttributes & DF_NON_NULL_DST) {
1986 oatSetBit(cUnit, cUnit->tempSSARegisterV, mir->ssaRep->defs[0]);
1987 }
1988
1989 // Mark non-null returns from invoke-style NEW*
1990 if (dfAttributes & DF_NON_NULL_RET) {
1991 MIR* nextMir = mir->next;
1992 // Next should be an MOVE_RESULT_OBJECT
1993 if (nextMir &&
1994 nextMir->dalvikInsn.opcode == Instruction::MOVE_RESULT_OBJECT) {
1995 // Mark as null checked
1996 oatSetBit(cUnit, cUnit->tempSSARegisterV, nextMir->ssaRep->defs[0]);
1997 } else {
1998 if (nextMir) {
1999 LOG(WARNING) << "Unexpected opcode following new: "
2000 << (int)nextMir->dalvikInsn.opcode;
2001 } else if (bb->fallThrough) {
2002 // Look in next basic block
2003 struct BasicBlock* nextBB = bb->fallThrough;
2004 for (MIR* tmir = nextBB->firstMIRInsn; tmir;
2005 tmir =tmir->next) {
2006 if ((int)tmir->dalvikInsn.opcode >= (int)kMirOpFirst) {
2007 continue;
2008 }
2009 // First non-pseudo should be MOVE_RESULT_OBJECT
2010 if (tmir->dalvikInsn.opcode == Instruction::MOVE_RESULT_OBJECT) {
2011 // Mark as null checked
2012 oatSetBit(cUnit, cUnit->tempSSARegisterV, tmir->ssaRep->defs[0]);
2013 } else {
2014 LOG(WARNING) << "Unexpected op after new: "
2015 << (int)tmir->dalvikInsn.opcode;
2016 }
2017 break;
2018 }
2019 }
2020 }
2021 }
buzbee5abfa3e2012-01-31 17:01:43 -08002022
buzbee43a36422011-09-14 14:00:13 -07002023 /*
Bill Buzbeea114add2012-05-03 15:00:40 -07002024 * Propagate nullcheck state on register copies (including
2025 * Phi pseudo copies. For the latter, nullcheck state is
2026 * the "and" of all the Phi's operands.
buzbee43a36422011-09-14 14:00:13 -07002027 */
Bill Buzbeea114add2012-05-03 15:00:40 -07002028 if (dfAttributes & (DF_NULL_TRANSFER_0 | DF_NULL_TRANSFER_N)) {
2029 int tgtSreg = mir->ssaRep->defs[0];
2030 int operands = (dfAttributes & DF_NULL_TRANSFER_0) ? 1 :
2031 mir->ssaRep->numUses;
2032 bool nullChecked = true;
2033 for (int i = 0; i < operands; i++) {
2034 nullChecked &= oatIsBitSet(cUnit->tempSSARegisterV,
2035 mir->ssaRep->uses[i]);
2036 }
2037 if (nullChecked) {
2038 oatSetBit(cUnit, cUnit->tempSSARegisterV, tgtSreg);
2039 }
buzbee43a36422011-09-14 14:00:13 -07002040 }
2041
Bill Buzbeea114add2012-05-03 15:00:40 -07002042 // Already nullchecked?
2043 if (dfAttributes & DF_HAS_NULL_CHKS) {
2044 int srcIdx;
2045 if (dfAttributes & DF_NULL_CHK_1) {
2046 srcIdx = 1;
2047 } else if (dfAttributes & DF_NULL_CHK_2) {
2048 srcIdx = 2;
2049 } else {
2050 srcIdx = 0;
2051 }
2052 int srcSreg = mir->ssaRep->uses[srcIdx];
2053 if (oatIsBitSet(cUnit->tempSSARegisterV, srcSreg)) {
2054 // Eliminate the null check
2055 mir->optimizationFlags |= MIR_IGNORE_NULL_CHECK;
2056 } else {
2057 // Mark sReg as null-checked
2058 oatSetBit(cUnit, cUnit->tempSSARegisterV, srcSreg);
buzbee43a36422011-09-14 14:00:13 -07002059 }
Bill Buzbeea114add2012-05-03 15:00:40 -07002060 }
2061 }
buzbee43a36422011-09-14 14:00:13 -07002062
Bill Buzbeea114add2012-05-03 15:00:40 -07002063 // Did anything change?
2064 bool res = oatCompareBitVectors(bb->dataFlowInfo->endingNullCheckV,
2065 cUnit->tempSSARegisterV);
2066 if (res) {
2067 oatCopyBitVector(bb->dataFlowInfo->endingNullCheckV,
2068 cUnit->tempSSARegisterV);
2069 }
2070 return res;
buzbee43a36422011-09-14 14:00:13 -07002071}
2072
2073void oatMethodNullCheckElimination(CompilationUnit *cUnit)
2074{
Bill Buzbeea114add2012-05-03 15:00:40 -07002075 if (!(cUnit->disableOpt & (1 << kNullCheckElimination))) {
2076 DCHECK(cUnit->tempSSARegisterV != NULL);
2077 oatDataFlowAnalysisDispatcher(cUnit, nullCheckEliminationInit, kAllNodes,
2078 false /* isIterative */);
2079 oatDataFlowAnalysisDispatcher(cUnit, eliminateNullChecks,
2080 kPreOrderDFSTraversal,
2081 true /* isIterative */);
2082 }
buzbee43a36422011-09-14 14:00:13 -07002083}
Elliott Hughes11d1b0c2012-01-23 16:57:47 -08002084
buzbeee1965672012-03-11 18:39:19 -07002085void oatMethodBasicBlockOptimization(CompilationUnit *cUnit)
2086{
Bill Buzbeea114add2012-05-03 15:00:40 -07002087 if (!(cUnit->disableOpt & (1 << kBBOpt))) {
2088 oatInitGrowableList(cUnit, &cUnit->compilerTemps, 6, kListMisc);
2089 DCHECK_EQ(cUnit->numCompilerTemps, 0);
buzbeee1965672012-03-11 18:39:19 -07002090 if (!(cUnit->disableOpt & (1 << kBBOpt))) {
Bill Buzbeea114add2012-05-03 15:00:40 -07002091 oatDataFlowAnalysisDispatcher(cUnit, basicBlockOpt,
2092 kAllNodes, false /* isIterative */);
buzbeee1965672012-03-11 18:39:19 -07002093 }
Bill Buzbeea114add2012-05-03 15:00:40 -07002094 }
buzbeee1965672012-03-11 18:39:19 -07002095}
2096
buzbee239c4e72012-03-16 08:42:29 -07002097void addLoopHeader(CompilationUnit* cUnit, BasicBlock* header,
Bill Buzbeea114add2012-05-03 15:00:40 -07002098 BasicBlock* backEdge)
buzbee239c4e72012-03-16 08:42:29 -07002099{
Bill Buzbeea114add2012-05-03 15:00:40 -07002100 GrowableListIterator iter;
2101 oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
2102 for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
2103 (loop != NULL); loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
2104 if (loop->header == header) {
2105 oatInsertGrowableList(cUnit, &loop->incomingBackEdges,
2106 (intptr_t)backEdge);
2107 return;
buzbee239c4e72012-03-16 08:42:29 -07002108 }
Bill Buzbeea114add2012-05-03 15:00:40 -07002109 }
2110 LoopInfo* info = (LoopInfo*)oatNew(cUnit, sizeof(LoopInfo), true,
2111 kAllocDFInfo);
2112 info->header = header;
2113 oatInitGrowableList(cUnit, &info->incomingBackEdges, 2, kListMisc);
2114 oatInsertGrowableList(cUnit, &info->incomingBackEdges, (intptr_t)backEdge);
2115 oatInsertGrowableList(cUnit, &cUnit->loopHeaders, (intptr_t)info);
buzbee239c4e72012-03-16 08:42:29 -07002116}
2117
2118bool findBackEdges(struct CompilationUnit* cUnit, struct BasicBlock* bb)
2119{
Bill Buzbeea114add2012-05-03 15:00:40 -07002120 if ((bb->dataFlowInfo == NULL) || (bb->lastMIRInsn == NULL)) {
buzbee239c4e72012-03-16 08:42:29 -07002121 return false;
Bill Buzbeea114add2012-05-03 15:00:40 -07002122 }
2123 Instruction::Code opcode = bb->lastMIRInsn->dalvikInsn.opcode;
2124 if (Instruction::Flags(opcode) & Instruction::kBranch) {
2125 if (bb->taken && (bb->taken->startOffset <= bb->startOffset)) {
2126 DCHECK(bb->dominators != NULL);
2127 if (oatIsBitSet(bb->dominators, bb->taken->id)) {
2128 if (cUnit->printMe) {
2129 LOG(INFO) << "Loop backedge from 0x"
2130 << std::hex << bb->lastMIRInsn->offset
2131 << " to 0x" << std::hex << bb->taken->startOffset;
2132 }
2133 addLoopHeader(cUnit, bb->taken, bb);
2134 }
2135 }
2136 }
2137 return false;
buzbee239c4e72012-03-16 08:42:29 -07002138}
2139
2140void addBlocksToLoop(CompilationUnit* cUnit, ArenaBitVector* blocks,
Bill Buzbeea114add2012-05-03 15:00:40 -07002141 BasicBlock* bb, int headId)
buzbee239c4e72012-03-16 08:42:29 -07002142{
Bill Buzbeea114add2012-05-03 15:00:40 -07002143 if (!oatIsBitSet(bb->dominators, headId) ||
2144 oatIsBitSet(blocks, bb->id)) {
2145 return;
2146 }
2147 oatSetBit(cUnit, blocks, bb->id);
2148 GrowableListIterator iter;
2149 oatGrowableListIteratorInit(bb->predecessors, &iter);
2150 BasicBlock* predBB;
2151 for (predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter); predBB;
2152 predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter)) {
2153 addBlocksToLoop(cUnit, blocks, predBB, headId);
2154 }
buzbee239c4e72012-03-16 08:42:29 -07002155}
2156
2157void oatDumpLoops(CompilationUnit *cUnit)
2158{
Bill Buzbeea114add2012-05-03 15:00:40 -07002159 GrowableListIterator iter;
2160 oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
2161 for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
2162 (loop != NULL); loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
2163 LOG(INFO) << "Loop head block id " << loop->header->id
2164 << ", offset 0x" << std::hex << loop->header->startOffset
2165 << ", Depth: " << loop->header->nestingDepth;
buzbee239c4e72012-03-16 08:42:29 -07002166 GrowableListIterator iter;
Bill Buzbeea114add2012-05-03 15:00:40 -07002167 oatGrowableListIteratorInit(&loop->incomingBackEdges, &iter);
2168 BasicBlock* edgeBB;
2169 for (edgeBB = (BasicBlock*)oatGrowableListIteratorNext(&iter); edgeBB;
2170 edgeBB = (BasicBlock*)oatGrowableListIteratorNext(&iter)) {
2171 LOG(INFO) << " Backedge block id " << edgeBB->id
2172 << ", offset 0x" << std::hex << edgeBB->startOffset;
2173 ArenaBitVectorIterator bIter;
2174 oatBitVectorIteratorInit(loop->blocks, &bIter);
2175 for (int bbId = oatBitVectorIteratorNext(&bIter); bbId != -1;
2176 bbId = oatBitVectorIteratorNext(&bIter)) {
2177 BasicBlock *bb;
2178 bb = (BasicBlock*)
2179 oatGrowableListGetElement(&cUnit->blockList, bbId);
2180 LOG(INFO) << " (" << bb->id << ", 0x" << std::hex
2181 << bb->startOffset << ")";
2182 }
buzbee239c4e72012-03-16 08:42:29 -07002183 }
Bill Buzbeea114add2012-05-03 15:00:40 -07002184 }
buzbee239c4e72012-03-16 08:42:29 -07002185}
2186
2187void oatMethodLoopDetection(CompilationUnit *cUnit)
2188{
Bill Buzbeea114add2012-05-03 15:00:40 -07002189 if (cUnit->disableOpt & (1 << kPromoteRegs)) {
2190 return;
2191 }
2192 oatInitGrowableList(cUnit, &cUnit->loopHeaders, 6, kListMisc);
2193 // Find the loop headers
2194 oatDataFlowAnalysisDispatcher(cUnit, findBackEdges,
2195 kAllNodes, false /* isIterative */);
2196 GrowableListIterator iter;
2197 oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
2198 // Add blocks to each header
2199 for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
2200 loop; loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
2201 loop->blocks = oatAllocBitVector(cUnit, cUnit->numBlocks, true,
2202 kBitMapMisc);
2203 oatSetBit(cUnit, loop->blocks, loop->header->id);
buzbee239c4e72012-03-16 08:42:29 -07002204 GrowableListIterator iter;
Bill Buzbeea114add2012-05-03 15:00:40 -07002205 oatGrowableListIteratorInit(&loop->incomingBackEdges, &iter);
2206 BasicBlock* edgeBB;
2207 for (edgeBB = (BasicBlock*)oatGrowableListIteratorNext(&iter); edgeBB;
2208 edgeBB = (BasicBlock*)oatGrowableListIteratorNext(&iter)) {
2209 addBlocksToLoop(cUnit, loop->blocks, edgeBB, loop->header->id);
buzbee239c4e72012-03-16 08:42:29 -07002210 }
Bill Buzbeea114add2012-05-03 15:00:40 -07002211 }
2212 // Compute the nesting depth of each header
2213 oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
2214 for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
2215 loop; loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
2216 GrowableListIterator iter2;
2217 oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter2);
2218 LoopInfo* loop2;
2219 for (loop2 = (LoopInfo*)oatGrowableListIteratorNext(&iter2);
2220 loop2; loop2 = (LoopInfo*)oatGrowableListIteratorNext(&iter2)) {
2221 if (oatIsBitSet(loop2->blocks, loop->header->id)) {
2222 loop->header->nestingDepth++;
2223 }
buzbee239c4e72012-03-16 08:42:29 -07002224 }
Bill Buzbeea114add2012-05-03 15:00:40 -07002225 }
2226 // Assign nesting depth to each block in all loops
2227 oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
2228 for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
2229 (loop != NULL); loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
2230 ArenaBitVectorIterator bIter;
2231 oatBitVectorIteratorInit(loop->blocks, &bIter);
2232 for (int bbId = oatBitVectorIteratorNext(&bIter); bbId != -1;
2233 bbId = oatBitVectorIteratorNext(&bIter)) {
2234 BasicBlock *bb;
2235 bb = (BasicBlock*) oatGrowableListGetElement(&cUnit->blockList, bbId);
2236 bb->nestingDepth = std::max(bb->nestingDepth,
2237 loop->header->nestingDepth);
buzbee239c4e72012-03-16 08:42:29 -07002238 }
Bill Buzbeea114add2012-05-03 15:00:40 -07002239 }
2240 if (cUnit->printMe) {
2241 oatDumpLoops(cUnit);
2242 }
buzbee239c4e72012-03-16 08:42:29 -07002243}
2244
2245/*
buzbee9c044ce2012-03-18 13:24:07 -07002246 * This function will make a best guess at whether the invoke will
2247 * end up using Method*. It isn't critical to get it exactly right,
2248 * and attempting to do would involve more complexity than it's
2249 * worth.
2250 */
2251bool invokeUsesMethodStar(CompilationUnit* cUnit, MIR* mir)
2252{
Bill Buzbeea114add2012-05-03 15:00:40 -07002253 InvokeType type;
2254 Instruction::Code opcode = mir->dalvikInsn.opcode;
2255 switch (opcode) {
2256 case Instruction::INVOKE_STATIC:
2257 case Instruction::INVOKE_STATIC_RANGE:
2258 type = kStatic;
2259 break;
2260 case Instruction::INVOKE_DIRECT:
2261 case Instruction::INVOKE_DIRECT_RANGE:
2262 type = kDirect;
2263 break;
2264 case Instruction::INVOKE_VIRTUAL:
2265 case Instruction::INVOKE_VIRTUAL_RANGE:
2266 type = kVirtual;
2267 break;
2268 case Instruction::INVOKE_INTERFACE:
2269 case Instruction::INVOKE_INTERFACE_RANGE:
2270 return false;
2271 case Instruction::INVOKE_SUPER_RANGE:
2272 case Instruction::INVOKE_SUPER:
2273 type = kSuper;
2274 break;
2275 default:
2276 LOG(WARNING) << "Unexpected invoke op: " << (int)opcode;
2277 return false;
2278 }
2279 OatCompilationUnit mUnit(cUnit->class_loader, cUnit->class_linker,
2280 *cUnit->dex_file, *cUnit->dex_cache,
2281 cUnit->code_item, cUnit->method_idx,
2282 cUnit->access_flags);
2283 // TODO: add a flag so we don't counts the stats for this twice
2284 uint32_t dexMethodIdx = mir->dalvikInsn.vB;
2285 int vtableIdx;
2286 uintptr_t directCode;
2287 uintptr_t directMethod;
2288 bool fastPath =
2289 cUnit->compiler->ComputeInvokeInfo(dexMethodIdx, &mUnit, type,
2290 vtableIdx, directCode,
2291 directMethod) &&
2292 !SLOW_INVOKE_PATH;
2293 return (((type == kDirect) || (type == kStatic)) &&
2294 fastPath && ((directCode == 0) || (directMethod == 0)));
buzbee9c044ce2012-03-18 13:24:07 -07002295}
2296
2297/*
buzbee239c4e72012-03-16 08:42:29 -07002298 * Count uses, weighting by loop nesting depth. This code only
2299 * counts explicitly used sRegs. A later phase will add implicit
2300 * counts for things such as Method*, null-checked references, etc.
2301 */
2302bool countUses(struct CompilationUnit* cUnit, struct BasicBlock* bb)
2303{
Bill Buzbeea114add2012-05-03 15:00:40 -07002304 if (bb->blockType != kDalvikByteCode) {
buzbee239c4e72012-03-16 08:42:29 -07002305 return false;
Bill Buzbeea114add2012-05-03 15:00:40 -07002306 }
2307 for (MIR* mir = bb->firstMIRInsn; (mir != NULL); mir = mir->next) {
2308 if (mir->ssaRep == NULL) {
2309 continue;
2310 }
2311 uint32_t weight = std::min(16U, (uint32_t)bb->nestingDepth);
2312 for (int i = 0; i < mir->ssaRep->numUses; i++) {
2313 int sReg = mir->ssaRep->uses[i];
2314 DCHECK_LT(sReg, (int)cUnit->useCounts.numUsed);
2315 cUnit->rawUseCounts.elemList[sReg]++;
2316 cUnit->useCounts.elemList[sReg] += (1 << weight);
2317 }
2318 if (!(cUnit->disableOpt & (1 << kPromoteCompilerTemps))) {
2319 int dfAttributes = oatDataFlowAttributes[mir->dalvikInsn.opcode];
2320 // Implicit use of Method* ? */
2321 if (dfAttributes & DF_UMS) {
2322 /*
2323 * Some invokes will not use Method* - need to perform test similar
2324 * to that found in genInvoke() to decide whether to count refs
2325 * for Method* on invoke-class opcodes.
2326 * TODO: refactor for common test here, save results for genInvoke
2327 */
2328 int usesMethodStar = true;
2329 if ((dfAttributes & (DF_FORMAT_35C | DF_FORMAT_3RC)) &&
2330 !(dfAttributes & DF_NON_NULL_RET)) {
2331 usesMethodStar &= invokeUsesMethodStar(cUnit, mir);
2332 }
2333 if (usesMethodStar) {
2334 cUnit->rawUseCounts.elemList[cUnit->methodSReg]++;
2335 cUnit->useCounts.elemList[cUnit->methodSReg] += (1 << weight);
2336 }
2337 }
2338 }
2339 }
2340 return false;
buzbee239c4e72012-03-16 08:42:29 -07002341}
2342
2343void oatMethodUseCount(CompilationUnit *cUnit)
2344{
Bill Buzbeea114add2012-05-03 15:00:40 -07002345 oatInitGrowableList(cUnit, &cUnit->useCounts, cUnit->numSSARegs + 32,
2346 kListMisc);
2347 oatInitGrowableList(cUnit, &cUnit->rawUseCounts, cUnit->numSSARegs + 32,
2348 kListMisc);
2349 // Initialize list
2350 for (int i = 0; i < cUnit->numSSARegs; i++) {
2351 oatInsertGrowableList(cUnit, &cUnit->useCounts, 0);
2352 oatInsertGrowableList(cUnit, &cUnit->rawUseCounts, 0);
2353 }
2354 if (cUnit->disableOpt & (1 << kPromoteRegs)) {
2355 return;
2356 }
2357 oatDataFlowAnalysisDispatcher(cUnit, countUses,
2358 kAllNodes, false /* isIterative */);
buzbee239c4e72012-03-16 08:42:29 -07002359}
2360
Elliott Hughes11d1b0c2012-01-23 16:57:47 -08002361} // namespace art