<div dir="ltr"><div>It would seem like a Pseudo for BUILD_VECTOR that would take the two values and produce a RegClassAB register is a good solution. Then you can catch it in expandPostRAPseudo and produce the MOV instructions. The register allocator will then allocate the wide register you need and you can safely use the subregisters for the two MOV instructions. I would imagine you'd want to make sure that the isRenamable flag isn't set on the subregisters when you do that.<br><br></div>Hopefully this helps.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 10, 2018 at 5:16 AM, Dominique Torette via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="blue" vlink="purple" lang="EN-US">
<div class="m_7439419052098626258WordSection1">
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’ve some problems/questions while implementing the BUILD_VECTOR primitive for a SIMD microcontroller…<u></u><u></u></p>
<p class="MsoNormal">This microcontroller has two FPU units: UnitA and UnitB.<u></u><u></u></p>
<p class="MsoNormal">UnitA has a bank of 512 registers named RegisterA_0 .. RegisterA_511.<u></u><u></u></p>
<p class="MsoNormal">UnitB has a bank of 512 registers named RegisterB_0 .. RegisterB_511.<u></u><u></u></p>
<p class="MsoNormal">The FPU instruction format has a 2 bits operand indicating which units are involved: none, only UnitA, only UnitB, and the SIMD version UnitA and UnitB.<u></u><u></u></p>
<p class="MsoNormal">The SIMD version of a FPU instruction operates on registers with the same ID of both banks.<u></u><u></u></p>
<p class="MsoNormal">For examples:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">     FADD A     R1, R2;         // => ACC_A =  RegisterA_1 + RegisterA_1<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">     FADD B     R5, R6;         // => ACC_B =  RegisterB_5 + RegisterB_6<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">     FADD AB    R7, R8;         // => ACC_A =  RegisterA_7 + RegisterA_8 and ACC_B =  RegisterB_7 + RegisterB_8<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">From a machine registers definition point of view, I’ve first defined the 512 UnitA registers in a RegisterClass RegClassA and the 512 UnitB registers in a RegisterClass RegClassB.<u></u><u></u></p>
<p class="MsoNormal">In order to defined registers operands for the SIMD version of FPU instructions, I’ve then defined 512 registers in a RegisterClass RegClassAB.<u></u><u></u></p>
<p class="MsoNormal">The registers from RegClassAB overlap the one the ones of RegClassA and RegClassB in this way RegClassAB.R1 has two subregisters: RegClassA.R1 and RegClassB.R1.<u></u><u></u></p>
<p class="MsoNormal">So far, so good. I can generated code for math expression taking advantage of SIMD FPU!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">My problem is on the implementation of the BUILD_VECTOR that should build RegClassAB register from a pair of RegClassA/RegClassB registers or constants.<u></u><u></u></p>
<p class="MsoNormal">For this purpose, I only have a MOV instruction operating either on UnitA or UnitB.<u></u><u></u></p>
<p class="MsoNormal">So from the BUILD_VECTOR, I have to generate two MOV instructions, one for the UnitA and UnitB.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Assuming that %vreg3 (of class RegClassAB) will be allocated  to R22,   <span style="font-family:"Courier New"">%vreg3<def> = BUILD_VECTOR 2.7172, 3.1416</span> should be lowered into:<u></u><u></u></p>
<p class="MsoNormal" style="text-align:center" align="center"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">     MOV A      2.7172, R22 ;   // RegisterA_22 = 2.7172<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">     MOV B      3.1416, R22;    // RegisterB_22 = 3.1416<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Generating the two instruction could be easily  done by custom inserter at end of Instruction Selection.<u></u><u></u></p>
<p class="MsoNormal">It is understood that the MachineRegisterInfo has all the information about the sub-registers overlapping.   <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">But the problem is have to map (before registers allocation) _<i>one Virtual Register</i>_ of RegClassAB into the _<i>two overlapping physical sub-registers</i>_ !<br>
<br>
<u></u><u></u></p>
<p class="MsoNormal">Has someone an idea to properly lowering and allocating registers to BUILD_VECTOR, considering my SIMD registers definition and my instructions set?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks in advance, comments are welcome.      Dominique Torette.<u></u><u></u></p>
<p class="MsoNormal"><br>
<br>
<br>
<br>
<br>
<u></u><u></u></p>
<table class="m_7439419052098626258MsoNormalTable" style="width:402.0pt" cellspacing="0" cellpadding="0" width="536" border="0">
<tbody>
<tr>
<td style="padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><img id="m_7439419052098626258_x0000_i1025" src="http://www.spacebel.be/wp-content/uploads/2018/02/image-sign-sbp30y-1.jpg" alt="http://www.spacebel.be/wp-content/uploads/2018/02/image-sign-sbp30y-1.jpg" width="536" height="49"></span><span style="font-size:12.0pt;font-family:"Times New Roman","serif"" lang="FR-BE"><u></u><u></u></span></p>
</td>
</tr>
<tr>
<td style="border:solid silver 1.0pt;padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal" style="text-align:center" align="center">
<b><span style="font-size:10.0pt" lang="FR-BE">Dominique Torette</span></b><span style="font-size:10.0pt" lang="FR-BE">
<br>
System Architect<br>
Rue des Chasseurs Ardennais - Liège Science Park - B-4031 Angleur <br>
Tel: +32 (0) 4 361 81 11 - Fax: +32 (0) 4 361 81 20 <br>
</span><span style="font-size:10.0pt"><a href="http://www.spacebel.be/" target="_blank"><span style="color:blue" lang="FR-BE">www.spacebel.be</span></a></span><span style="font-size:12.0pt;font-family:"Times New Roman","serif"" lang="FR-BE"><u></u><u></u></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span lang="FR-BE"><u></u> <u></u></span></p>
</div>
<br clear="all">
 ------------------------------<wbr>------------------------------<wbr>------------------<br>
<br>
E-MAIL DISCLAIMER<br>
<br>
The present message may contain confidential and/or legally privileged information. If you are not the intended addressee and in case of a transmission error, please notify the sender immediately and destroy this E-mail. Disclosure, reproduction or distribution of this document and its possible attachments is strictly forbidden.<br>
<br>
SPACEBEL denies all liability for incomplete, improper, inaccurate, intercepted, (partly) destroyed, lost and/or belated transmission of the current information given that unencrypted electronic transmission cannot currently be guaranteed to be secure or error free.<br>
Upon request or in conformity with formal, contractual agreements, an originally signed hard copy will be sent to you to confirm the information contained in this E-mail.<br>
<br>
SPACEBEL denies all liability where E-mail is used for private use.<br>
<br>
SPACEBEL cannot be held responsible for possible viruses that might corrupt this message and/or your computer system.<br>
 ------------------------------<wbr>------------------------------<wbr>-------------------<br>
</div>

<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>