diff --git a/mlir/examples/toy/Ch1/parser/AST.cpp b/mlir/examples/toy/Ch1/parser/AST.cpp --- a/mlir/examples/toy/Ch1/parser/AST.cpp +++ b/mlir/examples/toy/Ch1/parser/AST.cpp @@ -61,7 +61,8 @@ } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch2/parser/AST.cpp b/mlir/examples/toy/Ch2/parser/AST.cpp --- a/mlir/examples/toy/Ch2/parser/AST.cpp +++ b/mlir/examples/toy/Ch2/parser/AST.cpp @@ -61,7 +61,8 @@ } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch3/parser/AST.cpp b/mlir/examples/toy/Ch3/parser/AST.cpp --- a/mlir/examples/toy/Ch3/parser/AST.cpp +++ b/mlir/examples/toy/Ch3/parser/AST.cpp @@ -61,7 +61,8 @@ } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch4/parser/AST.cpp b/mlir/examples/toy/Ch4/parser/AST.cpp --- a/mlir/examples/toy/Ch4/parser/AST.cpp +++ b/mlir/examples/toy/Ch4/parser/AST.cpp @@ -61,7 +61,8 @@ } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch5/parser/AST.cpp b/mlir/examples/toy/Ch5/parser/AST.cpp --- a/mlir/examples/toy/Ch5/parser/AST.cpp +++ b/mlir/examples/toy/Ch5/parser/AST.cpp @@ -61,7 +61,8 @@ } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch6/parser/AST.cpp b/mlir/examples/toy/Ch6/parser/AST.cpp --- a/mlir/examples/toy/Ch6/parser/AST.cpp +++ b/mlir/examples/toy/Ch6/parser/AST.cpp @@ -61,7 +61,8 @@ } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/examples/toy/Ch7/parser/AST.cpp b/mlir/examples/toy/Ch7/parser/AST.cpp --- a/mlir/examples/toy/Ch7/parser/AST.cpp +++ b/mlir/examples/toy/Ch7/parser/AST.cpp @@ -63,7 +63,8 @@ } // namespace /// Return a formatted string for the location of any node -template static std::string loc(T *node) { +template +static std::string loc(T *node) { const auto &loc = node->loc(); return (llvm::Twine("@") + *loc.file + ":" + llvm::Twine(loc.line) + ":" + llvm::Twine(loc.col)) diff --git a/mlir/include/mlir/ADT/TypeSwitch.h b/mlir/include/mlir/ADT/TypeSwitch.h --- a/mlir/include/mlir/ADT/TypeSwitch.h +++ b/mlir/include/mlir/ADT/TypeSwitch.h @@ -21,7 +21,8 @@ namespace mlir { namespace detail { -template class TypeSwitchBase { +template +class TypeSwitchBase { public: TypeSwitchBase(const T &value) : value(value) {} TypeSwitchBase(TypeSwitchBase &&other) : value(other.value) {} @@ -45,7 +46,8 @@ /// the first input of the given callable. /// Note: This inference rules for this overload are very simple: strip /// pointers and references. - template DerivedT &Case(CallableT &&caseFn) { + template + DerivedT &Case(CallableT &&caseFn) { using Traits = FunctionTraits>; using CaseT = std::remove_cv_t>>>; @@ -162,7 +164,8 @@ } /// As a default, invoke the given callable within the root value. - template void Default(CallableT &&defaultFn) { + template + void Default(CallableT &&defaultFn) { if (!foundMatch) defaultFn(this->value); } diff --git a/mlir/include/mlir/Analysis/CallGraph.h b/mlir/include/mlir/Analysis/CallGraph.h --- a/mlir/include/mlir/Analysis/CallGraph.h +++ b/mlir/include/mlir/Analysis/CallGraph.h @@ -217,7 +217,8 @@ namespace llvm { // Provide graph traits for traversing call graphs using standard graph // traversals. -template <> struct GraphTraits { +template <> +struct GraphTraits { using NodeRef = mlir::CallGraphNode *; static NodeRef getEntryNode(NodeRef node) { return node; } diff --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h --- a/mlir/include/mlir/Analysis/Dominance.h +++ b/mlir/include/mlir/Analysis/Dominance.h @@ -20,7 +20,8 @@ class Operation; namespace detail { -template class DominanceInfoBase { +template +class DominanceInfoBase { using base = llvm::DominatorTreeBase; public: @@ -119,7 +120,8 @@ /// DominatorTree GraphTraits specialization so the DominatorTree can be /// iterated by generic graph iterators. -template <> struct GraphTraits { +template <> +struct GraphTraits { using ChildIteratorType = mlir::DominanceInfoNode::iterator; using NodeRef = mlir::DominanceInfoNode *; @@ -128,7 +130,8 @@ static inline ChildIteratorType child_end(NodeRef N) { return N->end(); } }; -template <> struct GraphTraits { +template <> +struct GraphTraits { using ChildIteratorType = mlir::DominanceInfoNode::const_iterator; using NodeRef = const mlir::DominanceInfoNode *; diff --git a/mlir/include/mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h b/mlir/include/mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h --- a/mlir/include/mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h +++ b/mlir/include/mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h @@ -14,7 +14,8 @@ namespace mlir { class LLVMTypeConverter; class ModuleOp; -template class OpPassBase; +template +class OpPassBase; class OwningRewritePatternList; /// Collect a set of patterns to convert from the AVX512 dialect to LLVM. diff --git a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h --- a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h +++ b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h @@ -19,7 +19,8 @@ class Location; class ModuleOp; -template class OpPassBase; +template +class OpPassBase; namespace gpu { class GPUModuleOp; diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h --- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h +++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h @@ -14,7 +14,8 @@ class LLVMTypeConverter; class OwningRewritePatternList; -template class OpPassBase; +template +class OpPassBase; namespace gpu { class GPUModuleOp; diff --git a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h --- a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h +++ b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h @@ -15,7 +15,8 @@ namespace gpu { class GPUModuleOp; } // namespace gpu -template class OpPassBase; +template +class OpPassBase; /// Creates a pass that lowers GPU dialect operations to ROCDL counterparts. std::unique_ptr> createLowerGpuOpsToROCDLOpsPass(); diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h --- a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h +++ b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h @@ -20,7 +20,8 @@ namespace mlir { class ModuleOp; -template class OpPassBase; +template +class OpPassBase; /// Pass to convert GPU Ops to SPIR-V ops. For a gpu.func to be converted, it /// should have a spv.entry_point_abi attribute. diff --git a/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h b/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h --- a/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h +++ b/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h @@ -21,7 +21,8 @@ namespace mlir { class ModuleOp; -template class OpPassBase; +template +class OpPassBase; std::unique_ptr> createConvertVulkanLaunchFuncToVulkanCallsPass(); diff --git a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h --- a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h +++ b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h @@ -14,7 +14,8 @@ namespace mlir { class MLIRContext; class ModuleOp; -template class OpPassBase; +template +class OpPassBase; /// Populate the given list with patterns that convert from Linalg to LLVM. void populateLinalgToLLVMConversionPatterns(LLVMTypeConverter &converter, diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h @@ -14,7 +14,8 @@ namespace mlir { class FuncOp; -template class OpPassBase; +template +class OpPassBase; class Pass; /// Create a pass that converts loop nests into GPU kernels. It considers diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -14,7 +14,8 @@ namespace mlir { class LLVMTypeConverter; class ModuleOp; -template class OpPassBase; +template +class OpPassBase; class OwningRewritePatternList; /// Collect a set of patterns to convert memory-related operations from the diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h --- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h +++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h @@ -13,7 +13,8 @@ namespace mlir { class LLVMTypeConverter; class ModuleOp; -template class OpPassBase; +template +class OpPassBase; /// Collect a set of patterns to convert from Vector contractions to LLVM Matrix /// Intrinsics. To lower to assembly, the LLVM flag -lower-matrix-intrinsics diff --git a/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h b/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h --- a/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h +++ b/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h @@ -13,7 +13,8 @@ namespace mlir { class MLIRContext; class ModuleOp; -template class OpPassBase; +template +class OpPassBase; /// Collect a set of patterns to convert from the Vector dialect to loops + std. void populateVectorToAffineLoopsConversionPatterns( diff --git a/mlir/include/mlir/Dialect/Affine/Passes.h b/mlir/include/mlir/Dialect/Affine/Passes.h --- a/mlir/include/mlir/Dialect/Affine/Passes.h +++ b/mlir/include/mlir/Dialect/Affine/Passes.h @@ -24,7 +24,8 @@ class FuncOp; class ModuleOp; class Pass; -template class OpPassBase; +template +class OpPassBase; /// Creates a simplification pass for affine structures (maps and sets). In /// addition, this pass also normalizes memrefs to have the trivial (identity) diff --git a/mlir/include/mlir/Dialect/FxpMathOps/Passes.h b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h --- a/mlir/include/mlir/Dialect/FxpMathOps/Passes.h +++ b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h @@ -15,7 +15,8 @@ namespace mlir { class FuncOp; -template class OpPassBase; +template +class OpPassBase; namespace fxpmath { diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h --- a/mlir/include/mlir/Dialect/GPU/Passes.h +++ b/mlir/include/mlir/Dialect/GPU/Passes.h @@ -19,7 +19,8 @@ class MLIRContext; class ModuleOp; -template class OpPassBase; +template +class OpPassBase; class OwningRewritePatternList; std::unique_ptr> createGpuKernelOutliningPass(); diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h @@ -79,7 +79,8 @@ /// Helper template class for building loop.for and affine.loop nests from /// ranges. -template class GenericLoopNestRangeBuilder { +template +class GenericLoopNestRangeBuilder { public: GenericLoopNestRangeBuilder(ArrayRef ivs, ArrayRef ranges); diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h @@ -25,7 +25,8 @@ /// /// class DotOp : public Op::Impl> { /// -template class NInputs { +template +class NInputs { public: template class Impl : public OpTrait::TraitBase::Impl> { @@ -39,7 +40,8 @@ /// /// class DotOp : public Op::Impl> { /// -template class NOutputs { +template +class NOutputs { public: template class Impl : public OpTrait::TraitBase::Impl> { diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h --- a/mlir/include/mlir/Dialect/Linalg/Passes.h +++ b/mlir/include/mlir/Dialect/Linalg/Passes.h @@ -19,7 +19,8 @@ namespace mlir { class FuncOp; class ModuleOp; -template class OpPassBase; +template +class OpPassBase; std::unique_ptr> createLinalgFusionPass(); diff --git a/mlir/include/mlir/Dialect/Quant/Passes.h b/mlir/include/mlir/Dialect/Quant/Passes.h --- a/mlir/include/mlir/Dialect/Quant/Passes.h +++ b/mlir/include/mlir/Dialect/Quant/Passes.h @@ -20,7 +20,8 @@ namespace mlir { class FuncOp; -template class OpPassBase; +template +class OpPassBase; namespace quant { diff --git a/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h b/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h --- a/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h +++ b/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h @@ -113,13 +113,18 @@ void dump() const; /// LLVM-style casts. - template bool isa() const { return U::isClassFor(*this); } - template U dyn_cast() const { + template + bool isa() const { + return U::isClassFor(*this); + } + template + U dyn_cast() const { if (!isa()) return {}; return U(const_cast(this)->impl); } - template U cast() const { + template + U cast() const { assert(isa() && "cast to incorrect subtype"); return U(const_cast(this)->impl); } @@ -354,7 +359,8 @@ /// A visitor class for SDBM expressions. Calls the kind-specific function /// depending on the kind of expression it visits. -template class SDBMVisitor { +template +class SDBMVisitor { public: /// Visit the given SDBM expression, dispatching to kind-specific functions. Result visit(SDBMExpr expr) { @@ -439,7 +445,8 @@ llvm_unreachable("unhandled subtype of varying SDBM expression"); } - template void walk(SDBMExpr expr) { + template + void walk(SDBMExpr expr) { if (isPreorder) visit(expr); if (auto sumExpr = expr.dyn_cast()) { @@ -497,7 +504,8 @@ namespace llvm { // SDBMExpr hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::SDBMExpr getEmptyKey() { auto *pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::SDBMExpr(static_cast(pointer)); @@ -515,7 +523,8 @@ }; // SDBMDirectExpr hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::SDBMDirectExpr getEmptyKey() { auto *pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::SDBMDirectExpr( @@ -535,7 +544,8 @@ }; // SDBMTermExpr hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::SDBMTermExpr getEmptyKey() { auto *pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::SDBMTermExpr(static_cast(pointer)); @@ -553,7 +563,8 @@ }; // SDBMConstantExpr hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::SDBMConstantExpr getEmptyKey() { auto *pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::SDBMConstantExpr( diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h --- a/mlir/include/mlir/EDSC/Builders.h +++ b/mlir/include/mlir/EDSC/Builders.h @@ -532,7 +532,7 @@ } /// Emits a `load` when converting to a Value. - Value operator*(void)const { + Value operator*(void) const { return Load(getBase(), {indices.begin(), indices.end()}).getValue(); } diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -23,7 +23,8 @@ #include namespace llvm { -template class Expected; +template +class Expected; class Module; class ExecutionEngine; class JITEventListener; diff --git a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h --- a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h +++ b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h @@ -67,11 +67,13 @@ template std::ostream &operator<<(std::ostream &os, const Vector &v); -template struct StaticSizeMult { +template +struct StaticSizeMult { static constexpr int value = 1; }; -template struct StaticSizeMult { +template +struct StaticSizeMult { static constexpr int value = N * StaticSizeMult::value; }; @@ -81,7 +83,8 @@ } } -template struct VectorDataPrinter { +template +struct VectorDataPrinter { static void print(std::ostream &os, const Vector &val); }; @@ -118,7 +121,8 @@ return os; } -template struct MemRefDataPrinter { +template +struct MemRefDataPrinter { static void print(std::ostream &os, T *base, int64_t rank, int64_t offset, int64_t *sizes, int64_t *strides); static void printFirst(std::ostream &os, T *base, int64_t rank, @@ -127,7 +131,8 @@ int64_t *sizes, int64_t *strides); }; -template struct MemRefDataPrinter { +template +struct MemRefDataPrinter { static void print(std::ostream &os, T *base, int64_t rank, int64_t offset, int64_t *sizes = nullptr, int64_t *strides = nullptr); }; @@ -185,7 +190,8 @@ os << base[offset]; } -template void printMemRef(StridedMemRefType &M) { +template +void printMemRef(StridedMemRefType &M) { static_assert(N > 0, "Expected N > 0"); printMemRefMetaData(std::cout, M); std::cout << " data = " << std::endl; @@ -194,7 +200,8 @@ std::cout << std::endl; } -template void printMemRef(StridedMemRefType &M) { +template +void printMemRef(StridedMemRefType &M) { printMemRefMetaData(std::cout, M); std::cout << " data = " << std::endl; std::cout << "["; diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h --- a/mlir/include/mlir/IR/AffineExpr.h +++ b/mlir/include/mlir/IR/AffineExpr.h @@ -79,10 +79,14 @@ bool operator!() const { return expr == nullptr; } - template bool isa() const; - template U dyn_cast() const; - template U dyn_cast_or_null() const; - template U cast() const; + template + bool isa() const; + template + U dyn_cast() const; + template + U dyn_cast_or_null() const; + template + U cast() const; MLIRContext *getContext() const; @@ -221,7 +225,8 @@ raw_ostream &operator<<(raw_ostream &os, AffineExpr &expr); -template bool AffineExpr::isa() const { +template +bool AffineExpr::isa() const { if (std::is_same::value) return getKind() <= AffineExprKind::LAST_AFFINE_BINARY_OP; if (std::is_same::value) @@ -231,15 +236,18 @@ if (std::is_same::value) return getKind() == AffineExprKind::Constant; } -template U AffineExpr::dyn_cast() const { +template +U AffineExpr::dyn_cast() const { if (isa()) return U(expr); return U(nullptr); } -template U AffineExpr::dyn_cast_or_null() const { +template +U AffineExpr::dyn_cast_or_null() const { return (!*this || !isa()) ? U(nullptr) : U(expr); } -template U AffineExpr::cast() const { +template +U AffineExpr::cast() const { assert(isa()); return U(expr); } @@ -252,7 +260,8 @@ unsigned numSymbols); namespace detail { -template void bindDims(MLIRContext *ctx) {} +template +void bindDims(MLIRContext *ctx) {} template void bindDims(MLIRContext *ctx, AffineExprTy &e, AffineExprTy2 &... exprs) { @@ -273,7 +282,8 @@ namespace llvm { // AffineExpr hash just like pointers -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::AffineExpr getEmptyKey() { auto pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::AffineExpr(static_cast(pointer)); diff --git a/mlir/include/mlir/IR/AffineExprVisitor.h b/mlir/include/mlir/IR/AffineExprVisitor.h --- a/mlir/include/mlir/IR/AffineExprVisitor.h +++ b/mlir/include/mlir/IR/AffineExprVisitor.h @@ -64,7 +64,8 @@ /// just as efficient as having your own switch instruction over the instruction /// opcode. -template class AffineExprVisitor { +template +class AffineExprVisitor { //===--------------------------------------------------------------------===// // Interface code - This is the public interface of the AffineExprVisitor // that you use to visit affine expressions... diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h --- a/mlir/include/mlir/IR/AffineMap.h +++ b/mlir/include/mlir/IR/AffineMap.h @@ -280,7 +280,8 @@ namespace llvm { // AffineExpr hash just like pointers -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::AffineMap getEmptyKey() { auto pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::AffineMap(static_cast(pointer)); diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -83,10 +83,14 @@ bool operator!() const { return impl == nullptr; } - template bool isa() const; - template U dyn_cast() const; - template U dyn_cast_or_null() const; - template U cast() const; + template + bool isa() const; + template + U dyn_cast() const; + template + U dyn_cast_or_null() const; + template + U cast() const; // Support dyn_cast'ing Attribute to itself. static bool classof(Attribute) { return true; } @@ -563,8 +567,10 @@ //===----------------------------------------------------------------------===// namespace detail { -template class ElementsAttrIterator; -template class ElementsAttrRange; +template +class ElementsAttrIterator; +template +class ElementsAttrRange; } // namespace detail /// A base attribute that represents a reference to a static shaped tensor or @@ -572,8 +578,10 @@ class ElementsAttr : public Attribute { public: using Attribute::Attribute; - template using iterator = detail::ElementsAttrIterator; - template using iterator_range = detail::ElementsAttrRange; + template + using iterator = detail::ElementsAttrIterator; + template + using iterator_range = detail::ElementsAttrRange; /// Return the type of this ElementsAttr, guaranteed to be a vector or tensor /// with static shape. @@ -585,14 +593,16 @@ /// Return the value of type 'T' at the given index, where 'T' corresponds to /// an Attribute type. - template T getValue(ArrayRef index) const { + template + T getValue(ArrayRef index) const { return getValue(index).template cast(); } /// Return the elements of this attribute as a value of type 'T'. Note: /// Aborts if the subclass is OpaqueElementsAttrs, these attrs do not support /// iteration. - template iterator_range getValues() const; + template + iterator_range getValues() const; /// Return if the given 'index' refers to a valid element in this attribute. bool isValidIndex(ArrayRef index) const; @@ -860,7 +870,8 @@ Attribute getValue(ArrayRef index) const { return getValue(index); } - template T getValue(ArrayRef index) const { + template + T getValue(ArrayRef index) const { // Skip to the element corresponding to the flattened index. return *std::next(getValues().begin(), getFlattenedIndex(index)); } @@ -1142,7 +1153,8 @@ /// Return the values of this attribute in the form of the given type 'T'. 'T' /// may be any of Attribute, APInt, APFloat, c++ integer/float types, etc. - template llvm::iterator_range> getValues() const { + template + llvm::iterator_range> getValues() const { auto zeroValue = getZeroValue(); auto valueIt = getValues().getValues().begin(); const std::vector flatSparseIndices(getFlattenedSparseIndices()); @@ -1273,22 +1285,28 @@ } /// Utility functors used to generically implement the iterators methods. - template struct PlusAssign { + template + struct PlusAssign { void operator()(ItT &it, ptrdiff_t offset) { it += offset; } }; - template struct Minus { + template + struct Minus { ptrdiff_t operator()(const ItT &lhs, const ItT &rhs) { return lhs - rhs; } }; - template struct MinusAssign { + template + struct MinusAssign { void operator()(ItT &it, ptrdiff_t offset) { it -= offset; } }; - template struct Dereference { + template + struct Dereference { T operator()(ItT &it) { return *it; } }; - template struct ConstructIter { + template + struct ConstructIter { void operator()(ItT &dest, const ItT &it) { ::new (&dest) ItT(it); } }; - template struct DestructIter { + template + struct DestructIter { void operator()(ItT &it) { it.~ItT(); } }; @@ -1364,17 +1382,21 @@ // Attributes Utils //===----------------------------------------------------------------------===// -template bool Attribute::isa() const { +template +bool Attribute::isa() const { assert(impl && "isa<> used on a null attribute."); return U::classof(*this); } -template U Attribute::dyn_cast() const { +template +U Attribute::dyn_cast() const { return isa() ? U(impl) : U(nullptr); } -template U Attribute::dyn_cast_or_null() const { +template +U Attribute::dyn_cast_or_null() const { return (impl && isa()) ? U(impl) : U(nullptr); } -template U Attribute::cast() const { +template +U Attribute::cast() const { assert(isa()); return U(impl); } @@ -1441,7 +1463,8 @@ namespace llvm { // Attribute hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::Attribute getEmptyKey() { auto pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::Attribute(static_cast(pointer)); @@ -1459,7 +1482,8 @@ }; /// Allow LLVM to steal the low bits of Attributes. -template <> struct PointerLikeTypeTraits { +template <> +struct PointerLikeTypeTraits { static inline void *getAsVoidPointer(mlir::Attribute attr) { return const_cast(attr.getAsOpaquePointer()); } diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -18,7 +18,8 @@ namespace mlir { class TypeRange; -template class ValueTypeRange; +template +class ValueTypeRange; /// `Block` represents an ordered list of `Operation`s. class Block : public IRObjectWithUseList, @@ -194,15 +195,18 @@ /// Return an iterator range over the operations within this block that are of /// 'OpT'. - template iterator_range> getOps() { + template + iterator_range> getOps() { auto endIt = end(); return {op_filter_iterator(begin(), endIt), op_filter_iterator(endIt, endIt)}; } - template op_iterator op_begin() { + template + op_iterator op_begin() { return op_filter_iterator(begin(), end()); } - template op_iterator op_end() { + template + op_iterator op_end() { return op_filter_iterator(end(), end()); } diff --git a/mlir/include/mlir/IR/BlockAndValueMapping.h b/mlir/include/mlir/IR/BlockAndValueMapping.h --- a/mlir/include/mlir/IR/BlockAndValueMapping.h +++ b/mlir/include/mlir/IR/BlockAndValueMapping.h @@ -67,7 +67,8 @@ /// Lookup a mapped value within the map. This asserts the provided value /// exists within the map. - template T lookup(T from) const { + template + T lookup(T from) const { auto result = lookupOrNull(from); assert(result && "expected 'from' to be contained within the map"); return result; diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h --- a/mlir/include/mlir/IR/BlockSupport.h +++ b/mlir/include/mlir/IR/BlockSupport.h @@ -105,7 +105,8 @@ }; } // end namespace ilist_detail -template <> struct ilist_traits<::mlir::Operation> { +template <> +struct ilist_traits<::mlir::Operation> { using Operation = ::mlir::Operation; using op_iterator = simple_ilist::iterator; diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -76,7 +76,8 @@ NoneType getNoneType(); /// Get or construct an instance of the type 'ty' with provided arguments. - template Ty getType(Args... args) { + template + Ty getType(Args... args) { return Ty::get(context, args...); } @@ -380,7 +381,8 @@ Operation *cloneWithoutRegions(Operation &op) { return insert(op.cloneWithoutRegions()); } - template OpT cloneWithoutRegions(OpT op) { + template + OpT cloneWithoutRegions(OpT op) { return cast(cloneWithoutRegions(*op.getOperation())); } diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h --- a/mlir/include/mlir/IR/Diagnostics.h +++ b/mlir/include/mlir/IR/Diagnostics.h @@ -230,10 +230,12 @@ Diagnostic &operator<<(OperationName val); /// Stream in a range. - template Diagnostic &operator<<(iterator_range range) { + template + Diagnostic &operator<<(iterator_range range) { return appendRange(range); } - template Diagnostic &operator<<(ArrayRef range) { + template + Diagnostic &operator<<(ArrayRef range) { return appendRange(range); } @@ -254,7 +256,8 @@ return append(std::forward(arg2), std::forward(args)...); } /// Append one argument to the diagnostic. - template Diagnostic &append(Arg &&arg) { + template + Diagnostic &append(Arg &&arg) { *this << std::forward(arg); return *this; } @@ -332,21 +335,25 @@ } /// Stream operator for new diagnostic arguments. - template InFlightDiagnostic &operator<<(Arg &&arg) & { + template + InFlightDiagnostic &operator<<(Arg &&arg) & { return append(std::forward(arg)); } - template InFlightDiagnostic &&operator<<(Arg &&arg) && { + template + InFlightDiagnostic &&operator<<(Arg &&arg) && { return std::move(append(std::forward(arg))); } /// Append arguments to the diagnostic. - template InFlightDiagnostic &append(Args &&... args) & { + template + InFlightDiagnostic &append(Args &&... args) & { assert(isActive() && "diagnostic not active"); if (isInFlight()) impl->append(std::forward(args)...); return *this; } - template InFlightDiagnostic &&append(Args &&... args) && { + template + InFlightDiagnostic &&append(Args &&... args) && { return std::move(append(std::forward(args)...)); } @@ -515,7 +522,8 @@ protected: /// Set the handler to manage via RAII. - template void setHandler(FuncTy &&handler) { + template + void setHandler(FuncTy &&handler) { auto &diagEngine = ctx->getDiagEngine(); if (handlerID) diagEngine.eraseHandler(handlerID); diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h --- a/mlir/include/mlir/IR/Dialect.h +++ b/mlir/include/mlir/IR/Dialect.h @@ -164,7 +164,8 @@ auto it = registeredInterfaces.find(interfaceID); return it != registeredInterfaces.end() ? it->getSecond().get() : nullptr; } - template const InterfaceT *getRegisteredInterface() { + template + const InterfaceT *getRegisteredInterface() { return static_cast( getRegisteredInterface(InterfaceT::getInterfaceID())); } @@ -181,7 +182,8 @@ /// This method is used by derived classes to add their operations to the set. /// - template void addOperations() { + template + void addOperations() { (void)std::initializer_list{ 0, (addOperation(AbstractOperation::get(*this)), 0)...}; } @@ -189,12 +191,14 @@ void addOperation(AbstractOperation opInfo); /// This method is used by derived classes to add their types to the set. - template void addTypes() { + template + void addTypes() { (void)std::initializer_list{0, (addSymbol(Args::getClassID()), 0)...}; } /// This method is used by derived classes to add their attributes to the set. - template void addAttributes() { + template + void addAttributes() { (void)std::initializer_list{0, (addSymbol(Args::getClassID()), 0)...}; } @@ -208,7 +212,8 @@ void addInterface(std::unique_ptr interface); /// Register a set of dialect interfaces with this dialect instance. - template void addInterfaces() { + template + void addInterfaces() { (void)std::initializer_list{ 0, (addInterface(std::make_unique(this)), 0)...}; } @@ -259,7 +264,8 @@ /// Utility to register a dialect. Client can register their dialect with the /// global registry by calling registerDialect(); -template void registerDialect() { +template +void registerDialect() { Dialect::registerDialectAllocator(ClassID::getID(), [](MLIRContext *ctx) { // Just allocate the dialect, the context @@ -275,7 +281,8 @@ /// /// // At namespace scope. /// static DialectRegistration Unused; -template struct DialectRegistration { +template +struct DialectRegistration { DialectRegistration() { registerDialect(); } }; diff --git a/mlir/include/mlir/IR/DialectHooks.h b/mlir/include/mlir/IR/DialectHooks.h --- a/mlir/include/mlir/IR/DialectHooks.h +++ b/mlir/include/mlir/IR/DialectHooks.h @@ -79,7 +79,8 @@ /// /// // At namespace scope. /// static DialectHooksRegistration Unused("dialect_namespace"); -template struct DialectHooksRegistration { +template +struct DialectHooksRegistration { DialectHooksRegistration(StringRef dialectName) { registerDialectHooks(dialectName); } diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h --- a/mlir/include/mlir/IR/DialectImplementation.h +++ b/mlir/include/mlir/IR/DialectImplementation.h @@ -135,7 +135,8 @@ virtual ParseResult parseFloat(double &result) = 0; /// Parse an integer value from the stream. - template ParseResult parseInteger(IntT &result) { + template + ParseResult parseInteger(IntT &result) { auto loc = getCurrentLocation(); OptionalParseResult parseResult = parseOptionalInteger(result); if (!parseResult.hasValue()) @@ -305,7 +306,8 @@ virtual ParseResult parseType(Type &result) = 0; /// Parse a type of a specific kind, e.g. a FunctionType. - template ParseResult parseType(TypeType &result) { + template + ParseResult parseType(TypeType &result) { llvm::SMLoc loc = getCurrentLocation(); // Parse any kind of type. diff --git a/mlir/include/mlir/IR/DialectInterface.h b/mlir/include/mlir/IR/DialectInterface.h --- a/mlir/include/mlir/IR/DialectInterface.h +++ b/mlir/include/mlir/IR/DialectInterface.h @@ -127,10 +127,12 @@ }; /// Iterator access to the held interfaces. - template iterator interface_begin() const { + template + iterator interface_begin() const { return iterator(orderedInterfaces.begin()); } - template iterator interface_end() const { + template + iterator interface_end() const { return iterator(orderedInterfaces.end()); } diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -116,7 +116,8 @@ namespace llvm { // Functions hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::FuncOp getEmptyKey() { auto pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::FuncOp::getFromOpaquePointer(pointer); @@ -132,7 +133,8 @@ }; /// Allow stealing the low bits of FuncOp. -template <> struct PointerLikeTypeTraits { +template <> +struct PointerLikeTypeTraits { public: static inline void *getAsVoidPointer(mlir::FuncOp I) { return const_cast(I.getAsOpaquePointer()); diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h --- a/mlir/include/mlir/IR/IntegerSet.h +++ b/mlir/include/mlir/IR/IntegerSet.h @@ -119,7 +119,8 @@ namespace llvm { // IntegerSet hash just like pointers -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::IntegerSet getEmptyKey() { auto pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::IntegerSet(static_cast(pointer)); diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h --- a/mlir/include/mlir/IR/Location.h +++ b/mlir/include/mlir/IR/Location.h @@ -67,9 +67,18 @@ LocationAttr *operator->() const { return const_cast(&impl); } /// Type casting utilities on the underlying location. - template bool isa() const { return impl.isa(); } - template U dyn_cast() const { return impl.dyn_cast(); } - template U cast() const { return impl.cast(); } + template + bool isa() const { + return impl.isa(); + } + template + U dyn_cast() const { + return impl.dyn_cast(); + } + template + U cast() const { + return impl.cast(); + } /// Comparison operators. bool operator==(Location rhs) const { return impl == rhs.impl; } @@ -249,7 +258,8 @@ } /// Returns a pointer to some data structure that opaque location stores. - template static T getUnderlyingLocation(Location location) { + template + static T getUnderlyingLocation(Location location) { assert(isa(location)); return reinterpret_cast( location.cast().getUnderlyingLocation()); @@ -268,7 +278,8 @@ /// Checks whether provided location is opaque location and contains a pointer /// to an object of particular type. - template static bool isa(Location location) { + template + static bool isa(Location location) { auto opaque_loc = location.dyn_cast(); return opaque_loc && opaque_loc.getClassId() == ClassID::getID(); } @@ -302,7 +313,8 @@ namespace llvm { // Type hash just like pointers. -template <> struct DenseMapInfo { +template <> +struct DenseMapInfo { static mlir::Location getEmptyKey() { auto pointer = llvm::DenseMapInfo::getEmptyKey(); return mlir::Location::getFromOpaquePointer(pointer); @@ -320,7 +332,8 @@ }; /// We align LocationStorage by 8, so allow LLVM to steal the low bits. -template <> struct PointerLikeTypeTraits { +template <> +struct PointerLikeTypeTraits { public: static inline void *getAsVoidPointer(mlir::Location I) { return const_cast(I.getAsOpaquePointer()); diff --git a/mlir/include/mlir/IR/MLIRContext.h b/mlir/include/mlir/IR/MLIRContext.h --- a/mlir/include/mlir/IR/MLIRContext.h +++ b/mlir/include/mlir/IR/MLIRContext.h @@ -45,7 +45,8 @@ /// Get a registered IR dialect for the given derived dialect type. The /// derived type must provide a static 'getDialectNamespace' method. - template T *getRegisteredDialect() { + template + T *getRegisteredDialect() { return static_cast(getRegisteredDialect(T::getDialectNamespace())); } diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h --- a/mlir/include/mlir/IR/Matchers.h +++ b/mlir/include/mlir/IR/Matchers.h @@ -55,7 +55,8 @@ /// The matcher that matches operations that have the `ConstantLike` trait, and /// binds the folded attribute value. -template struct constant_op_binder { +template +struct constant_op_binder { AttrT *bind_value; /// Creates a matcher instance that binds the constant attribute value to @@ -111,7 +112,8 @@ /// The matcher that matches a given target constant scalar / vector splat / /// tensor splat integer value. -template struct constant_int_value_matcher { +template +struct constant_int_value_matcher { bool match(Operation *op) { APInt value; return constant_int_op_binder(&value).match(op) && TargetValue == value; @@ -120,7 +122,8 @@ /// The matcher that matches anything except the given target constant scalar / /// vector splat / tensor splat integer value. -template struct constant_int_not_value_matcher { +template +struct constant_int_not_value_matcher { bool match(Operation *op) { APInt value; return constant_int_op_binder(&value).match(op) && TargetNotValue != value; @@ -128,7 +131,8 @@ }; /// The matcher that matches a certain kind of op. -template struct op_matcher { +template +struct op_matcher { bool match(Operation *op) { return isa(op); } }; @@ -222,7 +226,8 @@ } /// Matches the given OpClass. -template inline detail::op_matcher m_Op() { +template +inline detail::op_matcher m_Op() { return detail::op_matcher(); } diff --git a/mlir/include/mlir/IR/Module.h b/mlir/include/mlir/IR/Module.h --- a/mlir/include/mlir/IR/Module.h +++ b/mlir/include/mlir/IR/Module.h @@ -75,7 +75,8 @@ /// This returns a range of operations of the given type 'T' held within the /// module. - template iterator_range> getOps() { + template + iterator_range> getOps() { return getBody()->getOps(); } @@ -154,7 +155,8 @@ namespace llvm { /// Allow stealing the low bits of ModuleOp. -template <> struct PointerLikeTypeTraits { +template <> +struct PointerLikeTypeTraits { public: static inline void *getAsVoidPointer(mlir::ModuleOp I) { return const_cast(I.getAsOpaquePointer()); diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -27,7 +27,8 @@ class Builder; namespace OpTrait { -template class OneResult; +template +class OneResult; } /// This class represents success/failure for operation parsing. It is @@ -112,7 +113,8 @@ Operation *getParentOp() { return getOperation()->getParentOp(); } /// Return the closest surrounding parent operation that is of type 'OpTy'. - template OpTy getParentOfType() { + template + OpTy getParentOfType() { return getOperation()->getParentOfType(); } @@ -153,7 +155,8 @@ Attribute getAttr(StringRef name) { return state->getAttr(name); } /// If the operation has an attribute of the specified type, return it. - template AttrClass getAttrOfType(StringRef name) { + template + AttrClass getAttrOfType(StringRef name) { return getAttr(name).dyn_cast_or_null(); } @@ -173,7 +176,8 @@ void setAttrs(NamedAttributeList newAttrs) { state->setAttrs(newAttrs); } /// Set the dialect attributes for this operation, and preserve all dependent. - template void setDialectAttrs(DialectAttrs &&attrs) { + template + void setDialectAttrs(DialectAttrs &&attrs) { state->setDialectAttrs(std::move(attrs)); } @@ -492,7 +496,8 @@ /// /// class FooOp : public Op::Impl> { /// -template class NOperands { +template +class NOperands { public: static_assert(N > 1, "use ZeroOperands/OneOperand for N < 2"); @@ -511,7 +516,8 @@ /// /// class FooOp : public Op::Impl> { /// -template class AtLeastNOperands { +template +class AtLeastNOperands { public: template class Impl : public detail::MultiOperandTraitBase void replaceAllUsesWith(ValuesT &&values) { + template + void replaceAllUsesWith(ValuesT &&values) { this->getOperation()->replaceAllUsesWith(std::forward(values)); } @@ -617,7 +624,8 @@ /// /// class FooOp : public Op::Impl> { /// -template class NResults { +template +class NResults { public: static_assert(N > 1, "use ZeroResult/OneResult for N < 2"); @@ -636,7 +644,8 @@ /// /// class FooOp : public Op::Impl> { /// -template class AtLeastNResults { +template +class AtLeastNResults { public: template class Impl : public detail::MultiResultTraitBase struct SingleBlockImplicitTerminator { +template +struct SingleBlockImplicitTerminator { template class Impl : public TraitBase { public: @@ -988,7 +998,8 @@ }; /// This class provides a verifier for ops that are expecting a specific parent. -template struct HasParent { +template +struct HasParent { template class Impl : public TraitBase { public: @@ -1145,7 +1156,8 @@ } private: - template struct BaseVerifier; + template + struct BaseVerifier; template struct BaseVerifier { @@ -1155,11 +1167,13 @@ } }; - template struct BaseVerifier { + template + struct BaseVerifier { static LogicalResult verifyTrait(Operation *op) { return success(); } }; - template struct BaseProperties; + template + struct BaseProperties; template struct BaseProperties { @@ -1169,7 +1183,8 @@ } }; - template struct BaseProperties { + template + struct BaseProperties { static AbstractOperation::OperationProperties getTraitProperties() { return 0; } @@ -1243,7 +1258,8 @@ class OpInterface : public Op { public: using Concept = typename Traits::Concept; - template using Model = typename Traits::template Model; + template + using Model = typename Traits::template Model; OpInterface(Operation *op = nullptr) : Op(op), impl(op ? getInterfaceFor(op) : nullptr) { diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -118,7 +118,8 @@ Operation *getParentOp(); /// Return the closest surrounding parent operation that is of type 'OpTy'. - template OpTy getParentOfType() { + template + OpTy getParentOfType() { auto *op = this; while ((op = op->getParentOp())) if (auto parentOp = dyn_cast(op)) @@ -288,11 +289,13 @@ Attribute getAttr(Identifier name) { return attrs.get(name); } Attribute getAttr(StringRef name) { return attrs.get(name); } - template AttrClass getAttrOfType(Identifier name) { + template + AttrClass getAttrOfType(Identifier name) { return getAttr(name).dyn_cast_or_null(); } - template AttrClass getAttrOfType(StringRef name) { + template + AttrClass getAttrOfType(StringRef name) { return getAttr(name).dyn_cast_or_null(); } @@ -450,7 +453,8 @@ /// Returns if the operation was registered with a particular trait, e.g. /// hasTrait(). - template