Construct ArchetypeType from generic params; Construct a Scope for the SIL
function body so TypeAliasDecl for the generic params can be added to ScopeInfo.
Remove an extra '$' in SILPrinter when printing the lookup type for an
archetype_method.
Swift SVN r6219
Reimplement fallthrough using switch's new internal representation of case-to-BB mappings and scope management. Fallthrough can't pass control into a case block with pattern variables, so fallthrough destinations will always be at outermost switch scope, and we can assume the destination block will be emitted in that scope.
Swift SVN r6197
Check that a row in the clause matrix actually binds variables before rescoping it during pattern specialization, instead of always rescoping it if its constructor got specialized. We need to be able to `fallthrough` into scopes without variables, and fallthrough-ing across scopes isn't going to work. A nice side effect of this is that we can kill some useless continuation BBs; we won't use the continuation BB for a specialization scope unless variables actually get bound in that scope.
Swift SVN r6191
These still need to be serialized, because they are one-to-one with the
type's protocol list, but don't actually require any data. Found on
attempting to emit a module for the standard library.
Most of the churn here is moving Interleave.h to a more general STLExtras.h.
Swift SVN r6167
I was emitting cases in the wrong scopes, causing control flow transfers inside the case body to over-release. Oops. Fix that by emitting case bodies last thing before closing out a scope instead of trying to do them on demand.
Swift SVN r6145
UnreachableInst's constructor didn't take a SILLocation. Oops. Fix that, and associate Unreachables emitted due to failed switch coverage with the switch. For missing-return Unreachables, there isn't yet readily available SILLocation info to attach to them, but Anna will fix that soon.
Swift SVN r6132
As clause matrix specialization exposes columns with variable bindings, bind all of the variables in each column to a new box for the variables in that column. (Since only one row out of the matrix ever ends up getting executed, we can share one box for the entire column.) Set up a scope hierarchy following that of the specialized clause matrices, and associate each case with the scope it needs to see all the variables of its fully-destructured pattern clause. Remove our ad-hoc hack for binding ExprPattern implicit variables, and bind them to the column's box too.
Swift SVN r6127
This the first part for improving source location fidelity for types,
changes to follow:
-The Parser will not create any types, it will just create TypeReprs.
-The type checker will create the types by going through TypeReprs.
-IdentifierType will be removed.
Swift SVN r6112
Put emitDecisionTree in charge of setting up case-to-BB mappings as they are needed by leaves of the decision tree. This lets us avoid emitting empty waypoint BBs for default dispatches, cull unreachable case blocks, and will let us handle the scoping of pattern variables relative to case blocks. This new implementation breaks fallthrough, but it's going to need reworking in the face of case variables anyway, so tear out the old implementation and mark it as not implemented for now.
Swift SVN r6094
The idea for now is that this is a SIL-only type used for
representing the storage of a weak or unowned reference.
Having it be its own type is pretty vital for reasonable
behavior in SIL and IR-generation, and it's likely that
this will surface into runtime metadata as well (hence
the mangling).
I've implemented a bunch of things that technically I don't
think are necessary if this stays out of the typechecker,
but it's easier to implement half-a-dozen "recurse into
the child type" methods now that it would be to find them
all later if we change our minds.
Swift SVN r6091
We can figure out the orthogonality, specialization, and dispatch behavior we need using Pattern AST nodes directly. And because we need logic more complex than equality comparison to deal with pattern specialization on type casts, the canonicalization to an abstract pattern constructor form doesn't really save us enough to be worth having another "thing" around.
Swift SVN r6082
Casts to concrete struct types are orthogonal to each other, so when we see one or more "is S" patterns in a switch, we can specialize the clause matrix on each of those types. Casts to class types and casts to or from archetypes are a bit trickier since they don't necessarily refute other types, so our ability to specialize on those cases is limited. With type relationship information, we could refute casts to unrelated classes or concrete types, but that data doesn't survive type-checking right now. For now, when we specialize on a class or archetype cast, conservatively preserve casts to all other classes or concrete types. In the class case, a class cast is at least able to refute non-class casts.
Swift SVN r6057
New format for SILConstant:
'#' sil-dotted-path sil-constant-kind-and-uncurry-level?
sil-dotted-path:
identifier ('.' identifier)*
sil-constant-kind-and-uncurry-level:
'!' sil-constant-kind ('.' sil-constant-uncurry-level)? ('.objc')?
'!' sil-constant-uncurry-level ('.objc')?
'!objc'
sil-constant-kind:
'func' | 'getter' | 'setter' | 'allocator' | 'initializer' | 'oneofelt' \
| 'destroyer' | 'globalaccessor'
Add helper function printFullContext in SILPrinter to generate the fully
qualified dotted path for a given DeclContext; Add parseSILConstant to
SILParser; Testing cases are updated to reflect the new format.
Swift SVN r6055
Since pattern matches semantically occur in source order, we need to exclude rows prior to the first occurrence of a pattern constructor when producing the specialized clause matrix for that constructor. This falls out naturally for constructors that are orthogonal, such as oneof alternatives, but will be required for 'is' patterns, where specializations can overlap due to subtype relationships, as in:
class B {}
class D : B {}
var b:B
var x:Int
switch (b, x) {
case (is B, 0):
foo()
case (is D, 1):
bar()
case (is B, 2):
bas()
}
The 'is D' specialization needs to exclude the first 'is B' pattern.
Swift SVN r6028
ExprPatterns are essentially guards. When exploring the clause matrix we treat the ExprPattern itself as a wildcard, and as we expose leaf ExprPatterns, project their 'expr ~= value' conditions out on the row's guard.
Swift SVN r5997
Lay the groundwork for the pattern matching compilation algorithm from Luc Maranget's "Compiling Pattern Matching to Good Decision Trees". This algorithm organizes the set of patterns to consider into a "clause matrix", where each row corresponds to a pattern and its branch destination, and each column is a destructured subelement of the pattern. The algorithm heuristically chooses a "necessary column" on which to reduce the matrix; for that column, specialized matrices are generated for each constructor form in the column, which are then recursively considered until we reach a termination case where a matrix either has no rows, in which case the match fails, or a matrix's top row always succeeds, in which case we emit a leaf branch to that target.
For this initial version, we stick only to matching tuples and wildcards in naive left-to-right order. We modify the algorithm from the paper to also handle guards: if the first row in the clause matrix is all wildcards, then instead of unconditionally branching to the destination, we evaluate the guard and conditionally branch to the target; on the false branch, we proceed with Maranget's algorithm by removing the guarded row from the matrix.
We don't yet implement variable bindings, ExprPatterns, "is" patterns, or nominal type patterns.
Swift SVN r5993
This partly rolls back <rdar://problem/14221244>, which caused the
ListMaker build to break. We need to mirror the Clang module structure
properly into Swift to actually get entities mangling into the right
contexts.
Swift SVN r5968
Guard against StringRef-uncleanness in APFloat (e.g. rdar://14323230) and hopefully stop the intermittent buildbot failures in some Interpreter tests.
Swift SVN r5951
Instead of stampeding forward generating bogus SIL, raise an error and bail if cast*ObjectPointer are used with non-class values. Fix a test that was applying cast*ObjectPointer to things that were already ObjectPointers.
Swift SVN r5860
Our mangling grammar says that entities should always be mangled with a context, so in cases where we weren't (Clang module contexts and top-level code), do so. Additionally, for ObjC protocols, mangle them into the special "So" context so we can catch global ObjC runtime namespace collisions with them. Fixes <rdar://problem/14221244>.
Swift SVN r5851
This adds builtin types Builtin.VecNxT, where N is a natural number
and T is a builtin type, which map down to the LLVM type <N x T>.
Update varous builtins to support vector arguments, e.g., binary
operations, comparisons, negation. Add InsertElement and
ExtractElement builtins for vectors.
On top of these builtins, add Vec4f and Vec4b structs to the standard
library, which provide 4xFloat and 4xBool vectors, respectively, with
basic support for arithmetic. These are mostly straw men, to be burned
down at our leisure.
Some issues as yet unresolved:
- Comparisons of Vec4f'ss are producing bogus Vec4b's, which I
haven't tracked down yet.
- We still don't support the shuffle builtin, although it should be
easy
- More testing!
Swift SVN r5820
Map BOOL parameters, return types, and properties to swift.Bool in the Clang importer like we map NSString to swift.String. Generalize SIL's handling of type bridging to accommodate Bool bridging in addition to String bridging. Add convertObjCBoolToBool and v.v. entry points for the compiler to use to insert bridging conversions between the two types. Implements <rdar://problem/14271667>.
Swift SVN r5819
I talked to John about parsing patterns today, and because of the magnitude of name-lookup-dependent ambiguities between patterns and expressions, we agreed that at least for a first-pass implementation it makes sense to parse patterns as extensions of the expr grammar and charge name binding with distinguishing patterns from expressions. This gets us out of needing the concept of an "unresolved pattern", at least in the short term.
Swift SVN r5808
A single case block can have one or more 'case ...:' labels. 'case' labels contain patterns instead of exprs. 'default:' is a funny spelling for 'case _:'. Change the CaseStmt representation and rip out all the parsing, type-checking, and SILGen built off the old representation.
Swift SVN r5795
Introduce Pattern subclasses for the 'is T', 'T(<pattern>)', and '<expr>' pattern syntaxes we'll be introducing for pattern-matching "switch" statements. Also add an 'UnresolvedCalLPattern' to act as an intermediate for name lookup to resolve to a nominal type, oneof element, or function call expression pattern. Since we'll need to be able to rewrite patterns like we do expressions, add setters to AST nodes that contain references to subpatterns. Implement some basic walking logic in places we search patterns for var decls, but punt on any more complex type-checking or SILGen derived from these nodes until we actually use them.
Swift SVN r5780