Search in sources :

Example 11 with Function

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

the class ClassCompiler method createAllocator.

private Function createAllocator() {
    Function fn = FunctionBuilder.allocator(sootClass);
    Value info = getInfoStruct(fn, sootClass);
    Value result = call(fn, BC_ALLOCATE, fn.getParameterRef(0), info);
    fn.add(new Ret(result));
    return fn;
}
Also used : Ret(org.robovm.compiler.llvm.Ret) Function(org.robovm.compiler.llvm.Function) Value(org.robovm.compiler.llvm.Value)

Example 12 with Function

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

the class TrampolineCompiler method createAnewarray.

private FunctionRef createAnewarray(Anewarray t) {
    String fnName = Symbols.anewarraySymbol(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_NEW_OBJECT_ARRAY, fn.getParameterRef(0), fn.getParameterRef(1), arrayClass);
        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 13 with Function

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

the class TrampolineCompiler method createInstanceofArray.

private FunctionRef createInstanceofArray(Instanceof t) {
    String fnName = Symbols.arrayinstanceofSymbol(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_INSTANCEOF_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 14 with Function

use of org.robovm.compiler.llvm.Function 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 15 with Function

use of org.robovm.compiler.llvm.Function 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)

Aggregations

Function (org.robovm.compiler.llvm.Function)29 Ret (org.robovm.compiler.llvm.Ret)24 Value (org.robovm.compiler.llvm.Value)22 FunctionRef (org.robovm.compiler.llvm.FunctionRef)16 IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)9 FunctionType (org.robovm.compiler.llvm.FunctionType)7 Global (org.robovm.compiler.llvm.Global)7 NullConstant (org.robovm.compiler.llvm.NullConstant)7 ArrayList (java.util.ArrayList)6 ConstantBitcast (org.robovm.compiler.llvm.ConstantBitcast)6 Label (org.robovm.compiler.llvm.Label)6 PointerType (org.robovm.compiler.llvm.PointerType)6 StructureType (org.robovm.compiler.llvm.StructureType)6 Unreachable (org.robovm.compiler.llvm.Unreachable)6 Variable (org.robovm.compiler.llvm.Variable)6 Bitcast (org.robovm.compiler.llvm.Bitcast)5 FunctionDeclaration (org.robovm.compiler.llvm.FunctionDeclaration)5 Load (org.robovm.compiler.llvm.Load)5 Type (org.robovm.compiler.llvm.Type)5 ModifiedUtf8HashFunction (org.robovm.compiler.hash.ModifiedUtf8HashFunction)4