Skip to content

Commit

Permalink
[compiler] refactor and clean cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyunqu committed Aug 19, 2024
1 parent 0e05851 commit abb049f
Show file tree
Hide file tree
Showing 37 changed files with 106 additions and 138 deletions.
12 changes: 12 additions & 0 deletions compiler/cmake/MLIR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND NOT LLVM_INSTALL_PREFIX)
endif()
message(STATUS "CMAKE_INSTALL_PREFIX : " ${CMAKE_INSTALL_PREFIX})

# Declare the library associated with a dialect.
function(add_byteir_dialect_library name)
set_property(GLOBAL APPEND PROPERTY BYTEIR_DIALECT_LIBS ${name})
add_mlir_library(${ARGV} DEPENDS mlir-headers)
endfunction(add_byteir_dialect_library)

# Declare the library associated with a pipeline.
function(add_byteir_pipeline_library name)
set_property(GLOBAL APPEND PROPERTY BYTEIR_PIPELINE_LIBS ${name})
add_mlir_library(${ARGV} DEPENDS mlir-headers)
endfunction(add_byteir_pipeline_library)

# Declare the library associated with a conversion.
function(add_byteir_conversion_library name)
set_property(GLOBAL APPEND PROPERTY BYTEIR_CONVERSION_LIBS ${name})
Expand Down
2 changes: 1 addition & 1 deletion compiler/dialects/lib/Dialect/Ace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRAceDialect
add_byteir_dialect_library(MLIRAceDialect
IR/AceDialect.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
4 changes: 2 additions & 2 deletions compiler/dialects/lib/Dialect/Ccl/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRCclDialect
add_byteir_dialect_library(MLIRCclDialect
CclOps.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -10,4 +10,4 @@ add_mlir_dialect_library(MLIRCclDialect
LINK_LIBS PUBLIC
MLIRIR
MLIRSupport
)
)
42 changes: 8 additions & 34 deletions compiler/lib/CAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
get_property(byteir_dialect_libs GLOBAL PROPERTY BYTEIR_DIALECT_LIBS)
get_property(byteir_pipeline_libs GLOBAL PROPERTY BYTEIR_PIPELINE_LIBS)
get_property(byteir_conversion_libs GLOBAL PROPERTY BYTEIR_CONVERSION_LIBS)
get_property(byteir_translation_libs GLOBAL PROPERTY BYTEIR_TRANSLATION_LIBS)
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(extension_libs GLOBAL PROPERTY MLIR_EXTENSION_LIBS)

Expand All @@ -8,46 +12,16 @@ add_mlir_public_c_api_library(ByteIRCAPI
PDLValue.cpp

LINK_LIBS PUBLIC
${byteir_dialect_libs}
${byteir_pipeline_libs}
${byteir_conversion_libs}
${byteir_translation_libs}
${dialect_libs}
${extension_libs}
MLIRCatDialect
MLIRCclTransformOps

# conversion passes
ByteIRGPUToNVVM
ByteIRHloToCat
ByteIRHloToTensor
ByteIRToAce
ByteIRToAIT
ByteIRToByre
ByteIRToGPU
ByteIRToMhlo
ByteIRToLinalg
ByteIRToLLVM
ByteIRToPTX
ByteIRLcclToByre

# transofrm passes
ByteIRTransforms

# dialect specific passes
ByteIRAffinePasses
ByteIRByrePasses
ByteIRGPUPasses
ByteIRLinalgPasses
ByteIRMemRefPasses
ByteIRMhloPasses
ByteIRSCFPasses
ByteIRTransformPasses

# pipelines
ByteIRGPUPipelines
ByteIRHostPipelines
ByteIRPipelines

# translate passes
MLIRTranslateLib
ByteIRTargetPTX
ByteIRTargetCUDA
ByteIRTargetCpp
)
4 changes: 3 additions & 1 deletion compiler/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
add_subdirectory(Analysis)
add_subdirectory(CAPI)
add_subdirectory(Conversion)
add_subdirectory(Dialect)
add_subdirectory(Pipelines)
add_subdirectory(Stat)
add_subdirectory(Target)
add_subdirectory(Transforms)
add_subdirectory(Utils)

# note: CAPI depends on byteir property, so add it at last
add_subdirectory(CAPI)
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/Ace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(ByteIRAcePasses
add_byteir_dialect_library(ByteIRAcePasses
Transforms/BufferizableOpInterfaceImpl.cpp
Transforms/Bufferize.cpp

Expand All @@ -19,4 +19,4 @@ add_mlir_dialect_library(ByteIRAcePasses
MLIRBufferizationTransforms
MLIRLaceDialect
MLIRMemRefDialect
)
)
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/Affine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(ByteIRAffinePasses
add_byteir_dialect_library(ByteIRAffinePasses
Transforms/AffineLoopFusionEx.cpp
Transforms/InsertTrivialAffineLoop.cpp
Transforms/RewriteAffineToMemref.cpp
Expand All @@ -20,4 +20,4 @@ add_mlir_dialect_library(ByteIRAffinePasses
MLIRMemRefDialect
MLIRSideEffectInterfaces
MLIRSupport
)
)
12 changes: 6 additions & 6 deletions compiler/lib/Dialect/Byre/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRByreDialect
add_byteir_dialect_library(MLIRByreDialect
IR/ByreDialect.cpp
IR/Common.cpp

Expand All @@ -16,9 +16,9 @@ add_mlir_dialect_library(MLIRByreDialect
MLIRSideEffectInterfaces
MLIRSupport
MLIRLLVMDialect
)
)

add_mlir_dialect_library(MLIRByreSerialization
add_byteir_dialect_library(MLIRByreSerialization
IR/Serialization/ByreSerialOps.cpp
IR/Serialization/Bytecode.cpp
IR/Serialization/Versioning.cpp
Expand All @@ -35,9 +35,9 @@ add_mlir_dialect_library(MLIRByreSerialization
MLIRIR
MLIRSupport
MLIRByreDialect
)
)

add_mlir_dialect_library(ByteIRByrePasses
add_byteir_dialect_library(ByteIRByrePasses
Transforms/BufferizableOpInterfaceImpl.cpp
Transforms/Serial.cpp

Expand All @@ -57,4 +57,4 @@ add_mlir_dialect_library(ByteIRByrePasses
MLIRByreSerialization
MLIRMemRefDialect
MLIRTensorDialect
)
)
2 changes: 1 addition & 1 deletion compiler/lib/Dialect/Cat/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRCatDialect
add_byteir_dialect_library(MLIRCatDialect
CatDialect.cpp

DEPENDS
Expand Down
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/Ccl/TransformOps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRCclTransformOps
add_byteir_dialect_library(MLIRCclTransformOps
CclTransformOps.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -16,4 +16,4 @@ add_mlir_dialect_library(MLIRCclTransformOps
MLIRPDLDialect
MLIRSideEffectInterfaces
MLIRTransformDialect
)
)
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/Ccl/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(ByteIRCclPasses
add_byteir_dialect_library(ByteIRCclPasses
CclMoveDown.cpp
CclBufferizeOpInterfaceImpl.cpp

Expand All @@ -14,4 +14,4 @@ add_mlir_dialect_library(ByteIRCclPasses
MLIRIR
MhloDialect
MLIRSupport
)
)
2 changes: 1 addition & 1 deletion compiler/lib/Dialect/GPU/TransformOps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRGPUExtTransformOps
add_byteir_dialect_library(MLIRGPUExtTransformOps
GPUExtTransformOps.cpp
Utils.cpp

Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/Dialect/GPU/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(ByteIRGPUPasses
add_byteir_dialect_library(ByteIRGPUPasses
GPUBlockSwizzle.cpp
GPUDistributeSharedMemoryCopy.cpp
GPUDistributeToWarp.cpp
Expand Down
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/Lace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRLaceDialect
add_byteir_dialect_library(MLIRLaceDialect
IR/LaceDialect.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -14,4 +14,4 @@ add_mlir_dialect_library(MLIRLaceDialect
MLIRSupport
MLIRViewLikeInterface
MLIRAceDialect
)
)
2 changes: 1 addition & 1 deletion compiler/lib/Dialect/Lccl/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRLcclDialect
add_byteir_dialect_library(MLIRLcclDialect
LcclOps.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/Dialect/Linalg/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRLinalgExt
add_byteir_dialect_library(MLIRLinalgExt
LinalgExtInterfaces.cpp
LinalgExtOps.cpp

Expand Down
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/Linalg/TransformOps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRLinalgExtTransformOps
add_byteir_dialect_library(MLIRLinalgExtTransformOps
LinalgExtTransformOps.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -24,4 +24,4 @@ add_mlir_dialect_library(MLIRLinalgExtTransformOps
MLIRTensorTilingInterfaceImplExt
MLIRTransformDialect
MLIRVectorDialect
)
)
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/Linalg/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(ByteIRLinalgPasses
add_byteir_dialect_library(ByteIRLinalgPasses
BufferizableOpInterfaceImpl.cpp
Bufferize.cpp
CanonicalizeExt.cpp
Expand Down Expand Up @@ -39,4 +39,4 @@ add_mlir_dialect_library(ByteIRLinalgPasses
MLIRLinalgTransforms
MLIRMemRefDialect
MLIRSupport
)
)
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/Linalg/Util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRLinalgExtUtils
add_byteir_dialect_library(MLIRLinalgExtUtils
Util.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -7,4 +7,4 @@ add_mlir_dialect_library(MLIRLinalgExtUtils
LINK_LIBS PUBLIC
MLIRIR
MLIRLinalgDialect
)
)
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/MemRef/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(ByteIRMemRefPasses
add_byteir_dialect_library(ByteIRMemRefPasses
Transforms/ApplyMemRefAffineLayout.cpp
Transforms/ExtractAddressComputation.cpp
Transforms/RemoveCopy.cpp
Expand All @@ -25,4 +25,4 @@ add_mlir_dialect_library(ByteIRMemRefPasses
MLIRMemRefDialect
MLIRMemRefTransforms
MLIRSupport
)
)
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/SCF/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(ByteIRSCFPasses
add_byteir_dialect_library(ByteIRSCFPasses
ForallCollapsing.cpp
FuseNestedForall.cpp
InsertTrivialSCFLoop.cpp
Expand All @@ -21,4 +21,4 @@ add_mlir_dialect_library(ByteIRSCFPasses
MLIRSCFTransforms
MLIRSideEffectInterfaces
MLIRSupport
)
)
4 changes: 2 additions & 2 deletions compiler/lib/Dialect/SCF/Util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRSCFExtUtils
add_byteir_dialect_library(MLIRSCFExtUtils
Util.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -7,4 +7,4 @@ add_mlir_dialect_library(MLIRSCFExtUtils
LINK_LIBS PUBLIC
MLIRIR
MLIRSCFDialect
)
)
6 changes: 3 additions & 3 deletions compiler/lib/Dialect/Shape/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRShapeExt
add_byteir_dialect_library(MLIRShapeExt
IR/ShapeExtOps.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -12,7 +12,7 @@ add_mlir_dialect_library(MLIRShapeExt
MLIRSupport
)

add_mlir_dialect_library(ByteIRShapePasses
add_byteir_dialect_library(ByteIRShapePasses
Transforms/InsertTieShape.cpp
Transforms/ResolveShapeConstraint.cpp
Transforms/SetAssumingAlwaysTrue.cpp
Expand All @@ -33,4 +33,4 @@ add_mlir_dialect_library(ByteIRShapePasses
MLIRShapeDialect
MLIRShapeExt
MLIRSupport
)
)
2 changes: 1 addition & 1 deletion compiler/lib/Dialect/Tensor/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRTensorTilingInterfaceImplExt
add_byteir_dialect_library(MLIRTensorTilingInterfaceImplExt
TilingInterfaceImpl.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
5 changes: 2 additions & 3 deletions compiler/lib/Dialect/Tensor/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

add_mlir_dialect_library(ByteIRTensorPasses
add_byteir_dialect_library(ByteIRTensorPasses
CanonicalizeExt.cpp
ExtractSliceSpecialization.cpp
TensorPadSpecialization.cpp
Expand All @@ -17,4 +16,4 @@ add_mlir_dialect_library(ByteIRTensorPasses
MLIRSupport
MLIRSCFDialect
ByteIRUtils
)
)
2 changes: 1 addition & 1 deletion compiler/lib/Dialect/Transform/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(MLIRTransformExtDialect
add_byteir_dialect_library(MLIRTransformExtDialect
TransformExtOps.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/Dialect/Transform/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(ByteIRTransformPasses
add_byteir_dialect_library(ByteIRTransformPasses
TransformDialectInterpreter.cpp
TransformInsertion.cpp

Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/Dialect/Vector/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_dialect_library(ByteIRVectorPasses
add_byteir_dialect_library(ByteIRVectorPasses
CanonicalizeExt.cpp
VectorLowerings.cpp
VectorWarpDistribute.cpp
Expand Down
Loading

0 comments on commit abb049f

Please sign in to comment.