1 /*
   2  * Copyright (c) 2017, 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.core.gen;
  26 
  27 import org.graalvm.compiler.code.CompilationResult;
  28 import org.graalvm.compiler.core.common.CompilationIdentifier;
  29 import org.graalvm.compiler.lir.LIR;
  30 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
  31 import org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory;
  32 import org.graalvm.compiler.lir.framemap.FrameMap;
  33 import org.graalvm.compiler.lir.gen.LIRGenerationResult;
  34 import org.graalvm.compiler.lir.gen.LIRGeneratorTool;
  35 import org.graalvm.compiler.nodes.StructuredGraph;
  36 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
  37 
  38 import jdk.vm.ci.code.RegisterConfig;
  39 import jdk.vm.ci.meta.ResolvedJavaMethod;
  40 
  41 /**
  42  * Provides compiler backend-specific generation helpers for the {@link LIRCompilerBackend}.
  43  */
  44 public interface LIRGenerationProvider {
  45     LIRGeneratorTool newLIRGenerator(LIRGenerationResult lirGenRes);
  46 
  47     LIRGenerationResult newLIRGenerationResult(CompilationIdentifier compilationId,
  48                     LIR lir,
  49                     RegisterConfig registerConfig,
  50                     StructuredGraph graph,
  51                     Object stub);
  52 
  53     NodeLIRBuilderTool newNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen);
  54 
  55     /**
  56      * Creates the object used to fill in the details of a given compilation result.
  57      */
  58     CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenResult,
  59                     FrameMap frameMap,
  60                     CompilationResult compilationResult,
  61                     CompilationResultBuilderFactory factory);
  62 
  63     /**
  64      * Emits the code for a given graph.
  65      *
  66      * @param installedCodeOwner the method the compiled code will be associated with once
  67      *            installed. This argument can be null.
  68      */
  69     void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod installedCodeOwner);
  70 }