[llvm-commits] [dragonegg] r130497 - /dragonegg/trunk/src/Convert.cpp

Duncan Sands baldrick at free.fr
Fri Apr 29 06:55:12 PDT 2011


Author: baldrick
Date: Fri Apr 29 08:55:11 2011
New Revision: 130497

URL: http://llvm.org/viewvc/llvm-project?rev=130497&view=rev
Log:
Fully support cond_expr: as well as a comparison the condition might be
an ssa name, see is_gimple_condexpr.

Modified:
    dragonegg/trunk/src/Convert.cpp

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=130497&r1=130496&r2=130497&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Fri Apr 29 08:55:11 2011
@@ -2387,11 +2387,17 @@
 }
 
 Value *TreeToLLVM::EmitCOND_EXPR(tree exp) {
-  // Emit the comparison.
+  // Emit the condition.  It may not be in SSA form, but if not then it is a
+  // comparison.
   tree cond = COND_EXPR_COND(exp);
-  assert(COMPARISON_CLASS_P(cond) && "Expected a comparison!");
-  Value *CondVal = EmitCompare(TREE_OPERAND(cond, 0), TREE_OPERAND(cond, 1),
-                               TREE_CODE(cond));
+  Value *CondVal = COMPARISON_CLASS_P(cond) ?
+    EmitCompare(TREE_OPERAND(cond, 0), TREE_OPERAND(cond, 1), TREE_CODE(cond)) :
+    EmitRegister(cond);
+
+  // Ensure the condition has i1 type.
+  if (!CondVal->getType()->isIntegerTy(1))
+    CondVal = Builder.CreateICmpNE(CondVal,
+                                   Constant::getNullValue(CondVal->getType()));
 
   // Emit the true and false values.
   Value *TrueVal = EmitRegister(COND_EXPR_THEN(exp));





More information about the llvm-commits mailing list