<div><div dir="auto">Indeed xmm registers can hold richer structures than just scalar floats and doubles. </div></div><div dir="auto"><br></div><div dir="auto">They can do 4 32 bit floats or 32bit ints or words </div><div dir="auto"><br></div><div dir="auto">or 2 64 bit doubles or 64bit ints or words. </div><div dir="auto"><br></div><div dir="auto">Or scalar 32/64bit ints or words! (Distinct from the gpr registers!)</div><div dir="auto"><br></div><div dir="auto">Xmm registers are the lower half of ymm/ lower quarter of zmm simd registers (when they exist on newer x86-64 cpus )</div><div dir="auto"><br></div><div><div dir="auto">Agreed, the maybes are definitely going to be removed before end of summer. Though Andreas and I may try to go over things a tad closely in our code reviews </div><div dir="auto"><br></div><div dir="auto"><br></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 13, 2018 at 6:22 PM Simon Peyton Jones via ghc-devs <<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-GB" link="blue" vlink="purple">
<div class="m_3427816333616726356WordSection1">
<p class="MsoNormal"><span>Typesetting is really strange here. Hard to read.<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>Yes, let’s get rid of those Maybes if poss. What does Nothing mean???<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>Does this mean that Xmm regs really can contain multiple integers or multiple floats? I did not know that.<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>the general direction looks right.<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>Thanks<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>Simon<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Abhiroop Sarkar <<a href="mailto:asiamgenius@gmail.com" target="_blank">asiamgenius@gmail.com</a>>
<br>
<b>Sent:</b> 13 July 2018 16:32</span></p></div></div></div></div></div><div lang="EN-GB" link="blue" vlink="purple"><div class="m_3427816333616726356WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><span lang="EN-US"><br>
<b>To:</b> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>
<b>Cc:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: Is it possible to enhance the vector STG registers(Xmm, Ymm, Zmm) with more information?<u></u><u></u></span></p></div></div></div></div></div><div lang="EN-GB" link="blue" vlink="purple"><div class="m_3427816333616726356WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">The formatting of the function[1] got spoilt in the last mail. It is modified from:<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">globalRegType _ (XmmReg _) = cmmVec 4 (cmmBits W32)<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">to<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">globalRegType _ (XmmReg _ m ty) = let (l,w) = fromMaybe (2, W64) m<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> in case fromMaybe Float ty of<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> Integer -> cmmVec l (cmmBits w)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> Float -> cmmVec l (cmmFloat w)<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thank,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Abhiroop<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">[1] <a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAbhiroop%2Fghc-1%2Fblob%2Fwip%2Fsimd-ncg-support%2Fcompiler%2Fcmm%2FCmmExpr.hs%23L596&data=02%7C01%7Csimonpj%40microsoft.com%7Cee2fb4d91cfc45ae307808d5e8d5d097%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636670927384427518&sdata=XngOwITn9xqGS417NO16ftCgC8%2BGa1NidVraLD7KS1I%3D&reserved=0" target="_blank">
https://github.com/Abhiroop/ghc-1/blob/wip/simd-ncg-support/compiler/cmm/CmmExpr.hs#L596</a><u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Fri, Jul 13, 2018 at 4:26 PM Abhiroop Sarkar <<a href="mailto:asiamgenius@gmail.com" target="_blank">asiamgenius@gmail.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">Sorry I mistyped and forgot to include the register number in the mail but it is present in the patch. So it is:<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:12.0pt">data GlobalReg = ...<br>
| XmmReg !Int<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:12.0pt"> (Maybe (Length, Width))<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt;background:white"><span style="font-size:12.0pt"> (Maybe GlobalVecRegTy)<br>
<br>
The purpose of the GlobalVecRegTy field is to rewrite this function definition : <a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fghc%2Fghc%2Fblob%2Fmaster%2Fcompiler%2Fcmm%2FCmmExpr.hs%23L585-L587&data=02%7C01%7Csimonpj%40microsoft.com%7Cee2fb4d91cfc45ae307808d5e8d5d097%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636670927384437535&sdata=50vVucmqx1KOIVJUMnqby1%2BxRkE2nv7CG5qbkDZ0g3c%3D&reserved=0" target="_blank">https://github.com/ghc/ghc/blob/master/compiler/cmm/CmmExpr.hs#L585-L587</a><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:#fffbdd">globalRegType _ (</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-ent"><span style="font-size:9.0pt;font-family:Consolas;color:#22863a">XmmReg</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:#fffbdd">
_) </span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#d73a49">=</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:#fffbdd"> cmmVec
</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-c1"><span style="font-size:9.0pt;font-family:Consolas;color:#005cc5">4</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:#fffbdd"> (cmmBits
</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-ent"><span style="font-size:9.0pt;font-family:Consolas;color:#22863a">W32</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:#fffbdd">)
</span><span style="font-size:12.0pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:12.0pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:12.0pt">and rewrite it to : <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:12.0pt"><u></u> <u></u></span></p>
</div>
<div>
<table class="m_3427816333616726356MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse">
<tbody>
<tr>
<td valign="top" style="padding:0cm 7.5pt 0cm 7.5pt">
<p class="MsoNormal" style="line-height:15.0pt"><span style="font-size:9.0pt;font-family:Consolas;color:#24292e">globalRegType _ (</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-ent"><span style="font-size:9.0pt;font-family:Consolas;color:#22863a">XmmReg</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e">
_ m ty) </span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#d73a49">=</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e">
</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#d73a49">let</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e"> (l,w)
</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#d73a49">=</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e"> fromMaybe (</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-c1"><span style="font-size:9.0pt;font-family:Consolas;color:#005cc5">2</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e">,
</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-ent"><span style="font-size:9.0pt;font-family:Consolas;color:#22863a">W64</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e">) m -- a random default value of 2 and W64 chosen
</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#d73a49;background:white">in</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:white">
</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#d73a49;background:white">case</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:white"> fromMaybe
</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-ent"><span style="font-size:9.0pt;font-family:Consolas;color:#22863a;background:white">Float</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:white"> ty
</span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#d73a49;background:white">of
</span></span><span class="m_3427816333616726356m5607108372526412337gmail-pl-ent"><span style="font-size:9.0pt;font-family:Consolas;color:#22863a;background:white">Integer</span></span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:white">
</span></span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#d73a49;background:white">-></span></span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:white">
cmmVec l (cmmBits w) </span></span><span class="m_3427816333616726356m5607108372526412337gmail-pl-ent"><span style="font-size:9.0pt;font-family:Consolas;color:#22863a;background:white">Float</span></span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:white">
</span></span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#d73a49;background:white">-></span></span><span class="m_3427816333616726356m5607108372526412337gmail-pl-k"><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:white">
cmmVec l (cmmFloat w) Thanks, Abhiroop</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e"><u></u><u></u></span></p>
</td>
</tr>
<tr style="box-sizing:border-box">
<td width="50" nowrap valign="top" style="width:37.5pt;padding:0cm 7.5pt 0cm 7.5pt;box-sizing:border-box;min-width:50px;color:rgba(27,31,35,0.3)" id="m_3427816333616726356m_5607108372526412337gmail-L597">
</td>
<td valign="top" style="padding:0cm 7.5pt 0cm 7.5pt;box-sizing:border-box;word-wrap:normal;white-space:pre-wrap;overflow:visible" id="m_3427816333616726356m_5607108372526412337gmail-LC597">
</td>
</tr>
</tbody>
</table>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:12.0pt"><u></u> <u></u></span></p>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Fri, Jul 13, 2018 at 4:12 PM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">What is the GlobalVecRegTy field doing?<u></u><u></u></p>
<p class="MsoNormal">Don’t you need an Int for the register number, like all the rest?<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Generally, sounds good though<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">S<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Abhiroop Sarkar <<a href="mailto:asiamgenius@gmail.com" target="_blank">asiamgenius@gmail.com</a>>
<br>
<b>Sent:</b> 13 July 2018 14:07<br>
<b>To:</b> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>
<b>Cc:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: Is it possible to enhance the vector STG registers(Xmm, Ymm, Zmm) with more information?</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Hello Simon,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks for your response. I had written a patch[1] for this and the approach I took was quite similar to what you pointed out. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">data GlobalReg = ...<br>
| XmmReg <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> (Maybe (Length, Width))<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> (Maybe GlobalVecRegTy)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">data GlobalVecRegTy = Integer | Float<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">-- Width and Length are already defined<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">data Width = W8 | W16 | W32 .....<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">type Length = Int <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I wrapped the types inside a `Maybe` because when initializing a GlobalReg (in the `activeStgRegs`[2] function), I was not sure what value to initialize the register with, so I
used a `Nothing` when initializing. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I see now in the case of `VanillaReg` it is initialized with the `VGcPtr` constructor: <span class="m_3427816333616726356m5607108372526412337m6965542420395903681gmail-pl-ent"><span style="font-size:9.0pt;font-family:Consolas;color:#22863a;background:white">VanillaReg</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:white">
</span><span class="m_3427816333616726356m5607108372526412337m6965542420395903681gmail-pl-c1"><span style="font-size:9.0pt;font-family:Consolas;color:#005cc5;background:white">1</span></span><span style="font-size:9.0pt;font-family:Consolas;color:#24292e;background:white">
</span><span class="m_3427816333616726356m5607108372526412337m6965542420395903681gmail-pl-ent"><span style="font-size:9.0pt;font-family:Consolas;color:#22863a;background:white">VGcPtr etc</span></span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I think I should modify my patch as well to remove the Maybe and initialize with some default Length, Width and GlobalRegTy. Thanks for the help.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;background:white">Abhiroop</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">[1] <a href="https://phabricator.haskell.org/D4922" target="_blank">https://phabricator.haskell.org/D4922</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">[2] <a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fghc%2Fghc%2Fblob%2Fmaster%2Fincludes%2FCodeGen.Platform.hs%23L450&data=02%7C01%7Csimonpj%40microsoft.com%7Cee2fb4d91cfc45ae307808d5e8d5d097%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636670927384447548&sdata=4zBPD6H62ynzybNQWXm3FkFuvZS3Jnvzi98sT69zvmY%3D&reserved=0" target="_blank">https://github.com/ghc/ghc/blob/master/includes/CodeGen.Platform.hs#L450-L623</a><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Fri, Jul 13, 2018 at 10:58 AM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">Abhiroop</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Did anyone reply?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt">My instinct is this. You want to use the same register (say Xmm reg 3) in different ways. We already have this for ‘VanillaReg’:</span><u></u><u></u></p>
<p class="m_3427816333616726356m5607108372526412337m6965542420395903681m160898050108459242code">data GlobalReg<u></u><u></u></p>
<p class="m_3427816333616726356m5607108372526412337m6965542420395903681m160898050108459242code"> = VanillaReg -- pointers, unboxed ints and chars<u></u><u></u></p>
<p class="m_3427816333616726356m5607108372526412337m6965542420395903681m160898050108459242code"> Int -- its number<u></u><u></u></p>
<p class="m_3427816333616726356m5607108372526412337m6965542420395903681m160898050108459242code"> VGcPtr<u></u><u></u></p>
<p class="m_3427816333616726356m5607108372526412337m6965542420395903681m160898050108459242code"> | …<u></u><u></u></p>
<p class="m_3427816333616726356m5607108372526412337m6965542420395903681m160898050108459242code"> <u></u><u></u></p>
<p class="m_3427816333616726356m5607108372526412337m6965542420395903681m160898050108459242code">data VGcPtr = VGcPtr | VNonGcPtr
<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt">We use VanillaReg for both pointers and non-pointers, so (VanillaReg 3 VGcPtr) is register 3 used as a pointer, and (VanillaReg 3 VNonGcPtr) is register
3 used as a non-pointer. And notice that globalRegType looks at this field to decide what type to return.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt">I think you can do exactly the same: add a field to Xmm that explains how you are gong to divide it up. Would that work?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Simon</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> ghc-devs <<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">ghc-devs-bounces@haskell.org</a>>
<b>On Behalf Of </b>Abhiroop Sarkar<br>
<b>Sent:</b> 27 June 2018 22:32<br>
<b>To:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Is it possible to enhance the vector STG registers(Xmm, Ymm, Zmm) with more information?</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Hello all,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">I am currently working on adding support for SIMD operations to the native code generator. One of the roadblocks I faced recently was the definition of the `globalRegType` function in
"compiler/cmm/CmmExpr.hs". The `globalRegType` function maps the STG registers to the respective `CmmType` datatype.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">For Xmm, Ymm, Zmm registers the function defines globalRegType like this: <a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fghc%2Fghc%2Fblob%2Fmaster%2Fcompiler%2Fcmm%2FCmmExpr.hs%23L585-L587&data=02%7C01%7Csimonpj%40microsoft.com%7Cee2fb4d91cfc45ae307808d5e8d5d097%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636670927384457557&sdata=PRvCQNU2vMMBuI4RJHcXiuy2vHdf9oK5IyzLq%2BroAvA%3D&reserved=0" target="_blank">https://github.com/ghc/ghc/blob/master/compiler/cmm/CmmExpr.hs#L585-L587</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Consider the case for an Xmm register, the above definition limits an Xmm register to hold only vectors of size 4. However we can store 2 64-bit Doubles or 16 Int8s or 8 Int16s and so
on<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">The function `globalRegType` is internally called by the function `cmmRegType` (<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fghc%2Fghc%2Fblob%2F838b69032566ce6ab3918d70e8d5e098d0bcee02%2Fcompiler%2Fcmm%2FCmmExpr.hs%23L275&data=02%7C01%7Csimonpj%40microsoft.com%7Cee2fb4d91cfc45ae307808d5e8d5d097%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636670927384457557&sdata=uPI1WMQzitwsatfNc5XvO7DpunpziVtE75R3maBVAz4%3D&reserved=0" target="_blank">https://github.com/ghc/ghc/blob/838b69032566ce6ab3918d70e8d5e098d0bcee02/compiler/cmm/CmmExpr.hs#L275</a>)
which is itself used in a number of places in the x86 code generator.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">In fact depending on the result of the `cmmRegType` function is another important function `cmmTypeFormat` defined in Format.hs whose result is used to print the actual assembly instruction.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">I have extended all the other Format types to include VectorFormats, however this definition of the `globalRegType` seems incorrect to me. Looking at the signature of the function itself:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">`globalRegType :: DynFlags -> GlobalReg -> CmmType`<br>
<br>
its actually difficult to predict the CmmType by just looking at the GlobalReg in case of Xmm, Ymm, Zmm. So thats why my original question how do I go about solving this. Should I modify the GlobalReg type to contain more information like Width and Length(for
Xmm, Ymm, Zmm) or do I somehow pass the length and width information to the globalRegType function?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Thanks<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Abhiroop Sakar<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">--
<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">Kloona - Coming Soon!<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">Kloona - Coming Soon!<u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">Kloona - Coming Soon!<u></u><u></u></p>
</div>
</div>
</div></div></div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div></div>