blob: c991ffc6f37b8c29d0a9a828ed66bf9d32de07ea [file] [log] [blame]
// Copyright (c) 2017, 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.code.CfPop;
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.optimize.Inliner.Constraint;
import com.android.tools.r8.shaking.Enqueuer.AppInfoWithLiveness;
import com.android.tools.r8.utils.InternalOptions;
public class Pop extends Instruction {
public Pop(StackValue src) {
super(null, src);
}
@Override
public boolean isPop() {
return true;
}
@Override
public Pop asPop() {
return this;
}
@Override
public boolean identicalNonValueNonPositionParts(Instruction other) {
return true;
}
@Override
public int compareNonValueParts(Instruction other) {
return 0;
}
@Override
public int maxInValueRegister() {
throw new Unreachable();
}
@Override
public int maxOutValueRegister() {
throw new Unreachable();
}
@Override
public Constraint inliningConstraint(AppInfoWithLiveness info, DexType invocationContext) {
return Constraint.ALWAYS;
}
@Override
public void buildCf(CfBuilder builder) {
builder.add(new CfPop(inValues.get(0).type));
}
@Override
public boolean canBeDeadCode(IRCode code, InternalOptions options) {
// Pop cannot be dead code as it modifies the stack height.
return false;
}
}