1 /* 2 * Copyright (c) 2016, 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 package org.graalvm.compiler.nodes.graphbuilderconf; 24 25 import org.graalvm.compiler.core.common.spi.ConstantFieldProvider; 26 import org.graalvm.compiler.nodes.StructuredGraph; 27 import org.graalvm.compiler.nodes.ValueNode; 28 import org.graalvm.compiler.nodes.spi.StampProvider; 29 import org.graalvm.compiler.options.OptionValues; 30 31 import jdk.vm.ci.meta.Assumptions; 32 import jdk.vm.ci.meta.ConstantReflectionProvider; 33 import jdk.vm.ci.meta.MetaAccessProvider; 34 35 /** 36 * Used by a {@link GraphBuilderPlugin} to interface with an object that builds a graph. 37 */ 38 public interface GraphBuilderTool { 39 40 /** 41 * Raw operation for adding a node to the graph. 42 * 43 * @return either the node added or an equivalent node 44 */ 45 <T extends ValueNode> T append(T value); 46 47 /** 48 * Adds the given node to the graph and also adds recursively all referenced inputs. 49 * 50 * @param value the node to be added to the graph 51 * @return either the node added or an equivalent node 52 */ 53 <T extends ValueNode> T recursiveAppend(T value); 54 55 StampProvider getStampProvider(); 56 57 MetaAccessProvider getMetaAccess(); 58 59 default Assumptions getAssumptions() { 60 return getGraph().getAssumptions(); 61 } 62 63 ConstantReflectionProvider getConstantReflection(); 64 65 ConstantFieldProvider getConstantFieldProvider(); 66 67 /** 68 * Gets the graph being constructed. 69 */ 70 StructuredGraph getGraph(); 71 72 default OptionValues getOptions() { 73 return getGraph().getOptions(); 74 } 75 76 /** 77 * Determines if this parsing context is within the bytecode of an intrinsic or a method inlined 78 * by an intrinsic. 79 */ 80 boolean parsingIntrinsic(); 81 }