diff options
Diffstat (limited to 'mlir/lib')
36 files changed, 321 insertions, 327 deletions
diff --git a/mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp b/mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp index 0be43b9ec7a6..d98bb2a23335 100644 --- a/mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp +++ b/mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#include "../PassDetail.h" #include "mlir/Conversion/BufferizationToMemRef/BufferizationToMemRef.h" +#include "../PassDetail.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" diff --git a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp index b104826b757f..9e9ba52e70aa 100644 --- a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp +++ b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp @@ -766,8 +766,8 @@ struct SqrtOpConversion : public OpConversionPattern<complex::SqrtOp> { Value absArg = b.create<complex::AbsOp>(elementType, arg); Value addAbs = b.create<arith::AddFOp>(absLhs, absArg); - Value half = b.create<arith::ConstantOp>( - elementType, b.getFloatAttr(elementType, 0.5)); + Value half = b.create<arith::ConstantOp>(elementType, + b.getFloatAttr(elementType, 0.5)); Value halfAddAbs = b.create<arith::MulFOp>(addAbs, half); Value sqrtAddAbs = b.create<math::SqrtOp>(halfAddAbs); diff --git a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp index 26fed8c1691e..529efab55892 100644 --- a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp +++ b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp @@ -877,9 +877,9 @@ mlir::createGpuToLLVMConversionPass() { return std::make_unique<GpuToLLVMConversionPass>(); } -void mlir::populateGpuToLLVMConversionPatterns( - LLVMTypeConverter &converter, RewritePatternSet &patterns, - StringRef gpuBinaryAnnotation) { +void mlir::populateGpuToLLVMConversionPatterns(LLVMTypeConverter &converter, + RewritePatternSet &patterns, + StringRef gpuBinaryAnnotation) { converter.addConversion( [context = &converter.getContext()](gpu::AsyncTokenType type) -> Type { return LLVM::LLVMPointerType::get(IntegerType::get(context, 8)); diff --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp index c50c942cac54..2e52122d94d5 100644 --- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp +++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp @@ -146,7 +146,6 @@ LogicalResult SingleWorkgroupReduction::matchAndRewrite( // TODO: Load to Workgroup storage class first. - // Get the input element accessed by this invocation. Value inputElementPtr = spirv::getElementPtr( *typeConverter, originalInputType, convertedInput, {x}, loc, rewriter); diff --git a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp index 95307737e9c1..2779d247ddf1 100644 --- a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp +++ b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp @@ -111,7 +111,6 @@ LogicalResult mlir::linalg::LinalgOpToLibraryCallRewrite::matchAndRewrite( return success(); } - /// Populate the given list with patterns that convert from Linalg to Standard. void mlir::linalg::populateLinalgToStandardConversionPatterns( RewritePatternSet &patterns) { diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp index 8a497d7936fc..d2dc66d61078 100644 --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -2753,7 +2753,8 @@ LogicalResult AffineStoreOp::fold(ArrayRef<Attribute> cstOperands, // AffineMinMaxOpBase //===----------------------------------------------------------------------===// -template <typename T> static LogicalResult verifyAffineMinMaxOp(T op) { +template <typename T> +static LogicalResult verifyAffineMinMaxOp(T op) { // Verify that operand count matches affine map dimension and symbol count. if (op.getNumOperands() != op.getMap().getNumDims() + op.getMap().getNumSymbols()) @@ -2762,7 +2763,8 @@ template <typename T> static LogicalResult verifyAffineMinMaxOp(T op) { return success(); } -template <typename T> static void printAffineMinMaxOp(OpAsmPrinter &p, T op) { +template <typename T> +static void printAffineMinMaxOp(OpAsmPrinter &p, T op) { p << ' ' << op->getAttr(T::getMapAttrStrName()); auto operands = op.getOperands(); unsigned numDims = op.getMap().getNumDims(); @@ -2870,7 +2872,8 @@ struct DeduplicateAffineMinMaxExpressions : public OpRewritePattern<T> { /// /// %1 = affine.min affine_map< /// ()[s0, s1] -> (s0 + 4, s1 + 16, s1 * 8)> ()[%sym2, %sym1] -template <typename T> struct MergeAffineMinMaxOp : public OpRewritePattern<T> { +template <typename T> +struct MergeAffineMinMaxOp : public OpRewritePattern<T> { using OpRewritePattern<T>::OpRewritePattern; LogicalResult matchAndRewrite(T affineOp, diff --git a/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp b/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp index 672df0c9947e..f9f4c686a050 100644 --- a/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp +++ b/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp @@ -209,8 +209,8 @@ OpFoldResult arith::AddIOp::fold(ArrayRef<Attribute> operands) { operands, [](APInt a, const APInt &b) { return std::move(a) + b; }); } -void arith::AddIOp::getCanonicalizationPatterns( - RewritePatternSet &patterns, MLIRContext *context) { +void arith::AddIOp::getCanonicalizationPatterns(RewritePatternSet &patterns, + MLIRContext *context) { patterns.add<AddIAddConstant, AddISubConstantRHS, AddISubConstantLHS>( context); } @@ -231,8 +231,8 @@ OpFoldResult arith::SubIOp::fold(ArrayRef<Attribute> operands) { operands, [](APInt a, const APInt &b) { return std::move(a) - b; }); } -void arith::SubIOp::getCanonicalizationPatterns( - RewritePatternSet &patterns, MLIRContext *context) { +void arith::SubIOp::getCanonicalizationPatterns(RewritePatternSet &patterns, + MLIRContext *context) { patterns .add<SubIRHSAddConstant, SubILHSAddConstant, SubIRHSSubConstantRHS, SubIRHSSubConstantLHS, SubILHSSubConstantRHS, SubILHSSubConstantLHS>( @@ -539,8 +539,8 @@ OpFoldResult arith::XOrIOp::fold(ArrayRef<Attribute> operands) { operands, [](APInt a, const APInt &b) { return std::move(a) ^ b; }); } -void arith::XOrIOp::getCanonicalizationPatterns( - RewritePatternSet &patterns, MLIRContext *context) { +void arith::XOrIOp::getCanonicalizationPatterns(RewritePatternSet &patterns, + MLIRContext *context) { patterns.add<XOrINotCmpI>(context); } @@ -921,8 +921,8 @@ bool arith::ExtSIOp::areCastCompatible(TypeRange inputs, TypeRange outputs) { return checkWidthChangeCast<std::greater, IntegerType>(inputs, outputs); } -void arith::ExtSIOp::getCanonicalizationPatterns( - RewritePatternSet &patterns, MLIRContext *context) { +void arith::ExtSIOp::getCanonicalizationPatterns(RewritePatternSet &patterns, + MLIRContext *context) { patterns.add<ExtSIOfExtUI>(context); } @@ -1017,8 +1017,8 @@ LogicalResult arith::TruncFOp::verify() { // AndIOp //===----------------------------------------------------------------------===// -void arith::AndIOp::getCanonicalizationPatterns( - RewritePatternSet &patterns, MLIRContext *context) { +void arith::AndIOp::getCanonicalizationPatterns(RewritePatternSet &patterns, + MLIRContext *context) { patterns.add<AndOfExtUI, AndOfExtSI>(context); } @@ -1026,8 +1026,8 @@ void arith::AndIOp::getCanonicalizationPatterns( // OrIOp //===----------------------------------------------------------------------===// -void arith::OrIOp::getCanonicalizationPatterns( - RewritePatternSet &patterns, MLIRContext *context) { +void arith::OrIOp::getCanonicalizationPatterns(RewritePatternSet &patterns, + MLIRContext *context) { patterns.add<OrOfExtUI, OrOfExtSI>(context); } @@ -1226,8 +1226,8 @@ OpFoldResult arith::BitcastOp::fold(ArrayRef<Attribute> operands) { return IntegerAttr::get(resType, bits); } -void arith::BitcastOp::getCanonicalizationPatterns( - RewritePatternSet &patterns, MLIRContext *context) { +void arith::BitcastOp::getCanonicalizationPatterns(RewritePatternSet &patterns, + MLIRContext *context) { patterns.add<BitcastOfBitcast>(context); } diff --git a/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp b/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp index b4bff0f2de95..afe7aab99af3 100644 --- a/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp +++ b/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp @@ -159,7 +159,7 @@ public: Location loc = op.getLoc(); // If any operand is NaN, 'cmp' will be true (and 'select' returns 'lhs'). static_assert(pred == arith::CmpFPredicate::UGT || - pred == arith::CmpFPredicate::ULT, + pred == arith::CmpFPredicate::ULT, "pred must be either UGT or ULT"); Value cmp = rewriter.create<arith::CmpFOp>(loc, pred, lhs, rhs); Value select = rewriter.create<arith::SelectOp>(loc, cmp, lhs, rhs); diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp index f1dfbd113947..10c6d6e65de5 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp @@ -212,15 +212,14 @@ struct OneShotBufferizePass }; // Configure op filter. - OpFilter::Entry::FilterFn filterFn = - [&](Operation *op) { - // Filter may be specified via options. - if (this->dialectFilter.hasValue()) - return llvm::is_contained(this->dialectFilter, - op->getDialect()->getNamespace()); - // No filter specified: All other ops are allowed. - return true; - }; + OpFilter::Entry::FilterFn filterFn = [&](Operation *op) { + // Filter may be specified via options. + if (this->dialectFilter.hasValue()) + return llvm::is_contained(this->dialectFilter, + op->getDialect()->getNamespace()); + // No filter specified: All other ops are allowed. + return true; + }; opt.opFilter.allowOperation(filterFn); } else { opt = *options; diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp index b33db153c644..e1b1e7e93d65 100644 --- a/mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp @@ -133,16 +133,15 @@ SerializeToCubinPass::serializeISA(const std::string &isa) { // Register pass to serialize GPU kernel functions to a CUBIN binary annotation. void mlir::registerGpuSerializeToCubinPass() { - PassRegistration<SerializeToCubinPass> registerSerializeToCubin( - [] { - // Initialize LLVM NVPTX backend. - LLVMInitializeNVPTXTarget(); - LLVMInitializeNVPTXTargetInfo(); - LLVMInitializeNVPTXTargetMC(); - LLVMInitializeNVPTXAsmPrinter(); - - return std::make_unique<SerializeToCubinPass>(); - }); + PassRegistration<SerializeToCubinPass> registerSerializeToCubin([] { + // Initialize LLVM NVPTX backend. + LLVMInitializeNVPTXTarget(); + LLVMInitializeNVPTXTargetInfo(); + LLVMInitializeNVPTXTargetMC(); + LLVMInitializeNVPTXAsmPrinter(); + + return std::make_unique<SerializeToCubinPass>(); + }); } #else // MLIR_GPU_TO_CUBIN_PASS_ENABLE void mlir::registerGpuSerializeToCubinPass() {} diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp index 2b0a8ac26710..eb33071dc1ae 100644 --- a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp @@ -360,8 +360,7 @@ SerializeToHsacoPass::assembleIsa(const std::string &isa) { } llvm::SourceMgr srcMgr; - srcMgr.AddNewSourceBuffer(llvm::MemoryBuffer::getMemBuffer(isa), - SMLoc()); + srcMgr.AddNewSourceBuffer(llvm::MemoryBuffer::getMemBuffer(isa), SMLoc()); const llvm::MCTargetOptions mcOptions; std::unique_ptr<llvm::MCRegisterInfo> mri( @@ -469,18 +468,17 @@ SerializeToHsacoPass::serializeISA(const std::string &isa) { // Register pass to serialize GPU kernel functions to a HSACO binary annotation. void mlir::registerGpuSerializeToHsacoPass() { - PassRegistration<SerializeToHsacoPass> registerSerializeToHSACO( - [] { - // Initialize LLVM AMDGPU backend. - LLVMInitializeAMDGPUAsmParser(); - LLVMInitializeAMDGPUAsmPrinter(); - LLVMInitializeAMDGPUTarget(); - LLVMInitializeAMDGPUTargetInfo(); - LLVMInitializeAMDGPUTargetMC(); - - return std::make_unique<SerializeToHsacoPass>("amdgcn-amd-amdhsa", "", - "", 2); - }); + PassRegistration<SerializeToHsacoPass> registerSerializeToHSACO([] { + // Initialize LLVM AMDGPU backend. + LLVMInitializeAMDGPUAsmParser(); + LLVMInitializeAMDGPUAsmPrinter(); + LLVMInitializeAMDGPUTarget(); + LLVMInitializeAMDGPUTargetInfo(); + LLVMInitializeAMDGPUTargetMC(); + + return std::make_unique<SerializeToHsacoPass>("amdgcn-amd-amdhsa", "", "", + 2); + }); } /// Create an instance of the GPU kernel function to HSAco binary serialization diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 965563af7415..ea3bfbabac13 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -485,7 +485,8 @@ recordStructIndices(Type baseGEPType, unsigned indexPos, unsigned dynamicIndexPos = indexPos; if (!isStaticIndex) dynamicIndexPos = llvm::count(structIndices.take_front(indexPos + 1), - LLVM::GEPOp::kDynamicIndex) - 1; + LLVM::GEPOp::kDynamicIndex) - + 1; return llvm::TypeSwitch<Type, llvm::Error>(baseGEPType) .Case<LLVMStructType>([&](LLVMStructType structType) -> llvm::Error { diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp index 04015efea3e9..52d798fe58cb 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp @@ -311,8 +311,7 @@ static LLVMArrayType parseArrayType(AsmParser &parser) { /// error at `subtypesLoc` in case of failure. static LLVMStructType trySetStructBody(LLVMStructType type, ArrayRef<Type> subtypes, bool isPacked, - AsmParser &parser, - SMLoc subtypesLoc) { + AsmParser &parser, SMLoc subtypesLoc) { for (Type t : subtypes) { if (!LLVMStructType::isValidElementType(t)) { parser.emitError(subtypesLoc) diff --git a/mlir/lib/Dialect/MemRef/Transforms/ComposeSubView.cpp b/mlir/lib/Dialect/MemRef/Transforms/ComposeSubView.cpp index 5cad72de397c..d5387c9faeff 100644 --- a/mlir/lib/Dialect/MemRef/Transforms/ComposeSubView.cpp +++ b/mlir/lib/Dialect/MemRef/Transforms/ComposeSubView.cpp @@ -127,7 +127,7 @@ struct ComposeSubViewOpPattern : public OpRewritePattern<memref::SubViewOp> { } // namespace -void mlir::memref::populateComposeSubViewPatterns( - RewritePatternSet &patterns, MLIRContext *context) { +void mlir::memref::populateComposeSubViewPatterns(RewritePatternSet &patterns, + MLIRContext *context) { patterns.add<ComposeSubViewOpPattern>(context); } diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp index 405ef8f52f29..8621281ea017 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp @@ -483,7 +483,8 @@ namespace { // parseAndVerify does the actual parsing and verification of individual // elements. This is a functor since parsing the last element of the list // (termination condition) needs partial specialization. -template <typename ParseType, typename... Args> struct ParseCommaSeparatedList { +template <typename ParseType, typename... Args> +struct ParseCommaSeparatedList { Optional<std::tuple<ParseType, Args...>> operator()(SPIRVDialect const &dialect, DialectAsmParser &parser) const { auto parseVal = parseAndVerify<ParseType>(dialect, parser); @@ -503,7 +504,8 @@ template <typename ParseType, typename... Args> struct ParseCommaSeparatedList { // Partial specialization of the function to parse a comma separated list of // specs to parse the last element of the list. -template <typename ParseType> struct ParseCommaSeparatedList<ParseType> { +template <typename ParseType> +struct ParseCommaSeparatedList<ParseType> { Optional<std::tuple<ParseType>> operator()(SPIRVDialect const &dialect, DialectAsmParser &parser) const { if (auto value = parseAndVerify<ParseType>(dialect, parser)) diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp index 494f32925315..bf4582511f1a 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp @@ -259,33 +259,42 @@ void CooperativeMatrixNVType::getCapabilities( // ImageType //===----------------------------------------------------------------------===// -template <typename T> static constexpr unsigned getNumBits() { return 0; } -template <> constexpr unsigned getNumBits<Dim>() { +template <typename T> +static constexpr unsigned getNumBits() { + return 0; +} +template <> +constexpr unsigned getNumBits<Dim>() { static_assert((1 << 3) > getMaxEnumValForDim(), "Not enough bits to encode Dim value"); return 3; } -template <> constexpr unsigned getNumBits<ImageDepthInfo>() { +template <> +constexpr unsigned getNumBits<ImageDepthInfo>() { static_assert((1 << 2) > getMaxEnumValForImageDepthInfo(), "Not enough bits to encode ImageDepthInfo value"); return 2; } -template <> constexpr unsigned getNumBits<ImageArrayedInfo>() { +template <> +constexpr unsigned getNumBits<ImageArrayedInfo>() { static_assert((1 << 1) > getMaxEnumValForImageArrayedInfo(), "Not enough bits to encode ImageArrayedInfo value"); return 1; } -template <> constexpr unsigned getNumBits<ImageSamplingInfo>() { +template <> +constexpr unsigned getNumBits<ImageSamplingInfo>() { static_assert((1 << 1) > getMaxEnumValForImageSamplingInfo(), "Not enough bits to encode ImageSamplingInfo value"); return 1; } -template <> constexpr unsigned getNumBits<ImageSamplerUseInfo>() { +template <> +constexpr unsigned getNumBits<ImageSamplerUseInfo>() { static_assert((1 << 2) > getMaxEnumValForImageSamplerUseInfo(), "Not enough bits to encode ImageSamplerUseInfo value"); return 2; } -template <> constexpr unsigned getNumBits<ImageFormat>() { +template <> +constexpr unsigned getNumBits<ImageFormat>() { static_assert((1 << 6) > getMaxEnumValForImageFormat(), "Not enough bits to encode ImageFormat value"); return 6; diff --git a/mlir/lib/IR/AffineExpr.cpp b/mlir/lib/IR/AffineExpr.cpp index 5a19535a062f..38d0e9b66dae 100644 --- a/mlir/lib/IR/AffineExpr.cpp +++ b/mlir/lib/IR/AffineExpr.cpp @@ -8,8 +8,8 @@ #include <utility> -#include "mlir/IR/AffineExpr.h" #include "AffineExprDetail.h" +#include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/IntegerSet.h" diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 7865652d0572..2dc324f455be 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -930,8 +930,7 @@ private: }; } // namespace -SSANameState::SSANameState( - Operation *op, const OpPrintingFlags &printerFlags) +SSANameState::SSANameState(Operation *op, const OpPrintingFlags &printerFlags) : printerFlags(printerFlags) { llvm::SaveAndRestore<unsigned> valueIDSaver(nextValueID); llvm::SaveAndRestore<unsigned> argumentIDSaver(nextArgumentID); diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index feb21493d0d3..18a79d25ff5b 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -319,11 +319,11 @@ unsigned PredecessorIterator::getSuccessorIndex() const { SuccessorRange::SuccessorRange() : SuccessorRange(nullptr, 0) {} SuccessorRange::SuccessorRange(Block *block) : SuccessorRange() { - if (block->empty() || llvm::hasSingleElement(*block->getParent())) - return; - Operation *term = &block->back(); - if ((count = term->getNumSuccessors())) - base = term->getBlockOperands().data(); + if (block->empty() || llvm::hasSingleElement(*block->getParent())) + return; + Operation *term = &block->back(); + if ((count = term->getNumSuccessors())) + base = term->getBlockOperands().data(); } SuccessorRange::SuccessorRange(Operation *term) : SuccessorRange() { diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp index 98b9085f825a..83bc50bfec97 100644 --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -373,8 +373,7 @@ struct SourceMgrDiagnosticHandlerImpl { // Otherwise, try to load the source file. std::string ignored; - unsigned id = - mgr.AddIncludeFile(std::string(filename), SMLoc(), ignored); + unsigned id = mgr.AddIncludeFile(std::string(filename), SMLoc(), ignored); filenameToBufId[filename] = id; return id; } diff --git a/mlir/lib/IR/FunctionInterfaces.cpp b/mlir/lib/IR/FunctionInterfaces.cpp index dc3e08c8fdf0..3331aefc76d1 100644 --- a/mlir/lib/IR/FunctionInterfaces.cpp +++ b/mlir/lib/IR/FunctionInterfaces.cpp @@ -261,10 +261,8 @@ TypeRange mlir::function_interface_impl::insertTypesInto( return storage; } -TypeRange -mlir::function_interface_impl::filterTypesOut(TypeRange types, - const BitVector &indices, - SmallVectorImpl<Type> &storage) { +TypeRange mlir::function_interface_impl::filterTypesOut( + TypeRange types, const BitVector &indices, SmallVectorImpl<Type> &storage) { if (indices.none()) return types; diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp index aaae4c8ad9da..1f7a739cae50 100644 --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -292,8 +292,7 @@ void detail::OperandStorage::eraseOperands(unsigned start, unsigned length) { operands[numOperands + i].~OpOperand(); } -void detail::OperandStorage::eraseOperands( - const BitVector &eraseIndices) { +void detail::OperandStorage::eraseOperands(const BitVector &eraseIndices) { MutableArrayRef<OpOperand> operands = getOperands(); assert(eraseIndices.size() == operands.size()); diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp index ea730eb46422..75976628e82a 100644 --- a/mlir/lib/IR/Value.cpp +++ b/mlir/lib/IR/Value.cpp @@ -212,4 +212,3 @@ unsigned BlockOperand::getOperandNumber() { unsigned OpOperand::getOperandNumber() { return this - &getOwner()->getOpOperands()[0]; } - diff --git a/mlir/lib/Parser/AsmParserImpl.h b/mlir/lib/Parser/AsmParserImpl.h index 7e204bc392c7..8f9c2b3f52a4 100644 --- a/mlir/lib/Parser/AsmParserImpl.h +++ b/mlir/lib/Parser/AsmParserImpl.h @@ -51,9 +51,7 @@ public: /// Get the location of the next token and store it into the argument. This /// always succeeds. - SMLoc getCurrentLocation() override { - return parser.getToken().getLoc(); - } + SMLoc getCurrentLocation() override { return parser.getToken().getLoc(); } /// Re-encode the given source location as an MLIR location and return it. Location getEncodedSourceLoc(SMLoc loc) override { diff --git a/mlir/lib/Parser/AsmParserState.cpp b/mlir/lib/Parser/AsmParserState.cpp index 5c59848bd3b2..a3aa3a71e535 100644 --- a/mlir/lib/Parser/AsmParserState.cpp +++ b/mlir/lib/Parser/AsmParserState.cpp @@ -259,8 +259,7 @@ void AsmParserState::addDefinition(Block *block, SMLoc location) { impl->blocks[it->second]->definition.loc = convertIdLocToRange(location); } -void AsmParserState::addDefinition(BlockArgument blockArg, - SMLoc location) { +void AsmParserState::addDefinition(BlockArgument blockArg, SMLoc location) { auto it = impl->blocksToIdx.find(blockArg.getOwner()); assert(it != impl->blocksToIdx.end() && "expected owner block to have an entry"); diff --git a/mlir/lib/Parser/AttributeParser.cpp b/mlir/lib/Parser/AttributeParser.cpp index 9f0b56d8ae9e..72cec30dda6d 100644 --- a/mlir/lib/Parser/AttributeParser.cpp +++ b/mlir/lib/Parser/AttributeParser.cpp @@ -525,8 +525,7 @@ ParseResult TensorLiteralParser::parse(bool allowHex) { /// Build a dense attribute instance with the parsed elements and the given /// shaped type. -DenseElementsAttr TensorLiteralParser::getAttr(SMLoc loc, - ShapedType type) { +DenseElementsAttr TensorLiteralParser::getAttr(SMLoc loc, ShapedType type) { Type eltType = type.getElementType(); // Check to see if we parse the literal from a hex string. @@ -676,8 +675,7 @@ TensorLiteralParser::getFloatAttrElements(SMLoc loc, FloatType eltTy, } /// Build a Dense String attribute for the given type. -DenseElementsAttr TensorLiteralParser::getStringAttr(SMLoc loc, - ShapedType type, +DenseElementsAttr TensorLiteralParser::getStringAttr(SMLoc loc, ShapedType type, Type eltTy) { if (hexStorage.has_value()) { auto stringValue = hexStorage.value().getStringValue(); @@ -698,8 +696,7 @@ DenseElementsAttr TensorLiteralParser::getStringAttr(SMLoc loc, } /// Build a Dense attribute with hex data for the given type. -DenseElementsAttr TensorLiteralParser::getHexAttr(SMLoc loc, - ShapedType type) { +DenseElementsAttr TensorLiteralParser::getHexAttr(SMLoc loc, ShapedType type) { Type elementType = type.getElementType(); if (!elementType.isIntOrIndexOrFloat() && !elementType.isa<ComplexType>()) { p.emitError(loc) diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp index dff65b6fe77c..c17963c51112 100644 --- a/mlir/lib/Pass/IRPrinting.cpp +++ b/mlir/lib/Pass/IRPrinting.cpp @@ -62,7 +62,8 @@ public: } private: - template <typename T> void addDataToHash(llvm::SHA1 &hasher, const T &data) { + template <typename T> + void addDataToHash(llvm::SHA1 &hasher, const T &data) { hasher.update( ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(&data), sizeof(T))); } diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp index 709baea6bd52..9f0ce23c5b81 100644 --- a/mlir/lib/Pass/PassRegistry.cpp +++ b/mlir/lib/Pass/PassRegistry.cpp @@ -8,9 +8,9 @@ #include <utility> -#include "mlir/Pass/PassRegistry.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" +#include "mlir/Pass/PassRegistry.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" diff --git a/mlir/lib/Rewrite/PatternApplicator.cpp b/mlir/lib/Rewrite/PatternApplicator.cpp index edaf13e575d3..686b8e2330b0 100644 --- a/mlir/lib/Rewrite/PatternApplicator.cpp +++ b/mlir/lib/Rewrite/PatternApplicator.cpp @@ -33,9 +33,9 @@ PatternApplicator::~PatternApplicator() = default; #ifndef NDEBUG /// Log a message for a pattern that is impossible to match. static void logImpossibleToMatch(const Pattern &pattern) { - llvm::dbgs() << "Ignoring pattern '" << pattern.getRootKind() - << "' because it is impossible to match or cannot lead " - "to legal IR (by cost model)\n"; + llvm::dbgs() << "Ignoring pattern '" << pattern.getRootKind() + << "' because it is impossible to match or cannot lead " + "to legal IR (by cost model)\n"; } /// Log IR after pattern application. diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp index 49431d15ed81..d8ce25f2e9a3 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp @@ -341,10 +341,9 @@ static LogicalResult convertDataOp(acc::DataOp &op, mapperAllocas))) return failure(); - if (failed(processOperands(builder, moduleTranslation, op, - op.createOperands(), totalNbOperand, - kCreateFlag | kHoldFlag, flags, names, index, - mapperAllocas))) + if (failed(processOperands( + builder, moduleTranslation, op, op.createOperands(), totalNbOperand, + kCreateFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); // TODO create zero currenlty handled as create. Update when extension @@ -355,10 +354,9 @@ static LogicalResult convertDataOp(acc::DataOp &op, mapperAllocas))) return failure(); - if (failed(processOperands(builder, moduleTranslation, op, - op.presentOperands(), totalNbOperand, - kPresentFlag | kHoldFlag, flags, names, index, - mapperAllocas))) + if (failed(processOperands( + builder, moduleTranslation, op, op.presentOperands(), totalNbOperand, + kPresentFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); llvm::GlobalVariable *maptypes = diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h index d5a9e9913851..442b8e369d77 100644 --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h @@ -467,7 +467,8 @@ private: /// Method to deserialize an operation in the SPIR-V dialect that is a mirror /// of an instruction in the SPIR-V spec. This is auto generated if hasOpcode /// == 1 and autogenSerialization == 1 in ODS. - template <typename OpTy> LogicalResult processOp(ArrayRef<uint32_t> words) { + template <typename OpTy> + LogicalResult processOp(ArrayRef<uint32_t> words) { return emitError(unknownLoc, "unsupported deserialization for ") << OpTy::getOperationName() << " op"; } diff --git a/mlir/lib/Target/SPIRV/Serialization/Serializer.h b/mlir/lib/Target/SPIRV/Serialization/Serializer.h index 69d9461cd9c1..a338111fd2f2 100644 --- a/mlir/lib/Target/SPIRV/Serialization/Serializer.h +++ b/mlir/lib/Target/SPIRV/Serialization/Serializer.h @@ -297,7 +297,8 @@ private: /// Serializes an operation in the SPIR-V dialect that is a mirror of an /// instruction in the SPIR-V spec. This is auto generated if hasOpcode == 1 /// and autogenSerialization == 1 in ODS. - template <typename OpTy> LogicalResult processOp(OpTy op) { + template <typename OpTy> + LogicalResult processOp(OpTy op) { return op.emitError("unsupported op serialization"); } diff --git a/mlir/lib/Tools/PDLL/AST/Nodes.cpp b/mlir/lib/Tools/PDLL/AST/Nodes.cpp index 3af6ddf4dba3..57b52fde6261 100644 --- a/mlir/lib/Tools/PDLL/AST/Nodes.cpp +++ b/mlir/lib/Tools/PDLL/AST/Nodes.cpp @@ -199,8 +199,7 @@ CompoundStmt *CompoundStmt::create(Context &ctx, SMRange loc, // LetStmt //===----------------------------------------------------------------------===// -LetStmt *LetStmt::create(Context &ctx, SMRange loc, - VariableDecl *varDecl) { +LetStmt *LetStmt::create(Context &ctx, SMRange loc, VariableDecl *varDecl) { return new (ctx.getAllocator().Allocate<LetStmt>()) LetStmt(loc, varDecl); } @@ -394,8 +393,7 @@ Optional<StringRef> OpConstraintDecl::getName() const { // TypeConstraintDecl //===----------------------------------------------------------------------===// -TypeConstraintDecl *TypeConstraintDecl::create(Context &ctx, - SMRange loc) { +TypeConstraintDecl *TypeConstraintDecl::create(Context &ctx, SMRange loc) { return new (ctx.getAllocator().Allocate<TypeConstraintDecl>()) TypeConstraintDecl(loc); } @@ -414,8 +412,8 @@ TypeRangeConstraintDecl *TypeRangeConstraintDecl::create(Context &ctx, // ValueConstraintDecl //===----------------------------------------------------------------------===// -ValueConstraintDecl * -ValueConstraintDecl::create(Context &ctx, SMRange loc, Expr *typeExpr) { +ValueConstraintDecl *ValueConstraintDecl::create(Context &ctx, SMRange loc, + Expr *typeExpr) { return new (ctx.getAllocator().Allocate<ValueConstraintDecl>()) ValueConstraintDecl(loc, typeExpr); } @@ -424,9 +422,8 @@ ValueConstraintDecl::create(Context &ctx, SMRange loc, Expr *typeExpr) { // ValueRangeConstraintDecl //===----------------------------------------------------------------------===// -ValueRangeConstraintDecl *ValueRangeConstraintDecl::create(Context &ctx, - SMRange loc, - Expr *typeExpr) { +ValueRangeConstraintDecl * +ValueRangeConstraintDecl::create(Context &ctx, SMRange loc, Expr *typeExpr) { return new (ctx.getAllocator().Allocate<ValueRangeConstraintDecl>()) ValueRangeConstraintDecl(loc, typeExpr); } @@ -498,8 +495,8 @@ OpNameDecl *OpNameDecl::create(Context &ctx, SMRange loc) { // PatternDecl //===----------------------------------------------------------------------===// -PatternDecl *PatternDecl::create(Context &ctx, SMRange loc, - const Name *name, Optional<uint16_t> benefit, +PatternDecl *PatternDecl::create(Context &ctx, SMRange loc, const Name *name, + Optional<uint16_t> benefit, bool hasBoundedRecursion, const CompoundStmt *body) { return new (ctx.getAllocator().Allocate<PatternDecl>()) @@ -554,8 +551,7 @@ VariableDecl *VariableDecl::create(Context &ctx, const Name &name, Type type, // Module //===----------------------------------------------------------------------===// -Module *Module::create(Context &ctx, SMLoc loc, - ArrayRef<Decl *> children) { +Module *Module::create(Context &ctx, SMLoc loc, ArrayRef<Decl *> children) { unsigned allocSize = Module::totalSizeToAlloc<Decl *>(children.size()); void *rawData = ctx.getAllocator().Allocate(allocSize, alignof(Module)); diff --git a/mlir/lib/Tools/PDLL/Parser/Lexer.cpp b/mlir/lib/Tools/PDLL/Parser/Lexer.cpp index 250b21d4519e..92bf4812d8bb 100644 --- a/mlir/lib/Tools/PDLL/Parser/Lexer.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Lexer.cpp @@ -44,18 +44,18 @@ std::string Token::getStringValue() const { assert(i + 1 <= e && "invalid string should be caught by lexer"); auto c1 = bytes[i++]; switch (c1) { - case '"': - case '\\': - result.push_back(c1); - continue; - case 'n': - result.push_back('\n'); - continue; - case 't': - result.push_back('\t'); - continue; - default: - break; + case '"': + case '\\': + result.push_back(c1); + continue; + case 'n': + result.push_back('\n'); + continue; + case 't': + result.push_back('\t'); + continue; + default: + break; } assert(i + 1 <= e && "invalid string should be caught by lexer"); @@ -101,7 +101,8 @@ Lexer::Lexer(llvm::SourceMgr &mgr, ast::DiagnosticEngine &diagEngine, } Lexer::~Lexer() { - if (addedHandlerToDiagEngine) diagEngine.setHandlerFn(nullptr); + if (addedHandlerToDiagEngine) + diagEngine.setHandlerFn(nullptr); } LogicalResult Lexer::pushInclude(StringRef filename, SMRange includeLoc) { @@ -121,39 +122,39 @@ Token Lexer::emitError(SMRange loc, const Twine &msg) { diagEngine.emitError(loc, msg); return formToken(Token::error, loc.Start.getPointer()); } -Token Lexer::emitErrorAndNote(SMRange loc, const Twine &msg, - SMRange noteLoc, const Twine ¬e) { +Token Lexer::emitErrorAndNote(SMRange loc, const Twine &msg, SMRange noteLoc, + const Twine ¬e) { diagEngine.emitError(loc, msg)->attachNote(note, noteLoc); return formToken(Token::error, loc.Start.getPointer()); } Token Lexer::emitError(const char *loc, const Twine &msg) { - return emitError(SMRange(SMLoc::getFromPointer(loc), - SMLoc::getFromPointer(loc + 1)), - msg); + return emitError( + SMRange(SMLoc::getFromPointer(loc), SMLoc::getFromPointer(loc + 1)), msg); } int Lexer::getNextChar() { char curChar = *curPtr++; switch (curChar) { - default: - return static_cast<unsigned char>(curChar); - case 0: { - // A nul character in the stream is either the end of the current buffer - // or a random nul in the file. Disambiguate that here. - if (curPtr - 1 != curBuffer.end()) return 0; - - // Otherwise, return end of file. - --curPtr; - return EOF; - } - case '\n': - case '\r': - // Handle the newline character by ignoring it and incrementing the line - // count. However, be careful about 'dos style' files with \n\r in them. - // Only treat a \n\r or \r\n as a single line. - if ((*curPtr == '\n' || (*curPtr == '\r')) && *curPtr != curChar) - ++curPtr; - return '\n'; + default: + return static_cast<unsigned char>(curChar); + case 0: { + // A nul character in the stream is either the end of the current buffer + // or a random nul in the file. Disambiguate that here. + if (curPtr - 1 != curBuffer.end()) + return 0; + + // Otherwise, return end of file. + --curPtr; + return EOF; + } + case '\n': + case '\r': + // Handle the newline character by ignoring it and incrementing the line + // count. However, be careful about 'dos style' files with \n\r in them. + // Only treat a \n\r or \r\n as a single line. + if ((*curPtr == '\n' || (*curPtr == '\r')) && *curPtr != curChar) + ++curPtr; + return '\n'; } } @@ -168,99 +169,100 @@ Token Lexer::lexToken() { // This always consumes at least one character. int curChar = getNextChar(); switch (curChar) { - default: - // Handle identifiers: [a-zA-Z_] - if (isalpha(curChar) || curChar == '_') return lexIdentifier(tokStart); - - // Unknown character, emit an error. - return emitError(tokStart, "unexpected character"); - case EOF: { - // Return EOF denoting the end of lexing. - Token eof = formToken(Token::eof, tokStart); - - // Check to see if we are in an included file. - SMLoc parentIncludeLoc = srcMgr.getParentIncludeLoc(curBufferID); - if (parentIncludeLoc.isValid()) { - curBufferID = srcMgr.FindBufferContainingLoc(parentIncludeLoc); - curBuffer = srcMgr.getMemoryBuffer(curBufferID)->getBuffer(); - curPtr = parentIncludeLoc.getPointer(); - } - - return eof; + default: + // Handle identifiers: [a-zA-Z_] + if (isalpha(curChar) || curChar == '_') + return lexIdentifier(tokStart); + + // Unknown character, emit an error. + return emitError(tokStart, "unexpected character"); + case EOF: { + // Return EOF denoting the end of lexing. + Token eof = formToken(Token::eof, tokStart); + + // Check to see if we are in an included file. + SMLoc parentIncludeLoc = srcMgr.getParentIncludeLoc(curBufferID); + if (parentIncludeLoc.isValid()) { + curBufferID = srcMgr.FindBufferContainingLoc(parentIncludeLoc); + curBuffer = srcMgr.getMemoryBuffer(curBufferID)->getBuffer(); + curPtr = parentIncludeLoc.getPointer(); + } + + return eof; + } + + // Lex punctuation. + case '-': + if (*curPtr == '>') { + ++curPtr; + return formToken(Token::arrow, tokStart); + } + return emitError(tokStart, "unexpected character"); + case ':': + return formToken(Token::colon, tokStart); + case ',': + return formToken(Token::comma, tokStart); + case '.': + return formToken(Token::dot, tokStart); + case '=': + if (*curPtr == '>') { + ++curPtr; + return formToken(Token::equal_arrow, tokStart); + } + return formToken(Token::equal, tokStart); + case ';': + return formToken(Token::semicolon, tokStart); + case '[': + if (*curPtr == '{') { + ++curPtr; + return lexString(tokStart, /*isStringBlock=*/true); } + return formToken(Token::l_square, tokStart); + case ']': + return formToken(Token::r_square, tokStart); + + case '<': + return formToken(Token::less, tokStart); + case '>': + return formToken(Token::greater, tokStart); + case '{': + return formToken(Token::l_brace, tokStart); + case '}': + return formToken(Token::r_brace, tokStart); + case '(': + return formToken(Token::l_paren, tokStart); + case ')': + return formToken(Token::r_paren, tokStart); + case '/': + if (*curPtr == '/') { + lexComment(); + continue; + } + return emitError(tokStart, "unexpected character"); - // Lex punctuation. - case '-': - if (*curPtr == '>') { - ++curPtr; - return formToken(Token::arrow, tokStart); - } - return emitError(tokStart, "unexpected character"); - case ':': - return formToken(Token::colon, tokStart); - case ',': - return formToken(Token::comma, tokStart); - case '.': - return formToken(Token::dot, tokStart); - case '=': - if (*curPtr == '>') { - ++curPtr; - return formToken(Token::equal_arrow, tokStart); - } - return formToken(Token::equal, tokStart); - case ';': - return formToken(Token::semicolon, tokStart); - case '[': - if (*curPtr == '{') { - ++curPtr; - return lexString(tokStart, /*isStringBlock=*/true); - } - return formToken(Token::l_square, tokStart); - case ']': - return formToken(Token::r_square, tokStart); - - case '<': - return formToken(Token::less, tokStart); - case '>': - return formToken(Token::greater, tokStart); - case '{': - return formToken(Token::l_brace, tokStart); - case '}': - return formToken(Token::r_brace, tokStart); - case '(': - return formToken(Token::l_paren, tokStart); - case ')': - return formToken(Token::r_paren, tokStart); - case '/': - if (*curPtr == '/') { - lexComment(); - continue; - } - return emitError(tokStart, "unexpected character"); - - // Ignore whitespace characters. - case 0: - case ' ': - case '\t': - case '\n': - return lexToken(); - - case '#': - return lexDirective(tokStart); - case '"': - return lexString(tokStart, /*isStringBlock=*/false); - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return lexNumber(tokStart); + // Ignore whitespace characters. + case 0: + case ' ': + case '\t': + case '\n': + return lexToken(); + + case '#': + return lexDirective(tokStart); + case '"': + return lexString(tokStart, /*isStringBlock=*/false); + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return lexNumber(tokStart); } } } @@ -273,27 +275,28 @@ void Lexer::lexComment() { while (true) { switch (*curPtr++) { - case '\n': - case '\r': - // Newline is end of comment. + case '\n': + case '\r': + // Newline is end of comment. + return; + case 0: + // If this is the end of the buffer, end the comment. + if (curPtr - 1 == curBuffer.end()) { + --curPtr; return; - case 0: - // If this is the end of the buffer, end the comment. - if (curPtr - 1 == curBuffer.end()) { - --curPtr; - return; - } - LLVM_FALLTHROUGH; - default: - // Skip over other characters. - break; + } + LLVM_FALLTHROUGH; + default: + // Skip over other characters. + break; } } } Token Lexer::lexDirective(const char *tokStart) { // Match the rest with an identifier regex: [0-9a-zA-Z_]* - while (isalnum(*curPtr) || *curPtr == '_') ++curPtr; + while (isalnum(*curPtr) || *curPtr == '_') + ++curPtr; StringRef str(tokStart, curPtr - tokStart); return Token(Token::directive, str); @@ -301,7 +304,8 @@ Token Lexer::lexDirective(const char *tokStart) { Token Lexer::lexIdentifier(const char *tokStart) { // Match the rest of the identifier regex: [0-9a-zA-Z_]* - while (isalnum(*curPtr) || *curPtr == '_') ++curPtr; + while (isalnum(*curPtr) || *curPtr == '_') + ++curPtr; // Check to see if this identifier is a keyword. StringRef str(tokStart, curPtr - tokStart); @@ -334,7 +338,8 @@ Token Lexer::lexNumber(const char *tokStart) { assert(isdigit(curPtr[-1])); // Handle the normal decimal case. - while (isdigit(*curPtr)) ++curPtr; + while (isdigit(*curPtr)) + ++curPtr; return formToken(Token::integer, tokStart); } @@ -352,54 +357,54 @@ Token Lexer::lexString(const char *tokStart, bool isStringBlock) { } switch (*curPtr++) { - case '"': - // If this is a string block, we only end the string when we encounter a - // `}]`. - if (!isStringBlock) - return formToken(Token::string, tokStart); + case '"': + // If this is a string block, we only end the string when we encounter a + // `}]`. + if (!isStringBlock) + return formToken(Token::string, tokStart); + continue; + case '}': + // If this is a string block, we only end the string when we encounter a + // `}]`. + if (!isStringBlock || *curPtr != ']') continue; - case '}': - // If this is a string block, we only end the string when we encounter a - // `}]`. - if (!isStringBlock || *curPtr != ']') - continue; - ++curPtr; - return formToken(Token::string_block, tokStart); - case 0: { - // If this is a random nul character in the middle of a string, just - // include it. If it is the end of file, then it is an error. - if (curPtr - 1 != curBuffer.end()) - continue; - --curPtr; + ++curPtr; + return formToken(Token::string_block, tokStart); + case 0: { + // If this is a random nul character in the middle of a string, just + // include it. If it is the end of file, then it is an error. + if (curPtr - 1 != curBuffer.end()) + continue; + --curPtr; - StringRef expectedEndStr = isStringBlock ? "}]" : "\""; - return emitError(curPtr - 1, - "expected '" + expectedEndStr + "' in string literal"); - } + StringRef expectedEndStr = isStringBlock ? "}]" : "\""; + return emitError(curPtr - 1, + "expected '" + expectedEndStr + "' in string literal"); + } - case '\n': - case '\v': - case '\f': - // String blocks allow multiple lines. - if (!isStringBlock) - return emitError(curPtr - 1, "expected '\"' in string literal"); - continue; + case '\n': + case '\v': + case '\f': + // String blocks allow multiple lines. + if (!isStringBlock) + return emitError(curPtr - 1, "expected '\"' in string literal"); + continue; - case '\\': - // Handle explicitly a few escapes. - if (*curPtr == '"' || *curPtr == '\\' || *curPtr == 'n' || - *curPtr == 't') { - ++curPtr; - } else if (llvm::isHexDigit(*curPtr) && llvm::isHexDigit(curPtr[1])) { - // Support \xx for two hex digits. - curPtr += 2; - } else { - return emitError(curPtr - 1, "unknown escape in string literal"); - } - continue; + case '\\': + // Handle explicitly a few escapes. + if (*curPtr == '"' || *curPtr == '\\' || *curPtr == 'n' || + *curPtr == 't') { + ++curPtr; + } else if (llvm::isHexDigit(*curPtr) && llvm::isHexDigit(curPtr[1])) { + // Support \xx for two hex digits. + curPtr += 2; + } else { + return emitError(curPtr - 1, "unknown escape in string literal"); + } + continue; - default: - continue; + default: + continue; } } } diff --git a/mlir/lib/Tools/PDLL/Parser/Lexer.h b/mlir/lib/Tools/PDLL/Parser/Lexer.h index 1c521f37bce3..6a78669f854d 100644 --- a/mlir/lib/Tools/PDLL/Parser/Lexer.h +++ b/mlir/lib/Tools/PDLL/Parser/Lexer.h @@ -133,7 +133,8 @@ public: /// Return if the token does not have the given kind. bool isNot(Kind k) const { return k != kind; } - template <typename... T> bool isNot(Kind k1, Kind k2, T... others) const { + template <typename... T> + bool isNot(Kind k1, Kind k2, T... others) const { return !isAny(k1, k2, others...); } @@ -141,17 +142,13 @@ public: bool is(Kind k) const { return kind == k; } /// Return a location for the start of this token. - SMLoc getStartLoc() const { - return SMLoc::getFromPointer(spelling.data()); - } + SMLoc getStartLoc() const { return SMLoc::getFromPointer(spelling.data()); } /// Return a location at the end of this token. SMLoc getEndLoc() const { return SMLoc::getFromPointer(spelling.data() + spelling.size()); } /// Return a location for the range of this token. - SMRange getLoc() const { - return SMRange(getStartLoc(), getEndLoc()); - } + SMRange getLoc() const { return SMRange(getStartLoc(), getEndLoc()); } private: /// Discriminator that indicates the kind of token this is. @@ -193,8 +190,8 @@ public: /// Emit an error to the lexer with the given location and message. Token emitError(SMRange loc, const Twine &msg); Token emitError(const char *loc, const Twine &msg); - Token emitErrorAndNote(SMRange loc, const Twine &msg, - SMRange noteLoc, const Twine ¬e); + Token emitErrorAndNote(SMRange loc, const Twine &msg, SMRange noteLoc, + const Twine ¬e); private: Token formToken(Token::Kind kind, const char *tokStart) { diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp index 538fb18ad19c..1cd0164f6dd3 100644 --- a/mlir/lib/Transforms/ViewOpGraph.cpp +++ b/mlir/lib/Transforms/ViewOpGraph.cpp @@ -314,8 +314,7 @@ private: } // namespace -std::unique_ptr<Pass> -mlir::createPrintOpGraphPass(raw_ostream &os) { +std::unique_ptr<Pass> mlir::createPrintOpGraphPass(raw_ostream &os) { return std::make_unique<PrintOpPass>(os); } |