[PATCH] D114063: [fir] Add fir.constc conversion

Andrzej Warzynski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 17 00:43:17 PST 2021


awarzynski added inline comments.


================
Comment at: flang/lib/Optimizer/CodeGen/CodeGen.cpp:569
 
+struct ConstcOpConversion : public FIROpConversion<fir::ConstcOp> {
+  using FIROpConversion::FIROpConversion;
----------------
Could you add a short comment for this struct? 


================
Comment at: flang/lib/Optimizer/CodeGen/CodeGen.cpp:579-586
+    auto ri = mlir::FloatAttr::get(ety, getValue(conc.getReal()));
+    auto rp = rewriter.create<mlir::LLVM::ConstantOp>(loc, ety, ri);
+    auto ii = mlir::FloatAttr::get(ety, getValue(conc.getImaginary()));
+    auto ip = rewriter.create<mlir::LLVM::ConstantOp>(loc, ety, ii);
+    auto c0 = mlir::ArrayAttr::get(ctx, rewriter.getI32IntegerAttr(0));
+    auto c1 = mlir::ArrayAttr::get(ctx, rewriter.getI32IntegerAttr(1));
+    auto r = rewriter.create<mlir::LLVM::UndefOp>(loc, ty);
----------------
It would really help me to understand the logic here if the names were more descriptive :)  For example, what's `ri` and `ii`? And what's the difference between `r` and `rr`?


================
Comment at: flang/test/Fir/convert-to-llvm.fir:696
+func @test_constc() -> !fir.complex<4> {
+  %0 = fir.constc (#fir.real<4, 1.4>, #fir.real<4, 2.3>) : !fir.complex<4>
+  return %0 : !fir.complex<4>
----------------
[nit] How  about different KIND?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114063/new/

https://reviews.llvm.org/D114063



More information about the llvm-commits mailing list