<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Dec 31, 2010, at 11:34 AM, Benjamin Kramer wrote:</div><blockquote type="cite"><div>To sum this up, should we consider using local register vars outside of asm statements<br>unsafe and just ignore them (as we do now)? While GCC supports them to some extent I don't<br>think it's worth to support it just to enable some premature optimizations. We don't even<br>need a warning in that case.</div></blockquote></div><br><div>There are three cases:</div><div><br></div><div>1. Pinned local variables are treated no differently than normal local variables except when they are used as operands for inline asm. This is what Rafael's patch implements. I suppose you could warn if such a variable is never used for inline asm.</div><div><br></div><div>2. Global variables pinned to a reserved register. This is just an odd way of accessing a register, and it is fairly easy to support in the front end by emitting empty inline asm instead of reads and writes to the global.</div><div><br></div><div>3. Global variables pinned to an allocatable register. For this to work, the backend must treat the pinned register as reserved, effectively changing the calling convention of all functions in the compilation unit. Other compilation units would have to be built with -ffixed-<i>reg.</i> I really don't want to support this if it can at all be avoided.</div><div><br></div><div>It is very hard for the frontend to distinguish between 2. and 3., it would have to know if a register is reserved. Even the backend has a hard time telling when %ebp (the frame pointer) is reserved.</div><div><br></div><div>I think we should consider not supporting pinned global variables, and instead provide a way of reading and writing specific registers with inline asm constraints.</div><div><br></div><div>Instead of:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">       </span>register unsigned long current_stack_pointer asm("esp");<br><span class="Apple-tab-span" style="white-space:pre">        </span>foo = current_stack_pointer;</div><div><br></div><div>We could permit:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>asm ("" : "={esp}"(foo));</div><div><br></div><div>The curly brace syntax for inline asm constraints also obsoletes pinned local variables.</div><div><br></div><div>/jakob</div><div><br></div></body></html>