package org.graalvm.compiler.hotspot.replacements;
import java.lang.annotation.Annotation;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import org.graalvm.compiler.core.common.type.Stamp;
import org.graalvm.compiler.graph.NodeInputList;
import org.graalvm.compiler.nodes.ConstantNode;
import org.graalvm.compiler.nodes.PluginReplacementNode;
import org.graalvm.compiler.nodes.ValueNode;
import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedFoldInvocationPlugin;
import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedPluginFactory;
import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedPluginInjectionProvider;
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
final class Plugin_DigestBaseSubstitutions_useSHA1Intrinsics extends GeneratedFoldInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!b.isPluginEnabled(this)) {
return false;
}
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_DigestBaseSubstitutions_useSHA1Intrinsics.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injectedGraalHotSpotVMConfig;
boolean result = org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions.useSHA1Intrinsics(arg0);
JavaConstant constant = JavaConstant.forInt(result ? 1 : 0);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
b.notifyReplacedCall(targetMethod, node);
return true;
}
@Override
public Class<? extends Annotation> getSource() {
return org.graalvm.compiler.api.replacements.Fold.class;
}
private final org.graalvm.compiler.hotspot.GraalHotSpotVMConfig injectedGraalHotSpotVMConfig;
Plugin_DigestBaseSubstitutions_useSHA1Intrinsics(GeneratedPluginInjectionProvider injection) {
this.injectedGraalHotSpotVMConfig = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
}
}
final class PluginReplacementNode_DigestBaseSubstitutions_useSHA1Intrinsics implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_DigestBaseSubstitutions_useSHA1Intrinsics();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
boolean result = org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions.useSHA1Intrinsics(arg0);
JavaConstant constant = JavaConstant.forInt(result ? 1 : 0);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
return true;
}
}
final class Plugin_DigestBaseSubstitutions_useSHA256Intrinsics extends GeneratedFoldInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!b.isPluginEnabled(this)) {
return false;
}
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_DigestBaseSubstitutions_useSHA256Intrinsics.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injectedGraalHotSpotVMConfig;
boolean result = org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions.useSHA256Intrinsics(arg0);
JavaConstant constant = JavaConstant.forInt(result ? 1 : 0);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
b.notifyReplacedCall(targetMethod, node);
return true;
}
@Override
public Class<? extends Annotation> getSource() {
return org.graalvm.compiler.api.replacements.Fold.class;
}
private final org.graalvm.compiler.hotspot.GraalHotSpotVMConfig injectedGraalHotSpotVMConfig;
Plugin_DigestBaseSubstitutions_useSHA256Intrinsics(GeneratedPluginInjectionProvider injection) {
this.injectedGraalHotSpotVMConfig = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
}
}
final class PluginReplacementNode_DigestBaseSubstitutions_useSHA256Intrinsics implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_DigestBaseSubstitutions_useSHA256Intrinsics();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
boolean result = org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions.useSHA256Intrinsics(arg0);
JavaConstant constant = JavaConstant.forInt(result ? 1 : 0);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
return true;
}
}
final class Plugin_DigestBaseSubstitutions_useSHA512Intrinsics extends GeneratedFoldInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!b.isPluginEnabled(this)) {
return false;
}
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_DigestBaseSubstitutions_useSHA512Intrinsics.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injectedGraalHotSpotVMConfig;
boolean result = org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions.useSHA512Intrinsics(arg0);
JavaConstant constant = JavaConstant.forInt(result ? 1 : 0);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
b.notifyReplacedCall(targetMethod, node);
return true;
}
@Override
public Class<? extends Annotation> getSource() {
return org.graalvm.compiler.api.replacements.Fold.class;
}
private final org.graalvm.compiler.hotspot.GraalHotSpotVMConfig injectedGraalHotSpotVMConfig;
Plugin_DigestBaseSubstitutions_useSHA512Intrinsics(GeneratedPluginInjectionProvider injection) {
this.injectedGraalHotSpotVMConfig = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
}
}
final class PluginReplacementNode_DigestBaseSubstitutions_useSHA512Intrinsics implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_DigestBaseSubstitutions_useSHA512Intrinsics();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
boolean result = org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions.useSHA512Intrinsics(arg0);
JavaConstant constant = JavaConstant.forInt(result ? 1 : 0);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
return true;
}
}
public class PluginFactory_DigestBaseSubstitutions implements GeneratedPluginFactory {
@Override
public void registerPlugins(InvocationPlugins plugins, GeneratedPluginInjectionProvider injection) {
plugins.register(new Plugin_DigestBaseSubstitutions_useSHA1Intrinsics(injection), org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions.class, "useSHA1Intrinsics", org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
plugins.register(new Plugin_DigestBaseSubstitutions_useSHA256Intrinsics(injection), org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions.class, "useSHA256Intrinsics", org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
plugins.register(new Plugin_DigestBaseSubstitutions_useSHA512Intrinsics(injection), org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions.class, "useSHA512Intrinsics", org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
}
}