Skip to content

Commit 3540c01

Browse files
committed
rename initializeLibSwift -> InitializeSwiftModules
and some updates in comments.
1 parent 48f5cba commit 3540c01

File tree

21 files changed

+51
-53
lines changed

21 files changed

+51
-53
lines changed

SwiftCompilerSources/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import PackageDescription
44

55
let package = Package(
6-
name: "libswift",
6+
name: "SwiftCompilerSources",
77
platforms: [
88
.macOS("10.9"),
99
],

SwiftCompilerSources/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ This makes the SIL API easy to use and it allows to program in a "Swifty" style.
111111

112112
Bridging SIL classes is implemented by including a two word Swift object header (`SwiftObjectHeader`) in the C++ definition of a class, like in `SILFunction`, `SILBasicBlock` or `SILNode`. This enables to use SIL objects on both, the C++ and the Swift, side.
113113

114-
The Swift class metatypes are "registered" by `registerClass()`, called from `initializeLibSwift()`. On the C++ side, they are stored in static global variables (see `registerBridgedClass()`) and then used to initialize the object headers in the class constructors.
114+
The Swift class metatypes are "registered" by `registerClass()`, called from `initializeSwiftModules()`. On the C++ side, they are stored in static global variables (see `registerBridgedClass()`) and then used to initialize the object headers in the class constructors.
115115

116116
The reference counts in the object header are initialized to "immortal", which let's all ARC operations on SIL objects be no-ops.
117117

SwiftCompilerSources/Sources/Optimizer/PassManager/PassRegistration.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import OptimizerBridging
1717
import ExperimentalRegex
1818
#endif
1919

20-
@_cdecl("initializeLibSwift")
21-
public func initializeLibSwift() {
20+
@_cdecl("initializeSwiftModules")
21+
public func initializeSwiftModules() {
2222
registerSILClasses()
2323
registerSwiftPasses()
2424

SwiftCompilerSources/stubs.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
extern "C" {
1414

15-
void initializeLibSwift();
15+
void initializeSwiftModules();
1616

1717
}
1818

19-
void initializeLibSwift() {}
19+
void initializeSwiftModules() {}
2020

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- InitializeLibSwift.h -----------------------------------*- C++ -*-===//
1+
//===--- InitializeSwiftModules.h -------------------------------*- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -10,17 +10,17 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef SWIFT_BASIC_INITIALIZELIBSWIFT_H
14-
#define SWIFT_BASIC_INITIALIZELIBSWIFT_H
13+
#ifndef SWIFT_BASIC_INITIALIZE_SWIFT_MODULES_H
14+
#define SWIFT_BASIC_INITIALIZE_SWIFT_MODULES_H
1515

1616
#ifdef __cplusplus
1717
extern "C" {
1818
#endif
1919

20-
void initializeLibSwift();
20+
void initializeSwiftModules();
2121

2222
#ifdef __cplusplus
2323
}
2424
#endif
2525

26-
#endif // SWIFT_BASIC_INITIALIZELIBSWIFT_H
26+
#endif // SWIFT_BASIC_INITIALIZE_SWIFT_MODULES_H

include/swift/SIL/SILBridgingUtils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ inline StringRef getStringRef(BridgedStringRef str) {
3434
/// freeing it.
3535
inline BridgedStringRef getCopiedBridgedStringRef(std::string str,
3636
bool removeTrailingNewline = false) {
37-
// A couple of mallocs are needed for passing a std::string to libswift. But
37+
// A couple of mallocs are needed for passing a std::string to Swift. But
3838
// it's currently only used or debug descriptions. So, its' maybe not so bad -
3939
// for now.
40-
// TODO: find a better way to pass std::strings to libswift.
40+
// TODO: find a better way to pass std::strings to Swift.
4141
StringRef strRef(str);
4242
if (removeTrailingNewline)
4343
strRef.consume_back("\n");

include/swift/SIL/SILBuilder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class SILBuilder {
123123
setInsertionPoint(I);
124124
}
125125

126-
// Used by libswift bridging.
126+
// Used by swift bridging.
127127
explicit SILBuilder(SILInstruction *I, const SILDebugScope *debugScope)
128128
: TempContext(I->getFunction()->getModule()),
129129
C(TempContext), F(I->getFunction()), CurDebugScope(debugScope) {

include/swift/SIL/SILInstructionWorklist.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ template <typename VectorT = std::vector<SILInstruction *>,
6767
class SILInstructionWorklist : SILInstructionWorklistBase {
6868
BlotSetVector<SILInstruction *, VectorT, MapT> worklist;
6969

70-
/// For invoking Swift instruction passes in libswift.
70+
/// For invoking Swift instruction passes in Swift.
7171
LibswiftPassInvocation *libswiftPassInvocation = nullptr;
7272

7373
void operator=(const SILInstructionWorklist &rhs) = delete;

include/swift/SIL/SILModule.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class Output;
5959
namespace swift {
6060

6161
/// The payload for the FixedSizeSlab.
62-
/// This is a super-class rather than a member of FixedSizeSlab to make bridging
63-
/// with libswift easier.
62+
/// This is a super-class rather than a member of FixedSizeSlab to make swift
63+
/// bridging easier.
6464
class FixedSizeSlabPayload {
6565
public:
6666
/// The capacity of the payload.

include/swift/SIL/SILNode.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ class SILNodePointer {
116116
/// ValueBase subobject, the cast will yield a corrupted value.
117117
/// Always use the LLVM casts (cast<>, dyn_cast<>, etc.) instead.
118118
class alignas(8) SILNode :
119-
// SILNode contains a swift object header for bridging with libswift.
120-
// For details see libswift/README.md.
119+
// SILNode contains a swift object header for bridging with Swift.
120+
// For details see SwiftCompilerSources/README.md.
121121
public SwiftObjectHeader {
122122
public:
123123
enum { NumVOKindBits = 3 };

include/swift/SIL/SwiftObjectHeader.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
/// The C++ version of SwiftObject.
1818
///
1919
/// It is used for bridging the SIL core classes (e.g. SILFunction, SILNode,
20-
/// etc.) with libswift.
21-
/// For details see libswift/README.md.
20+
/// etc.) with Swift.
21+
/// For details see SwiftCompilerSources/README.md.
2222
///
2323
/// In C++ code, never use BridgedSwiftObject directly. SwiftObjectHeader has
2424
/// the proper constructor, which avoids the header to be uninitialized.

include/swift/SILOptimizer/PassManager/PassManager.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void executePassPipelinePlan(SILModule *SM, const SILPassPipelinePlan &plan,
4444
bool isMandatory = false,
4545
irgen::IRGenModule *IRMod = nullptr);
4646

47-
/// Utility class to invoke passes in libswift.
47+
/// Utility class to invoke Swift passes.
4848
class LibswiftPassInvocation {
4949
/// Backlink to the pass manager.
5050
SILPassManager *passManager;
@@ -125,7 +125,7 @@ class SILPassManager {
125125
/// The number of passes run so far.
126126
unsigned NumPassesRun = 0;
127127

128-
/// For invoking Swift passes in libswift.
128+
/// For invoking Swift passes.
129129
LibswiftPassInvocation libswiftPassInvocation;
130130

131131
/// Change notifications, collected during a bridged pass run.

include/swift/SILOptimizer/PassManager/Passes.def

+9-10
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@
4545

4646
/// SWIFT_FUNCTION_PASS(Id, Tag, Description)
4747
/// This macro follows the same conventions as PASS(Id, Tag, Description),
48-
/// but is used for function passes which are implemented in libswift.
48+
/// but is used for function passes which are implemented in Swift.
4949
///
50-
/// No further code is need on the C++ side. In libswift a function pass with
51-
/// the same name must be registered with 'registerPass()'.
50+
/// No further code is need on the C++ side. On the swift swift a function
51+
/// pass with the same name must be registered with 'registerPass()'.
5252
///
5353
#ifndef SWIFT_FUNCTION_PASS
5454
#define SWIFT_FUNCTION_PASS(Id, Tag, Description) PASS(Id, Tag, Description)
5555
#endif
5656

5757
/// SWIFT_FUNCTION_PASS_WITH_LEGACY(Id, Tag, Description)
58-
/// Like SWIFT_FUNCTION_PASS, but the a C++ legacy pass is used if the not
59-
/// built with libswift.
58+
/// Like SWIFT_FUNCTION_PASS, but a C++ legacy pass is used if the Swift pass
59+
/// is not registered.
6060
/// The C++ legacy creation function must be named 'createLegacy<Id>'
6161
///
6262
#ifndef SWIFT_FUNCTION_PASS_WITH_LEGACY
@@ -66,21 +66,20 @@
6666

6767
/// SWIFT_INSTRUCTION_PASS(Inst, Tag)
6868
/// Similar to SWIFT_FUNCTION_PASS, but defines an instruction pass which is
69-
/// implemented in libswift and is run by the SILCombiner.
69+
/// implemented in swift and is run by the SILCombiner.
7070
/// The \p Inst argument specifies the instruction class, and \p Tag a name
7171
/// for the pass.
7272
///
73-
/// No further code is need on the C++ side. In libswift an instruction pass
74-
/// with the same name must be registered with 'registerPass()'.
73+
/// No further code is need on the C++ side. On the swift side an instruction
74+
/// pass with the same name must be registered with 'registerPass()'.
7575
///
7676
#ifndef SWIFT_INSTRUCTION_PASS
7777
#define SWIFT_INSTRUCTION_PASS(Inst, Tag)
7878
#endif
7979

8080
/// SWIFT_INSTRUCTION_PASS_WITH_LEGACY(Inst, Tag)
8181
/// Like SWIFT_INSTRUCTION_PASS, but the a C++ legacy SILCombine visit
82-
/// function is used if the not
83-
/// built with libswift.
82+
/// function is used if the swift pass is not registered.
8483
/// The C++ legacy visit function must be named
8584
/// 'SILCombiner::legacyVisit<Inst>'.
8685
///

lib/DriverTool/driver.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "swift/AST/DiagnosticEngine.h"
1818
#include "swift/AST/DiagnosticsDriver.h"
1919
#include "swift/Basic/LLVMInitialize.h"
20-
#include "swift/Basic/InitializeLibSwift.h"
20+
#include "swift/Basic/InitializeSwiftModules.h"
2121
#include "swift/Basic/PrettyStackTrace.h"
2222
#include "swift/Basic/Program.h"
2323
#include "swift/Basic/TaskQueue.h"
@@ -186,8 +186,8 @@ static bool appendSwiftDriverName(SmallString<256> &buffer) {
186186
static int run_driver(StringRef ExecName,
187187
const ArrayRef<const char *> argv) {
188188
// This is done here and not done in FrontendTool.cpp, because
189-
// FrontendTool.cpp is linked to tools, which don't use libswift.
190-
initializeLibSwift();
189+
// FrontendTool.cpp is linked to tools, which don't use swift modules.
190+
initializeSwiftModules();
191191

192192
// Handle integrated tools.
193193
if (argv.size() > 1) {

lib/Immediate/Immediate.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,15 @@ int swift::RunImmediately(CompilerInstance &CI,
253253
if (emplaceProcessArgs == nullptr)
254254
return -1;
255255
#else
256-
// In case the compiler is built with libswift, it already has the stdlib
256+
// In case the compiler is built with swift modules, it already has the stdlib
257257
// linked to. First try to lookup the symbol with the standard library
258258
// resolving.
259259
auto emplaceProcessArgs
260260
= (ArgOverride)dlsym(RTLD_DEFAULT, "_swift_stdlib_overrideUnsafeArgvArgc");
261261

262262
if (dlerror()) {
263-
// If this does not work (= not build with libswift), we have to explicitly
264-
// load the stdlib.
263+
// If this does not work (= the Swift modules are not linked to the tool),
264+
// we have to explicitly load the stdlib.
265265
auto stdlib = loadSwiftRuntime(Context.SearchPathOpts.RuntimeLibraryPaths);
266266
if (!stdlib) {
267267
CI.getDiags().diagnose(SourceLoc(),

lib/Parse/ParseRegex.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "swift/Parse/SyntaxParsingContext.h"
2121
#include "swift/Syntax/SyntaxKind.h"
2222

23-
// Regex parser delivered via libSwift
23+
// Regex parser delivered via Swift modules.
2424
#include "swift/Parse/ExperimentalRegexBridging.h"
2525
static RegexLiteralParsingFn regexLiteralParsingFn = nullptr;
2626
void Parser_registerRegexLiteralParsingFn(RegexLiteralParsingFn fn) {

lib/SIL/Utils/SILBridging.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ namespace {
2121

2222
bool nodeMetatypesInitialized = false;
2323

24-
// Filled in by class registration in initializeLibSwift().
24+
// Filled in by class registration in initializeSwiftModules().
2525
SwiftMetatype nodeMetatypes[(unsigned)SILNodeKind::Last_SILNode + 1];
2626

2727
}
2828

29-
// Does return null, if libswift is not used, i.e. initializeLibSwift() is
30-
// never called.
29+
// Does return null if initializeSwiftModules() is never called.
3130
SwiftMetatype SILNode::getSILNodeMetatype(SILNodeKind kind) {
3231
SwiftMetatype metatype = nodeMetatypes[(unsigned)kind];
3332
assert((!nodeMetatypesInitialized || metatype) &&
@@ -71,8 +70,8 @@ static void setUnimplementedRange(SwiftMetatype metatype,
7170
}
7271
}
7372

74-
/// Registers the metatype of a libswift class.
75-
/// Called by initializeLibSwift().
73+
/// Registers the metatype of a swift SIL class.
74+
/// Called by initializeSwiftModules().
7675
void registerBridgedClass(BridgedStringRef className, SwiftMetatype metatype) {
7776
nodeMetatypesInitialized = true;
7877

@@ -94,10 +93,10 @@ void registerBridgedClass(BridgedStringRef className, SwiftMetatype metatype) {
9493
}
9594

9695
// Pre-populate the "unimplemented" ranges of metatypes.
97-
// If a specifc class is not implemented yet in libswift, it bridges to an
96+
// If a specifc class is not implemented in Swift yet, it bridges to an
9897
// "unimplemented" class. This ensures that optimizations handle _all_ kind of
9998
// instructions gracefully, without the need to define the not-yet-used
100-
// classes in libswift.
99+
// classes in Swift.
101100
#define VALUE_RANGE(ID) SILNodeKind::First_##ID, SILNodeKind::Last_##ID
102101
if (clName == "UnimplementedRefCountingInst")
103102
return setUnimplementedRange(metatype, VALUE_RANGE(RefCountingInst));

lib/SILOptimizer/PassManager/Passes.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static void runBridgedFunctionPass(BridgedFunctionPassRunFn &runFunction,
243243
runFunction({{f}, {passManager->getLibswiftPassInvocation()}});
244244
}
245245

246-
// Called from libswift's initializeLibSwift().
246+
// Called from initializeSwiftModules().
247247
void SILPassManager_registerFunctionPass(BridgedStringRef name,
248248
BridgedFunctionPassRunFn runFn) {
249249
bridgedPassRunFunctions[getStringRef(name)] = runFn;

lib/SILOptimizer/SILCombiner/SILCombine.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ void SILCombiner::eraseInstIncludingUsers(SILInstruction *inst) {
468468
eraseInstFromFunction(*inst);
469469
}
470470

471-
/// Runs an instruction pass in libswift.
471+
/// Runs a Swift instruction pass.
472472
void SILCombiner::runSwiftInstructionPass(SILInstruction *inst,
473473
void (*runFunction)(BridgedInstructionPassCtxt)) {
474474
Worklist.setLibswiftPassInvocation(&libswiftPassInvocation);
@@ -481,7 +481,7 @@ void SILCombiner::runSwiftInstructionPass(SILInstruction *inst,
481481
static llvm::StringMap<BridgedInstructionPassRunFn> libswiftInstPasses;
482482
static bool passesRegistered = false;
483483

484-
// Called from libswift's initializeLibSwift().
484+
// Called from initializeSwiftModules().
485485
void SILCombine_registerInstructionPass(BridgedStringRef name,
486486
BridgedInstructionPassRunFn runFn) {
487487
libswiftInstPasses[getStringRef(name)] = runFn;

lib/SILOptimizer/SILCombiner/SILCombiner.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class SILCombiner :
109109
/// External context struct used by \see ownershipRAUWHelper.
110110
OwnershipFixupContext ownershipFixupContext;
111111

112-
/// For invoking Swift instruction passes in libswift.
112+
/// For invoking Swift instruction passes.
113113
LibswiftPassInvocation libswiftPassInvocation;
114114

115115
public:

tools/sil-opt/SILOpt.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "swift/AST/SILOptions.h"
2121
#include "swift/Basic/FileTypes.h"
2222
#include "swift/Basic/LLVMInitialize.h"
23-
#include "swift/Basic/InitializeLibSwift.h"
23+
#include "swift/Basic/InitializeSwiftModules.h"
2424
#include "swift/Frontend/DiagnosticVerifier.h"
2525
#include "swift/Frontend/Frontend.h"
2626
#include "swift/Frontend/PrintingDiagnosticConsumer.h"
@@ -505,7 +505,7 @@ int main(int argc, char **argv) {
505505

506506
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SIL optimizer\n");
507507

508-
initializeLibSwift();
508+
initializeSwiftModules();
509509

510510
if (PrintStats)
511511
llvm::EnableStatistics();

0 commit comments

Comments
 (0)