[Mlir-commits] [mlir] 824954a - [mlir] Small stylistic changes to Complex_NumberAttr

Alexander Belyaev llvmlistbot at llvm.org
Thu Jul 28 02:00:01 PDT 2022


Author: Alexander Belyaev
Date: 2022-07-28T10:59:52+02:00
New Revision: 824954a8c9c30b9e7c281e3c06d3d00eecbc9934

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

LOG: [mlir] Small stylistic changes to Complex_NumberAttr

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

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Complex/IR/ComplexAttributes.td
    mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Complex/IR/ComplexAttributes.td b/mlir/include/mlir/Dialect/Complex/IR/ComplexAttributes.td
index b387718ceab0f..c5e099a83719c 100644
--- a/mlir/include/mlir/Dialect/Complex/IR/ComplexAttributes.td
+++ b/mlir/include/mlir/Dialect/Complex/IR/ComplexAttributes.td
@@ -34,8 +34,9 @@ def Complex_NumberAttr : Complex_Attr<"Number", "number"> {
     ```
   }];
 
-  let parameters = (ins APFloatParameter<"">:$real, APFloatParameter<"">:$imag, AttributeSelfTypeParameter<"">:$type);
-
+  let parameters = (ins APFloatParameter<"">:$real,
+                        APFloatParameter<"">:$imag,
+                        AttributeSelfTypeParameter<"">:$type);
   let genVerifyDecl = 1;
   let hasCustomAssemblyFormat = 1;
 }

diff  --git a/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp b/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp
index 60ffd1919efe4..697fe7057f218 100644
--- a/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp
+++ b/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp
@@ -64,47 +64,23 @@ LogicalResult complex::NumberAttr::verify(
 }
 
 void complex::NumberAttr::print(AsmPrinter &printer) const {
-  printer << "<:";
-  printer.printType(getType());
-  printer << " ";
-  printer.printFloat(getReal());
-  printer << ", ";
-  printer.printFloat(getImag());
-  printer << ">";
+  printer << "<:" << getType() << " " << getReal() << ", " << getImag() << ">";
 }
 
 Attribute complex::NumberAttr::parse(AsmParser &parser, Type odsType) {
-  if (failed(parser.parseLess()))
-    return {};
-
-  if (failed(parser.parseColon()))
-    return {};
-
   Type type;
-  if (failed(parser.parseType(type)))
-    return {};
-
-  double real;
-  if (failed(parser.parseFloat(real)))
-    return {};
-
-  if (failed(parser.parseComma()))
-    return {};
-
-  double imag;
-  if (failed(parser.parseFloat(imag)))
-    return {};
-
-  if (failed(parser.parseGreater()))
+  double real, imag;
+  if (parser.parseLess() || parser.parseColon() || parser.parseType(type) ||
+      parser.parseFloat(real) || parser.parseComma() ||
+      parser.parseFloat(imag) || parser.parseGreater())
     return {};
 
   bool unused = false;
-  auto realFloat = APFloat(real);
+  APFloat realFloat(real);
   realFloat.convert(type.cast<FloatType>().getFloatSemantics(),
                     APFloat::rmNearestTiesToEven, &unused);
-  auto imagFloat = APFloat(imag);
+  APFloat imagFloat(imag);
   imagFloat.convert(type.cast<FloatType>().getFloatSemantics(),
                     APFloat::rmNearestTiesToEven, &unused);
-
   return NumberAttr::get(parser.getContext(), realFloat, imagFloat, type);
 }


        


More information about the Mlir-commits mailing list