1 /* 2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 package org.graalvm.compiler.nodes.graphbuilderconf; 26 27 import org.graalvm.compiler.core.common.spi.ConstantFieldProvider; 28 import org.graalvm.compiler.debug.DebugContext; 29 import org.graalvm.compiler.nodes.StructuredGraph; 30 import org.graalvm.compiler.nodes.ValueNode; 31 import org.graalvm.compiler.nodes.spi.Replacements; 32 import org.graalvm.compiler.nodes.spi.StampProvider; 33 import org.graalvm.compiler.options.OptionValues; 34 35 import jdk.vm.ci.meta.Assumptions; 36 import jdk.vm.ci.meta.ConstantReflectionProvider; 37 import jdk.vm.ci.meta.MetaAccessProvider; 38 39 /** 40 * Used by a {@link GraphBuilderPlugin} to interface with an object that builds a graph. 41 */ 42 public interface GraphBuilderTool { 43 44 /** 45 * Adds the given node to the graph and also adds recursively all referenced inputs. 46 * 47 * @param value the node to be added to the graph 48 * @return either the node added or an equivalent node 49 */ 50 <T extends ValueNode> T append(T value); 51 52 StampProvider getStampProvider(); 53 54 MetaAccessProvider getMetaAccess(); 55 56 Replacements getReplacements(); 57 58 default Assumptions getAssumptions() { 59 return getGraph().getAssumptions(); 60 } 61 62 ConstantReflectionProvider getConstantReflection(); 63 64 ConstantFieldProvider getConstantFieldProvider(); 65 66 /** 67 * Gets the graph being constructed. 68 */ 69 StructuredGraph getGraph(); 70 71 default OptionValues getOptions() { 72 return getGraph().getOptions(); 73 } 74 75 default DebugContext getDebug() { 76 return getGraph().getDebug(); 77 } 78 79 /** 80 * Determines if this parsing context is within the bytecode of an intrinsic or a method inlined 81 * by an intrinsic. 82 */ 83 boolean parsingIntrinsic(); 84 85 @SuppressWarnings("unused") 86 default boolean canDeferPlugin(GeneratedInvocationPlugin plugin) { 87 // By default generated plugins must be completely processed during parsing. 88 return false; 89 } 90 }