diff options
Diffstat (limited to 'mlir/lib/Dialect')
-rw-r--r-- | mlir/lib/Dialect/AffineOps/AffineOps.cpp | 12 | ||||
-rw-r--r-- | mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 10 | ||||
-rw-r--r-- | mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 8 | ||||
-rw-r--r-- | mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp | 6 | ||||
-rw-r--r-- | mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp | 2 | ||||
-rw-r--r-- | mlir/lib/Dialect/LoopOps/LoopOps.cpp | 2 | ||||
-rw-r--r-- | mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp | 4 | ||||
-rw-r--r-- | mlir/lib/Dialect/SDBM/SDBMExpr.cpp | 5 | ||||
-rw-r--r-- | mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp | 2 | ||||
-rw-r--r-- | mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp | 11 | ||||
-rw-r--r-- | mlir/lib/Dialect/VectorOps/VectorOps.cpp | 33 | ||||
-rw-r--r-- | mlir/lib/Dialect/VectorOps/VectorTransforms.cpp | 3 |
12 files changed, 57 insertions, 41 deletions
diff --git a/mlir/lib/Dialect/AffineOps/AffineOps.cpp b/mlir/lib/Dialect/AffineOps/AffineOps.cpp index 0da539ea9f0..f846adaf4c4 100644 --- a/mlir/lib/Dialect/AffineOps/AffineOps.cpp +++ b/mlir/lib/Dialect/AffineOps/AffineOps.cpp @@ -141,7 +141,8 @@ bool mlir::isValidDim(Value value) { /// Returns true if the 'index' dimension of the `memref` defined by /// `memrefDefOp` is a statically shaped one or defined using a valid symbol. template <typename AnyMemRefDefOp> -bool isMemRefSizeValidSymbol(AnyMemRefDefOp memrefDefOp, unsigned index) { +static bool isMemRefSizeValidSymbol(AnyMemRefDefOp memrefDefOp, + unsigned index) { auto memRefType = memrefDefOp.getType(); // Statically shaped. if (!ShapedType::isDynamic(memRefType.getDimSize(index))) @@ -1620,7 +1621,8 @@ static LogicalResult verify(AffineIfOp op) { return success(); } -ParseResult parseAffineIfOp(OpAsmParser &parser, OperationState &result) { +static ParseResult parseAffineIfOp(OpAsmParser &parser, + OperationState &result) { // Parse the condition attribute set. IntegerSetAttr conditionAttr; unsigned numDims; @@ -1667,7 +1669,7 @@ ParseResult parseAffineIfOp(OpAsmParser &parser, OperationState &result) { return success(); } -void print(OpAsmPrinter &p, AffineIfOp op) { +static void print(OpAsmPrinter &p, AffineIfOp op) { auto conditionAttr = op.getAttrOfType<IntegerSetAttr>(op.getConditionAttrName()); p << "affine.if " << conditionAttr; @@ -2057,7 +2059,7 @@ static ParseResult parseAffinePrefetchOp(OpAsmParser &parser, return success(); } -void print(OpAsmPrinter &p, AffinePrefetchOp op) { +static void print(OpAsmPrinter &p, AffinePrefetchOp op) { p << AffinePrefetchOp::getOperationName() << " " << op.memref() << '['; AffineMapAttr mapAttr = op.getAttrOfType<AffineMapAttr>(op.getMapAttrName()); if (mapAttr) { @@ -2074,7 +2076,7 @@ void print(OpAsmPrinter &p, AffinePrefetchOp op) { p << " : " << op.getMemRefType(); } -LogicalResult verify(AffinePrefetchOp op) { +static LogicalResult verify(AffinePrefetchOp op) { auto mapAttr = op.getAttrOfType<AffineMapAttr>(op.getMapAttrName()); if (mapAttr) { AffineMap map = mapAttr.getValue(); diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index dbca1fb003a..083e2826020 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -258,7 +258,7 @@ iterator_range<Block::args_iterator> LaunchOp::getKernelArguments() { return llvm::drop_begin(args, LaunchOp::kNumConfigRegionAttributes); } -LogicalResult verify(LaunchOp op) { +static LogicalResult verify(LaunchOp op) { // Kernel launch takes kNumConfigOperands leading operands for grid/block // sizes and transforms them into kNumConfigRegionAttributes region arguments // for block/thread identifiers and grid/block sizes. @@ -300,7 +300,7 @@ static void printSizeAssignment(OpAsmPrinter &p, KernelDim3 size, p << size.z << " = " << operands[2] << ')'; } -void printLaunchOp(OpAsmPrinter &p, LaunchOp op) { +static void printLaunchOp(OpAsmPrinter &p, LaunchOp op) { ValueRange operands = op.getOperands(); // Print the launch configuration. @@ -370,7 +370,7 @@ parseSizeAssignment(OpAsmParser &parser, // (`args` ssa-reassignment `:` type-list)? // region attr-dict? // ssa-reassignment ::= `(` ssa-id `=` ssa-use (`,` ssa-id `=` ssa-use)* `)` -ParseResult parseLaunchOp(OpAsmParser &parser, OperationState &result) { +static ParseResult parseLaunchOp(OpAsmParser &parser, OperationState &result) { // Sizes of the grid and block. SmallVector<OpAsmParser::OperandType, LaunchOp::kNumConfigOperands> sizes( LaunchOp::kNumConfigOperands); @@ -549,7 +549,7 @@ KernelDim3 LaunchFuncOp::getBlockSizeOperandValues() { return KernelDim3{getOperand(3), getOperand(4), getOperand(5)}; } -LogicalResult verify(LaunchFuncOp op) { +static LogicalResult verify(LaunchFuncOp op) { auto module = op.getParentOfType<ModuleOp>(); if (!module) return op.emitOpError("expected to belong to a module"); @@ -729,7 +729,7 @@ static void printAttributions(OpAsmPrinter &p, StringRef keyword, } /// Prints a GPU Func op. -void printGPUFuncOp(OpAsmPrinter &p, GPUFuncOp op) { +static void printGPUFuncOp(OpAsmPrinter &p, GPUFuncOp op) { p << GPUFuncOp::getOperationName() << ' '; p.printSymbolName(op.getName()); diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index a8be9b20b44..384d24957f4 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -109,7 +109,7 @@ static ParseResult parseGenericOp(OpAsmParser &parser, OperationState &result) { } template <typename GenericOpType> -LogicalResult verifyBlockArgs(GenericOpType op, Block &block); +static LogicalResult verifyBlockArgs(GenericOpType op, Block &block); template <> LogicalResult verifyBlockArgs(GenericOp op, Block &block) { auto nViews = op.getNumInputsAndOutputs(); @@ -158,7 +158,7 @@ template <> LogicalResult verifyBlockArgs(IndexedGenericOp op, Block &block) { } template <typename GenericOpType> -LogicalResult verifyFuncArgs(GenericOpType op, FunctionType funType); +static LogicalResult verifyFuncArgs(GenericOpType op, FunctionType funType); template <> LogicalResult verifyFuncArgs(GenericOp op, FunctionType funType) { auto nViews = op.getNumInputsAndOutputs(); @@ -228,7 +228,7 @@ LogicalResult verifyFuncArgs(IndexedGenericOp op, FunctionType funType) { } template <typename GenericOpType> -LogicalResult verifyGenericOp(GenericOpType op) { +static LogicalResult verifyGenericOp(GenericOpType op) { auto nInputViews = op.getNumInputs(); auto nLoops = op.getNumLoops(); auto nViews = op.getNumInputsAndOutputs(); @@ -729,7 +729,7 @@ static ParseResult parseYieldOp(OpAsmParser &parser, OperationState &result) { } template <typename GenericOpType> -LogicalResult verifyYield(YieldOp op, GenericOpType genericOp) { +static LogicalResult verifyYield(YieldOp op, GenericOpType genericOp) { // The operand number and types must match the view element types. auto nOutputViews = genericOp.getNumOutputs(); if (op.getNumOperands() != nOutputViews) diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp index c9f4b34ebc0..f5dac8aced1 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp @@ -37,6 +37,8 @@ using IndexedAffineValue = TemplatedIndexedValue<affine_load, affine_store>; using edsc::op::operator+; using edsc::op::operator==; +namespace { + static SmallVector<ValueHandle, 8> makeCanonicalAffineApplies(OpBuilder &b, Location loc, AffineMap map, ArrayRef<Value> vals) { @@ -379,7 +381,6 @@ public: } }; -namespace { // This struct is for factoring out the implementation and support template // instantiations in the following 2 cases: // 1. Appending to a list of patterns via RewritePatternList. @@ -393,7 +394,6 @@ class LinalgOpToLoopsImpl { public: static LogicalResult doit(Operation *op, PatternRewriter &rewriter); }; -} // namespace template <typename LoopTy, typename IndexedValueTy, typename ConcreteOpTy> LogicalResult LinalgOpToLoopsImpl<LoopTy, IndexedValueTy, ConcreteOpTy>::doit( @@ -538,6 +538,8 @@ void LowerLinalgToLoopsPass<LoopType, IndexedValueType>::runOnFunction() { applyPatternsGreedily(this->getFunction(), patterns); } +} // namespace + /// Create a pass to convert Linalg operations to loop.for loops and /// std.load/std.store accesses. std::unique_ptr<OpPassBase<FuncOp>> diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index b77f658aa2f..bcf6576abbb 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -170,7 +170,7 @@ struct TileCheck : public AffineExprVisitor<TileCheck> { // // TODO(pifon, ntv): Investigate whether mixing implicit and explicit indices // does not lead to losing information. -void transformIndexedGenericOpIndices( +static void transformIndexedGenericOpIndices( OpBuilder &b, LinalgOp op, ArrayRef<ValueHandle *> pivs, const LoopIndexToRangeIndexMap &loopIndexToRangeIndex) { auto indexedGenericOp = dyn_cast<IndexedGenericOp>(op.getOperation()); diff --git a/mlir/lib/Dialect/LoopOps/LoopOps.cpp b/mlir/lib/Dialect/LoopOps/LoopOps.cpp index 7e3e286b842..8effe71088c 100644 --- a/mlir/lib/Dialect/LoopOps/LoopOps.cpp +++ b/mlir/lib/Dialect/LoopOps/LoopOps.cpp @@ -68,7 +68,7 @@ void ForOp::build(Builder *builder, OperationState &result, Value lb, Value ub, bodyRegion->front().addArgument(builder->getIndexType()); } -LogicalResult verify(ForOp op) { +static LogicalResult verify(ForOp op) { if (auto cst = dyn_cast_or_null<ConstantIndexOp>(op.step().getDefiningOp())) if (cst.getValue() <= 0) return op.emitOpError("constant step operand must be positive"); diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp index 2a4c14f2231..ffd7efb21bd 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp @@ -26,8 +26,6 @@ public: void runOnFunction() override; }; -} // end anonymous namespace - /// Base class rewrites ConstFakeQuant into a qbarrier/dbarrier pair. template <typename ConcreteRewriteClass, typename FakeQuantOp> class FakeQuantRewrite : public OpRewritePattern<FakeQuantOp> { @@ -126,6 +124,8 @@ public: } }; +} // namespace + void ConvertSimulatedQuantPass::runOnFunction() { bool hadFailure = false; OwningRewritePatternList patterns; diff --git a/mlir/lib/Dialect/SDBM/SDBMExpr.cpp b/mlir/lib/Dialect/SDBM/SDBMExpr.cpp index 68e3e1c278e..ae2f447796e 100644 --- a/mlir/lib/Dialect/SDBM/SDBMExpr.cpp +++ b/mlir/lib/Dialect/SDBM/SDBMExpr.cpp @@ -301,8 +301,9 @@ AffineExpr SDBMExpr::getAsAffineExpr() const { // expression is already a sum expression, update its constant and extract the // LHS if the constant becomes zero. Otherwise, construct a sum expression. template <typename Result> -Result addConstantAndSink(SDBMDirectExpr expr, int64_t constant, bool negated, - function_ref<Result(SDBMDirectExpr)> builder) { +static Result addConstantAndSink(SDBMDirectExpr expr, int64_t constant, + bool negated, + function_ref<Result(SDBMDirectExpr)> builder) { SDBMDialect *dialect = expr.getDialect(); if (auto sumExpr = expr.dyn_cast<SDBMSumExpr>()) { if (negated) diff --git a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp index 98c36fb9b08..0e543df29b6 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp @@ -375,6 +375,7 @@ Optional<uint64_t> parseAndVerify<uint64_t>(SPIRVDialect const &dialect, return parseAndVerifyInteger<uint64_t>(dialect, parser); } +namespace { // Functor object to parse a comma separated list of specs. The function // parseAndVerify does the actual parsing and verification of individual // elements. This is a functor since parsing the last element of the list @@ -407,6 +408,7 @@ template <typename ParseType> struct parseCommaSeparatedList<ParseType> { return llvm::None; } }; +} // namespace // dim ::= `1D` | `2D` | `3D` | `Cube` | <and other SPIR-V Dim specifiers...> // diff --git a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp index 750710fa3d9..46596741ea0 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp @@ -33,8 +33,8 @@ using namespace mlir; // Deserializes the SPIR-V binary module stored in the file named as // `inputFilename` and returns a module containing the SPIR-V module. -OwningModuleRef deserializeModule(const llvm::MemoryBuffer *input, - MLIRContext *context) { +static OwningModuleRef deserializeModule(const llvm::MemoryBuffer *input, + MLIRContext *context) { Builder builder(context); // Make sure the input stream can be treated as a stream of SPIR-V words @@ -71,7 +71,7 @@ static TranslateToMLIRRegistration fromBinary( // Serialization registration //===----------------------------------------------------------------------===// -LogicalResult serializeModule(ModuleOp module, raw_ostream &output) { +static LogicalResult serializeModule(ModuleOp module, raw_ostream &output) { if (!module) return failure(); @@ -104,8 +104,9 @@ static TranslateFromMLIRRegistration // Round-trip registration //===----------------------------------------------------------------------===// -LogicalResult roundTripModule(llvm::SourceMgr &sourceMgr, raw_ostream &output, - MLIRContext *context) { +static 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) diff --git a/mlir/lib/Dialect/VectorOps/VectorOps.cpp b/mlir/lib/Dialect/VectorOps/VectorOps.cpp index f2742de8428..b26f70adbba 100644 --- a/mlir/lib/Dialect/VectorOps/VectorOps.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorOps.cpp @@ -918,9 +918,10 @@ static ParseResult parseInsertStridedSliceOp(OpAsmParser &parser, // TODO(ntv) Should be moved to Tablegen Confined attributes. template <typename OpType> -LogicalResult isIntegerArrayAttrSmallerThanShape(OpType op, ArrayAttr arrayAttr, - ArrayRef<int64_t> shape, - StringRef attrName) { +static LogicalResult isIntegerArrayAttrSmallerThanShape(OpType op, + ArrayAttr arrayAttr, + ArrayRef<int64_t> shape, + StringRef attrName) { if (arrayAttr.size() > shape.size()) return op.emitOpError("expected ") << attrName << " attribute of rank smaller than vector rank"; @@ -931,10 +932,10 @@ LogicalResult isIntegerArrayAttrSmallerThanShape(OpType op, ArrayAttr arrayAttr, // interval. If `halfOpen` is true then the admissible interval is [min, max). // Otherwise, the admissible interval is [min, max]. template <typename OpType> -LogicalResult isIntegerArrayAttrConfinedToRange(OpType op, ArrayAttr arrayAttr, - int64_t min, int64_t max, - StringRef attrName, - bool halfOpen = true) { +static LogicalResult +isIntegerArrayAttrConfinedToRange(OpType op, ArrayAttr arrayAttr, int64_t min, + int64_t max, StringRef attrName, + bool halfOpen = true) { for (auto attr : arrayAttr) { auto val = attr.cast<IntegerAttr>().getInt(); auto upper = max; @@ -951,7 +952,7 @@ LogicalResult isIntegerArrayAttrConfinedToRange(OpType op, ArrayAttr arrayAttr, // interval. If `halfOpen` is true then the admissible interval is [min, max). // Otherwise, the admissible interval is [min, max]. template <typename OpType> -LogicalResult +static LogicalResult isIntegerArrayAttrConfinedToShape(OpType op, ArrayAttr arrayAttr, ArrayRef<int64_t> shape, StringRef attrName, bool halfOpen = true, int64_t min = 0) { @@ -975,7 +976,7 @@ isIntegerArrayAttrConfinedToShape(OpType op, ArrayAttr arrayAttr, // interval. If `halfOpen` is true then the admissible interval is [min, max). // Otherwise, the admissible interval is [min, max]. template <typename OpType> -LogicalResult isSumOfIntegerArrayAttrConfinedToShape( +static LogicalResult isSumOfIntegerArrayAttrConfinedToShape( OpType op, ArrayAttr arrayAttr1, ArrayAttr arrayAttr2, ArrayRef<int64_t> shape, StringRef attrName1, StringRef attrName2, bool halfOpen = true, int64_t min = 1) { @@ -1470,7 +1471,8 @@ static void print(OpAsmPrinter &p, TransferReadOp op) { p << " : " << op.getMemRefType() << ", " << op.getVectorType(); } -ParseResult parseTransferReadOp(OpAsmParser &parser, OperationState &result) { +static ParseResult parseTransferReadOp(OpAsmParser &parser, + OperationState &result) { llvm::SMLoc typesLoc; OpAsmParser::OperandType memrefInfo; SmallVector<OpAsmParser::OperandType, 8> indexInfo; @@ -1545,7 +1547,8 @@ static void print(OpAsmPrinter &p, TransferWriteOp op) { p << " : " << op.getVectorType() << ", " << op.getMemRefType(); } -ParseResult parseTransferWriteOp(OpAsmParser &parser, OperationState &result) { +static ParseResult parseTransferWriteOp(OpAsmParser &parser, + OperationState &result) { llvm::SMLoc typesLoc; OpAsmParser::OperandType storeValueInfo; OpAsmParser::OperandType memRefInfo; @@ -1682,7 +1685,8 @@ static LogicalResult verify(TupleGetOp op) { // ConstantMaskOp //===----------------------------------------------------------------------===// -ParseResult parseConstantMaskOp(OpAsmParser &parser, OperationState &result) { +static ParseResult parseConstantMaskOp(OpAsmParser &parser, + OperationState &result) { Type resultType; ArrayAttr maskDimSizesAttr; StringRef attrName = ConstantMaskOp::getMaskDimSizesAttrName(); @@ -1729,7 +1733,8 @@ static LogicalResult verify(ConstantMaskOp &op) { // CreateMaskOp //===----------------------------------------------------------------------===// -ParseResult parseCreateMaskOp(OpAsmParser &parser, OperationState &result) { +static ParseResult parseCreateMaskOp(OpAsmParser &parser, + OperationState &result) { auto indexType = parser.getBuilder().getIndexType(); Type resultType; SmallVector<OpAsmParser::OperandType, 4> operandInfo; @@ -1758,7 +1763,7 @@ static LogicalResult verify(CreateMaskOp op) { // PrintOp //===----------------------------------------------------------------------===// -ParseResult parsePrintOp(OpAsmParser &parser, OperationState &result) { +static ParseResult parsePrintOp(OpAsmParser &parser, OperationState &result) { OpAsmParser::OperandType source; Type sourceType; return failure(parser.parseOperand(source) || diff --git a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp index d98f41e3d63..c86c4325d79 100644 --- a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp @@ -522,6 +522,7 @@ generateTransferOpSlices(VectorType vectorType, TupleType tupleType, } } +namespace { // Splits vector TransferReadOp into smaller TransferReadOps based on slicing // scheme of its unique ExtractSlicesOp user. struct SplitTransferReadOp : public OpRewritePattern<vector::TransferReadOp> { @@ -657,6 +658,8 @@ struct TupleGetFolderOp : public OpRewritePattern<vector::TupleGetOp> { } }; +} // namespace + // TODO(andydavis) Add pattern to rewrite ExtractSlices(ConstantMaskOp). // TODO(andydavis) Add this as DRR pattern. void mlir::vector::populateVectorToVectorTransformationPatterns( |