use of org.graalvm.compiler.replacements.nodes.arithmetic.IntegerSubExactNode in project graal by oracle.
the class StandardGraphBuilderPlugins method registerMathPlugins.
private static void registerMathPlugins(InvocationPlugins plugins, boolean allowDeoptimization) {
Registration r = new Registration(plugins, Math.class);
if (allowDeoptimization) {
for (JavaKind kind : new JavaKind[] { JavaKind.Int, JavaKind.Long }) {
Class<?> type = kind.toJavaClass();
r.register1("decrementExact", type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x) {
b.addPush(kind, new IntegerSubExactNode(x, ConstantNode.forIntegerKind(kind, 1)));
return true;
}
});
r.register1("incrementExact", type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x) {
b.addPush(kind, new IntegerAddExactNode(x, ConstantNode.forIntegerKind(kind, 1)));
return true;
}
});
r.register2("addExact", type, type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
b.addPush(kind, new IntegerAddExactNode(x, y));
return true;
}
});
r.register2("subtractExact", type, type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
b.addPush(kind, new IntegerSubExactNode(x, y));
return true;
}
});
r.register2("multiplyExact", type, type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
b.addPush(kind, new IntegerMulExactNode(x, y));
return true;
}
});
}
}
r.register1("abs", Float.TYPE, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Float, b.append(new AbsNode(value).canonical(null)));
return true;
}
});
r.register1("abs", Double.TYPE, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Double, b.append(new AbsNode(value).canonical(null)));
return true;
}
});
r.register1("sqrt", Double.TYPE, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Double, b.append(SqrtNode.create(value, NodeView.DEFAULT)));
return true;
}
});
}
Aggregations