[flang-commits] [flang] 575c9d6 - [flang][NFC] Fix some formatting
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Wed Jun 15 07:49:08 PDT 2022
Author: Valentin Clement
Date: 2022-06-15T16:49:02+02:00
New Revision: 575c9d6d4a20dd272113f9aa2f9e601d297b79b1
URL: https://github.com/llvm/llvm-project/commit/575c9d6d4a20dd272113f9aa2f9e601d297b79b1
DIFF: https://github.com/llvm/llvm-project/commit/575c9d6d4a20dd272113f9aa2f9e601d297b79b1.diff
LOG: [flang][NFC] Fix some formatting
Fix some mismatch in format used in the file and reduce the diff with fir-dev
to be able to finish the upstreaming on this file.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: PeteSteinfeld, kiranchandramohan
Differential Revision: https://reviews.llvm.org/D127849
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 aca8f96a37f9c..c5c14414041ad 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -246,7 +246,7 @@ class FIROpConversion : public mlir::ConvertOpToLLVMPattern<FromOp> {
mlir::LLVM::GEPOp genGEP(mlir::Location loc, mlir::Type ty,
mlir::ConversionPatternRewriter &rewriter,
mlir::Value base, ARGS... args) const {
- llvm::SmallVector<mlir::Value> cv{args...};
+ llvm::SmallVector<mlir::Value> cv = {args...};
return rewriter.create<mlir::LLVM::GEPOp>(loc, ty, base, cv);
}
@@ -275,8 +275,10 @@ class FIROpAndTypeConversion : public FIROpConversion<FromOp> {
doRewrite(FromOp addr, mlir::Type ty, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const = 0;
};
+} // namespace
-// Lower `fir.address_of` operation to `llvm.address_of` operation.
+namespace {
+/// Lower `fir.address_of` operation to `llvm.address_of` operation.
struct AddrOfOpConversion : public FIROpConversion<fir::AddrOfOp> {
using FIROpConversion::FIROpConversion;
@@ -299,7 +301,9 @@ getDependentTypeMemSizeFn(fir::RecordType recTy, fir::AllocaOp op,
mlir::ConversionPatternRewriter &rewriter) {
auto module = op->getParentOfType<mlir::ModuleOp>();
std::string name = recTy.getName().str() + "P.mem.size";
- return module.lookupSymbol<mlir::LLVM::LLVMFuncOp>(name);
+ if (auto memSizeFunc = module.lookupSymbol<mlir::LLVM::LLVMFuncOp>(name))
+ return memSizeFunc;
+ TODO(op.getLoc(), "did not find allocation function");
}
// Compute the alloc scale size (constant factors encoded in the array type).
@@ -366,8 +370,7 @@ struct AllocaOpConversion : public FIROpConversion<fir::AllocaOp> {
auto call = rewriter.create<mlir::LLVM::CallOp>(
loc, ity, lenParams, llvm::ArrayRef<mlir::NamedAttribute>{attr});
size = call.getResult(0);
- ty = mlir::LLVM::LLVMPointerType::get(
- mlir::IntegerType::get(alloc.getContext(), 8));
+ ty = ::getVoidPtrType(alloc.getContext());
} else {
return emitError(loc, "unexpected type ")
<< scalarType << " with type parameters";
@@ -637,7 +640,7 @@ struct StringLitOpConversion : public FIROpConversion<fir::StringLitOp> {
}
};
-// `fir.call` -> `llvm.call`
+/// `fir.call` -> `llvm.call`
struct CallOpConversion : public FIROpConversion<fir::CallOp> {
using FIROpConversion::FIROpConversion;
@@ -678,7 +681,7 @@ struct CmpcOpConversion : public FIROpConversion<fir::CmpcOp> {
mlir::Type resTy = convertType(cmp.getType());
mlir::Location loc = cmp.getLoc();
auto pos0 = mlir::ArrayAttr::get(ctxt, rewriter.getI32IntegerAttr(0));
- llvm::SmallVector<mlir::Value, 2> rp{
+ llvm::SmallVector<mlir::Value, 2> rp = {
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, eleTy, operands[0],
pos0),
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, eleTy, operands[1],
@@ -686,14 +689,14 @@ struct CmpcOpConversion : public FIROpConversion<fir::CmpcOp> {
auto rcp =
rewriter.create<mlir::LLVM::FCmpOp>(loc, resTy, rp, cmp->getAttrs());
auto pos1 = mlir::ArrayAttr::get(ctxt, rewriter.getI32IntegerAttr(1));
- llvm::SmallVector<mlir::Value, 2> ip{
+ llvm::SmallVector<mlir::Value, 2> ip = {
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, eleTy, operands[0],
pos1),
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, eleTy, operands[1],
pos1)};
auto icp =
rewriter.create<mlir::LLVM::FCmpOp>(loc, resTy, ip, cmp->getAttrs());
- llvm::SmallVector<mlir::Value, 2> cp{rcp, icp};
+ llvm::SmallVector<mlir::Value, 2> cp = {rcp, icp};
switch (cmp.getPredicate()) {
case mlir::arith::CmpFPredicate::OEQ: // .EQ.
rewriter.replaceOpWithNewOp<mlir::LLVM::AndOp>(cmp, resTy, cp);
@@ -992,7 +995,7 @@ computeDerivedTypeSize(mlir::Location loc, mlir::Type ptrTy, mlir::Type idxTy,
mlir::ConversionPatternRewriter &rewriter) {
auto nullPtr = rewriter.create<mlir::LLVM::NullOp>(loc, ptrTy);
mlir::Value one = genConstantIndex(loc, idxTy, rewriter, 1);
- llvm::SmallVector<mlir::Value> args{one};
+ llvm::SmallVector<mlir::Value> args = {one};
auto gep = rewriter.create<mlir::LLVM::GEPOp>(loc, ptrTy, nullPtr, args);
return rewriter.create<mlir::LLVM::PtrToIntOp>(loc, idxTy, gep);
}
@@ -1005,12 +1008,12 @@ struct AllocMemOpConversion : public FIROpConversion<fir::AllocMemOp> {
mlir::LogicalResult
matchAndRewrite(fir::AllocMemOp heap, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const override {
- auto heapTy = heap.getType();
- auto ty = convertType(heapTy);
+ mlir::Type heapTy = heap.getType();
+ mlir::Type ty = convertType(heapTy);
mlir::LLVM::LLVMFuncOp mallocFunc = getMalloc(heap, rewriter);
mlir::Location loc = heap.getLoc();
auto ity = lowerTy().indexType();
- auto dataTy = fir::unwrapRefType(heapTy);
+ mlir::Type dataTy = fir::unwrapRefType(heapTy);
if (fir::isRecordWithTypeParameters(fir::unwrapSequenceType(dataTy)))
TODO(loc, "fir.allocmem codegen of derived type with length parameters");
mlir::Value size = genTypeSizeInBytes(loc, ity, rewriter, ty);
@@ -1080,8 +1083,6 @@ struct FreeMemOpConversion : public FIROpConversion<fir::FreeMemOp> {
};
} // namespace
-namespace {} // namespace
-
/// Common base class for embox to descriptor conversion.
template <typename OP>
struct EmboxCommonConversion : public FIROpConversion<OP> {
@@ -1130,7 +1131,7 @@ struct EmboxCommonConversion : public FIROpConversion<OP> {
return recTy && recTy.getNumLenParams() > 0;
}
static bool isDerivedType(fir::BoxType boxTy) {
- return unwrapIfDerived(boxTy) != nullptr;
+ return static_cast<bool>(unwrapIfDerived(boxTy));
}
// Get the element size and CFI type code of the boxed value.
@@ -2000,8 +2001,8 @@ struct InsertOnRangeOpConversion
type = t.getElementType();
}
- llvm::SmallVector<uint64_t> lBounds;
- llvm::SmallVector<uint64_t> uBounds;
+ llvm::SmallVector<std::uint64_t> lBounds;
+ llvm::SmallVector<std::uint64_t> uBounds;
// Unzip the upper and lower bound and convert to a row major format.
mlir::DenseIntElementsAttr coor = range.getCoor();
@@ -2391,7 +2392,7 @@ struct CoordinateOpConversion
}
auto voidPtrBase =
rewriter.create<mlir::LLVM::BitcastOp>(loc, voidPtrTy, resultAddr);
- llvm::SmallVector<mlir::Value> args{off};
+ llvm::SmallVector<mlir::Value> args = {off};
resultAddr = rewriter.create<mlir::LLVM::GEPOp>(loc, voidPtrTy,
voidPtrBase, args);
i += arrTy.getDimension() - 1;
@@ -2618,7 +2619,7 @@ struct GlobalOpConversion : public FIROpConversion<fir::GlobalOp> {
if (global.getType().isa<fir::BoxType>())
tyAttr = tyAttr.cast<mlir::LLVM::LLVMPointerType>().getElementType();
auto loc = global.getLoc();
- mlir::Attribute initAttr{};
+ mlir::Attribute initAttr;
if (global.getInitVal())
initAttr = global.getInitVal().getValue();
auto linkage = convertLinkage(global.getLinkName());
@@ -3321,8 +3322,6 @@ namespace {
///
/// This pass lowers all FIR dialect operations to LLVM IR dialect. An
/// MLIR pass is used to lower residual Std dialect to LLVM IR dialect.
-///
-/// This pass is not complete yet. We are upstreaming it in small patches.
class FIRToLLVMLowering : public fir::FIRToLLVMLoweringBase<FIRToLLVMLowering> {
public:
FIRToLLVMLowering() = default;
More information about the flang-commits
mailing list