Mercurial > hg > graal-compiler
view graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java @ 16527:22ae26714321
[SPARC] Fix warnings thrown by compiler
author | Stefan Anzinger <stefan.anzinger@gmail.com> |
---|---|
date | Tue, 15 Jul 2014 19:42:36 -0700 |
parents | 96bb07a5d667 |
children | 9619ba4daf4c |
line wrap: on
line source
/* * Copyright (c) 2013, 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.lir.ptx; import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import static com.oracle.graal.lir.LIRValueUtil.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.ptx.*; import com.oracle.graal.asm.ptx.PTXMacroAssembler.Mov; import com.oracle.graal.compiler.common.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.MoveOp; import com.oracle.graal.lir.StandardOp.NullCheck; import com.oracle.graal.lir.asm.*; public class PTXMove { @Opcode("MOVE") public static class SpillMoveOp extends PTXLIRInstruction implements MoveOp { @Def({REG, STACK}) protected AllocatableValue result; @Use({REG, STACK, CONST}) protected Value input; public SpillMoveOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @Override public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { move(crb, masm, getResult(), getInput()); } @Override public Value getInput() { return input; } @Override public AllocatableValue getResult() { return result; } } @Opcode("MOVE") public static class MoveToRegOp extends PTXLIRInstruction implements MoveOp { @Def({REG, HINT}) protected AllocatableValue result; @Use({REG, STACK, CONST}) protected Value input; public MoveToRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @Override public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { move(crb, masm, getResult(), getInput()); } @Override public Value getInput() { return input; } @Override public AllocatableValue getResult() { return result; } } @Opcode("MOVE") public static class MoveFromRegOp extends PTXLIRInstruction implements MoveOp { @Def({REG, STACK}) protected AllocatableValue result; @Use({REG, CONST, HINT}) protected Value input; public MoveFromRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @Override public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { move(crb, masm, getResult(), getInput()); } @Override public Value getInput() { return input; } @Override public AllocatableValue getResult() { return result; } } public static class LeaOp extends PTXLIRInstruction { @Def({REG}) protected AllocatableValue result; @Use({COMPOSITE, UNINITIALIZED}) protected PTXAddressValue address; public LeaOp(AllocatableValue result, PTXAddressValue address) { this.result = result; this.address = address; } @Override public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { throw new InternalError("NYI"); } } public static class StackLeaOp extends PTXLIRInstruction { @Def({REG}) protected AllocatableValue result; @Use({STACK, UNINITIALIZED}) protected StackSlot slot; public StackLeaOp(AllocatableValue result, StackSlot slot) { this.result = result; this.slot = slot; } @Override public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { throw new InternalError("NYI"); } } @Opcode("CAS") public static class CompareAndSwapOp extends PTXLIRInstruction { @Def protected AllocatableValue result; @Use({COMPOSITE}) protected PTXAddressValue address; @Use protected AllocatableValue cmpValue; @Use protected AllocatableValue newValue; public CompareAndSwapOp(AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { this.result = result; this.address = address; this.cmpValue = cmpValue; this.newValue = newValue; } @Override public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { compareAndSwap(crb, masm, result, address, cmpValue, newValue); } } public static void move(CompilationResultBuilder crb, PTXMacroAssembler masm, Value result, Value input) { if (isVariable(input)) { if (isVariable(result)) { reg2reg(masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isConstant(input)) { if (isVariable(result)) { const2reg(crb, masm, result, (Constant) input); } else { throw GraalInternalError.shouldNotReachHere(); } } else { throw GraalInternalError.shouldNotReachHere(); } } private static void reg2reg(PTXMacroAssembler masm, Value result, Value input) { Variable dest = (Variable) result; Variable source = (Variable) input; if (dest.index == source.index) { return; } switch (input.getKind()) { case Int: case Long: case Float: case Double: case Object: new Mov(dest, source).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere("missing: " + input.getKind()); } } private static void const2reg(CompilationResultBuilder crb, PTXMacroAssembler masm, Value result, Constant input) { Variable dest = (Variable) result; switch (input.getKind().getStackKind()) { case Int: case Long: if (crb.codeCache.needsDataPatch(input)) { crb.recordInlineDataInCode(input); } new Mov(dest, input).emit(masm); break; case Object: if (input.isNull()) { new Mov(dest, Constant.forLong(0x0L)).emit(masm); } else if (crb.target.inlineObjects) { crb.recordInlineDataInCode(input); new Mov(dest, Constant.forLong(0xDEADDEADDEADDEADL)).emit(masm); } else { // new Mov(dest, crb.recordDataReferenceInCode(input, 0, false)); } break; default: throw GraalInternalError.shouldNotReachHere("missing: " + input.getKind()); } } @SuppressWarnings("unused") protected static void compareAndSwap(CompilationResultBuilder crb, PTXAssembler masm, AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { throw new InternalError("NYI"); } public static class NullCheckOp extends PTXLIRInstruction implements NullCheck { @Use({REG}) protected AllocatableValue input; @State protected LIRFrameState state; public NullCheckOp(Variable input, LIRFrameState state) { this.input = input; this.state = state; } @Override public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { crb.recordImplicitException(masm.position(), state); masm.nullCheck(asRegister(input)); } public Value getCheckedValue() { return input; } public LIRFrameState getState() { return state; } } }