001/*
002 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package com.oracle.graal.hotspot;
024
025import jdk.internal.jvmci.code.*;
026import jdk.internal.jvmci.common.*;
027import jdk.internal.jvmci.hotspot.HotSpotVMConfig.*;
028import jdk.internal.jvmci.meta.*;
029
030import com.oracle.graal.hotspot.meta.*;
031import com.oracle.graal.hotspot.nodes.*;
032import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
033import com.oracle.graal.lir.gen.*;
034
035/**
036 * This interface defines the contract a HotSpot backend LIR generator needs to fulfill in addition
037 * to abstract methods from {@link LIRGenerator} and {@link LIRGeneratorTool}.
038 */
039public interface HotSpotLIRGenerator extends LIRGeneratorTool {
040
041    /**
042     * Emits an operation to make a tail call.
043     *
044     * @param args the arguments of the call
045     * @param address the target address of the call
046     */
047    void emitTailcall(Value[] args, Value address);
048
049    void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason);
050
051    /**
052     * Emits code for a {@link SaveAllRegistersNode}.
053     *
054     * @return a {@link SaveRegistersOp} operation
055     */
056    SaveRegistersOp emitSaveAllRegisters();
057
058    /**
059     * Emits code for a {@link LeaveCurrentStackFrameNode}.
060     *
061     * @param saveRegisterOp saved registers
062     */
063    default void emitLeaveCurrentStackFrame(SaveRegistersOp saveRegisterOp) {
064        throw JVMCIError.unimplemented();
065    }
066
067    /**
068     * Emits code for a {@link LeaveDeoptimizedStackFrameNode}.
069     *
070     * @param frameSize
071     * @param initialInfo
072     */
073    default void emitLeaveDeoptimizedStackFrame(Value frameSize, Value initialInfo) {
074        throw JVMCIError.unimplemented();
075    }
076
077    /**
078     * Emits code for a {@link EnterUnpackFramesStackFrameNode}.
079     *
080     * @param framePc
081     * @param senderSp
082     * @param senderFp
083     * @param saveRegisterOp
084     */
085    default void emitEnterUnpackFramesStackFrame(Value framePc, Value senderSp, Value senderFp, SaveRegistersOp saveRegisterOp) {
086        throw JVMCIError.unimplemented();
087    }
088
089    /**
090     * Emits code for a {@link LeaveUnpackFramesStackFrameNode}.
091     *
092     * @param saveRegisterOp
093     */
094    default void emitLeaveUnpackFramesStackFrame(SaveRegistersOp saveRegisterOp) {
095        throw JVMCIError.unimplemented();
096    }
097
098    /**
099     * Emits code for a {@link PushInterpreterFrameNode}.
100     *
101     * @param frameSize
102     * @param framePc
103     * @param senderSp
104     * @param initialInfo
105     */
106    default void emitPushInterpreterFrame(Value frameSize, Value framePc, Value senderSp, Value initialInfo) {
107        throw JVMCIError.unimplemented();
108    }
109
110    /**
111     * Emits code for a {@link UncommonTrapCallNode}.
112     *
113     * @param trapRequest
114     * @param saveRegisterOp
115     * @return a {@code Deoptimization::UnrollBlock} pointer
116     */
117    default Value emitUncommonTrapCall(Value trapRequest, SaveRegistersOp saveRegisterOp) {
118        throw JVMCIError.unimplemented();
119    }
120
121    /**
122     * Emits code for a {@link DeoptimizationFetchUnrollInfoCallNode}.
123     *
124     * @param saveRegisterOp
125     * @return a {@code Deoptimization::UnrollBlock} pointer
126     */
127    default Value emitDeoptimizationFetchUnrollInfoCall(SaveRegistersOp saveRegisterOp) {
128        throw JVMCIError.unimplemented();
129    }
130
131    default Value emitCardTableShift() {
132        throw JVMCIError.unimplemented();
133    }
134
135    default Value emitCardTableAddress() {
136        throw JVMCIError.unimplemented();
137    }
138
139    /**
140     * Gets a stack slot for a lock at a given lock nesting depth.
141     */
142    StackSlotValue getLockSlot(int lockDepth);
143
144    HotSpotProviders getProviders();
145
146    Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull);
147
148    Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull);
149
150    void emitPrefetchAllocate(Value address);
151}