| // Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| package com.android.tools.r8.ir.code; |
| |
| import com.android.tools.r8.cf.LoadStoreHelper; |
| import com.android.tools.r8.cf.code.CfStackInstruction; |
| import com.android.tools.r8.cf.code.CfStackInstruction.Opcode; |
| import com.android.tools.r8.errors.Unreachable; |
| import com.android.tools.r8.graph.DexType; |
| import com.android.tools.r8.ir.conversion.CfBuilder; |
| import com.android.tools.r8.ir.conversion.DexBuilder; |
| import com.android.tools.r8.ir.optimize.Inliner.ConstraintWithTarget; |
| import com.android.tools.r8.ir.optimize.InliningConstraints; |
| |
| public class Dup extends Instruction { |
| |
| public Dup(StackValues dest, StackValue src) { |
| super(dest, src); |
| } |
| |
| @Override |
| public void buildDex(DexBuilder builder) { |
| throw new Unreachable("This classfile-specific IR should not be inserted in the Dex backend."); |
| } |
| |
| @Override |
| public void buildCf(CfBuilder builder) { |
| if (this.inValues.get(0).type == ValueType.LONG_OR_DOUBLE) { |
| builder.add(new CfStackInstruction(Opcode.Dup2)); |
| } else { |
| builder.add(new CfStackInstruction(Opcode.Dup)); |
| } |
| } |
| |
| @Override |
| public boolean identicalNonValueNonPositionParts(Instruction other) { |
| return false; |
| } |
| |
| @Override |
| public int compareNonValueParts(Instruction other) { |
| return 0; |
| } |
| |
| @Override |
| public int maxInValueRegister() { |
| return 0; |
| } |
| |
| @Override |
| public int maxOutValueRegister() { |
| throw new Unreachable(); |
| } |
| |
| @Override |
| public ConstraintWithTarget inliningConstraint( |
| InliningConstraints inliningConstraints, DexType invocationContext) { |
| return inliningConstraints.forDup(); |
| } |
| |
| @Override |
| public void insertLoadAndStores(InstructionListIterator it, LoadStoreHelper helper) {} |
| |
| @Override |
| public boolean hasInvariantOutType() { |
| return false; |
| } |
| } |