[flang-commits] [flang] b5a11a9 - [fir] Split FIROptimizer lib into several smaller libraries

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Tue Oct 5 05:02:57 PDT 2021


Author: Valentin Clement
Date: 2021-10-05T14:02:32+02:00
New Revision: b5a11a991e17982bb9915d295797410186aa9894

URL: https://github.com/llvm/llvm-project/commit/b5a11a991e17982bb9915d295797410186aa9894
DIFF: https://github.com/llvm/llvm-project/commit/b5a11a991e17982bb9915d295797410186aa9894.diff

LOG: [fir] Split FIROptimizer lib into several smaller libraries

Partition libFIROptimizer into smaller libraries that reflect the
structure. Adapt potential problems.

This patch is part of the upstreaming effort from fir-dev branch. It's a
building stone to upstreaming transformations.

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D111055

Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>

Added: 
    flang/lib/Optimizer/CodeGen/CMakeLists.txt
    flang/lib/Optimizer/Dialect/CMakeLists.txt
    flang/lib/Optimizer/Support/CMakeLists.txt
    flang/lib/Optimizer/Transforms/CMakeLists.txt
    flang/unittests/Optimizer/RTBuilder.cpp

Modified: 
    flang/lib/Lower/CMakeLists.txt
    flang/lib/Optimizer/CMakeLists.txt
    flang/tools/fir-opt/CMakeLists.txt
    flang/tools/tco/CMakeLists.txt
    flang/unittests/CMakeLists.txt
    flang/unittests/Optimizer/CMakeLists.txt

Removed: 
    flang/unittests/Lower/CMakeLists.txt
    flang/unittests/Lower/RTBuilder.cpp


################################################################################
diff  --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt
index 07b87ef22ce92..27e54d44893bc 100644
--- a/flang/lib/Lower/CMakeLists.txt
+++ b/flang/lib/Lower/CMakeLists.txt
@@ -17,11 +17,15 @@ add_flang_library(FortranLower
   PFTBuilder.cpp
 
   DEPENDS
-  FIROptimizer
+  FIRDialect
+  FIRSupport
+  FIRTransforms
   ${dialect_libs}
 
   LINK_LIBS
-  FIROptimizer
+  FIRDialect
+  FIRSupport
+  FIRTransforms
   ${dialect_libs}
   FortranCommon
   FortranParser

diff  --git a/flang/lib/Optimizer/CMakeLists.txt b/flang/lib/Optimizer/CMakeLists.txt
index b83d6a079db63..4b37a18340cfa 100644
--- a/flang/lib/Optimizer/CMakeLists.txt
+++ b/flang/lib/Optimizer/CMakeLists.txt
@@ -1,34 +1,4 @@
-get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
-
-add_flang_library(FIROptimizer
-  Dialect/FIRAttr.cpp
-  Dialect/FIRDialect.cpp
-  Dialect/FIROps.cpp
-  Dialect/FIRType.cpp
-
-  Support/FIRContext.cpp
-  Support/InternalNames.cpp
-  Support/KindMapping.cpp
-
-  CodeGen/CGOps.cpp
-  CodeGen/PreCGRewrite.cpp
-
-  Transforms/Inliner.cpp
-
-  DEPENDS
-  FIROpsIncGen
-  FIROptCodeGenPassIncGen
-  FIROptTransformsPassIncGen
-  CGOpsIncGen
-  ${dialect_libs}
-
-  LINK_LIBS
-  ${dialect_libs}
-  MLIRLLVMToLLVMIRTranslation
-  MLIRTargetLLVMIRExport
-
-  LINK_COMPONENTS
-  AsmParser
-  AsmPrinter
-  Remarks
-)
+add_subdirectory(CodeGen)
+add_subdirectory(Dialect)
+add_subdirectory(Support)
+add_subdirectory(Transforms)

diff  --git a/flang/lib/Optimizer/CodeGen/CMakeLists.txt b/flang/lib/Optimizer/CodeGen/CMakeLists.txt
new file mode 100644
index 0000000000000..6a8d82cb1f671
--- /dev/null
+++ b/flang/lib/Optimizer/CodeGen/CMakeLists.txt
@@ -0,0 +1,22 @@
+add_flang_library(FIRCodeGen
+  CGOps.cpp
+  PreCGRewrite.cpp
+
+  DEPENDS
+  FIRDialect
+  FIRSupport
+  FIROptCodeGenPassIncGen
+  CGOpsIncGen
+
+  LINK_LIBS
+  FIRDialect
+  FIRSupport
+  MLIROpenMPToLLVM
+  MLIRLLVMToLLVMIRTranslation
+  MLIRTargetLLVMIRExport
+
+  LINK_COMPONENTS
+  AsmParser
+  AsmPrinter
+  Remarks
+)

diff  --git a/flang/lib/Optimizer/Dialect/CMakeLists.txt b/flang/lib/Optimizer/Dialect/CMakeLists.txt
new file mode 100644
index 0000000000000..7116dab90b6f0
--- /dev/null
+++ b/flang/lib/Optimizer/Dialect/CMakeLists.txt
@@ -0,0 +1,21 @@
+add_flang_library(FIRDialect
+  FIRAttr.cpp
+  FIRDialect.cpp
+  FIROps.cpp
+  FIRType.cpp
+
+  DEPENDS
+  FIRSupport
+  FIROpsIncGen
+
+  LINK_LIBS
+  FIRSupport
+  MLIROpenMPToLLVM
+  MLIRLLVMToLLVMIRTranslation
+  MLIRTargetLLVMIRExport
+
+  LINK_COMPONENTS
+  AsmParser
+  AsmPrinter
+  Remarks
+)

diff  --git a/flang/lib/Optimizer/Support/CMakeLists.txt b/flang/lib/Optimizer/Support/CMakeLists.txt
new file mode 100644
index 0000000000000..30a163de9ccaf
--- /dev/null
+++ b/flang/lib/Optimizer/Support/CMakeLists.txt
@@ -0,0 +1,18 @@
+get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+
+add_flang_library(FIRSupport
+  FIRContext.cpp
+  InternalNames.cpp
+  KindMapping.cpp
+
+  DEPENDS
+  FIROpsIncGen
+  MLIRIR
+  ${dialect_libs}
+
+  LINK_LIBS
+  ${dialect_libs}
+  MLIROpenMPToLLVMIRTranslation
+  MLIRLLVMToLLVMIRTranslation
+  MLIRTargetLLVMIRExport
+)

diff  --git a/flang/lib/Optimizer/Transforms/CMakeLists.txt b/flang/lib/Optimizer/Transforms/CMakeLists.txt
new file mode 100644
index 0000000000000..462ae40354d62
--- /dev/null
+++ b/flang/lib/Optimizer/Transforms/CMakeLists.txt
@@ -0,0 +1,16 @@
+add_flang_library(FIRTransforms
+  Inliner.cpp
+
+  DEPENDS
+  FIRDialect
+  FIRSupport
+  FIROptTransformsPassIncGen
+
+  LINK_LIBS
+  FIRDialect
+  MLIRAffineToStandard
+  MLIRLLVMIR
+  MLIROpenACC
+  MLIROpenMP
+  FIRSupport
+)

diff  --git a/flang/tools/fir-opt/CMakeLists.txt b/flang/tools/fir-opt/CMakeLists.txt
index efd33f9826b98..566aa787e7c35 100644
--- a/flang/tools/fir-opt/CMakeLists.txt
+++ b/flang/tools/fir-opt/CMakeLists.txt
@@ -3,7 +3,10 @@ llvm_update_compile_flags(fir-opt)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
 
 target_link_libraries(fir-opt PRIVATE
-  FIROptimizer
+  FIRDialect
+  FIRSupport
+  FIRTransforms
+  FIRCodeGen
   ${dialect_libs}
 
   # TODO: these should be transitive dependencies from a target providing

diff  --git a/flang/tools/tco/CMakeLists.txt b/flang/tools/tco/CMakeLists.txt
index 4a22427486d71..1a9c5ac72f153 100644
--- a/flang/tools/tco/CMakeLists.txt
+++ b/flang/tools/tco/CMakeLists.txt
@@ -1,7 +1,10 @@
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
 
 set(LIBS
-  FIROptimizer
+  FIRCodeGen
+  FIRDialect
+  FIRSupport
+  FIRTransforms
   ${dialect_libs}
   MLIRIR
   MLIRLLVMIR

diff  --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index 95e3f6d611dd6..5acebce7192af 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -39,6 +39,5 @@ endfunction()
 add_subdirectory(Optimizer)
 add_subdirectory(Decimal)
 add_subdirectory(Evaluate)
-add_subdirectory(Lower)
 add_subdirectory(Runtime)
 add_subdirectory(Frontend)

diff  --git a/flang/unittests/Lower/CMakeLists.txt b/flang/unittests/Lower/CMakeLists.txt
deleted file mode 100644
index a3f61f0be5ed9..0000000000000
--- a/flang/unittests/Lower/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
-
-set(LIBS
-  FIROptimizer
-  MLIRLLVMIR
-  ${dialect_libs}
-)
-
-add_flang_unittest(FlangLoweringTests
-  RTBuilder.cpp
-)
-
-target_link_libraries(FlangLoweringTests
-  PRIVATE
-  ${LIBS})

diff  --git a/flang/unittests/Optimizer/CMakeLists.txt b/flang/unittests/Optimizer/CMakeLists.txt
index 3996c69b1a982..8bfb8604b4127 100644
--- a/flang/unittests/Optimizer/CMakeLists.txt
+++ b/flang/unittests/Optimizer/CMakeLists.txt
@@ -1,7 +1,9 @@
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
 
 set(LIBS
-  FIROptimizer
+  FIRCodeGen
+  FIRDialect
+  FIRSupport
   ${dialect_libs}
 )
 
@@ -9,6 +11,7 @@ add_flang_unittest(FlangOptimizerTests
   FIRContextTest.cpp
   InternalNamesTest.cpp
   KindMappingTest.cpp
+  RTBuilder.cpp
 )
 target_link_libraries(FlangOptimizerTests
   PRIVATE

diff  --git a/flang/unittests/Lower/RTBuilder.cpp b/flang/unittests/Optimizer/RTBuilder.cpp
similarity index 100%
rename from flang/unittests/Lower/RTBuilder.cpp
rename to flang/unittests/Optimizer/RTBuilder.cpp


        


More information about the flang-commits mailing list