[Freestanding] Use task-to-thread concurrency model.

Defined SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY to describe
whether the standard library will use the task-to-thread model for
concurrency.  It is true only for freestanding non-Darwin stdlibs.

When it is true, SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL is defined
during stdlib compilation of both Swift and C++ sources.

Added an option to LangOptions to specify which concurrency model is
used, either standard or task-to-thread.  When
SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY is true, the model is
specified to be task-to-thread.
This commit is contained in:
Nate Chandler
2022-06-24 14:45:04 -07:00
parent abc21579c9
commit b03904d704
7 changed files with 56 additions and 0 deletions

View File

@@ -1018,6 +1018,14 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.DumpTypeWitnessSystems = Args.hasArg(OPT_dump_type_witness_systems);
if (const Arg *A = Args.getLastArg(options::OPT_concurrency_model)) {
Opts.ActiveConcurrencyModel =
llvm::StringSwitch<ConcurrencyModel>(A->getValue())
.Case("standard", ConcurrencyModel::Standard)
.Case("task-to-thread", ConcurrencyModel::TaskToThread)
.Default(ConcurrencyModel::Standard);
}
return HadError || UnsupportedOS || UnsupportedArch;
}