Skip to content

Commit

Permalink
[fir] Split FIROptimizer lib into several smaller libraries
Browse files Browse the repository at this point in the history
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@nvidia.com>
  • Loading branch information
clementval and schweitzpgi committed Oct 5, 2021
1 parent ca5be06 commit c02a8cd
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 55 deletions.
8 changes: 6 additions & 2 deletions flang/lib/Lower/CMakeLists.txt
Expand Up @@ -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
Expand Down
38 changes: 4 additions & 34 deletions 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)
22 changes: 22 additions & 0 deletions 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
)
21 changes: 21 additions & 0 deletions 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
)
15 changes: 15 additions & 0 deletions flang/lib/Optimizer/Support/CMakeLists.txt
@@ -0,0 +1,15 @@
add_flang_library(FIRSupport
FIRContext.cpp
InternalNames.cpp
KindMapping.cpp

DEPENDS
${dialect_libs}
MLIRIR

LINK_LIBS
${dialect_libs}
MLIROpenMPToLLVMIRTranslation
MLIRLLVMToLLVMIRTranslation
MLIRTargetLLVMIRExport
)
16 changes: 16 additions & 0 deletions 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
)
5 changes: 4 additions & 1 deletion flang/tools/fir-opt/CMakeLists.txt
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion 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
Expand Down
1 change: 0 additions & 1 deletion flang/unittests/CMakeLists.txt
Expand Up @@ -39,6 +39,5 @@ endfunction()
add_subdirectory(Optimizer)
add_subdirectory(Decimal)
add_subdirectory(Evaluate)
add_subdirectory(Lower)
add_subdirectory(Runtime)
add_subdirectory(Frontend)
15 changes: 0 additions & 15 deletions flang/unittests/Lower/CMakeLists.txt

This file was deleted.

5 changes: 4 additions & 1 deletion flang/unittests/Optimizer/CMakeLists.txt
@@ -1,14 +1,17 @@
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)

set(LIBS
FIROptimizer
FIRCodeGen
FIRDialect
FIRSupport
${dialect_libs}
)

add_flang_unittest(FlangOptimizerTests
FIRContextTest.cpp
InternalNamesTest.cpp
KindMappingTest.cpp
RTBuilder.cpp
)
target_link_libraries(FlangOptimizerTests
PRIVATE
Expand Down
File renamed without changes.

0 comments on commit c02a8cd

Please sign in to comment.