class one { int i = 0; } class two { int i = 1; } class multiple: one, two; This causes the first i to be ignored and the second i to replace it. This is a useful property if you want to specialize classes. But I don't know if it was intended to work that way or not. For example, if you have an instruction class with no patterns, you can merge it with one that defines the pattern and maybe other instruction components by building a derived class. Anybody know if this is intended behavior in tablegen?
Seems to just be a byproduct of TGParser::AddSubClass() begin called twice. This means that TGParser::AddValue() is being called once for the "i" of each class, and the "last one wins". Not sure if it is intended, but this behavior seems to more-or-less "make sense". --Sean Silva On Mon, Jul 2, 2012 at 4:55 PM, reed kotler <rkotler at mips.com> wrote:> class one { > int i = 0; > } > > class two { > int i = 1; > } > > class multiple: one, two; > > This causes the first i to be ignored and the second i to replace it. > > This is a useful property if you want to specialize classes. > > But I don't know if it was intended to work that way or not. > > For example, if you have an instruction class with no patterns, you can > merge it with one that defines the pattern and maybe other instruction > components by building a derived class. > > Anybody know if this is intended behavior in tablegen? > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Whether originally intended or not, existing targets use/exploit/abuse (depending on your perspective) this behavior quite a bit. -Jim On Jul 2, 2012, at 8:59 PM, Sean Silva <silvas at purdue.edu> wrote:> Seems to just be a byproduct of TGParser::AddSubClass() begin called > twice. This means that TGParser::AddValue() is being called once for > the "i" of each class, and the "last one wins". > > Not sure if it is intended, but this behavior seems to more-or-less > "make sense". > > --Sean Silva > > On Mon, Jul 2, 2012 at 4:55 PM, reed kotler <rkotler at mips.com> wrote: >> class one { >> int i = 0; >> } >> >> class two { >> int i = 1; >> } >> >> class multiple: one, two; >> >> This causes the first i to be ignored and the second i to replace it. >> >> This is a useful property if you want to specialize classes. >> >> But I don't know if it was intended to work that way or not. >> >> For example, if you have an instruction class with no patterns, you can >> merge it with one that defines the pattern and maybe other instruction >> components by building a derived class. >> >> Anybody know if this is intended behavior in tablegen? >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev