forked from OSchip/llvm-project
Add a utility function to Op that allows for checking if an operation has a specific trait.
PiperOrigin-RevId: 251489498
This commit is contained in:
parent
9b4a02c1e9
commit
11d18a4a5e
|
@ -749,6 +749,13 @@ class Op : public OpState,
|
|||
typelist_contains<OpTrait::OneResult<ConcreteType>, OpState,
|
||||
Traits<ConcreteType>...>::value> {
|
||||
public:
|
||||
/// Return if this operation contains the provided trait.
|
||||
template <template <typename T> class Trait>
|
||||
static constexpr bool hasTrait() {
|
||||
return typelist_contains<Trait<ConcreteType>, OpState,
|
||||
Traits<ConcreteType>...>::value;
|
||||
}
|
||||
|
||||
/// Return the operation that this refers to.
|
||||
Operation *getOperation() { return OpState::getOperation(); }
|
||||
|
||||
|
|
Loading…
Reference in New Issue