view graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java @ 9003:a8fea2979e63

eager infopoint mode (fka debug mode)
author Michael Haupt <michael.haupt@oracle.com>
date Thu, 11 Apr 2013 09:53:10 +0200
parents 2c0c708a0ad6
children 589e140a7f1c
line wrap: on
line source

/*
 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */
package com.oracle.graal.nodes.spi;

import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.nodes.*;
import com.oracle.graal.nodes.calc.*;
import com.oracle.graal.nodes.extended.*;
import com.oracle.graal.nodes.java.*;

public abstract class LIRGeneratorTool {

    public abstract TargetDescription target();

    public abstract CodeCacheProvider getRuntime();

    /**
     * Checks whether the supplied constant can be used without loading it into a register for most
     * operations, i.e., for commonly used arithmetic, logical, and comparison operations.
     * 
     * @param c The constant to check.
     * @return True if the constant can be used directly, false if the constant needs to be in a
     *         register.
     */
    public abstract boolean canInlineConstant(Constant c);

    public abstract RegisterAttributes attributes(Register register);

    public abstract Value operand(ValueNode object);

    public abstract AllocatableValue newVariable(Kind kind);

    public abstract Value setResult(ValueNode x, Value operand);

    public abstract Value emitMove(Value input);

    public abstract void emitMove(Value dst, Value src);

    public abstract Value emitLoad(Kind kind, Value base, int displacement, Value index, int scale, DeoptimizingNode deopting);

    public abstract void emitStore(Kind kind, Value base, int displacement, Value index, int scale, Value input, DeoptimizingNode deopting);

    public abstract Value emitLea(Value base, int displacement, Value index, int scale);

    public abstract Value emitLea(StackSlot slot);

    public abstract Value emitNegate(Value input);

    public abstract Value emitAdd(Value a, Value b);

    public abstract Value emitSub(Value a, Value b);

    public abstract Value emitMul(Value a, Value b);

    public abstract Value emitDiv(Value a, Value b, DeoptimizingNode deopting);

    public abstract Value emitRem(Value a, Value b, DeoptimizingNode deopting);

    public abstract Value emitUDiv(Value a, Value b, DeoptimizingNode deopting);

    public abstract Value emitURem(Value a, Value b, DeoptimizingNode deopting);

    public abstract Value emitAnd(Value a, Value b);

    public abstract Value emitOr(Value a, Value b);

    public abstract Value emitXor(Value a, Value b);

    public abstract Value emitShl(Value a, Value b);

    public abstract Value emitShr(Value a, Value b);

    public abstract Value emitUShr(Value a, Value b);

    public abstract Value emitConvert(ConvertNode.Op opcode, Value inputVal);

    public abstract void emitMembar(int barriers);

    public abstract void emitDeoptimize(DeoptimizationAction action, DeoptimizingNode deopting);

    public abstract void emitNullCheck(ValueNode v, DeoptimizingNode deopting);

    public abstract Value emitCall(RuntimeCallTarget callTarget, CallingConvention cc, DeoptimizingNode info, Value... args);

    public abstract void emitIf(IfNode i);

    public abstract void emitConditional(ConditionalNode i);

    public abstract void emitSwitch(SwitchNode i);

    public abstract void emitInvoke(Invoke i);

    public abstract void visitRuntimeCall(RuntimeCallNode i);

    // Handling of block-end nodes still needs to be unified in the LIRGenerator.
    public abstract void visitMerge(MergeNode i);

    public abstract void visitEndNode(EndNode i);

    public abstract void visitLoopEnd(LoopEndNode i);

    public abstract void visitCompareAndSwap(CompareAndSwapNode i);

    // These methods define the contract a runtime specific backend must provide.

    public abstract void visitReturn(ReturnNode i);

    public abstract void visitSafepointNode(SafepointNode i);

    public abstract void visitBreakpointNode(BreakpointNode i);

    public abstract void emitUnwind(Value operand);

    /**
     * Called just before register allocation is performed on the LIR owned by this generator.
     */
    public void beforeRegisterAllocation() {
    }

    public abstract void visitInfopointNode(InfopointNode i);
}