Skip to content

Commit 317743a

Browse files
committed
RequirementMachine: Rename GeneratingConformances => MinimalConformances
1 parent d72500d commit 317743a

File tree

8 files changed

+94
-93
lines changed

8 files changed

+94
-93
lines changed

lib/AST/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ add_swift_host_library(swiftAST STATIC
7474
ProtocolConformance.cpp
7575
RawComment.cpp
7676
RequirementEnvironment.cpp
77-
RequirementMachine/GeneratingConformances.cpp
7877
RequirementMachine/GenericSignatureQueries.cpp
7978
RequirementMachine/HomotopyReduction.cpp
8079
RequirementMachine/KnuthBendix.cpp
80+
RequirementMachine/MinimalConformances.cpp
8181
RequirementMachine/PropertyMap.cpp
8282
RequirementMachine/PropertyUnification.cpp
8383
RequirementMachine/RequirementLowering.cpp

lib/AST/RequirementMachine/Debug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ enum class DebugFlags : unsigned {
4141
/// Print debug output from the homotopy reduction algorithm.
4242
HomotopyReduction = (1<<6),
4343

44-
/// Print debug output from the generating conformances algorithm.
45-
GeneratingConformances = (1<<7),
44+
/// Print debug output from the minimal conformances algorithm.
45+
MinimalConformances = (1<<7),
4646

4747
/// Print debug output from the protocol dependency graph.
4848
ProtocolDependencies = (1<<8),

lib/AST/RequirementMachine/HomotopyReduction.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@
4646
//
4747
// Also, for a conformance rule (V.[P] => V) to be redundant, a stronger
4848
// condition is needed than appearing once in a loop and without context;
49-
// the rule must not be a _generating conformance_. The algorithm for computing
50-
// a minimal set of generating conformances is implemented in
51-
// GeneratingConformances.cpp.
49+
// the rule must not be a _minimal conformance_. The algorithm for computing
50+
// minimal conformances is implemented in MinimalConformances.cpp.
5251
//
5352
//===----------------------------------------------------------------------===//
5453

@@ -129,7 +128,7 @@ RewriteLoop::findRulesAppearingOnceInEmptyContext(
129128
/// explicit bit to all other rules appearing in empty context within the same
130129
/// loop.
131130
///
132-
/// When computing generating conformances we prefer to eliminate non-explicit
131+
/// When computing minimal conformances we prefer to eliminate non-explicit
133132
/// rules, as a heuristic to ensure that minimized conformance requirements
134133
/// remain in the same protocol as originally written, in cases where they can
135134
/// be moved between protocols.
@@ -359,17 +358,18 @@ isCandidateForDeletion(unsigned ruleID,
359358
return true;
360359

361360
// Protocol conformance rules are eliminated via a different
362-
// algorithm which computes "generating conformances".
361+
// algorithm which computes "minimal conformances". This runs between
362+
// two passes of homotopy reduction.
363363
//
364364
// The first pass skips protocol conformance rules.
365365
//
366366
// The second pass eliminates any protocol conformance rule which is
367-
// redundant according to both homotopy reduction and the generating
367+
// redundant according to both homotopy reduction and the minimal
368368
// conformances algorithm.
369369
//
370-
// Later on, we verify that any conformance redundant via generating
370+
// Later on, we verify that any conformance redundant via minimal
371371
// conformances was also redundant via homotopy reduction. This
372-
// means that the set of generating conformances is always a superset
372+
// means that the set of minimal conformances is always a superset
373373
// (or equal to) of the set of minimal protocol conformance
374374
// requirements that homotopy reduction alone would produce.
375375
if (rule.isAnyConformanceRule()) {
@@ -392,11 +392,11 @@ isCandidateForDeletion(unsigned ruleID,
392392
/// 1) First, rules that are not conformance rules are deleted, with
393393
/// \p redundantConformances equal to nullptr.
394394
///
395-
/// 2) Second, generating conformances are computed.
395+
/// 2) Second, minimal conformances are computed.
396396
///
397397
/// 3) Finally, redundant conformance rules are deleted, with
398398
/// \p redundantConformances equal to the set of conformance rules that are
399-
/// not generating conformances.
399+
/// not minimal conformances.
400400
Optional<unsigned> RewriteSystem::
401401
findRuleToDelete(const llvm::DenseSet<unsigned> *redundantConformances,
402402
RewritePath &replacementPath) {
@@ -524,15 +524,15 @@ void RewriteSystem::minimizeRewriteSystem() {
524524
// First pass: Eliminate all redundant rules that are not conformance rules.
525525
performHomotopyReduction(/*redundantConformances=*/nullptr);
526526

527-
// Now find a minimal set of generating conformances.
527+
// Now compute a set of minimal conformances.
528528
//
529529
// FIXME: For now this just produces a set of redundant conformances, but
530-
// it should actually output the canonical generating conformance equation
531-
// for each non-generating conformance. We can then use information to
530+
// it should actually output the canonical minimal conformance equation
531+
// for each non-minimal conformance. We can then use information to
532532
// compute conformance access paths, instead of the current "brute force"
533533
// algorithm used for that purpose.
534534
llvm::DenseSet<unsigned> redundantConformances;
535-
computeGeneratingConformances(redundantConformances);
535+
computeMinimalConformances(redundantConformances);
536536

537537
// Second pass: Eliminate all redundant conformance rules.
538538
performHomotopyReduction(/*redundantConformances=*/&redundantConformances);

0 commit comments

Comments
 (0)