<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.5726" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Verdana><FONT size=2>Hi all, I'm very instresting in LLVM, and 
trying to port a dsp target on LLVM now.</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2></FONT></FONT> </DIV>
<DIV><FONT face=Verdana><FONT size=2>I found that, the Greddy Register Allocator 
will generate a reload instrucion just between the function call and 
ADJCALLSTACKUP instruction. If the reload instruction is transfered to be a load 
instruction finally, which uses the SP register as an operand, and the target 
uses the ADJCALLSTACKUP instruction to adjust the SP register's value, will the 
reload instruction get a bad SP register value?</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2></FONT></FONT> </DIV>
<DIV><FONT face=Verdana><FONT size=2>Let me use MBlaze to explain 
that:</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2>compile option: clang -target mblaze -O2 -S 
-mllvm -unroll-threshold=1024 -mllvm -unroll-allow-partial demo.c -o demo.s 
-mllvm -print-after-all</FONT></FONT></DIV>
<DIV><FONT face=Verdana size=2>The IR after Virtual Register Rewriter whill show 
this situation as below:</FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2>"<BR>    BRLID R15, 
</FONT><A href="mailto:ga@printf"><FONT size=2>ga@printf</FONT></A><FONT 
size=2>, </FONT></FONT><FONT size=2>%R3<imp_def,dead>,<FONT face=Verdana> 
</FONT>%R4<imp_def,dead>,<FONT face=Verdana> 
</FONT>%R5<imp_def,dead>...</FONT></DIV>
<DIV><FONT size=2>       %R4<def>=LWI 
<fi#5>,0</FONT></DIV>
<DIV><FONT size=2>       ADJCALLSTACKUP 68, 0, %R1 
<imp_def>, %R1<imp_def></FONT></DIV>
<DIV>"</DIV>
<DIV>The instruction "<FONT size=2> %R4<def>=LWI <fi#5>,0</FONT>" 
loads value from the stack, and it will use SP register as an operand. But 
the SP may need to be adjusted int the ADJCALLSTACKUP instruction(MBlaze will 
not do that), is it a problem? Or I get the wrong understanding? </DIV>
<DIV> </DIV>
<DIV>The demo code has no actual meaning.</DIV>
<DIV>demo.c:</DIV>
<DIV>extern float b[10][10];</DIV>
<DIV>extern void do_nothing(float a, float b);</DIV>
<DIV>void fun()</DIV>
<DIV>{</DIV>
<DIV>    register int i, j;</DIV>
<DIV>    register float f1, f2, f3, f4, f5, f6, f7, f8;</DIV>
<DIV>    float a[10][10];</DIV>
<DIV>    </DIV>
<DIV>    float(int i = 0; i < 10; i++)</DIV>
<DIV>    {</DIV>
<DIV>        float(int j = 0; j < 10; 
j++)</DIV>
<DIV>        {</DIV>
<DIV>            f1 = 
a[i][j];</DIV>
<DIV>            f2 = 
b[i][j];</DIV>
<DIV>            f3 
= f1 + f2;</DIV>
<DIV>            f4 = f3 * 
f3;</DIV>
<DIV>            f5 = f4 - 
f3;</DIV>
<DIV>            f6 = f4 + 
f3;</DIV>
<DIV>            f7 = f5 + 
f6;</DIV>
<DIV>            f8 = f6 + 
f7;</DIV>
<DIV>            do_nothing(f1, 
f2);</DIV>
<DIV>        }</DIV>
<DIV>    }</DIV>
<DIV>
<DIV>    float(int i = 0; i < 10; i++)</DIV>
<DIV>    {</DIV>
<DIV>        float(int j = 0; j < 10; 
j++)</DIV>
<DIV>        {</DIV>
<DIV>            printf("%f %f %f 
%f %f %f %f %f \n", f3, f4, f5, f6, f7, f8, a[i][j], b[i][j]);</DIV>
<DIV>        }</DIV>
<DIV>    }</DIV></DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>Thank you very much!</DIV>
<DIV> </DIV>
<DIV>GooKe.</DIV>
<DIV><FONT color=#c0c0c0><FONT face=Verdana color=#000000 
size=2></FONT></FONT> </DIV></BODY></HTML>