<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} P{margin-top:0;margin-bottom:0;}--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>What sort of outputs, specifically?  Memory outputs are easy; I think the LLVM IR patch actually supports them already.  Register outputs are complicated... I guess they're also possible, but we would need to come up with some frontend rule that allows sane
 code generation.  Consider the case where two or more asm gotos jump to the same destination, and output a value to the same register, but a different variable.  In general, it's possible to lower by rewriting the PHI nodes to match, then inserting a switch
 at the beginning of the destination to fix the rewritten PHIs.  But that's both expensive at runtime and difficult to implement, so we probably want a rule that prohibits constructs which would require that sort of lowering.<br>
</p>
<p><br>
</p>
<p>If we do intend to implement register outputs at some point, we might want to draft a design at the LLVM IR level now, so we have some confidence the current IR is forward-compatible.<br>
</p>
<p><br>
</p>
<p>Obviously we should have diagnostics in the parser if the user tries to write an asm goto with an output.  I'm not worried about the difficulty of fixing the frontend otherwise; this patch isn't that big in the first place.<br>
</p>
<p><br>
</p>
<p>-Eli<br>
</p>
<p><br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Nick Desaulniers <ndesaulniers@google.com><br>
<b>Sent:</b> Tuesday, February 5, 2019 1:14 AM<br>
<b>To:</b> reviews+D56571+public+1482c3abd76a8c19@reviews.llvm.org<br>
<b>Cc:</b> Yu, Jennifer; Keane, Erich; chandlerc@gmail.com; syaghmour@apple.com; craig.topper@gmail.com; hans@chromium.org; e5ten.arch@gmail.com; dima@golovin.in; natechancellor@gmail.com; tstellar@redhat.com; Eli Friedman; srhines@google.com; eraman@google.com;
 cfe-commits@lists.llvm.org<br>
<b>Subject:</b> [EXT] Re: [PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang</font>
<div> </div>
</div>
<div>
<div dir="auto">Note that kernel developers are requesting output support with ASM goto. Doesn't need to be in V1 of ASM go-to support, but we should expect it to be implemented in the future. We should help users with diagnostics that this is not supported,
 and add asserts that will help us implement such a feature in the future.
<div dir="auto"><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Tue, Feb 5, 2019, 3:32 AM Richard Smith - zygoloid via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
rsmith added inline comments.<br>
<br>
<br>
================<br>
Comment at: lib/AST/Stmt.cpp:457-460<br>
   this->NumOutputs = NumOutputs;<br>
   this->NumInputs = NumInputs;<br>
   this->NumClobbers = NumClobbers;<br>
+  this->NumLabels = NumLabels;<br>
----------------<br>
jyu2 wrote:<br>
> rsmith wrote:<br>
> > Please assert that you don't have both outputs and labels here. (If you did, you would assign them the same slots within `Exprs`.)<br>
> > <br>
> > You also seem to be missing `Sema` enforcement of the rule that you cannot have both outputs and labels. (If you want to actually support that as an intentional extension to the GCC functionality, you should change the implementation of `GCCAsmStmt` to
 use different slots for outputs and labels, add some tests, and add a `-Wgcc-compat` warning for that case. Seems better to just add an error for it for now.)<br>
> This is enforcement during the parer.  <br>
> <br>
> for example:<br>
> a.c:12:23: error: expected ':'<br>
> asm goto ("decl %0;" :"a": "m"(cond) : "memory" );<br>
> <br>
> Do you think this is enough for now?<br>
> Thanks.<br>
> Jennifer<br>
Thanks, I see it now. Please still add the assert here.<br>
<br>
I'd also like a custom diagnostic for that parse error; it'd seem easy and useful to add an "asm goto cannot have output constraints" error.<br>
<br>
<br>
CHANGES SINCE LAST ACTION<br>
  <a href="https://reviews.llvm.org/D56571/new/" rel="noreferrer noreferrer" target="_blank">
https://reviews.llvm.org/D56571/new/</a><br>
<br>
<a href="https://reviews.llvm.org/D56571" rel="noreferrer noreferrer" target="_blank">https://reviews.llvm.org/D56571</a><br>
<br>
<br>
<br>
</blockquote>
</div>
</div>
</div>
</body>
</html>