Commit Graph

859 Commits

Author SHA1 Message Date
Slava Pestov
17664c0c59 RequirementMachine: Use RewriteStep::ConcreteTypeWitness in nested type concretization 2021-12-14 02:16:46 -05:00
Slava Pestov
654953cbac RequirementMachine: Introduce RewriteStep::ConcreteTypeWitness 2021-12-14 02:16:46 -05:00
Slava Pestov
c6441c0d89 RequirementMachine: Add machinery for recording concrete type witnesses 2021-12-14 02:16:46 -05:00
Slava Pestov
56fb3cc937 RequirementMachine: Refactor nested type concretization a bit 2021-12-13 18:48:48 -05:00
Slava Pestov
d25b0db75c RequirementMachine: Fold recordConcreteConformanceRules() into concretizeNestedTypesFromConcreteParent() 2021-12-13 18:48:48 -05:00
Slava Pestov
d07812e479 RequirementMachine: Factor out PropertyMap::concretizeTypeWitnessInConformance() 2021-12-13 18:48:48 -05:00
Slava Pestov
7a56ab8c18 RequirementMachine: Mark conflicting rules
This isn't quite right, because we really want the longer (more
specific) of the two rules to be conflicting, not the most-recently
added rule.
2021-12-13 18:48:23 -05:00
Slava Pestov
5ac43b14d2 RequirementMachine: Fully canonicalize substitutions in concrete type rules
Previously we did this when adding new concrete type rules,
but we don't have a complete rewrite system at that point yet,
so there was no guarantee concrete substitution terms would
be canonical.

Now, perform simplification in a post-pass after completion,
at the same time as simplifying rule right hand sides.

Rewrite loops are recorded relating the original rule with the
simplified substitutions.
2021-12-13 18:48:23 -05:00
Slava Pestov
e86fe2706a RequirementMachine: Allow simplified rules to appear in rewrite paths 2021-12-13 18:48:23 -05:00
Slava Pestov
1d5fdc3e62 RequirementMachine: Implement linear order on concrete type symbols with the same concrete type 2021-12-13 16:51:51 -05:00
Slava Pestov
49274ccd64 RequirementMachine: Forgot to set ProtocolComponent::InProgress to true 2021-12-10 17:31:41 -05:00
Slava Pestov
74616dbda5 RequirementMachine: Fix concrete conformances with inherited protocols 2021-12-10 17:31:41 -05:00
Slava Pestov
42e20509e8 RequirementMachine: Better debug output for generating conformances algorithm 2021-12-10 17:31:41 -05:00
Slava Pestov
7f7bf2fa97 RequirementMachine: Fix subtle bug in Knuth-Bendix algorithm
Filter out trivial overlaps where a rule overlaps entirely with
itself before looking at CheckedOverlaps. Otherwise, we'll miss
overlaps where a rule overlaps with itself at a non-zero
position.
2021-12-10 00:49:46 -05:00
Slava Pestov
3138020e5d RequirementMachine: Diagnose non-confluent rewrite systems instead of asserting
We assert when building a rewrite system for an existing generic
signature, or in AbstractGenericSignatureRequest, where there is no
source location.

In RequirementSignatureRequest and InferredGenericSignatureRequest
we now produce a diagnostic.
2021-12-10 00:49:46 -05:00
Slava Pestov
360fbc67bc RequirementMachine: Fix silly mistake in requirement inference
getFirstTypeRepr() asserts unless the RequirementRepr is a SameType
requirement. For type requirements we need to call getSubjectTypeRepr().
2021-12-10 00:49:46 -05:00
Slava Pestov
d7b5dfc644 RequirementMachine: Don't keep protocol requirement machines around 2021-12-10 00:49:45 -05:00
Slava Pestov
c1339240cd RequirementMachine: Add flags to enable and disable merged associated types
On by default, no change from current behavior. I'm going to try turning
this off (and hopefully ripping it out entirely) once I fix a few bugs.
2021-12-08 21:32:42 -05:00
Slava Pestov
cfd8dbf272 Merge pull request #40465 from slavapestov/rqm-protocol-minimization-fixes
RequirementMachine: Protocol requirement signature minimization fixes
2021-12-08 17:19:21 -05:00
Zoe Carver
a46a3c525a Merge pull request #39605 from zoecarver/cxx-interop-import-as-class
[cxx-interop] Implement foreign reference types.
2021-12-08 19:33:50 +00:00
zoecarver
fc3b3a1d71 [cxx-interop] Implement foreign reference types.
This is an expiremental feature to allow an attribute, `import_as_ref`, to import a C++ record as a non-reference-counted reference type in Swift.
2021-12-08 15:35:18 +00:00
Slava Pestov
b999cea0f7 RequirementMachine: Try to minimize away concrete conformances first 2021-12-08 00:53:35 -05:00
Slava Pestov
96bdef9f50 RequirementMachine: Move generating conformances algorithm into its own class 2021-12-08 00:53:35 -05:00
Slava Pestov
86c15ad5c1 RequirementMachine: Generating conformances can reason about concrete conformances now 2021-12-08 00:53:35 -05:00
Slava Pestov
0686cd5aef RequirementMachine: Better assertions for generating conformances 2021-12-08 00:53:35 -05:00
Slava Pestov
2f2249cef1 RequirementMachine: Fix various RewriteSteps to work when re-contextualized
When a rewrite rule is replaced with a path containing ::Adjust, ::Decompose,
::ConcreteConformance or ::SuperclassConformance rewrite steps, the steps
will get a non-zero EndOffset if the original rule appears in a step with a
non-zero EndOffset.

For this reason, these steps must work with a non-zero EndOffset, which
primarily means computing correct offsets into the term being manipulated.
2021-12-08 00:53:35 -05:00
Slava Pestov
044611dddc RequirementMachine: Another cycle-breaking hack for associated type inference 2021-12-08 00:53:35 -05:00
Slava Pestov
47f3341b40 RequirementMachine: Delete loops that don't have rules in empty context
When a rule is replaced by a rewrite path, if the rule is in context
then every step of the replacement step is necessarily always in context.

The only way new rules in empty context can be introduced by a
replacement is if the original rewrite step being replaced had no
context.

Therefore, loops that do not contain rules in empty context will
never provide any additional information during homotopy reduction.
2021-12-08 00:53:35 -05:00
Slava Pestov
1bf6102f1e RequirementMachine: Don't bother normalizing loops 2021-12-08 00:53:35 -05:00
Slava Pestov
0e2fd5ad06 RequirementMachine: Don't call getExistentialLayout() from desugarConformanceRequirement() 2021-12-08 00:53:35 -05:00
Slava Pestov
34cbfd23a5 RequirementMachine: Don't assert if a rewrite system has unresolved rules
This is a source-level error, not an invariant violation. Instead, plumb
a new hadError() flag, which in the future will assert if no diagnostic
was produced.
2021-12-08 00:53:34 -05:00
Slava Pestov
26293c4695 RequirementMachine: Factor out Symbol::withConcreteSubstitutions() 2021-12-07 15:31:47 -05:00
Slava Pestov
99b0be27c7 RequirementMachine: Dump histograms after deleting requirement machine instances 2021-12-07 15:31:47 -05:00
Slava Pestov
417b789069 RequirementMachine: Track maximum value stored in the histogram 2021-12-07 15:31:47 -05:00
Slava Pestov
8e7a9b0f9f RequirementMachine: Add a couple of histograms 2021-12-07 15:31:47 -05:00
Slava Pestov
36a7c4c032 RequirementMachine: Move some code around 2021-12-07 15:31:47 -05:00
Slava Pestov
d1cda342ed RequirementMachine: Property map construction introduces concrete conformance rules 2021-12-07 15:31:47 -05:00
Slava Pestov
2aab4bb773 RequirementMachine: Stub out logic for property map to record rewrite loops
For homotopy reduction to properly deal with new rules introduced
while bulding the property map, rewrite loops must be recorded
relating these to existing rules.
2021-12-07 15:31:45 -05:00
Slava Pestov
e9b50f00f2 RequirementMachine: Record property rule IDs in property bags
For homotopy reduction to properly deal with rewrite rules
introduced by property map construction, we need to keep
track of the original property rules when recording properties
in property bags.

For now, this doesn't even attempt to handle unification or
conflicts; we only record the first rule for each kind of
property on a fixed key.

This isn't actually used for anything yet, except a new
verify pass that runs after property map construction.
2021-12-06 23:04:46 -05:00
Slava Pestov
7427b68785 RequirementMachine: Introduce RewriteStep::ConcreteConformance and ::SuperclassConformance 2021-12-06 23:04:46 -05:00
Slava Pestov
e9b94c1bf1 RequirementMachine: Move some methods from RewriteStep to RewritePathEvaluator
This better encapsulates the evaluator state into a single struct.
2021-12-06 23:04:46 -05:00
Slava Pestov
d19b15b66c RequirementMachine: Introduce Symbol::Kind::ConcreteConformance 2021-12-06 23:04:46 -05:00
Saleem Abdulrasool
349af3707d Merge pull request #40305 from compnerd/semitruck
gardening: make c++98-compat-extra-semi an error
2021-11-30 08:18:36 -08:00
Slava Pestov
77d4a207f8 RequirementMachine: Implement requirement inference 2021-11-29 13:54:15 -05:00
Slava Pestov
291ddd7a31 RequirementMachine: Plumb through the ModuleDecl used for requirement inference 2021-11-29 13:54:15 -05:00
Saleem Abdulrasool
910fbee14e gardening: make c++98-compat-extra-semi an error
This cleans up 90 instances of this warning and reduces the build spew
when building on Linux.  This helps identify actual issues when
building which can get lost in the stream of warning messages.  It also
helps restore the ability to build the compiler with gcc.
2021-11-27 11:40:17 -08:00
Slava Pestov
af9ea678ed RequirementMachine: Implement InferredGenericSignatureRequest 2021-11-19 17:06:00 -05:00
Slava Pestov
42c0a28ad7 RequirementMachine: Add RequirementMachine::initWithWrittenRequirements() 2021-11-19 15:48:28 -05:00
Slava Pestov
1c78b0466b RequirementMachine: Clean up the RequirementMachine::initWith*() methods a bit 2021-11-19 15:48:15 -05:00
Slava Pestov
f0899e3acb RequirementMachine: Make some entry points in RequirementLowering.cpp public 2021-11-19 15:48:07 -05:00