[AutoDiff upstream] [SIL] Add differentiable function instructions.

Add `differentiable_function` and `differentiable_function_extract`
instructions.

`differentiable_function` creates a `@differentiable` function-typed
value from an original function operand and derivative function operands
(optional).

`differentiable_function_extract` extracts either the original or
derivative function value from a `@differentiable` function.

The differentiation transform canonicalizes `differentiable_function`
instructions, filling in derivative function operands if missing.

Resolves TF-1139 and TF-1140.
This commit is contained in:
Dan Zheng
2020-03-22 11:50:36 -07:00
parent 603db8c954
commit cc7e9fc39e
21 changed files with 762 additions and 5 deletions

View File

@@ -875,6 +875,8 @@ InlineCost swift::instructionInlineCost(SILInstruction &I) {
case SILInstructionKind::SelectValueInst:
case SILInstructionKind::KeyPathInst:
case SILInstructionKind::GlobalValueInst:
case SILInstructionKind::DifferentiableFunctionInst:
case SILInstructionKind::DifferentiableFunctionExtractInst:
case SILInstructionKind::DifferentiabilityWitnessFunctionInst:
#define COMMON_ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name) \
case SILInstructionKind::Name##ToRefInst: \