Commit Graph

86 Commits

Author SHA1 Message Date
Slava Pestov
84e2a627ec RequirementMachine: Replace RewriteStep::AbstractTypeWitness with relations 2022-01-13 00:02:31 -05:00
Slava Pestov
abb85fb3ca RequirementMachine: Replace RewriteStep::{Superclass,Concrete}Conformance with relations 2022-01-13 00:02:31 -05:00
Slava Pestov
f06f59a18a RequirementMachine: Generalize relations so they look more like rules 2022-01-13 00:02:31 -05:00
Slava Pestov
220d4882fd RequirementMachine: Move some code to a new PropertyRelations.cpp file 2022-01-13 00:02:31 -05:00
Slava Pestov
f674ca95bd RequirementMachine: Remove the older 'concrete type in domain' hack 2022-01-11 21:43:56 -05:00
Slava Pestov
378231cb97 RequirementMachine: A better trick to tie off type witness recursion
This will replace the 'concrete type in domain' hack. Instead of
finding some other type parameter with the same concrete type and a
compatible starting symbol, this finds a prefix of the original
term. This allows the induced same-type requirement to be described
with a rewrite path.
2022-01-11 21:43:55 -05:00
Slava Pestov
746f4a5a8f RequirementMachine: Throw out rewrite loops not part of the minimization domain
When minimizing a generic signature, we only care about loops
where the basepoint is a generic parameter symbol.

When minimizing protocol requirement signatures in a connected
component, we only care about loops where the basepoint is a
protocol symbol or associated type symbol whose protocol is
part of the connected component.

All other loops can be discarded since they do not encode
redundancies that are relevant to us.
2022-01-05 23:59:46 -05:00
Slava Pestov
9bb497c866 RequirementMachine: Concrete class requirements imply superclass requirements 2022-01-05 22:41:03 -05:00
Slava Pestov
be772cc74b RequirementMachine: Layout requirement implied by superclass is now handled in the property map 2022-01-05 22:41:03 -05:00
Slava Pestov
2737989f8f RequirementMachine: Fix 'relations' where one rule is a suffix of the other 2022-01-05 22:41:03 -05:00
Slava Pestov
5ced0f8c2e RequirementMachine: Avoid some wasted work when re-building the property map 2022-01-05 22:41:03 -05:00
Slava Pestov
380dba1a9f RequirementMachine: Fold PropertyBag::addProperty() into PropertyMap::addProperty() 2022-01-05 22:41:03 -05:00
Slava Pestov
66cf913d68 RequirementMachine: Minimization understands 'relations' among layout requirements
A superclass requirement 'T : C' implies a layout requirement
'T : AnyObject' (if the class is @objc) or 'T : _NativeObject'
(if the class is not @objc).

In the latter case, there might already be a 'T : AnyObject'
requirement, in which case the type parameter 'T' is subject
to two layout requirements:

    T : AnyObject
    T : _NativeObject

The second requirement implies the first however. To encode this
in the world of rewrite loops, we the notion of a 'relation'
between property symbols, and a 'Relation' rewrite step.

Here, the relation is that _NativeObject < AnyObject. Once this
relation is recorded, the Relation rewrite step will transform

    T.[layout: _NativeObject].[layout: AnyObject]

into

    T.[layout: _NativeObject]

and vice versa.

This rewrite step allows us to construct a rewrite loop which
makes the first rewrite rule redundant via the second.
2022-01-04 22:35:58 -05:00
Slava Pestov
b42402bd6f Merge pull request #40646 from slavapestov/rqm-more-validation-test-fixes
RequirementMachine: More fixes for validation tests with -requirement-machine-protocol-signatures=verify
2021-12-21 08:34:57 -05:00
Slava Pestov
5c11f36354 RequirementMachine: Mark rules as conflicting more aggressively 2021-12-20 17:59:31 -05:00
Saleem Abdulrasool
d5174b28df AST: make RequirementMachine/PropertyUnification.cpp build on VS2022
Using the qualified name is subtly different from scoping the function.
Use the latter, which correctly places the function into the namespace,
to enable building with VS2022.
2021-12-19 15:37:24 -08:00
Slava Pestov
40b585f441 RequirementMachine: Use RewriteStep::AbstractTypeWitness in nested type concretization 2021-12-17 10:04:52 -05:00
Slava Pestov
4c83fe851d RequirementMachine: Generalize ConcreteTypeWitness to TypeWitness 2021-12-17 10:04:52 -05:00
Slava Pestov
b1a3d2c6af RequirementMachine: Preserve rewrite path for simplifying substitutions 2021-12-17 10:04:52 -05:00
Slava Pestov
22816b0b41 RequirementMachine: Skip more work in concretizeNestedTypesFromConcreteParent() 2021-12-17 10:04:51 -05:00
Slava Pestov
71194c2c46 RequirementMachine: Use RewriteStep::SameTypeWitness in nested type concretization 2021-12-14 02:16:47 -05:00
Slava Pestov
5a2b19393c RequirementMachine: Refactor PropertyMap::computeConstraintTermForTypeWitness() 2021-12-14 02:16:46 -05:00
Slava Pestov
17664c0c59 RequirementMachine: Use RewriteStep::ConcreteTypeWitness in nested type concretization 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
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
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
d19b15b66c RequirementMachine: Introduce Symbol::Kind::ConcreteConformance 2021-12-06 23:04:46 -05:00
Robert Widmann
22405cefea Plumb the "Is Type Sequence" Bit Through the Surface AST 2021-11-08 13:48:30 -08:00
Slava Pestov
0571b65cb8 RequirementMachine: Move protocol linear order from ProtocolGraph to RewriteContext 2021-10-21 19:00:10 -04:00
Slava Pestov
d00ad536d4 RequirementMachine: Split off PropertyUnification.cpp from PropertyMap.cpp 2021-10-19 18:42:41 -04:00