Namespaceify a few explicit template specializations to appease errors caused...
authorRiver Riddle <riverriddle@google.com>
Sat, 4 May 2019 19:13:41 +0000 (12:13 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 6 May 2019 15:29:09 +0000 (08:29 -0700)
    (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480)

--

PiperOrigin-RevId: 246664463

mlir/examples/Linalg/Linalg3/lib/Transforms.cpp
mlir/lib/IR/Operation.cpp
mlir/lib/Transforms/LowerVectorTransfers.cpp

index d9a56c6..42999ae 100644 (file)
@@ -222,6 +222,29 @@ void linalg::lowerToLoops(mlir::Function *f) {
   });
 }
 
+/// Emits and returns the standard load and store ops from the view indexings.
+/// If the indexing is of index type, use it as an index to the load/store.
+/// If the indexing is a range, use range.min + indexing as an index to the
+/// load/store.
+template <typename LoadOrStoreOp>
+static SmallVector<Value *, 8>
+emitAndReturnLoadStoreOperands(LoadOrStoreOp loadOrStoreOp, ViewOp viewOp) {
+  unsigned storeDim = 0;
+  SmallVector<Value *, 8> operands;
+  for (auto *indexing : viewOp.getIndexings()) {
+    if (indexing->getType().isa<IndexType>()) {
+      operands.push_back(indexing);
+      continue;
+    }
+    RangeOp range = indexing->getDefiningOp()->cast<RangeOp>();
+    ValueHandle min(range.getMin());
+    Value *storeIndex = *(loadOrStoreOp.getIndices().begin() + storeDim++);
+    using edsc::op::operator+;
+    operands.push_back(min + ValueHandle(storeIndex));
+  }
+  return operands;
+}
+
 namespace {
 
 /// Rewriting linalg::LoadOp and linalg::StoreOp to mlir::LoadOp and
@@ -247,30 +270,6 @@ struct LowerLinalgLoadStorePass
     applyPatternsGreedily(getFunction(), std::move(patterns));
   }
 };
-} // namespace
-
-/// Emits and returns the standard load and store ops from the view indexings.
-/// If the indexing is of index type, use it as an index to the load/store.
-/// If the indexing is a range, use range.min + indexing as an index to the
-/// load/store.
-template <typename LoadOrStoreOp>
-static SmallVector<Value *, 8>
-emitAndReturnLoadStoreOperands(LoadOrStoreOp loadOrStoreOp, ViewOp viewOp) {
-  unsigned storeDim = 0;
-  SmallVector<Value *, 8> operands;
-  for (auto *indexing : viewOp.getIndexings()) {
-    if (indexing->getType().isa<IndexType>()) {
-      operands.push_back(indexing);
-      continue;
-    }
-    RangeOp range = indexing->getDefiningOp()->cast<RangeOp>();
-    ValueHandle min(range.getMin());
-    Value *storeIndex = *(loadOrStoreOp.getIndices().begin() + storeDim++);
-    using edsc::op::operator+;
-    operands.push_back(min + ValueHandle(storeIndex));
-  }
-  return operands;
-}
 
 template <>
 PatternMatchResult
@@ -303,6 +302,7 @@ Rewriter<linalg::StoreOp>::matchAndRewrite(Operation *op,
                                              operands);
   return matchSuccess();
 }
+} // namespace
 
 FunctionPassBase *linalg::createLowerLinalgLoadStorePass() {
   return new LowerLinalgLoadStorePass();
index 067e86a..2c97988 100644 (file)
@@ -70,19 +70,25 @@ unsigned OpResult::getResultNumber() {
 // OpOperand
 //===----------------------------------------------------------------------===//
 
+// TODO: This namespace is only required because of a bug in GCC<7.0.
+namespace mlir {
 /// Return which operand this is in the operand list.
 template <> unsigned OpOperand::getOperandNumber() {
   return this - &getOwner()->getOpOperands()[0];
 }
+} // end namespace mlir
 
 //===----------------------------------------------------------------------===//
 // BlockOperand
 //===----------------------------------------------------------------------===//
 
+// TODO: This namespace is only required because of a bug in GCC<7.0.
+namespace mlir {
 /// Return which operand this is in the operand list.
 template <> unsigned BlockOperand::getOperandNumber() {
   return this - &getOwner()->getBlockOperands()[0];
 }
+} // end namespace mlir
 
 //===----------------------------------------------------------------------===//
 // Operation
index f0990e4..f7352d6 100644 (file)
@@ -120,7 +120,6 @@ struct VectorTransferRewriter : public RewritePattern {
   PatternMatchResult matchAndRewrite(Operation *op,
                                      PatternRewriter &rewriter) const override;
 };
-} // end anonymous namespace
 
 /// Analyzes the `transfer` to find an access dimension along the fastest remote
 /// MemRef dimension. If such a dimension with coalescing properties is found,
@@ -160,9 +159,9 @@ void coalesceCopy(VectorTransferOpTy transfer,
 /// Emits remote memory accesses that are clipped to the boundaries of the
 /// MemRef.
 template <typename VectorTransferOpTy>
-static llvm::SmallVector<edsc::ValueHandle, 8>
-clip(VectorTransferOpTy transfer, edsc::MemRefView &view,
-     ArrayRef<edsc::IndexHandle> ivs) {
+llvm::SmallVector<edsc::ValueHandle, 8> clip(VectorTransferOpTy transfer,
+                                             edsc::MemRefView &view,
+                                             ArrayRef<edsc::IndexHandle> ivs) {
   using namespace mlir::edsc;
   using namespace edsc::op;
   using edsc::intrinsics::select;
@@ -357,7 +356,6 @@ VectorTransferRewriter<VectorTransferWriteOp>::matchAndRewrite(
   return matchSuccess();
 }
 
-namespace {
 struct LowerVectorTransfersPass
     : public FunctionPass<LowerVectorTransfersPass> {
   void runOnFunction() {