Initial Task Executor implementation Task(on:), addTask(on:) etc. (#68793)

Co-authored-by: John McCall <rjmccall@gmail.com>
This commit is contained in:
Konrad `ktoso` Malawski
2023-12-12 17:14:24 +09:00
committed by GitHub
parent 7a3e3aea15
commit 828f589be4
68 changed files with 2680 additions and 277 deletions

View File

@@ -714,6 +714,9 @@ struct OperandOwnershipBuiltinClassifier
#include "swift/AST/Builtins.def"
OperandOwnership check(BuiltinInst *bi) { return visit(bi); }
OperandOwnership visitCreateAsyncTask(BuiltinInst *bi, StringRef attr,
int operationIndex);
};
} // end anonymous namespace
@@ -907,25 +910,44 @@ OperandOwnershipBuiltinClassifier
const int PARAMETER_INDEX_CREATE_ASYNC_TASK_FUTURE_FUNCTION = 2;
const int PARAMETER_INDEX_CREATE_ASYNC_TASK_GROUP_FUTURE_FUNCTION = 3;
const int PARAMETER_INDEX_CREATE_ASYNC_TASK_WITH_EXECUTOR_FUNCTION = 3;
const int PARAMETER_INDEX_CREATE_ASYNC_TASK_GROUP_WITH_EXECUTOR_FUNCTION = 4;
OperandOwnership
OperandOwnershipBuiltinClassifier::visitCreateAsyncTask(BuiltinInst *bi,
StringRef attr) {
OperandOwnership OperandOwnershipBuiltinClassifier::visitCreateAsyncTask(
BuiltinInst *bi, StringRef attr, int paramIndex) {
// The function operand is consumed by the new task.
if (&op == &bi->getOperandRef(PARAMETER_INDEX_CREATE_ASYNC_TASK_FUTURE_FUNCTION))
if (&op == &bi->getOperandRef(paramIndex))
return OperandOwnership::DestroyingConsume;
return OperandOwnership::InstantaneousUse;
}
OperandOwnership
OperandOwnershipBuiltinClassifier::visitCreateAsyncTask(BuiltinInst *bi,
StringRef attr) {
return visitCreateAsyncTask(
bi, attr, PARAMETER_INDEX_CREATE_ASYNC_TASK_FUTURE_FUNCTION);
}
OperandOwnership
OperandOwnershipBuiltinClassifier::visitCreateAsyncTaskInGroup(BuiltinInst *bi,
StringRef attr) {
// The function operand is consumed by the new task.
if (&op == &bi->getOperandRef(PARAMETER_INDEX_CREATE_ASYNC_TASK_GROUP_FUTURE_FUNCTION))
return OperandOwnership::DestroyingConsume;
return visitCreateAsyncTask(
bi, attr, PARAMETER_INDEX_CREATE_ASYNC_TASK_GROUP_FUTURE_FUNCTION);
}
return OperandOwnership::InstantaneousUse;
OperandOwnership
OperandOwnershipBuiltinClassifier::visitCreateAsyncTaskWithExecutor(
BuiltinInst *bi, StringRef attr) {
return visitCreateAsyncTask(
bi, attr, PARAMETER_INDEX_CREATE_ASYNC_TASK_WITH_EXECUTOR_FUNCTION);
}
OperandOwnership
OperandOwnershipBuiltinClassifier::visitCreateAsyncTaskInGroupWithExecutor(
BuiltinInst *bi, StringRef attr) {
return visitCreateAsyncTask(
bi, attr, PARAMETER_INDEX_CREATE_ASYNC_TASK_GROUP_WITH_EXECUTOR_FUNCTION);
}
OperandOwnership OperandOwnershipBuiltinClassifier::
@@ -972,6 +994,7 @@ BUILTIN_OPERAND_OWNERSHIP(PointerEscape, AutoDiffProjectTopLevelSubcontext)
// ownership should be 'TrivialUse'.
BUILTIN_OPERAND_OWNERSHIP(ForwardingConsume, ConvertTaskToJob)
BUILTIN_OPERAND_OWNERSHIP(BitwiseEscape, BuildOrdinaryTaskExecutorRef)
BUILTIN_OPERAND_OWNERSHIP(BitwiseEscape, BuildOrdinarySerialExecutorRef)
BUILTIN_OPERAND_OWNERSHIP(BitwiseEscape, BuildComplexEqualitySerialExecutorRef)
BUILTIN_OPERAND_OWNERSHIP(BitwiseEscape, BuildDefaultActorExecutorRef)