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);
}
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);
}
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);
}
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);
}
}
}
}
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;
}
Aggregations