[mlir][Complex] Add a convenience getValue() method.
authorAdrian Kuegel <akuegel@google.com>
Fri, 29 Jul 2022 13:17:57 +0000 (15:17 +0200)
committerAdrian Kuegel <akuegel@google.com>
Fri, 29 Jul 2022 13:35:39 +0000 (15:35 +0200)
This method returns the value as std::complex<APFloat>

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

mlir/include/mlir/Dialect/Complex/IR/ComplexAttributes.td

index ab6074e..afae94c 100644 (file)
@@ -53,6 +53,12 @@ def Complex_NumberAttr : Complex_Attr<"Number", "number"> {
     }]>
   ];
 
+  let extraClassDeclaration = [{
+    std::complex<APFloat> getValue() {
+      return std::complex<APFloat>(getReal(), getImag());
+    }
+  }];
+
   let genVerifyDecl = 1;
   let hasCustomAssemblyFormat = 1;
   let skipDefaultBuilders = 1;