Tablegen generic class argument that accepts SDNode or Intrinsic

Hi,

I'm trying to define a class in tablegen that can have either an SDNode
or an Intrinsic as an argument. Basically something like this:

class OP1 <Record NodeOrIntr> : Instruction {
  let pattern = [(set Reg:$dst, (NodeOrIntr Reg:$src))];
}

I haven't been able to come with a way to do this yet. Is this
something that is possible with tablegen?

Thanks,
Tom Stellard

Tom Stellard <thomas.stellard@amd.com> writes:

Hi,

I'm trying to define a class in tablegen that can have either an SDNode
or an Intrinsic as an argument. Basically something like this:

class OP1 <Record NodeOrIntr> : Instruction {
  let pattern = [(set Reg:$dst, (NodeOrIntr Reg:$src))];
}

I haven't been able to come with a way to do this yet. Is this
something that is possible with tablegen?

Usually these get split into separate patterns, one for the SDNode and
one for the Intrinsic. I don't know of a reasonable way to
programmatically substitute one for another. Probably a !cast<>() from
string is the closest but you still need to know statically what you are
casting to, so I don't think it helps much.

This is one area of redundancy I never successfully completely
eliminated, though I was able to factor it down to a small set of
pattern-containing classes which I could reuse.

                          -Dave