<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Hi Stepan,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">I see what Fixup is now, and thanks for your explanation!</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">
<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">The solution sounds reasonable to me, and it is like a lazy-evaluation after knowing the layout. I didn't realize there is such a stage.</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Thanks,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">
-Jiangning</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-28 14:24 GMT+08:00 Stepan Dyatkovskiy <span dir="ltr"><<a href="mailto:stpworld@narod.ru" target="_blank">stpworld@narod.ru</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
Renato,<br>
If it will not evaluated, it *will* fail with "expected relocatable expression" message.<br>
<br>
Try next:<br>
    .text<br>
    cmp r2, #(l2 - doesntExist) >> 2<br>
l1:<br>
l2:<div class=""><br>
<br>
> But we still need more examples as tests, just to make sure we<br>
> evaluate what's possible and err where it's not. I don't have a list,<br>
> unfortunately, bu tI know Saleem does, this is why I asked him.<br></div>
Couldn't we add them as additional commits?<br>
<br>
<br>
Below is my small research of how it works.<br>
<br>
Fixup's technique has been introduced for cases when you are not able to evaluate (resolve) some symbols, and thus not able to encode instruction properly. In this case you leave a gap in output code, and create an MCFixup instance with location of this gap.<br>

Then when encoding stage is finished, we start to resolve collection of MCFixup instances (see MCAssembler::Finish).<br>
<br>
As Rafael mentioned, MCAssembler::handleFixup is called. This method invokes evaluateFixup, and if it fails it puts relocation.<br>
<br>
evuluateFixup though, first, once again tries to fold expression via Fixup.getValue()-><u></u>EvaluateAsRelocatable call. On this stage this method *always* has layout, so we always able to evaluate expressions. And if it failed to evaluate it, it emits error:<br>

  if (!Fixup.getValue()-><u></u>EvaluateAsRelocatable(Target, &Layout))<br>
    getContext().FatalError(Fixup.<u></u>getLoc(), "expected relocatable expression");<br>
<br>
Else, if it managed to evaluate fixup, but it is still not absolute, it will put relocatable record.<br>
<br>
So I think, we can add MCFixup for now, then commit additional tests. And meanwhile I could switch to PR18929.<br>
What do you think, guys?<span class="HOEnZb"><font color="#888888"><br>
<br>
-Stepan.</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
Renato Golin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 27 March 2014 21:00, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That is what a fixup is :-)<br>
</blockquote>
<br>
Right. I used the term "fixup" before in the context of relocations,<br>
and I thought the MC layer was just being smart to fold them later,<br>
but there was no guarantee that it would happen. If at the final<br>
emission the expression cannot be resolved, would that incur in an<br>
error? If so, I think this is the right solution after all.<br>
<br>
But we still need more examples as tests, just to make sure we<br>
evaluate what's possible and err where it's not. I don't have a list,<br>
unfortunately, bu tI know Saleem does, this is why I asked him.<br>
<br>
cheers,<br>
--renato<br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">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/<u></u>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font face="courier new, monospace">Thanks,</font><div><font face="courier new, monospace">-Jiangning</font></div></div>
</div>