# HG changeset patch # User Christian Wimmer # Date 1395771337 25200 # Node ID c4903a8f6ef4c0a555f3b593e94979d404cb49be # Parent 5ba874df3b2b93cbdd22f5b8b7c4f8daa2c2a938 Support zero-extend-load for all data sizes diff -r 5ba874df3b2b -r c4903a8f6ef4 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Tue Mar 25 11:07:47 2014 -0700 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Tue Mar 25 11:15:37 2014 -0700 @@ -61,7 +61,7 @@ import com.oracle.graal.lir.amd64.AMD64ControlFlow.StrategySwitchOp; import com.oracle.graal.lir.amd64.AMD64ControlFlow.TableSwitchOp; import com.oracle.graal.lir.amd64.AMD64Move.LeaOp; -import com.oracle.graal.lir.amd64.AMD64Move.LoadOp; +import com.oracle.graal.lir.amd64.AMD64Move.ZeroExtendLoadOp; import com.oracle.graal.lir.amd64.AMD64Move.MembarOp; import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp; import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp; @@ -597,11 +597,10 @@ } protected Value emitZeroExtendMemory(Kind memoryKind, int resultBits, AMD64AddressValue address, LIRFrameState state) { - assert memoryKind.isUnsigned(); // Issue a zero extending load of the proper bit size and set the result to // the proper kind. Variable result = newVariable(resultBits == 32 ? Kind.Int : Kind.Long); - append(new LoadOp(memoryKind, result, address, state)); + append(new ZeroExtendLoadOp(memoryKind, result, address, state)); return result; } diff -r 5ba874df3b2b -r c4903a8f6ef4 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Tue Mar 25 11:07:47 2014 -0700 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Tue Mar 25 11:15:37 2014 -0700 @@ -172,6 +172,38 @@ } } + public static class ZeroExtendLoadOp extends MemOp { + + @Def({REG}) protected AllocatableValue result; + + public ZeroExtendLoadOp(Kind kind, AllocatableValue result, AMD64AddressValue address, LIRFrameState state) { + super(kind, address, state); + this.result = result; + } + + @Override + public void emitMemAccess(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + switch (kind) { + case Boolean: + case Byte: + masm.movzbl(asRegister(result), address.toAddress()); + break; + case Char: + case Short: + masm.movzwl(asRegister(result), address.toAddress()); + break; + case Int: + masm.movl(asRegister(result), address.toAddress()); + break; + case Long: + masm.movq(asRegister(result), address.toAddress()); + break; + default: + throw GraalInternalError.shouldNotReachHere(); + } + } + } + public static class StoreOp extends MemOp { @Use({REG}) protected AllocatableValue input;