<div dir="ltr">On Thu, May 29, 2014 at 3:05 PM, 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>
lib/MC/MCParser/AsmParser.cpp | 37 ++++++++++++++++++-----<br>
test/MC/AsmParser/conditional_asm.s | 60 +++++++++++++++++++++++++++++++++++++<br>
2 files changed, 89 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp<br>
index 168597f..208d758 100644<br>
--- a/lib/MC/MCParser/AsmParser.cpp<br>
+++ b/lib/MC/MCParser/AsmParser.cpp<br>
@@ -352,8 +352,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>
@@ -440,8 +441,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>
@@ -1236,8 +1237,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>
@@ -3799,9 +3805,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>
@@ -3816,6 +3821,17 @@ bool AsmParser::parseDirectiveIf(SMLoc DirectiveLoc) {<br>
<br>
Lex();<br>
<br>
+ if (DirKind == DK_IFEQ)<br></blockquote><div><br></div><div>There shouldn't be the extra space between the if and the (.</div><div><br></div><div>I think this might be nicer in a switch statement.</div><div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ ExprValue = ExprValue == 0;<br>
+ else if (DirKind == DK_IFGE)<br>
+ ExprValue = ExprValue >= 0;<br>
+ else if (DirKind == DK_IFGT)<br>
+ ExprValue = ExprValue > 0;<br>
+ else if (DirKind == DK_IFLE)<br>
+ ExprValue = ExprValue <= 0;<br>
+ else if (DirKind == DK_IFLT)<br>
+ ExprValue = ExprValue < 0;<br>
+<br>
TheCondState.CondMet = ExprValue;<br>
TheCondState.Ignore = !TheCondState.CondMet;<br>
}<br>
@@ -4118,6 +4134,11 @@ void AsmParser::initializeDirectiveKindMap() {<br>
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></blockquote><div><br></div><div>Can you please add some tests to cover diagnostics for bad input?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888">--<br>
1.9.3<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</div></div>