Slava Pestov
273c4b2b1a
RequirementMachine: Convert to new assertions
2024-06-22 08:53:22 -04:00
Evan Wilde
250082df25
[NFC] Reformat all the LLVMs
...
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f
[NFC] add llvm namespace to Optional and None
...
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".
I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Slava Pestov
919101d4b3
RequirementMachine: Remove old minimal conformances algorithm
2022-07-06 11:57:21 -04:00
Josh Soref
81d3ad76ac
Spelling ast ( #42463 )
...
* spelling: accessor
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: accommodates
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: argument
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: associated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: availability
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: available
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: belongs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: bookkeeping
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: building
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clazz
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clonable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: closure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: concatenated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conformance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: context
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conversion
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: correspondence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declarations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declared
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: defining
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: delayed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: dependency
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: deployed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: descendants
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnose
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnostic
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: equitable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: evaluation
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: exclusivity
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existential
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: explicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: expressed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: for
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: foreign
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: function
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: identifier
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: implicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: indices
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: information
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: instance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interchangeable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interface
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: introduced
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: invalid
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: kind-in
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: least
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: library
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: location
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: namespace
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: necessary
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: nonexistent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: not
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: number
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: obtains
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: occurs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: opaque
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: overridden
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: parameter
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: precede
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: preceding
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: property
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: protocol
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: qualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recognized
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recursively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: references
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: relaxing
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: represented
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: request
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirements
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: retrieve
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: returned
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfied
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfy
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: siblings
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: simplified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: something
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: source
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specializations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specially
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: statement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: stripped
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: structure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: substitution
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: the
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transform
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transformed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transitively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transparent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: typecheck
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unknown
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unlabeled
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unqualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: whether
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: with
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com >
2022-04-21 12:57:16 -07:00
Slava Pestov
5bff2a02c5
RequirementMachine: Rename RewritePath::getRulesInEmptyContext() to findRulesAppearingOnceInEmptyContext()
2022-04-04 12:41:57 -04:00
Slava Pestov
deaeb36f57
RequirementMachine: Make RewritePath::getRulesInEmptyContext() const
2022-04-04 12:41:57 -04:00
Slava Pestov
86561b8865
RequirementMachine: Generalize RewritePath::replaceRuleWithPath() to replaceRulesWithPaths()
2022-03-15 13:35:34 -04:00
Slava Pestov
f810d3f388
RequirementMachine: Optimize Rewrite{Path,Loop}::computeNormalForm()
2022-03-15 13:35:34 -04:00
Slava Pestov
4df7bf91c5
RequirementMachine: Pack RewriteStep more tightly
2022-03-15 13:35:34 -04:00
Slava Pestov
a259844803
RequirementMachine: Record those rewrite loops involving protocol typealiases
2022-03-11 17:28:01 -05:00
Holly Borla
b5d7a0152b
[RequirementMachine] Factor the 'rules once in empty context' computation out
...
into a method on RewritePath.
2022-03-09 16:17:55 -08:00
Slava Pestov
a0c3045709
RequirementMachine: Relax criterion for deleting a useless loop
...
Distinguish a loop with elimination candidates, which are rules
appearing in empty context and exactly once, from a useful loop,
which contains at least one rule in empty context (but the same
rule might appear more than once).
Normalizing a useful loop might produce a loop with elimination
candidates, but normalizing a useless loop never does.
2022-03-08 22:47:22 -05:00
Slava Pestov
713e0a4a6d
RequirementMachine: Reduce replacement paths for redundant rules to left-canonical normal form
...
This brings back the code I deleted in 1bf6102f1e
but repurposes it to simplify the replacement paths recorded for
redundant rewrite rules only.
2022-03-08 22:47:22 -05:00
Slava Pestov
991fe1dbd8
RequirementMachine: Preserve replacement paths for redundant rules
2022-02-16 16:28:08 -05:00
Slava Pestov
426df360b0
RequirementMachine: More elimination order tweaking
...
- Prefer rewrite loops not involving Decompose
- Prefer more deeply nested concrete types
2022-02-15 04:02:46 -05:00
Slava Pestov
eab371d8c5
RequirementMachine: Simplify RewriteStep::Decompose
...
The inverted form no longer has to replace substitutions; we use
the inverted form of DecomposeConcrete for that. So just assert
that the substitutions are equal.
2022-02-15 04:02:46 -05:00
Slava Pestov
aeceda3cfa
RequirementMachine: Introduce RewriteLoop::getProjectionCount()
2022-02-09 10:45:09 -05:00
Slava Pestov
2c355de71b
RequirementMachine: Introduce RewriteStep::{Left,Right}ConcreteProjection
2022-02-07 08:20:59 -05:00
Slava Pestov
7e4a5876d1
RequirementMachine: Introduce RewriteStep::DecomposeConcrete
2022-02-07 08:20:58 -05:00
Slava Pestov
d8aa79c5e5
RequirementMachine: Rename RewriteStep::AdjustConcreteType to ::PrefixSubstitutions
2022-02-07 08:20:58 -05:00
Slava Pestov
a11151a7e3
RequirementMachine: Fix up some comments
2022-02-04 22:49:28 -05:00
Slava Pestov
3790bba7a0
RequirementMachine: Verify loops immediately when they're added to aid debugging
2022-02-04 22:48:35 -05:00
Slava Pestov
6895fa0f9b
RequirementMachine: Remove dead RewriteStep::applyConcreteConformance() declaration
2022-02-04 22:48:05 -05:00
Slava Pestov
bdbf50e1e3
RequirementMachine: Replace RewriteStep::SameTypeWitness with a relation
2022-01-13 19:14:52 -05:00
Slava Pestov
6064671abd
RequirementMachine: Replace RewriteStep::ConcreteTypeWitness with relations
2022-01-13 18:01:15 -05:00
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
3d2492fe56
RequirementMachine: Rename RewriteStep::ApplyRewriteRule to RewriteStep::Rule
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
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
7148aea7ed
RequirementMachine: Rename RewriteStep::RuleID to RewriteStep::Arg
...
It's used to store more than just the rule ID. However, add a
getRuleID() method that also asserts that Kind is ApplyRewriteRule
for readability.
2022-01-04 22:35:58 -05:00
Slava Pestov
8bf1bc283c
RequirementMachine: Rename A/B stack to primary/secondary stack
2022-01-04 22:35:58 -05:00
Slava Pestov
2bca132380
RequirementMachine: Introduce RewriteStep::AbstractTypeWitness
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
d72500db0d
RequirementMachine: Cache result of RewriteLoop::findRulesAppearingOnceInEmptyContext()
2021-12-17 10:04:51 -05:00
Slava Pestov
7708c75184
RequirementMachine: Introduce RewriteStep::SameTypeWitness
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
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
1bf6102f1e
RequirementMachine: Don't bother normalizing loops
2021-12-08 00:53:35 -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
49aaedeedb
RequirementMachine: Fix RewriteStep::AdjustConcreteType
...
Using StartOffset to encode the prefix length is wrong, because
then we get an invalid rewrite step after replaceRuleWithPath().
Instead, encode the prefix length in the RuleID field.
2021-11-01 22:51:59 -04:00
Slava Pestov
7d2b22a352
RequirementMachine: Fix runtime crash with MSVC
...
Signed vs unsigned bitfields strike again.
2021-10-27 01:28:24 -04:00
Slava Pestov
450c7c268a
RequirementMachine: Split off RewriteLoop.cpp from HomotopyReduction.cpp
2021-10-27 01:28:24 -04:00