use of org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MIOp 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);
}
Aggregations