[Mlir-commits] [mlir] da93829 - [DialectAsmPrinter] Add missing 'printAttributeWithoutType' member.

Chris Lattner llvmlistbot at llvm.org
Tue Sep 21 18:45:32 PDT 2021


Author: Chris Lattner
Date: 2021-09-21T18:45:24-07:00
New Revision: da93829b441525fd82a23c710290328907dde756

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

LOG: [DialectAsmPrinter] Add missing 'printAttributeWithoutType' member.

DialectAsmParser has a `parseAttribute` member that takes a
contextual type, but DialectAsmPrinter doesn't have the corresponding
member to take advantage of it.  As such, custom attribute
implementations can't really use it.  This adds the obvious missing
method which fills this hole.

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

Added: 
    

Modified: 
    mlir/include/mlir/IR/DialectImplementation.h
    mlir/lib/IR/AsmPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h
index 1e4b7bb04ebf9..2d19f693d08c4 100644
--- a/mlir/include/mlir/IR/DialectImplementation.h
+++ b/mlir/include/mlir/IR/DialectImplementation.h
@@ -39,6 +39,10 @@ class DialectAsmPrinter {
   /// Print the given attribute to the stream.
   virtual void printAttribute(Attribute attr) = 0;
 
+  /// Print the given attribute without its type. The corresponding parser must
+  /// provide a valid type for the attribute.
+  virtual void printAttributeWithoutType(Attribute attr) = 0;
+
   /// Print the given floating point value in a stabilized form that can be
   /// roundtripped through the IR. This is the companion to the 'parseFloat'
   /// hook on the DialectAsmParser.

diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index f3b69ae85182e..7a90804cd047c 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -2055,6 +2055,12 @@ struct CustomDialectAsmPrinter : public DialectAsmPrinter {
   /// Print the given attribute to the stream.
   void printAttribute(Attribute attr) override { printer.printAttribute(attr); }
 
+  /// Print the given attribute without its type. The corresponding parser must
+  /// provide a valid type for the attribute.
+  void printAttributeWithoutType(Attribute attr) override {
+    printer.printAttribute(attr, ModulePrinter::AttrTypeElision::Must);
+  }
+
   /// Print the given floating point value in a stablized form.
   void printFloat(const APFloat &value) override {
     printFloatValue(value, getStream());


        


More information about the Mlir-commits mailing list