From 4562e389a43caa2e30ebf277c12743edafe6a0ac Mon Sep 17 00:00:00 2001 From: River Riddle Date: Wed, 18 Dec 2019 09:28:48 -0800 Subject: [PATCH] NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974 --- mlir/include/mlir/Analysis/AffineAnalysis.h | 18 ++--- mlir/include/mlir/Analysis/AffineStructures.h | 22 +++--- mlir/include/mlir/Analysis/CallInterfaces.h | 5 +- mlir/include/mlir/Analysis/Dominance.h | 2 +- mlir/include/mlir/Analysis/InferTypeOpInterface.td | 2 +- mlir/include/mlir/Analysis/LoopAnalysis.h | 8 +-- mlir/include/mlir/Dialect/AffineOps/AffineOps.h | 8 +-- mlir/include/mlir/Dialect/CommonFolders.h | 4 +- mlir/include/mlir/Dialect/GPU/GPUOps.td | 2 +- mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h | 2 +- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 2 +- .../Dialect/Linalg/Analysis/DependenceAnalysis.h | 4 +- mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h | 18 ++--- .../mlir/Dialect/Linalg/IR/LinalgLibraryOps.td | 4 +- mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td | 2 +- mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h | 4 +- .../Dialect/Linalg/Transforms/LinalgTransforms.h | 2 +- mlir/include/mlir/Dialect/Linalg/Utils/Utils.h | 38 +++++----- mlir/include/mlir/Dialect/QuantOps/QuantTypes.h | 2 +- .../include/mlir/Dialect/QuantOps/UniformSupport.h | 7 +- mlir/include/mlir/Dialect/SDBM/SDBM.h | 4 +- mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h | 2 +- mlir/include/mlir/Dialect/StandardOps/Ops.h | 2 +- mlir/include/mlir/Dialect/VectorOps/Utils.h | 14 ++-- mlir/include/mlir/EDSC/Builders.h | 15 ++-- mlir/include/mlir/EDSC/Helpers.h | 8 +-- mlir/include/mlir/EDSC/Intrinsics.h | 4 +- .../include/mlir/ExecutionEngine/ExecutionEngine.h | 6 +- mlir/include/mlir/IR/AffineExpr.h | 6 +- mlir/include/mlir/IR/AffineMap.h | 2 +- mlir/include/mlir/IR/Attributes.h | 24 +++---- mlir/include/mlir/IR/Block.h | 10 +-- mlir/include/mlir/IR/BlockAndValueMapping.h | 2 +- mlir/include/mlir/IR/Diagnostics.h | 20 +++--- mlir/include/mlir/IR/Function.h | 2 +- mlir/include/mlir/IR/FunctionImplementation.h | 2 +- mlir/include/mlir/IR/FunctionSupport.h | 2 +- mlir/include/mlir/IR/IntegerSet.h | 2 +- mlir/include/mlir/IR/Module.h | 2 +- mlir/include/mlir/IR/OpDefinition.h | 13 ++-- mlir/include/mlir/IR/Operation.h | 4 +- mlir/include/mlir/IR/OperationSupport.h | 11 ++- mlir/include/mlir/IR/PatternMatch.h | 10 +-- mlir/include/mlir/IR/Region.h | 9 ++- mlir/include/mlir/IR/StandardTypes.h | 8 +-- mlir/include/mlir/IR/TypeUtilities.h | 5 +- mlir/include/mlir/IR/UseDefLists.h | 4 +- mlir/include/mlir/IR/Value.h | 4 +- mlir/include/mlir/IR/Visitors.h | 2 +- mlir/include/mlir/Pass/AnalysisManager.h | 21 +++--- mlir/include/mlir/Pass/Pass.h | 19 +++-- mlir/include/mlir/Pass/PassInstrumentation.h | 10 +-- mlir/include/mlir/Pass/PassManager.h | 2 +- .../include/mlir/Quantizer/Support/Configuration.h | 6 +- .../Quantizer/Support/ConstraintAnalysisGraph.h | 33 ++++----- mlir/include/mlir/Quantizer/Support/Metadata.h | 2 +- mlir/include/mlir/Quantizer/Support/Statistics.h | 3 +- mlir/include/mlir/Support/Functional.h | 17 +++-- mlir/include/mlir/Support/MlirOptMain.h | 1 + mlir/include/mlir/Support/StorageUniquer.h | 6 +- mlir/include/mlir/Support/ToolUtilities.h | 8 +-- mlir/include/mlir/TableGen/Pattern.h | 2 +- .../include/mlir/Target/LLVMIR/ModuleTranslation.h | 6 +- mlir/include/mlir/Transforms/DialectConversion.h | 14 ++-- mlir/include/mlir/Transforms/FoldUtils.h | 14 ++-- mlir/include/mlir/Transforms/InliningUtils.h | 6 +- mlir/include/mlir/Transforms/LoopFusionUtils.h | 7 +- mlir/include/mlir/Transforms/Passes.h | 4 +- mlir/include/mlir/Transforms/RegionUtils.h | 6 +- mlir/include/mlir/Transforms/ViewOpGraph.h | 8 +-- mlir/include/mlir/Transforms/ViewRegionGraph.h | 8 +-- mlir/lib/Analysis/AffineAnalysis.cpp | 9 ++- mlir/lib/Analysis/AffineStructures.cpp | 17 ++--- mlir/lib/Analysis/LoopAnalysis.cpp | 8 +-- mlir/lib/Analysis/OpStats.cpp | 4 +- mlir/lib/Analysis/TestMemRefDependenceCheck.cpp | 2 +- .../Conversion/GPUCommon/OpToFuncCallLowering.h | 2 +- .../Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 6 +- .../StandardToLLVM/ConvertStandardToLLVM.cpp | 16 ++--- .../VectorToLoops/ConvertVectorToLoops.cpp | 10 +-- mlir/lib/Dialect/AffineOps/AffineOps.cpp | 15 ++-- .../FxpMathOps/Transforms/UniformKernelUtils.h | 2 +- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 2 +- .../lib/Dialect/GPU/Transforms/KernelOutlining.cpp | 4 +- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 4 +- mlir/lib/Dialect/Linalg/EDSC/Builders.cpp | 2 +- mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 2 +- .../Dialect/Linalg/Transforms/LinalgTransforms.cpp | 2 +- mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp | 4 +- mlir/lib/Dialect/SDBM/SDBM.cpp | 17 +++-- mlir/lib/Dialect/SDBM/SDBMExpr.cpp | 4 +- mlir/lib/Dialect/SPIRV/LayoutUtils.cpp | 7 +- mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp | 2 +- mlir/lib/Dialect/SPIRV/SPIRVOps.cpp | 8 +-- .../Dialect/SPIRV/Serialization/Deserializer.cpp | 2 +- .../lib/Dialect/SPIRV/Serialization/Serializer.cpp | 10 +-- .../SPIRV/Serialization/TranslateRegistration.cpp | 19 +++-- mlir/lib/Dialect/StandardOps/Ops.cpp | 15 ++-- mlir/lib/Dialect/Traits.cpp | 5 +- mlir/lib/Dialect/VectorOps/VectorTransforms.cpp | 10 +-- mlir/lib/EDSC/Builders.cpp | 24 +++---- mlir/lib/EDSC/CoreAPIs.cpp | 4 +- mlir/lib/ExecutionEngine/ExecutionEngine.cpp | 19 +++-- mlir/lib/IR/AffineExpr.cpp | 18 ++--- mlir/lib/IR/AffineMap.cpp | 8 +-- mlir/lib/IR/AsmPrinter.cpp | 12 ++-- mlir/lib/IR/Attributes.cpp | 27 ++++---- mlir/lib/IR/Block.cpp | 2 +- mlir/lib/IR/Diagnostics.cpp | 20 +++--- mlir/lib/IR/Function.cpp | 6 +- mlir/lib/IR/FunctionImplementation.cpp | 2 +- mlir/lib/IR/IntegerSet.cpp | 3 +- mlir/lib/IR/Module.cpp | 2 +- mlir/lib/IR/Operation.cpp | 2 +- mlir/lib/IR/Region.cpp | 4 +- mlir/lib/IR/StandardTypes.cpp | 9 +-- mlir/lib/Parser/Parser.cpp | 51 +++++++------- mlir/lib/Pass/Pass.cpp | 4 +- mlir/lib/Pass/PassManagerOptions.cpp | 2 +- mlir/lib/Pass/PassRegistry.cpp | 9 ++- mlir/lib/Pass/PassStatistics.cpp | 2 +- mlir/lib/Pass/PassTiming.cpp | 15 ++-- .../Quantizer/Support/ConstraintAnalysisGraph.cpp | 8 +-- mlir/lib/Quantizer/Support/Metadata.cpp | 2 +- mlir/lib/Quantizer/Support/Statistics.cpp | 16 ++--- mlir/lib/Quantizer/Support/UniformConstraints.cpp | 14 ++-- mlir/lib/Quantizer/Support/UniformSolvers.cpp | 10 ++- .../Transforms/InferQuantizedTypesPass.cpp | 4 +- mlir/lib/Support/JitRunner.cpp | 16 ++--- mlir/lib/Support/StorageUniquer.cpp | 31 ++++----- mlir/lib/Support/TranslateClParser.cpp | 8 +-- mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp | 4 +- mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp | 17 +++-- mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp | 21 +++--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 2 +- mlir/lib/Transforms/DialectConversion.cpp | 13 ++-- mlir/lib/Transforms/Inliner.cpp | 8 +-- mlir/lib/Transforms/LoopInvariantCodeMotion.cpp | 2 +- mlir/lib/Transforms/Utils/FoldUtils.cpp | 7 +- mlir/lib/Transforms/Utils/InliningUtils.cpp | 11 ++- mlir/lib/Transforms/Utils/LoopUtils.cpp | 16 ++--- mlir/lib/Transforms/Utils/RegionUtils.cpp | 12 ++-- mlir/lib/Transforms/Vectorize.cpp | 14 ++-- mlir/lib/Transforms/ViewOpGraph.cpp | 80 +++++++++++----------- mlir/lib/Transforms/ViewRegionGraph.cpp | 21 +++--- 145 files changed, 650 insertions(+), 700 deletions(-) diff --git a/mlir/include/mlir/Analysis/AffineAnalysis.h b/mlir/include/mlir/Analysis/AffineAnalysis.h index bb50c80..8243d1f 100644 --- a/mlir/include/mlir/Analysis/AffineAnalysis.h +++ b/mlir/include/mlir/Analysis/AffineAnalysis.h @@ -24,6 +24,7 @@ #ifndef MLIR_ANALYSIS_AFFINE_ANALYSIS_H #define MLIR_ANALYSIS_AFFINE_ANALYSIS_H +#include "mlir/Support/LLVM.h" #include "mlir/Support/LogicalResult.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" @@ -41,9 +42,8 @@ class Value; /// Returns in `affineApplyOps`, the sequence of those AffineApplyOp /// Operations that are reachable via a search starting from `operands` and /// ending at those operands that are not the result of an AffineApplyOp. -void getReachableAffineApplyOps( - llvm::ArrayRef operands, - llvm::SmallVectorImpl &affineApplyOps); +void getReachableAffineApplyOps(ArrayRef operands, + SmallVectorImpl &affineApplyOps); /// Builds a system of constraints with dimensional identifiers corresponding to /// the loop IVs of the forOps appearing in that order. Bounds of the loop are @@ -51,14 +51,14 @@ void getReachableAffineApplyOps( /// operands are added as symbols in the system. Returns failure for the yet /// unimplemented cases. // TODO(bondhugula): handle non-unit strides. -LogicalResult getIndexSet(llvm::MutableArrayRef forOps, +LogicalResult getIndexSet(MutableArrayRef forOps, FlatAffineConstraints *domain); /// Encapsulates a memref load or store access information. struct MemRefAccess { Value *memref; Operation *opInst; - llvm::SmallVector indices; + SmallVector indices; /// Constructs a MemRefAccess from a load or store operation. // TODO(b/119949820): add accessors to standard op's load, store, DMA op's to @@ -94,9 +94,9 @@ struct DependenceComponent { // The AffineForOp Operation associated with this dependence component. Operation *op; // The lower bound of the dependence distance. - llvm::Optional lb; + Optional lb; // The upper bound of the dependence distance (inclusive). - llvm::Optional ub; + Optional ub; DependenceComponent() : lb(llvm::None), ub(llvm::None) {} }; @@ -122,7 +122,7 @@ struct DependenceResult { DependenceResult checkMemrefAccessDependence( const MemRefAccess &srcAccess, const MemRefAccess &dstAccess, unsigned loopDepth, FlatAffineConstraints *dependenceConstraints, - llvm::SmallVector *dependenceComponents, + SmallVector *dependenceComponents, bool allowRAR = false); /// Utility function that returns true if the provided DependenceResult @@ -136,7 +136,7 @@ inline bool hasDependence(DependenceResult result) { /// [1, maxLoopDepth]. void getDependenceComponents( AffineForOp forOp, unsigned maxLoopDepth, - std::vector> *depCompsVec); + std::vector> *depCompsVec); } // end namespace mlir diff --git a/mlir/include/mlir/Analysis/AffineStructures.h b/mlir/include/mlir/Analysis/AffineStructures.h index 143956e..e53af50 100644 --- a/mlir/include/mlir/Analysis/AffineStructures.h +++ b/mlir/include/mlir/Analysis/AffineStructures.h @@ -795,10 +795,10 @@ AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims, /// 'cst' contains constraints that connect newly introduced local identifiers /// to existing dimensional and symbolic identifiers. See documentation for /// AffineExprFlattener on how mod's and div's are flattened. -LogicalResult -getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols, - llvm::SmallVectorImpl *flattenedExpr, - FlatAffineConstraints *cst = nullptr); +LogicalResult getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, + unsigned numSymbols, + SmallVectorImpl *flattenedExpr, + FlatAffineConstraints *cst = nullptr); /// Flattens the result expressions of the map to their corresponding flattened /// forms and set in 'flattenedExprs'. Returns failure if any expression in the @@ -810,12 +810,14 @@ getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols, /// method should be used instead of repeatedly calling getFlattenedAffineExpr /// since local variables added to deal with div's and mod's will be reused /// across expressions. -LogicalResult getFlattenedAffineExprs( - AffineMap map, std::vector> *flattenedExprs, - FlatAffineConstraints *cst = nullptr); -LogicalResult getFlattenedAffineExprs( - IntegerSet set, std::vector> *flattenedExprs, - FlatAffineConstraints *cst = nullptr); +LogicalResult +getFlattenedAffineExprs(AffineMap map, + std::vector> *flattenedExprs, + FlatAffineConstraints *cst = nullptr); +LogicalResult +getFlattenedAffineExprs(IntegerSet set, + std::vector> *flattenedExprs, + FlatAffineConstraints *cst = nullptr); } // end namespace mlir. diff --git a/mlir/include/mlir/Analysis/CallInterfaces.h b/mlir/include/mlir/Analysis/CallInterfaces.h index 0c67e84..dd23d77 100644 --- a/mlir/include/mlir/Analysis/CallInterfaces.h +++ b/mlir/include/mlir/Analysis/CallInterfaces.h @@ -30,9 +30,8 @@ namespace mlir { /// A callable is either a symbol, or an SSA value, that is referenced by a /// call-like operation. This represents the destination of the call. -struct CallInterfaceCallable - : public llvm::PointerUnion { - using llvm::PointerUnion::PointerUnion; +struct CallInterfaceCallable : public PointerUnion { + using PointerUnion::PointerUnion; }; #include "mlir/Analysis/CallInterfaces.h.inc" diff --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h index 5e21e6e..09114ea 100644 --- a/mlir/include/mlir/Analysis/Dominance.h +++ b/mlir/include/mlir/Analysis/Dominance.h @@ -56,7 +56,7 @@ protected: bool properlyDominates(Block *a, Block *b); /// A mapping of regions to their base dominator tree. - llvm::DenseMap> dominanceInfos; + DenseMap> dominanceInfos; }; } // end namespace detail diff --git a/mlir/include/mlir/Analysis/InferTypeOpInterface.td b/mlir/include/mlir/Analysis/InferTypeOpInterface.td index 7f63b2b..aae6e83 100644 --- a/mlir/include/mlir/Analysis/InferTypeOpInterface.td +++ b/mlir/include/mlir/Analysis/InferTypeOpInterface.td @@ -47,7 +47,7 @@ def InferTypeOpInterface : OpInterface<"InferTypeOpInterface"> { }], /*retTy=*/"LogicalResult", /*methodName=*/"inferReturnTypes", - /*args=*/(ins "llvm::Optional":$location, + /*args=*/(ins "Optional":$location, "ValueRange":$operands, "ArrayRef":$attributes, "RegionRange":$regions, diff --git a/mlir/include/mlir/Analysis/LoopAnalysis.h b/mlir/include/mlir/Analysis/LoopAnalysis.h index 140d9e9..47cc22a 100644 --- a/mlir/include/mlir/Analysis/LoopAnalysis.h +++ b/mlir/include/mlir/Analysis/LoopAnalysis.h @@ -50,7 +50,7 @@ void buildTripCountMapAndOperands(AffineForOp forOp, AffineMap *map, /// Returns the trip count of the loop if it's a constant, None otherwise. This /// uses affine expression analysis and is able to determine constant trip count /// in non-trivial cases. -llvm::Optional getConstantTripCount(AffineForOp forOp); +Optional getConstantTripCount(AffineForOp forOp); /// Returns the greatest known integral divisor of the trip count. Affine /// expression analysis is used (indirectly through getTripCount), and @@ -66,8 +66,8 @@ uint64_t getLargestDivisorOfTripCount(AffineForOp forOp); /// /// Emits a note if it encounters a chain of affine.apply and conservatively /// those cases. -llvm::DenseSet> -getInvariantAccesses(Value *iv, llvm::ArrayRef indices); +DenseSet> +getInvariantAccesses(Value *iv, ArrayRef indices); using VectorizableLoopFun = std::function; @@ -91,7 +91,7 @@ bool isVectorizableLoopBody(AffineForOp loop, int *memRefDim, /// 'def' and all its uses have the same shift factor. // TODO(mlir-team): extend this to check for memory-based dependence // violation when we have the support. -bool isInstwiseShiftValid(AffineForOp forOp, llvm::ArrayRef shifts); +bool isInstwiseShiftValid(AffineForOp forOp, ArrayRef shifts); } // end namespace mlir #endif // MLIR_ANALYSIS_LOOP_ANALYSIS_H diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h index 8268f81..36b4e55 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h @@ -538,17 +538,17 @@ bool isValidSymbol(Value *value); /// dimensional operands /// 4. propagate constant operands and drop them void canonicalizeMapAndOperands(AffineMap *map, - llvm::SmallVectorImpl *operands); + SmallVectorImpl *operands); /// Canonicalizes an integer set the same way canonicalizeMapAndOperands does /// for affine maps. void canonicalizeSetAndOperands(IntegerSet *set, - llvm::SmallVectorImpl *operands); + SmallVectorImpl *operands); /// Returns a composed AffineApplyOp by composing `map` and `operands` with /// other AffineApplyOps supplying those operands. The operands of the resulting /// AffineApplyOp do not change the length of AffineApplyOp chains. AffineApplyOp makeComposedAffineApply(OpBuilder &b, Location loc, AffineMap map, - llvm::ArrayRef operands); + ArrayRef operands); /// Given an affine map `map` and its input `operands`, this method composes /// into `map`, maps of AffineApplyOps whose results are the values in @@ -558,7 +558,7 @@ AffineApplyOp makeComposedAffineApply(OpBuilder &b, Location loc, AffineMap map, /// terminal symbol, i.e., a symbol defined at the top level or a block/function /// argument. void fullyComposeAffineMapAndOperands(AffineMap *map, - llvm::SmallVectorImpl *operands); + SmallVectorImpl *operands); #define GET_OP_CLASSES #include "mlir/Dialect/AffineOps/AffineOps.h.inc" diff --git a/mlir/include/mlir/Dialect/CommonFolders.h b/mlir/include/mlir/Dialect/CommonFolders.h index 28619ce..4555294 100644 --- a/mlir/include/mlir/Dialect/CommonFolders.h +++ b/mlir/include/mlir/Dialect/CommonFolders.h @@ -35,8 +35,8 @@ namespace mlir { template > -Attribute constFoldBinaryOp(llvm::ArrayRef operands, + function_ref> +Attribute constFoldBinaryOp(ArrayRef operands, const CalculationT &calculate) { assert(operands.size() == 2 && "binary op takes two operands"); if (!operands[0] || !operands[1]) diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td index 5f7bab3..46433c6 100644 --- a/mlir/include/mlir/Dialect/GPU/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td @@ -443,7 +443,7 @@ def GPU_LaunchOp : GPU_Op<"launch", [IsolatedFromAbove]>, KernelDim3 getBlockSizeOperandValues(); /// Get the SSA values of the kernel arguments. - llvm::iterator_range getKernelArguments(); + iterator_range getKernelArguments(); /// Erase the `index`-th kernel argument. Both the entry block argument and /// the operand will be dropped. The block argument must not have any uses. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h index 5332a74..dae27d0 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h @@ -156,7 +156,7 @@ private: /// Get an LLVMType with an llvm type that may cause changes to the underlying /// llvm context when constructed. static LLVMType getLocked(LLVMDialect *dialect, - llvm::function_ref typeBuilder); + function_ref typeBuilder); }; ///// Ops ///// diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index a711914..4deab2e 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -637,7 +637,7 @@ def LLVM_LLVMFuncOp def LLVM_NullOp : LLVM_OneResultOp<"mlir.null", [NoSideEffect]>, LLVM_Builder<"$res = llvm::ConstantPointerNull::get(" - " llvm::cast($_resultType));"> { + " cast($_resultType));"> { let parser = [{ return parseNullOp(parser, result); }]; let printer = [{ printNullOp(p, *this); }]; let verifier = [{ return ::verify(*this); }]; diff --git a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h index 354c94c..01d3e4b 100644 --- a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h +++ b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h @@ -66,10 +66,10 @@ public: // 2. dst in the case of dependencesIntoGraphs. Value *indexingView; }; - using LinalgDependences = llvm::SmallVector; + using LinalgDependences = SmallVector; using DependenceGraph = DenseMap; using dependence_iterator = LinalgDependences::const_iterator; - using dependence_range = llvm::iterator_range; + using dependence_range = iterator_range; enum DependenceType { RAR = 0, RAW, WAR, WAW, NumTypes }; diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h index 4213420..cf63352 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h @@ -77,13 +77,13 @@ private: inline void defaultRegionBuilder(ArrayRef args) {} -Operation *makeLinalgGenericOp( - ArrayRef iteratorTypes, ArrayRef inputs, - ArrayRef outputs, - llvm::function_ref)> regionBuilder = - defaultRegionBuilder, - ArrayRef otherValues = {}, - ArrayRef otherAttributes = {}); +Operation *makeLinalgGenericOp(ArrayRef iteratorTypes, + ArrayRef inputs, + ArrayRef outputs, + function_ref)> + regionBuilder = defaultRegionBuilder, + ArrayRef otherValues = {}, + ArrayRef otherAttributes = {}); namespace ops { using edsc::StructuredIndexed; @@ -120,7 +120,7 @@ void macRegionBuilder(ArrayRef args); /// with in-place semantics and parallelism. /// Unary pointwise operation (with broadcast) entry point. -using UnaryPointwiseOpBuilder = llvm::function_ref; +using UnaryPointwiseOpBuilder = function_ref; Operation *linalg_pointwise(UnaryPointwiseOpBuilder unaryOp, StructuredIndexed I, StructuredIndexed O); @@ -131,7 +131,7 @@ Operation *linalg_pointwise_tanh(StructuredIndexed I, StructuredIndexed O); /// Binary pointwise operation (with broadcast) entry point. using BinaryPointwiseOpBuilder = - llvm::function_ref; + function_ref; Operation *linalg_pointwise(BinaryPointwiseOpBuilder binaryOp, StructuredIndexed I1, StructuredIndexed I2, StructuredIndexed O); diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td index 1f24a90..12318a2 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td @@ -101,13 +101,13 @@ def LinalgLibraryInterface : OpInterface<"LinalgOp"> { Query the index of the given input value, or `None` if the value is not an input. }], - "llvm::Optional", "getIndexOfInput", (ins "Value *":$view) + "Optional", "getIndexOfInput", (ins "Value *":$view) >, InterfaceMethod<[{ Query the index of the given view value, or `None` if the value is not an view. }], - "llvm::Optional", "getIndexOfOutput", (ins "Value *":$view) + "Optional", "getIndexOfOutput", (ins "Value *":$view) >, InterfaceMethod<[{ Query the type of the input view at the given index. diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td index 64e0bb0..b806d75 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td @@ -128,7 +128,7 @@ def Linalg_SliceOp : Linalg_Op<"slice", [NoSideEffect]>, // Get the subset of indexings that are of RangeType. SmallVector getRanges() { - llvm::SmallVector res; + SmallVector res; for (auto *operand : indexings()) if (!operand->getType().isa()) res.push_back(operand); diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h index fa5f9e7..a24c1ca 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h @@ -83,7 +83,7 @@ public: } /// Return the index of `view` in the list of input views if found, llvm::None /// otherwise. - llvm::Optional getIndexOfInput(Value *view) { + Optional getIndexOfInput(Value *view) { auto it = llvm::find(getInputs(), view); if (it != getInputs().end()) return it - getInputs().begin(); @@ -104,7 +104,7 @@ public: } /// Return the index of `view` in the list of output views if found, /// llvm::None otherwise. - llvm::Optional getIndexOfOutput(Value *view) { + Optional getIndexOfOutput(Value *view) { auto it = llvm::find(getOutputs(), view); if (it != getOutputs().end()) return it - getOutputs().begin(); diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h index 9682948..dfbac5a 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h @@ -39,7 +39,7 @@ namespace detail { // Implementation detail of isProducedByOpOfType avoids the need for explicit // template instantiations. bool isProducedByOpOfTypeImpl(Operation *consumerOp, Value *consumedView, - llvm::function_ref isaOpType); + function_ref isaOpType); } // namespace detail // Returns true if the `consumedView` value use in `consumerOp` is produced by diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h index 9f1a834..f8d10ec 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -62,16 +62,16 @@ public: /// directly. In the current implementation it produces loop.for operations. class LoopNestRangeBuilder { public: - LoopNestRangeBuilder(llvm::ArrayRef ivs, - llvm::ArrayRef ranges); - LoopNestRangeBuilder(llvm::ArrayRef ivs, - llvm::ArrayRef ranges); - LoopNestRangeBuilder(llvm::ArrayRef ivs, - llvm::ArrayRef ranges); + LoopNestRangeBuilder(ArrayRef ivs, + ArrayRef ranges); + LoopNestRangeBuilder(ArrayRef ivs, + ArrayRef ranges); + LoopNestRangeBuilder(ArrayRef ivs, + ArrayRef ranges); edsc::ValueHandle operator()(std::function fun = nullptr); private: - llvm::SmallVector loops; + SmallVector loops; }; } // namespace edsc @@ -150,10 +150,10 @@ struct TiledLinalgOp { /// When non-null, the optional pointer `folder` is used to call into the /// `createAndFold` builder method. If `folder` is null, the regular `create` /// method is called. -llvm::Optional tileLinalgOp(OpBuilder &b, LinalgOp op, - ArrayRef tileSizes, - ArrayRef permutation = {}, - OperationFolder *folder = nullptr); +Optional tileLinalgOp(OpBuilder &b, LinalgOp op, + ArrayRef tileSizes, + ArrayRef permutation = {}, + OperationFolder *folder = nullptr); /// Performs standalone tiling of a single LinalgOp by constant `tileSizes`. /// and permute the loop nest according to `permutation` @@ -170,14 +170,14 @@ llvm::Optional tileLinalgOp(OpBuilder &b, LinalgOp op, /// When non-null, the optional pointer `folder` is used to call into the /// `createAndFold` builder method. If `folder` is null, the regular `create` /// method is called. -llvm::Optional tileLinalgOp(OpBuilder &b, LinalgOp op, - ArrayRef tileSizes, - ArrayRef permutation = {}, - OperationFolder *folder = nullptr); +Optional tileLinalgOp(OpBuilder &b, LinalgOp op, + ArrayRef tileSizes, + ArrayRef permutation = {}, + OperationFolder *folder = nullptr); template -llvm::Optional tileLinalgOperation(OpBuilder &b, Operation *op, - Args... args) { +Optional tileLinalgOperation(OpBuilder &b, Operation *op, + Args... args) { return tileLinalgOp(b, cast(op), args...); } @@ -198,14 +198,14 @@ struct PromotionInfo { /// /// Returns a list of PromotionInfo which hold the promoted buffer and the /// full and partial views indexing into the buffer. -llvm::SmallVector +SmallVector promoteSubViews(OpBuilder &b, Location loc, ArrayRef subViews, bool dynamicBuffers = false, OperationFolder *folder = nullptr); /// Returns all the operands of `linalgOp` that are not views. /// Asserts that these operands are value types to allow transformations like /// tiling to just use the values when cloning `linalgOp`. -llvm::SmallVector getAssumedNonViewOperands(LinalgOp linalgOp); +SmallVector getAssumedNonViewOperands(LinalgOp linalgOp); /// Apply the permutation defined by `permutation` to `inVec`. /// Element `i` in `inVec` is mapped to location `j = permutation[i]`. diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h b/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h index a681d16..55e921f 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h +++ b/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h @@ -361,7 +361,7 @@ public: /// Verifies construction invariants and issues errors/warnings. static LogicalResult verifyConstructionInvariants( - llvm::Optional loc, MLIRContext *context, unsigned flags, + Optional loc, MLIRContext *context, unsigned flags, Type storageType, Type expressedType, ArrayRef scales, ArrayRef zeroPoints, int32_t quantizedDimension, int64_t storageTypeMin, int64_t storageTypeMax); diff --git a/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h b/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h index b68d40f..0416db3 100644 --- a/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h +++ b/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h @@ -85,7 +85,7 @@ public: clampMax(clampMax), scaleDouble(scale), zeroPointDouble(zeroPoint), clampMinDouble(clampMin), clampMaxDouble(clampMax), storageBitWidth(storageBitWidth), isSigned(isSigned), - roundMode(llvm::APFloat::rmNearestTiesToAway) {} + roundMode(APFloat::rmNearestTiesToAway) {} UniformQuantizedValueConverter(double scale, double zeroPoint, APFloat clampMin, APFloat clampMax, @@ -95,7 +95,7 @@ public: clampMinDouble(clampMin.convertToDouble()), clampMaxDouble(clampMax.convertToDouble()), storageBitWidth(storageBitWidth), isSigned(isSigned), - roundMode(llvm::APFloat::rmNearestTiesToAway) {} + roundMode(APFloat::rmNearestTiesToAway) {} virtual APInt quantizeFloatToInt(APFloat expressedValue) const { // This function is a performance critical code path in quantization @@ -154,8 +154,7 @@ private: } else { signlessResult = static_cast(clamped); } - llvm::APInt result(storageBitWidth, signlessResult); - return result; + return APInt(storageBitWidth, signlessResult); } // Keep both APFloat and double versions of the quantization parameters diff --git a/mlir/include/mlir/Dialect/SDBM/SDBM.h b/mlir/include/mlir/Dialect/SDBM/SDBM.h index 9707846..f95a51e 100644 --- a/mlir/include/mlir/Dialect/SDBM/SDBM.h +++ b/mlir/include/mlir/Dialect/SDBM/SDBM.h @@ -115,7 +115,7 @@ public: SmallVectorImpl &inequalities, SmallVectorImpl &equalities); - void print(llvm::raw_ostream &os); + void print(raw_ostream &os); void dump(); IntInfty operator()(int i, int j) { return at(i, j); } @@ -198,7 +198,7 @@ private: /// temporaries can appear in these expressions. This removes the need to /// iteratively substitute definitions of the temporaries in the reverse /// conversion. - llvm::DenseMap stripeToPoint; + DenseMap stripeToPoint; }; } // namespace mlir diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h index 353004b..cb33146 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h @@ -41,7 +41,7 @@ namespace spirv { /// /// Get the function that can be used to symbolize an enum value. /// template -/// llvm::Optional (*)(StringRef) symbolizeEnum(); +/// Optional (*)(StringRef) symbolizeEnum(); #include "mlir/Dialect/SPIRV/SPIRVOpUtils.inc" } // end namespace spirv diff --git a/mlir/include/mlir/Dialect/StandardOps/Ops.h b/mlir/include/mlir/Dialect/StandardOps/Ops.h index fcf16c0..1b1cf02 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/Ops.h @@ -345,7 +345,7 @@ ParseResult parseDimAndSymbolList(OpAsmParser &parser, SmallVectorImpl &operands, unsigned &numDims); -llvm::raw_ostream &operator<<(llvm::raw_ostream &os, SubViewOp::Range &range); +raw_ostream &operator<<(raw_ostream &os, SubViewOp::Range &range); } // end namespace mlir diff --git a/mlir/include/mlir/Dialect/VectorOps/Utils.h b/mlir/include/mlir/Dialect/VectorOps/Utils.h index 2cff879..f61a813 100644 --- a/mlir/include/mlir/Dialect/VectorOps/Utils.h +++ b/mlir/include/mlir/Dialect/VectorOps/Utils.h @@ -46,15 +46,15 @@ class VectorType; /// - shapeRatio({3, 4, 5, 8}, {2, 5, 2}) returns {3, 2, 1, 4} /// - shapeRatio({3, 4, 4, 8}, {2, 5, 2}) returns None /// - shapeRatio({1, 2, 10, 32}, {2, 5, 2}) returns {1, 1, 2, 16} -llvm::Optional> -shapeRatio(ArrayRef superShape, ArrayRef subShape); +Optional> shapeRatio(ArrayRef superShape, + ArrayRef subShape); /// Computes and returns the multi-dimensional ratio of the shapes of /// `superVector` to `subVector`. If integral division is not possible, returns /// None. /// Assumes and enforces that the VectorTypes have the same elemental type. -llvm::Optional> -shapeRatio(VectorType superVectorType, VectorType subVectorType); +Optional> shapeRatio(VectorType superVectorType, + VectorType subVectorType); /// Constructs a permutation map of invariant memref indices to vector /// dimension. @@ -121,9 +121,9 @@ shapeRatio(VectorType superVectorType, VectorType subVectorType); /// Meaning that vector.transfer_read will be responsible of reading the slice /// `%arg0[%c0, %c0]` into vector<128xf32> which needs a 1-D vector broadcast. /// -AffineMap makePermutationMap( - Operation *op, ArrayRef indices, - const llvm::DenseMap &loopToVectorDim); +AffineMap +makePermutationMap(Operation *op, ArrayRef indices, + const DenseMap &loopToVectorDim); namespace matcher { diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h index 740b5cd..69c72a5 100644 --- a/mlir/include/mlir/EDSC/Builders.h +++ b/mlir/include/mlir/EDSC/Builders.h @@ -78,7 +78,7 @@ private: /// Top level OpBuilder. OpBuilder &builder; /// The previous insertion point of the builder. - llvm::Optional prevBuilderInsertPoint; + Optional prevBuilderInsertPoint; /// Current location. Location location; /// Parent context we return into. @@ -178,7 +178,7 @@ public: /// The only purpose of this operator is to serve as a sequence point so that /// the evaluation of `fun` (which build IR snippets in a scoped fashion) is /// scoped within a LoopBuilder. - void operator()(llvm::function_ref fun = nullptr); + void operator()(function_ref fun = nullptr); private: LoopBuilder() = default; @@ -217,7 +217,7 @@ public: AffineLoopNestBuilder(ArrayRef ivs, ArrayRef lbs, ArrayRef ubs, ArrayRef steps); - void operator()(llvm::function_ref fun = nullptr); + void operator()(function_ref fun = nullptr); private: SmallVector loops; @@ -228,13 +228,12 @@ private: /// loop.for. class LoopNestBuilder { public: - LoopNestBuilder(llvm::ArrayRef ivs, - ArrayRef lbs, ArrayRef ubs, - ArrayRef steps); + LoopNestBuilder(ArrayRef ivs, ArrayRef lbs, + ArrayRef ubs, ArrayRef steps); void operator()(std::function fun = nullptr); private: - llvm::SmallVector loops; + SmallVector loops; }; // This class exists solely to handle the C++ vexing parse case when @@ -264,7 +263,7 @@ public: /// The only purpose of this operator is to serve as a sequence point so that /// the evaluation of `fun` (which build IR snippets in a scoped fashion) is /// scoped within a BlockBuilder. - void operator()(llvm::function_ref fun = nullptr); + void operator()(function_ref fun = nullptr); private: BlockBuilder(BlockBuilder &) = delete; diff --git a/mlir/include/mlir/EDSC/Helpers.h b/mlir/include/mlir/EDSC/Helpers.h index 69b7290..423c92b 100644 --- a/mlir/include/mlir/EDSC/Helpers.h +++ b/mlir/include/mlir/EDSC/Helpers.h @@ -137,12 +137,12 @@ public: TemplatedIndexedValue operator()(ValueHandle index, Args... indices) { return TemplatedIndexedValue(base, index).append(indices...); } - TemplatedIndexedValue operator()(llvm::ArrayRef indices) { + TemplatedIndexedValue operator()(ArrayRef indices) { return TemplatedIndexedValue(base, indices); } - TemplatedIndexedValue operator()(llvm::ArrayRef indices) { + TemplatedIndexedValue operator()(ArrayRef indices) { return TemplatedIndexedValue( - base, llvm::ArrayRef(indices.begin(), indices.end())); + base, ArrayRef(indices.begin(), indices.end())); } /// Emits a `store`. @@ -215,7 +215,7 @@ private: return *this; } ValueHandle base; - llvm::SmallVector indices; + SmallVector indices; }; /// Operator overloadings. diff --git a/mlir/include/mlir/EDSC/Intrinsics.h b/mlir/include/mlir/EDSC/Intrinsics.h index 6dbb343..06c7550 100644 --- a/mlir/include/mlir/EDSC/Intrinsics.h +++ b/mlir/include/mlir/EDSC/Intrinsics.h @@ -106,14 +106,14 @@ public: values.append(vals.begin(), vals.end()); } ValueHandleArray(ArrayRef vals) { - llvm::SmallVector tmp(vals.begin(), vals.end()); + SmallVector tmp(vals.begin(), vals.end()); values.append(tmp.begin(), tmp.end()); } operator ArrayRef() { return values; } private: ValueHandleArray() = default; - llvm::SmallVector values; + SmallVector values; }; template inline T unpack(T value) { return value; } diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h index 23a8764..4e70a21 100644 --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -50,7 +50,7 @@ public: std::unique_ptr getObject(const llvm::Module *M) override; /// Dump cached object to output file `filename`. - void dumpToObjectFile(llvm::StringRef filename); + void dumpToObjectFile(StringRef filename); private: llvm::StringMap> cachedObjects; @@ -103,7 +103,7 @@ public: static bool setupTargetTriple(llvm::Module *llvmModule); /// Dump object code to output file `filename`. - void dumpToObjectFile(llvm::StringRef filename); + void dumpToObjectFile(StringRef filename); private: // Ordering of llvmContext and jit is important for destruction purposes: the @@ -124,7 +124,7 @@ llvm::Error ExecutionEngine::invoke(StringRef name, Args &... args) { return expectedFPtr.takeError(); auto fptr = *expectedFPtr; - llvm::SmallVector packedArgs{static_cast(&args)...}; + SmallVector packedArgs{static_cast(&args)...}; (*fptr)(packedArgs.data()); return llvm::Error::success(); diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h index 37e7592..b66933d 100644 --- a/mlir/include/mlir/IR/AffineExpr.h +++ b/mlir/include/mlir/IR/AffineExpr.h @@ -272,7 +272,7 @@ AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims, /// flattened. bool getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols, - llvm::SmallVectorImpl *flattenedExpr); + SmallVectorImpl *flattenedExpr); /// Flattens the result expressions of the map to their corresponding flattened /// forms and set in 'flattenedExprs'. Returns true on success or false @@ -282,9 +282,9 @@ bool getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, /// repeatedly calling getFlattenedAffineExpr since local variables added to /// deal with div's and mod's will be reused across expressions. bool getFlattenedAffineExprs( - AffineMap map, std::vector> *flattenedExprs); + AffineMap map, std::vector> *flattenedExprs); bool getFlattenedAffineExprs( - IntegerSet set, std::vector> *flattenedExprs); + IntegerSet set, std::vector> *flattenedExprs); namespace detail { template void bindDims(MLIRContext *ctx) {} diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h index e42173d..ab07cfa 100644 --- a/mlir/include/mlir/IR/AffineMap.h +++ b/mlir/include/mlir/IR/AffineMap.h @@ -227,7 +227,7 @@ AffineMap inversePermutation(AffineMap map); /// ```{.mlir} /// (i, j, k) -> (i, k, k, j, i, j) /// ``` -AffineMap concatAffineMaps(llvm::ArrayRef maps); +AffineMap concatAffineMaps(ArrayRef maps); inline raw_ostream &operator<<(raw_ostream &os, AffineMap map) { map.print(os); diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index 59df75d..94aea94 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -583,16 +583,14 @@ public: /// Generates a new ElementsAttr by mapping each int value to a new /// underlying APInt. The new values can represent either a integer or float. /// This ElementsAttr should contain integers. - ElementsAttr - mapValues(Type newElementType, - llvm::function_ref mapping) const; + ElementsAttr mapValues(Type newElementType, + function_ref mapping) const; /// Generates a new ElementsAttr by mapping each float value to a new /// underlying APInt. The new values can represent either a integer or float. /// This ElementsAttr should contain floats. - ElementsAttr - mapValues(Type newElementType, - llvm::function_ref mapping) const; + ElementsAttr mapValues(Type newElementType, + function_ref mapping) const; /// Method for support type inquiry through isa, cast and dyn_cast. static bool classof(Attribute attr) { @@ -921,16 +919,15 @@ public: /// Generates a new DenseElementsAttr by mapping each int value to a new /// underlying APInt. The new values can represent either a integer or float. /// This underlying type must be an DenseIntElementsAttr. - DenseElementsAttr - mapValues(Type newElementType, - llvm::function_ref mapping) const; + DenseElementsAttr mapValues(Type newElementType, + function_ref mapping) const; /// Generates a new DenseElementsAttr by mapping each float value to a new /// underlying APInt. the new values can represent either a integer or float. /// This underlying type must be an DenseFPElementsAttr. DenseElementsAttr mapValues(Type newElementType, - llvm::function_ref mapping) const; + function_ref mapping) const; protected: /// Return the raw storage data held by this attribute. @@ -993,7 +990,7 @@ public: /// constructing the DenseElementsAttr given the new element type. DenseElementsAttr mapValues(Type newElementType, - llvm::function_ref mapping) const; + function_ref mapping) const; /// Iterator access to the float element values. iterator begin() const { return float_value_begin(); } @@ -1029,9 +1026,8 @@ public: /// Generates a new DenseElementsAttr by mapping each value attribute, and /// constructing the DenseElementsAttr given the new element type. - DenseElementsAttr - mapValues(Type newElementType, - llvm::function_ref mapping) const; + DenseElementsAttr mapValues(Type newElementType, + function_ref mapping) const; /// Iterator access to the integer element values. iterator begin() const { return raw_int_begin(); } diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h index 2ef7bf3..6c5099b 100644 --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -89,7 +89,7 @@ public: BlockArgument *addArgument(Type type); /// Add one argument to the argument list for each type specified in the list. - llvm::iterator_range addArguments(ArrayRef types); + iterator_range addArguments(ArrayRef types); /// Erase the argument at 'index' and remove it from the argument list. If /// 'updatePredTerms' is set to true, this argument is also removed from the @@ -175,7 +175,7 @@ public: template class op_iterator : public llvm::mapped_iterator, OpT (*)(Operation &)> { - static OpT unwrap(Operation &op) { return llvm::cast(op); } + static OpT unwrap(Operation &op) { return cast(op); } public: using reference = OpT; @@ -191,7 +191,7 @@ public: /// Return an iterator range over the operations within this block that are of /// 'OpT'. - template llvm::iterator_range> getOps() { + template iterator_range> getOps() { auto endIt = end(); return {op_filter_iterator(begin(), endIt), op_filter_iterator(endIt, endIt)}; @@ -205,7 +205,7 @@ public: /// Return an iterator range over the operation within this block excluding /// the terminator operation at the end. - llvm::iterator_range without_terminator() { + iterator_range without_terminator() { if (begin() == end()) return {begin(), end()}; auto endIt = --end(); @@ -230,7 +230,7 @@ public: return pred_iterator((BlockOperand *)getFirstUse()); } pred_iterator pred_end() { return pred_iterator(nullptr); } - llvm::iterator_range getPredecessors() { + iterator_range getPredecessors() { return {pred_begin(), pred_end()}; } diff --git a/mlir/include/mlir/IR/BlockAndValueMapping.h b/mlir/include/mlir/IR/BlockAndValueMapping.h index bd69aa2..cd15d45 100644 --- a/mlir/include/mlir/IR/BlockAndValueMapping.h +++ b/mlir/include/mlir/IR/BlockAndValueMapping.h @@ -85,7 +85,7 @@ private: return it != valueMap.end() ? static_cast(it->second) : value; } - llvm::DenseMap valueMap; + DenseMap valueMap; }; } // end namespace mlir diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h index 4baea74..9385de9 100644 --- a/mlir/include/mlir/IR/Diagnostics.h +++ b/mlir/include/mlir/IR/Diagnostics.h @@ -239,10 +239,10 @@ public: Diagnostic &operator<<(OperationName val); /// Stream in a range. - template Diagnostic &operator<<(llvm::iterator_range range) { + template Diagnostic &operator<<(iterator_range range) { return appendRange(range); } - template Diagnostic &operator<<(llvm::ArrayRef range) { + template Diagnostic &operator<<(ArrayRef range) { return appendRange(range); } @@ -277,16 +277,16 @@ public: /// Attaches a note to this diagnostic. A new location may be optionally /// provided, if not, then the location defaults to the one specified for this /// diagnostic. Notes may not be attached to other notes. - Diagnostic &attachNote(llvm::Optional noteLoc = llvm::None); + Diagnostic &attachNote(Optional noteLoc = llvm::None); using note_iterator = NoteIteratorImpl; using const_note_iterator = NoteIteratorImpl; /// Returns the notes held by this diagnostic. - llvm::iterator_range getNotes() { + iterator_range getNotes() { return {notes.begin(), notes.end()}; } - llvm::iterator_range getNotes() const { + iterator_range getNotes() const { return {notes.begin(), notes.end()}; } @@ -360,7 +360,7 @@ public: } /// Attaches a note to this diagnostic. - Diagnostic &attachNote(llvm::Optional noteLoc = llvm::None) { + Diagnostic &attachNote(Optional noteLoc = llvm::None) { assert(isActive() && "diagnostic not active"); return impl->attachNote(noteLoc); } @@ -394,7 +394,7 @@ private: DiagnosticEngine *owner = nullptr; /// The raw diagnostic that is inflight to be reported. - llvm::Optional impl; + Optional impl; }; //===----------------------------------------------------------------------===// @@ -551,7 +551,7 @@ struct SourceMgrDiagnosticHandlerImpl; class SourceMgrDiagnosticHandler : public ScopedDiagnosticHandler { public: SourceMgrDiagnosticHandler(llvm::SourceMgr &mgr, MLIRContext *ctx, - llvm::raw_ostream &os); + raw_ostream &os); SourceMgrDiagnosticHandler(llvm::SourceMgr &mgr, MLIRContext *ctx); ~SourceMgrDiagnosticHandler(); @@ -570,7 +570,7 @@ protected: llvm::SourceMgr &mgr; /// The output stream to use when printing diagnostics. - llvm::raw_ostream &os; + raw_ostream &os; private: /// Convert a location into the given memory buffer into an SMLoc. @@ -597,7 +597,7 @@ struct SourceMgrDiagnosticVerifierHandlerImpl; class SourceMgrDiagnosticVerifierHandler : public SourceMgrDiagnosticHandler { public: SourceMgrDiagnosticVerifierHandler(llvm::SourceMgr &srcMgr, MLIRContext *ctx, - llvm::raw_ostream &out); + raw_ostream &out); SourceMgrDiagnosticVerifierHandler(llvm::SourceMgr &srcMgr, MLIRContext *ctx); ~SourceMgrDiagnosticVerifierHandler(); diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h index 83489f6..6731f543 100644 --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -50,7 +50,7 @@ public: static FuncOp create(Location location, StringRef name, FunctionType type, ArrayRef attrs = {}); static FuncOp create(Location location, StringRef name, FunctionType type, - llvm::iterator_range attrs); + iterator_range attrs); static FuncOp create(Location location, StringRef name, FunctionType type, ArrayRef attrs, ArrayRef argAttrs); diff --git a/mlir/include/mlir/IR/FunctionImplementation.h b/mlir/include/mlir/IR/FunctionImplementation.h index 241d561..c557d58 100644 --- a/mlir/include/mlir/IR/FunctionImplementation.h +++ b/mlir/include/mlir/IR/FunctionImplementation.h @@ -55,7 +55,7 @@ void addArgAndResultAttrs(Builder &builder, OperationState &result, /// function arguments and results, VariadicFlag indicates whether the function /// should have variadic arguments; in case of error, it may populate the last /// argument with a message. -using FuncTypeBuilder = llvm::function_ref, ArrayRef, VariadicFlag, std::string &)>; /// Parses a function signature using `parser`. The `allowVariadic` argument diff --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h index 4656c35..b15b056 100644 --- a/mlir/include/mlir/IR/FunctionSupport.h +++ b/mlir/include/mlir/IR/FunctionSupport.h @@ -191,7 +191,7 @@ public: using args_iterator = Block::args_iterator; args_iterator args_begin() { return front().args_begin(); } args_iterator args_end() { return front().args_end(); } - llvm::iterator_range getArguments() { + iterator_range getArguments() { return {args_begin(), args_end()}; } diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h index 8bcd1d2..6ffe830 100644 --- a/mlir/include/mlir/IR/IntegerSet.h +++ b/mlir/include/mlir/IR/IntegerSet.h @@ -108,7 +108,7 @@ public: /// Walk all of the AffineExpr's in this set's constraints. Each node in an /// expression tree is visited in postorder. - void walkExprs(llvm::function_ref callback) const; + void walkExprs(function_ref callback) const; void print(raw_ostream &os) const; void dump() const; diff --git a/mlir/include/mlir/IR/Module.h b/mlir/include/mlir/IR/Module.h index 1ff885d..52d2455 100644 --- a/mlir/include/mlir/IR/Module.h +++ b/mlir/include/mlir/IR/Module.h @@ -81,7 +81,7 @@ public: /// This returns a range of operations of the given type 'T' held within the /// module. - template llvm::iterator_range> getOps() { + template iterator_range> getOps() { return getBody()->getOps(); } diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 89ab014..c220120 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -54,7 +54,7 @@ public: explicit operator bool() const { return failed(*this); } }; /// This class implements `Optional` functionality for ParseResult. We don't -/// directly use llvm::Optional here, because it provides an implicit conversion +/// directly use Optional here, because it provides an implicit conversion /// to 'bool' which we want to avoid. This class is used to implement tri-state /// 'parseOptional' functions that may have a failure mode when parsing that /// shouldn't be attributed to "not present". @@ -85,9 +85,8 @@ namespace impl { /// region's only block if it does not have a terminator already. If the region /// is empty, insert a new block first. `buildTerminatorOp` should return the /// terminator operation to insert. -void ensureRegionTerminator( - Region ®ion, Location loc, - llvm::function_ref buildTerminatorOp); +void ensureRegionTerminator(Region ®ion, Location loc, + function_ref buildTerminatorOp); /// Templated version that fills the generates the provided operation type. template void ensureRegionTerminator(Region ®ion, Builder &builder, Location loc) { @@ -258,8 +257,8 @@ inline bool operator!=(OpState lhs, OpState rhs) { } /// This class represents a single result from folding an operation. -class OpFoldResult : public llvm::PointerUnion { - using llvm::PointerUnion::PointerUnion; +class OpFoldResult : public PointerUnion { + using PointerUnion::PointerUnion; }; /// This template defines the foldHook as used by AbstractOperation. @@ -1142,7 +1141,7 @@ private: /// }; /// template class Model { /// unsigned getNumInputs(Operation *op) final { -/// return llvm::cast(op).getNumInputs(); +/// return cast(op).getNumInputs(); /// } /// }; /// }; diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index ac78647..2159d10 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -132,7 +132,7 @@ public: template OpTy getParentOfType() { auto *op = this; while ((op = op->getParentOp())) - if (auto parentOp = llvm::dyn_cast(op)) + if (auto parentOp = dyn_cast(op)) return parentOp; return OpTy(); } @@ -339,7 +339,7 @@ public: // Allow access to the constructor. friend Operation; }; - using dialect_attr_range = llvm::iterator_range; + using dialect_attr_range = iterator_range; /// Return a range corresponding to the dialect attributes for this operation. dialect_attr_range getDialectAttrs() { diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index 0a0e1ac..23ef0ce 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -212,7 +212,7 @@ private: class OperationName { public: using RepresentationUnion = - llvm::PointerUnion; + PointerUnion; OperationName(AbstractOperation *op) : representation(op) {} OperationName(StringRef name, MLIRContext *context); @@ -511,7 +511,7 @@ public: private: /// Elide large elements attributes if the number of elements is larger than /// the upper limit. - llvm::Optional elementsAttrElementLimit; + Optional elementsAttrElementLimit; /// Print debug information. bool printDebugInfoFlag : 1; @@ -616,9 +616,8 @@ private: /// parameter. class ValueRange final : public detail::indexed_accessor_range_base< - ValueRange, - llvm::PointerUnion, Value *, - Value *, Value *> { + ValueRange, PointerUnion, + Value *, Value *, Value *> { public: using RangeBaseT::RangeBaseT; @@ -646,7 +645,7 @@ public: private: /// The type representing the owner of this range. This is either a list of /// values, operands, or results. - using OwnerT = llvm::PointerUnion; + using OwnerT = PointerUnion; /// See `detail::indexed_accessor_range_base` for details. static OwnerT offset_base(const OwnerT &owner, ptrdiff_t index); diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index 4805152..707bb7c 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -202,7 +202,7 @@ protected: /// A list of the potential operations that may be generated when rewriting /// an op with this pattern. - llvm::SmallVector generatedOps; + SmallVector generatedOps; }; /// OpRewritePattern is a wrapper around RewritePattern that allows for @@ -217,17 +217,17 @@ template struct OpRewritePattern : public RewritePattern { /// Wrappers around the RewritePattern methods that pass the derived op type. void rewrite(Operation *op, std::unique_ptr state, PatternRewriter &rewriter) const final { - rewrite(llvm::cast(op), std::move(state), rewriter); + rewrite(cast(op), std::move(state), rewriter); } void rewrite(Operation *op, PatternRewriter &rewriter) const final { - rewrite(llvm::cast(op), rewriter); + rewrite(cast(op), rewriter); } PatternMatchResult match(Operation *op) const final { - return match(llvm::cast(op)); + return match(cast(op)); } PatternMatchResult matchAndRewrite(Operation *op, PatternRewriter &rewriter) const final { - return matchAndRewrite(llvm::cast(op), rewriter); + return matchAndRewrite(cast(op), rewriter); } /// Rewrite and Match methods that operate on the SourceOp type. These must be diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h index 27b20c2..c1390ad 100644 --- a/mlir/include/mlir/IR/Region.h +++ b/mlir/include/mlir/IR/Region.h @@ -117,7 +117,7 @@ public: /// Emit errors if `noteLoc` is provided; this location is used to point /// to the operation containing the region, the actual error is reported at /// the operation with an offending use. - bool isIsolatedFromAbove(llvm::Optional noteLoc = llvm::None); + bool isIsolatedFromAbove(Optional noteLoc = llvm::None); /// Drop all operand uses from operations within this region, which is /// an essential step in breaking cyclic dependences between references when @@ -150,7 +150,7 @@ public: /// depends on Graphviz to generate the graph. /// This function is defined in ViewRegionGraph and only works with that /// target linked. - void viewGraph(const llvm::Twine ®ionName); + void viewGraph(const Twine ®ionName); void viewGraph(); private: @@ -167,12 +167,11 @@ private: /// parameter. class RegionRange : public detail::indexed_accessor_range_base< - RegionRange, - llvm::PointerUnion *>, + RegionRange, PointerUnion *>, Region *, Region *, Region *> { /// The type representing the owner of this range. This is either a list of /// values, operands, or results. - using OwnerT = llvm::PointerUnion *>; + using OwnerT = PointerUnion *>; public: using RangeBaseT::RangeBaseT; diff --git a/mlir/include/mlir/IR/StandardTypes.h b/mlir/include/mlir/IR/StandardTypes.h index 5634f86..b6b4b6e 100644 --- a/mlir/include/mlir/IR/StandardTypes.h +++ b/mlir/include/mlir/IR/StandardTypes.h @@ -464,10 +464,10 @@ public: Location location); /// Verify the construction of a unranked memref type. - static LogicalResult - verifyConstructionInvariants(llvm::Optional loc, - MLIRContext *context, Type elementType, - unsigned memorySpace); + static LogicalResult verifyConstructionInvariants(Optional loc, + MLIRContext *context, + Type elementType, + unsigned memorySpace); ArrayRef getShape() const { return llvm::None; } diff --git a/mlir/include/mlir/IR/TypeUtilities.h b/mlir/include/mlir/IR/TypeUtilities.h index c1d1095..2cce4db 100644 --- a/mlir/include/mlir/IR/TypeUtilities.h +++ b/mlir/include/mlir/IR/TypeUtilities.h @@ -84,8 +84,7 @@ private: static Type unwrap(Value *value); }; -using OperandElementTypeRange = - llvm::iterator_range; +using OperandElementTypeRange = iterator_range; // An iterator for the tensor element types of an op's results of shaped types. class ResultElementTypeIterator final @@ -102,7 +101,7 @@ private: static Type unwrap(Value *value); }; -using ResultElementTypeRange = llvm::iterator_range; +using ResultElementTypeRange = iterator_range; } // end namespace mlir diff --git a/mlir/include/mlir/IR/UseDefLists.h b/mlir/include/mlir/IR/UseDefLists.h index fe0e9e0..96e4ace 100644 --- a/mlir/include/mlir/IR/UseDefLists.h +++ b/mlir/include/mlir/IR/UseDefLists.h @@ -46,7 +46,7 @@ public: inline bool hasOneUse() const; using use_iterator = ValueUseIterator; - using use_range = llvm::iterator_range; + using use_range = iterator_range; inline use_iterator use_begin() const; inline use_iterator use_end() const; @@ -55,7 +55,7 @@ public: inline use_range getUses() const; using user_iterator = ValueUserIterator; - using user_range = llvm::iterator_range; + using user_range = iterator_range; inline user_iterator user_begin() const; inline user_iterator user_end() const; diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index 110c74f..34c74c8 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -82,7 +82,7 @@ public: Region *getParentRegion(); using use_iterator = ValueUseIterator; - using use_range = llvm::iterator_range; + using use_range = iterator_range; inline use_iterator use_begin(); inline use_iterator use_end(); @@ -112,7 +112,7 @@ inline auto Value::use_begin() -> use_iterator { inline auto Value::use_end() -> use_iterator { return use_iterator(nullptr); } -inline auto Value::getUses() -> llvm::iterator_range { +inline auto Value::getUses() -> iterator_range { return {use_begin(), use_end()}; } diff --git a/mlir/include/mlir/IR/Visitors.h b/mlir/include/mlir/IR/Visitors.h index 395a4e7..50d6562 100644 --- a/mlir/include/mlir/IR/Visitors.h +++ b/mlir/include/mlir/IR/Visitors.h @@ -94,7 +94,7 @@ template < typename RetT = decltype(std::declval()(std::declval()))> typename std::enable_if::value, RetT>::type walkOperations(Operation *op, FuncTy &&callback) { - return detail::walkOperations(op, llvm::function_ref(callback)); + return detail::walkOperations(op, function_ref(callback)); } /// Walk all of the operations of type 'ArgT' nested under and including the diff --git a/mlir/include/mlir/Pass/AnalysisManager.h b/mlir/include/mlir/Pass/AnalysisManager.h index 6c37223..e233a4a 100644 --- a/mlir/include/mlir/Pass/AnalysisManager.h +++ b/mlir/include/mlir/Pass/AnalysisManager.h @@ -128,10 +128,10 @@ template struct AnalysisModel : public AnalysisConcept { class AnalysisMap { /// A mapping between an analysis id and an existing analysis instance. using ConceptMap = - llvm::DenseMap>; + DenseMap>; /// Utility to return the name of the given analysis class. - template static llvm::StringRef getAnalysisName() { + template static StringRef getAnalysisName() { StringRef name = llvm::getTypeName(); if (!name.consume_front("mlir::")) name.consume_front("(anonymous namespace)::"); @@ -165,7 +165,7 @@ public: /// Get a cached analysis instance if one exists, otherwise return null. template - llvm::Optional> getCachedAnalysis() const { + Optional> getCachedAnalysis() const { auto res = analyses.find(AnalysisID::getID()); if (res == analyses.end()) return llvm::None; @@ -206,7 +206,7 @@ struct NestedAnalysisMap { void invalidate(const PreservedAnalyses &pa); /// The cached analyses for nested operations. - llvm::DenseMap> childAnalyses; + DenseMap> childAnalyses; /// The analyses for the owning module. detail::AnalysisMap analyses; @@ -224,8 +224,8 @@ class ModuleAnalysisManager; /// accessible via 'slice'. This class is intended to be passed around by value, /// and cannot be constructed directly. class AnalysisManager { - using ParentPointerT = llvm::PointerUnion; + using ParentPointerT = + PointerUnion; public: using PreservedAnalyses = detail::PreservedAnalyses; @@ -233,7 +233,7 @@ public: // Query for a cached analysis on the given parent operation. The analysis may // not exist and if it does it may be out-of-date. template - llvm::Optional> + Optional> getCachedParentAnalysis(Operation *parentOp) const { ParentPointerT curParent = parent; while (auto *parentAM = curParent.dyn_cast()) { @@ -251,7 +251,7 @@ public: // Query for a cached entry of the given analysis on the current operation. template - llvm::Optional> getCachedAnalysis() const { + Optional> getCachedAnalysis() const { return impl->analyses.getCachedAnalysis(); } @@ -262,7 +262,7 @@ public: /// Query for a cached analysis of a child operation, or return null. template - llvm::Optional> + Optional> getCachedChildAnalysis(Operation *op) const { assert(op->getParentOp() == impl->getOperation()); auto it = impl->childAnalyses.find(op); @@ -297,8 +297,7 @@ private: /// A reference to the parent analysis manager, or the top-level module /// analysis manager. - llvm::PointerUnion - parent; + ParentPointerT parent; /// A reference to the impl analysis map within the parent analysis manager. detail::NestedAnalysisMap *impl; diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index 274ae9d..380b097 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -68,7 +68,7 @@ public: /// Returns the name of the operation that this pass operates on, or None if /// this is a generic OperationPass. - llvm::Optional getOpName() const { return opName; } + Optional getOpName() const { return opName; } /// Prints out the pass in the textual representation of pipelines. If this is /// an adaptor pass, print with the op_name(sub_pass,...) format. @@ -100,8 +100,7 @@ public: MutableArrayRef getStatistics() { return statistics; } protected: - explicit Pass(const PassID *passID, - llvm::Optional opName = llvm::None) + explicit Pass(const PassID *passID, Optional opName = llvm::None) : passID(passID), opName(opName) {} /// Returns the current pass state. @@ -143,10 +142,10 @@ private: /// The name of the operation that this pass operates on, or None if this is a /// generic OperationPass. - llvm::Optional opName; + Optional opName; /// The current execution state for the pass. - llvm::Optional passState; + Optional passState; /// The set of statistics held by this pass. std::vector statistics; @@ -170,7 +169,7 @@ public: } protected: - explicit PassModel(llvm::Optional opName = llvm::None) + explicit PassModel(Optional opName = llvm::None) : BasePassT(PassID::getID(), opName) {} /// Signal that some invariant was broken when running. The IR is allowed to @@ -187,7 +186,7 @@ protected: /// Query a cached instance of an analysis for the current ir unit if one /// exists. template - llvm::Optional> getCachedAnalysis() { + Optional> getCachedAnalysis() { return this->getAnalysisManager().template getCachedAnalysis(); } @@ -219,13 +218,13 @@ protected: /// Returns the analysis for the parent operation if it exists. template - llvm::Optional> + Optional> getCachedParentAnalysis(Operation *parent) { return this->getAnalysisManager() .template getCachedParentAnalysis(parent); } template - llvm::Optional> getCachedParentAnalysis() { + Optional> getCachedParentAnalysis() { return this->getAnalysisManager() .template getCachedParentAnalysis( this->getOperation()->getParentOp()); @@ -233,7 +232,7 @@ protected: /// Returns the analysis for the given child operation if it exists. template - llvm::Optional> + Optional> getCachedChildAnalysis(Operation *child) { return this->getAnalysisManager() .template getCachedChildAnalysis(child); diff --git a/mlir/include/mlir/Pass/PassInstrumentation.h b/mlir/include/mlir/Pass/PassInstrumentation.h index e801842..4b61850 100644 --- a/mlir/include/mlir/Pass/PassInstrumentation.h +++ b/mlir/include/mlir/Pass/PassInstrumentation.h @@ -83,14 +83,14 @@ public: /// A callback to run before an analysis is computed. This function takes the /// name of the analysis to be computed, its AnalysisID, as well as the /// current operation being analyzed. - virtual void runBeforeAnalysis(llvm::StringRef name, AnalysisID *id, + virtual void runBeforeAnalysis(StringRef name, AnalysisID *id, Operation *op) {} /// A callback to run before an analysis is computed. This function takes the /// name of the analysis that was computed, its AnalysisID, as well as the /// current operation being analyzed. - virtual void runAfterAnalysis(llvm::StringRef name, AnalysisID *id, - Operation *op) {} + virtual void runAfterAnalysis(StringRef name, AnalysisID *id, Operation *op) { + } }; /// This class holds a collection of PassInstrumentation objects, and invokes @@ -122,10 +122,10 @@ public: void runAfterPassFailed(Pass *pass, Operation *op); /// See PassInstrumentation::runBeforeAnalysis for details. - void runBeforeAnalysis(llvm::StringRef name, AnalysisID *id, Operation *op); + void runBeforeAnalysis(StringRef name, AnalysisID *id, Operation *op); /// See PassInstrumentation::runAfterAnalysis for details. - void runAfterAnalysis(llvm::StringRef name, AnalysisID *id, Operation *op); + void runAfterAnalysis(StringRef name, AnalysisID *id, Operation *op); /// Add the given instrumentation to the collection. void addInstrumentation(std::unique_ptr pi); diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h index d7c73d8..9de8ace 100644 --- a/mlir/include/mlir/Pass/PassManager.h +++ b/mlir/include/mlir/Pass/PassManager.h @@ -62,7 +62,7 @@ public: llvm::pointee_iterator>::iterator>; pass_iterator begin(); pass_iterator end(); - llvm::iterator_range getPasses() { return {begin(), end()}; } + iterator_range getPasses() { return {begin(), end()}; } /// Run the held passes over the given operation. LogicalResult run(Operation *op, AnalysisManager am); diff --git a/mlir/include/mlir/Quantizer/Support/Configuration.h b/mlir/include/mlir/Quantizer/Support/Configuration.h index a260824..17a472d 100644 --- a/mlir/include/mlir/Quantizer/Support/Configuration.h +++ b/mlir/include/mlir/Quantizer/Support/Configuration.h @@ -74,7 +74,7 @@ public: return candidateTypes[index]; } - llvm::ArrayRef getCandidateTypes() const { + ArrayRef getCandidateTypes() const { return candidateTypes; } @@ -84,8 +84,8 @@ public: } /// Gets a mask with every candidate type except those in the given mask. - llvm::SmallBitVector getCandidateTypeDisabledExceptMask( - llvm::ArrayRef exceptOrdinals) const { + llvm::SmallBitVector + getCandidateTypeDisabledExceptMask(ArrayRef exceptOrdinals) const { llvm::SmallBitVector disabled(allCandidateTypesMask); for (unsigned ordinal : exceptOrdinals) { disabled.reset(ordinal); diff --git a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h index 63f62dbee..070b3c3 100644 --- a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h +++ b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h @@ -68,7 +68,7 @@ public: }; // Vector and iterator over nodes. - using node_vector = llvm::SmallVector; + using node_vector = SmallVector; using iterator = node_vector::iterator; using const_iterator = node_vector::const_iterator; @@ -100,12 +100,11 @@ public: const TargetConfiguration &config) {} /// Prints the node label, suitable for one-line display. - virtual void printLabel(llvm::raw_ostream &os) const; + virtual void printLabel(raw_ostream &os) const; - template - void findChildrenOfKind(llvm::SmallVectorImpl &found) { + template void findChildrenOfKind(SmallVectorImpl &found) { for (CAGNode *child : *this) { - T *ofKind = llvm::dyn_cast(child); + T *ofKind = dyn_cast(child); if (ofKind) { found.push_back(ofKind); } @@ -173,7 +172,7 @@ public: void propagate(SolverContext &solverContext, const TargetConfiguration &config) override; - void printLabel(llvm::raw_ostream &os) const override; + void printLabel(raw_ostream &os) const override; /// Given the anchor metadata and resolved solutions, chooses the most /// salient and returns an appropriate type to represent it. @@ -213,7 +212,7 @@ public: Value *getValue() const final { return op->getOperand(operandIdx); } - void printLabel(llvm::raw_ostream &os) const override; + void printLabel(raw_ostream &os) const override; private: Operation *op; @@ -234,7 +233,7 @@ public: Operation *getOp() const final { return resultValue->getDefiningOp(); } Value *getValue() const final { return resultValue; } - void printLabel(llvm::raw_ostream &os) const override; + void printLabel(raw_ostream &os) const override; private: Value *resultValue; @@ -275,8 +274,7 @@ public: /// Adds a relation constraint with incoming 'from' anchors and outgoing 'to' /// anchors. template - T *addUniqueConstraint(llvm::ArrayRef anchors, - Args... args) { + T *addUniqueConstraint(ArrayRef anchors, Args... args) { static_assert(std::is_convertible(), "T must be a CAGConstraingNode"); T *constraintNode = addNode(std::make_unique(args...)); @@ -288,7 +286,7 @@ public: /// Adds a unidirectional constraint from a node to an array of target nodes. template T *addUnidirectionalConstraint(CAGAnchorNode *fromAnchor, - llvm::ArrayRef toAnchors, + ArrayRef toAnchors, Args... args) { static_assert(std::is_convertible(), "T must be a CAGConstraingNode"); @@ -301,10 +299,10 @@ public: } template - T *addClusteredConstraint(llvm::ArrayRef anchors) { + T *addClusteredConstraint(ArrayRef anchors) { static_assert(std::is_convertible(), "T must be a CAGConstraingNode"); - llvm::SmallVector cluster; + SmallVector cluster; for (auto *anchor : anchors) { anchor->findChildrenOfKind(cluster); } @@ -356,14 +354,11 @@ private: SolverContext &context; std::vector allNodes; - llvm::DenseMap, CAGOperandAnchor *> - operandAnchors; - llvm::DenseMap, CAGResultAnchor *> - resultAnchors; + DenseMap, CAGOperandAnchor *> operandAnchors; + DenseMap, CAGResultAnchor *> resultAnchors; }; -inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, - const CAGNode &node) { +inline raw_ostream &operator<<(raw_ostream &os, const CAGNode &node) { node.printLabel(os); return os; } diff --git a/mlir/include/mlir/Quantizer/Support/Metadata.h b/mlir/include/mlir/Quantizer/Support/Metadata.h index 4e6fc09..6c327d9 100644 --- a/mlir/include/mlir/Quantizer/Support/Metadata.h +++ b/mlir/include/mlir/Quantizer/Support/Metadata.h @@ -101,7 +101,7 @@ struct CAGUniformMetadata { DiscreteScaleZeroPointFact explicitScaleZeroPoint; /// Prints a summary of the metadata suitable for display in a graph label. - void printSummary(llvm::raw_ostream &os) const; + void printSummary(raw_ostream &os) const; }; } // end namespace quantizer diff --git a/mlir/include/mlir/Quantizer/Support/Statistics.h b/mlir/include/mlir/Quantizer/Support/Statistics.h index e1f130b..744c5b6 100644 --- a/mlir/include/mlir/Quantizer/Support/Statistics.h +++ b/mlir/include/mlir/Quantizer/Support/Statistics.h @@ -85,8 +85,7 @@ private: Attribute attr; }; -llvm::raw_ostream &operator<<(llvm::raw_ostream &os, - const TensorAxisStatistics &stats); +raw_ostream &operator<<(raw_ostream &os, const TensorAxisStatistics &stats); } // end namespace quantizer } // end namespace mlir diff --git a/mlir/include/mlir/Support/Functional.h b/mlir/include/mlir/Support/Functional.h index eca7504..e8bf394 100644 --- a/mlir/include/mlir/Support/Functional.h +++ b/mlir/include/mlir/Support/Functional.h @@ -18,6 +18,7 @@ #ifndef MLIR_SUPPORT_FUNCTIONAL_H_ #define MLIR_SUPPORT_FUNCTIONAL_H_ +#include "mlir/Support/LLVM.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Casting.h" @@ -34,10 +35,9 @@ namespace functional { /// Map with iterators. template auto map(Fn fun, IterType begin, IterType end) - -> llvm::SmallVector::type, - 8> { + -> SmallVector::type, 8> { using R = typename std::result_of::type; - llvm::SmallVector res; + SmallVector res; // auto i works with both pointer types and value types with an operator*. // auto *i only works for pointer types. for (auto i = begin; i != end; ++i) { @@ -58,13 +58,12 @@ auto map(Fn fun, ContainerType input) /// TODO(ntv): make variadic when needed. template auto zipMap(Fn fun, ContainerType1 input1, ContainerType2 input2) - -> llvm::SmallVector< - typename std::result_of::type, - 8> { + -> SmallVector::type, + 8> { using R = typename std::result_of::type; - llvm::SmallVector res; + SmallVector res; auto zipIter = llvm::zip(input1, input2); for (auto it : zipIter) { res.push_back(fun(std::get<0>(it), std::get<1>(it))); @@ -104,7 +103,7 @@ void zipApply(Fn fun, ContainerType1 input1, ContainerType2 input2) { /// Operation::operand_range types. template inline std::function makePtrDynCaster() { - return [](T *val) { return llvm::dyn_cast(val); }; + return [](T *val) { return dyn_cast(val); }; } /// Simple ScopeGuard. diff --git a/mlir/include/mlir/Support/MlirOptMain.h b/mlir/include/mlir/Support/MlirOptMain.h index 66b1a87..be8e432 100644 --- a/mlir/include/mlir/Support/MlirOptMain.h +++ b/mlir/include/mlir/Support/MlirOptMain.h @@ -26,6 +26,7 @@ namespace llvm { class raw_ostream; class MemoryBuffer; } // end namespace llvm + namespace mlir { struct LogicalResult; class PassPipelineCLParser; diff --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h index b7d95b6..fe1f898 100644 --- a/mlir/include/mlir/Support/StorageUniquer.h +++ b/mlir/include/mlir/Support/StorageUniquer.h @@ -202,7 +202,7 @@ private: /// Implementation for getting/creating an instance of a derived type with /// complex storage. BaseStorage *getImpl(unsigned kind, unsigned hashValue, - llvm::function_ref isEqual, + function_ref isEqual, std::function ctorFn); /// Implementation for getting/creating an instance of a derived type with @@ -213,7 +213,7 @@ private: /// Implementation for erasing an instance of a derived type with complex /// storage. void eraseImpl(unsigned kind, unsigned hashValue, - llvm::function_ref isEqual, + function_ref isEqual, std::function cleanupFn); /// The internal implementation class. @@ -263,7 +263,7 @@ private: ::llvm::hash_code>::type getHash(unsigned kind, const DerivedKey &derivedKey) { return llvm::hash_combine( - kind, llvm::DenseMapInfo::getHashValue(derivedKey)); + kind, DenseMapInfo::getHashValue(derivedKey)); } }; } // end namespace mlir diff --git a/mlir/include/mlir/Support/ToolUtilities.h b/mlir/include/mlir/Support/ToolUtilities.h index d1c898f..13a3742 100644 --- a/mlir/include/mlir/Support/ToolUtilities.h +++ b/mlir/include/mlir/Support/ToolUtilities.h @@ -22,6 +22,7 @@ #ifndef MLIR_SUPPORT_TOOLUTILITIES_H #define MLIR_SUPPORT_TOOLUTILITIES_H +#include "mlir/Support/LLVM.h" #include "llvm/ADT/STLExtras.h" #include @@ -32,8 +33,8 @@ class MemoryBuffer; namespace mlir { struct LogicalResult; -using ChunkBufferHandler = llvm::function_ref chunkBuffer, llvm::raw_ostream &os)>; +using ChunkBufferHandler = function_ref chunkBuffer, raw_ostream &os)>; /// Splits the specified buffer on a marker (`// -----`), processes each chunk /// independently according to the normal `processChunkBuffer` logic, and writes @@ -43,8 +44,7 @@ using ChunkBufferHandler = llvm::function_ref originalBuffer, - ChunkBufferHandler processChunkBuffer, - llvm::raw_ostream &os); + ChunkBufferHandler processChunkBuffer, raw_ostream &os); } // namespace mlir #endif // MLIR_SUPPORT_TOOLUTILITIES_H diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h index e9456f4..8bd1c91 100644 --- a/mlir/include/mlir/TableGen/Pattern.h +++ b/mlir/include/mlir/TableGen/Pattern.h @@ -46,7 +46,7 @@ namespace tblgen { // is shared among multiple patterns to avoid creating the wrapper object for // the same op again and again. But this map will continuously grow. using RecordOperatorMap = - llvm::DenseMap>; + DenseMap>; class Pattern; diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h index 0b65218..da2670a 100644 --- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h +++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h @@ -116,13 +116,13 @@ private: std::unique_ptr llvmModule; // Mappings between llvm.mlir.global definitions and corresponding globals. - llvm::DenseMap globalsMapping; + DenseMap globalsMapping; protected: // Mappings between original and translated values, used for lookups. llvm::StringMap functionMapping; - llvm::DenseMap valueMapping; - llvm::DenseMap blockMapping; + DenseMap valueMapping; + DenseMap blockMapping; }; } // namespace LLVM diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 249b4c1..814f220 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -94,7 +94,7 @@ public: private: /// The remapping information for each of the original arguments. - SmallVector, 4> remappedInputs; + SmallVector, 4> remappedInputs; /// The set of new argument types. SmallVector argTypes; @@ -133,7 +133,7 @@ public: /// This function converts the type signature of the given block, by invoking /// 'convertSignatureArg' for each argument. This function should return a /// valid conversion for the signature on success, None otherwise. - llvm::Optional convertBlockSignature(Block *block); + Optional convertBlockSignature(Block *block); /// This hook allows for materializing a conversion from a set of types into /// one result type by generating a cast operation of some kind. The generated @@ -236,13 +236,13 @@ struct OpConversionPattern : public ConversionPattern { /// type. void rewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { - rewrite(llvm::cast(op), operands, rewriter); + rewrite(cast(op), operands, rewriter); } void rewrite(Operation *op, ArrayRef properOperands, ArrayRef destinations, ArrayRef> operands, ConversionPatternRewriter &rewriter) const final { - rewrite(llvm::cast(op), properOperands, destinations, operands, + rewrite(cast(op), properOperands, destinations, operands, rewriter); } PatternMatchResult @@ -250,13 +250,13 @@ struct OpConversionPattern : public ConversionPattern { ArrayRef destinations, ArrayRef> operands, ConversionPatternRewriter &rewriter) const final { - return matchAndRewrite(llvm::cast(op), properOperands, - destinations, operands, rewriter); + return matchAndRewrite(cast(op), properOperands, destinations, + operands, rewriter); } PatternMatchResult matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { - return matchAndRewrite(llvm::cast(op), operands, rewriter); + return matchAndRewrite(cast(op), operands, rewriter); } // TODO(b/142763075): Use OperandAdaptor when it supports access to unnamed diff --git a/mlir/include/mlir/Transforms/FoldUtils.h b/mlir/include/mlir/Transforms/FoldUtils.h index bbf2c0e..bdf88d3 100644 --- a/mlir/include/mlir/Transforms/FoldUtils.h +++ b/mlir/include/mlir/Transforms/FoldUtils.h @@ -66,10 +66,10 @@ public: /// before it is replaced. 'processGeneratedConstants' is invoked for any new /// operations generated when folding. If the op was completely folded it is /// erased. - LogicalResult tryToFold( - Operation *op, - llvm::function_ref processGeneratedConstants = nullptr, - llvm::function_ref preReplaceAction = nullptr); + LogicalResult + tryToFold(Operation *op, + function_ref processGeneratedConstants = nullptr, + function_ref preReplaceAction = nullptr); /// Notifies that the given constant `op` should be remove from this /// OperationFolder's internal bookkeeping. @@ -125,9 +125,9 @@ private: /// Tries to perform folding on the given `op`. If successful, populates /// `results` with the results of the folding. - LogicalResult tryToFold(Operation *op, SmallVectorImpl &results, - llvm::function_ref - processGeneratedConstants = nullptr); + LogicalResult tryToFold( + Operation *op, SmallVectorImpl &results, + function_ref processGeneratedConstants = nullptr); /// Try to get or create a new constant entry. On success this returns the /// constant operation, nullptr otherwise. diff --git a/mlir/include/mlir/Transforms/InliningUtils.h b/mlir/include/mlir/Transforms/InliningUtils.h index a022188..590b46a 100644 --- a/mlir/include/mlir/Transforms/InliningUtils.h +++ b/mlir/include/mlir/Transforms/InliningUtils.h @@ -143,7 +143,7 @@ public: /// Process a set of blocks that have been inlined. This callback is invoked /// *before* inlined terminator operations have been processed. virtual void - processInlinedBlocks(llvm::iterator_range inlinedBlocks) {} + processInlinedBlocks(iterator_range inlinedBlocks) {} /// These hooks mirror the hooks for the DialectInlinerInterface, with default /// implementations that call the hook on the handler for the dialect 'op' is @@ -188,7 +188,7 @@ public: LogicalResult inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, BlockAndValueMapping &mapper, ArrayRef resultsToReplace, - llvm::Optional inlineLoc = llvm::None, + Optional inlineLoc = llvm::None, bool shouldCloneInlinedRegion = true); /// This function is an overload of the above 'inlineRegion' that allows for @@ -198,7 +198,7 @@ LogicalResult inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, ArrayRef inlinedOperands, ArrayRef resultsToReplace, - llvm::Optional inlineLoc = llvm::None, + Optional inlineLoc = llvm::None, bool shouldCloneInlinedRegion = true); /// This function inlines a given region, 'src', of a callable operation, diff --git a/mlir/include/mlir/Transforms/LoopFusionUtils.h b/mlir/include/mlir/Transforms/LoopFusionUtils.h index b6d1ea4..af84b89 100644 --- a/mlir/include/mlir/Transforms/LoopFusionUtils.h +++ b/mlir/include/mlir/Transforms/LoopFusionUtils.h @@ -24,6 +24,7 @@ #ifndef MLIR_TRANSFORMS_LOOP_FUSION_UTILS_H #define MLIR_TRANSFORMS_LOOP_FUSION_UTILS_H +#include "mlir/Support/LLVM.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -64,11 +65,11 @@ FusionResult canFuseLoops(AffineForOp srcForOp, AffineForOp dstForOp, /// loop body. struct LoopNestStats { /// Map from AffineForOp to immediate child AffineForOps in its loop body. - llvm::DenseMap> loopMap; + DenseMap> loopMap; /// Map from AffineForOp to count of operations in its loop body. - llvm::DenseMap opCountMap; + DenseMap opCountMap; /// Map from AffineForOp to its constant trip count. - llvm::DenseMap tripCountMap; + DenseMap tripCountMap; }; /// Collect loop nest statistics (eg. loop trip count and operation count) diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h index ffdeeb2..5480a9a 100644 --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -44,7 +44,7 @@ std::unique_ptr createCSEPass(); /// Creates a pass to vectorize loops, operations and data types using a /// target-independent, n-D super-vector abstraction. std::unique_ptr> -createVectorizePass(llvm::ArrayRef virtualVectorSize); +createVectorizePass(ArrayRef virtualVectorSize); /// Creates a pass to allow independent testing of vectorizer functionality with /// FileCheck. @@ -52,7 +52,7 @@ std::unique_ptr> createVectorizerTestPass(); /// Creates a pass to lower super-vectors to target-dependent HW vectors. std::unique_ptr> -createMaterializeVectorsPass(llvm::ArrayRef vectorSize); +createMaterializeVectorsPass(ArrayRef vectorSize); /// Creates a loop unrolling pass with the provided parameters. /// 'getUnrollFactor' is a function callback for clients to supply a function diff --git a/mlir/include/mlir/Transforms/RegionUtils.h b/mlir/include/mlir/Transforms/RegionUtils.h index 944f601..48080b2 100644 --- a/mlir/include/mlir/Transforms/RegionUtils.h +++ b/mlir/include/mlir/Transforms/RegionUtils.h @@ -47,7 +47,7 @@ void visitUsedValuesDefinedAbove(Region ®ion, Region &limit, /// Calls `callback` for each use of a value within any of the regions provided /// that was defined in one of the ancestors. -void visitUsedValuesDefinedAbove(llvm::MutableArrayRef regions, +void visitUsedValuesDefinedAbove(MutableArrayRef regions, function_ref callback); /// Fill `values` with a list of values defined at the ancestors of the `limit` @@ -57,14 +57,14 @@ void getUsedValuesDefinedAbove(Region ®ion, Region &limit, /// Fill `values` with a list of values used within any of the regions provided /// but defined in one of the ancestors. -void getUsedValuesDefinedAbove(llvm::MutableArrayRef regions, +void getUsedValuesDefinedAbove(MutableArrayRef regions, llvm::SetVector &values); /// Run a set of structural simplifications over the given regions. This /// includes transformations like unreachable block elimination, dead argument /// elimination, as well as some other DCE. This function returns success if any /// of the regions were simplified, failure otherwise. -LogicalResult simplifyRegions(llvm::MutableArrayRef regions); +LogicalResult simplifyRegions(MutableArrayRef regions); } // namespace mlir diff --git a/mlir/include/mlir/Transforms/ViewOpGraph.h b/mlir/include/mlir/Transforms/ViewOpGraph.h index 4f9856e..41f5eb5 100644 --- a/mlir/include/mlir/Transforms/ViewOpGraph.h +++ b/mlir/include/mlir/Transforms/ViewOpGraph.h @@ -37,13 +37,13 @@ void viewGraph(Block &block, const Twine &name, bool shortNames = false, const Twine &title = "", llvm::GraphProgram::Name program = llvm::GraphProgram::DOT); -llvm::raw_ostream &writeGraph(llvm::raw_ostream &os, Block &block, - bool shortNames = false, const Twine &title = ""); +raw_ostream &writeGraph(raw_ostream &os, Block &block, bool shortNames = false, + const Twine &title = ""); /// Creates a pass to print op graphs. std::unique_ptr> -createPrintOpGraphPass(llvm::raw_ostream &os = llvm::errs(), - bool shortNames = false, const llvm::Twine &title = ""); +createPrintOpGraphPass(raw_ostream &os = llvm::errs(), bool shortNames = false, + const Twine &title = ""); } // end namespace mlir diff --git a/mlir/include/mlir/Transforms/ViewRegionGraph.h b/mlir/include/mlir/Transforms/ViewRegionGraph.h index 57fe1d3..4378d38f 100644 --- a/mlir/include/mlir/Transforms/ViewRegionGraph.h +++ b/mlir/include/mlir/Transforms/ViewRegionGraph.h @@ -37,13 +37,13 @@ void viewGraph(Region ®ion, const Twine &name, bool shortNames = false, const Twine &title = "", llvm::GraphProgram::Name program = llvm::GraphProgram::DOT); -llvm::raw_ostream &writeGraph(llvm::raw_ostream &os, Region ®ion, - bool shortNames = false, const Twine &title = ""); +raw_ostream &writeGraph(raw_ostream &os, Region ®ion, + bool shortNames = false, const Twine &title = ""); /// Creates a pass to print CFG graphs. std::unique_ptr> -createPrintCFGGraphPass(llvm::raw_ostream &os = llvm::errs(), - bool shortNames = false, const llvm::Twine &title = ""); +createPrintCFGGraphPass(raw_ostream &os = llvm::errs(), bool shortNames = false, + const Twine &title = ""); } // end namespace mlir diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp index 9cf7fa8..97868a5 100644 --- a/mlir/lib/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Analysis/AffineAnalysis.cpp @@ -619,7 +619,7 @@ static void computeDirectionVector( const FlatAffineConstraints &srcDomain, const FlatAffineConstraints &dstDomain, unsigned loopDepth, FlatAffineConstraints *dependenceDomain, - llvm::SmallVector *dependenceComponents) { + SmallVector *dependenceComponents) { // Find the number of common loops shared by src and dst accesses. SmallVector commonLoops; unsigned numCommonLoops = @@ -772,8 +772,7 @@ void MemRefAccess::getAccessMap(AffineValueMap *accessMap) const { DependenceResult mlir::checkMemrefAccessDependence( const MemRefAccess &srcAccess, const MemRefAccess &dstAccess, unsigned loopDepth, FlatAffineConstraints *dependenceConstraints, - llvm::SmallVector *dependenceComponents, - bool allowRAR) { + SmallVector *dependenceComponents, bool allowRAR) { LLVM_DEBUG(llvm::dbgs() << "Checking for dependence at depth: " << Twine(loopDepth) << " between:\n";); LLVM_DEBUG(srcAccess.opInst->dump();); @@ -865,7 +864,7 @@ DependenceResult mlir::checkMemrefAccessDependence( /// rooted at 'forOp' at loop depths in range [1, maxLoopDepth]. void mlir::getDependenceComponents( AffineForOp forOp, unsigned maxLoopDepth, - std::vector> *depCompsVec) { + std::vector> *depCompsVec) { // Collect all load and store ops in loop nest rooted at 'forOp'. SmallVector loadAndStoreOpInsts; forOp.getOperation()->walk([&](Operation *opInst) { @@ -883,7 +882,7 @@ void mlir::getDependenceComponents( MemRefAccess dstAccess(dstOpInst); FlatAffineConstraints dependenceConstraints; - llvm::SmallVector depComps; + SmallVector depComps; // TODO(andydavis,bondhugula) Explore whether it would be profitable // to pre-compute and store deps instead of repeatedly checking. DependenceResult result = checkMemrefAccessDependence( diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp index 7f6da8e..d678355 100644 --- a/mlir/lib/Analysis/AffineStructures.cpp +++ b/mlir/lib/Analysis/AffineStructures.cpp @@ -24,6 +24,7 @@ #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/IntegerSet.h" +#include "mlir/Support/LLVM.h" #include "mlir/Support/MathExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/Debug.h" @@ -34,7 +35,6 @@ using namespace mlir; using llvm::SmallDenseMap; using llvm::SmallDenseSet; -using llvm::SmallPtrSet; namespace { @@ -73,10 +73,11 @@ private: // Flattens the expressions in map. Returns failure if 'expr' was unable to be // flattened (i.e., semi-affine expressions not handled yet). -static LogicalResult getFlattenedAffineExprs( - ArrayRef exprs, unsigned numDims, unsigned numSymbols, - std::vector> *flattenedExprs, - FlatAffineConstraints *localVarCst) { +static LogicalResult +getFlattenedAffineExprs(ArrayRef exprs, unsigned numDims, + unsigned numSymbols, + std::vector> *flattenedExprs, + FlatAffineConstraints *localVarCst) { if (exprs.empty()) { localVarCst->reset(numDims, numSymbols); return success(); @@ -109,7 +110,7 @@ static LogicalResult getFlattenedAffineExprs( LogicalResult mlir::getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols, - llvm::SmallVectorImpl *flattenedExpr, + SmallVectorImpl *flattenedExpr, FlatAffineConstraints *localVarCst) { std::vector> flattenedExprs; LogicalResult ret = ::getFlattenedAffineExprs({expr}, numDims, numSymbols, @@ -121,7 +122,7 @@ mlir::getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, /// Flattens the expressions in map. Returns failure if 'expr' was unable to be /// flattened (i.e., semi-affine expressions not handled yet). LogicalResult mlir::getFlattenedAffineExprs( - AffineMap map, std::vector> *flattenedExprs, + AffineMap map, std::vector> *flattenedExprs, FlatAffineConstraints *localVarCst) { if (map.getNumResults() == 0) { localVarCst->reset(map.getNumDims(), map.getNumSymbols()); @@ -133,7 +134,7 @@ LogicalResult mlir::getFlattenedAffineExprs( } LogicalResult mlir::getFlattenedAffineExprs( - IntegerSet set, std::vector> *flattenedExprs, + IntegerSet set, std::vector> *flattenedExprs, FlatAffineConstraints *localVarCst) { if (set.getNumConstraints() == 0) { localVarCst->reset(set.getNumDims(), set.getNumSymbols()); diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index 1d88d09..a8111657 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -97,7 +97,7 @@ void mlir::buildTripCountMapAndOperands( // being an analysis utility, it shouldn't. Replace with a version that just // works with analysis structures (FlatAffineConstraints) and thus doesn't // update the IR. -llvm::Optional mlir::getConstantTripCount(AffineForOp forOp) { +Optional mlir::getConstantTripCount(AffineForOp forOp) { SmallVector operands; AffineMap map; buildTripCountMapAndOperands(forOp, &map, &operands); @@ -197,9 +197,9 @@ static bool isAccessIndexInvariant(Value *iv, Value *index) { return !(AffineValueMap(composeOp).isFunctionOf(0, iv)); } -llvm::DenseSet -mlir::getInvariantAccesses(Value *iv, llvm::ArrayRef indices) { - llvm::DenseSet res; +DenseSet mlir::getInvariantAccesses(Value *iv, + ArrayRef indices) { + DenseSet res; for (unsigned idx = 0, n = indices.size(); idx < n; ++idx) { auto *val = indices[idx]; if (isAccessIndexInvariant(iv, val)) { diff --git a/mlir/lib/Analysis/OpStats.cpp b/mlir/lib/Analysis/OpStats.cpp index f01ec56..1c9f621 100644 --- a/mlir/lib/Analysis/OpStats.cpp +++ b/mlir/lib/Analysis/OpStats.cpp @@ -27,7 +27,7 @@ using namespace mlir; namespace { struct PrintOpStatsPass : public ModulePass { - explicit PrintOpStatsPass(llvm::raw_ostream &os = llvm::errs()) : os(os) {} + explicit PrintOpStatsPass(raw_ostream &os = llvm::errs()) : os(os) {} // Prints the resultant operation statistics post iterating over the module. void runOnModule() override; @@ -37,7 +37,7 @@ struct PrintOpStatsPass : public ModulePass { private: llvm::StringMap opCount; - llvm::raw_ostream &os; + raw_ostream &os; }; } // namespace diff --git a/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp b/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp index d0351e9..80a579d 100644 --- a/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp +++ b/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp @@ -94,7 +94,7 @@ static void checkDependences(ArrayRef loadsAndStores) { getNumCommonSurroundingLoops(*srcOpInst, *dstOpInst); for (unsigned d = 1; d <= numCommonLoops + 1; ++d) { FlatAffineConstraints dependenceConstraints; - llvm::SmallVector dependenceComponents; + SmallVector dependenceComponents; DependenceResult result = checkMemrefAccessDependence( srcAccess, dstAccess, d, &dependenceConstraints, &dependenceComponents); diff --git a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h index e06e88b..23bfa30 100644 --- a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h +++ b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h @@ -94,7 +94,7 @@ private: Operation *funcOp = SymbolTable::lookupNearestSymbolFrom(op, funcName); if (funcOp) - return llvm::cast(*funcOp); + return cast(*funcOp); mlir::OpBuilder b(op->getParentOfType()); return b.create(op->getLoc(), funcName, funcType); diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index 4689736..78fe15d 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -370,13 +370,13 @@ private: [&] { Value *shflValue = rewriter.create( loc, type, shfl, rewriter.getIndexArrayAttr(0)); - return llvm::SmallVector{ + return SmallVector{ accumFactory(loc, value, shflValue, rewriter)}; }, [&] { return llvm::makeArrayRef(value); }); value = rewriter.getInsertionBlock()->getArgument(0); } - return llvm::SmallVector{value}; + return SmallVector{value}; }, // Generate a reduction over the entire warp. This is a specialization // of the above reduction with unconditional accumulation. @@ -394,7 +394,7 @@ private: /*return_value_and_is_valid=*/UnitAttr()); value = accumFactory(loc, value, shflValue, rewriter); } - return llvm::SmallVector{value}; + return SmallVector{value}; }); return rewriter.getInsertionBlock()->getArgument(0); } diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp index 5d6a92f..5bb1845 100644 --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -1603,15 +1603,14 @@ struct ReturnOpLowering : public LLVMLegalizationPattern { // If ReturnOp has 0 or 1 operand, create it and return immediately. if (numArguments == 0) { - rewriter.replaceOpWithNewOp(op, llvm::ArrayRef(), - llvm::ArrayRef(), - op->getAttrs()); + rewriter.replaceOpWithNewOp( + op, ArrayRef(), ArrayRef(), op->getAttrs()); return matchSuccess(); } if (numArguments == 1) { rewriter.replaceOpWithNewOp( - op, llvm::ArrayRef(operands.front()), - llvm::ArrayRef(), op->getAttrs()); + op, ArrayRef(operands.front()), ArrayRef(), + op->getAttrs()); return matchSuccess(); } @@ -1626,9 +1625,8 @@ struct ReturnOpLowering : public LLVMLegalizationPattern { op->getLoc(), packedType, packed, operands[i], rewriter.getI64ArrayAttr(i)); } - rewriter.replaceOpWithNewOp(op, llvm::makeArrayRef(packed), - llvm::ArrayRef(), - op->getAttrs()); + rewriter.replaceOpWithNewOp( + op, llvm::makeArrayRef(packed), ArrayRef(), op->getAttrs()); return matchSuccess(); } }; @@ -1971,7 +1969,7 @@ static void ensureDistinctSuccessors(Block &bb) { auto *terminator = bb.getTerminator(); // Find repeated successors with arguments. - llvm::SmallDenseMap> successorPositions; + llvm::SmallDenseMap> successorPositions; for (int i = 0, e = terminator->getNumSuccessors(); i < e; ++i) { Block *successor = terminator->getSuccessor(i); // Blocks with no arguments are safe even if they appear multiple times diff --git a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp b/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp index d4f362d..721e709 100644 --- a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp +++ b/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp @@ -155,16 +155,16 @@ void coalesceCopy(TransferOpTy transfer, /// Emits remote memory accesses that are clipped to the boundaries of the /// MemRef. template -llvm::SmallVector clip(TransferOpTy transfer, - edsc::MemRefView &view, - ArrayRef ivs) { +SmallVector clip(TransferOpTy transfer, + edsc::MemRefView &view, + ArrayRef ivs) { using namespace mlir::edsc; using namespace edsc::op; using edsc::intrinsics::select; IndexHandle zero(index_t(0)), one(index_t(1)); - llvm::SmallVector memRefAccess(transfer.indices()); - llvm::SmallVector clippedScalarAccessExprs( + SmallVector memRefAccess(transfer.indices()); + SmallVector clippedScalarAccessExprs( memRefAccess.size(), edsc::IndexHandle()); // Indices accessing to remote memory are clipped and their expressions are diff --git a/mlir/lib/Dialect/AffineOps/AffineOps.cpp b/mlir/lib/Dialect/AffineOps/AffineOps.cpp index e58f6f8..8c8c67d 100644 --- a/mlir/lib/Dialect/AffineOps/AffineOps.cpp +++ b/mlir/lib/Dialect/AffineOps/AffineOps.cpp @@ -616,9 +616,8 @@ AffineApplyOp mlir::makeComposedAffineApply(OpBuilder &b, Location loc, // A symbol may appear as a dim in affine.apply operations. This function // canonicalizes dims that are valid symbols into actual symbols. template -static void -canonicalizePromotedSymbols(MapOrSet *mapOrSet, - llvm::SmallVectorImpl *operands) { +static void canonicalizePromotedSymbols(MapOrSet *mapOrSet, + SmallVectorImpl *operands) { if (!mapOrSet || operands->empty()) return; @@ -662,7 +661,7 @@ canonicalizePromotedSymbols(MapOrSet *mapOrSet, template static void canonicalizeMapOrSetAndOperands(MapOrSet *mapOrSet, - llvm::SmallVectorImpl *operands) { + SmallVectorImpl *operands) { static_assert(std::is_same::value || std::is_same::value, "Argument must be either of AffineMap or IntegerSet type"); @@ -738,13 +737,13 @@ canonicalizeMapOrSetAndOperands(MapOrSet *mapOrSet, *operands = resultOperands; } -void mlir::canonicalizeMapAndOperands( - AffineMap *map, llvm::SmallVectorImpl *operands) { +void mlir::canonicalizeMapAndOperands(AffineMap *map, + SmallVectorImpl *operands) { canonicalizeMapOrSetAndOperands(map, operands); } -void mlir::canonicalizeSetAndOperands( - IntegerSet *set, llvm::SmallVectorImpl *operands) { +void mlir::canonicalizeSetAndOperands(IntegerSet *set, + SmallVectorImpl *operands) { canonicalizeMapOrSetAndOperands(set, operands); } diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h b/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h index f0eeba08..955e2ec 100644 --- a/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h @@ -35,7 +35,7 @@ inline quant::UniformQuantizedType getUniformElementType(Type t) { } inline bool hasStorageBitWidth(quant::QuantizedType t, - llvm::ArrayRef checkWidths) { + ArrayRef checkWidths) { unsigned w = t.getStorageType().getIntOrFloatBitWidth(); for (unsigned checkWidth : checkWidths) { if (w == checkWidth) diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index 1c20be6..7324b96 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -237,7 +237,7 @@ KernelDim3 LaunchOp::getBlockSizeOperandValues() { return KernelDim3{getOperand(3), getOperand(4), getOperand(5)}; } -llvm::iterator_range LaunchOp::getKernelArguments() { +iterator_range LaunchOp::getKernelArguments() { auto args = body().getBlocks().front().getArguments(); return llvm::drop_begin(args, LaunchOp::kNumConfigRegionAttributes); } diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index 416a37b..0a6a591 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -69,7 +69,7 @@ static gpu::LaunchFuncOp inlineBeneficiaryOps(gpu::GPUFuncOp kernelFunc, gpu::LaunchFuncOp launch) { OpBuilder kernelBuilder(kernelFunc.getBody()); auto &firstBlock = kernelFunc.getBody().front(); - llvm::SmallVector newLaunchArgs; + SmallVector newLaunchArgs; BlockAndValueMapping map; for (int i = 0, e = launch.getNumKernelOperands(); i < e; ++i) { map.map(launch.getKernelOperand(i), kernelFunc.getArgument(i)); @@ -195,7 +195,7 @@ private: SymbolTable symbolTable(kernelModule); symbolTable.insert(kernelFunc); - llvm::SmallVector symbolDefWorklist = {kernelFunc}; + SmallVector symbolDefWorklist = {kernelFunc}; while (!symbolDefWorklist.empty()) { if (Optional symbolUses = SymbolTable::getSymbolUses(symbolDefWorklist.pop_back_val())) { diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 9ac5645..abbc4e0 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -1227,7 +1227,7 @@ static ParseResult parseLLVMFuncOp(OpAsmParser &parser, auto *body = result.addRegion(); return parser.parseOptionalRegion( - *body, entryArgs, entryArgs.empty() ? llvm::ArrayRef() : argTypes); + *body, entryArgs, entryArgs.empty() ? ArrayRef() : argTypes); } // Print the LLVMFuncOp. Collects argument and result types and passes them to @@ -1499,7 +1499,7 @@ LLVMType LLVMType::get(MLIRContext *context, llvm::Type *llvmType) { /// Get an LLVMType with an llvm type that may cause changes to the underlying /// llvm context when constructed. LLVMType LLVMType::getLocked(LLVMDialect *dialect, - llvm::function_ref typeBuilder) { + function_ref typeBuilder) { // Lock access to the llvm context and build the type. llvm::sys::SmartScopedLock lock(dialect->impl->mutex); return get(dialect->getContext(), typeBuilder()); diff --git a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp index 77e3a1e..ba96186 100644 --- a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp @@ -44,7 +44,7 @@ static void getMaxDimIndex(ArrayRef structuredIndices, Operation *mlir::edsc::makeLinalgGenericOp( ArrayRef iteratorTypes, ArrayRef inputs, ArrayRef outputs, - llvm::function_ref)> regionBuilder, + function_ref)> regionBuilder, ArrayRef otherValues, ArrayRef otherAttributes) { auto &builder = edsc::ScopedContext::getBuilder(); auto *ctx = builder.getContext(); diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index 6adfeb5..0fd29cd 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -632,7 +632,7 @@ namespace linalg { } // namespace linalg } // namespace mlir -static AffineMap extractOrIdentityMap(llvm::Optional maybeMap, +static AffineMap extractOrIdentityMap(Optional maybeMap, unsigned rank, MLIRContext *context) { if (maybeMap) return maybeMap.getValue(); diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp index 7400021..f436492 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp @@ -100,7 +100,7 @@ LogicalResult mlir::linalg::tileAndFuseLinalgOpAndSetMarker( bool mlir::linalg::detail::isProducedByOpOfTypeImpl( Operation *consumerOp, Value *consumedView, - llvm::function_ref isaOpType) { + function_ref isaOpType) { LinalgOp consumer = dyn_cast(consumerOp); if (!consumer) return false; diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index 435aa72..4d8a24c 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -315,7 +315,7 @@ makeTiledViews(OpBuilder &b, Location loc, LinalgOp linalgOp, return res; } -llvm::Optional mlir::linalg::tileLinalgOp( +Optional mlir::linalg::tileLinalgOp( OpBuilder &b, LinalgOp op, ArrayRef tileSizes, ArrayRef permutation, OperationFolder *folder) { // 1. Enforce the convention that "tiling by zero" skips tiling a particular @@ -389,7 +389,7 @@ llvm::Optional mlir::linalg::tileLinalgOp( return TiledLinalgOp{res, loops}; } -llvm::Optional mlir::linalg::tileLinalgOp( +Optional mlir::linalg::tileLinalgOp( OpBuilder &b, LinalgOp op, ArrayRef tileSizes, ArrayRef permutation, OperationFolder *folder) { if (tileSizes.empty()) diff --git a/mlir/lib/Dialect/SDBM/SDBM.cpp b/mlir/lib/Dialect/SDBM/SDBM.cpp index ec3c7f3..510e13e 100644 --- a/mlir/lib/Dialect/SDBM/SDBM.cpp +++ b/mlir/lib/Dialect/SDBM/SDBM.cpp @@ -88,11 +88,11 @@ namespace { struct SDBMBuilderResult { // Positions in the matrix of the variables taken with the "+" sign in the // difference expression, 0 if it is a constant rather than a variable. - llvm::SmallVector positivePos; + SmallVector positivePos; // Positions in the matrix of the variables taken with the "-" sign in the // difference expression, 0 if it is a constant rather than a variable. - llvm::SmallVector negativePos; + SmallVector negativePos; // Constant value in the difference expression. int64_t value = 0; @@ -184,13 +184,12 @@ public: return lhs; } - SDBMBuilder(llvm::DenseMap> - &pointExprToStripe, - llvm::function_ref callback) + SDBMBuilder(DenseMap> &pointExprToStripe, + function_ref callback) : pointExprToStripe(pointExprToStripe), linearPosition(callback) {} - llvm::DenseMap> &pointExprToStripe; - llvm::function_ref linearPosition; + DenseMap> &pointExprToStripe; + function_ref linearPosition; }; } // namespace @@ -239,7 +238,7 @@ SDBM SDBM::get(ArrayRef inequalities, ArrayRef equalities) { // expression. Keep track of those in pointExprToStripe. // There may also be multiple stripe expressions equal to the same variable. // Introduce a temporary variable for each of those. - llvm::DenseMap> pointExprToStripe; + DenseMap> pointExprToStripe; unsigned numTemporaries = 0; auto updateStripePointMaps = [&numTemporaries, &result, &pointExprToStripe, @@ -512,7 +511,7 @@ void SDBM::getSDBMExpressions(SDBMDialect *dialect, } } -void SDBM::print(llvm::raw_ostream &os) { +void SDBM::print(raw_ostream &os) { unsigned numVariables = getNumVariables(); // Helper function that prints the name of the variable given its linearized diff --git a/mlir/lib/Dialect/SDBM/SDBMExpr.cpp b/mlir/lib/Dialect/SDBM/SDBMExpr.cpp index 8f6b59d..8cdd9c8 100644 --- a/mlir/lib/Dialect/SDBM/SDBMExpr.cpp +++ b/mlir/lib/Dialect/SDBM/SDBMExpr.cpp @@ -89,7 +89,7 @@ public: : subExprs(exprs.begin(), exprs.end()) {} AffineExprMatcherStorage(AffineExprMatcher &a, AffineExprMatcher &b) : subExprs({a, b}) {} - llvm::SmallVector subExprs; + SmallVector subExprs; AffineExpr matched; }; } // namespace @@ -311,7 +311,7 @@ AffineExpr SDBMExpr::getAsAffineExpr() const { // LHS if the constant becomes zero. Otherwise, construct a sum expression. template Result addConstantAndSink(SDBMDirectExpr expr, int64_t constant, bool negated, - llvm::function_ref builder) { + function_ref builder) { SDBMDialect *dialect = expr.getDialect(); if (auto sumExpr = expr.dyn_cast()) { if (negated) diff --git a/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp b/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp index e2d5332..5db478d 100644 --- a/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp +++ b/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp @@ -33,10 +33,9 @@ VulkanLayoutUtils::decorateType(spirv::StructType structType, return structType; } - llvm::SmallVector memberTypes; - llvm::SmallVector layoutInfo; - llvm::SmallVector - memberDecorations; + SmallVector memberTypes; + SmallVector layoutInfo; + SmallVector memberDecorations; VulkanLayoutUtils::Size structMemberOffset = 0; VulkanLayoutUtils::Size maxMemberAlignment = 1; diff --git a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp index c99e7ca..def8ee8 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp @@ -149,7 +149,7 @@ Optional parseAndVerify(SPIRVDialect const &dialect, DialectAsmParser &parser); static bool isValidSPIRVIntType(IntegerType type) { - return llvm::is_contained(llvm::ArrayRef({1, 8, 16, 32, 64}), + return llvm::is_contained(ArrayRef({1, 8, 16, 32, 64}), type.getWidth()); } diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index 140470b..0df4525 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -80,7 +80,7 @@ static LogicalResult extractValueFromConstOp(Operation *op, template static ArrayAttr getStrArrayAttrForEnumList(Builder &builder, ArrayRef enumValues, - llvm::function_ref stringifyFn) { + function_ref stringifyFn) { if (enumValues.empty()) { return nullptr; } @@ -399,7 +399,7 @@ static unsigned getBitWidth(Type type) { /// emits errors with the given loc on failure. static Type getElementType(Type type, ArrayRef indices, - llvm::function_ref emitErrorFn) { + function_ref emitErrorFn) { if (indices.empty()) { emitErrorFn("expected at least one index for spv.CompositeExtract"); return nullptr; @@ -423,7 +423,7 @@ getElementType(Type type, ArrayRef indices, static Type getElementType(Type type, Attribute indices, - llvm::function_ref emitErrorFn) { + function_ref emitErrorFn) { auto indicesArrayAttr = indices.dyn_cast(); if (!indicesArrayAttr) { emitErrorFn("expected a 32-bit integer array attribute for 'indices'"); @@ -2317,7 +2317,7 @@ static LogicalResult verify(spirv::ModuleOp moduleOp) { auto &op = *moduleOp.getOperation(); auto *dialect = op.getDialect(); auto &body = op.getRegion(0).front(); - llvm::DenseMap, spirv::EntryPointOp> + DenseMap, spirv::EntryPointOp> entryPoints; SymbolTable table(moduleOp); diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp index e60805a..df9cb47 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp @@ -2366,7 +2366,7 @@ Deserializer::processOp(ArrayRef operands) { auto functionName = getFunctionSymbol(functionID); - llvm::SmallVector arguments; + SmallVector arguments; for (auto operand : llvm::drop_begin(operands, 3)) { auto *value = getValue(operand); if (!value) { diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp index 7db7111..4baac53 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -69,7 +69,7 @@ static LogicalResult encodeInstructionInto(SmallVectorImpl &binary, /// serialization of the merge block and the continue block, if exists, until /// after all other blocks have been processed. static LogicalResult visitInPrettyBlockOrder( - Block *headerBlock, llvm::function_ref blockHandler, + Block *headerBlock, function_ref blockHandler, bool skipHeader = false, ArrayRef skipBlocks = {}) { llvm::df_iterator_default_set doneBlocks; doneBlocks.insert(skipBlocks.begin(), skipBlocks.end()); @@ -301,7 +301,7 @@ private: /// instruction if this is a SPIR-V selection/loop header block. LogicalResult processBlock(Block *block, bool omitLabel = false, - llvm::function_ref actionBeforeTerminator = nullptr); + function_ref actionBeforeTerminator = nullptr); /// Emits OpPhi instructions for the given block if it has block arguments. LogicalResult emitPhiForBlockArguments(Block *block); @@ -457,7 +457,7 @@ private: /// placed inside `functions`) here. And then after emitting all blocks, we /// replace the dummy 0 with the real result by overwriting /// `functions[offset]`. - DenseMap> deferredPhiValues; + DenseMap> deferredPhiValues; }; } // namespace @@ -1341,7 +1341,7 @@ uint32_t Serializer::getOrCreateBlockID(Block *block) { LogicalResult Serializer::processBlock(Block *block, bool omitLabel, - llvm::function_ref actionBeforeTerminator) { + function_ref actionBeforeTerminator) { LLVM_DEBUG(llvm::dbgs() << "processing block " << block << ":\n"); LLVM_DEBUG(block->print(llvm::dbgs())); LLVM_DEBUG(llvm::dbgs() << '\n'); @@ -1773,7 +1773,7 @@ Serializer::processOp(spirv::FunctionCallOp op) { auto funcName = op.callee(); uint32_t resTypeID = 0; - llvm::SmallVector resultTypes(op.getResultTypes()); + SmallVector resultTypes(op.getResultTypes()); if (failed(processType(op.getLoc(), (resultTypes.empty() ? getVoidType() : resultTypes[0]), resTypeID))) { diff --git a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp index 655f559..e9b4f23 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp @@ -80,7 +80,7 @@ static TranslateToMLIRRegistration fromBinary( // Serialization registration //===----------------------------------------------------------------------===// -LogicalResult serializeModule(ModuleOp module, llvm::raw_ostream &output) { +LogicalResult serializeModule(ModuleOp module, raw_ostream &output) { if (!module) return failure(); @@ -105,7 +105,7 @@ LogicalResult serializeModule(ModuleOp module, llvm::raw_ostream &output) { } static TranslateFromMLIRRegistration - toBinary("serialize-spirv", [](ModuleOp module, llvm::raw_ostream &output) { + toBinary("serialize-spirv", [](ModuleOp module, raw_ostream &output) { return serializeModule(module, output); }); @@ -113,8 +113,8 @@ static TranslateFromMLIRRegistration // Round-trip registration //===----------------------------------------------------------------------===// -LogicalResult roundTripModule(llvm::SourceMgr &sourceMgr, - llvm::raw_ostream &output, MLIRContext *context) { +LogicalResult roundTripModule(llvm::SourceMgr &sourceMgr, raw_ostream &output, + MLIRContext *context) { // Parse an MLIR module from the source manager. auto srcModule = OwningModuleRef(parseSourceFile(sourceMgr, context)); if (!srcModule) @@ -147,9 +147,8 @@ LogicalResult roundTripModule(llvm::SourceMgr &sourceMgr, return mlir::success(); } -static TranslateRegistration - roundtrip("test-spirv-roundtrip", - [](llvm::SourceMgr &sourceMgr, llvm::raw_ostream &output, - MLIRContext *context) { - return roundTripModule(sourceMgr, output, context); - }); +static TranslateRegistration roundtrip( + "test-spirv-roundtrip", + [](llvm::SourceMgr &sourceMgr, raw_ostream &output, MLIRContext *context) { + return roundTripModule(sourceMgr, output, context); + }); diff --git a/mlir/lib/Dialect/StandardOps/Ops.cpp b/mlir/lib/Dialect/StandardOps/Ops.cpp index 3189e42..b2b3ba5 100644 --- a/mlir/lib/Dialect/StandardOps/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/Ops.cpp @@ -2297,7 +2297,7 @@ static void print(OpAsmPrinter &p, ViewOp op) { Value *ViewOp::getDynamicOffset() { int64_t offset; - llvm::SmallVector strides; + SmallVector strides; auto result = succeeded(mlir::getStridesAndOffset(getType(), strides, offset)); assert(result); @@ -2341,7 +2341,7 @@ static LogicalResult verify(ViewOp op) { // Verify that the result memref type has a strided layout map. int64_t offset; - llvm::SmallVector strides; + SmallVector strides; if (failed(getStridesAndOffset(viewType, strides, offset))) return op.emitError("result type ") << viewType << " is not strided"; @@ -2383,7 +2383,7 @@ struct ViewOpShapeFolder : public OpRewritePattern { // Get offset from old memref view type 'memRefType'. int64_t oldOffset; - llvm::SmallVector oldStrides; + SmallVector oldStrides; if (failed(getStridesAndOffset(memrefType, oldStrides, oldOffset))) return matchFailure(); @@ -2585,13 +2585,13 @@ static LogicalResult verify(SubViewOp op) { // Verify that the base memref type has a strided layout map. int64_t baseOffset; - llvm::SmallVector baseStrides; + SmallVector baseStrides; if (failed(getStridesAndOffset(baseType, baseStrides, baseOffset))) return op.emitError("base type ") << subViewType << " is not strided"; // Verify that the result memref type has a strided layout map. int64_t subViewOffset; - llvm::SmallVector subViewStrides; + SmallVector subViewStrides; if (failed(getStridesAndOffset(subViewType, subViewStrides, subViewOffset))) return op.emitError("result type ") << subViewType << " is not strided"; @@ -2677,8 +2677,7 @@ static LogicalResult verify(SubViewOp op) { return success(); } -llvm::raw_ostream &mlir::operator<<(llvm::raw_ostream &os, - SubViewOp::Range &range) { +raw_ostream &mlir::operator<<(raw_ostream &os, SubViewOp::Range &range) { return os << "range " << *range.offset << ":" << *range.size << ":" << *range.stride; } @@ -2734,7 +2733,7 @@ static bool hasConstantOffsetSizesAndStrides(MemRefType memrefType) { return false; // Get offset and strides. int64_t offset; - llvm::SmallVector strides; + SmallVector strides; if (failed(getStridesAndOffset(memrefType, strides, offset))) return false; // Return 'false' if any of offset or strides is dynamic. diff --git a/mlir/lib/Dialect/Traits.cpp b/mlir/lib/Dialect/Traits.cpp index 9945b6a..0ac07c2 100644 --- a/mlir/lib/Dialect/Traits.cpp +++ b/mlir/lib/Dialect/Traits.cpp @@ -112,8 +112,7 @@ Type OpTrait::util::getBroadcastedType(Type type1, Type type2) { // Returns the type kind if the given type is a vector or ranked tensor type. // Returns llvm::None otherwise. - auto getCompositeTypeKind = - [](Type type) -> llvm::Optional { + auto getCompositeTypeKind = [](Type type) -> Optional { if (type.isa() || type.isa()) return static_cast(type.getKind()); return llvm::None; @@ -122,7 +121,7 @@ Type OpTrait::util::getBroadcastedType(Type type1, Type type2) { // Make sure the composite type, if has, is consistent. auto compositeKind1 = getCompositeTypeKind(type1); auto compositeKind2 = getCompositeTypeKind(type2); - llvm::Optional resultCompositeKind; + Optional resultCompositeKind; if (compositeKind1 && compositeKind2) { // Disallow mixing vector and tensor. diff --git a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp index c4d3e9d..64cacb2 100644 --- a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp @@ -513,11 +513,11 @@ Value *mlir::vector::unrollSingleResultOpMatchingType( // Generates slices of 'vectorType' according to 'sizes' and 'strides, and // calls 'fn' with linear index and indices for each slice. -static void generateTransferOpSlices( - VectorType vectorType, TupleType tupleType, ArrayRef sizes, - ArrayRef strides, ArrayRef indices, - PatternRewriter &rewriter, - llvm::function_ref)> fn) { +static void +generateTransferOpSlices(VectorType vectorType, TupleType tupleType, + ArrayRef sizes, ArrayRef strides, + ArrayRef indices, PatternRewriter &rewriter, + function_ref)> fn) { // Compute strides w.r.t. to slice counts in each dimension. auto maybeDimSliceCounts = shapeRatio(vectorType.getShape(), sizes); assert(maybeDimSliceCounts.hasValue()); diff --git a/mlir/lib/EDSC/Builders.cpp b/mlir/lib/EDSC/Builders.cpp index 9d7ca8c..2956066 100644 --- a/mlir/lib/EDSC/Builders.cpp +++ b/mlir/lib/EDSC/Builders.cpp @@ -142,21 +142,21 @@ BlockHandle mlir::edsc::BlockHandle::create(ArrayRef argTypes) { return res; } -static llvm::Optional emitStaticFor(ArrayRef lbs, - ArrayRef ubs, - int64_t step) { +static Optional emitStaticFor(ArrayRef lbs, + ArrayRef ubs, + int64_t step) { if (lbs.size() != 1 || ubs.size() != 1) - return llvm::Optional(); + return Optional(); auto *lbDef = lbs.front().getValue()->getDefiningOp(); auto *ubDef = ubs.front().getValue()->getDefiningOp(); if (!lbDef || !ubDef) - return llvm::Optional(); + return Optional(); auto lbConst = dyn_cast(lbDef); auto ubConst = dyn_cast(ubDef); if (!lbConst || !ubConst) - return llvm::Optional(); + return Optional(); return ValueHandle::create(lbConst.getValue(), ubConst.getValue(), step); @@ -194,7 +194,7 @@ mlir::edsc::LoopBuilder::makeLoop(ValueHandle *iv, ValueHandle lbHandle, return result; } -void mlir::edsc::LoopBuilder::operator()(llvm::function_ref fun) { +void mlir::edsc::LoopBuilder::operator()(function_ref fun) { // Call to `exit` must be explicit and asymmetric (cannot happen in the // destructor) because of ordering wrt comma operator. /// The particular use case concerns nested blocks: @@ -236,7 +236,7 @@ mlir::edsc::AffineLoopNestBuilder::AffineLoopNestBuilder( } void mlir::edsc::AffineLoopNestBuilder::operator()( - llvm::function_ref fun) { + function_ref fun) { if (fun) fun(); // Iterate on the calling operator() on all the loops in the nest. @@ -281,7 +281,7 @@ mlir::edsc::BlockBuilder::BlockBuilder(BlockHandle *bh, ArrayRef args) { assert(!*bh && "BlockHandle already captures a block, use " "the explicit BockBuilder(bh, Append())({}) syntax instead."); - llvm::SmallVector types; + SmallVector types; for (auto *a : args) { assert(!a->hasValue() && "Expected delayed ValueHandle that has not yet captured."); @@ -296,7 +296,7 @@ mlir::edsc::BlockBuilder::BlockBuilder(BlockHandle *bh, /// Only serves as an ordering point between entering nested block and creating /// stmts. -void mlir::edsc::BlockBuilder::operator()(llvm::function_ref fun) { +void mlir::edsc::BlockBuilder::operator()(function_ref fun) { // Call to `exit` must be explicit and asymmetric (cannot happen in the // destructor) because of ordering wrt comma operator. if (fun) @@ -328,7 +328,7 @@ categorizeValueByAffineType(MLIRContext *context, Value *val, unsigned &numDims, static ValueHandle createBinaryIndexHandle( ValueHandle lhs, ValueHandle rhs, - llvm::function_ref affCombiner) { + function_ref affCombiner) { MLIRContext *context = ScopedContext::getContext(); unsigned numDims = 0, numSymbols = 0; AffineExpr d0, d1; @@ -352,7 +352,7 @@ static ValueHandle createBinaryIndexHandle( template static ValueHandle createBinaryHandle( ValueHandle lhs, ValueHandle rhs, - llvm::function_ref affCombiner) { + function_ref affCombiner) { auto thisType = lhs.getValue()->getType(); auto thatType = rhs.getValue()->getType(); assert(thisType == thatType && "cannot mix types in operators"); diff --git a/mlir/lib/EDSC/CoreAPIs.cpp b/mlir/lib/EDSC/CoreAPIs.cpp index b88a1fd..46199c2 100644 --- a/mlir/lib/EDSC/CoreAPIs.cpp +++ b/mlir/lib/EDSC/CoreAPIs.cpp @@ -34,7 +34,7 @@ using namespace mlir; mlir_type_t makeMemRefType(mlir_context_t context, mlir_type_t elemType, int64_list_t sizes) { auto t = mlir::MemRefType::get( - llvm::ArrayRef(sizes.values, sizes.n), + ArrayRef(sizes.values, sizes.n), mlir::Type::getFromOpaquePointer(elemType), {mlir::AffineMap::getMultiDimIdentityMap( sizes.n, reinterpret_cast(context))}, @@ -44,7 +44,7 @@ mlir_type_t makeMemRefType(mlir_context_t context, mlir_type_t elemType, mlir_type_t makeFunctionType(mlir_context_t context, mlir_type_list_t inputs, mlir_type_list_t outputs) { - llvm::SmallVector ins(inputs.n), outs(outputs.n); + SmallVector ins(inputs.n), outs(outputs.n); for (unsigned i = 0; i < inputs.n; ++i) { ins[i] = mlir::Type::getFromOpaquePointer(inputs.types[i]); } diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp index 2913c43..bbee80a 100644 --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -64,7 +64,7 @@ using llvm::orc::ThreadSafeModule; using llvm::orc::TMOwningSimpleCompiler; // Wrap a string into an llvm::StringError. -static inline Error make_string_error(const llvm::Twine &message) { +static inline Error make_string_error(const Twine &message) { return llvm::make_error(message.str(), llvm::inconvertibleErrorCode()); } @@ -89,7 +89,7 @@ std::unique_ptr SimpleObjectCache::getObject(const Module *M) { return MemoryBuffer::getMemBuffer(I->second->getMemBufferRef()); } -void SimpleObjectCache::dumpToObjectFile(llvm::StringRef outputFilename) { +void SimpleObjectCache::dumpToObjectFile(StringRef outputFilename) { // Set up the output file. std::string errorMessage; auto file = openOutputFile(outputFilename, &errorMessage); @@ -105,7 +105,7 @@ void SimpleObjectCache::dumpToObjectFile(llvm::StringRef outputFilename) { file->keep(); } -void ExecutionEngine::dumpToObjectFile(llvm::StringRef filename) { +void ExecutionEngine::dumpToObjectFile(StringRef filename) { cache->dumpToObjectFile(filename); } @@ -136,7 +136,7 @@ static std::string makePackedFunctionName(StringRef name) { void packFunctionArguments(Module *module) { auto &ctx = module->getContext(); llvm::IRBuilder<> builder(ctx); - llvm::DenseSet interfaceFunctions; + DenseSet interfaceFunctions; for (auto &func : module->getFunctionList()) { if (func.isDeclaration()) { continue; @@ -152,8 +152,7 @@ void packFunctionArguments(Module *module) { /*isVarArg=*/false); auto newName = makePackedFunctionName(func.getName()); auto funcCst = module->getOrInsertFunction(newName, newType); - llvm::Function *interfaceFunc = - llvm::cast(funcCst.getCallee()); + llvm::Function *interfaceFunc = cast(funcCst.getCallee()); interfaceFunctions.insert(interfaceFunc); // Extract the arguments from the type-erased argument list and cast them to @@ -162,11 +161,11 @@ void packFunctionArguments(Module *module) { bb->insertInto(interfaceFunc); builder.SetInsertPoint(bb); llvm::Value *argList = interfaceFunc->arg_begin(); - llvm::SmallVector args; + SmallVector args; args.reserve(llvm::size(func.args())); for (auto &indexedArg : llvm::enumerate(func.args())) { llvm::Value *argIndex = llvm::Constant::getIntegerValue( - builder.getInt64Ty(), llvm::APInt(64, indexedArg.index())); + builder.getInt64Ty(), APInt(64, indexedArg.index())); llvm::Value *argPtrPtr = builder.CreateGEP(argList, argIndex); llvm::Value *argPtr = builder.CreateLoad(argPtrPtr); argPtr = builder.CreateBitCast( @@ -181,7 +180,7 @@ void packFunctionArguments(Module *module) { // Assuming the result is one value, potentially of type `void`. if (!result->getType()->isVoidTy()) { llvm::Value *retIndex = llvm::Constant::getIntegerValue( - builder.getInt64Ty(), llvm::APInt(64, llvm::size(func.args()))); + builder.getInt64Ty(), APInt(64, llvm::size(func.args()))); llvm::Value *retPtrPtr = builder.CreateGEP(argList, retIndex); llvm::Value *retPtr = builder.CreateLoad(retPtrPtr); retPtr = builder.CreateBitCast(retPtr, result->getType()->getPointerTo()); @@ -220,7 +219,7 @@ Expected> ExecutionEngine::create( llvm::raw_svector_ostream os(buffer); WriteBitcodeToFile(*llvmModule, os); } - llvm::MemoryBufferRef bufferRef(llvm::StringRef(buffer.data(), buffer.size()), + llvm::MemoryBufferRef bufferRef(StringRef(buffer.data(), buffer.size()), "cloned module buffer"); auto expectedModule = parseBitcodeFile(bufferRef, *ctx); if (!expectedModule) diff --git a/mlir/lib/IR/AffineExpr.cpp b/mlir/lib/IR/AffineExpr.cpp index 19599a8..009c1a1 100644 --- a/mlir/lib/IR/AffineExpr.cpp +++ b/mlir/lib/IR/AffineExpr.cpp @@ -866,9 +866,10 @@ AffineExpr mlir::simplifyAffineExpr(AffineExpr expr, unsigned numDims, // Flattens the expressions in map. Returns true on success or false // if 'expr' was unable to be flattened (i.e., semi-affine expressions not // handled yet). -static bool getFlattenedAffineExprs( - ArrayRef exprs, unsigned numDims, unsigned numSymbols, - std::vector> *flattenedExprs) { +static bool +getFlattenedAffineExprs(ArrayRef exprs, unsigned numDims, + unsigned numSymbols, + std::vector> *flattenedExprs) { if (exprs.empty()) { return true; } @@ -894,9 +895,9 @@ static bool getFlattenedAffineExprs( // Flattens 'expr' into 'flattenedExpr'. Returns true on success or false // if 'expr' was unable to be flattened (semi-affine expressions not handled // yet). -bool mlir::getFlattenedAffineExpr( - AffineExpr expr, unsigned numDims, unsigned numSymbols, - llvm::SmallVectorImpl *flattenedExpr) { +bool mlir::getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, + unsigned numSymbols, + SmallVectorImpl *flattenedExpr) { std::vector> flattenedExprs; bool ret = ::getFlattenedAffineExprs({expr}, numDims, numSymbols, &flattenedExprs); @@ -908,7 +909,7 @@ bool mlir::getFlattenedAffineExpr( /// if 'expr' was unable to be flattened (i.e., semi-affine expressions not /// handled yet). bool mlir::getFlattenedAffineExprs( - AffineMap map, std::vector> *flattenedExprs) { + AffineMap map, std::vector> *flattenedExprs) { if (map.getNumResults() == 0) { return true; } @@ -917,8 +918,7 @@ bool mlir::getFlattenedAffineExprs( } bool mlir::getFlattenedAffineExprs( - IntegerSet set, - std::vector> *flattenedExprs) { + IntegerSet set, std::vector> *flattenedExprs) { if (set.getNumConstraints() == 0) { return true; } diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp index 98357b1..6cfef36 100644 --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -48,7 +48,7 @@ public: } private: - llvm::Optional constantFoldImpl(AffineExpr expr) { + Optional constantFoldImpl(AffineExpr expr) { switch (expr.getKind()) { case AffineExprKind::Add: return constantFoldBinExpr( @@ -83,8 +83,8 @@ private: } // TODO: Change these to operate on APInts too. - llvm::Optional constantFoldBinExpr(AffineExpr expr, - int64_t (*op)(int64_t, int64_t)) { + Optional constantFoldBinExpr(AffineExpr expr, + int64_t (*op)(int64_t, int64_t)) { auto binOpExpr = expr.cast(); if (auto lhs = constantFoldImpl(binOpExpr.getLHS())) if (auto rhs = constantFoldImpl(binOpExpr.getRHS())) @@ -324,7 +324,7 @@ AffineMap mlir::concatAffineMaps(ArrayRef maps) { for (auto m : maps) numResults += m ? m.getNumResults() : 0; unsigned numDims = 0; - llvm::SmallVector results; + SmallVector results; results.reserve(numResults); for (auto m : maps) { if (!m) diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 0ea447e..e1903d5 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -437,9 +437,9 @@ public: void printLocation(LocationAttr loc); void printAffineMap(AffineMap map); - void printAffineExpr( - AffineExpr expr, - llvm::function_ref printValueName = nullptr); + void + printAffineExpr(AffineExpr expr, + function_ref printValueName = nullptr); void printAffineConstraint(AffineExpr expr, bool isEq); void printIntegerSet(IntegerSet set); @@ -463,7 +463,7 @@ protected: }; void printAffineExprInternal( AffineExpr expr, BindingStrength enclosingTightness, - llvm::function_ref printValueName = nullptr); + function_ref printValueName = nullptr); /// The output stream for the printer. raw_ostream &os; @@ -1175,13 +1175,13 @@ void ModulePrinter::printDialectType(Type type) { //===----------------------------------------------------------------------===// void ModulePrinter::printAffineExpr( - AffineExpr expr, llvm::function_ref printValueName) { + AffineExpr expr, function_ref printValueName) { printAffineExprInternal(expr, BindingStrength::Weak, printValueName); } void ModulePrinter::printAffineExprInternal( AffineExpr expr, BindingStrength enclosingTightness, - llvm::function_ref printValueName) { + function_ref printValueName) { const char *binopSpelling = nullptr; switch (expr.getKind()) { case AffineExprKind::SymbolId: { diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp index b546643..bb35a63 100644 --- a/mlir/lib/IR/Attributes.cpp +++ b/mlir/lib/IR/Attributes.cpp @@ -405,9 +405,9 @@ bool ElementsAttr::isValidIndex(ArrayRef index) const { }); } -ElementsAttr ElementsAttr::mapValues( - Type newElementType, - llvm::function_ref mapping) const { +ElementsAttr +ElementsAttr::mapValues(Type newElementType, + function_ref mapping) const { switch (getKind()) { case StandardAttributes::DenseElements: return cast().mapValues(newElementType, mapping); @@ -416,9 +416,9 @@ ElementsAttr ElementsAttr::mapValues( } } -ElementsAttr ElementsAttr::mapValues( - Type newElementType, - llvm::function_ref mapping) const { +ElementsAttr +ElementsAttr::mapValues(Type newElementType, + function_ref mapping) const { switch (getKind()) { case StandardAttributes::DenseElements: return cast().mapValues(newElementType, mapping); @@ -798,15 +798,14 @@ DenseElementsAttr DenseElementsAttr::reshape(ShapedType newType) { return getRaw(newType, getRawData(), isSplat()); } -DenseElementsAttr DenseElementsAttr::mapValues( - Type newElementType, - llvm::function_ref mapping) const { +DenseElementsAttr +DenseElementsAttr::mapValues(Type newElementType, + function_ref mapping) const { return cast().mapValues(newElementType, mapping); } DenseElementsAttr DenseElementsAttr::mapValues( - Type newElementType, - llvm::function_ref mapping) const { + Type newElementType, function_ref mapping) const { return cast().mapValues(newElementType, mapping); } @@ -855,8 +854,7 @@ static ShapedType mappingHelper(Fn mapping, Attr &attr, ShapedType inType, } DenseElementsAttr DenseFPElementsAttr::mapValues( - Type newElementType, - llvm::function_ref mapping) const { + Type newElementType, function_ref mapping) const { llvm::SmallVector elementData; auto newArrayType = mappingHelper(mapping, *this, getType(), newElementType, elementData); @@ -875,8 +873,7 @@ bool DenseFPElementsAttr::classof(Attribute attr) { //===----------------------------------------------------------------------===// DenseElementsAttr DenseIntElementsAttr::mapValues( - Type newElementType, - llvm::function_ref mapping) const { + Type newElementType, function_ref mapping) const { llvm::SmallVector elementData; auto newArrayType = mappingHelper(mapping, *this, getType(), newElementType, elementData); diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index 63e8580..4dac32a 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -159,7 +159,7 @@ BlockArgument *Block::addArgument(Type type) { /// Add one argument to the argument list for each type specified in the list. auto Block::addArguments(ArrayRef types) - -> llvm::iterator_range { + -> iterator_range { arguments.reserve(arguments.size() + types.size()); auto initialSize = arguments.size(); for (auto type : types) { diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp index 70a802c..59e16a4 100644 --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -104,7 +104,7 @@ void DiagnosticArgument::print(raw_ostream &os) const { static StringRef twineToStrRef(const Twine &val, std::vector> &strings) { // Allocate memory to hold this string. - llvm::SmallString<64> data; + SmallString<64> data; auto strRef = val.toStringRef(data); strings.push_back(std::unique_ptr(new char[strRef.size()])); memcpy(&strings.back()[0], strRef.data(), strRef.size()); @@ -157,7 +157,7 @@ std::string Diagnostic::str() const { /// Attaches a note to this diagnostic. A new location may be optionally /// provided, if not, then the location defaults to the one specified for this /// diagnostic. Notes may not be attached to other notes. -Diagnostic &Diagnostic::attachNote(llvm::Optional noteLoc) { +Diagnostic &Diagnostic::attachNote(Optional noteLoc) { // We don't allow attaching notes to notes. assert(severity != DiagnosticSeverity::Note && "cannot attach a note to a note"); @@ -285,9 +285,8 @@ void DiagnosticEngine::emit(Diagnostic diag) { /// Helper function used to emit a diagnostic with an optionally empty twine /// message. If the message is empty, then it is not inserted into the /// diagnostic. -static InFlightDiagnostic emitDiag(Location location, - DiagnosticSeverity severity, - const llvm::Twine &message) { +static InFlightDiagnostic +emitDiag(Location location, DiagnosticSeverity severity, const Twine &message) { auto &diagEngine = location->getContext()->getDiagEngine(); auto diag = diagEngine.emit(location, severity); if (!message.isTriviallyEmpty()) @@ -374,7 +373,7 @@ struct SourceMgrDiagnosticHandlerImpl { } // end namespace mlir /// Return a processable FileLineColLoc from the given location. -static llvm::Optional getFileLineColLoc(Location loc) { +static Optional getFileLineColLoc(Location loc) { switch (loc->getKind()) { case StandardAttributes::NameLocation: return getFileLineColLoc(loc.cast().getChildLoc()); @@ -405,7 +404,7 @@ static llvm::SourceMgr::DiagKind getDiagKind(DiagnosticSeverity kind) { SourceMgrDiagnosticHandler::SourceMgrDiagnosticHandler(llvm::SourceMgr &mgr, MLIRContext *ctx, - llvm::raw_ostream &os) + raw_ostream &os) : ScopedDiagnosticHandler(ctx), mgr(mgr), os(os), impl(new SourceMgrDiagnosticHandlerImpl()) { setHandler([this](Diagnostic &diag) { emitDiagnostic(diag); }); @@ -556,8 +555,7 @@ struct SourceMgrDiagnosticVerifierHandlerImpl { SourceMgrDiagnosticVerifierHandlerImpl() : status(success()) {} /// Returns the expected diagnostics for the given source file. - llvm::Optional> - getExpectedDiags(StringRef bufName); + Optional> getExpectedDiags(StringRef bufName); /// Computes the expected diagnostics for the given source buffer. MutableArrayRef @@ -592,7 +590,7 @@ static StringRef getDiagKindStr(DiagnosticSeverity kind) { } /// Returns the expected diagnostics for the given source file. -llvm::Optional> +Optional> SourceMgrDiagnosticVerifierHandlerImpl::getExpectedDiags(StringRef bufName) { auto expectedDiags = expectedDiagsPerFile.find(bufName); if (expectedDiags != expectedDiagsPerFile.end()) @@ -681,7 +679,7 @@ SourceMgrDiagnosticVerifierHandlerImpl::computeExpectedDiags( } SourceMgrDiagnosticVerifierHandler::SourceMgrDiagnosticVerifierHandler( - llvm::SourceMgr &srcMgr, MLIRContext *ctx, llvm::raw_ostream &out) + llvm::SourceMgr &srcMgr, MLIRContext *ctx, raw_ostream &out) : SourceMgrDiagnosticHandler(srcMgr, ctx, out), impl(new SourceMgrDiagnosticVerifierHandlerImpl()) { // Compute the expected diagnostics for each of the current files in the diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp index e5e85426..b51c77f 100644 --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -40,10 +40,10 @@ FuncOp FuncOp::create(Location location, StringRef name, FunctionType type, OperationState state(location, "func"); Builder builder(location->getContext()); FuncOp::build(&builder, state, name, type, attrs); - return llvm::cast(Operation::create(state)); + return cast(Operation::create(state)); } FuncOp FuncOp::create(Location location, StringRef name, FunctionType type, - llvm::iterator_range attrs) { + iterator_range attrs) { SmallVector attrRef(attrs); return create(location, name, type, llvm::makeArrayRef(attrRef)); } @@ -204,7 +204,7 @@ FuncOp FuncOp::clone(BlockAndValueMapping &mapper) { } // Create the new function. - FuncOp newFunc = llvm::cast(getOperation()->cloneWithoutRegions()); + FuncOp newFunc = cast(getOperation()->cloneWithoutRegions()); newFunc.setType(newType); /// Set the argument attributes for arguments that aren't being replaced. diff --git a/mlir/lib/IR/FunctionImplementation.cpp b/mlir/lib/IR/FunctionImplementation.cpp index 66c0d8a..9cec216 100644 --- a/mlir/lib/IR/FunctionImplementation.cpp +++ b/mlir/lib/IR/FunctionImplementation.cpp @@ -213,7 +213,7 @@ mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, OperationState &result, // Parse the optional function body. auto *body = result.addRegion(); return parser.parseOptionalRegion( - *body, entryArgs, entryArgs.empty() ? llvm::ArrayRef() : argTypes); + *body, entryArgs, entryArgs.empty() ? ArrayRef() : argTypes); } // Print a function result list. diff --git a/mlir/lib/IR/IntegerSet.cpp b/mlir/lib/IR/IntegerSet.cpp index e571587..ce50fa7 100644 --- a/mlir/lib/IR/IntegerSet.cpp +++ b/mlir/lib/IR/IntegerSet.cpp @@ -73,8 +73,7 @@ MLIRContext *IntegerSet::getContext() const { /// Walk all of the AffineExpr's in this set. Each node in an expression /// tree is visited in postorder. -void IntegerSet::walkExprs( - llvm::function_ref callback) const { +void IntegerSet::walkExprs(function_ref callback) const { for (auto expr : getConstraints()) expr.walk(callback); } diff --git a/mlir/lib/IR/Module.cpp b/mlir/lib/IR/Module.cpp index 79e0452..c52a55b 100644 --- a/mlir/lib/IR/Module.cpp +++ b/mlir/lib/IR/Module.cpp @@ -38,7 +38,7 @@ ModuleOp ModuleOp::create(Location loc, Optional name) { OperationState state(loc, "module"); Builder builder(loc->getContext()); ModuleOp::build(&builder, state, name); - return llvm::cast(Operation::create(state)); + return cast(Operation::create(state)); } ParseResult ModuleOp::parse(OpAsmParser &parser, OperationState &result) { diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index fd747a9..9df10791 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -1174,7 +1174,7 @@ Value *impl::foldCastOp(Operation *op) { /// terminator operation to insert. void impl::ensureRegionTerminator( Region ®ion, Location loc, - llvm::function_ref buildTerminatorOp) { + function_ref buildTerminatorOp) { if (region.empty()) region.push_back(new Block); diff --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp index c588e56..6cec021 100644 --- a/mlir/lib/IR/Region.cpp +++ b/mlir/lib/IR/Region.cpp @@ -129,7 +129,7 @@ void Region::dropAllReferences() { /// is used to point to the operation containing the region, the actual error is /// reported at the operation with an offending use. static bool isIsolatedAbove(Region ®ion, Region &limit, - llvm::Optional noteLoc) { + Optional noteLoc) { assert(limit.isAncestor(®ion) && "expected isolation limit to be an ancestor of the given region"); @@ -174,7 +174,7 @@ static bool isIsolatedAbove(Region ®ion, Region &limit, return true; } -bool Region::isIsolatedFromAbove(llvm::Optional noteLoc) { +bool Region::isIsolatedFromAbove(Optional noteLoc) { return isIsolatedAbove(*this, *this, noteLoc); } diff --git a/mlir/lib/IR/StandardTypes.cpp b/mlir/lib/IR/StandardTypes.cpp index 8a47c5b..7c494e2 100644 --- a/mlir/lib/IR/StandardTypes.cpp +++ b/mlir/lib/IR/StandardTypes.cpp @@ -375,7 +375,7 @@ MemRefType MemRefType::getImpl(ArrayRef shape, Type elementType, // Drop identity maps from the composition. // This may lead to the composition becoming empty, which is interpreted as an // implicit identity. - llvm::SmallVector cleanedAffineMapComposition; + SmallVector cleanedAffineMapComposition; for (const auto &map : affineMapComposition) { if (map.isIdentity()) continue; @@ -417,7 +417,7 @@ unsigned UnrankedMemRefType::getMemorySpace() const { } LogicalResult UnrankedMemRefType::verifyConstructionInvariants( - llvm::Optional loc, MLIRContext *context, Type elementType, + Optional loc, MLIRContext *context, Type elementType, unsigned memorySpace) { // Check that memref is formed from allowed types. if (!elementType.isIntOrFloat() && !elementType.isa()) @@ -647,8 +647,9 @@ ComplexType ComplexType::getChecked(Type elementType, Location location) { } /// Verify the construction of an integer type. -LogicalResult ComplexType::verifyConstructionInvariants( - llvm::Optional loc, MLIRContext *context, Type elementType) { +LogicalResult ComplexType::verifyConstructionInvariants(Optional loc, + MLIRContext *context, + Type elementType) { if (!elementType.isa() && !elementType.isa()) return emitOptionalError(loc, "invalid element type for complex"); return success(); diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index ddc8d01..1a02745 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -349,7 +349,7 @@ public: /// Parse an AffineMap where the dim and symbol identifiers are SSA ids. ParseResult parseAffineMapOfSSAIds(AffineMap &map, - llvm::function_ref parseElement); + function_ref parseElement); private: /// The Parser is subclassed and reinstantiated. Do not add additional @@ -832,7 +832,7 @@ static Symbol parseExtendedSymbol(Parser &p, Token::Kind identifierTok, /// parsing failed, nullptr is returned. The number of bytes read from the input /// string is returned in 'numRead'. template -static T parseSymbol(llvm::StringRef inputStr, MLIRContext *context, +static T parseSymbol(StringRef inputStr, MLIRContext *context, SymbolState &symbolState, ParserFn &&parserFn, size_t *numRead = nullptr) { SourceMgr sourceMgr; @@ -1866,7 +1866,7 @@ private: /// parseList([[1, 2], [3, 4]]) -> Success, [2, 2] /// parseList([[1, 2], 3]) -> Failure /// parseList([[1, [2, 3]], [4, [5]]]) -> Failure - ParseResult parseList(llvm::SmallVectorImpl &dims); + ParseResult parseList(SmallVectorImpl &dims); Parser &p; @@ -1877,7 +1877,7 @@ private: std::vector> storage; /// A flag that indicates the type of elements that have been parsed. - llvm::Optional knownEltKind; + Optional knownEltKind; }; } // namespace @@ -2032,13 +2032,11 @@ ParseResult TensorLiteralParser::parseElement() { /// parseList([[1, 2], [3, 4]]) -> Success, [2, 2] /// parseList([[1, 2], 3]) -> Failure /// parseList([[1, [2, 3]], [4, [5]]]) -> Failure -ParseResult -TensorLiteralParser::parseList(llvm::SmallVectorImpl &dims) { +ParseResult TensorLiteralParser::parseList(SmallVectorImpl &dims) { p.consumeToken(Token::l_square); - auto checkDims = - [&](const llvm::SmallVectorImpl &prevDims, - const llvm::SmallVectorImpl &newDims) -> ParseResult { + auto checkDims = [&](const SmallVectorImpl &prevDims, + const SmallVectorImpl &newDims) -> ParseResult { if (prevDims == newDims) return success(); return p.emitError("tensor literal is invalid; ranks are not consistent " @@ -2046,10 +2044,10 @@ TensorLiteralParser::parseList(llvm::SmallVectorImpl &dims) { }; bool first = true; - llvm::SmallVector newDims; + SmallVector newDims; unsigned size = 0; auto parseCommaSeparatedList = [&]() -> ParseResult { - llvm::SmallVector thisDims; + SmallVector thisDims; if (p.getToken().getKind() == Token::l_square) { if (parseList(thisDims)) return failure(); @@ -2275,7 +2273,7 @@ ParseResult Parser::parseFusedLocation(LocationAttr &loc) { return failure(); } - llvm::SmallVector locations; + SmallVector locations; auto parseElt = [&] { LocationAttr newLoc; if (parseLocationInstance(newLoc)) @@ -2411,7 +2409,7 @@ namespace { class AffineParser : public Parser { public: AffineParser(ParserState &state, bool allowParsingSSAIds = false, - llvm::function_ref parseElement = nullptr) + function_ref parseElement = nullptr) : Parser(state), allowParsingSSAIds(allowParsingSSAIds), parseElement(parseElement), numDimOperands(0), numSymbolOperands(0) {} @@ -2454,7 +2452,7 @@ private: private: bool allowParsingSSAIds; - llvm::function_ref parseElement; + function_ref parseElement; unsigned numDimOperands; unsigned numSymbolOperands; SmallVector, 4> dimsAndSymbols; @@ -3048,8 +3046,9 @@ ParseResult Parser::parseAffineMapOrIntegerSetReference(AffineMap &map, /// Parse an AffineMap of SSA ids. The callback 'parseElement' is used to /// parse SSA value uses encountered while parsing affine expressions. -ParseResult Parser::parseAffineMapOfSSAIds( - AffineMap &map, llvm::function_ref parseElement) { +ParseResult +Parser::parseAffineMapOfSSAIds(AffineMap &map, + function_ref parseElement) { return AffineParser(state, /*allowParsingSSAIds=*/true, parseElement) .parseAffineMapOfSSAIds(map); } @@ -3113,7 +3112,7 @@ public: /// Return the location of the value identified by its name and number if it /// has been already reference. - llvm::Optional getReferenceLoc(StringRef name, unsigned number) { + Optional getReferenceLoc(StringRef name, unsigned number) { auto &values = isolatedNameScopes.back().values; if (!values.count(name) || number >= values[name].size()) return {}; @@ -4781,8 +4780,8 @@ OwningModuleRef mlir::parseSourceString(StringRef moduleStr, /// parsing failed, nullptr is returned. The number of bytes read from the input /// string is returned in 'numRead'. template -static T parseSymbol(llvm::StringRef inputStr, MLIRContext *context, - size_t &numRead, ParserFn &&parserFn) { +static T parseSymbol(StringRef inputStr, MLIRContext *context, size_t &numRead, + ParserFn &&parserFn) { SymbolState aliasState; return parseSymbol( inputStr, context, aliasState, @@ -4795,35 +4794,33 @@ static T parseSymbol(llvm::StringRef inputStr, MLIRContext *context, &numRead); } -Attribute mlir::parseAttribute(llvm::StringRef attrStr, MLIRContext *context) { +Attribute mlir::parseAttribute(StringRef attrStr, MLIRContext *context) { size_t numRead = 0; return parseAttribute(attrStr, context, numRead); } -Attribute mlir::parseAttribute(llvm::StringRef attrStr, Type type) { +Attribute mlir::parseAttribute(StringRef attrStr, Type type) { size_t numRead = 0; return parseAttribute(attrStr, type, numRead); } -Attribute mlir::parseAttribute(llvm::StringRef attrStr, MLIRContext *context, +Attribute mlir::parseAttribute(StringRef attrStr, MLIRContext *context, size_t &numRead) { return parseSymbol(attrStr, context, numRead, [](Parser &parser) { return parser.parseAttribute(); }); } -Attribute mlir::parseAttribute(llvm::StringRef attrStr, Type type, - size_t &numRead) { +Attribute mlir::parseAttribute(StringRef attrStr, Type type, size_t &numRead) { return parseSymbol( attrStr, type.getContext(), numRead, [type](Parser &parser) { return parser.parseAttribute(type); }); } -Type mlir::parseType(llvm::StringRef typeStr, MLIRContext *context) { +Type mlir::parseType(StringRef typeStr, MLIRContext *context) { size_t numRead = 0; return parseType(typeStr, context, numRead); } -Type mlir::parseType(llvm::StringRef typeStr, MLIRContext *context, - size_t &numRead) { +Type mlir::parseType(StringRef typeStr, MLIRContext *context, size_t &numRead) { return parseSymbol(typeStr, context, numRead, [](Parser &parser) { return parser.parseType(); }); } diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index cb5194a..f893c7b 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -725,7 +725,7 @@ void PassInstrumentor::runAfterPassFailed(Pass *pass, Operation *op) { } /// See PassInstrumentation::runBeforeAnalysis for details. -void PassInstrumentor::runBeforeAnalysis(llvm::StringRef name, AnalysisID *id, +void PassInstrumentor::runBeforeAnalysis(StringRef name, AnalysisID *id, Operation *op) { llvm::sys::SmartScopedLock instrumentationLock(impl->mutex); for (auto &instr : impl->instrumentations) @@ -733,7 +733,7 @@ void PassInstrumentor::runBeforeAnalysis(llvm::StringRef name, AnalysisID *id, } /// See PassInstrumentation::runAfterAnalysis for details. -void PassInstrumentor::runAfterAnalysis(llvm::StringRef name, AnalysisID *id, +void PassInstrumentor::runAfterAnalysis(StringRef name, AnalysisID *id, Operation *op) { llvm::sys::SmartScopedLock instrumentationLock(impl->mutex); for (auto &instr : llvm::reverse(impl->instrumentations)) diff --git a/mlir/lib/Pass/PassManagerOptions.cpp b/mlir/lib/Pass/PassManagerOptions.cpp index 932bf98..c29e0d0 100644 --- a/mlir/lib/Pass/PassManagerOptions.cpp +++ b/mlir/lib/Pass/PassManagerOptions.cpp @@ -105,7 +105,7 @@ struct PassManagerOptions { }; } // end anonymous namespace -static llvm::ManagedStatic> options; +static llvm::ManagedStatic> options; /// Add an IR printing instrumentation if enabled by any 'print-ir' flags. void PassManagerOptions::addPrinterInstrumentation(PassManager &pm) { diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp index 397fef3..1a321d6 100644 --- a/mlir/lib/Pass/PassRegistry.cpp +++ b/mlir/lib/Pass/PassRegistry.cpp @@ -27,8 +27,7 @@ using namespace mlir; using namespace detail; /// Static mapping of all of the registered passes. -static llvm::ManagedStatic> - passRegistry; +static llvm::ManagedStatic> passRegistry; /// Static mapping of all of the registered pass pipelines. static llvm::ManagedStatic> @@ -138,7 +137,7 @@ private: /// A functor used to emit errors found during pipeline handling. The first /// parameter corresponds to the raw location within the pipeline string. This /// should always return failure. - using ErrorHandlerT = function_ref; + using ErrorHandlerT = function_ref; /// A struct to capture parsed pass pipeline names. /// @@ -189,7 +188,7 @@ LogicalResult TextualPipeline::initialize(StringRef text, pipelineMgr.AddNewSourceBuffer(llvm::MemoryBuffer::getMemBuffer( text, "MLIR Textual PassPipeline Parser"), llvm::SMLoc()); - auto errorHandler = [&](const char *rawLoc, llvm::Twine msg) { + auto errorHandler = [&](const char *rawLoc, Twine msg) { pipelineMgr.PrintMessage(errorStream, llvm::SMLoc::getFromPointer(rawLoc), llvm::SourceMgr::DK_Error, msg); return failure(); @@ -401,7 +400,7 @@ namespace { /// The name for the command line option used for parsing the textual pass /// pipeline. -static constexpr llvm::StringLiteral passPipelineArg = "pass-pipeline"; +static constexpr StringLiteral passPipelineArg = "pass-pipeline"; /// Adds command line option for each registered pass or pass pipeline, as well /// as textual pass pipelines. diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp index 3c46b0b..5306974 100644 --- a/mlir/lib/Pass/PassStatistics.cpp +++ b/mlir/lib/Pass/PassStatistics.cpp @@ -23,7 +23,7 @@ using namespace mlir; using namespace mlir::detail; -constexpr llvm::StringLiteral kPassStatsDescription = +constexpr StringLiteral kPassStatsDescription = "... Pass statistics report ..."; namespace { diff --git a/mlir/lib/Pass/PassTiming.cpp b/mlir/lib/Pass/PassTiming.cpp index dd193a4..113b65a 100644 --- a/mlir/lib/Pass/PassTiming.cpp +++ b/mlir/lib/Pass/PassTiming.cpp @@ -29,7 +29,7 @@ using namespace mlir; using namespace mlir::detail; -constexpr llvm::StringLiteral kPassTimingDescription = +constexpr StringLiteral kPassTimingDescription = "... Pass execution timing report ..."; namespace { @@ -182,11 +182,10 @@ struct PassTiming : public PassInstrumentation { void runAfterPassFailed(Pass *pass, Operation *op) override { runAfterPass(pass, op); } - void runBeforeAnalysis(llvm::StringRef name, AnalysisID *id, - Operation *) override { + void runBeforeAnalysis(StringRef name, AnalysisID *id, Operation *) override { startAnalysisTimer(name, id); } - void runAfterAnalysis(llvm::StringRef, AnalysisID *, Operation *) override; + void runAfterAnalysis(StringRef, AnalysisID *, Operation *) override; /// Print and clear the timing results. void print(); @@ -195,7 +194,7 @@ struct PassTiming : public PassInstrumentation { void startPassTimer(Pass *pass); /// Start a new timer for the given analysis. - void startAnalysisTimer(llvm::StringRef name, AnalysisID *id); + void startAnalysisTimer(StringRef name, AnalysisID *id); /// Pop the last active timer for the current thread. Timer *popLastActiveTimer() { @@ -301,7 +300,7 @@ void PassTiming::startPassTimer(Pass *pass) { } /// Start a new timer for the given analysis. -void PassTiming::startAnalysisTimer(llvm::StringRef name, AnalysisID *id) { +void PassTiming::startAnalysisTimer(StringRef name, AnalysisID *id) { Timer *timer = getTimer(id, TimerKind::PassOrAnalysis, [name] { return "(A) " + name.str(); }); timer->start(); @@ -330,12 +329,12 @@ void PassTiming::runAfterPass(Pass *pass, Operation *) { } /// Stop a timer. -void PassTiming::runAfterAnalysis(llvm::StringRef, AnalysisID *, Operation *) { +void PassTiming::runAfterAnalysis(StringRef, AnalysisID *, Operation *) { popLastActiveTimer()->stop(); } /// Utility to print the timer heading information. -static void printTimerHeader(llvm::raw_ostream &os, TimeRecord total) { +static void printTimerHeader(raw_ostream &os, TimeRecord total) { os << "===" << std::string(73, '-') << "===\n"; // Figure out how many spaces to description name. unsigned padding = (80 - kPassTimingDescription.size()) / 2; diff --git a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp index cfed2a2..d38c762 100644 --- a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp +++ b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp @@ -157,15 +157,15 @@ Type CAGAnchorNode::getTransformedType() { getOriginalType()); } -void CAGNode::printLabel(llvm::raw_ostream &os) const { +void CAGNode::printLabel(raw_ostream &os) const { os << "Node<" << static_cast(this) << ">"; } -void CAGAnchorNode::printLabel(llvm::raw_ostream &os) const { +void CAGAnchorNode::printLabel(raw_ostream &os) const { getUniformMetadata().printSummary(os); } -void CAGOperandAnchor::printLabel(llvm::raw_ostream &os) const { +void CAGOperandAnchor::printLabel(raw_ostream &os) const { os << "Operand<"; op->getName().print(os); os << "," << operandIdx; @@ -173,7 +173,7 @@ void CAGOperandAnchor::printLabel(llvm::raw_ostream &os) const { CAGAnchorNode::printLabel(os); } -void CAGResultAnchor::printLabel(llvm::raw_ostream &os) const { +void CAGResultAnchor::printLabel(raw_ostream &os) const { os << "Result<"; getOp()->getName().print(os); os << ">"; diff --git a/mlir/lib/Quantizer/Support/Metadata.cpp b/mlir/lib/Quantizer/Support/Metadata.cpp index 3661f52..89478c4 100644 --- a/mlir/lib/Quantizer/Support/Metadata.cpp +++ b/mlir/lib/Quantizer/Support/Metadata.cpp @@ -24,7 +24,7 @@ using namespace mlir; using namespace mlir::quantizer; -void CAGUniformMetadata::printSummary(llvm::raw_ostream &os) const { +void CAGUniformMetadata::printSummary(raw_ostream &os) const { if (requiredRange.hasValue()) { os << "\n[" << requiredRange.getValue().first << "," << requiredRange.getValue().second << "]"; diff --git a/mlir/lib/Quantizer/Support/Statistics.cpp b/mlir/lib/Quantizer/Support/Statistics.cpp index 788c2f6..d155875 100644 --- a/mlir/lib/Quantizer/Support/Statistics.cpp +++ b/mlir/lib/Quantizer/Support/Statistics.cpp @@ -28,11 +28,12 @@ using namespace mlir::quantizer; // AttributeTensorStatistics implementation //===----------------------------------------------------------------------===// -static void -collectElementsStatisticsDim(ElementsAttr attr, unsigned numElements, - ArrayRef shape, - llvm::SmallVectorImpl &indices, - uint64_t dim, TensorAxisStatistics &statistics) { +static void collectElementsStatisticsDim(ElementsAttr attr, + unsigned numElements, + ArrayRef shape, + SmallVectorImpl &indices, + uint64_t dim, + TensorAxisStatistics &statistics) { // Recursive terminating condition. if (dim >= shape.size()) return; @@ -71,7 +72,7 @@ static bool getElementsStatistics(ElementsAttr attr, if (!elementTy.isa()) return false; - llvm::SmallVector indices; + SmallVector indices; indices.resize(sType.getRank()); ArrayRef shape = sType.getShape(); @@ -97,8 +98,7 @@ bool AttributeTensorStatistics::get(TensorAxisStatistics &stats) const { namespace mlir { namespace quantizer { -llvm::raw_ostream &operator<<(llvm::raw_ostream &os, - const TensorAxisStatistics &stats) { +raw_ostream &operator<<(raw_ostream &os, const TensorAxisStatistics &stats) { os << "STATS[sampleSize=" << stats.sampleSize << ", min=" << stats.minValue << ", maxValue=" << stats.maxValue << ", mean=" << stats.mean << ", variance=" << stats.variance << "]"; diff --git a/mlir/lib/Quantizer/Support/UniformConstraints.cpp b/mlir/lib/Quantizer/Support/UniformConstraints.cpp index c43ecdf..1a800da 100644 --- a/mlir/lib/Quantizer/Support/UniformConstraints.cpp +++ b/mlir/lib/Quantizer/Support/UniformConstraints.cpp @@ -118,7 +118,7 @@ public: } private: - void printLabel(llvm::raw_ostream &os) const override { + void printLabel(raw_ostream &os) const override { os << "PropagateExplicitScale"; } void propagate(SolverContext &solverContext, @@ -127,7 +127,7 @@ private: // Get scale/zp from all parents. for (auto it = incoming_begin(), e = incoming_end(); it != e; ++it) { - auto parentAnchor = llvm::cast(*it); + auto parentAnchor = cast(*it); auto selectedType = parentAnchor->getUniformMetadata().selectedType; if (auto uqType = selectedType.dyn_cast_or_null()) { scaleZp.assertValue( @@ -139,7 +139,7 @@ private: // Propagate to children. if (scaleZp.hasValue()) { for (auto it = begin(), e = end(); it != e; ++it) { - auto childAnchor = llvm::cast(*it); + auto childAnchor = cast(*it); if (modified(childAnchor->getUniformMetadata() .explicitScaleZeroPoint.mergeFrom(scaleZp))) { childAnchor->markDirty(); @@ -163,9 +163,7 @@ public: } private: - void printLabel(llvm::raw_ostream &os) const override { - os << "SolveUniform"; - } + void printLabel(raw_ostream &os) const override { os << "SolveUniform"; } void propagate(SolverContext &solverContext, const TargetConfiguration &config) override { @@ -176,7 +174,7 @@ private: ClusteredFacts clusteredFacts; Type originalElementType; for (auto it = incoming_begin(), e = incoming_end(); it != e; ++it) { - auto parentAnchor = llvm::cast(*it); + auto parentAnchor = cast(*it); auto metadata = parentAnchor->getUniformMetadata(); // TODO: Possibly use a location that fuses all involved parents. fusedLoc = parentAnchor->getOp()->getLoc(); @@ -226,7 +224,7 @@ private: // Apply it to all parents. for (auto it = incoming_begin(), e = incoming_end(); it != e; ++it) { - auto parentAnchor = llvm::cast(*it); + auto parentAnchor = cast(*it); auto &metadata = parentAnchor->getUniformMetadata(); if (metadata.selectedType != selectedType) { metadata.selectedType = selectedType; diff --git a/mlir/lib/Quantizer/Support/UniformSolvers.cpp b/mlir/lib/Quantizer/Support/UniformSolvers.cpp index 341df5b..bd2fe68 100644 --- a/mlir/lib/Quantizer/Support/UniformSolvers.cpp +++ b/mlir/lib/Quantizer/Support/UniformSolvers.cpp @@ -16,9 +16,8 @@ // ============================================================================= #include "mlir/Quantizer/Support/UniformSolvers.h" - +#include "mlir/Support/LLVM.h" #include "llvm/Support/raw_ostream.h" - #include using namespace mlir; @@ -131,14 +130,13 @@ double UniformParamsFromMinMaxSolver::dequantize(int64_t xq) const { namespace mlir { namespace quantizer { -llvm::raw_ostream &operator<<(llvm::raw_ostream &os, - const UniformStorageParams &p) { +raw_ostream &operator<<(raw_ostream &os, const UniformStorageParams &p) { os << "UniformStorageParams{" << p.numLevels << ", " << p.minValue << "}"; return os; } -llvm::raw_ostream &operator<<(llvm::raw_ostream &os, - const UniformParamsFromMinMaxSolver &s) { +raw_ostream &operator<<(raw_ostream &os, + const UniformParamsFromMinMaxSolver &s) { os << "UniformParamsFromMinMaxSolver(" << s.getStepCount() << "){"; os << "(" << s.getBoundingMin() << ":" << s.getBoundingMax() << ") -> "; if (!s.isSatisfied()) { diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp index 7c449e3..511df0a 100644 --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -162,7 +162,7 @@ void InferQuantizedTypesPass::runWithConfig(SolverContext &solverContext, // operands). // Apply result types. for (auto *node : cag) { - auto anchorNode = llvm::dyn_cast(node); + auto anchorNode = dyn_cast(node); if (!anchorNode) continue; if (Type newType = anchorNode->getTransformedType()) @@ -171,7 +171,7 @@ void InferQuantizedTypesPass::runWithConfig(SolverContext &solverContext, // Apply operand types. for (auto *node : cag) { - auto anchorNode = llvm::dyn_cast(node); + auto anchorNode = dyn_cast(node); if (!anchorNode) continue; if (Type newType = anchorNode->getTransformedType()) diff --git a/mlir/lib/Support/JitRunner.cpp b/mlir/lib/Support/JitRunner.cpp index 8914681..dcd2343 100644 --- a/mlir/lib/Support/JitRunner.cpp +++ b/mlir/lib/Support/JitRunner.cpp @@ -122,14 +122,14 @@ static void initializeLLVM() { llvm::InitializeNativeTargetAsmPrinter(); } -static inline Error make_string_error(const llvm::Twine &message) { +static inline Error make_string_error(const Twine &message) { return llvm::make_error(message.str(), llvm::inconvertibleErrorCode()); } -static llvm::Optional getCommandLineOptLevel() { - llvm::Optional optLevel; - llvm::SmallVector>, 4> optFlags{ +static Optional getCommandLineOptLevel() { + Optional optLevel; + SmallVector>, 4> optFlags{ optO0, optO1, optO2, optO3}; // Determine if there is an optimization flag present. @@ -217,7 +217,7 @@ static Error compileAndExecuteSingleFloatReturnFunction( // the MLIR module to the ExecutionEngine. int mlir::JitRunnerMain( int argc, char **argv, - llvm::function_ref mlirTransformer) { + function_ref mlirTransformer) { llvm::InitLLVM y(argc, argv); initializeLLVM(); @@ -225,8 +225,8 @@ int mlir::JitRunnerMain( llvm::cl::ParseCommandLineOptions(argc, argv, "MLIR CPU execution driver\n"); - llvm::Optional optLevel = getCommandLineOptLevel(); - llvm::SmallVector>, 4> optFlags{ + Optional optLevel = getCommandLineOptLevel(); + SmallVector>, 4> optFlags{ optO0, optO1, optO2, optO3}; unsigned optCLIPosition = 0; // Determine if there is an optimization flag present, and its CLI position @@ -240,7 +240,7 @@ int mlir::JitRunnerMain( } // Generate vector of pass information, plus the index at which we should // insert any optimization passes in that vector (optPosition). - llvm::SmallVector passes; + SmallVector passes; unsigned optPosition = 0; for (unsigned i = 0, e = llvmPasses.size(); i < e; ++i) { passes.push_back(llvmPasses[i]); diff --git a/mlir/lib/Support/StorageUniquer.cpp b/mlir/lib/Support/StorageUniquer.cpp index 3672c0f..cae4dce 100644 --- a/mlir/lib/Support/StorageUniquer.cpp +++ b/mlir/lib/Support/StorageUniquer.cpp @@ -39,7 +39,7 @@ struct StorageUniquerImpl { unsigned hashValue; /// An equality function for comparing with an existing storage instance. - llvm::function_ref isEqual; + function_ref isEqual; }; /// A utility wrapper object representing a hashed storage object. This class @@ -52,8 +52,8 @@ struct StorageUniquerImpl { /// Get or create an instance of a complex derived type. BaseStorage * getOrCreate(unsigned kind, unsigned hashValue, - llvm::function_ref isEqual, - llvm::function_ref ctorFn) { + function_ref isEqual, + function_ref ctorFn) { LookupKey lookupKey{kind, hashValue, isEqual}; // Check for an existing instance in read-only mode. @@ -83,7 +83,7 @@ struct StorageUniquerImpl { /// Get or create an instance of a simple derived type. BaseStorage * getOrCreate(unsigned kind, - llvm::function_ref ctorFn) { + function_ref ctorFn) { // Check for an existing instance in read-only mode. { llvm::sys::SmartScopedReader typeLock(mutex); @@ -107,8 +107,8 @@ struct StorageUniquerImpl { /// Erase an instance of a complex derived type. void erase(unsigned kind, unsigned hashValue, - llvm::function_ref isEqual, - llvm::function_ref cleanupFn) { + function_ref isEqual, + function_ref cleanupFn) { LookupKey lookupKey{kind, hashValue, isEqual}; // Acquire a writer-lock so that we can safely erase the type instance. @@ -127,9 +127,9 @@ struct StorageUniquerImpl { //===--------------------------------------------------------------------===// /// Utility to create and initialize a storage instance. - BaseStorage *initializeStorage( - unsigned kind, - llvm::function_ref ctorFn) { + BaseStorage * + initializeStorage(unsigned kind, + function_ref ctorFn) { BaseStorage *storage = ctorFn(allocator); storage->kind = kind; return storage; @@ -162,11 +162,11 @@ struct StorageUniquerImpl { }; // Unique types with specific hashing or storage constraints. - using StorageTypeSet = llvm::DenseSet; + using StorageTypeSet = DenseSet; StorageTypeSet storageTypes; // Unique types with just the kind. - llvm::DenseMap simpleTypes; + DenseMap simpleTypes; // Allocator to use when constructing derived type instances. StorageUniquer::StorageAllocator allocator; @@ -184,7 +184,7 @@ StorageUniquer::~StorageUniquer() {} /// complex storage. auto StorageUniquer::getImpl( unsigned kind, unsigned hashValue, - llvm::function_ref isEqual, + function_ref isEqual, std::function ctorFn) -> BaseStorage * { return impl->getOrCreate(kind, hashValue, isEqual, ctorFn); } @@ -199,9 +199,8 @@ auto StorageUniquer::getImpl( /// Implementation for erasing an instance of a derived type with complex /// storage. -void StorageUniquer::eraseImpl( - unsigned kind, unsigned hashValue, - llvm::function_ref isEqual, - std::function cleanupFn) { +void StorageUniquer::eraseImpl(unsigned kind, unsigned hashValue, + function_ref isEqual, + std::function cleanupFn) { impl->erase(kind, hashValue, isEqual, cleanupFn); } diff --git a/mlir/lib/Support/TranslateClParser.cpp b/mlir/lib/Support/TranslateClParser.cpp index dae0437..115c0c0 100644 --- a/mlir/lib/Support/TranslateClParser.cpp +++ b/mlir/lib/Support/TranslateClParser.cpp @@ -35,9 +35,9 @@ using namespace mlir; // Storage for the translation function wrappers that survive the parser. -static llvm::SmallVector wrapperStorage; +static SmallVector wrapperStorage; -static LogicalResult printMLIROutput(ModuleOp module, llvm::raw_ostream &os) { +static LogicalResult printMLIROutput(ModuleOp module, raw_ostream &os) { if (failed(verify(module))) return failure(); module.print(os); @@ -57,7 +57,7 @@ TranslationParser::TranslationParser(llvm::cl::Option &opt) for (const auto &kv : toMLIRRegistry) { TranslateSourceMgrToMLIRFunction function = kv.second; TranslateFunction wrapper = [function](llvm::SourceMgr &sourceMgr, - llvm::raw_ostream &output, + raw_ostream &output, MLIRContext *context) { OwningModuleRef module = function(sourceMgr, context); if (!module) @@ -72,7 +72,7 @@ TranslationParser::TranslationParser(llvm::cl::Option &opt) for (const auto &kv : fromMLIRRegistry) { TranslateFromMLIRFunction function = kv.second; TranslateFunction wrapper = [function](llvm::SourceMgr &sourceMgr, - llvm::raw_ostream &output, + raw_ostream &output, MLIRContext *context) { auto module = OwningModuleRef(parseSourceFile(sourceMgr, context)); if (!module) diff --git a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp index b3bea0f..e69dce7 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp @@ -34,8 +34,8 @@ std::unique_ptr mlir::translateModuleToLLVMIR(ModuleOp m) { return LLVM::ModuleTranslation::translateModule<>(m); } -static TranslateFromMLIRRegistration registration( - "mlir-to-llvmir", [](ModuleOp module, llvm::raw_ostream &output) { +static TranslateFromMLIRRegistration + registration("mlir-to-llvmir", [](ModuleOp module, raw_ostream &output) { auto llvmModule = LLVM::ModuleTranslation::translateModule<>(module); if (!llvmModule) return failure(); diff --git a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp index 166ec89..83c4869 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp @@ -105,12 +105,11 @@ std::unique_ptr mlir::translateModuleToNVVMIR(Operation *m) { } static TranslateFromMLIRRegistration - registration("mlir-to-nvvmir", - [](ModuleOp module, llvm::raw_ostream &output) { - auto llvmModule = mlir::translateModuleToNVVMIR(module); - if (!llvmModule) - return failure(); - - llvmModule->print(output, nullptr); - return success(); - }); + registration("mlir-to-nvvmir", [](ModuleOp module, raw_ostream &output) { + auto llvmModule = mlir::translateModuleToNVVMIR(module); + if (!llvmModule) + return failure(); + + llvmModule->print(output, nullptr); + return success(); + }); diff --git a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp index 31ba4a2..c06e1ca 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp @@ -60,11 +60,11 @@ static llvm::Value *createDeviceFunctionCall(llvm::IRBuilder<> &builder, llvm::Type::getInt64Ty(module->getContext()), // return type. llvm::Type::getInt32Ty(module->getContext()), // parameter type. false); // no variadic arguments. - llvm::Function *fn = llvm::dyn_cast( + llvm::Function *fn = dyn_cast( module->getOrInsertFunction(fn_name, function_type).getCallee()); llvm::Value *fn_op0 = llvm::ConstantInt::get( llvm::Type::getInt32Ty(module->getContext()), parameter); - return builder.CreateCall(fn, llvm::ArrayRef(fn_op0)); + return builder.CreateCall(fn, ArrayRef(fn_op0)); } class ModuleTranslation : public LLVM::ModuleTranslation { @@ -111,12 +111,11 @@ std::unique_ptr mlir::translateModuleToROCDLIR(Operation *m) { } static TranslateFromMLIRRegistration - registration("mlir-to-rocdlir", - [](ModuleOp module, llvm::raw_ostream &output) { - auto llvmModule = mlir::translateModuleToROCDLIR(module); - if (!llvmModule) - return failure(); - - llvmModule->print(output, nullptr); - return success(); - }); + registration("mlir-to-rocdlir", [](ModuleOp module, raw_ostream &output) { + auto llvmModule = mlir::translateModuleToROCDLIR(module); + if (!llvmModule) + return failure(); + + llvmModule->print(output, nullptr); + return success(); + }); diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index 7a7964d..086c3a8 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -473,7 +473,7 @@ LogicalResult ModuleTranslation::convertFunctions() { for (auto function : getModuleBody(mlirModule).getOps()) { llvm::FunctionCallee llvmFuncCst = llvmModule->getOrInsertFunction( function.getName(), - llvm::cast(function.getType().getUnderlyingType())); + cast(function.getType().getUnderlyingType())); assert(isa(llvmFuncCst.getCallee())); functionMapping[function.getName()] = cast(llvmFuncCst.getCallee()); diff --git a/mlir/lib/Transforms/DialectConversion.cpp b/mlir/lib/Transforms/DialectConversion.cpp index 4b4575a..37c918f 100644 --- a/mlir/lib/Transforms/DialectConversion.cpp +++ b/mlir/lib/Transforms/DialectConversion.cpp @@ -35,7 +35,7 @@ using namespace mlir::detail; /// If 'target' is nonnull, operations that are recursively legal have their /// regions pre-filtered to avoid considering them for legalization. static LogicalResult -computeConversionSet(llvm::iterator_range region, +computeConversionSet(iterator_range region, Location regionLoc, std::vector &toConvert, ConversionTarget *target = nullptr) { if (llvm::empty(region)) @@ -537,9 +537,8 @@ struct ConversionPatternRewriterImpl { Region::iterator before); /// Notifies that the blocks of a region were cloned into another. - void - notifyRegionWasClonedBefore(llvm::iterator_range &blocks, - Location origRegionLoc); + void notifyRegionWasClonedBefore(iterator_range &blocks, + Location origRegionLoc); /// Remap the given operands to those with potentially different types. void remapValues(Operation::operand_range operands, @@ -742,7 +741,7 @@ void ConversionPatternRewriterImpl::notifyRegionIsBeingInlinedBefore( } void ConversionPatternRewriterImpl::notifyRegionWasClonedBefore( - llvm::iterator_range &blocks, Location origRegionLoc) { + iterator_range &blocks, Location origRegionLoc) { for (Block &block : blocks) blockActions.push_back(BlockAction::getCreate(&block)); @@ -986,7 +985,7 @@ private: void computeLegalizationGraphBenefit(); /// The current set of patterns that have been applied. - llvm::SmallPtrSet appliedPatterns; + SmallPtrSet appliedPatterns; /// The set of legality information for operations transitively supported by /// the target. @@ -1572,7 +1571,7 @@ void mlir::populateFuncOpTypeConversionPattern( /// 'convertSignatureArg' for each argument. This function should return a valid /// conversion for the signature on success, None otherwise. auto TypeConverter::convertBlockSignature(Block *block) - -> llvm::Optional { + -> Optional { SignatureConversion conversion(block->getNumArguments()); for (unsigned i = 0, e = block->getNumArguments(); i != e; ++i) if (failed(convertSignatureArg(i, block->getArgument(i)->getType(), diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp index dbb5381..9948a42 100644 --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -79,11 +79,11 @@ struct ResolvedCall { /// Collect all of the callable operations within the given range of blocks. If /// `traverseNestedCGNodes` is true, this will also collect call operations /// inside of nested callgraph nodes. -static void collectCallOps(llvm::iterator_range blocks, +static void collectCallOps(iterator_range blocks, CallGraph &cg, SmallVectorImpl &calls, bool traverseNestedCGNodes) { SmallVector worklist; - auto addToWorklist = [&](llvm::iterator_range blocks) { + auto addToWorklist = [&](iterator_range blocks) { for (Block &block : blocks) worklist.push_back(&block); }; @@ -120,8 +120,8 @@ struct Inliner : public InlinerInterface { /// Process a set of blocks that have been inlined. This callback is invoked /// *before* inlined terminator operations have been processed. - void processInlinedBlocks( - llvm::iterator_range inlinedBlocks) final { + void + processInlinedBlocks(iterator_range inlinedBlocks) final { collectCallOps(inlinedBlocks, cg, calls, /*traverseNestedCGNodes=*/true); } diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index 738524a..4932494 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -50,7 +50,7 @@ public: // - the op has no side-effects. If sideEffecting is Never, sideeffects of this // op and its nested ops are ignored. static bool canBeHoisted(Operation *op, - llvm::function_ref definedOutside, + function_ref definedOutside, SideEffecting sideEffecting, SideEffectsInterface &interface) { // Check that dependencies are defined outside of loop. diff --git a/mlir/lib/Transforms/Utils/FoldUtils.cpp b/mlir/lib/Transforms/Utils/FoldUtils.cpp index 5faca12..d4b7caa 100644 --- a/mlir/lib/Transforms/Utils/FoldUtils.cpp +++ b/mlir/lib/Transforms/Utils/FoldUtils.cpp @@ -82,9 +82,8 @@ static Operation *materializeConstant(Dialect *dialect, OpBuilder &builder, //===----------------------------------------------------------------------===// LogicalResult OperationFolder::tryToFold( - Operation *op, - llvm::function_ref processGeneratedConstants, - llvm::function_ref preReplaceAction) { + Operation *op, function_ref processGeneratedConstants, + function_ref preReplaceAction) { // If this is a unique'd constant, return failure as we know that it has // already been folded. if (referencedDialects.count(op)) @@ -140,7 +139,7 @@ void OperationFolder::notifyRemoval(Operation *op) { /// `results` with the results of the folding. LogicalResult OperationFolder::tryToFold( Operation *op, SmallVectorImpl &results, - llvm::function_ref processGeneratedConstants) { + function_ref processGeneratedConstants) { SmallVector operandConstants; SmallVector foldResults; diff --git a/mlir/lib/Transforms/Utils/InliningUtils.cpp b/mlir/lib/Transforms/Utils/InliningUtils.cpp index fd08c53..e8e6ae0 100644 --- a/mlir/lib/Transforms/Utils/InliningUtils.cpp +++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp @@ -35,7 +35,7 @@ using namespace mlir; /// Remap locations from the inlined blocks with CallSiteLoc locations with the /// provided caller location. static void -remapInlinedLocations(llvm::iterator_range inlinedBlocks, +remapInlinedLocations(iterator_range inlinedBlocks, Location callerLoc) { DenseMap mappedLocations; auto remapOpLoc = [&](Operation *op) { @@ -50,9 +50,8 @@ remapInlinedLocations(llvm::iterator_range inlinedBlocks, block.walk(remapOpLoc); } -static void -remapInlinedOperands(llvm::iterator_range inlinedBlocks, - BlockAndValueMapping &mapper) { +static void remapInlinedOperands(iterator_range inlinedBlocks, + BlockAndValueMapping &mapper) { auto remapOperands = [&](Operation *op) { for (auto &operand : op->getOpOperands()) if (auto *mappedOp = mapper.lookupOrNull(operand.get())) @@ -133,7 +132,7 @@ LogicalResult mlir::inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, BlockAndValueMapping &mapper, ArrayRef resultsToReplace, - llvm::Optional inlineLoc, + Optional inlineLoc, bool shouldCloneInlinedRegion) { // We expect the region to have at least one block. if (src->empty()) @@ -226,7 +225,7 @@ LogicalResult mlir::inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, ArrayRef inlinedOperands, ArrayRef resultsToReplace, - llvm::Optional inlineLoc, + Optional inlineLoc, bool shouldCloneInlinedRegion) { // We expect the region to have at least one block. if (src->empty()) diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 50248b0..419df8d 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -532,11 +532,11 @@ void mlir::interchangeLoops(AffineForOp forOpA, AffineForOp forOpB) { // desired loop interchange would violate dependences by making the // dependence component lexicographically negative. static bool checkLoopInterchangeDependences( - const std::vector> &depCompsVec, + const std::vector> &depCompsVec, ArrayRef loops, ArrayRef loopPermMap) { // Invert permutation map. unsigned maxLoopDepth = loops.size(); - llvm::SmallVector loopPermMapInv; + SmallVector loopPermMapInv; loopPermMapInv.resize(maxLoopDepth); for (unsigned i = 0; i < maxLoopDepth; ++i) loopPermMapInv[loopPermMap[i]] = i; @@ -547,7 +547,7 @@ static bool checkLoopInterchangeDependences( // Example 1: [-1, 1][0, 0] // Example 2: [0, 0][-1, 1] for (unsigned i = 0, e = depCompsVec.size(); i < e; ++i) { - const llvm::SmallVector &depComps = depCompsVec[i]; + const SmallVector &depComps = depCompsVec[i]; assert(depComps.size() >= maxLoopDepth); // Check if the first non-zero dependence component is positive. // This iterates through loops in the desired order. @@ -572,7 +572,7 @@ bool mlir::isValidLoopInterchangePermutation(ArrayRef loops, // rooted at 'loops[0]', at loop depths in range [1, maxLoopDepth]. assert(loopPermMap.size() == loops.size()); unsigned maxLoopDepth = loops.size(); - std::vector> depCompsVec; + std::vector> depCompsVec; getDependenceComponents(loops[0], maxLoopDepth, &depCompsVec); return checkLoopInterchangeDependences(depCompsVec, loops, loopPermMap); } @@ -608,13 +608,13 @@ AffineForOp mlir::sinkSequentialLoops(AffineForOp forOp) { // Gather dependence components for dependences between all ops in loop nest // rooted at 'loops[0]', at loop depths in range [1, maxLoopDepth]. unsigned maxLoopDepth = loops.size(); - std::vector> depCompsVec; + std::vector> depCompsVec; getDependenceComponents(loops[0], maxLoopDepth, &depCompsVec); // Mark loops as either parallel or sequential. - llvm::SmallVector isParallelLoop(maxLoopDepth, true); + SmallVector isParallelLoop(maxLoopDepth, true); for (unsigned i = 0, e = depCompsVec.size(); i < e; ++i) { - llvm::SmallVector &depComps = depCompsVec[i]; + SmallVector &depComps = depCompsVec[i]; assert(depComps.size() >= maxLoopDepth); for (unsigned j = 0; j < maxLoopDepth; ++j) { DependenceComponent &depComp = depComps[j]; @@ -632,7 +632,7 @@ AffineForOp mlir::sinkSequentialLoops(AffineForOp forOp) { // Compute permutation of loops that sinks sequential loops (and thus raises // parallel loops) while preserving relative order. - llvm::SmallVector loopPermMap(maxLoopDepth); + SmallVector loopPermMap(maxLoopDepth); unsigned nextSequentialLoop = numParallelLoops; unsigned nextParallelLoop = 0; for (unsigned i = 0; i < maxLoopDepth; ++i) { diff --git a/mlir/lib/Transforms/Utils/RegionUtils.cpp b/mlir/lib/Transforms/Utils/RegionUtils.cpp index ba77cea..b91b189 100644 --- a/mlir/lib/Transforms/Utils/RegionUtils.cpp +++ b/mlir/lib/Transforms/Utils/RegionUtils.cpp @@ -36,14 +36,13 @@ void mlir::replaceAllUsesInRegionWith(Value *orig, Value *replacement, } void mlir::visitUsedValuesDefinedAbove( - Region ®ion, Region &limit, - llvm::function_ref callback) { + Region ®ion, Region &limit, function_ref callback) { assert(limit.isAncestor(®ion) && "expected isolation limit to be an ancestor of the given region"); // Collect proper ancestors of `limit` upfront to avoid traversing the region // tree for every value. - llvm::SmallPtrSet properAncestors; + SmallPtrSet properAncestors; for (auto *reg = limit.getParentRegion(); reg != nullptr; reg = reg->getParentRegion()) { properAncestors.insert(reg); @@ -58,8 +57,7 @@ void mlir::visitUsedValuesDefinedAbove( } void mlir::visitUsedValuesDefinedAbove( - llvm::MutableArrayRef regions, - llvm::function_ref callback) { + MutableArrayRef regions, function_ref callback) { for (Region ®ion : regions) visitUsedValuesDefinedAbove(region, region, callback); } @@ -71,7 +69,7 @@ void mlir::getUsedValuesDefinedAbove(Region ®ion, Region &limit, }); } -void mlir::getUsedValuesDefinedAbove(llvm::MutableArrayRef regions, +void mlir::getUsedValuesDefinedAbove(MutableArrayRef regions, llvm::SetVector &values) { for (Region ®ion : regions) getUsedValuesDefinedAbove(region, region, values); @@ -352,7 +350,7 @@ static LogicalResult runRegionDCE(MutableArrayRef regions) { /// includes transformations like unreachable block elimination, dead argument /// elimination, as well as some other DCE. This function returns success if any /// of the regions were simplified, failure otherwise. -LogicalResult mlir::simplifyRegions(llvm::MutableArrayRef regions) { +LogicalResult mlir::simplifyRegions(MutableArrayRef regions) { LogicalResult eliminatedBlocks = eraseUnreachableBlocks(regions); LogicalResult eliminatedOpsOrArgs = runRegionDCE(regions); return success(succeeded(eliminatedBlocks) || succeeded(eliminatedOpsOrArgs)); diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index 036e534..e3212d5 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -557,7 +557,7 @@ static llvm::cl::list clFastestVaryingPattern( /// Forward declaration. static FilterFunctionType -isVectorizableLoopPtrFactory(const llvm::DenseSet ¶llelLoops, +isVectorizableLoopPtrFactory(const DenseSet ¶llelLoops, int fastestVaryingMemRefDimension); /// Creates a vectorization pattern from the command line arguments. @@ -565,7 +565,7 @@ isVectorizableLoopPtrFactory(const llvm::DenseSet ¶llelLoops, /// If the command line argument requests a pattern of higher order, returns an /// empty pattern list which will conservatively result in no vectorization. static std::vector -makePatterns(const llvm::DenseSet ¶llelLoops, int vectorRank, +makePatterns(const DenseSet ¶llelLoops, int vectorRank, ArrayRef fastestVaryingPattern) { using matcher::For; int64_t d0 = fastestVaryingPattern.empty() ? -1 : fastestVaryingPattern[0]; @@ -842,8 +842,8 @@ static LogicalResult vectorizeRootOrTerminal(Value *iv, map(makePtrDynCaster(), indices), AffineMapAttr::get(permutationMap), // TODO(b/144455320) add a proper padding value, not just 0.0 : f32 - state->folder->create( - b, opInst->getLoc(), llvm::APFloat(0.0f), b.getF32Type())); + state->folder->create(b, opInst->getLoc(), + APFloat(0.0f), b.getF32Type())); state->registerReplacement(opInst, transfer.getOperation()); } else { state->registerTerminal(opInst); @@ -889,7 +889,7 @@ static LogicalResult vectorizeAffineForOp(AffineForOp loop, int64_t step, /// loop whose underlying load/store accesses are either invariant or all // varying along the `fastestVaryingMemRefDimension`. static FilterFunctionType -isVectorizableLoopPtrFactory(const llvm::DenseSet ¶llelLoops, +isVectorizableLoopPtrFactory(const DenseSet ¶llelLoops, int fastestVaryingMemRefDimension) { return [¶llelLoops, fastestVaryingMemRefDimension](Operation &forOp) { auto loop = cast(forOp); @@ -1255,7 +1255,7 @@ void Vectorize::runOnFunction() { // Thread-safe RAII local context, BumpPtrAllocator freed on exit. NestedPatternContext mlContext; - llvm::DenseSet parallelLoops; + DenseSet parallelLoops; f.walk([¶llelLoops](AffineForOp loop) { if (isLoopParallel(loop)) parallelLoops.insert(loop); @@ -1293,7 +1293,7 @@ void Vectorize::runOnFunction() { } std::unique_ptr> -mlir::createVectorizePass(llvm::ArrayRef virtualVectorSize) { +mlir::createVectorizePass(ArrayRef virtualVectorSize) { return std::make_unique(virtualVectorSize); } diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp index 503a82b..591562d 100644 --- a/mlir/lib/Transforms/ViewOpGraph.cpp +++ b/mlir/lib/Transforms/ViewOpGraph.cpp @@ -28,15 +28,17 @@ static llvm::cl::opt elideIfLarger( llvm::cl::desc("Upper limit to emit elements attribute rather than elide"), llvm::cl::init(16)); +using namespace mlir; + namespace llvm { // Specialize GraphTraits to treat Block as a graph of Operations as nodes and // uses as edges. -template <> struct GraphTraits { - using GraphType = mlir::Block *; - using NodeRef = mlir::Operation *; +template <> struct GraphTraits { + using GraphType = Block *; + using NodeRef = Operation *; - using ChildIteratorType = mlir::UseIterator; + using ChildIteratorType = UseIterator; static ChildIteratorType child_begin(NodeRef n) { return ChildIteratorType(n); } @@ -46,49 +48,46 @@ template <> struct GraphTraits { // Operation's destructor is private so use Operation* instead and use // mapped iterator. - static mlir::Operation *AddressOf(mlir::Operation &op) { return &op; } - using nodes_iterator = - mapped_iterator; - static nodes_iterator nodes_begin(mlir::Block *b) { + static Operation *AddressOf(Operation &op) { return &op; } + using nodes_iterator = mapped_iterator; + static nodes_iterator nodes_begin(Block *b) { return nodes_iterator(b->begin(), &AddressOf); } - static nodes_iterator nodes_end(mlir::Block *b) { + static nodes_iterator nodes_end(Block *b) { return nodes_iterator(b->end(), &AddressOf); } }; // Specialize DOTGraphTraits to produce more readable output. -template <> -struct DOTGraphTraits : public DefaultDOTGraphTraits { +template <> struct DOTGraphTraits : public DefaultDOTGraphTraits { using DefaultDOTGraphTraits::DefaultDOTGraphTraits; - static std::string getNodeLabel(mlir::Operation *op, mlir::Block *); + static std::string getNodeLabel(Operation *op, Block *); }; -std::string DOTGraphTraits::getNodeLabel(mlir::Operation *op, - mlir::Block *b) { +std::string DOTGraphTraits::getNodeLabel(Operation *op, Block *b) { // Reuse the print output for the node labels. std::string ostr; raw_string_ostream os(ostr); os << op->getName() << "\n"; - if (!op->getLoc().isa()) { + if (!op->getLoc().isa()) { os << op->getLoc() << "\n"; } // Print resultant types - mlir::interleaveComma(op->getResultTypes(), os); + interleaveComma(op->getResultTypes(), os); os << "\n"; for (auto attr : op->getAttrs()) { os << '\n' << attr.first << ": "; // Always emit splat attributes. - if (attr.second.isa()) { + if (attr.second.isa()) { attr.second.print(os); continue; } // Elide "big" elements attributes. - auto elements = attr.second.dyn_cast(); + auto elements = attr.second.dyn_cast(); if (elements && elements.getNumElements() > elideIfLarger) { os << std::string(elements.getType().getRank(), '[') << "..." << std::string(elements.getType().getRank(), ']') << " : " @@ -96,7 +95,7 @@ std::string DOTGraphTraits::getNodeLabel(mlir::Operation *op, continue; } - auto array = attr.second.dyn_cast(); + auto array = attr.second.dyn_cast(); if (array && static_cast(array.size()) > elideIfLarger) { os << "[...]"; continue; @@ -114,14 +113,14 @@ namespace { // PrintOpPass is simple pass to write graph per function. // Note: this is a module pass only to avoid interleaving on the same ostream // due to multi-threading over functions. -struct PrintOpPass : public mlir::ModulePass { - explicit PrintOpPass(llvm::raw_ostream &os = llvm::errs(), - bool short_names = false, const llvm::Twine &title = "") +struct PrintOpPass : public ModulePass { + explicit PrintOpPass(raw_ostream &os = llvm::errs(), bool short_names = false, + const Twine &title = "") : os(os), title(title.str()), short_names(short_names) {} - std::string getOpName(mlir::Operation &op) { - auto symbolAttr = op.getAttrOfType( - mlir::SymbolTable::getSymbolAttrName()); + std::string getOpName(Operation &op) { + auto symbolAttr = + op.getAttrOfType(SymbolTable::getSymbolAttrName()); if (symbolAttr) return symbolAttr.getValue(); ++unnamedOpCtr; @@ -129,22 +128,22 @@ struct PrintOpPass : public mlir::ModulePass { } // Print all the ops in a module. - void processModule(mlir::ModuleOp module) { - for (mlir::Operation &op : module) { + void processModule(ModuleOp module) { + for (Operation &op : module) { // Modules may actually be nested, recurse on nesting. - if (auto nestedModule = llvm::dyn_cast(op)) { + if (auto nestedModule = dyn_cast(op)) { processModule(nestedModule); continue; } auto opName = getOpName(op); - for (mlir::Region ®ion : op.getRegions()) { + for (Region ®ion : op.getRegions()) { for (auto indexed_block : llvm::enumerate(region)) { // Suffix block number if there are more than 1 block. auto blockName = region.getBlocks().size() == 1 ? "" : ("__" + llvm::utostr(indexed_block.index())); llvm::WriteGraph(os, &indexed_block.value(), short_names, - llvm::Twine(title) + opName + blockName); + Twine(title) + opName + blockName); } } } @@ -153,29 +152,28 @@ struct PrintOpPass : public mlir::ModulePass { void runOnModule() override { processModule(getModule()); } private: - llvm::raw_ostream &os; + raw_ostream &os; std::string title; int unnamedOpCtr = 0; bool short_names; }; } // namespace -void mlir::viewGraph(mlir::Block &block, const llvm::Twine &name, - bool shortNames, const llvm::Twine &title, - llvm::GraphProgram::Name program) { +void mlir::viewGraph(Block &block, const Twine &name, bool shortNames, + const Twine &title, llvm::GraphProgram::Name program) { llvm::ViewGraph(&block, name, shortNames, title, program); } -llvm::raw_ostream &mlir::writeGraph(llvm::raw_ostream &os, mlir::Block &block, - bool shortNames, const llvm::Twine &title) { +raw_ostream &mlir::writeGraph(raw_ostream &os, Block &block, bool shortNames, + const Twine &title) { return llvm::WriteGraph(os, &block, shortNames, title); } -std::unique_ptr> -mlir::createPrintOpGraphPass(llvm::raw_ostream &os, bool shortNames, - const llvm::Twine &title) { +std::unique_ptr> +mlir::createPrintOpGraphPass(raw_ostream &os, bool shortNames, + const Twine &title) { return std::make_unique(os, shortNames, title); } -static mlir::PassRegistration pass("print-op-graph", - "Print op graph per region"); +static PassRegistration pass("print-op-graph", + "Print op graph per region"); diff --git a/mlir/lib/Transforms/ViewRegionGraph.cpp b/mlir/lib/Transforms/ViewRegionGraph.cpp index 57c2f31..db55415 100644 --- a/mlir/lib/Transforms/ViewRegionGraph.cpp +++ b/mlir/lib/Transforms/ViewRegionGraph.cpp @@ -53,41 +53,40 @@ std::string DOTGraphTraits::getNodeLabel(Block *Block, Region *) { } // end namespace llvm -void mlir::viewGraph(Region ®ion, const llvm::Twine &name, bool shortNames, - const llvm::Twine &title, - llvm::GraphProgram::Name program) { +void mlir::viewGraph(Region ®ion, const Twine &name, bool shortNames, + const Twine &title, llvm::GraphProgram::Name program) { llvm::ViewGraph(®ion, name, shortNames, title, program); } -llvm::raw_ostream &mlir::writeGraph(llvm::raw_ostream &os, Region ®ion, - bool shortNames, const llvm::Twine &title) { +raw_ostream &mlir::writeGraph(raw_ostream &os, Region ®ion, bool shortNames, + const Twine &title) { return llvm::WriteGraph(os, ®ion, shortNames, title); } -void mlir::Region::viewGraph(const llvm::Twine ®ionName) { +void mlir::Region::viewGraph(const Twine ®ionName) { ::mlir::viewGraph(*this, regionName); } void mlir::Region::viewGraph() { viewGraph("region"); } namespace { struct PrintCFGPass : public FunctionPass { - PrintCFGPass(llvm::raw_ostream &os = llvm::errs(), bool shortNames = false, - const llvm::Twine &title = "") + PrintCFGPass(raw_ostream &os = llvm::errs(), bool shortNames = false, + const Twine &title = "") : os(os), shortNames(shortNames), title(title.str()) {} void runOnFunction() override { mlir::writeGraph(os, getFunction().getBody(), shortNames, title); } private: - llvm::raw_ostream &os; + raw_ostream &os; bool shortNames; std::string title; }; } // namespace std::unique_ptr> -mlir::createPrintCFGGraphPass(llvm::raw_ostream &os, bool shortNames, - const llvm::Twine &title) { +mlir::createPrintCFGGraphPass(raw_ostream &os, bool shortNames, + const Twine &title) { return std::make_unique(os, shortNames, title); } -- 2.7.4