Move SDBM infrastructure into a new SDBM dialect
authorAlex Zinenko <zinenko@google.com>
Tue, 21 May 2019 14:22:35 +0000 (07:22 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 2 Jun 2019 02:54:33 +0000 (19:54 -0700)
    We now have sufficient extensibility in dialects to move attribute components
    such as SDBM out of the core IR into a dedicated dialect and make them
    optional.  Introduce an SDBM dialect and move the code.  This is a mostly
    non-functional change.

--

PiperOrigin-RevId: 249244802

17 files changed:
mlir/include/mlir/SDBM/SDBM.h [moved from mlir/include/mlir/IR/SDBM.h with 100% similarity]
mlir/include/mlir/SDBM/SDBMDialect.h [new file with mode: 0644]
mlir/include/mlir/SDBM/SDBMExpr.h [moved from mlir/include/mlir/IR/SDBMExpr.h with 100% similarity]
mlir/lib/CMakeLists.txt
mlir/lib/SDBM/CMakeLists.txt [new file with mode: 0644]
mlir/lib/SDBM/SDBM.cpp [moved from mlir/lib/IR/SDBM.cpp with 99% similarity]
mlir/lib/SDBM/SDBMDialect.cpp [new file with mode: 0644]
mlir/lib/SDBM/SDBMExpr.cpp [moved from mlir/lib/IR/SDBMExpr.cpp with 99% similarity]
mlir/lib/SDBM/SDBMExprDetail.h [moved from mlir/lib/IR/SDBMExprDetail.h with 99% similarity]
mlir/test/CMakeLists.txt
mlir/test/SDBM/CMakeLists.txt [new file with mode: 0644]
mlir/test/SDBM/lit.local.cfg [new file with mode: 0644]
mlir/test/SDBM/sdbm-api-test.cpp [moved from mlir/test/IR/sdbm-api-test.cpp with 98% similarity]
mlir/unittests/CMakeLists.txt
mlir/unittests/IR/CMakeLists.txt
mlir/unittests/SDBM/CMakeLists.txt [new file with mode: 0644]
mlir/unittests/SDBM/SDBMTest.cpp [moved from mlir/unittests/IR/SDBMTest.cpp with 98% similarity]

diff --git a/mlir/include/mlir/SDBM/SDBMDialect.h b/mlir/include/mlir/SDBM/SDBMDialect.h
new file mode 100644 (file)
index 0000000..ba645b3
--- /dev/null
@@ -0,0 +1,34 @@
+//===- SDBMDialect.h - Dialect for striped DBMs -----------------*- C++ -*-===//
+//
+// Copyright 2019 The MLIR Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// =============================================================================
+
+#ifndef MLIR_SDBM_SDBMDIALECT_H
+#define MLIR_SDBM_SDBMDIALECT_H
+
+#include "mlir/IR/Dialect.h"
+
+namespace mlir {
+class MLIRContext;
+
+class SDBMDialect : public Dialect {
+public:
+  SDBMDialect(MLIRContext *context) : Dialect(getDialectNamespace(), context) {}
+
+  static StringRef getDialectNamespace() { return "sdbm"; }
+};
+} // namespace mlir
+
+#endif // MLIR_SDBM_SDBMDIALECT_H
index 995c886..4ffd472 100644 (file)
@@ -10,6 +10,7 @@ add_subdirectory(Linalg)
 add_subdirectory(Parser)
 add_subdirectory(Pass)
 add_subdirectory(Quantizer)
+add_subdirectory(SDBM)
 add_subdirectory(StandardOps)
 add_subdirectory(Support)
 add_subdirectory(TableGen)
diff --git a/mlir/lib/SDBM/CMakeLists.txt b/mlir/lib/SDBM/CMakeLists.txt
new file mode 100644 (file)
index 0000000..30b2f64
--- /dev/null
@@ -0,0 +1,10 @@
+add_llvm_library(MLIRSDBM
+  SDBM.cpp
+  SDBMExpr.cpp
+  SDBMDialect.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir/SDBM
+)
+add_dependencies(MLIRSDBM MLIRIR)
+target_link_libraries(MLIRSDBM MLIRIR)
similarity index 99%
rename from mlir/lib/IR/SDBM.cpp
rename to mlir/lib/SDBM/SDBM.cpp
index 3023349..080a132 100644 (file)
@@ -20,8 +20,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/IR/SDBM.h"
-#include "mlir/IR/SDBMExpr.h"
+#include "mlir/SDBM/SDBM.h"
+#include "mlir/SDBM/SDBMExpr.h"
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SetVector.h"
diff --git a/mlir/lib/SDBM/SDBMDialect.cpp b/mlir/lib/SDBM/SDBMDialect.cpp
new file mode 100644 (file)
index 0000000..e000209
--- /dev/null
@@ -0,0 +1,20 @@
+//===- SDBMDialect.cpp - Dialect for striped difference-bound matrices ----===//
+//
+// Copyright 2019 The MLIR Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// =============================================================================
+
+#include "mlir/SDBM/SDBMDialect.h"
+
+static mlir::DialectRegistration<mlir::SDBMDialect> SDBMDialect;
similarity index 99%
rename from mlir/lib/IR/SDBMExpr.cpp
rename to mlir/lib/SDBM/SDBMExpr.cpp
index a95e3fe..fc8662d 100644 (file)
@@ -21,7 +21,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/IR/SDBMExpr.h"
+#include "mlir/SDBM/SDBMExpr.h"
 #include "SDBMExprDetail.h"
 #include "mlir/IR/AffineExpr.h"
 #include "mlir/IR/AffineExprVisitor.h"
similarity index 99%
rename from mlir/lib/IR/SDBMExprDetail.h
rename to mlir/lib/SDBM/SDBMExprDetail.h
index b4e748f..0ce8ea3 100644 (file)
@@ -25,7 +25,7 @@
 #define MLIR_IR_SDBMEXPRDETAIL_H
 
 #include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/SDBMExpr.h"
+#include "mlir/SDBM/SDBMExpr.h"
 #include "mlir/Support/StorageUniquer.h"
 
 namespace mlir {
index 8abe540..03c486c 100644 (file)
@@ -1,5 +1,6 @@
-add_subdirectory(mlir-cpu-runner)
 add_subdirectory(EDSC)
+add_subdirectory(mlir-cpu-runner)
+add_subdirectory(SDBM)
 
 llvm_canonicalize_cmake_booleans(
   LLVM_BUILD_EXAMPLES
@@ -27,6 +28,7 @@ set(MLIR_TEST_DEPENDS
   MLIRUnitTests
   mlir-cpu-runner
   mlir-opt
+  mlir-sdbm-api-test
   mlir-tblgen
   mlir-translate
   sdot
diff --git a/mlir/test/SDBM/CMakeLists.txt b/mlir/test/SDBM/CMakeLists.txt
new file mode 100644 (file)
index 0000000..321a37d
--- /dev/null
@@ -0,0 +1,18 @@
+add_executable(mlir-sdbm-api-test
+  sdbm-api-test.cpp
+)
+
+llvm_update_compile_flags(mlir-sdbm-api-test)
+
+target_link_libraries(mlir-sdbm-api-test
+  MLIRIR
+  MLIRSDBM
+  LLVMCore
+  LLVMSupport
+)
+
+target_include_directories(mlir-sdbm-api-test PRIVATE ..)
+
+whole_archive_link(mlir-sdbm-api-test
+  MLIRSDBM
+)
diff --git a/mlir/test/SDBM/lit.local.cfg b/mlir/test/SDBM/lit.local.cfg
new file mode 100644 (file)
index 0000000..8126155
--- /dev/null
@@ -0,0 +1 @@
+config.suffixes.add('.cpp')
similarity index 98%
rename from mlir/test/IR/sdbm-api-test.cpp
rename to mlir/test/SDBM/sdbm-api-test.cpp
index 53ed1d3..08075fd 100644 (file)
 // limitations under the License.
 // =============================================================================
 
-// RUN: %p/sdbm-api-test | FileCheck %s
+// RUN: mlir-sdbm-api-test | FileCheck %s
 
 #include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/SDBM.h"
-#include "mlir/IR/SDBMExpr.h"
+#include "mlir/SDBM/SDBM.h"
+#include "mlir/SDBM/SDBMExpr.h"
 
 #include "llvm/Support/raw_ostream.h"
 
index c5568f8..e80cc91 100644 (file)
@@ -8,4 +8,5 @@ endfunction()
 add_subdirectory(Dialect)
 add_subdirectory(IR)
 add_subdirectory(Pass)
+add_subdirectory(SDBM)
 add_subdirectory(TableGen)
index 5337eb4..20e8722 100644 (file)
@@ -2,7 +2,6 @@ add_mlir_unittest(MLIRIRTests
   DialectTest.cpp
   OperationSupportTest.cpp
   OpDefinitionTest.cpp
-  SDBMTest.cpp
 )
 target_link_libraries(MLIRIRTests
   PRIVATE
diff --git a/mlir/unittests/SDBM/CMakeLists.txt b/mlir/unittests/SDBM/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d86f9dd
--- /dev/null
@@ -0,0 +1,7 @@
+add_mlir_unittest(MLIRSDBMTests
+  SDBMTest.cpp
+)
+target_link_libraries(MLIRSDBMTests
+  PRIVATE
+  MLIRSDBM
+)
similarity index 98%
rename from mlir/unittests/IR/SDBMTest.cpp
rename to mlir/unittests/SDBM/SDBMTest.cpp
index 2676513..22dd6c3 100644 (file)
 // limitations under the License.
 // =============================================================================
 
-#include "mlir/IR/SDBM.h"
+#include "mlir/SDBM/SDBM.h"
 #include "mlir/IR/AffineExpr.h"
 #include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/SDBMExpr.h"
+#include "mlir/SDBM/SDBMExpr.h"
 #include "gtest/gtest.h"
 
 #include "llvm/ADT/DenseSet.h"
@@ -151,7 +151,7 @@ TEST(SDBMExpr, Constant) {
 TEST(SDBMExpr, Dim) {
   // We can create dimension expressions and query them.
   auto expr = SDBMDimExpr::get(ctx(), 0);
-  EXPECT_EQ(expr.getPosition(), 0);
+  EXPECT_EQ(expr.getPosition(), 0u);
 
   // Two separately created dimensions with the same position are trivially
   // equal.
@@ -174,7 +174,7 @@ TEST(SDBMExpr, Dim) {
 TEST(SDBMExpr, Symbol) {
   // We can create symbol expressions and query them.
   auto expr = SDBMSymbolExpr::get(ctx(), 0);
-  EXPECT_EQ(expr.getPosition(), 0);
+  EXPECT_EQ(expr.getPosition(), 0u);
 
   // Two separately created symbols with the same position are trivially equal.
   auto expr2 = SDBMSymbolExpr::get(ctx(), 0);