Files
swift-mirror/lib/SIL/CMakeLists.txt
Michael Gottesman 11b24415c1 [sil-module] Create SILFunctionBuilder and hide creation/erasing functions on SILModule.
This commit does not modify those APIs or their usage. It just:

1. Moves the APIs onto SILFunctionBuilder and makes SILFunctionBuilder a friend
   of SILModule.
2. Hides the APIs on SILModule so all users need to use SILFunctionBuilder to
   create/destroy functions.

I am doing this in order to allow for adding/removing function notifications to
be enforced via the type system in the SILOptimizer. In the process of finishing
off CallerAnalysis for FSO, I discovered that we were not doing this everywhere
we need to. After considering various other options such as:

1. Verifying after all passes that the notifications were sent correctly and
   asserting. Turned out to be expensive.
2. Putting a callback in SILModule. This would add an unnecessary virtual call.

I realized that by using a builder we can:

1. Enforce that users of SILFunctionBuilder can only construct composed function
   builders by making the composed function builder's friends of
   SILFunctionBuilder (notice I did not use the word subclass, I am talking
   about a pure composition).
2. Refactor a huge amount of code in SILOpt/SILGen that involve function
   creation onto a SILGenFunctionBuilder/SILOptFunctionBuilder struct. Many of
   the SILFunction creation code in question are straight up copies of each
   other with small variations. A builder would be a great way to simplify that
   code.
3. Reduce the size of SILModule.cpp by 25% from ~30k -> ~23k making the whole
   file easier to read.

NOTE: In this commit, I do not hide the constructor of SILFunctionBuilder since
I have not created the derived builder structs yet. Once I have created those in
a subsequent commit, I will hide that constructor.

rdar://42301529
2018-07-31 10:04:03 -07:00

54 lines
1.2 KiB
CMake

add_swift_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
OptimizationRemark.cpp
PrettyStackTrace.cpp
Projection.cpp
SIL.cpp
SILArgument.cpp
SILBasicBlock.cpp
SILBuilder.cpp
SILCoverageMap.cpp
SILDebugScope.cpp
SILDeclRef.cpp
SILDefaultWitnessTable.cpp
SILFunction.cpp
SILFunctionType.cpp
SILGlobalVariable.cpp
SILInstruction.cpp
SILInstructions.cpp
SILLocation.cpp
SILModule.cpp
SILFunctionBuilder.cpp
SILOpenedArchetypesTracker.cpp
SILPrinter.cpp
SILProfiler.cpp
SILSuccessor.cpp
SILType.cpp
SILValue.cpp
SILVerifier.cpp
SILOwnershipVerifier.cpp
SILVTable.cpp
SILWitnessTable.cpp
TypeLowering.cpp
ValueOwnershipKindClassifier.cpp
LINK_LIBRARIES
swiftSerialization
swiftSema
)
# intrinsics_gen is the LLVM tablegen target that generates the include files
# where intrinsics and attributes are declared. swiftSIL depends on these
# headers.
# For more information see the comment at the top of lib/CMakeLists.txt.
add_dependencies(swiftSIL intrinsics_gen clang-tablegen-targets)