use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class StandardGraphBuilderPlugins method registerUnsignedMathPlugins.
private static void registerUnsignedMathPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, UnsignedMath.class);
r.register2("aboveThan", int.class, int.class, new UnsignedMathPlugin(Condition.AT));
r.register2("aboveThan", long.class, long.class, new UnsignedMathPlugin(Condition.AT));
r.register2("belowThan", int.class, int.class, new UnsignedMathPlugin(Condition.BT));
r.register2("belowThan", long.class, long.class, new UnsignedMathPlugin(Condition.BT));
r.register2("aboveOrEqual", int.class, int.class, new UnsignedMathPlugin(Condition.AE));
r.register2("aboveOrEqual", long.class, long.class, new UnsignedMathPlugin(Condition.AE));
r.register2("belowOrEqual", int.class, int.class, new UnsignedMathPlugin(Condition.BE));
r.register2("belowOrEqual", long.class, long.class, new UnsignedMathPlugin(Condition.BE));
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class StandardGraphBuilderPlugins method registerCharacterPlugins.
private static void registerCharacterPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, Character.class);
r.register1("reverseBytes", char.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
// return (char) (Integer.reverse(i) >> 16);
ReverseBytesNode reverse = b.add(new ReverseBytesNode(value));
RightShiftNode rightShift = b.add(new RightShiftNode(reverse, b.add(ConstantNode.forInt(16))));
ZeroExtendNode charCast = b.add(new ZeroExtendNode(b.add(new NarrowNode(rightShift, 16)), 32));
b.push(JavaKind.Char, b.append(charCast.canonical(null)));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class StandardGraphBuilderPlugins method registerDoublePlugins.
private static void registerDoublePlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, Double.class);
r.register1("doubleToRawLongBits", double.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Long, b.append(ReinterpretNode.create(JavaKind.Long, value, NodeView.DEFAULT)));
return true;
}
});
r.register1("longBitsToDouble", long.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Double, b.append(ReinterpretNode.create(JavaKind.Double, value, NodeView.DEFAULT)));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class StandardGraphBuilderPlugins method registerFloatPlugins.
private static void registerFloatPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, Float.class);
r.register1("floatToRawIntBits", float.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Int, b.append(ReinterpretNode.create(JavaKind.Int, value, NodeView.DEFAULT)));
return true;
}
});
r.register1("intBitsToFloat", int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Float, b.append(ReinterpretNode.create(JavaKind.Float, value, NodeView.DEFAULT)));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class StandardGraphBuilderPlugins method registerStringPlugins.
private static void registerStringPlugins(InvocationPlugins plugins, BytecodeProvider bytecodeProvider, SnippetReflectionProvider snippetReflection) {
final Registration r = new Registration(plugins, String.class, bytecodeProvider);
r.register1("hashCode", Receiver.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
if (receiver.isConstant()) {
String s = snippetReflection.asObject(String.class, (JavaConstant) receiver.get().asConstant());
b.addPush(JavaKind.Int, b.add(ConstantNode.forInt(s.hashCode())));
return true;
}
return false;
}
});
if (Java8OrEarlier) {
r.registerMethodSubstitution(StringSubstitutions.class, "equals", Receiver.class, Object.class);
r.register7("indexOf", char[].class, int.class, int.class, char[].class, int.class, int.class, int.class, new StringIndexOfConstantPlugin());
Registration sr = new Registration(plugins, StringSubstitutions.class);
sr.register1("getValue", String.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
ResolvedJavaField field = b.getMetaAccess().lookupJavaField(STRING_VALUE_FIELD);
b.addPush(JavaKind.Object, LoadFieldNode.create(b.getConstantFieldProvider(), b.getConstantReflection(), b.getMetaAccess(), b.getOptions(), b.getAssumptions(), value, field, false, false));
return true;
}
});
}
}
Aggregations