<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="NL" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi all,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US">Can anyone explain how the order of the registers in XXXGenRegisterInfo.inc is determined?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">E.g. for RISCV:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">namespace RISCV {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">enum {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">  NoRegister,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> X0 = 1,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">  X1 = 2,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">  // (…)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">  F31_F = 96,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">  NUM_TARGET_REGS // 97<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">};<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">}<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">How does this relate to the content of the XXXRegisterInfo.td file? It seems like the enum is generated with the same ordering as the register records appear when running llvm-tblgen.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I have shuffled with my definitions but don’t seem to be able to influence this order.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US">Root issue:<o:p></o:p></span></b></p>
<p class="MsoNormal"><span lang="EN-US">My architecture has specific registers for constants, a separate register class. I run a pre-regalloc allocator to allocate constants to registers from that class (because they need to be persistent and not be reused
 etc).<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I can simply ‘MO.setReg(constRegId++)’ in my allocator but then I would need to know the number of the register, which apparently is not the same as the one defined in my XXXRegisterInfo.td file:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">foreach regid = 447-510 in {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">  def C#regid : XXXConstReg<regid, "c"#regid, ["c"#regid]>, DwarfRegNum<[regid]>;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">}<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">If there is a way to get the register range for a certain register class such that I can allocate machine operands to a physical register in that class, then that would solve my issue.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Mvg Simon de Vegt<o:p></o:p></span></p>
</div>
</body>
</html>