Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_DEX_INSTRUCTION_INL_H_ |
| 18 | #define ART_RUNTIME_DEX_INSTRUCTION_INL_H_ |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 19 | |
| 20 | #include "dex_instruction.h" |
| 21 | |
| 22 | namespace art { |
| 23 | |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 24 | //------------------------------------------------------------------------------ |
| 25 | // VRegA |
| 26 | //------------------------------------------------------------------------------ |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 27 | inline int8_t Instruction::VRegA_10t(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 28 | DCHECK_EQ(FormatOf(Opcode()), k10t); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 29 | return static_cast<int8_t>(InstAA(inst_data)); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 30 | } |
| 31 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 32 | inline uint8_t Instruction::VRegA_10x(uint16_t inst_data) const { |
Sebastien Hertz | 5243e91 | 2013-05-21 10:55:07 +0200 | [diff] [blame] | 33 | DCHECK_EQ(FormatOf(Opcode()), k10x); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 34 | return InstAA(inst_data); |
Sebastien Hertz | 5243e91 | 2013-05-21 10:55:07 +0200 | [diff] [blame] | 35 | } |
| 36 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 37 | inline uint4_t Instruction::VRegA_11n(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 38 | DCHECK_EQ(FormatOf(Opcode()), k11n); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 39 | return InstA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 40 | } |
| 41 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 42 | inline uint8_t Instruction::VRegA_11x(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 43 | DCHECK_EQ(FormatOf(Opcode()), k11x); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 44 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 47 | inline uint4_t Instruction::VRegA_12x(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 48 | DCHECK_EQ(FormatOf(Opcode()), k12x); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 49 | return InstA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | inline int16_t Instruction::VRegA_20t() const { |
| 53 | DCHECK_EQ(FormatOf(Opcode()), k20t); |
| 54 | return static_cast<int16_t>(Fetch16(1)); |
| 55 | } |
| 56 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 57 | inline uint8_t Instruction::VRegA_21c(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 58 | DCHECK_EQ(FormatOf(Opcode()), k21c); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 59 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 60 | } |
| 61 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 62 | inline uint8_t Instruction::VRegA_21h(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 63 | DCHECK_EQ(FormatOf(Opcode()), k21h); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 64 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 65 | } |
| 66 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 67 | inline uint8_t Instruction::VRegA_21s(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 68 | DCHECK_EQ(FormatOf(Opcode()), k21s); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 69 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 70 | } |
| 71 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 72 | inline uint8_t Instruction::VRegA_21t(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 73 | DCHECK_EQ(FormatOf(Opcode()), k21t); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 74 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 75 | } |
| 76 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 77 | inline uint8_t Instruction::VRegA_22b(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 78 | DCHECK_EQ(FormatOf(Opcode()), k22b); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 79 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 80 | } |
| 81 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 82 | inline uint4_t Instruction::VRegA_22c(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 83 | DCHECK_EQ(FormatOf(Opcode()), k22c); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 84 | return InstA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 85 | } |
| 86 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 87 | inline uint4_t Instruction::VRegA_22s(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 88 | DCHECK_EQ(FormatOf(Opcode()), k22s); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 89 | return InstA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 90 | } |
| 91 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 92 | inline uint4_t Instruction::VRegA_22t(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 93 | DCHECK_EQ(FormatOf(Opcode()), k22t); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 94 | return InstA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 95 | } |
| 96 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 97 | inline uint8_t Instruction::VRegA_22x(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 98 | DCHECK_EQ(FormatOf(Opcode()), k22x); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 99 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 100 | } |
| 101 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 102 | inline uint8_t Instruction::VRegA_23x(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 103 | DCHECK_EQ(FormatOf(Opcode()), k23x); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 104 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | inline int32_t Instruction::VRegA_30t() const { |
| 108 | DCHECK_EQ(FormatOf(Opcode()), k30t); |
| 109 | return static_cast<int32_t>(Fetch32(1)); |
| 110 | } |
| 111 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 112 | inline uint8_t Instruction::VRegA_31c(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 113 | DCHECK_EQ(FormatOf(Opcode()), k31c); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 114 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 115 | } |
| 116 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 117 | inline uint8_t Instruction::VRegA_31i(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 118 | DCHECK_EQ(FormatOf(Opcode()), k31i); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 119 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 120 | } |
| 121 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 122 | inline uint8_t Instruction::VRegA_31t(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 123 | DCHECK_EQ(FormatOf(Opcode()), k31t); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 124 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | inline uint16_t Instruction::VRegA_32x() const { |
| 128 | DCHECK_EQ(FormatOf(Opcode()), k32x); |
| 129 | return Fetch16(1); |
| 130 | } |
| 131 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 132 | inline uint4_t Instruction::VRegA_35c(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 133 | DCHECK_EQ(FormatOf(Opcode()), k35c); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 134 | return InstB(inst_data); // This is labeled A in the spec. |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 135 | } |
| 136 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 137 | inline uint8_t Instruction::VRegA_3rc(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 138 | DCHECK_EQ(FormatOf(Opcode()), k3rc); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 139 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 140 | } |
| 141 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 142 | inline uint8_t Instruction::VRegA_51l(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 143 | DCHECK_EQ(FormatOf(Opcode()), k51l); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 144 | return InstAA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | //------------------------------------------------------------------------------ |
| 148 | // VRegB |
| 149 | //------------------------------------------------------------------------------ |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 150 | inline int4_t Instruction::VRegB_11n(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 151 | DCHECK_EQ(FormatOf(Opcode()), k11n); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 152 | return static_cast<int4_t>((InstB(inst_data) << 28) >> 28); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 153 | } |
| 154 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 155 | inline uint4_t Instruction::VRegB_12x(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 156 | DCHECK_EQ(FormatOf(Opcode()), k12x); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 157 | return InstB(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | inline uint16_t Instruction::VRegB_21c() const { |
| 161 | DCHECK_EQ(FormatOf(Opcode()), k21c); |
| 162 | return Fetch16(1); |
| 163 | } |
| 164 | |
| 165 | inline uint16_t Instruction::VRegB_21h() const { |
| 166 | DCHECK_EQ(FormatOf(Opcode()), k21h); |
| 167 | return Fetch16(1); |
| 168 | } |
| 169 | |
| 170 | inline int16_t Instruction::VRegB_21s() const { |
| 171 | DCHECK_EQ(FormatOf(Opcode()), k21s); |
| 172 | return static_cast<int16_t>(Fetch16(1)); |
| 173 | } |
| 174 | |
| 175 | inline int16_t Instruction::VRegB_21t() const { |
| 176 | DCHECK_EQ(FormatOf(Opcode()), k21t); |
| 177 | return static_cast<int16_t>(Fetch16(1)); |
| 178 | } |
| 179 | |
| 180 | inline uint8_t Instruction::VRegB_22b() const { |
| 181 | DCHECK_EQ(FormatOf(Opcode()), k22b); |
| 182 | return static_cast<uint8_t>(Fetch16(1) & 0xff); |
| 183 | } |
| 184 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 185 | inline uint4_t Instruction::VRegB_22c(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 186 | DCHECK_EQ(FormatOf(Opcode()), k22c); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 187 | return InstB(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 188 | } |
| 189 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 190 | inline uint4_t Instruction::VRegB_22s(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 191 | DCHECK_EQ(FormatOf(Opcode()), k22s); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 192 | return InstB(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 193 | } |
| 194 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 195 | inline uint4_t Instruction::VRegB_22t(uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 196 | DCHECK_EQ(FormatOf(Opcode()), k22t); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 197 | return InstB(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | inline uint16_t Instruction::VRegB_22x() const { |
| 201 | DCHECK_EQ(FormatOf(Opcode()), k22x); |
| 202 | return Fetch16(1); |
| 203 | } |
| 204 | |
| 205 | inline uint8_t Instruction::VRegB_23x() const { |
| 206 | DCHECK_EQ(FormatOf(Opcode()), k23x); |
| 207 | return static_cast<uint8_t>(Fetch16(1) & 0xff); |
| 208 | } |
| 209 | |
| 210 | inline uint32_t Instruction::VRegB_31c() const { |
| 211 | DCHECK_EQ(FormatOf(Opcode()), k31c); |
| 212 | return Fetch32(1); |
| 213 | } |
| 214 | |
| 215 | inline int32_t Instruction::VRegB_31i() const { |
| 216 | DCHECK_EQ(FormatOf(Opcode()), k31i); |
| 217 | return static_cast<int32_t>(Fetch32(1)); |
| 218 | } |
| 219 | |
| 220 | inline int32_t Instruction::VRegB_31t() const { |
| 221 | DCHECK_EQ(FormatOf(Opcode()), k31t); |
| 222 | return static_cast<int32_t>(Fetch32(1)); |
| 223 | } |
| 224 | |
| 225 | inline uint16_t Instruction::VRegB_32x() const { |
| 226 | DCHECK_EQ(FormatOf(Opcode()), k32x); |
| 227 | return Fetch16(2); |
| 228 | } |
| 229 | |
| 230 | inline uint16_t Instruction::VRegB_35c() const { |
| 231 | DCHECK_EQ(FormatOf(Opcode()), k35c); |
| 232 | return Fetch16(1); |
| 233 | } |
| 234 | |
| 235 | inline uint16_t Instruction::VRegB_3rc() const { |
| 236 | DCHECK_EQ(FormatOf(Opcode()), k3rc); |
| 237 | return Fetch16(1); |
| 238 | } |
| 239 | |
| 240 | inline uint64_t Instruction::VRegB_51l() const { |
| 241 | DCHECK_EQ(FormatOf(Opcode()), k51l); |
| 242 | uint64_t vB_wide = Fetch32(1) | ((uint64_t) Fetch32(3) << 32); |
| 243 | return vB_wide; |
| 244 | } |
| 245 | |
| 246 | //------------------------------------------------------------------------------ |
| 247 | // VRegC |
| 248 | //------------------------------------------------------------------------------ |
| 249 | inline int8_t Instruction::VRegC_22b() const { |
| 250 | DCHECK_EQ(FormatOf(Opcode()), k22b); |
| 251 | return static_cast<int8_t>(Fetch16(1) >> 8); |
| 252 | } |
| 253 | |
| 254 | inline uint16_t Instruction::VRegC_22c() const { |
| 255 | DCHECK_EQ(FormatOf(Opcode()), k22c); |
| 256 | return Fetch16(1); |
| 257 | } |
| 258 | |
| 259 | inline int16_t Instruction::VRegC_22s() const { |
| 260 | DCHECK_EQ(FormatOf(Opcode()), k22s); |
| 261 | return static_cast<int16_t>(Fetch16(1)); |
| 262 | } |
| 263 | |
| 264 | inline int16_t Instruction::VRegC_22t() const { |
| 265 | DCHECK_EQ(FormatOf(Opcode()), k22t); |
| 266 | return static_cast<int16_t>(Fetch16(1)); |
| 267 | } |
| 268 | |
| 269 | inline uint8_t Instruction::VRegC_23x() const { |
| 270 | DCHECK_EQ(FormatOf(Opcode()), k23x); |
| 271 | return static_cast<uint8_t>(Fetch16(1) >> 8); |
| 272 | } |
| 273 | |
| 274 | inline uint4_t Instruction::VRegC_35c() const { |
| 275 | DCHECK_EQ(FormatOf(Opcode()), k35c); |
| 276 | return static_cast<uint4_t>(Fetch16(2) & 0x0f); |
| 277 | } |
| 278 | |
| 279 | inline uint16_t Instruction::VRegC_3rc() const { |
| 280 | DCHECK_EQ(FormatOf(Opcode()), k3rc); |
| 281 | return Fetch16(2); |
| 282 | } |
| 283 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 284 | inline void Instruction::GetArgs(uint32_t arg[5], uint16_t inst_data) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 285 | DCHECK_EQ(FormatOf(Opcode()), k35c); |
| 286 | |
| 287 | /* |
| 288 | * Note that the fields mentioned in the spec don't appear in |
| 289 | * their "usual" positions here compared to most formats. This |
| 290 | * was done so that the field names for the argument count and |
| 291 | * reference index match between this format and the corresponding |
| 292 | * range formats (3rc and friends). |
| 293 | * |
| 294 | * Bottom line: The argument count is always in vA, and the |
| 295 | * method constant (or equivalent) is always in vB. |
| 296 | */ |
| 297 | uint16_t regList = Fetch16(2); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 298 | uint4_t count = InstB(inst_data); // This is labeled A in the spec. |
| 299 | DCHECK_LE(count, 5U) << "Invalid arg count in 35c (" << count << ")"; |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 300 | |
| 301 | /* |
| 302 | * Copy the argument registers into the arg[] array, and |
| 303 | * also copy the first argument (if any) into vC. (The |
| 304 | * DecodedInstruction structure doesn't have separate |
| 305 | * fields for {vD, vE, vF, vG}, so there's no need to make |
| 306 | * copies of those.) Note that cases 5..2 fall through. |
| 307 | */ |
| 308 | switch (count) { |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 309 | case 5: arg[4] = InstA(inst_data); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 310 | case 4: arg[3] = (regList >> 12) & 0x0f; |
| 311 | case 3: arg[2] = (regList >> 8) & 0x0f; |
| 312 | case 2: arg[1] = (regList >> 4) & 0x0f; |
| 313 | case 1: arg[0] = regList & 0x0f; break; |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 314 | default: // case 0 |
| 315 | break; // Valid, but no need to do anything. |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 316 | } |
| 317 | } |
| 318 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 319 | } // namespace art |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 320 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 321 | #endif // ART_RUNTIME_DEX_INSTRUCTION_INL_H_ |