<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 9, 2015 at 3:02 PM Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">----- Original Message -----<br>
> From: "Derek Schuff via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="cremed">llvm-dev@lists.llvm.org</a>><br>
> To: <a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="cremed">llvm-dev@lists.llvm.org</a><br>
> Sent: Wednesday, December 9, 2015 4:31:31 PM<br>
> Subject: [llvm-dev] Allowing virtual registers after register allocation<br>
><br>
><br>
> Hi all,<br>
> Virtual ISAs such as WebAssembly and NVPTX use infinite virtual<br>
> register sets instead of traditional phsyical registers.<br>
> PrologEpilogInserter is run after register allocation and asserts<br>
> that all virtuals have been allocated but doesn't otherwise depend<br>
> on this if scavenging is not needed. We'd like to use the<br>
> target-independent PEI code for WebAssembly, so we're proposing a<br>
> TargetRegisterInfo hook for targets to indicate that they use<br>
> virtual registers in this way (currently called<br>
> usesVirtualRegstersAfterRegAlloc(), other suggestions welcome). The<br>
> code is at <a href="http://reviews.llvm.org/D15394" rel="noreferrer" target="_blank" class="cremed">http://reviews.llvm.org/D15394</a> and an example of the<br>
> intended use for WebAssembly is at <a href="http://reviews.llvm.org/D15344" rel="noreferrer" target="_blank" class="cremed">http://reviews.llvm.org/D15344</a> .<br>
><br>
<br>
I think this makes sense, and generally speaking, I think it will be good for us to have better support for VM targets without fixed-sized register sets.<br>
<br>
Bikeshedding: usesVirtualRegstersAfterRegAlloc() - Are you actually "allocating" virtual registers, or just using the ones that the infrastructure already provides? </blockquote><div><br></div><div>Not exactly; the actual register allocation does nothing (i.e.  WebAssemblyPassConfig::createTargetRegisterAllocator() returns nullptr) and we just use the regular infrastructure virtual registers. However we do run a custom register coloring pass which reduces the total number of virtual registers used.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is the answer the same for the NVPTX backend?</blockquote><div><br></div><div>Yes (at least, they have a null TargetRegisterAllocator too).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Maybe something like: targetLacksPhysicalRegissters() would be better?<br></blockquote><div><br></div><div>Maybe. We actually do have "physical" registers called SP and FP (returned by TargetRegisterInfo::getFrameRegister() and used by some default ISel lowerings and by FrameIndex elimination) but of course they aren't really physical registers either.</div><div><br></div><div> </div></div></div>