# HG changeset patch # User Thomas Wuerthinger # Date 1381108130 -7200 # Node ID 10755fbf8df8040562064ed60f7880d38aa1225c # Parent 776e348d6c2eba9062f1c218b412086e351ab797 Fix warnings in PTX code. diff -r 776e348d6c2e -r 10755fbf8df8 graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java --- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Mon Oct 07 03:05:50 2013 +0200 +++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Mon Oct 07 03:08:50 2013 +0200 @@ -228,7 +228,7 @@ public static class SingleOperandFormat { protected Variable dest; - protected Value source; + protected Value source; public SingleOperandFormat(Variable dst, Value src) { setDestination(dst); @@ -339,8 +339,7 @@ @Override public String emit() { - return (typeForKind(dest.getKind()) + "." + typeForKind(source.getKind()) + " " + - emitVariable(dest) + ", " + emitValue(source) + ";"); + return (typeForKind(dest.getKind()) + "." + typeForKind(source.getKind()) + " " + emitVariable(dest) + ", " + emitValue(source) + ";"); } } @@ -366,21 +365,18 @@ @Override public String emitRegister(Variable var, boolean comma) { - /* if (space == Parameter) { - return ("param" + var.index); - } else { - return ("%r" + var.index); - } */ + /* + * if (space == Parameter) { return ("param" + var.index); } else { return ("%r" + + * var.index); } + */ return ("%r" + var.index); } public String emit(boolean isLoad) { if (isLoad) { - return (space.getStateName() + "." + typeForKind(valueKind) + " " + - emitRegister(dest, false) + ", " + emitAddress(source1, source2) + ";"); + return (space.getStateName() + "." + typeForKind(valueKind) + " " + emitRegister(dest, false) + ", " + emitAddress(source1, source2) + ";"); } else { - return (space.getStateName() + "." + typeForKind(valueKind) + " " + - emitAddress(source1, source2) + ", " + emitRegister(dest, false) + ";"); + return (space.getStateName() + "." + typeForKind(valueKind) + " " + emitAddress(source1, source2) + ", " + emitRegister(dest, false) + ";"); } } } @@ -521,8 +517,8 @@ emitString("@%p" + pred + " " + "bra" + " " + tgt + ";"); } - public final void bra(String target) { - emitString("bra " + target + ";"); + public final void bra(String targetIdentifier) { + emitString("bra " + targetIdentifier + ";"); } public final void bra_uni(String tgt) { @@ -539,7 +535,7 @@ asm.emitString("cvt." + super.emit()); } } - + public static class Mov extends SingleOperandFormat { private int predicateRegisterNumber = -1; @@ -552,16 +548,15 @@ super(dst, src); this.predicateRegisterNumber = predicate; } + /* - public Mov(Variable dst, AbstractAddress src) { - throw GraalInternalError.unimplemented("AbstractAddress Mov"); - } - */ - + * public Mov(Variable dst, AbstractAddress src) { throw + * GraalInternalError.unimplemented("AbstractAddress Mov"); } + */ + public void emit(PTXAssembler asm) { if (predicateRegisterNumber >= 0) { - asm.emitString("@%p" + String.valueOf(predicateRegisterNumber) - + " mov." + super.emit()); + asm.emitString("@%p" + String.valueOf(predicateRegisterNumber) + " mov." + super.emit()); } else { asm.emitString("mov." + super.emit()); } @@ -578,7 +573,7 @@ asm.emitString("neg." + super.emit()); } } - + public static class Not extends BinarySingleOperandFormat { public Not(Variable dst, Variable src) { @@ -589,7 +584,7 @@ asm.emitString("not." + super.emit()); } } - + public static class Ld extends LoadStoreFormat { public Ld(PTXStateSpace space, Variable dst, Variable src1, Value src2) { @@ -628,7 +623,7 @@ this.targets = targets; } - private String valueForKind(Kind k) { + private static String valueForKind(Kind k) { switch (k.getTypeChar()) { case 'i': return "s32"; @@ -639,12 +634,12 @@ } } - private String emitTargets(PTXAssembler asm, LabelRef[] refs) { + private static String emitTargets(PTXAssembler asm, LabelRef[] refs) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < refs.length; i++) { sb.append(asm.nameOf(refs[i].label())); - if (i < (refs.length -1)) { + if (i < (refs.length - 1)) { sb.append(", "); } } @@ -653,9 +648,7 @@ } public void emit(PTXAssembler asm) { - asm.emitString(".global ." + valueForKind(kind) + - " " + name + "[" + targets.length + "] = " + - "{ " + emitTargets(asm, targets) + " };"); + asm.emitString(".global ." + valueForKind(kind) + " " + name + "[" + targets.length + "] = " + "{ " + emitTargets(asm, targets) + " };"); } } @@ -677,7 +670,7 @@ } public void emit(PTXAssembler asm) { - asm.emitString(".param ." + paramForKind(dest.getKind()) + emitParameter(dest) + (lastParameter ? "" : ",")); + asm.emitString(".param ." + paramForKind(dest.getKind()) + emitParameter(dest) + (lastParameter ? "" : ",")); } public String paramForKind(Kind k) { @@ -722,9 +715,9 @@ emitString("ret.uni;" + " " + ""); } - public static class Setp { + public static class Setp { - private ConditionOperator operator; + private ConditionOperator operator; private Value first, second; private Kind kind; private int predicate; @@ -762,12 +755,18 @@ case 'a': // unsigned switch (condition) { - case EQ: return ConditionOperator.U_EQ; - case NE: return ConditionOperator.U_NE; - case LT: return ConditionOperator.U_LO; - case LE: return ConditionOperator.U_LS; - case GT: return ConditionOperator.U_HI; - case GE: return ConditionOperator.U_HS; + case EQ: + return ConditionOperator.U_EQ; + case NE: + return ConditionOperator.U_NE; + case LT: + return ConditionOperator.U_LO; + case LE: + return ConditionOperator.U_LS; + case GT: + return ConditionOperator.U_HI; + case GE: + return ConditionOperator.U_HS; default: throw GraalInternalError.shouldNotReachHere(); } @@ -777,11 +776,16 @@ case 'j': // signed switch (condition) { - case EQ: return ConditionOperator.S_EQ; - case NE: return ConditionOperator.S_NE; - case LT: return ConditionOperator.S_LT; - case LE: return ConditionOperator.S_LE; - case GT: return ConditionOperator.S_GT; + case EQ: + return ConditionOperator.S_EQ; + case NE: + return ConditionOperator.S_NE; + case LT: + return ConditionOperator.S_LT; + case LE: + return ConditionOperator.S_LE; + case GT: + return ConditionOperator.S_GT; case GE: case AE: return ConditionOperator.S_GE; @@ -792,12 +796,18 @@ case 'd': // floating point - do these need to accept NaN?? switch (condition) { - case EQ: return ConditionOperator.F_EQ; - case NE: return ConditionOperator.F_NE; - case LT: return ConditionOperator.F_LT; - case LE: return ConditionOperator.F_LE; - case GT: return ConditionOperator.F_GT; - case GE: return ConditionOperator.F_GE; + case EQ: + return ConditionOperator.F_EQ; + case NE: + return ConditionOperator.F_NE; + case LT: + return ConditionOperator.F_LT; + case LE: + return ConditionOperator.F_LE; + case GT: + return ConditionOperator.F_GT; + case GE: + return ConditionOperator.F_GE; default: throw GraalInternalError.shouldNotReachHere(); } @@ -815,7 +825,7 @@ kind = first.getKind(); } } - + public String emitValue(Value v) { assert v != null; @@ -867,16 +877,16 @@ throw GraalInternalError.shouldNotReachHere(); } } - + public String emitVariable(Variable v) { return ("%r" + v.index); } public void emit(PTXAssembler asm) { - asm.emitString("setp." + operator.getOperator() + "." + typeForKind(kind) + - " %p" + predicate + emitValue(first) + emitValue(second) + ";"); + asm.emitString("setp." + operator.getOperator() + "." + typeForKind(kind) + " %p" + predicate + emitValue(first) + emitValue(second) + ";"); } } + @Override public PTXAddress makeAddress(Register base, int displacement) { throw GraalInternalError.shouldNotReachHere(); @@ -896,5 +906,4 @@ bra(str); } - } diff -r 776e348d6c2e -r 10755fbf8df8 graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java --- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java Mon Oct 07 03:05:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java Mon Oct 07 03:08:50 2013 +0200 @@ -36,7 +36,7 @@ } else { printReport("testLoop: no VALUE"); } - ret = (Integer) invoke(compile("testSwitchDefault1I"), 3); + ret = (Integer) invoke(compile("testSwitchDefault1I"), 3); if (ret != null) { printReport("testSwitchDefault1I: " + ret); } else { @@ -83,12 +83,12 @@ } public static int testIfElse2I(int c, int y) { - if (c > 19) { - return (int) 'M'; // millenial + if (c > 19) { + return 'M'; // millenial } else if (y > 84) { - return (int) 'Y'; // young + return 'Y'; // young } else { - return (int) 'O'; // old + return 'O'; // old } } diff -r 776e348d6c2e -r 10755fbf8df8 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Mon Oct 07 03:05:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Mon Oct 07 03:08:50 2013 +0200 @@ -66,7 +66,6 @@ import java.lang.annotation.*; - /** * This class implements the PTX specific portion of the LIR generator. */ @@ -88,9 +87,7 @@ } } - public PTXLIRGenerator(StructuredGraph graph, CodeCacheProvider runtime, - TargetDescription target, FrameMap frameMap, - CallingConvention cc, LIR lir) { + public PTXLIRGenerator(StructuredGraph graph, CodeCacheProvider runtime, TargetDescription target, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, runtime, target, frameMap, cc, lir); lir.spillMoveFactory = new PTXSpillMoveFactory(); int callVariables = cc.getArgumentCount() + (cc.getReturn() == Value.ILLEGAL ? 0 : 1); @@ -127,9 +124,7 @@ if (isRegister(value)) { return asRegister(value).asValue(value.getKind().getStackKind()); } else if (isStackSlot(value)) { - return StackSlot.get(value.getKind().getStackKind(), - asStackSlot(value).getRawOffset(), - asStackSlot(value).getRawAddFrameSize()); + return StackSlot.get(value.getKind().getStackKind(), asStackSlot(value).getRawOffset(), asStackSlot(value).getRawAddFrameSize()); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -337,30 +332,23 @@ } @Override - public Variable emitConditionalMove(Value left, Value right, - Condition cond, boolean unorderedIsTrue, - Value trueValue, Value falseValue) { + public Variable emitConditionalMove(Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) { Condition finalCondition = LIRValueUtil.isVariable(right) ? cond.mirror() : cond; - boolean mirrored; - mirrored = emitCompare(finalCondition, left, right); + emitCompare(finalCondition, left, right); Variable result = newVariable(trueValue.getKind()); switch (left.getKind().getStackKind()) { case Int: case Long: case Object: - append(new CondMoveOp(result, finalCondition, - load(trueValue), loadNonConst(falseValue), - nextPredRegNum)); + append(new CondMoveOp(result, finalCondition, load(trueValue), loadNonConst(falseValue), nextPredRegNum)); nextPredRegNum++; break; case Float: case Double: - append(new FloatCondMoveOp(result, finalCondition, unorderedIsTrue, - load(trueValue), load(falseValue), - nextPredRegNum)); + append(new FloatCondMoveOp(result, finalCondition, unorderedIsTrue, load(trueValue), load(falseValue), nextPredRegNum)); nextPredRegNum++; break; default: @@ -370,9 +358,9 @@ } /** - * This method emits the compare instruction, and may reorder the operands. - * It returns true if it did so. - * + * This method emits the compare instruction, and may reorder the operands. It returns true if + * it did so. + * * @param a the left operand of the comparison * @param b the right operand of the comparison * @return true if the left and right operands were switched, false otherwise @@ -412,7 +400,6 @@ return mirrored; } - @Override public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) { throw new InternalError("NYI"); diff -r 776e348d6c2e -r 10755fbf8df8 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Mon Oct 07 03:05:50 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Mon Oct 07 03:08:50 2013 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.lir.ptx; -import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.asm.ptx.PTXAssembler.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import static com.oracle.graal.lir.LIRValueUtil.*; @@ -59,7 +58,8 @@ public static class ReturnNoValOp extends PTXLIRInstruction { - public ReturnNoValOp() { } + public ReturnNoValOp() { + } @Override public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) { @@ -107,9 +107,7 @@ private final Condition condition; private final int predicate; - public CondMoveOp(Variable result, Condition condition, - Variable trueValue, Value falseValue, - int predicateRegister) { + public CondMoveOp(Variable result, Condition condition, Variable trueValue, Value falseValue, int predicateRegister) { this.result = result; this.condition = condition; this.trueValue = trueValue; @@ -119,8 +117,7 @@ @Override public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) { - cmove(tasm, masm, result, false, condition, false, - trueValue, falseValue, predicate); + cmove(tasm, masm, result, false, condition, false, trueValue, falseValue, predicate); } } @@ -133,10 +130,7 @@ private final boolean unorderedIsTrue; private final int predicate; - public FloatCondMoveOp(Variable result, Condition condition, - boolean unorderedIsTrue, - Variable trueValue, Variable falseValue, - int predicateRegister) { + public FloatCondMoveOp(Variable result, Condition condition, boolean unorderedIsTrue, Variable trueValue, Variable falseValue, int predicateRegister) { this.result = result; this.condition = condition; this.unorderedIsTrue = unorderedIsTrue; @@ -147,21 +141,17 @@ @Override public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) { - cmove(tasm, masm, result, true, condition, unorderedIsTrue, - trueValue, falseValue, predicate); + cmove(tasm, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue, predicate); } } - private static void cmove(TargetMethodAssembler tasm, PTXAssembler asm, - Value result, boolean isFloat, Condition condition, - boolean unorderedIsTrue, - Value trueValue, Value falseValue, - int predicateRegister) { + private static void cmove(TargetMethodAssembler tasm, PTXAssembler asm, Value result, boolean isFloat, Condition condition, boolean unorderedIsTrue, Value trueValue, Value falseValue, + int predicateRegister) { // check that we don't overwrite an input operand before it is used. assert !result.equals(trueValue); PTXMove.move(tasm, asm, result, falseValue); - cmove(tasm, asm, result, condition, trueValue, predicateRegister); + cmove(asm, result, trueValue, predicateRegister); if (isFloat) { if (unorderedIsTrue && !trueOnUnordered(condition)) { @@ -187,12 +177,9 @@ } } - private static void cmove(TargetMethodAssembler tasm, PTXAssembler asm, - Value result, Condition cond, Value other, - int predicateRegister) { + private static void cmove(PTXAssembler asm, Value result, Value other, int predicateRegister) { if (isVariable(other)) { - assert !asVariable(other).equals(asVariable(result)) : - "other already overwritten by previous move"; + assert !asVariable(other).equals(asVariable(result)) : "other already overwritten by previous move"; switch (other.getKind()) { case Int: @@ -219,9 +206,7 @@ // Number of predicate register that would be set by this instruction. protected int predRegNum; - public SequentialSwitchOp(Constant[] keyConstants, - LabelRef[] keyTargets, LabelRef defaultTarget, - Value key, Value scratch, int predReg) { + public SequentialSwitchOp(Constant[] keyConstants, LabelRef[] keyTargets, LabelRef defaultTarget, Value key, Value scratch, int predReg) { assert keyConstants.length == keyTargets.length; this.keyConstants = keyConstants; this.keyTargets = keyTargets; @@ -280,9 +265,7 @@ // Number of predicate register that would be set by this instruction. protected int predRegNum; - public TableSwitchOp(final int lowKey, final LabelRef defaultTarget, - final LabelRef[] targets, - Variable index, Variable scratch, int predReg) { + public TableSwitchOp(final int lowKey, final LabelRef defaultTarget, final LabelRef[] targets, Variable index, Variable scratch, int predReg) { this.lowKey = lowKey; this.defaultTarget = defaultTarget; this.targets = targets; @@ -293,15 +276,12 @@ @Override public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) { - tableswitch(tasm, masm, lowKey, defaultTarget, targets, - index, scratch, predRegNum); + tableswitch(tasm, masm, lowKey, defaultTarget, targets, index, scratch, predRegNum); } } @SuppressWarnings("unused") - private static void tableswitch(TargetMethodAssembler tasm, PTXAssembler masm, int lowKey, - LabelRef defaultTarget, LabelRef[] targets, - Value value, Value scratch, int predNum) { + private static void tableswitch(TargetMethodAssembler tasm, PTXAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value value, Value scratch, int predNum) { Buffer buf = masm.codeBuffer; // Compare index against jump table bounds @@ -323,7 +303,6 @@ // address of jump table int tablePos = buf.position(); - JumpTable jt = new JumpTable(tablePos, lowKey, highKey, 4); String name = "jumptable" + jt.position;