RequirementMachine: Add flags to enable and disable merged associated types

On by default, no change from current behavior. I'm going to try turning
this off (and hopefully ripping it out entirely) once I fix a few bugs.
This commit is contained in:
Slava Pestov
2021-12-08 21:32:41 -05:00
parent cfd8dbf272
commit c1339240cd
4 changed files with 19 additions and 1 deletions

View File

@@ -468,6 +468,9 @@ namespace swift {
RequirementMachineMode EnableRequirementMachine = RequirementMachineMode EnableRequirementMachine =
RequirementMachineMode::Enabled; RequirementMachineMode::Enabled;
/// Enables merged associated type support, which might go away.
bool RequirementMachineMergedAssociatedTypes = true;
/// Enables dumping rewrite systems from the requirement machine. /// Enables dumping rewrite systems from the requirement machine.
bool DumpRequirementMachine = false; bool DumpRequirementMachine = false;

View File

@@ -321,6 +321,14 @@ def requirement_machine_depth_limit : Separate<["-"], "requirement-machine-depth
Flags<[FrontendOption, HelpHidden, DoesNotAffectIncrementalBuild]>, Flags<[FrontendOption, HelpHidden, DoesNotAffectIncrementalBuild]>,
HelpText<"Set the maximum depth before we give up on confluent completion">; HelpText<"Set the maximum depth before we give up on confluent completion">;
def disable_requirement_machine_merged_associated_types : Flag<["-"], "disable-requirement-machine-merged-associated-types">,
Flags<[FrontendOption, HelpHidden, DoesNotAffectIncrementalBuild]>,
HelpText<"Disable merged associated types">;
def enable_requirement_machine_merged_associated_types : Flag<["-"], "enable-requirement-machine-merged-associated-types">,
Flags<[FrontendOption, HelpHidden, DoesNotAffectIncrementalBuild]>,
HelpText<"Enable merged associated types">;
def debug_generic_signatures : Flag<["-"], "debug-generic-signatures">, def debug_generic_signatures : Flag<["-"], "debug-generic-signatures">,
HelpText<"Debug generic signatures">; HelpText<"Debug generic signatures">;

View File

@@ -294,7 +294,8 @@ void RewriteSystem::processMergedAssociatedTypes() {
/// types in RewriteSystem::processMergedAssociatedTypes(). /// types in RewriteSystem::processMergedAssociatedTypes().
void RewriteSystem::checkMergedAssociatedType(Term lhs, Term rhs) { void RewriteSystem::checkMergedAssociatedType(Term lhs, Term rhs) {
// FIXME: Figure out 3-cell representation for merged associated types // FIXME: Figure out 3-cell representation for merged associated types
if (RecordLoops) if (RecordLoops ||
!Context.getASTContext().LangOpts.RequirementMachineMergedAssociatedTypes)
return; return;
if (lhs.size() == rhs.size() && if (lhs.size() == rhs.size() &&

View File

@@ -891,6 +891,12 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
A->getAsString(Args), A->getValue()); A->getAsString(Args), A->getValue());
} }
if (auto A = Args.getLastArg(OPT_enable_requirement_machine_merged_associated_types,
OPT_disable_requirement_machine_merged_associated_types)) {
Opts.RequirementMachineMergedAssociatedTypes
= A->getOption().matches(OPT_enable_requirement_machine_merged_associated_types);
}
Opts.DumpRequirementMachine = Args.hasArg( Opts.DumpRequirementMachine = Args.hasArg(
OPT_dump_requirement_machine); OPT_dump_requirement_machine);
Opts.AnalyzeRequirementMachine = Args.hasArg( Opts.AnalyzeRequirementMachine = Args.hasArg(