[llvm-dev] Pass a class as a parameter of a multidef

Roger Ferrer Ibáñez via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 11 13:18:48 PDT 2018


Hi all,

I searched the mailing list but I couldn't find anything relevant so I
thought I'd ask.

I'm adding a few instructions of an ISA that is very regular and I find
myself writing repeatedly multidefs that are only different in the classes
used inside the multidef. However, to the best of my knowledge, it is not
possible to parameterise multidefs using classes, only values.

So I have something now that looks like this.

multidef foo<things> {
  def A : ClassFoo<values_from_things>;
  def : ClassFooAlias<more_values_from_things>;
}

multidef bar<things> {
  def A : ClassBar<values_from_things>;
  def : ClassBarAlias<more_values_from_things>;
}

multidef moo<things> {
  defm FOO : foo<things>;
  defm BAR : bar<things>
}

defm QUUX : moo<things>;

And I would like to compact all the above as

multidef common<class C, class CAlias> {
   def A : C<values_from_things>;
   def  : CAlias<more_values_from_things>;
}

multidef moo {
   def FOO : common<ClassFoo, ClassFooAlias>;
   def BAR : common<ClassBar, ClassBarAlias>;
}

defm QUUX : moo<things>;

Perhaps I'm using tablegen suboptimally and there is a better approach or a
way to simulate a similar behaviour.

If not, has anyone in the past considered such generalisation? Maybe we'd
be hitting some limits of tablegen here?

Thanks a lot,

-- 
Roger Ferrer Ibáñez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181011/bfc6e687/attachment.html>


More information about the llvm-dev mailing list