<div dir="ltr"><div>Is there a way to force or increase the likelihood of rematerialization of condition registers, instead of copying or spilling?<br><br></div>mips isa doesn't have a handy instruction which enables reading or writing condition registers in one or two cycles (you need several shift and masking operations), so it makes more sense to rematerialize, if that's possible.<br>
<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Apr 6, 2013 at 9:56 AM, Jakob Stoklund Olesen <span dir="ltr"><<a href="mailto:stoklund@2pi.dk" target="_blank">stoklund@2pi.dk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Apr 6, 2013, at 12:42 AM, Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:<br>
<br>
> ----- Original Message -----<br>
>> From: "Jakob Stoklund Olesen" <<a href="mailto:stoklund@2pi.dk">stoklund@2pi.dk</a>><br>
>> To: "Akira Hatanaka" <<a href="mailto:ahatanak@gmail.com">ahatanak@gmail.com</a>><br>
>> Cc: "LLVM Developers Mailing List" <<a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a>>, "Hal Finkel" <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>><br>
>> Sent: Tuesday, March 26, 2013 12:40:44 PM<br>
>> Subject: Re: [LLVMdev] [PATCH] RegScavenger::scavengeRegister<br>
>><br>
>><br>
>> On Mar 26, 2013, at 10:29 AM, Akira Hatanaka <<a href="mailto:ahatanak@gmail.com">ahatanak@gmail.com</a>><br>
>> wrote:<br>
>><br>
>>> The size of general purpose integer registers for mips32 is 32-bit<br>
>>> and accumulators are 64-bit registers consisting of 32-bit hi/lo<br>
>>> register pairs. So you will need two instructions to copy two<br>
>>> 32-bit GPR registers to a 64-bit accumulator register. If spilling<br>
>>> to multiple registers is unsupported, perhaps I can I define a new<br>
>>> register class consisting of paired GPR registers and pseudo copy<br>
>>> instructions?<br>
>><br>
>> Yes, that would work. Look at the ARM GPRPair register class.<br>
><br>
> In the PPC case, for CR spilling, the CRs are only really 4 bits; I'd need to define 8-tuples just to pair with 32-bit GPR registers. Under normal circumstances, i32 is the smallest legal type. Instead, to make this work, would I define a 4-bit subregister of the GPRs to hold the data (or maybe 8 bits, and then also use some CR-pair register class)?<br>

<br>
</div>No, that shouldn't be necessary.<br>
<br>
The types on register classes are only used by isel, and this register class wouldn't be used before register allocation. Just make it [i32], or even [untyped]. (The type is used to pick a default spill size, so you may need to 'let Size = 4' if you go with untyped).<br>

<br>
Your implementation in copyPhysReg is the final word on what it means to copy between registers in this class.<br>
<br>
The register class will not be used automatically without permission from your implementation of getLargestLegalSuperClass. This function should not allow normal GPR registers to be inflated to the GPR+CR super-class because not all registers in that class have enough bits.<br>

<br>
X86RegisterInfo::getLargestLegalSuperClass() does something similar with the GR8_NOREX register class to work around some awkward x86 encoding issues with the 20 8-bit registers.<br>
<span class="HOEnZb"><font color="#888888"><br>
/jakob<br>
<br>
</font></span></blockquote></div><br></div>