Erik Eckstein
7eedc18965
Swift AST: add ConstructorDecl.isInheritable
...
and make `AbstractFunctionDecl.isOverridden` final
2025-12-05 11:34:54 +01:00
Daniil Kovalev
b73676ee68
Bridging: Implement several optional- and enum-related bridges ( #85756 )
...
In #85757 , part of the changes resolving #68944 is submitted. Most
bridges required for #85757 were previously implemented in #84648 . After
#82653 got merged, we have demand for several new bridges in order to
properly support optimizing derivatives of throwing functions via
AutoDiff Closure Specialization pass.
This patch implements:
- **AST:**
* `var optionalObjectType: Type` property of `Type` struct
* `var optionalType: Type` property of `Type` struct
- **SIL:**
* `let name: StringRef` property of `EnumCase` struct
* `func createOptionalSome(operand: Value, type: Type) -> EnumInst`
method of `Builder`
* `func createOptionalNone(type: Type) -> EnumInst` method of `Builder`
2025-12-04 08:26:44 +00:00
Arnold Schwaighofer
36a3c6e611
Merge pull request #85644 from aschwaighofer/wip_embedded_exits_with_eriks_changes_v1
...
[embedded] Fix associated type conformances for specialized witness tables
2025-12-01 16:40:31 -08:00
eeckstein
9304ce951c
Merge pull request #85707 from eeckstein/embedded-witness-method-specialization
...
embedded: change the function representation of directly called witness methods
2025-12-01 09:36:45 +01:00
Erik Eckstein
4920ace11e
AST: add enum FunctionTypeRepresentation and TypeProperties.functionTypeRepresentation
2025-11-26 16:23:46 +01:00
Erik Eckstein
a371aecb95
AST: add var ClassDecl.isForeign
2025-11-21 16:33:06 +01:00
Erik Eckstein
1486d009b0
AST: add var ProtocolDecl.isMarkerProtocol
2025-11-20 10:56:05 -08:00
Daniil Kovalev
a172134162
Address review comments
2025-11-18 01:46:49 +03:00
Daniil Kovalev
c12819f881
Address review comments
2025-11-17 14:13:09 +03:00
Daniil Kovalev
c1f4bcfd98
Merge branch 'main' into users/kovdan01/ast-bridges-for-autodiff-closure-spec
2025-11-17 10:22:24 +03:00
Slava Pestov
819738c83e
AST: Rename mapTypeIntoContext() => mapTypeIntoEnvironment(), mapTypeOutOfContext() => mapTypeOutOfEnvironment()
2025-11-12 14:48:19 -05:00
Daniil Kovalev
f0bf57a269
Resolve merge conflicts & address review comments
2025-11-10 19:18:25 +03:00
Daniil Kovalev
72431dbd2d
Merge branch 'main' into users/kovdan01/ast-bridges-for-autodiff-closure-spec
2025-11-10 18:46:04 +03:00
Aidan Hall
c7af4c584e
Bridging: APIs for PackSpecialization pass
2025-10-26 13:44:34 +00:00
Daniil Kovalev
7c90f03032
Merge branch 'main' into users/kovdan01/ast-bridges-for-autodiff-closure-spec
2025-10-15 13:17:36 +03:00
Daniil Kovalev
02fcd218d7
Address review comments
2025-10-15 05:14:15 +03:00
Andrew Trick
0d496b5404
SwiftCompilerSources: bridge Type.unsafePointerElementType
2025-10-07 10:44:42 -07:00
Daniil Kovalev
b3d31c7d51
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` elements
2025-10-06 17:56:38 +03:00
Erik Eckstein
65d69fe965
SIL/AST: add some APIs
...
* `GenericSignature.isEmpty`
* `Builder.emitDestroy`
* `Function.abi`
* `KeyPathInst.substitutionMap`
* `KeyPathInst.hasPattern`
2025-09-04 08:15:44 +02:00
Erik Eckstein
0a8c60290f
AST: add Type.interfaceTypeOfArchetype and some related APIs
2025-08-26 16:38:19 +02:00
Erik Eckstein
0a953b60ca
SIL/AST: add var InjectEnumAddrInst.element and var EnumElementDecl.hasAssociatedValues
2025-08-03 11:06:15 +02:00
Anthony Latsis
6eb5d7d857
Bridging: Bridge swift::SourceLoc directly
2025-07-15 21:33:06 +01:00
eeckstein
1d3895610e
Merge pull request #82349 from eeckstein/alloc-box-to-stack
...
Optimizer: re-implement and improve the AllocBoxToStack pass
2025-06-21 07:28:18 +02:00
Erik Eckstein
1f304e5609
SIL: improve APIs for Box types
...
* move `isBox` from `SIL.Type` to `TypeProperties` to make it also available for AST types
* add `BoxFieldsArray.isMutable(fieldIndex:)`
2025-06-20 08:14:59 +02:00
Erik Eckstein
d025e9f7a5
SIL: add var Argument.decl: ValueDecl?
2025-06-20 08:14:58 +02:00
Anthony Latsis
722bc0f086
ASTBridging: Bridge swift::DiagID directly
2025-06-19 12:29:27 +01:00
Valeriy Van
949c2bad67
Fix some typos in SwiftCompilerSources/Sources
2025-06-08 11:22:45 +03:00
Pavel Yaskevich
202907d0f6
[CompilerSources] Register using declaration
2025-05-30 15:52:18 -07:00
Erik Eckstein
28985f4d41
Swift AST: add var EnumDecl.hasRawType
2025-05-29 08:12:17 +02:00
Erik Eckstein
dbd0af063c
AST: add some BuiltinFixedArray and IntegerType APIs
2025-05-15 21:29:02 +02:00
Erik Eckstein
5dc71aa0a5
AST/SIL: support source location in diagnostics for de-serialized debug info
...
Diagnostics only work with `SourceLoc` which is basically a pointer into a buffer of the loaded source file.
But when debug info is de-serialized, the SIL `Location` consists of a filename+line+column.
To "convert" this to a `SourceLoc`, the file must be loaded.
This change adds `DiagnosticEngine.getLocationFromExternalSource` for this purpose.
Also, the new protocol `ProvidingSourceLocation` - to which `SourceLoc` and `Location` conform - help to generalize the helper struct `Diagnostic` and make this "conversion" happen automatically.
2025-05-14 11:43:47 +02:00
eeckstein
66e07f04ac
Merge pull request #81441 from eeckstein/vector_base_addr
...
SIL: introduce the `vector_base_addr` instruction and use it in `InlineArray`
2025-05-13 06:52:42 +02:00
Max Desiatov
5dd244c345
NFC: Fix comment typos in Type.swift ( #81442 )
...
`performas a global` -> `performs a global`
`canoncial` -> `canonical`
2025-05-12 11:26:24 -07:00
Erik Eckstein
ff2341e83a
Swift AST/SIL: add Type APIs for Builtin.FixedArray
...
* `Type.isBuiltinFixedArray`
* `Type.builtinFixedArrayElementType`
2025-05-12 19:24:31 +02:00
Erik Eckstein
aacb4d458f
Swift AST: add Type.hasDynamicSelf
2025-05-08 19:21:08 +02:00
Meghana Gupta
5395721a20
Bridge getSwiftMutableSpanDecl() and isBuiltinType()
2025-04-30 13:40:12 -07:00
Slava Pestov
b911b80725
AST: Remove unused and incorrect BridgedASTType::subst()
2025-04-28 13:47:53 -04:00
Erik Eckstein
fd17b7e9f1
Swift AST: add GenericSignature.mapTypeIntoContext
2025-04-18 06:58:38 +02:00
Erik Eckstein
9aa61e127a
Swift AST: add some Type APIs
2025-04-18 06:58:38 +02:00
Erik Eckstein
2020897459
Swift AST: add some Decl APIs
...
* in `Decl`: `var parent: Decl?`
* in `ProtocolDecl`: `var requiresClass: Bool`
2025-04-18 06:58:38 +02:00
Erik Eckstein
75152f27be
Swift AST: make Conformance hashable and rename var proto -> var protocol
2025-04-18 06:58:38 +02:00
Erik Eckstein
1c9a7cd562
SwiftCompilerSources: refactor DiagnosticEngine
...
* move it from the SIL to the AST module (where it belongs)
* change the signature of `diagnose` from `diagnose(location, .some_error)` to `diagnose(.some_error, at: location)`
* add an overload to allow passing a `SIL.Location` directly to `diagnose`
* add a `Diagnostic : Error` utility struct which allows throwing a `Diagnostic`
2025-04-18 06:58:38 +02:00
Artem Chikin
281f84da0f
[Compile Time Values] Rewrite the 'Diagnose Unknown Compile Time Values' diagnostic pass in Swift
2025-03-28 10:30:07 -07:00
Erik Eckstein
ac55dae26c
AST: add the possibility to compare SubstitutionMaps
2025-03-26 08:45:38 +01:00
Erik Eckstein
67556cfbf4
SIL: add some Function APIs
...
* `var wasDeserializedCanonical`
* `var genericSignature`
* `func mapTypeIntoContext`
* `var forwardingSubstitutionMap`
2025-03-26 08:45:07 +01:00
Erik Eckstein
b39a6cdd22
AST: add var GenericSignature.genericParameters
2025-03-26 07:30:11 +01:00
Erik Eckstein
42bba8f484
AST: add some Declaration APIs
...
* `var Declaration.parentModule`
* `var AbstractFunctionDecl.isOverridden`
2025-03-26 07:30:11 +01:00
Erik Eckstein
e1af31bc19
AST: add var Conformance.rootConformance
2025-03-26 07:30:10 +01:00
Erik Eckstein
d523e303c3
SIL/AST: move some SIL.Type APIs to the TypeProperties protocol which makes them also available for AST.Type and AST.CanonicalType
2025-03-26 07:30:10 +01:00
Slava Pestov
8bcd09aaa4
SIL: Preliminary refactoring of SILWitnessTable::AssociatedConformanceWitness
...
The Protocol field isn't really necessary, because the conformance
stores the protocol. But we do need the substituted subject type
of the requirement, just temporarily, until an abstract conformance
stores its own subject type too.
2025-03-18 19:38:42 -04:00