# HG changeset patch # User Stefan Anzinger # Date 1410373118 25200 # Node ID 602fcd1b2cd4a935159dd839599ff7ad666bdac5 # Parent bd26b71aa5fc9334e5f69dcf1cf97acced4ac176 [SPARC] fix issues with moving between float and general purpose registers (alignment) diff -r bd26b71aa5fc -r 602fcd1b2cd4 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Tue Sep 09 18:35:08 2014 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Wed Sep 10 11:18:38 2014 -0700 @@ -111,6 +111,7 @@ this.result = result; this.input = input; this.temp = temp; + assert this.temp.getPlatformKind() == Kind.Long; } public Value getInput() { @@ -123,42 +124,66 @@ @Override public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { - PlatformKind inputKind = input.getPlatformKind(); - PlatformKind resultKind = result.getPlatformKind(); + Kind inputKind = (Kind) input.getPlatformKind(); + Kind resultKind = (Kind) result.getPlatformKind(); + int resultKindSize = crb.target.getSizeInBytes(resultKind); try (SPARCScratchRegister sc = SPARCScratchRegister.get()) { Register scratch = sc.getRegister(); SPARCAddress tempAddress = guaranueeLoadable((SPARCAddress) crb.asAddress(temp), masm, scratch); - if (inputKind == Kind.Float) { - new Stf(asFloatReg(input), tempAddress).emit(masm); - } else if (inputKind == Kind.Double) { - new Stdf(asDoubleReg(input), tempAddress).emit(masm); - } else if (inputKind == Kind.Int) { - new Stw(asIntReg(input), tempAddress).emit(masm); - } else if (inputKind == Kind.Short || inputKind == Kind.Char) { - new Sth(asIntReg(input), tempAddress).emit(masm); - } else if (inputKind == Kind.Byte) { - new Stb(asIntReg(input), tempAddress).emit(masm); - } else if (inputKind == Kind.Long) { - new Stx(asLongReg(input), tempAddress).emit(masm); - } else { - GraalInternalError.shouldNotReachHere(); + switch (inputKind) { + case Float: + assert resultKindSize == 4; + new Stf(asFloatReg(input), tempAddress).emit(masm); + break; + case Double: + assert resultKindSize == 8; + new Stdf(asDoubleReg(input), tempAddress).emit(masm); + break; + case Long: + case Int: + case Short: + case Char: + case Byte: + if (resultKindSize == 8) { + new Stx(asLongReg(input), tempAddress).emit(masm); + } else if (resultKindSize == 4) { + new Stw(asIntReg(input), tempAddress).emit(masm); + } else if (resultKindSize == 2) { + new Sth(asIntReg(input), tempAddress).emit(masm); + } else if (resultKindSize == 1) { + new Stb(asIntReg(input), tempAddress).emit(masm); + } else { + throw GraalInternalError.shouldNotReachHere(); + } + break; + default: + GraalInternalError.shouldNotReachHere(); } - if (resultKind == Kind.Int) { - new Ldsw(tempAddress, asIntReg(result)).emit(masm); - } else if (inputKind == Kind.Short) { - new Ldsh(tempAddress, asIntReg(input)).emit(masm); - } else if (inputKind == Kind.Char) { - new Lduh(tempAddress, asIntReg(input)).emit(masm); - } else if (inputKind == Kind.Byte) { - new Ldsb(tempAddress, asIntReg(input)).emit(masm); - } else if (resultKind == Kind.Float) { - new Ldf(tempAddress, asFloatReg(result)).emit(masm); - } else if (resultKind == Kind.Long) { - new Ldx(tempAddress, asLongReg(result)).emit(masm); - } else if (resultKind == Kind.Double) { - new Lddf(tempAddress, asDoubleReg(result)).emit(masm); - } else { - GraalInternalError.shouldNotReachHere(); + switch (resultKind) { + case Long: + new Ldx(tempAddress, asLongReg(result)).emit(masm); + break; + case Int: + new Ldsw(tempAddress, asIntReg(result)).emit(masm); + break; + case Short: + new Ldsh(tempAddress, asIntReg(input)).emit(masm); + break; + case Char: + new Lduh(tempAddress, asIntReg(input)).emit(masm); + break; + case Byte: + new Ldsb(tempAddress, asIntReg(input)).emit(masm); + break; + case Float: + new Ldf(tempAddress, asFloatReg(result)).emit(masm); + break; + case Double: + new Lddf(tempAddress, asDoubleReg(result)).emit(masm); + break; + default: + GraalInternalError.shouldNotReachHere(); + break; } } }