<div> </div>
<div>After look at documents of inline assemble,  i have known its reason.  </div>
<div> </div>
<div>Thanks!<br> </div>
<div><span class="gmail_quote">2009/12/30, Chris Lattner <<a href="mailto:clattner@apple.com">clattner@apple.com</a>>:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>On Dec 29, 2009, at 3:09 AM, Heyu Zhu wrote:<br><br>> Hi everyone,<br>><br>> I try to add an instruction to x86. The instruction is a multiply-add instruction<br>
> MULADD A, B, C; //A = A + B * C.<br>> I use the instruction by inline assemble as below<br>><br>> int x, y, z;<br>> .....  ....<br>> x = 0;<br>> asm("MULADD %0, %1, %2":"=r"(x):"0"(x), "r"(y), "r"(z));<br>
> ..... ....<br>><br>> The backend does allocate registers %edx, %edi, %esi for x,y, z respectively,<br>> but its assemble output is<br>>         MULADD %edx, %edx, %esi<br>> I expects it could output:<br>
>         MULADD %edx, %edi, %esi<br>><br>> What's  matter with my constraints of inline asm?<br>><br><br>The constraint tells the compiler what registers are valid to use.  "r" means that it can use any register.  You need to tell the compiler what registers need to be used, because it doesn't look inside the asm string.  Please take a look at the GCC documentation for more details:<br>
<a href="http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Extended-Asm">http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Extended-Asm</a><br><a href="http://gcc.gnu.org/onlinedocs/gcc/Constraints.html#Constraints">http://gcc.gnu.org/onlinedocs/gcc/Constraints.html#Constraints</a><br>
<br>-Chris<br><br></blockquote></div><br>