[flang-commits] [flang] 6592301 - [flang] Revert changes (NFC)

Jeff Niu via flang-commits flang-commits at lists.llvm.org
Tue Aug 9 13:10:35 PDT 2022


Author: Jeff Niu
Date: 2022-08-09T16:10:21-04:00
New Revision: 65923012b3d15890876458e5448ebaf3157d34d0

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

LOG: [flang] Revert changes (NFC)

Added: 
    

Modified: 
    flang/lib/Optimizer/CodeGen/CodeGen.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index b622203522412..ed4b71b13fe68 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -53,7 +53,8 @@ static mlir::LLVM::ConstantOp
 genConstantIndex(mlir::Location loc, mlir::Type ity,
                  mlir::ConversionPatternRewriter &rewriter,
                  std::int64_t offset) {
-  return rewriter.create<mlir::LLVM::ConstantOp>(loc, ity, offset);
+  auto cattr = rewriter.getI64IntegerAttr(offset);
+  return rewriter.create<mlir::LLVM::ConstantOp>(loc, ity, cattr);
 }
 
 static mlir::Block *createBlock(mlir::ConversionPatternRewriter &rewriter,
@@ -101,7 +102,8 @@ class FIROpConversion : public mlir::ConvertOpToLLVMPattern<FromOp> {
   genI32Constant(mlir::Location loc, mlir::ConversionPatternRewriter &rewriter,
                  int value) const {
     mlir::Type i32Ty = rewriter.getI32Type();
-    return rewriter.create<mlir::LLVM::ConstantOp>(loc, i32Ty, value);
+    mlir::IntegerAttr attr = rewriter.getI32IntegerAttr(value);
+    return rewriter.create<mlir::LLVM::ConstantOp>(loc, i32Ty, attr);
   }
 
   mlir::LLVM::ConstantOp
@@ -109,7 +111,8 @@ class FIROpConversion : public mlir::ConvertOpToLLVMPattern<FromOp> {
                     mlir::ConversionPatternRewriter &rewriter,
                     int offset) const {
     mlir::Type ity = lowerTy().offsetType();
-    return rewriter.create<mlir::LLVM::ConstantOp>(loc, ity, offset);
+    mlir::IntegerAttr cattr = rewriter.getI32IntegerAttr(offset);
+    return rewriter.create<mlir::LLVM::ConstantOp>(loc, ity, cattr);
   }
 
   /// Perform an extension or truncation as needed on an integer value. Lowering
@@ -627,11 +630,13 @@ struct StringLitOpConversion : public FIROpConversion<fir::StringLitOp> {
     if (auto arr = attr.dyn_cast<mlir::DenseElementsAttr>()) {
       cst = rewriter.create<mlir::LLVM::ConstantOp>(loc, ty, arr);
     } else if (auto arr = attr.dyn_cast<mlir::ArrayAttr>()) {
-      for (auto &a :
-           llvm::enumerate(arr.getAsValueRange<mlir::IntegerAttr>())) {
+      for (auto a : llvm::enumerate(arr.getValue())) {
         // convert each character to a precise bitsize
-        auto elemCst = rewriter.create<mlir::LLVM::ConstantOp>(
-            loc, intTy, a.value().zextOrTrunc(bits));
+        auto elemAttr = mlir::IntegerAttr::get(
+            intTy,
+            a.value().cast<mlir::IntegerAttr>().getValue().zextOrTrunc(bits));
+        auto elemCst =
+            rewriter.create<mlir::LLVM::ConstantOp>(loc, intTy, elemAttr);
         auto index = mlir::ArrayAttr::get(
             constop.getContext(), rewriter.getI32IntegerAttr(a.index()));
         cst = rewriter.create<mlir::LLVM::InsertValueOp>(loc, ty, cst, elemCst,
@@ -728,10 +733,12 @@ struct ConstcOpConversion : public FIROpConversion<fir::ConstcOp> {
     mlir::MLIRContext *ctx = conc.getContext();
     mlir::Type ty = convertType(conc.getType());
     mlir::Type ety = convertType(getComplexEleTy(conc.getType()));
-    auto realPart = rewriter.create<mlir::LLVM::ConstantOp>(
-        loc, ety, getValue(conc.getReal()));
-    auto imPart = rewriter.create<mlir::LLVM::ConstantOp>(
-        loc, ety, getValue(conc.getImaginary()));
+    auto realFloatAttr = mlir::FloatAttr::get(ety, getValue(conc.getReal()));
+    auto realPart =
+        rewriter.create<mlir::LLVM::ConstantOp>(loc, ety, realFloatAttr);
+    auto imFloatAttr = mlir::FloatAttr::get(ety, getValue(conc.getImaginary()));
+    auto imPart =
+        rewriter.create<mlir::LLVM::ConstantOp>(loc, ety, imFloatAttr);
     auto realIndex = mlir::ArrayAttr::get(ctx, rewriter.getI32IntegerAttr(0));
     auto imIndex = mlir::ArrayAttr::get(ctx, rewriter.getI32IntegerAttr(1));
     auto undef = rewriter.create<mlir::LLVM::UndefOp>(loc, ty);


        


More information about the flang-commits mailing list