<div dir="ltr">I don't think clang supports global register variables in general although 'sp' appears to work from clang-3.7 onwards. However it doesn't appear to understand 'r13' on arm which is equivalent.<div><br></div><div>You can always do something like</div><div><span class=""><br></span></div><div><span class="">asm</span><span class=""> (</span><span class="">"movq %0, </span><span class="">%%</span><span class="">xmm15"</span><span class="">::</span><span class="">"x"</span><span class="">(</span><span class="">100</span><span class="">):</span><span class="">"xmm15"</span><span class="">);</span><br></div><div><span class=""><br></span></div><div><span class="">although it's not strictly equivalent.</span></div><div><span class=""><br></span></div><div><span class="">
<p class=""><span class="">int</span><span class=""> main() </span><span class="">{</span></p>
<p class=""><span class="">    </span><span class="">asm</span><span class=""> (</span><span class="">"movq %0, </span><span class="">%%</span><span class="">xmm15"</span><span class="">::</span><span class="">"x"</span><span class="">(</span><span class="">100</span><span class="">):</span><span class="">"xmm15"</span><span class="">);</span></p>
<p class=""><span class="">    </span><span class="">return</span><span class=""> 0;</span></p>
<p class=""><span class="">}</span></p></span></div><div><p class=""><span class="">will generate</span></p><p class=""><span class="">       movl    $0, -4(%rbp)</span></p><p class=""><span class="">        movss   .LCPI0_0(%rip), %xmm0</span></p><p class=""><span class="">        #APP</span></p><p class=""><span class="">        movq    %xmm0, %xmm15</span></p><p class=""><span class="">        #NO_APP</span></p><p class=""><span class="">        xorl    %eax, %eax</span></p><p class=""><span class="">        popq    %rbp</span></p><p class="">














</p><p class=""><span class="">        retq</span></p><p class=""><span class=""><br></span></p><p class=""><span class="">So you could just have that as a replacement everytime 'A' is written but is not the same I appreciate that. The above also lacks context of the actual application of what is that you're trying to do so it's possible better (and faster) solutions exist!</span></p><p class=""><span class=""><br></span></p></div><div class="gmail_extra"><div class="gmail_quote">On 4 October 2015 at 07:44, Viswesh Narayanan via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">My use case is to store a global value permanently in a register (say<br>
xmm15) using LLVM<br>
<br>
The following piece of code works as expected in GCC while it is not<br>
supported in LLVM. It complains with "fatal error: error in backend:<br>
Invalid register name global variable".<br>
<br>
Can any expert here provide me a solution to this in Clang/LLVM?<br>
<br>
Code:<br>
#include <stdio.h><br>
volatile register int A asm ("xmm15");<br>
int main() {<br>
    A = 100;<br>
    return A;<br>
}<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br><br clear="all"><div><br></div><br><div class="gmail_signature"></div>
</div></div>