Generate LLVM code for the conditional jumps.
authorRoberto Raggi <roberto.raggi@nokia.com>
Tue, 5 Jun 2012 11:15:03 +0000 (13:15 +0200)
committerRoberto Raggi <roberto.raggi@nokia.com>
Tue, 5 Jun 2012 11:15:03 +0000 (13:15 +0200)
llvm_runtime.cpp
qv4isel_llvm.cpp

index 44670b5..76ae784 100644 (file)
@@ -24,4 +24,9 @@ void __qmljs_llvm_init_string(Context *ctx, Value *result, const char *str)
     __qmljs_init_string(result, __qmljs_string_from_utf8(ctx, str));
 }
 
+bool __qmljs_llvm_to_boolean(Context *ctx, const Value *value)
+{
+    return __qmljs_to_boolean(ctx, value);
+}
+
 } // extern "C"
index 2ac0130..8b72cf8 100644 (file)
@@ -135,14 +135,24 @@ llvm::Value *LLVMInstructionSelection::getLLVMValue(IR::Expr *expr)
 
 llvm::Value *LLVMInstructionSelection::getLLVMCondition(IR::Expr *expr)
 {
-    if (llvm::Value *value = getLLVMValue(expr)) {
-        if (value->getType() == getInt1Ty()) {
-            return value;
+    llvm::Value *value = 0;
+    if (IR::Temp *t = expr->asTemp()) {
+        value = getLLVMTemp(t);
+    } else {
+        value = getLLVMValue(expr);
+        if (! value) {
+            Q_UNIMPLEMENTED();
+            return getInt1(false);
         }
+
+        llvm::Value *tmp = CreateAlloca(_valueTy);
+        CreateStore(value, tmp);
+        value = tmp;
     }
 
-    Q_UNIMPLEMENTED();
-    return getInt1(false);
+    return CreateCall2(_llvmModule->getFunction("__qmljs_llvm_to_boolean"),
+                       _llvmFunction->arg_begin(),
+                       value);
 }
 
 llvm::Value *LLVMInstructionSelection::getLLVMTemp(IR::Temp *temp)