<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">So, unfortunately it is not so easy to revert that patch. Previously, here is what would happen:<div><br></div><div>1. clang frontend parses __asm { ... } blob with the help of MC. IsParsingMSInlineAsm is true in the AsmLexer. 0b111 is recognized as a binary integer literal.</div><div>2. clang *rewrites* the user asm, including many integer literals, to gnu/intel syntax, something that llvm-mc could parse in standalone mode. This rewrites 0b111 to 7, for example.</div><div>3. Backend builds a string literal to parse from the inline asm blob. String literal says something like "and al, 7" instead of "and al, 0b111".</div><div>4. Backend parses and re-emits asm in AT&T syntax, and you get "andb $7, %al".</div><div><br></div><div>r311639 removed the infrastructure that rewrote immediate expressions in step 2 to plain decimal integers, so now this doesn't work. We do step 1 correctly, step 2 never happens, and step 3 can't parse 0b111, since it thinks it's a label reference.</div><div><br></div><div>I think we need to fix forward at this point. I think the best way forward would be some global option to control how 0b is interpreted, rather than a distinct masm vs intel asm dialect.</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 22, 2018 at 2:08 PM Gerolf Hoflehner <<a href="mailto:ghoflehner@apple.com">ghoflehner@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><br><div><br><blockquote type="cite"><div>On Oct 22, 2018, at 1:44 PM, Reid Kleckner <<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>> wrote:</div><br class="m_-9017892451080956031Apple-interchange-newline"><div><div dir="ltr">After looking more closely at the patch in question, I again think it should be reverted.<div><br></div><div>The patch sets a boolean to indicate that inline asm is being parsed in three places now:<br></div><div>1. true when parsing intel inline asm</div><div>2. true when .intel_syntax directives are encountered (BUG!)</div><div>3. false when .att_syntax is encountered</div><div><br></div><div>We should only set this to true when parsing *inline asm*, clearly. I sent my second email after I saw place 1 when re-reading the patch and thought, oh, everything is working as intended. I'll go ahead and do it, since it is clearly wrong. .intel_syntax should not imply IsParsingInlineAsm.</div></div></div></blockquote>Thanks, Reid!</div><div><br><blockquote type="cite"><div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 22, 2018 at 1:13 PM Gerolf Hoflehner <<a href="mailto:ghoflehner@apple.com" target="_blank">ghoflehner@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><br><div><br><blockquote type="cite"><div>On Sep 12, 2018, at 1:48 PM, Reid Kleckner via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="m_-9017892451080956031m_1720088976694891648Apple-interchange-newline"><div><div dir="ltr">Sorry, I spoke too soon. This only happens for intel style inline assembly in LLVM IR. I don't have a good suggestion.</div></div></blockquote><div><br></div>Why is it relevant that the issue is contained? The 0b support in MS asm shouldn’t break the general intel assembly syntax. <br><blockquote type="cite"><div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 12, 2018 at 1:44 PM Reid Kleckner <<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think we should revert r301390 just on principle from looking at the code. If I understand correctly, it flips the bit for "is parsing inline asm" to true when encountering a plain .intel_syntax directive. That's just wrong.</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 12, 2018 at 6:34 AM Francis Visoiu Mistrih via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
We have a significant regression since llvm 5.0.0 in the x86 assembler.<br>
<br>
The following snippets fail:<br>
<br>
1)<br>
<br>
.intel_syntax<br>
0:<br>
  jmp 0b<br>
<br>
2)<br>
<br>
.intel_syntax<br>
  and edi, 0b010101<br>
<br>
when running through `llvm-mc -arch x86-64`.<br>
<br>
This regression was introduced in r301390, which was driven by PR27884.<br>
<br>
I think <a href="https://llvm.org/PR36144" rel="noreferrer" target="_blank">https://llvm.org/PR36144</a> describes this very well, and I think we should<br>
get this fixed, since it's a pretty basic thing to support in the assembler.<br>
<br>
Here are a few solutions to this:<br>
<br>
1) Introduce a new asm dialect/flavor/style to assemble masm files.<br>
<br>
2) Only set the flags based on the target triple. Also suggested in PR27884.<br>
<br>
3) Only set the flags based on a new command line flag.<br>
<br>
Let me know if any other solution comes to mind.<br>
<br>
While we get this issue fixed, is it reasonable to revert r301390?<br>
<br>
Thanks,<br>
<br>
-- <br>
Francis<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br></div></blockquote></div><br></div></blockquote></div>
</div></blockquote></div><br></div></blockquote></div>