use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class AMD64HotSpotForeignCallsProvider method initialize.
@Override
public void initialize(HotSpotProviders providers, OptionValues options) {
GraalHotSpotVMConfig config = runtime.getVMConfig();
TargetDescription target = providers.getCodeCache().getTarget();
PlatformKind word = target.arch.getWordKind();
// The calling convention for the exception handler stub is (only?) defined in
// TemplateInterpreterGenerator::generate_throw_exception()
// in templateInterpreter_x86_64.cpp around line 1923
RegisterValue exception = rax.asValue(LIRKind.reference(word));
RegisterValue exceptionPc = rdx.asValue(LIRKind.value(word));
CallingConvention exceptionCc = new CallingConvention(0, ILLEGAL, exception, exceptionPc);
register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, exceptionCc, null, NOT_REEXECUTABLE, any()));
register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, exceptionCc, null, NOT_REEXECUTABLE, any()));
link(new AMD64MathStub(ARITHMETIC_LOG_STUB, options, providers, registerStubCall(ARITHMETIC_LOG_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
link(new AMD64MathStub(ARITHMETIC_LOG10_STUB, options, providers, registerStubCall(ARITHMETIC_LOG10_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
link(new AMD64MathStub(ARITHMETIC_SIN_STUB, options, providers, registerStubCall(ARITHMETIC_SIN_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
link(new AMD64MathStub(ARITHMETIC_COS_STUB, options, providers, registerStubCall(ARITHMETIC_COS_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
link(new AMD64MathStub(ARITHMETIC_TAN_STUB, options, providers, registerStubCall(ARITHMETIC_TAN_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
link(new AMD64MathStub(ARITHMETIC_EXP_STUB, options, providers, registerStubCall(ARITHMETIC_EXP_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
link(new AMD64MathStub(ARITHMETIC_POW_STUB, options, providers, registerStubCall(ARITHMETIC_POW_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
if (config.useCRC32Intrinsics) {
// This stub does callee saving
registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
}
if (config.useCRC32CIntrinsics) {
registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
}
super.initialize(providers, options);
}
use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class AArch64HotSpotForeignCallsProvider method initialize.
@Override
public void initialize(HotSpotProviders providers, OptionValues options) {
GraalHotSpotVMConfig config = runtime.getVMConfig();
TargetDescription target = providers.getCodeCache().getTarget();
PlatformKind word = target.arch.getWordKind();
// The calling convention for the exception handler stub is (only?) defined in
// TemplateInterpreterGenerator::generate_throw_exception()
RegisterValue exception = r0.asValue(LIRKind.reference(word));
RegisterValue exceptionPc = r3.asValue(LIRKind.value(word));
CallingConvention exceptionCc = new CallingConvention(0, ILLEGAL, exception, exceptionPc);
register(new HotSpotForeignCallLinkageImpl(HotSpotBackend.EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF, exceptionCc, null, NOT_REEXECUTABLE, any()));
register(new HotSpotForeignCallLinkageImpl(HotSpotBackend.EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF, exceptionCc, null, NOT_REEXECUTABLE, any()));
// These stubs do callee saving
if (config.useCRC32Intrinsics) {
registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, any());
}
if (config.useCRC32CIntrinsics) {
registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, any());
}
super.initialize(providers, options);
}
use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class AMD64HotSpotFrameOmissionTest method testHelper.
private void testHelper(String name, CodeGenerator gen) {
ResolvedJavaMethod javaMethod = getResolvedJavaMethod(name);
InstalledCode installedCode = getCode(javaMethod);
TargetDescription target = getCodeCache().getTarget();
AMD64Assembler asm = new AMD64Assembler(target);
gen.generateCode(asm);
byte[] expectedCode = asm.close(true);
// Only compare up to expectedCode.length bytes to ignore
// padding instructions adding during code installation
byte[] actualCode = Arrays.copyOf(installedCode.getCode(), expectedCode.length);
Assert.assertArrayEquals(expectedCode, actualCode);
}
use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitNegate.
@Override
public Variable emitNegate(Value inputVal) {
AllocatableValue input = getLIRGen().asAllocatable(inputVal);
Variable result = getLIRGen().newVariable(LIRKind.combine(input));
TargetDescription target = getLIRGen().target();
boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
switch((AMD64Kind) input.getPlatformKind()) {
case DWORD:
getLIRGen().append(new AMD64Unary.MOp(NEG, DWORD, result, input));
break;
case QWORD:
getLIRGen().append(new AMD64Unary.MOp(NEG, QWORD, result, input));
break;
case SINGLE:
if (isAvx) {
getLIRGen().append(new AMD64Binary.DataThreeOp(AVXOp.XOR, PS, result, input, JavaConstant.forFloat(Float.intBitsToFloat(0x80000000)), 16));
} else {
getLIRGen().append(new AMD64Binary.DataTwoOp(SSEOp.XOR, PS, result, input, JavaConstant.forFloat(Float.intBitsToFloat(0x80000000)), 16));
}
break;
case DOUBLE:
if (isAvx) {
getLIRGen().append(new AMD64Binary.DataThreeOp(AVXOp.XOR, PD, result, input, JavaConstant.forDouble(Double.longBitsToDouble(0x8000000000000000L)), 16));
} else {
getLIRGen().append(new AMD64Binary.DataTwoOp(SSEOp.XOR, PD, result, input, JavaConstant.forDouble(Double.longBitsToDouble(0x8000000000000000L)), 16));
}
break;
default:
throw GraalError.shouldNotReachHere(input.getPlatformKind().toString());
}
return result;
}
use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitAdd.
@Override
public Variable emitAdd(LIRKind resultKind, Value a, Value b, boolean setFlags) {
TargetDescription target = getLIRGen().target();
boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
switch((AMD64Kind) a.getPlatformKind()) {
case DWORD:
if (isJavaConstant(b) && !setFlags) {
long displacement = asJavaConstant(b).asLong();
if (NumUtil.isInt(displacement) && displacement != 1 && displacement != -1) {
return emitBaseOffsetLea(resultKind, a, (int) displacement, OperandSize.DWORD);
}
}
return emitBinary(resultKind, ADD, DWORD, true, a, b, setFlags);
case QWORD:
if (isJavaConstant(b) && !setFlags) {
long displacement = asJavaConstant(b).asLong();
if (NumUtil.isInt(displacement) && displacement != 1 && displacement != -1) {
return emitBaseOffsetLea(resultKind, a, (int) displacement, OperandSize.QWORD);
}
}
return emitBinary(resultKind, ADD, QWORD, true, a, b, setFlags);
case SINGLE:
if (isAvx) {
return emitBinary(resultKind, AVXOp.ADD, SS, true, a, b);
} else {
return emitBinary(resultKind, SSEOp.ADD, SS, true, a, b);
}
case DOUBLE:
if (isAvx) {
return emitBinary(resultKind, AVXOp.ADD, SD, true, a, b);
} else {
return emitBinary(resultKind, SSEOp.ADD, SD, true, a, b);
}
default:
throw GraalError.shouldNotReachHere();
}
}
Aggregations