Search in sources :

Example 1 with LLVMTypeRef

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;
}
Also used : Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) RegisterValue(jdk.vm.ci.code.RegisterValue) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef) LLVMConstant(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMConstant)

Example 2 with LLVMTypeRef

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);
}
Also used : LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 3 with LLVMTypeRef

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;
}
Also used : LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) InlineAssemblyConstraint(com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)

Example 4 with LLVMTypeRef

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);
}
Also used : LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) InlineAssemblyConstraint(com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)

Example 5 with LLVMTypeRef

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;
    }
}
Also used : LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)

Aggregations

LLVMTypeRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)25 LLVMValueRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)15 InlineAssemblyConstraint (com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint)5 LLVMBasicBlockRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef)4 LLVMKind (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMKind)3 LLVMPendingSpecialRegisterRead (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMPendingSpecialRegisterRead)3 LLVMVariable (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable)3 RegisterValue (jdk.vm.ci.code.RegisterValue)3 Value (jdk.vm.ci.meta.Value)3 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 SpecialRegister (com.oracle.svm.core.graal.llvm.LLVMGenerator.SpecialRegister)2 LLVMIRBuilder (com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder)2 LLVMValueWrapper (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMValueWrapper)2 DebugInfo (jdk.vm.ci.code.DebugInfo)2 PlatformKind (jdk.vm.ci.meta.PlatformKind)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)2 FrameAccess (com.oracle.svm.core.FrameAccess)1 ReservedRegisters (com.oracle.svm.core.ReservedRegisters)1 SubstrateOptions (com.oracle.svm.core.SubstrateOptions)1