<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 14 (filtered medium)"><style><!--
/* Font Definitions */
@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:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
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";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>I’m looking at an issue where we want a particular pseudo-instruction to choose from a set of registers that is not included in the existing set of RegisterClass definitions. More concretely, there is a RegisterClass in <span style='font-family:"Courier New"'>ARMRegisterInfo.td</span> defined as<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-family:"Courier New"'>def rGPR : RegisterClass<"ARM", [i32], 32, (sub GPR, SP, PC)> {<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'>  let AltOrders = [(add LR, rGPR), (trunc rGPR, 8)];<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'>  let AltOrderSelect = [{<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'>      return 1 + MF.getTarget().getSubtarget<ARMSubtarget>().isThumb1Only();<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'>  }];<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>However, I’d like the instruction NOT to use the LR. I don’t see an existing RegisterClass defined with R0_R12;  something like:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-family:"Courier New"'>def newGPR : RegisterClass<"ARM", [i32], 32, (add (sequence "R%u", 0, 12))>;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal>I can add this new RegisterClass myself and then modify the pseudo-instruction definition to simply use my new RegisterClass. However, TableGen creates a set of dynamically created classes for GPRPairs that hold all the various incarnations of GPRPair sets that correspond to various RegisterClass definitions (like GPR pairs just for R0-R7, another for rGPR that doesn’t contain the SP, …). <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If I add a new RegisterClass however, the dynamically created GPRPair class corresponding to this new RegisterClass overlaps with the dynamically created class for rGPR. In Thumb2InstrInfo.cpp, the dynamically created TargetRegisterClass GPRPair_with_gsub_1_in_rGPRRegClass is explicitly called out. If I add my new class, the class GPRPair_with_gsub_1_in_rGPRRegClass is never created, instead the class GPRPair_with_gsub_1_in_newGPRRegClass is created. Compilation therefore fails. I could simply rename the RegisterClass so that it is alphabetically sorted after rGPR, but that seems to simply be avoiding the real issue.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>So, since I’m fairly new to LLVM, my question is, am I approaching this correctly? Is adding a new RegisterClass something that is highly discouraged? Is it better to force certain instructions to avoid certain registers in the register allocation process? Should explicit references to dynamically generated classes be done? <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal>Daniel<o:p></o:p></p></div></body></html>