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