I think the "let ... += ..." seems reasonable, but the "+Base" when inheriting seems like it is extremely error prone. Correct me if I'm wrong, but the "+Base" basically makes *all* list fields extend, which I think is a bit dangerous, since it's a "global" effect where all the inherited fields are appended, meaning that it is not effectively composable; this works OK in the case you gave, but I have doubts about its general usefulness (not that that would be out of place in TableGen, unfortunately :( ).<div>
<div><br></div><div>--Sean Silva<br><div><br><div class="gmail_quote">On Fri, Sep 14, 2012 at 5:41 PM, Akira Hatanaka <span dir="ltr"><<a href="mailto:ahatanak@gmail.com" target="_blank">ahatanak@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Please take a look at the attached patch.<br><br>I updated the BNF and added comments in the code.<div class="HOEnZb"><div class="h5">
<br><br><div class="gmail_quote">On Wed, Sep 12, 2012 at 4:58 PM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank">silvas@purdue.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If you are changing the syntax, please update the BNF in the comments.<br>
<br>
--Sean Silva<br>
<div><div><br>
On Wed, Sep 12, 2012 at 6:16 PM, Akira Hatanaka <<a href="mailto:ahatanak@gmail.com" target="_blank">ahatanak@gmail.com</a>> wrote:<br>
> The attached patch adds a construct that enables extending the base class'<br>
> lists rather than completely overwriting them.<br>
> The patch hasn't gone through extensive testing yet (other than running make<br>
> check).<br>
><br>
> The lists can be extended either with a "+=" operator in a let statement or<br>
> placing a '"+" in front of a superclass:<br>
><br>
> - Example 1:<br>
><br>
> def D0 : C1 {<br>
>   let Predicates += [P2]; // Append P2 to C1's Predicates<br>
> }<br>
><br>
> - Example 2:<br>
><br>
> def D0 : C1, +AddP1;<br>
><br>
><br>
> Using a real example, MOVi16 (in ARMInstrInfo.td) which is defined as<br>
><br>
> def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),<br>
>                  DPFrm, IIC_iMOVi,<br>
>                  "movw", "\t$Rd, $imm",<br>
>                  [(set GPR:$Rd, imm0_65535:$imm)]>,<br>
>                  Requires<[IsARM, HasV6T2]>, UnaryDP {<br>
><br>
><br>
> can be rewritten to this:<br>
><br>
> class PredHasV6T2 {<br>
>   list<Predicate> Predicates = [HasV6T2];<br>
> }<br>
><br>
> def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),<br>
>                  DPFrm, IIC_iMOVi,<br>
>                  "movw", "\t$Rd, $imm",<br>
>                  [(set GPR:$Rd, imm0_65535:$imm)]>,<br>
>                  +PredHasV6T2, UnaryDP {<br>
><br>
> Since AI1 already has "IsARM" in its predicate list, MOVi16 just has to<br>
> extend the list with [HasV6T2].<br>
><br>
><br>
> Also, I changed the last statement of ListRecTy::convertValue (in<br>
> lib/TableGen/Record.cpp) to pass the element type of the list rather than<br>
> the list type.<br>
> I would appreciate if someone could take a look at this code and tell me<br>
> whether this is correct.<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
</blockquote></div><br>
</div></div></blockquote></div><br></div></div></div>