<div dir="ltr">On Thu, Jun 12, 2014 at 12:08 AM, Janne Grunau <span dir="ltr"><<a href="mailto:j@jannau.net" target="_blank">j@jannau.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
llvm_unreachable added<br></blockquote><div><br></div><div>Thanks; committed as SVN r211218.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 lib/MC/MCParser/AsmParser.cpp       | 49 +++++++++++++++++++++++++-----<br>
<div class=""> test/MC/AsmParser/conditional_asm.s | 60 +++++++++++++++++++++++++++++++++++++<br>
 test/MC/AsmParser/if-diagnostics.s  | 29 ++++++++++++++++++<br>
</div> 3 files changed, 130 insertions(+), 8 deletions(-)<br>
<div class=""> create mode 100644 test/MC/AsmParser/if-diagnostics.s<br>
<br>
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp<br>
</div>index cbff7be..932d0f3 100644<br>
<div><div class="h5">--- a/lib/MC/MCParser/AsmParser.cpp<br>
+++ b/lib/MC/MCParser/AsmParser.cpp<br>
@@ -345,8 +345,9 @@ private:<br>
     DK_REFERENCE, DK_WEAK_DEFINITION, DK_WEAK_REFERENCE,<br>
     DK_WEAK_DEF_CAN_BE_HIDDEN, DK_COMM, DK_COMMON, DK_LCOMM, DK_ABORT,<br>
     DK_INCLUDE, DK_INCBIN, DK_CODE16, DK_CODE16GCC, DK_REPT, DK_IRP, DK_IRPC,<br>
-    DK_IF, DK_IFNE, DK_IFB, DK_IFNB, DK_IFC, DK_IFEQS, DK_IFNC, DK_IFDEF,<br>
-    DK_IFNDEF, DK_IFNOTDEF, DK_ELSEIF, DK_ELSE, DK_ENDIF,<br>
+    DK_IF, DK_IFEQ, DK_IFGE, DK_IFGT, DK_IFLE, DK_IFLT, DK_IFNE, DK_IFB,<br>
+    DK_IFNB, DK_IFC, DK_IFEQS, DK_IFNC, DK_IFDEF, DK_IFNDEF, DK_IFNOTDEF,<br>
+    DK_ELSEIF, DK_ELSE, DK_ENDIF,<br>
     DK_SPACE, DK_SKIP, DK_FILE, DK_LINE, DK_LOC, DK_STABS,<br>
     DK_CFI_SECTIONS, DK_CFI_STARTPROC, DK_CFI_ENDPROC, DK_CFI_DEF_CFA,<br>
     DK_CFI_DEF_CFA_OFFSET, DK_CFI_ADJUST_CFA_OFFSET, DK_CFI_DEF_CFA_REGISTER,<br>
@@ -433,8 +434,8 @@ private:<br>
   bool parseDirectiveInclude(); // ".include"<br>
   bool parseDirectiveIncbin(); // ".incbin"<br>
<br>
-  // ".if" or ".ifne"<br>
-  bool parseDirectiveIf(SMLoc DirectiveLoc);<br>
+  // ".if", ".ifeq", ".ifge", ".ifgt" , ".ifle", ".iflt" or ".ifne"<br>
+  bool parseDirectiveIf(SMLoc DirectiveLoc, DirectiveKind DirKind);<br>
   // ".ifb" or ".ifnb", depending on ExpectBlank.<br>
   bool parseDirectiveIfb(SMLoc DirectiveLoc, bool ExpectBlank);<br>
   // ".ifc" or ".ifnc", depending on ExpectEqual.<br>
@@ -1229,8 +1230,13 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info) {<br>
   default:<br>
     break;<br>
   case DK_IF:<br>
+  case DK_IFEQ:<br>
+  case DK_IFGE:<br>
+  case DK_IFGT:<br>
+  case DK_IFLE:<br>
+  case DK_IFLT:<br>
   case DK_IFNE:<br>
-    return parseDirectiveIf(IDLoc);<br>
+    return parseDirectiveIf(IDLoc, DirKind);<br>
   case DK_IFB:<br>
     return parseDirectiveIfb(IDLoc, true);<br>
   case DK_IFNB:<br>
@@ -3792,9 +3798,8 @@ bool AsmParser::parseDirectiveIncbin() {<br>
 }<br>
<br>
 /// parseDirectiveIf<br>
-/// ::= .if expression<br>
-/// ::= .ifne expression<br>
-bool AsmParser::parseDirectiveIf(SMLoc DirectiveLoc) {<br>
+/// ::= .if{,eq,ge,gt,le,lt,ne} expression<br>
+bool AsmParser::parseDirectiveIf(SMLoc DirectiveLoc, DirectiveKind DirKind) {<br>
   TheCondStack.push_back(TheCondState);<br>
   TheCondState.TheCond = AsmCond::IfCond;<br>
   if (TheCondState.Ignore) {<br>
</div></div>@@ -3809,6 +3814,29 @@ bool AsmParser::parseDirectiveIf(SMLoc DirectiveLoc) {<br>
<div class=""><br>
     Lex();<br>
<br>
+    switch (DirKind) {<br>
+    default:<br>
</div><div class="">+      llvm_unreachable("unsupported directive");<br>
</div>+    case DK_IF:<br>
+    case DK_IFNE:<br>
+      break;<br>
<div class="">+    case DK_IFEQ:<br>
+      ExprValue = ExprValue == 0;<br>
+      break;<br>
+    case DK_IFGE:<br>
+      ExprValue = ExprValue >= 0;<br>
+      break;<br>
+    case DK_IFGT:<br>
+      ExprValue = ExprValue > 0;<br>
+      break;<br>
+    case DK_IFLE:<br>
+      ExprValue = ExprValue <= 0;<br>
+      break;<br>
+    case DK_IFLT:<br>
+      ExprValue = ExprValue < 0;<br>
+      break;<br>
+    }<br>
+<br>
     TheCondState.CondMet = ExprValue;<br>
     TheCondState.Ignore = !TheCondState.CondMet;<br>
   }<br>
</div>@@ -4111,6 +4139,11 @@ void AsmParser::initializeDirectiveKindMap() {<br>
<div class="HOEnZb"><div class="h5">   DirectiveKindMap[".bundle_lock"] = DK_BUNDLE_LOCK;<br>
   DirectiveKindMap[".bundle_unlock"] = DK_BUNDLE_UNLOCK;<br>
   DirectiveKindMap[".if"] = DK_IF;<br>
+  DirectiveKindMap[".ifeq"] = DK_IFEQ;<br>
+  DirectiveKindMap[".ifge"] = DK_IFGE;<br>
+  DirectiveKindMap[".ifgt"] = DK_IFGT;<br>
+  DirectiveKindMap[".ifle"] = DK_IFLE;<br>
+  DirectiveKindMap[".iflt"] = DK_IFLT;<br>
   DirectiveKindMap[".ifne"] = DK_IFNE;<br>
   DirectiveKindMap[".ifb"] = DK_IFB;<br>
   DirectiveKindMap[".ifnb"] = DK_IFNB;<br>
diff --git a/test/MC/AsmParser/conditional_asm.s b/test/MC/AsmParser/conditional_asm.s<br>
index b9bee33..ecbceb1 100644<br>
--- a/test/MC/AsmParser/conditional_asm.s<br>
+++ b/test/MC/AsmParser/conditional_asm.s<br>
@@ -11,6 +11,66 @@<br>
     .endif<br>
 .endif<br>
<br>
+# CHECK: .byte 0<br>
+# CHECK-NOT: .byte 1<br>
+.ifeq 32 - 32<br>
+        .byte 0<br>
+.else<br>
+        .byte 1<br>
+.endif<br>
+<br>
+# CHECK: .byte 0<br>
+# CHECK: .byte 1<br>
+# CHECK-NOT: .byte 2<br>
+.ifge 32 - 31<br>
+        .byte 0<br>
+.endif<br>
+.ifge 32 - 32<br>
+        .byte 1<br>
+.endif<br>
+.ifge 32 - 33<br>
+        .byte 2<br>
+.endif<br>
+<br>
+# CHECK: .byte 0<br>
+# CHECK-NOT: .byte 1<br>
+# CHECK-NOT: .byte 2<br>
+.ifgt 32 - 31<br>
+        .byte 0<br>
+.endif<br>
+.ifgt 32 - 32<br>
+        .byte 1<br>
+.endif<br>
+.ifgt 32 - 33<br>
+        .byte 2<br>
+.endif<br>
+<br>
+# CHECK-NOT: .byte 0<br>
+# CHECK: .byte 1<br>
+# CHECK: .byte 2<br>
+.ifle 32 - 31<br>
+        .byte 0<br>
+.endif<br>
+.ifle 32 - 32<br>
+        .byte 1<br>
+.endif<br>
+.ifle 32 - 33<br>
+        .byte 2<br>
+.endif<br>
+<br>
+# CHECK-NOT: .byte 0<br>
+# CHECK-NOT: .byte 1<br>
+# CHECK: .byte 2<br>
+.iflt 32 - 31<br>
+        .byte 0<br>
+.endif<br>
+.iflt 32 - 32<br>
+        .byte 1<br>
+.endif<br>
+.iflt 32 - 33<br>
+        .byte 2<br>
+.endif<br>
+<br>
 # CHECK: .byte 1<br>
 # CHECK-NOT: .byte 0<br>
 .ifne 32 - 32<br>
diff --git a/test/MC/AsmParser/if-diagnostics.s b/test/MC/AsmParser/if-diagnostics.s<br>
new file mode 100644<br>
index 0000000..d102a56<br>
--- /dev/null<br>
+++ b/test/MC/AsmParser/if-diagnostics.s<br>
@@ -0,0 +1,29 @@<br>
+// RUN: not llvm-mc -triple i386 %s -o /dev/null 2>&1 | FileCheck %s<br>
+<br>
+.if<br>
+.endif<br>
+<br>
+// CHECK: error: unknown token in expression<br>
+// CHECK: .if<br>
+// CHECK:   ^<br>
+<br>
+.ifeq 0, 3<br>
+.endif<br>
+<br>
+// CHECK:error: unexpected token in '.if' directive<br>
+// CHECK: .ifeq 0, 3<br>
+// CHECK:        ^<br>
+<br>
+.iflt "string1"<br>
+.endif<br>
+<br>
+// CHECK: error: expected absolute expression<br>
+// CHECK: .iflt "string1"<br>
+// CHECK:       ^<br>
+<br>
+.ifge test<br>
+.endif<br>
+<br>
+// CHECK: error: expected absolute expression<br>
+// CHECK: .ifge test<br>
+// CHECK:       ^<br>
--<br>
2.0.0<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</div></div>