[mlir][NFC] Move several small methods from .cpp to .h to allow more aggressive inlining
authorRiver Riddle <riddleriver@gmail.com>
Wed, 23 Jun 2021 00:46:29 +0000 (00:46 +0000)
committerRiver Riddle <riddleriver@gmail.com>
Wed, 23 Jun 2021 00:52:26 +0000 (00:52 +0000)
Differential Revision: https://reviews.llvm.org/D104756

mlir/include/mlir/IR/Attributes.h
mlir/include/mlir/IR/Operation.h
mlir/include/mlir/IR/Region.h
mlir/include/mlir/IR/Types.h
mlir/lib/IR/Attributes.cpp
mlir/lib/IR/Operation.cpp
mlir/lib/IR/Region.cpp
mlir/lib/IR/Types.cpp

index 590faed..2bc294b 100644 (file)
@@ -67,7 +67,9 @@ public:
   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;
index 00eb2c5..6baa799 100644 (file)
@@ -96,11 +96,11 @@ public:
   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 @@ public:
 
   /// 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 <typename OpTy> OpTy getParentOfType() {
index 720a5ae..f2a4aeb 100644 (file)
@@ -191,7 +191,7 @@ public:
   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.
index 3b714ab..a260aa5 100644 (file)
@@ -111,7 +111,7 @@ public:
   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.
index cb79aab..4cc501d 100644 (file)
@@ -37,11 +37,6 @@ Type Attribute::getType() const { return impl->getType(); }
 /// 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
 //===----------------------------------------------------------------------===//
index 74d8b44..cff6865 100644 (file)
@@ -216,21 +216,6 @@ void Operation::destroy() {
   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) {
index b2600b5..698e405 100644 (file)
@@ -48,8 +48,6 @@ Region *Region::getParentRegion() {
   return container->getParentRegion();
 }
 
-Operation *Region::getParentOp() { return container; }
-
 bool Region::isProperAncestor(Region *other) {
   if (this == other)
     return false;
index ec32f36..defe2da 100644 (file)
@@ -16,10 +16,6 @@ using namespace mlir::detail;
 // Type
 //===----------------------------------------------------------------------===//
 
-Dialect &Type::getDialect() const {
-  return impl->getAbstractType().getDialect();
-}
-
 MLIRContext *Type::getContext() const { return getDialect().getContext(); }
 
 bool Type::isBF16() const { return isa<BFloat16Type>(); }