diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -67,7 +67,9 @@ MLIRContext *getContext() const; /// Get the dialect this attribute is registered to. - Dialect &getDialect() const; + Dialect &getDialect() const { + return impl->getAbstractAttribute().getDialect(); + } /// Print the attribute. void print(raw_ostream &os) const; diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -96,11 +96,11 @@ Block *getBlock() { return block; } /// Return the context this operation is associated with. - MLIRContext *getContext(); + MLIRContext *getContext() { return location->getContext(); } /// Return the dialect this operation is associated with, or nullptr if the /// associated dialect is not registered. - Dialect *getDialect(); + Dialect *getDialect() { return getName().getDialect(); } /// The source location the operation was defined or derived from. Location getLoc() { return location; } @@ -110,11 +110,11 @@ /// Returns the region to which the instruction belongs. Returns nullptr if /// the instruction is unlinked. - Region *getParentRegion(); + Region *getParentRegion() { return block ? block->getParent() : nullptr; } /// Returns the closest surrounding operation that contains this operation /// or nullptr if this is a top-level operation. - Operation *getParentOp(); + Operation *getParentOp() { return block ? block->getParentOp() : nullptr; } /// Return the closest surrounding parent operation that is of type 'OpTy'. template OpTy getParentOfType() { diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h --- a/mlir/include/mlir/IR/Region.h +++ b/mlir/include/mlir/IR/Region.h @@ -191,7 +191,7 @@ Region *getParentRegion(); /// Return the parent operation this region is attached to. - Operation *getParentOp(); + Operation *getParentOp() { return container; } /// Find the first parent operation of the given type, or nullptr if there is /// no ancestor operation. diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h --- a/mlir/include/mlir/IR/Types.h +++ b/mlir/include/mlir/IR/Types.h @@ -111,7 +111,7 @@ MLIRContext *getContext() const; /// Get the dialect this type is registered to. - Dialect &getDialect() const; + Dialect &getDialect() const { return impl->getAbstractType().getDialect(); } // Convenience predicates. This is only for floating point types, // derived types should use isa/dyn_cast. diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp --- a/mlir/lib/IR/Attributes.cpp +++ b/mlir/lib/IR/Attributes.cpp @@ -37,11 +37,6 @@ /// Return the context this attribute belongs to. MLIRContext *Attribute::getContext() const { return getDialect().getContext(); } -/// Get the dialect this attribute is registered to. -Dialect &Attribute::getDialect() const { - return impl->getAbstractAttribute().getDialect(); -} - //===----------------------------------------------------------------------===// // NamedAttribute //===----------------------------------------------------------------------===// diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -216,21 +216,6 @@ free(rawMem); } -/// Return the context this operation is associated with. -MLIRContext *Operation::getContext() { return location->getContext(); } - -/// Return the dialect this operation is associated with, or nullptr if the -/// associated dialect is not registered. -Dialect *Operation::getDialect() { return getName().getDialect(); } - -Region *Operation::getParentRegion() { - return block ? block->getParent() : nullptr; -} - -Operation *Operation::getParentOp() { - return block ? block->getParentOp() : nullptr; -} - /// Return true if this operation is a proper ancestor of the `other` /// operation. bool Operation::isProperAncestor(Operation *other) { diff --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp --- a/mlir/lib/IR/Region.cpp +++ b/mlir/lib/IR/Region.cpp @@ -48,8 +48,6 @@ return container->getParentRegion(); } -Operation *Region::getParentOp() { return container; } - bool Region::isProperAncestor(Region *other) { if (this == other) return false; diff --git a/mlir/lib/IR/Types.cpp b/mlir/lib/IR/Types.cpp --- a/mlir/lib/IR/Types.cpp +++ b/mlir/lib/IR/Types.cpp @@ -16,10 +16,6 @@ // Type //===----------------------------------------------------------------------===// -Dialect &Type::getDialect() const { - return impl->getAbstractType().getDialect(); -} - MLIRContext *Type::getContext() const { return getDialect().getContext(); } bool Type::isBF16() const { return isa(); }