Commit b3d31c7
committed
Bridging: Implement bridges required for ongoing AutoDiff changes
In #83926, part of the changes resolving #68944 is submitted. The AutoDiff
closure specialization optimizer pass relies on several bridges not
implemented yet.
This patch introduces these missing bridges. See the list of the changes below.
**AST:**
* Define `.asValueDecl` on each BridgedXXXDecl type that's also a ValueDecl.
* Define `.asNominalTypeDecl` on each BridgedXXXDecl type that's also a NominalTypeDecl.
* Define `.asGenericContext` on each BridgedXXXDecl type that's also a GenericContext.
* `class BridgedSourceFile`:
- Make nullable
- `func addTopLevelDecl(_ decl: BridgedDecl)`
* `class BridgedFileUnit`:
- `func castToSourceFile() -> BridgedNullableSourceFile`
* `class BridgedDecl`:
- `func getDeclContext() -> BridgedDeclContext`
* `class BridgedParamDecl`:
- `func cloneWithoutType() -> BridgedParamDecl`
- `func setInterfaceType(_ type : BridgedASTType)`
* Define `BridgedDecl.setImplicit()` instead of `BridgedParamDecl.setImplicit()`
* `class BridgedGenericContext`:
- `setGenericSignature(_ genSig: BridgedGenericSignature)`
* Change return type of `BridgedEnumDecl.createParsed(/*...*/)` from `BridgedNominalTypeDecl` to `BridgedEnumDecl`
* `class BridgedValueDecl`:
- `func setAccess(_ accessLevel: swift.AccessLevel)`
* `class BridgedNominalTypeDecl`:
- `func addMember(_ member: BridgedDecl)`
* `class BridgedGenericTypeParamDecl`:
- `func createImplicit(declContext: BridgedDeclContext, name: swift.Identifier, depth: UInt, index: UInt, paramKind: swift.GenericTypeParamKind)`
* `class ValueDecl`:
- `var baseIdentifier: swift.Identifier`
* `class NominalTypeDecl`:
- `var declaredInterfaceType: Type`
* `class EnumElementDecl`:
- `var parameterList: BridgedParameterList`
- `var nameStr: StringRef`
* `struct GenericSignature`:
- `var canonicalSignature: CanGenericSignature`
* `struct CanGenericSignature`:
- `var isEmpty: Bool`
- `var genericSignature: GenericSignature`
* `struct Type`:
- `func mapTypeOutOfContext() -> Type`
- `func getReducedType(sig: GenericSignature) -> CanonicalType`
- `func GenericTypeParam_getName() -> swift.Identifier`
- `func GenericTypeParam_getDepth() -> UInt`
- `func GenericTypeParam_getIndex() -> UInt`
- `func GenericTypeParam_getParamKind() -> swift.GenericTypeParamKind`
* `struct CanonicalType`:
- `func SILFunctionType_getSubstGenericSignature() -> CanGenericSignature`
- `func loweredType(in function: SIL.Function) -> SIL.Type`
**SIL:**
* `class Argument`:
- `func replaceAllUsesWith(newArg: Argument)`
* `class BasicBlock`:
- `func insertPhiArgument(atPosition: Int, type: Type, ownership: Ownership, _ context: some MutatingContext) -> Argument`
* `struct Builder`:
- `func createTuple(elements: [Value]) -> TupleInst`
* `protocol Context`:
- `func getTupleType(elements: [AST.Type]) -> AST.Type`
- `func getTupleTypeWithLabels(elements: [AST.Type], labels: [swift.Identifier]) -> AST.Type`
* `class Function`:
- `var sourceFile: BridgedNullableSourceFile`
- `func mapTypeIntoContext(_ type: Type) -> Type`
* `class PartialApplyInst`:
- `var substitutionMap: SubstitutionMap`
* `class SwitchEnumInst`:
- `var numCases: Int`
- `public func getSuccessorForDefault() -> BasicBlock?`
* `Type`:
- `var category: ValueCategory`
- `func getEnumCasePayload(caseIdx: Int, function: Function) -> Type`
- `func mapTypeOutOfContext() -> Type`
- `static func getPrimitiveType(canType: CanonicalType, silValueCategory: ValueCategory) -> Type`
* `struct EnumCase`:
- `let enumElementDecl: EnumElementDecl`
* `struct TupleElementArray`:
- `func label(at index: Int) -> swift.Identifier`
* Define `enum ValueCategory` with `address` and `object` elements1 parent 876fd51 commit b3d31c7
File tree
21 files changed
+561
-11
lines changed- SwiftCompilerSources/Sources
- AST
- SIL
- include/swift
- AST
- SIL
- lib
- ASTGen/Sources/ASTGen
- AST/Bridging
21 files changed
+561
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| |||
118 | 123 | | |
119 | 124 | | |
120 | 125 | | |
| 126 | + | |
| 127 | + | |
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
38 | 52 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
69 | 93 | | |
70 | 94 | | |
71 | 95 | | |
| |||
86 | 110 | | |
87 | 111 | | |
88 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
89 | 117 | | |
90 | 118 | | |
91 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
665 | 672 | | |
666 | 673 | | |
667 | 674 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
58 | 72 | | |
59 | 73 | | |
60 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| |||
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
91 | 99 | | |
92 | 100 | | |
93 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1351 | 1351 | | |
1352 | 1352 | | |
1353 | 1353 | | |
| 1354 | + | |
1354 | 1355 | | |
1355 | 1356 | | |
1356 | 1357 | | |
| |||
1929 | 1930 | | |
1930 | 1931 | | |
1931 | 1932 | | |
| 1933 | + | |
1932 | 1934 | | |
1933 | 1935 | | |
1934 | 1936 | | |
| |||
1953 | 1955 | | |
1954 | 1956 | | |
1955 | 1957 | | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
1956 | 1962 | | |
1957 | 1963 | | |
1958 | 1964 | | |
| |||
0 commit comments