Search in sources :

Example 21 with Value

use of org.robovm.compiler.llvm.Value in project robovm by robovm.

the class TrampolineCompiler method createLdcArray.

private FunctionRef createLdcArray(String targetClass) {
    if (isPrimitiveComponentType(targetClass)) {
        throw new IllegalArgumentException();
    }
    String fnName = Symbols.arrayldcSymbol(targetClass);
    FunctionRef fnRef = new FunctionRef(fnName, new FunctionType(OBJECT_PTR, ENV_PTR));
    if (!mb.hasSymbol(fnName)) {
        Function fn = new FunctionBuilder(fnRef).name(fnName).linkage(weak).build();
        Global g = new Global(Symbols.arrayPtrSymbol(targetClass), weak, new NullConstant(OBJECT_PTR));
        if (!mb.hasSymbol(g.getName())) {
            mb.addGlobal(g);
        }
        FunctionRef ldcArrayClassFn = BC_LDC_ARRAY_BOOT_CLASS;
        if (!isPrimitiveBaseType(targetClass)) {
            Clazz baseType = config.getClazzes().load(getBaseType(targetClass));
            if (!baseType.isInBootClasspath()) {
                ldcArrayClassFn = BC_LDC_ARRAY_CLASS;
            }
        }
        Value arrayClass = call(fn, ldcArrayClassFn, fn.getParameterRef(0), g.ref(), mb.getString(targetClass));
        fn.add(new Ret(arrayClass));
        mb.addFunction(fn);
    }
    return fnRef;
}
Also used : Ret(org.robovm.compiler.llvm.Ret) Function(org.robovm.compiler.llvm.Function) FunctionType(org.robovm.compiler.llvm.FunctionType) Value(org.robovm.compiler.llvm.Value) NullConstant(org.robovm.compiler.llvm.NullConstant) Clazz(org.robovm.compiler.clazz.Clazz) Global(org.robovm.compiler.llvm.Global) FunctionRef(org.robovm.compiler.llvm.FunctionRef)

Example 22 with Value

use of org.robovm.compiler.llvm.Value in project robovm by robovm.

the class TrampolineCompiler method createCheckcastArray.

private FunctionRef createCheckcastArray(Checkcast t) {
    String fnName = Symbols.arraycheckcastSymbol(t.getTarget());
    if (!mb.hasSymbol(fnName)) {
        Function fn = new FunctionBuilder(t).name(fnName).linkage(weak).build();
        Value arrayClass = callLdcArray(fn, t.getTarget());
        Value result = call(fn, BC_CHECKCAST_ARRAY, fn.getParameterRef(0), arrayClass, fn.getParameterRef(1));
        fn.add(new Ret(result));
        mb.addFunction(fn);
    }
    return new FunctionRef(fnName, t.getFunctionType());
}
Also used : Ret(org.robovm.compiler.llvm.Ret) Function(org.robovm.compiler.llvm.Function) Value(org.robovm.compiler.llvm.Value) FunctionRef(org.robovm.compiler.llvm.FunctionRef)

Example 23 with Value

use of org.robovm.compiler.llvm.Value in project robovm by robovm.

the class BroMethodCompiler method marshalValueObjectToNative.

protected Value marshalValueObjectToNative(Function fn, MarshalerMethod marshalerMethod, Type nativeType, Value env, Value object, long flags) {
    Invokestatic invokestatic = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
    trampolines.add(invokestatic);
    Value result = call(fn, invokestatic.getFunctionRef(), env, object, new IntegerConstant(flags));
    return marshalPrimitiveToNative(fn, marshalerMethod.getMethod(), result);
}
Also used : Invokestatic(org.robovm.compiler.trampoline.Invokestatic) Value(org.robovm.compiler.llvm.Value) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Example 24 with Value

use of org.robovm.compiler.llvm.Value in project robovm by robovm.

the class BroMethodCompiler method marshalNativeToValueObject.

protected Value marshalNativeToValueObject(Function fn, MarshalerMethod marshalerMethod, Value env, String valueClassName, Value nativeValue, long flags) {
    Invokestatic invokeToObject = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
    trampolines.add(invokeToObject);
    Value valueClass = ldcClass(fn, valueClassName, env);
    nativeValue = marshalNativeToPrimitive(fn, marshalerMethod.getMethod(), 1, nativeValue);
    return call(fn, invokeToObject.getFunctionRef(), env, valueClass, nativeValue, new IntegerConstant(flags));
}
Also used : Invokestatic(org.robovm.compiler.trampoline.Invokestatic) Value(org.robovm.compiler.llvm.Value) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Example 25 with Value

use of org.robovm.compiler.llvm.Value in project robovm by robovm.

the class BroMethodCompiler method marshalNativeToArray.

protected Value marshalNativeToArray(Function fn, MarshalerMethod marshalerMethod, Value env, String arrayClassName, Value nativeValue, long flags, int[] dimensions) {
    Invokestatic invokeToObject = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
    trampolines.add(invokeToObject);
    Variable handle = fn.newVariable(I64);
    fn.add(new Ptrtoint(handle, nativeValue, I64));
    Value valueClass = ldcClass(fn, arrayClassName, env);
    List<Value> args = new ArrayList<>();
    args.add(env);
    args.add(valueClass);
    args.add(handle.ref());
    args.add(new IntegerConstant(flags));
    args.addAll(arrayDimensionsValues(dimensions));
    return call(fn, invokeToObject.getFunctionRef(), args);
}
Also used : Invokestatic(org.robovm.compiler.trampoline.Invokestatic) Variable(org.robovm.compiler.llvm.Variable) Ptrtoint(org.robovm.compiler.llvm.Ptrtoint) Value(org.robovm.compiler.llvm.Value) ArrayList(java.util.ArrayList) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Aggregations

Value (org.robovm.compiler.llvm.Value)48 Ret (org.robovm.compiler.llvm.Ret)26 IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)24 Function (org.robovm.compiler.llvm.Function)22 Variable (org.robovm.compiler.llvm.Variable)18 FunctionRef (org.robovm.compiler.llvm.FunctionRef)16 Label (org.robovm.compiler.llvm.Label)10 Load (org.robovm.compiler.llvm.Load)10 ArrayList (java.util.ArrayList)9 PointerType (org.robovm.compiler.llvm.PointerType)9 Bitcast (org.robovm.compiler.llvm.Bitcast)8 FunctionType (org.robovm.compiler.llvm.FunctionType)8 NullConstant (org.robovm.compiler.llvm.NullConstant)8 ConstantBitcast (org.robovm.compiler.llvm.ConstantBitcast)7 StructureType (org.robovm.compiler.llvm.StructureType)7 Type (org.robovm.compiler.llvm.Type)7 VariableRef (org.robovm.compiler.llvm.VariableRef)7 Invokestatic (org.robovm.compiler.trampoline.Invokestatic)7 BasicBlockRef (org.robovm.compiler.llvm.BasicBlockRef)6 Br (org.robovm.compiler.llvm.Br)6