1 // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file 2 // for details. All rights reserved. Use of this source code is governed by a 3 // BSD-style license that can be found in the LICENSE file. 4 package com.android.tools.r8.code; 5 6 import com.android.tools.r8.graph.OffsetToObjectMapping; 7 8 abstract class BaseInstructionFactory { 9 create(int high, int opcode, BytecodeStream stream, OffsetToObjectMapping mapping)10 static Instruction create(int high, int opcode, BytecodeStream stream, 11 OffsetToObjectMapping mapping) { 12 switch (opcode) { 13 case 0x0: 14 return Nop.create(high, stream); 15 case Move.OPCODE: 16 return new Move(high, stream); 17 case MoveFrom16.OPCODE: 18 return new MoveFrom16(high, stream); 19 case Move16.OPCODE: 20 return new Move16(high, stream); 21 case MoveWide.OPCODE: 22 return new MoveWide(high, stream); 23 case MoveWideFrom16.OPCODE: 24 return new MoveWideFrom16(high, stream); 25 case MoveWide16.OPCODE: 26 return new MoveWide16(high, stream); 27 case MoveObject.OPCODE: 28 return new MoveObject(high, stream); 29 case MoveObjectFrom16.OPCODE: 30 return new MoveObjectFrom16(high, stream); 31 case MoveObject16.OPCODE: 32 return new MoveObject16(high, stream); 33 case MoveResult.OPCODE: 34 return new MoveResult(high, stream); 35 case MoveResultWide.OPCODE: 36 return new MoveResultWide(high, stream); 37 case MoveResultObject.OPCODE: 38 return new MoveResultObject(high, stream); 39 case MoveException.OPCODE: 40 return new MoveException(high, stream); 41 case ReturnVoid.OPCODE: 42 return new ReturnVoid(high, stream); 43 case Return.OPCODE: 44 return new Return(high, stream); 45 case ReturnWide.OPCODE: 46 return new ReturnWide(high, stream); 47 case ReturnObject.OPCODE: 48 return new ReturnObject(high, stream); 49 case Const4.OPCODE: 50 return new Const4(high, stream); 51 case Const16.OPCODE: 52 return new Const16(high, stream); 53 case Const.OPCODE: 54 return new Const(high, stream); 55 case ConstHigh16.OPCODE: 56 return new ConstHigh16(high, stream); 57 case ConstWide16.OPCODE: 58 return new ConstWide16(high, stream); 59 case ConstWide32.OPCODE: 60 return new ConstWide32(high, stream); 61 case ConstWide.OPCODE: 62 return new ConstWide(high, stream); 63 case ConstWideHigh16.OPCODE: 64 return new ConstWideHigh16(high, stream); 65 case ConstString.OPCODE: 66 return new ConstString(high, stream, mapping); 67 case ConstStringJumbo.OPCODE: 68 return new ConstStringJumbo(high, stream, mapping); 69 case ConstClass.OPCODE: 70 return new ConstClass(high, stream, mapping); 71 case MonitorEnter.OPCODE: 72 return new MonitorEnter(high, stream); 73 case MonitorExit.OPCODE: 74 return new MonitorExit(high, stream); 75 case CheckCast.OPCODE: 76 return new CheckCast(high, stream, mapping); 77 case InstanceOf.OPCODE: 78 return new InstanceOf(high, stream, mapping); 79 case ArrayLength.OPCODE: 80 return new ArrayLength(high, stream); 81 case NewInstance.OPCODE: 82 return new NewInstance(high, stream, mapping); 83 case NewArray.OPCODE: 84 return new NewArray(high, stream, mapping); 85 case FilledNewArray.OPCODE: 86 return new FilledNewArray(high, stream, mapping); 87 case FilledNewArrayRange.OPCODE: 88 return new FilledNewArrayRange(high, stream, mapping); 89 case FillArrayData.OPCODE: 90 return new FillArrayData(high, stream); 91 case Throw.OPCODE: 92 return new Throw(high, stream); 93 case Goto.OPCODE: 94 return new Goto(high, stream); 95 case Goto16.OPCODE: 96 return new Goto16(high, stream); 97 case Goto32.OPCODE: 98 return new Goto32(high, stream); 99 case PackedSwitch.OPCODE: 100 return new PackedSwitch(high, stream); 101 case SparseSwitch.OPCODE: 102 return new SparseSwitch(high, stream); 103 case CmplFloat.OPCODE: 104 return new CmplFloat(high, stream); 105 case CmpgFloat.OPCODE: 106 return new CmpgFloat(high, stream); 107 case CmplDouble.OPCODE: 108 return new CmplDouble(high, stream); 109 case CmpgDouble.OPCODE: 110 return new CmpgDouble(high, stream); 111 case CmpLong.OPCODE: 112 return new CmpLong(high, stream); 113 case IfEq.OPCODE: 114 return new IfEq(high, stream); 115 case IfNe.OPCODE: 116 return new IfNe(high, stream); 117 case IfLt.OPCODE: 118 return new IfLt(high, stream); 119 case IfGe.OPCODE: 120 return new IfGe(high, stream); 121 case IfGt.OPCODE: 122 return new IfGt(high, stream); 123 case IfLe.OPCODE: 124 return new IfLe(high, stream); 125 case IfEqz.OPCODE: 126 return new IfEqz(high, stream); 127 case IfNez.OPCODE: 128 return new IfNez(high, stream); 129 case IfLtz.OPCODE: 130 return new IfLtz(high, stream); 131 case IfGez.OPCODE: 132 return new IfGez(high, stream); 133 case IfGtz.OPCODE: 134 return new IfGtz(high, stream); 135 case IfLez.OPCODE: 136 return new IfLez(high, stream); 137 case Aget.OPCODE: 138 return new Aget(high, stream); 139 case AgetWide.OPCODE: 140 return new AgetWide(high, stream); 141 case AgetObject.OPCODE: 142 return new AgetObject(high, stream); 143 case AgetBoolean.OPCODE: 144 return new AgetBoolean(high, stream); 145 case AgetByte.OPCODE: 146 return new AgetByte(high, stream); 147 case AgetChar.OPCODE: 148 return new AgetChar(high, stream); 149 case AgetShort.OPCODE: 150 return new AgetShort(high, stream); 151 case Aput.OPCODE: 152 return new Aput(high, stream); 153 case AputWide.OPCODE: 154 return new AputWide(high, stream); 155 case AputObject.OPCODE: 156 return new AputObject(high, stream); 157 case AputBoolean.OPCODE: 158 return new AputBoolean(high, stream); 159 case AputByte.OPCODE: 160 return new AputByte(high, stream); 161 case AputChar.OPCODE: 162 return new AputChar(high, stream); 163 case AputShort.OPCODE: 164 return new AputShort(high, stream); 165 case Iget.OPCODE: 166 return new Iget(high, stream, mapping); 167 case IgetWide.OPCODE: 168 return new IgetWide(high, stream, mapping); 169 case IgetObject.OPCODE: 170 return new IgetObject(high, stream, mapping); 171 case IgetBoolean.OPCODE: 172 return new IgetBoolean(high, stream, mapping); 173 case IgetByte.OPCODE: 174 return new IgetByte(high, stream, mapping); 175 case IgetChar.OPCODE: 176 return new IgetChar(high, stream, mapping); 177 case IgetShort.OPCODE: 178 return new IgetShort(high, stream, mapping); 179 case Iput.OPCODE: 180 return new Iput(high, stream, mapping); 181 case IputWide.OPCODE: 182 return new IputWide(high, stream, mapping); 183 case IputObject.OPCODE: 184 return new IputObject(high, stream, mapping); 185 case IputBoolean.OPCODE: 186 return new IputBoolean(high, stream, mapping); 187 case IputByte.OPCODE: 188 return new IputByte(high, stream, mapping); 189 case IputChar.OPCODE: 190 return new IputChar(high, stream, mapping); 191 case IputShort.OPCODE: 192 return new IputShort(high, stream, mapping); 193 case Sget.OPCODE: 194 return new Sget(high, stream, mapping); 195 case SgetWide.OPCODE: 196 return new SgetWide(high, stream, mapping); 197 case SgetObject.OPCODE: 198 return new SgetObject(high, stream, mapping); 199 case SgetBoolean.OPCODE: 200 return new SgetBoolean(high, stream, mapping); 201 case SgetByte.OPCODE: 202 return new SgetByte(high, stream, mapping); 203 case SgetChar.OPCODE: 204 return new SgetChar(high, stream, mapping); 205 case SgetShort.OPCODE: 206 return new SgetShort(high, stream, mapping); 207 case Sput.OPCODE: 208 return new Sput(high, stream, mapping); 209 case SputWide.OPCODE: 210 return new SputWide(high, stream, mapping); 211 case SputObject.OPCODE: 212 return new SputObject(high, stream, mapping); 213 case SputBoolean.OPCODE: 214 return new SputBoolean(high, stream, mapping); 215 case SputByte.OPCODE: 216 return new SputByte(high, stream, mapping); 217 case SputChar.OPCODE: 218 return new SputChar(high, stream, mapping); 219 case SputShort.OPCODE: 220 return new SputShort(high, stream, mapping); 221 case InvokeVirtual.OPCODE: 222 return new InvokeVirtual(high, stream, mapping); 223 case InvokeSuper.OPCODE: 224 return new InvokeSuper(high, stream, mapping); 225 case InvokeDirect.OPCODE: 226 return new InvokeDirect(high, stream, mapping); 227 case InvokeStatic.OPCODE: 228 return new InvokeStatic(high, stream, mapping); 229 case InvokeInterface.OPCODE: 230 return new InvokeInterface(high, stream, mapping); 231 case InvokeVirtualRange.OPCODE: 232 return new InvokeVirtualRange(high, stream, mapping); 233 case InvokeSuperRange.OPCODE: 234 return new InvokeSuperRange(high, stream, mapping); 235 case InvokeDirectRange.OPCODE: 236 return new InvokeDirectRange(high, stream, mapping); 237 case InvokeStaticRange.OPCODE: 238 return new InvokeStaticRange(high, stream, mapping); 239 case InvokeInterfaceRange.OPCODE: 240 return new InvokeInterfaceRange(high, stream, mapping); 241 case NegInt.OPCODE: 242 return new NegInt(high, stream); 243 case NotInt.OPCODE: 244 return new NotInt(high, stream); 245 case NegLong.OPCODE: 246 return new NegLong(high, stream); 247 case NotLong.OPCODE: 248 return new NotLong(high, stream); 249 case NegFloat.OPCODE: 250 return new NegFloat(high, stream); 251 case NegDouble.OPCODE: 252 return new NegDouble(high, stream); 253 case IntToLong.OPCODE: 254 return new IntToLong(high, stream); 255 case IntToFloat.OPCODE: 256 return new IntToFloat(high, stream); 257 case IntToDouble.OPCODE: 258 return new IntToDouble(high, stream); 259 case LongToInt.OPCODE: 260 return new LongToInt(high, stream); 261 case LongToFloat.OPCODE: 262 return new LongToFloat(high, stream); 263 case LongToDouble.OPCODE: 264 return new LongToDouble(high, stream); 265 case FloatToInt.OPCODE: 266 return new FloatToInt(high, stream); 267 case FloatToLong.OPCODE: 268 return new FloatToLong(high, stream); 269 case FloatToDouble.OPCODE: 270 return new FloatToDouble(high, stream); 271 case DoubleToInt.OPCODE: 272 return new DoubleToInt(high, stream); 273 case DoubleToLong.OPCODE: 274 return new DoubleToLong(high, stream); 275 case DoubleToFloat.OPCODE: 276 return new DoubleToFloat(high, stream); 277 case IntToByte.OPCODE: 278 return new IntToByte(high, stream); 279 case IntToChar.OPCODE: 280 return new IntToChar(high, stream); 281 case IntToShort.OPCODE: 282 return new IntToShort(high, stream); 283 case AddInt.OPCODE: 284 return new AddInt(high, stream); 285 case SubInt.OPCODE: 286 return new SubInt(high, stream); 287 case MulInt.OPCODE: 288 return new MulInt(high, stream); 289 case DivInt.OPCODE: 290 return new DivInt(high, stream); 291 case RemInt.OPCODE: 292 return new RemInt(high, stream); 293 case AndInt.OPCODE: 294 return new AndInt(high, stream); 295 case OrInt.OPCODE: 296 return new OrInt(high, stream); 297 case XorInt.OPCODE: 298 return new XorInt(high, stream); 299 case ShlInt.OPCODE: 300 return new ShlInt(high, stream); 301 case ShrInt.OPCODE: 302 return new ShrInt(high, stream); 303 case UshrInt.OPCODE: 304 return new UshrInt(high, stream); 305 case AddLong.OPCODE: 306 return new AddLong(high, stream); 307 case SubLong.OPCODE: 308 return new SubLong(high, stream); 309 case MulLong.OPCODE: 310 return new MulLong(high, stream); 311 case DivLong.OPCODE: 312 return new DivLong(high, stream); 313 case RemLong.OPCODE: 314 return new RemLong(high, stream); 315 case AndLong.OPCODE: 316 return new AndLong(high, stream); 317 case OrLong.OPCODE: 318 return new OrLong(high, stream); 319 case XorLong.OPCODE: 320 return new XorLong(high, stream); 321 case ShlLong.OPCODE: 322 return new ShlLong(high, stream); 323 case ShrLong.OPCODE: 324 return new ShrLong(high, stream); 325 case UshrLong.OPCODE: 326 return new UshrLong(high, stream); 327 case AddFloat.OPCODE: 328 return new AddFloat(high, stream); 329 case SubFloat.OPCODE: 330 return new SubFloat(high, stream); 331 case MulFloat.OPCODE: 332 return new MulFloat(high, stream); 333 case DivFloat.OPCODE: 334 return new DivFloat(high, stream); 335 case RemFloat.OPCODE: 336 return new RemFloat(high, stream); 337 case AddDouble.OPCODE: 338 return new AddDouble(high, stream); 339 case SubDouble.OPCODE: 340 return new SubDouble(high, stream); 341 case MulDouble.OPCODE: 342 return new MulDouble(high, stream); 343 case DivDouble.OPCODE: 344 return new DivDouble(high, stream); 345 case RemDouble.OPCODE: 346 return new RemDouble(high, stream); 347 case AddInt2Addr.OPCODE: 348 return new AddInt2Addr(high, stream); 349 case SubInt2Addr.OPCODE: 350 return new SubInt2Addr(high, stream); 351 case MulInt2Addr.OPCODE: 352 return new MulInt2Addr(high, stream); 353 case DivInt2Addr.OPCODE: 354 return new DivInt2Addr(high, stream); 355 case RemInt2Addr.OPCODE: 356 return new RemInt2Addr(high, stream); 357 case AndInt2Addr.OPCODE: 358 return new AndInt2Addr(high, stream); 359 case OrInt2Addr.OPCODE: 360 return new OrInt2Addr(high, stream); 361 case XorInt2Addr.OPCODE: 362 return new XorInt2Addr(high, stream); 363 case ShlInt2Addr.OPCODE: 364 return new ShlInt2Addr(high, stream); 365 case ShrInt2Addr.OPCODE: 366 return new ShrInt2Addr(high, stream); 367 case UshrInt2Addr.OPCODE: 368 return new UshrInt2Addr(high, stream); 369 case AddLong2Addr.OPCODE: 370 return new AddLong2Addr(high, stream); 371 case SubLong2Addr.OPCODE: 372 return new SubLong2Addr(high, stream); 373 case MulLong2Addr.OPCODE: 374 return new MulLong2Addr(high, stream); 375 case DivLong2Addr.OPCODE: 376 return new DivLong2Addr(high, stream); 377 case RemLong2Addr.OPCODE: 378 return new RemLong2Addr(high, stream); 379 case AndLong2Addr.OPCODE: 380 return new AndLong2Addr(high, stream); 381 case OrLong2Addr.OPCODE: 382 return new OrLong2Addr(high, stream); 383 case XorLong2Addr.OPCODE: 384 return new XorLong2Addr(high, stream); 385 case ShlLong2Addr.OPCODE: 386 return new ShlLong2Addr(high, stream); 387 case ShrLong2Addr.OPCODE: 388 return new ShrLong2Addr(high, stream); 389 case UshrLong2Addr.OPCODE: 390 return new UshrLong2Addr(high, stream); 391 case AddFloat2Addr.OPCODE: 392 return new AddFloat2Addr(high, stream); 393 case SubFloat2Addr.OPCODE: 394 return new SubFloat2Addr(high, stream); 395 case MulFloat2Addr.OPCODE: 396 return new MulFloat2Addr(high, stream); 397 case DivFloat2Addr.OPCODE: 398 return new DivFloat2Addr(high, stream); 399 case RemFloat2Addr.OPCODE: 400 return new RemFloat2Addr(high, stream); 401 case AddDouble2Addr.OPCODE: 402 return new AddDouble2Addr(high, stream); 403 case SubDouble2Addr.OPCODE: 404 return new SubDouble2Addr(high, stream); 405 case MulDouble2Addr.OPCODE: 406 return new MulDouble2Addr(high, stream); 407 case DivDouble2Addr.OPCODE: 408 return new DivDouble2Addr(high, stream); 409 case RemDouble2Addr.OPCODE: 410 return new RemDouble2Addr(high, stream); 411 case AddIntLit16.OPCODE: 412 return new AddIntLit16(high, stream); 413 case RsubInt.OPCODE: 414 return new RsubInt(high, stream); 415 case MulIntLit16.OPCODE: 416 return new MulIntLit16(high, stream); 417 case DivIntLit16.OPCODE: 418 return new DivIntLit16(high, stream); 419 case RemIntLit16.OPCODE: 420 return new RemIntLit16(high, stream); 421 case AndIntLit16.OPCODE: 422 return new AndIntLit16(high, stream); 423 case OrIntLit16.OPCODE: 424 return new OrIntLit16(high, stream); 425 case XorIntLit16.OPCODE: 426 return new XorIntLit16(high, stream); 427 case AddIntLit8.OPCODE: 428 return new AddIntLit8(high, stream); 429 case RsubIntLit8.OPCODE: 430 return new RsubIntLit8(high, stream); 431 case MulIntLit8.OPCODE: 432 return new MulIntLit8(high, stream); 433 case DivIntLit8.OPCODE: 434 return new DivIntLit8(high, stream); 435 case RemIntLit8.OPCODE: 436 return new RemIntLit8(high, stream); 437 case AndIntLit8.OPCODE: 438 return new AndIntLit8(high, stream); 439 case OrIntLit8.OPCODE: 440 return new OrIntLit8(high, stream); 441 case XorIntLit8.OPCODE: 442 return new XorIntLit8(high, stream); 443 case ShlIntLit8.OPCODE: 444 return new ShlIntLit8(high, stream); 445 case ShrIntLit8.OPCODE: 446 return new ShrIntLit8(high, stream); 447 case UshrIntLit8.OPCODE: 448 return new UshrIntLit8(high, stream); 449 case InvokePolymorphic.OPCODE: 450 return new InvokePolymorphic(high, stream, mapping); 451 case InvokePolymorphicRange.OPCODE: 452 return new InvokePolymorphicRange(high, stream, mapping); 453 case InvokeCustom.OPCODE: 454 return new InvokeCustom(high, stream, mapping); 455 case InvokeCustomRange.OPCODE: 456 return new InvokeCustomRange(high, stream, mapping); 457 default: 458 throw new IllegalArgumentException("Illegal Opcode: 0x" + Integer.toString(opcode, 16)); 459 } 460 } 461 } 462