[NFC] Switch printFunctionLikeOp and parseFunctionLikeOp to only support "inline...
authorRahul Joshi <jurahul@google.com>
Thu, 12 Nov 2020 18:46:44 +0000 (10:46 -0800)
committerRahul Joshi <jurahul@google.com>
Thu, 12 Nov 2020 19:29:01 +0000 (11:29 -0800)
- 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

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

index bad32fe..c19100c 100644 (file)
@@ -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.
index 2139545..03378f2 100644 (file)
@@ -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() {
index a4e2493..e93c91f 100644 (file)
@@ -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())