use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef in project graal by oracle.
the class LLVMGenerator method emitConstant.
/* Constants */
@Override
public Value emitConstant(LIRKind kind, Constant constant) {
boolean uncompressedObject = isUncompressedObjectKind(kind);
LLVMTypeRef actualType = uncompressedObject ? builder.objectType(true) : ((LLVMKind) kind.getPlatformKind()).get();
LLVMValueRef value = emitLLVMConstant(actualType, (JavaConstant) constant);
Value val = new LLVMConstant(value, constant);
return uncompressedObject ? emitUncompress(val, ReferenceAccess.singleton().getCompressEncoding(), false) : val;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef in project graal by oracle.
the class LLVMGenerator method getLLVMFunctionReturnType.
LLVMTypeRef getLLVMFunctionReturnType(ResolvedJavaMethod method, boolean forMainFunction) {
ResolvedJavaType returnType = method.getSignature().getReturnType(null).resolve(null);
LLVMTypeRef llvmReturnType = getLLVMStackType(getTypeKind(returnType, forMainFunction));
if (forMainFunction && isEntryPoint) {
return llvmReturnType;
}
boolean voidReturnType = LLVMIRBuilder.isVoidType(llvmReturnType);
LLVMTypeRef[] returnTypes = new LLVMTypeRef[SpecialRegister.count() + (voidReturnType ? 0 : 1)];
for (SpecialRegister reg : SpecialRegister.registers()) {
returnTypes[reg.index] = builder.wordType();
}
if (!voidReturnType) {
returnTypes[SpecialRegister.count()] = llvmReturnType;
}
return builder.structType(returnTypes);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef in project graal by oracle.
the class LLVMGenerator method buildInlineGetRegister.
private LLVMValueRef buildInlineGetRegister(String registerName) {
LLVMTypeRef inlineAsmType = builder.functionType(builder.rawPointerType());
String asmSnippet = LLVMTargetSpecific.get().getRegisterInlineAsm(registerName);
InlineAssemblyConstraint outputConstraint = new InlineAssemblyConstraint(Type.Output, Location.namedRegister(LLVMTargetSpecific.get().getLLVMRegisterName(registerName)));
LLVMValueRef getRegister = builder.buildInlineAsm(inlineAsmType, asmSnippet, false, false, outputConstraint);
LLVMValueRef call = builder.buildCall(getRegister);
builder.setCallSiteAttribute(call, Attribute.GCLeafFunction);
return call;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef in project graal by oracle.
the class LLVMGenerator method buildInlineJump.
/* Inline assembly */
private void buildInlineJump(LLVMValueRef address) {
LLVMTypeRef inlineAsmType = builder.functionType(builder.voidType(), builder.rawPointerType());
String asmSnippet = LLVMTargetSpecific.get().getJumpInlineAsm();
InlineAssemblyConstraint inputConstraint = new InlineAssemblyConstraint(Type.Input, Location.register());
LLVMValueRef jump = builder.buildInlineAsm(inlineAsmType, asmSnippet, true, false, inputConstraint);
LLVMValueRef call = builder.buildCall(jump, address);
builder.setCallSiteAttribute(call, Attribute.GCLeafFunction);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef in project graal by oracle.
the class LLVMGenerator method buildCmpxchg.
private LLVMValueRef buildCmpxchg(LLVMValueRef address, LLVMValueRef expectedValue, LLVMValueRef newValue, MemoryOrderMode memoryOrder, boolean returnValue) {
LLVMTypeRef expectedType = LLVMIRBuilder.typeOf(expectedValue);
LLVMTypeRef newType = LLVMIRBuilder.typeOf(newValue);
assert LLVMIRBuilder.compatibleTypes(expectedType, newType) : dumpValues("invalid cmpxchg arguments", expectedValue, newValue);
boolean trackedAddress = LLVMIRBuilder.isObjectType(typeOf(address));
LLVMValueRef castedAddress;
if (!trackedAddress && LLVMIRBuilder.isObjectType(expectedType)) {
castedAddress = builder.buildAddrSpaceCast(address, builder.pointerType(expectedType, true, false));
} else {
castedAddress = builder.buildBitcast(address, builder.pointerType(expectedType, trackedAddress, false));
}
boolean convertResult = LLVMIRBuilder.isFloatType(expectedType) || LLVMIRBuilder.isDoubleType(expectedType);
LLVMValueRef castedExpectedValue = expectedValue;
LLVMValueRef castedNewValue = newValue;
if (convertResult) {
LLVMTypeRef cmpxchgType = LLVMIRBuilder.isFloatType(expectedType) ? builder.intType() : builder.longType();
castedExpectedValue = builder.buildFPToSI(expectedValue, cmpxchgType);
castedNewValue = builder.buildFPToSI(newValue, cmpxchgType);
}
LLVMValueRef result = builder.buildCmpxchg(castedAddress, castedExpectedValue, castedNewValue, memoryOrder, returnValue);
if (returnValue && convertResult) {
return builder.buildSIToFP(result, expectedType);
} else {
return result;
}
}
Aggregations