[Mlir-commits] [mlir] Switch member calls to `isa/dyn_cast/cast/...` to free function calls. (PR #89356)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Apr 19 02:16:20 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 95ffa8a2ac1154d968c0af2d428ade541eddd828 ed7c0058e2dded63667fd6afa85c9f97462453d9 -- mlir/examples/transform/Ch4/lib/MyExtension.cpp mlir/include/mlir/Dialect/Mesh/Interfaces/ShardingInterfaceImpl.h mlir/include/mlir/Dialect/Tosa/IR/TosaOps.h mlir/include/mlir/IR/Location.h mlir/lib/CAPI/Dialect/LLVM.cpp mlir/lib/CAPI/IR/BuiltinTypes.cpp mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp mlir/lib/Conversion/ArithToAMDGPU/ArithToAMDGPU.cpp mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp mlir/lib/Dialect/Arith/Transforms/BufferizableOpInterfaceImpl.cpp mlir/lib/Dialect/Arith/Transforms/EmulateUnsupportedFloats.cpp mlir/lib/Dialect/ArmNeon/Transforms/LowerContractionToSMMLAPattern.cpp mlir/lib/Dialect/Bufferization/IR/BufferDeallocationOpInterface.cpp mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp mlir/lib/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation.cpp mlir/lib/Dialect/Complex/IR/ComplexOps.cpp mlir/lib/Dialect/ControlFlow/Transforms/BufferDeallocationOpInterfaceImpl.cpp mlir/lib/Dialect/EmitC/IR/EmitC.cpp mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp mlir/lib/Dialect/IRDL/IRDLLoading.cpp mlir/lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp mlir/lib/Dialect/LLVMIR/Transforms/TypeConsistency.cpp mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp mlir/lib/Dialect/Linalg/Transforms/ConvertToDestinationStyle.cpp mlir/lib/Dialect/Linalg/Transforms/EliminateEmptyTensors.cpp mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp mlir/lib/Dialect/MemRef/Transforms/ExpandRealloc.cpp mlir/lib/Dialect/Mesh/IR/MeshOps.cpp mlir/lib/Dialect/Mesh/Interfaces/ShardingInterface.cpp mlir/lib/Dialect/Mesh/Transforms/Spmdization.cpp mlir/lib/Dialect/Mesh/Transforms/Transforms.cpp mlir/lib/Dialect/NVGPU/TransformOps/NVGPUTransformOps.cpp mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp mlir/lib/Dialect/SparseTensor/IR/Detail/Var.cpp mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp mlir/lib/Dialect/SparseTensor/IR/SparseTensorInterfaces.cpp mlir/lib/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.cpp mlir/lib/Dialect/SparseTensor/Transforms/SparseAssembler.cpp mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp mlir/lib/Dialect/Tensor/IR/TensorOps.cpp mlir/lib/Dialect/Tosa/IR/ShardingInterfaceImpl.cpp mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp mlir/lib/Dialect/Tosa/IR/TosaOps.cpp mlir/lib/Dialect/Tosa/Transforms/TosaFolders.cpp mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp mlir/lib/Dialect/Transform/DebugExtension/DebugExtensionOps.cpp mlir/lib/Dialect/Transform/IR/TransformOps.cpp mlir/lib/Dialect/Transform/IR/TransformTypes.cpp mlir/lib/Dialect/Vector/IR/VectorOps.cpp mlir/lib/Dialect/Vector/Transforms/LowerVectorTransfer.cpp mlir/lib/Dialect/Vector/Transforms/VectorDropLeadUnitDim.cpp mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp mlir/lib/Dialect/XeGPU/IR/XeGPUOps.cpp mlir/lib/IR/AffineMap.cpp mlir/lib/IR/Operation.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp mlir/lib/Target/LLVMIR/Dialect/VCIX/VCIXToLLVMIRTranslation.cpp mlir/test/lib/Conversion/MathToVCIX/TestMathToVCIXConversion.cpp mlir/test/lib/Dialect/Mesh/TestReshardingSpmdization.cpp mlir/test/lib/Dialect/Test/TestToLLVMIRTranslation.cpp mlir/test/lib/IR/TestAffineWalk.cpp mlir/test/lib/IR/TestBuiltinAttributeInterfaces.cpp mlir/test/lib/Rewrite/TestPDLByteCode.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Dialect/Linalg/Transforms/ConvertToDestinationStyle.cpp b/mlir/lib/Dialect/Linalg/Transforms/ConvertToDestinationStyle.cpp
index c8ea73427c..59c189fa1f 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/ConvertToDestinationStyle.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/ConvertToDestinationStyle.cpp
@@ -508,7 +508,8 @@ Value linalg::bufferizeToAllocation(
   // Gather tensor results.
   SmallVector<OpResult> tensorResults;
   for (OpResult result : op->getResults()) {
-    if (!isa<TensorType>(result.getType())) continue;
+    if (!isa<TensorType>(result.getType()))
+      continue;
     // Unranked tensors are not supported
     if (!isa<RankedTensorType>(result.getType()))
       return nullptr;
diff --git a/mlir/lib/Dialect/Linalg/Transforms/EliminateEmptyTensors.cpp b/mlir/lib/Dialect/Linalg/Transforms/EliminateEmptyTensors.cpp
index 18e3cbe517..4776883ed9 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/EliminateEmptyTensors.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/EliminateEmptyTensors.cpp
@@ -49,7 +49,8 @@ LogicalResult linalg::linalgOpAnchoredEmptyTensorEliminationStep(
 
     for (OpOperand *in : op.getDpsInputOperands()) {
       // Skip non-tensor operands.
-      if (!isa<RankedTensorType>(in->get().getType())) continue;
+      if (!isa<RankedTensorType>(in->get().getType()))
+        continue;
 
       // Find tensor.empty ops on the reverse SSA use-def chain. Only follow
       // equivalent tensors. I.e., stop when there are ops such as extract_slice
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
index 9de4bd6380..80bc04d62b 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -3475,7 +3475,8 @@ SplatOp::reifyResultShapes(OpBuilder &builder,
 
 OpFoldResult SplatOp::fold(FoldAdaptor adaptor) {
   auto constOperand = adaptor.getInput();
-  if (!isa_and_nonnull<IntegerAttr, FloatAttr>(constOperand)) return {};
+  if (!isa_and_nonnull<IntegerAttr, FloatAttr>(constOperand))
+    return {};
 
   // Do not fold if the splat is not statically shaped
   if (!getType().hasStaticShape())
diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
index 19bbc16377..d10a31941d 100644
--- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
@@ -6169,7 +6169,8 @@ void mlir::vector::populateVectorToVectorCanonicalizationPatterns(
 
 OpFoldResult SplatOp::fold(FoldAdaptor adaptor) {
   auto constOperand = adaptor.getInput();
-  if (!isa_and_nonnull<IntegerAttr, FloatAttr>(constOperand)) return {};
+  if (!isa_and_nonnull<IntegerAttr, FloatAttr>(constOperand))
+    return {};
 
   // SplatElementsAttr::get treats single value for second arg as being a splat.
   return SplatElementsAttr::get(getType(), {constOperand});
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 9cf65223f9..ebcdbc02aa 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -2489,7 +2489,8 @@ static void genMapInfos(llvm::IRBuilderBase &builder,
   auto addDevInfos = [&, fail](auto devOperands, auto devOpType) -> void {
     for (const auto &devOp : devOperands) {
       // TODO: Only LLVMPointerTypes are handled.
-      if (!isa<LLVM::LLVMPointerType>(devOp.getType())) return fail();
+      if (!isa<LLVM::LLVMPointerType>(devOp.getType()))
+        return fail();
 
       llvm::Value *mapOpValue = moduleTranslation.lookupValue(devOp);
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/89356


More information about the Mlir-commits mailing list