[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:
Michael Gottesman
2020-03-30 09:29:56 -07:00
parent 1420b815d5
commit e1a19e4173
58 changed files with 87 additions and 57 deletions

View File

@@ -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
AbstractionPattern.cpp
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)
${SIL_SOURCES})
target_link_libraries(swiftSIL PRIVATE
swiftSema
swiftSerialization)

35
lib/SIL/IR/CMakeLists.txt Normal file
View 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
)

View File

@@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//
#include "LinearLifetimeCheckerPrivate.h"
#include "swift/SIL/ApplySite.h"
#include "swift/SIL/OwnershipUtils.h"
#include "swift/SIL/SILBuiltinVisitor.h"
@@ -36,7 +35,6 @@ private:
LLVM_ATTRIBUTE_UNUSED SILModule &mod;
const Operand &op;
LinearLifetimeChecker::ErrorBehaviorKind errorBehavior;
bool checkingSubObject;
public:
@@ -49,9 +47,8 @@ public:
/// like struct_extract.
OperandOwnershipKindClassifier(
SILModule &mod, const Operand &op,
LinearLifetimeChecker::ErrorBehaviorKind errorBehavior,
bool checkingSubObject)
: mod(mod), op(op), errorBehavior(errorBehavior),
: mod(mod), op(op),
checkingSubObject(checkingSubObject) {}
bool isCheckingSubObject() const { return checkingSubObject; }
@@ -1050,7 +1047,6 @@ OperandOwnershipKindMap
Operand::getOwnershipKindMap(bool isForwardingSubValue) const {
OperandOwnershipKindClassifier classifier(
getUser()->getModule(), *this,
LinearLifetimeChecker::ErrorBehaviorKind::ReturnFalse,
isForwardingSubValue);
return classifier.visit(const_cast<SILInstruction *>(getUser()));
}

View 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
)

View File

@@ -0,0 +1,6 @@
sil_register_sources(
LinearLifetimeChecker.cpp
MemoryLifetime.cpp
SILOwnershipVerifier.cpp
SILVerifier.cpp
)