Tom Stellard
2011-Oct-26 20:24 UTC
[LLVMdev] 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
David A. Greene
2011-Nov-01 18:51 UTC
[LLVMdev] Tablegen generic class argument that accepts SDNode or Intrinsic
Tom Stellard <thomas.stellard at 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
Possibly Parallel Threads
- [LLVMdev] LLVM Backend DAGToDAGISel INTRINSIC
- [LLVMdev] Difficulty with reusing DAG nodes.
- [LLVMdev] Illegal optimization in LLVM 2.8 during SelectionDAG? (Re: comparison pattern trouble - might be a bug in LLVM 2.8?)
- [LLVMdev] comparison pattern trouble - might be a bug in LLVM 2.8?
- [LLVMdev] comparison pattern trouble - might be a bug in LLVM 2.8?