<div dir="ltr"><div dir="ltr" class="gmail_signature"><div>Hello all,</div><div><br></div><div>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.</div><div><br></div><div>For Xmm, Ymm, Zmm registers the function defines globalRegType like this: <a href="https://github.com/ghc/ghc/blob/master/compiler/cmm/CmmExpr.hs#L585-L587">https://github.com/ghc/ghc/blob/master/compiler/cmm/CmmExpr.hs#L585-L587</a></div><div><br></div><div>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</div><div><br></div><div>The function `globalRegType` is internally called by the function `cmmRegType` (<a href="https://github.com/ghc/ghc/blob/838b69032566ce6ab3918d70e8d5e098d0bcee02/compiler/cmm/CmmExpr.hs#L275">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.</div><div><br></div><div>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.</div><div><br></div><div>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:</div><div><br></div><div>`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?</div><div><br></div><div>Thanks</div><div>Abhiroop Sakar</div></div></div>