From a4b64edf8e431f6a7b7ca6a9251b5f1f8ce77a74 Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Sun, 22 Sep 2019 00:03:49 +0200
Subject: [PATCH] llvm: Implement LLVMPrinter._print_Conditional

---
 pystencils/llvm/llvm.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/pystencils/llvm/llvm.py b/pystencils/llvm/llvm.py
index 68d95c8b2..edbae21c1 100644
--- a/pystencils/llvm/llvm.py
+++ b/pystencils/llvm/llvm.py
@@ -302,8 +302,16 @@ class LLVMPrinter(Printer):
                 phi.add_incoming(val, block)
             return phi
 
-    # Should have a list of math library functions to validate this.
-    # TODO function calls to libs
+    def _print_Conditional(self, node):
+        cond = self._print(node.condition_expr)
+        with self.builder.if_else(cond) as (then, otherwise):
+            with then:
+                self._print(node.true_block)       # emit instructions for when the predicate is true
+            with otherwise:
+                self._print(node.false_block)       # emit instructions for when the predicate is true
+
+        # No return!
+
     def _print_Function(self, expr):
         name = expr.func.__name__
         e0 = self._print(expr.args[0])
-- 
GitLab