Search in sources :

Example 36 with Value

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

the class MethodCompiler method enterMonitor.

private void enterMonitor(EnterMonitorStmt stmt) {
    Value op = immediate(stmt, (Immediate) stmt.getOp());
    checkNull(stmt, op);
    call(stmt, MONITORENTER, env, op);
}
Also used : Value(org.robovm.compiler.llvm.Value)

Example 37 with Value

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

the class MethodCompiler method if_.

private void if_(IfStmt stmt) {
    ConditionExpr condition = (ConditionExpr) stmt.getCondition();
    Value op1 = immediate(stmt, (Immediate) condition.getOp1());
    Value op2 = immediate(stmt, (Immediate) condition.getOp2());
    Icmp.Condition c = null;
    if (condition instanceof EqExpr) {
        c = Icmp.Condition.eq;
    } else if (condition instanceof NeExpr) {
        c = Icmp.Condition.ne;
    } else if (condition instanceof GtExpr) {
        c = Icmp.Condition.sgt;
    } else if (condition instanceof LtExpr) {
        c = Icmp.Condition.slt;
    } else if (condition instanceof GeExpr) {
        c = Icmp.Condition.sge;
    } else if (condition instanceof LeExpr) {
        c = Icmp.Condition.sle;
    }
    Variable result = function.newVariable(Type.I1);
    function.add(new Icmp(result, c, op1, op2)).attach(stmt);
    Unit nextUnit = sootMethod.getActiveBody().getUnits().getSuccOf(stmt);
    function.add(new Br(new VariableRef(result), function.newBasicBlockRef(new Label(stmt.getTarget())), function.newBasicBlockRef(new Label(nextUnit)))).attach(stmt);
}
Also used : VariableRef(org.robovm.compiler.llvm.VariableRef) Condition(org.robovm.compiler.llvm.Icmp.Condition) Variable(org.robovm.compiler.llvm.Variable) NeExpr(soot.jimple.NeExpr) Label(org.robovm.compiler.llvm.Label) GtExpr(soot.jimple.GtExpr) LtExpr(soot.jimple.LtExpr) GeExpr(soot.jimple.GeExpr) Unit(soot.Unit) LeExpr(soot.jimple.LeExpr) Br(org.robovm.compiler.llvm.Br) EqExpr(soot.jimple.EqExpr) ConditionExpr(soot.jimple.ConditionExpr) Value(org.robovm.compiler.llvm.Value) Icmp(org.robovm.compiler.llvm.Icmp)

Example 38 with Value

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

the class MethodCompiler method throw_.

private void throw_(ThrowStmt stmt) {
    Value obj = immediate(stmt, (Immediate) stmt.getOp());
    checkNull(stmt, obj);
    call(stmt, BC_THROW, env, obj);
    function.add(new Unreachable()).attach(stmt);
}
Also used : Unreachable(org.robovm.compiler.llvm.Unreachable) Value(org.robovm.compiler.llvm.Value)

Example 39 with Value

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

the class MethodCompiler method initializeClassFields.

private void initializeClassFields() {
    for (SootField field : sootMethod.getDeclaringClass().getFields()) {
        if (!field.isStatic()) {
            continue;
        }
        for (Tag tag : field.getTags()) {
            Value value = null;
            if (tag instanceof DoubleConstantValueTag) {
                DoubleConstantValueTag dtag = (DoubleConstantValueTag) tag;
                value = new FloatingPointConstant(dtag.getDoubleValue());
            } else if (tag instanceof FloatConstantValueTag) {
                FloatConstantValueTag ftag = (FloatConstantValueTag) tag;
                value = new FloatingPointConstant(ftag.getFloatValue());
            } else if (tag instanceof IntegerConstantValueTag) {
                IntegerConstantValueTag itag = (IntegerConstantValueTag) tag;
                value = new IntegerConstant(itag.getIntValue());
                IntegerType type = (IntegerType) getType(field.getType());
                if (type.getBits() < 32) {
                    value = new ConstantTrunc((Constant) value, type);
                }
            } else if (tag instanceof LongConstantValueTag) {
                LongConstantValueTag ltag = (LongConstantValueTag) tag;
                value = new IntegerConstant(ltag.getLongValue());
            } else if (tag instanceof StringConstantValueTag) {
                String s = ((StringConstantValueTag) tag).getStringValue();
                value = call(ldcString(s), env);
            }
            if (value != null) {
                FunctionRef fn = FunctionBuilder.setter(field).ref();
                call(fn, env, value);
            }
        }
    }
}
Also used : FloatingPointConstant(org.robovm.compiler.llvm.FloatingPointConstant) FloatingPointConstant(org.robovm.compiler.llvm.FloatingPointConstant) Constant(org.robovm.compiler.llvm.Constant) NullConstant(org.robovm.compiler.llvm.NullConstant) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant) IntegerConstantValueTag(soot.tagkit.IntegerConstantValueTag) DoubleConstantValueTag(soot.tagkit.DoubleConstantValueTag) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant) IntegerType(org.robovm.compiler.llvm.IntegerType) ConstantTrunc(org.robovm.compiler.llvm.ConstantTrunc) Value(org.robovm.compiler.llvm.Value) LongConstantValueTag(soot.tagkit.LongConstantValueTag) SootField(soot.SootField) ArrayCheckTag(soot.jimple.toolkits.annotation.tags.ArrayCheckTag) NullCheckTag(soot.jimple.toolkits.annotation.tags.NullCheckTag) FloatConstantValueTag(soot.tagkit.FloatConstantValueTag) IntegerConstantValueTag(soot.tagkit.IntegerConstantValueTag) Tag(soot.tagkit.Tag) DoubleConstantValueTag(soot.tagkit.DoubleConstantValueTag) LongConstantValueTag(soot.tagkit.LongConstantValueTag) StringConstantValueTag(soot.tagkit.StringConstantValueTag) StringConstantValueTag(soot.tagkit.StringConstantValueTag) FloatConstantValueTag(soot.tagkit.FloatConstantValueTag) FunctionRef(org.robovm.compiler.llvm.FunctionRef)

Example 40 with Value

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

the class Linker method createCheckcast.

private Function createCheckcast(ModuleBuilder mb, Clazz clazz, TypeInfo typeInfo) {
    Function fn = FunctionBuilder.checkcast(clazz);
    Value info = getInfoStruct(mb, fn, clazz);
    if (typeInfo.error) {
        // This will trigger an exception
        call(fn, BC_LDC_CLASS, fn.getParameterRef(0), info);
        fn.add(new Ret(new NullConstant(Types.OBJECT_PTR)));
    } else if (!clazz.getClazzInfo().isInterface()) {
        Value result = call(fn, CHECKCAST_CLASS, fn.getParameterRef(0), info, fn.getParameterRef(1), new IntegerConstant((typeInfo.classTypes.length - 1) * 4 + 5 * 4), new IntegerConstant(typeInfo.id));
        fn.add(new Ret(result));
    } else {
        Value result = call(fn, CHECKCAST_INTERFACE, fn.getParameterRef(0), info, fn.getParameterRef(1), new IntegerConstant(typeInfo.id));
        fn.add(new Ret(result));
    }
    return fn;
}
Also used : Ret(org.robovm.compiler.llvm.Ret) ModifiedUtf8HashFunction(org.robovm.compiler.hash.ModifiedUtf8HashFunction) Function(org.robovm.compiler.llvm.Function) Value(org.robovm.compiler.llvm.Value) NullConstant(org.robovm.compiler.llvm.NullConstant) 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