use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitStoreConst.
protected void emitStoreConst(AMD64Kind kind, AMD64AddressValue address, ConstantValue value, LIRFrameState state) {
Constant c = value.getConstant();
if (JavaConstant.isNull(c)) {
assert kind == AMD64Kind.DWORD || kind == AMD64Kind.QWORD;
OperandSize size = kind == AMD64Kind.DWORD ? DWORD : QWORD;
getLIRGen().append(new AMD64BinaryConsumer.MemoryConstOp(AMD64MIOp.MOV, size, address, 0, state));
return;
} else if (c instanceof VMConstant) {
// only 32-bit constants can be patched
if (kind == AMD64Kind.DWORD) {
if (getLIRGen().target().inlineObjects || !(c instanceof JavaConstant)) {
// if c is a JavaConstant, it's an oop, otherwise it's a metaspace constant
assert !(c instanceof JavaConstant) || ((JavaConstant) c).getJavaKind() == JavaKind.Object;
getLIRGen().append(new AMD64BinaryConsumer.MemoryVMConstOp(AMD64MIOp.MOV, address, (VMConstant) c, state));
return;
}
}
} else {
JavaConstant jc = (JavaConstant) c;
assert jc.getJavaKind().isPrimitive();
AMD64MIOp op = AMD64MIOp.MOV;
OperandSize size;
long imm;
switch(kind) {
case BYTE:
op = AMD64MIOp.MOVB;
size = BYTE;
imm = jc.asInt();
break;
case WORD:
size = WORD;
imm = jc.asInt();
break;
case DWORD:
size = DWORD;
imm = jc.asInt();
break;
case QWORD:
size = QWORD;
imm = jc.asLong();
break;
case SINGLE:
size = DWORD;
imm = Float.floatToRawIntBits(jc.asFloat());
break;
case DOUBLE:
size = QWORD;
imm = Double.doubleToRawLongBits(jc.asDouble());
break;
default:
throw GraalError.shouldNotReachHere("unexpected kind " + kind);
}
if (NumUtil.isInt(imm)) {
getLIRGen().append(new AMD64BinaryConsumer.MemoryConstOp(op, size, address, (int) imm, state));
return;
}
}
// fallback: load, then store
emitStore(kind, address, getLIRGen().asAllocatable(value), state);
}
use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitBaseOffsetLea.
private Variable emitBaseOffsetLea(LIRKind resultKind, Value base, int offset, OperandSize size) {
Variable result = getLIRGen().newVariable(resultKind);
AMD64AddressValue address = new AMD64AddressValue(resultKind, getLIRGen().asAllocatable(base), offset);
getLIRGen().append(new AMD64Move.LeaOp(result, address, size));
return result;
}
use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitStore.
@Override
public void emitStore(ValueKind<?> lirKind, Value address, Value input, LIRFrameState state) {
AMD64AddressValue storeAddress = getAMD64LIRGen().asAddressValue(address);
AMD64Kind kind = (AMD64Kind) lirKind.getPlatformKind();
if (isConstantValue(input)) {
emitStoreConst(kind, storeAddress, asConstantValue(input), state);
} else {
emitStore(kind, storeAddress, getLIRGen().asAllocatable(input), state);
}
}
use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitLoad.
@Override
public Variable emitLoad(LIRKind kind, Value address, LIRFrameState state) {
AMD64AddressValue loadAddress = getAMD64LIRGen().asAddressValue(address);
Variable result = getLIRGen().newVariable(getLIRGen().toRegisterKind(kind));
switch((AMD64Kind) kind.getPlatformKind()) {
case BYTE:
getLIRGen().append(new AMD64Unary.MemoryOp(MOVSXB, DWORD, result, loadAddress, state));
break;
case WORD:
getLIRGen().append(new AMD64Unary.MemoryOp(MOVSX, DWORD, result, loadAddress, state));
break;
case DWORD:
getLIRGen().append(new AMD64Unary.MemoryOp(MOV, DWORD, result, loadAddress, state));
break;
case QWORD:
getLIRGen().append(new AMD64Unary.MemoryOp(MOV, QWORD, result, loadAddress, state));
break;
case SINGLE:
getLIRGen().append(new AMD64Unary.MemoryOp(MOVSS, SS, result, loadAddress, state));
break;
case DOUBLE:
getLIRGen().append(new AMD64Unary.MemoryOp(MOVSD, SD, result, loadAddress, state));
break;
default:
throw GraalError.shouldNotReachHere();
}
return result;
}
use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitBinaryMemory.
public Value emitBinaryMemory(AMD64RRMOp op, OperandSize size, AllocatableValue a, AMD64AddressValue location, LIRFrameState state) {
Variable result = getLIRGen().newVariable(LIRKind.combine(a));
getLIRGen().append(new AMD64Binary.MemoryThreeOp(op, size, result, a, location, state));
return result;
}
Aggregations