<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">> Whether it’s a hack or not depends on the sizes in question. Existing<br>
> X86 already has this property for 64 bit, there are registers which<br>
> simply don't exist<br>
> unless the target arch is 64 bit.  If WebASM folks are thinking of<br>
> allocating down to something like 32 or 64 registers, with maybe a<br>
> maximum of 128 or 256, then<br>
> making some portion of this reserved when a tighter allocation (only<br>
> coloring to 16 or 32) seems completely doable (and natural) using<br>
> all existing infrastructure, with nothing<br>
> special needed.<br>
<br>
</div></div>No argument from me on this point, however, whether or not a relatively-small fixed number is acceptable I don't know. What does seem to be the case, however, is that they need some kind of register use cost function which makes the use of each new register increasingly expensive and/or the ability to dynamically change the number of registers that are reserved at any given time. The former is probably better.<br>
<span class=""><br>
> If getting into significantly larger numbers, then I<br>
> can see where this might be considered a hack.  But unless you are<br>
> talking about multi-thousands,<br>
> it does beg the question about what the extra generality is worth<br>
> compared to the engineering effort to design, implement and support<br>
> it.<br>
<br>
</span>This is exactly why I was in favor of reusing the existing infrastructure for virtual registers.</blockquote><div><br></div><div>We aren't talking about have 32 or 64 virtual registers. Most functions should have just a few, but we are talking about having as many as the compiled code needs: the VM will spill what's needed to a shadow stack that's not user-accessible. This has interesting security properties, lets the VM do this as optimally as it sees fit for the target ISA, and would otherwise require the LLVM backend to emit an alloca which we then translate to a heap allocation to the user-accessible "stack" (which lives in their heap).</div><div><br></div><div>Put another way: it seems sensible for a virtual ISA to have virtual registers ;-)</div><div><br></div><div>I think Derek's proposal is sensible in that it doesn't have much cost to the LLVM code base, and NVPTX shows precedent for working around that limitation. We'd like virtual ISAs to be supported as first-class targets, that has a small cost in LLVM's generality but should help remove hacks in other virtual ISA implementations.</div></div><br></div></div>