[Mlir-commits] [mlir] dea24b4 - [NFC] Switch printFunctionLikeOp and parseFunctionLikeOp to only support "inline" visibility.

Rahul Joshi llvmlistbot at llvm.org
Thu Nov 12 11:29:26 PST 2020


Author: Rahul Joshi
Date: 2020-11-12T11:29:01-08:00
New Revision: dea24b422cc2f0d912f96924787cee949579c18f

URL: https://github.com/llvm/llvm-project/commit/dea24b422cc2f0d912f96924787cee949579c18f
DIFF: https://github.com/llvm/llvm-project/commit/dea24b422cc2f0d912f96924787cee949579c18f.diff

LOG: [NFC] Switch printFunctionLikeOp and parseFunctionLikeOp to only support "inline" visibility.

- Remove the default valued arguments from these functions.
- Besides FuncOp, looks like no other in-tree op is using these functions.

Differential Revision: https://reviews.llvm.org/D91369

Added: 
    

Modified: 
    mlir/include/mlir/IR/FunctionImplementation.h
    mlir/lib/IR/Function.cpp
    mlir/lib/IR/FunctionImplementation.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/FunctionImplementation.h b/mlir/include/mlir/IR/FunctionImplementation.h
index bad32fe3df38..c19100c55219 100644
--- a/mlir/include/mlir/IR/FunctionImplementation.h
+++ b/mlir/include/mlir/IR/FunctionImplementation.h
@@ -78,23 +78,15 @@ parseFunctionSignature(OpAsmParser &parser, bool allowVariadic,
 /// whether the function is variadic.  If the builder returns a null type,
 /// `result` will not contain the `type` attribute.  The caller can then add a
 /// type, report the error or delegate the reporting to the op's verifier.
-/// If `allowInlineVisibility` is true, then the parser will allow visibility
-/// to be specified after the operation name. If the visibility is not specified
-/// there or `allowInlineVisibility` is false, visibility will be allowed in the
-/// attribute dict.
 ParseResult parseFunctionLikeOp(OpAsmParser &parser, OperationState &result,
                                 bool allowVariadic,
-                                FuncTypeBuilder funcTypeBuilder,
-                                bool allowInlineVisibility = false);
+                                FuncTypeBuilder funcTypeBuilder);
 
 /// Printer implementation for function-like operations.  Accepts lists of
-/// argument and result types to use while printing. If `printVisibilityInline`
-/// is true, visibility is printed "inline" after the operation name and elided
-/// from the attributes dict. Otherwise, it is printed in the attribute dict.
+/// argument and result types to use while printing.
 void printFunctionLikeOp(OpAsmPrinter &p, Operation *op,
                          ArrayRef<Type> argTypes, bool isVariadic,
-                         ArrayRef<Type> resultTypes,
-                         bool printVisibilityInline = false);
+                         ArrayRef<Type> resultTypes);
 
 /// Prints the signature of the function-like operation `op`.  Assumes `op` has
 /// the FunctionLike trait and passed the verification.

diff  --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp
index 2139545ddd28..03378f21f638 100644
--- a/mlir/lib/IR/Function.cpp
+++ b/mlir/lib/IR/Function.cpp
@@ -69,15 +69,13 @@ ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) {
   };
 
   return impl::parseFunctionLikeOp(parser, result, /*allowVariadic=*/false,
-                                   buildFuncType,
-                                   /*allowInlineVisibility=*/true);
+                                   buildFuncType);
 }
 
 void FuncOp::print(OpAsmPrinter &p) {
   FunctionType fnType = getType();
   impl::printFunctionLikeOp(p, *this, fnType.getInputs(), /*isVariadic=*/false,
-                            fnType.getResults(),
-                            /*printVisibilityInline=*/true);
+                            fnType.getResults());
 }
 
 LogicalResult FuncOp::verify() {

diff  --git a/mlir/lib/IR/FunctionImplementation.cpp b/mlir/lib/IR/FunctionImplementation.cpp
index a4e249338fd4..e93c91fdd342 100644
--- a/mlir/lib/IR/FunctionImplementation.cpp
+++ b/mlir/lib/IR/FunctionImplementation.cpp
@@ -159,9 +159,10 @@ void mlir::impl::addArgAndResultAttrs(Builder &builder, OperationState &result,
 
 /// Parser implementation for function-like operations.  Uses `funcTypeBuilder`
 /// to construct the custom function type given lists of input and output types.
-ParseResult mlir::impl::parseFunctionLikeOp(
-    OpAsmParser &parser, OperationState &result, bool allowVariadic,
-    mlir::impl::FuncTypeBuilder funcTypeBuilder, bool allowInlineVisibility) {
+ParseResult
+mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, OperationState &result,
+                                bool allowVariadic,
+                                mlir::impl::FuncTypeBuilder funcTypeBuilder) {
   SmallVector<OpAsmParser::OperandType, 4> entryArgs;
   SmallVector<NamedAttrList, 4> argAttrs;
   SmallVector<NamedAttrList, 4> resultAttrs;
@@ -169,9 +170,8 @@ ParseResult mlir::impl::parseFunctionLikeOp(
   SmallVector<Type, 4> resultTypes;
   auto &builder = parser.getBuilder();
 
-  // Parse visibility if inline visibility is allowed.
-  if (allowInlineVisibility)
-    impl::parseOptionalVisibilityKeyword(parser, result.attributes);
+  // Parse visibility.
+  impl::parseOptionalVisibilityKeyword(parser, result.attributes);
 
   // Parse the name as a symbol.
   StringAttr nameAttr;
@@ -306,24 +306,21 @@ void mlir::impl::printFunctionAttributes(OpAsmPrinter &p, Operation *op,
 /// argument and result types to use while printing.
 void mlir::impl::printFunctionLikeOp(OpAsmPrinter &p, Operation *op,
                                      ArrayRef<Type> argTypes, bool isVariadic,
-                                     ArrayRef<Type> resultTypes,
-                                     bool printVisibilityInline) {
+                                     ArrayRef<Type> resultTypes) {
   // Print the operation and the function name.
   auto funcName =
       op->getAttrOfType<StringAttr>(SymbolTable::getSymbolAttrName())
           .getValue();
   p << op->getName() << ' ';
-  StringRef elidedAttr;
-  if (printVisibilityInline) {
-    elidedAttr = SymbolTable::getVisibilityAttrName();
-    if (auto visibility = op->getAttrOfType<StringAttr>(elidedAttr))
-      p << visibility.getValue() << ' ';
-  }
+
+  StringRef visibilityAttrName = SymbolTable::getVisibilityAttrName();
+  if (auto visibility = op->getAttrOfType<StringAttr>(visibilityAttrName))
+    p << visibility.getValue() << ' ';
   p.printSymbolName(funcName);
 
   printFunctionSignature(p, op, argTypes, isVariadic, resultTypes);
   printFunctionAttributes(p, op, argTypes.size(), resultTypes.size(),
-                          {elidedAttr});
+                          {visibilityAttrName});
   // Print the body if this is not an external function.
   Region &body = op->getRegion(0);
   if (!body.empty())


        


More information about the Mlir-commits mailing list