mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[sil] Split library into subfolders, while still building as a single library still.
Specifically, I split it into 3 initial categories: IR, Utils, Verifier. I just did this quickly, we can always split it more later if we want. I followed the model that we use in SILOptimizer: ./lib/SIL/CMakeLists.txt vends a macro (sil_register_sources) to the sub-folders that register the sources of the subdirectory with a global state variable that ./lib/SIL/CMakeLists.txt defines. Then after including those subdirs, the parent cmake declares the SIL library. So the output is the same, but we have the flexibility of having subdirectories to categorize source files.
This commit is contained in:
@@ -1,56 +1,32 @@
|
|||||||
|
|
||||||
|
set(SIL_SOURCES)
|
||||||
|
|
||||||
|
function(_list_transform newvar)
|
||||||
|
set(sources ${ARGN})
|
||||||
|
set(dir ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
set(tmp)
|
||||||
|
foreach (s ${sources})
|
||||||
|
list(APPEND tmp "${dir}/${s}")
|
||||||
|
endforeach()
|
||||||
|
set(${newvar} "${tmp}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
macro(sil_register_sources)
|
||||||
|
precondition(new_transformed_sources
|
||||||
|
NEGATE
|
||||||
|
MESSAGE "Expected this to be empty since we clear after each run")
|
||||||
|
_list_transform(new_transformed_sources ${ARGN})
|
||||||
|
list_union("${SIL_SOURCES}" "${new_transformed_sources}" out)
|
||||||
|
set(SIL_SOURCES "${out}" PARENT_SCOPE)
|
||||||
|
set(new_transformed_sources)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
add_subdirectory(IR)
|
||||||
|
add_subdirectory(Utils)
|
||||||
|
add_subdirectory(Verifier)
|
||||||
|
|
||||||
add_swift_host_library(swiftSIL STATIC
|
add_swift_host_library(swiftSIL STATIC
|
||||||
AbstractionPattern.cpp
|
${SIL_SOURCES})
|
||||||
BasicBlockUtils.cpp
|
|
||||||
Bridging.cpp
|
|
||||||
DebugUtils.cpp
|
|
||||||
Dominance.cpp
|
|
||||||
DynamicCasts.cpp
|
|
||||||
InstructionUtils.cpp
|
|
||||||
MemAccessUtils.cpp
|
|
||||||
Linker.cpp
|
|
||||||
LinearLifetimeChecker.cpp
|
|
||||||
LoopInfo.cpp
|
|
||||||
MemoryLifetime.cpp
|
|
||||||
Notifications.cpp
|
|
||||||
OperandOwnership.cpp
|
|
||||||
OptimizationRemark.cpp
|
|
||||||
OwnershipUtils.cpp
|
|
||||||
PrettyStackTrace.cpp
|
|
||||||
Projection.cpp
|
|
||||||
SIL.cpp
|
|
||||||
SILArgument.cpp
|
|
||||||
SILBasicBlock.cpp
|
|
||||||
SILBuilder.cpp
|
|
||||||
SILConstants.cpp
|
|
||||||
SILCoverageMap.cpp
|
|
||||||
SILDebugScope.cpp
|
|
||||||
SILDeclRef.cpp
|
|
||||||
SILDefaultWitnessTable.cpp
|
|
||||||
SILDifferentiabilityWitness.cpp
|
|
||||||
SILFunction.cpp
|
|
||||||
SILFunctionType.cpp
|
|
||||||
SILGlobalVariable.cpp
|
|
||||||
SILInstruction.cpp
|
|
||||||
SILInstructions.cpp
|
|
||||||
SILInstructionWorklist.cpp
|
|
||||||
SILLocation.cpp
|
|
||||||
SILModule.cpp
|
|
||||||
SILFunctionBuilder.cpp
|
|
||||||
SILOpenedArchetypesTracker.cpp
|
|
||||||
SILPrinter.cpp
|
|
||||||
SILProfiler.cpp
|
|
||||||
SILRemarkStreamer.cpp
|
|
||||||
SILSuccessor.cpp
|
|
||||||
SILType.cpp
|
|
||||||
SILUndef.cpp
|
|
||||||
SILValue.cpp
|
|
||||||
SILVerifier.cpp
|
|
||||||
SILOwnershipVerifier.cpp
|
|
||||||
SILVTable.cpp
|
|
||||||
SILWitnessTable.cpp
|
|
||||||
TypeLowering.cpp
|
|
||||||
ValueOwnership.cpp
|
|
||||||
ValueUtils.cpp)
|
|
||||||
target_link_libraries(swiftSIL PRIVATE
|
target_link_libraries(swiftSIL PRIVATE
|
||||||
swiftSema
|
swiftSema
|
||||||
swiftSerialization)
|
swiftSerialization)
|
||||||
|
|||||||
35
lib/SIL/IR/CMakeLists.txt
Normal file
35
lib/SIL/IR/CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
sil_register_sources(
|
||||||
|
AbstractionPattern.cpp
|
||||||
|
Bridging.cpp
|
||||||
|
Linker.cpp
|
||||||
|
Notifications.cpp
|
||||||
|
OperandOwnership.cpp
|
||||||
|
SIL.cpp
|
||||||
|
SILArgument.cpp
|
||||||
|
SILBasicBlock.cpp
|
||||||
|
SILBuilder.cpp
|
||||||
|
SILConstants.cpp
|
||||||
|
SILCoverageMap.cpp
|
||||||
|
SILDebugScope.cpp
|
||||||
|
SILDeclRef.cpp
|
||||||
|
SILDefaultWitnessTable.cpp
|
||||||
|
SILDifferentiabilityWitness.cpp
|
||||||
|
SILFunction.cpp
|
||||||
|
SILFunctionBuilder.cpp
|
||||||
|
SILFunctionType.cpp
|
||||||
|
SILGlobalVariable.cpp
|
||||||
|
SILInstruction.cpp
|
||||||
|
SILInstructions.cpp
|
||||||
|
SILLocation.cpp
|
||||||
|
SILModule.cpp
|
||||||
|
SILPrinter.cpp
|
||||||
|
SILProfiler.cpp
|
||||||
|
SILSuccessor.cpp
|
||||||
|
SILType.cpp
|
||||||
|
SILUndef.cpp
|
||||||
|
SILVTable.cpp
|
||||||
|
SILValue.cpp
|
||||||
|
SILWitnessTable.cpp
|
||||||
|
TypeLowering.cpp
|
||||||
|
ValueOwnership.cpp
|
||||||
|
)
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "LinearLifetimeCheckerPrivate.h"
|
|
||||||
#include "swift/SIL/ApplySite.h"
|
#include "swift/SIL/ApplySite.h"
|
||||||
#include "swift/SIL/OwnershipUtils.h"
|
#include "swift/SIL/OwnershipUtils.h"
|
||||||
#include "swift/SIL/SILBuiltinVisitor.h"
|
#include "swift/SIL/SILBuiltinVisitor.h"
|
||||||
@@ -36,7 +35,6 @@ private:
|
|||||||
LLVM_ATTRIBUTE_UNUSED SILModule &mod;
|
LLVM_ATTRIBUTE_UNUSED SILModule &mod;
|
||||||
|
|
||||||
const Operand &op;
|
const Operand &op;
|
||||||
LinearLifetimeChecker::ErrorBehaviorKind errorBehavior;
|
|
||||||
bool checkingSubObject;
|
bool checkingSubObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -49,9 +47,8 @@ public:
|
|||||||
/// like struct_extract.
|
/// like struct_extract.
|
||||||
OperandOwnershipKindClassifier(
|
OperandOwnershipKindClassifier(
|
||||||
SILModule &mod, const Operand &op,
|
SILModule &mod, const Operand &op,
|
||||||
LinearLifetimeChecker::ErrorBehaviorKind errorBehavior,
|
|
||||||
bool checkingSubObject)
|
bool checkingSubObject)
|
||||||
: mod(mod), op(op), errorBehavior(errorBehavior),
|
: mod(mod), op(op),
|
||||||
checkingSubObject(checkingSubObject) {}
|
checkingSubObject(checkingSubObject) {}
|
||||||
|
|
||||||
bool isCheckingSubObject() const { return checkingSubObject; }
|
bool isCheckingSubObject() const { return checkingSubObject; }
|
||||||
@@ -1050,7 +1047,6 @@ OperandOwnershipKindMap
|
|||||||
Operand::getOwnershipKindMap(bool isForwardingSubValue) const {
|
Operand::getOwnershipKindMap(bool isForwardingSubValue) const {
|
||||||
OperandOwnershipKindClassifier classifier(
|
OperandOwnershipKindClassifier classifier(
|
||||||
getUser()->getModule(), *this,
|
getUser()->getModule(), *this,
|
||||||
LinearLifetimeChecker::ErrorBehaviorKind::ReturnFalse,
|
|
||||||
isForwardingSubValue);
|
isForwardingSubValue);
|
||||||
return classifier.visit(const_cast<SILInstruction *>(getUser()));
|
return classifier.visit(const_cast<SILInstruction *>(getUser()));
|
||||||
}
|
}
|
||||||
17
lib/SIL/Utils/CMakeLists.txt
Normal file
17
lib/SIL/Utils/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
sil_register_sources(
|
||||||
|
BasicBlockUtils.cpp
|
||||||
|
DebugUtils.cpp
|
||||||
|
Dominance.cpp
|
||||||
|
DynamicCasts.cpp
|
||||||
|
InstructionUtils.cpp
|
||||||
|
LoopInfo.cpp
|
||||||
|
MemAccessUtils.cpp
|
||||||
|
OptimizationRemark.cpp
|
||||||
|
OwnershipUtils.cpp
|
||||||
|
PrettyStackTrace.cpp
|
||||||
|
Projection.cpp
|
||||||
|
SILInstructionWorklist.cpp
|
||||||
|
SILOpenedArchetypesTracker.cpp
|
||||||
|
SILRemarkStreamer.cpp
|
||||||
|
ValueUtils.cpp
|
||||||
|
)
|
||||||
6
lib/SIL/Verifier/CMakeLists.txt
Normal file
6
lib/SIL/Verifier/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
sil_register_sources(
|
||||||
|
LinearLifetimeChecker.cpp
|
||||||
|
MemoryLifetime.cpp
|
||||||
|
SILOwnershipVerifier.cpp
|
||||||
|
SILVerifier.cpp
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user