Commit Graph

1549 Commits

Author SHA1 Message Date
Adrian Prantl
46caf67a2d More cleanups: Someone implemented Size and Alignment while I wasn't looking :-)
Swift SVN r8121
2013-09-11 23:47:04 +00:00
Doug Gregor
0e3aa19313 Factor the selector-loading logic into its own routine.
When loading a selector in the JIT, we need to call
sel_registerName(). This was manually coded in two places and missed
in a third, so factor it appropriately.


Swift SVN r8082
2013-09-10 22:42:45 +00:00
Adrian Prantl
af562d1696 Debug info: name mangling for composite types containing Archetypes.
Among other things this enables mangled names for tuples.
This adds a pointer to the DeclContext to SILFunction and which is used
to provide the necessary context to the Mangler.
Fixes rdar://problem/14808764 and rdar://problem/14813658.

Swift SVN r8070
2013-09-10 17:04:33 +00:00
Chris Lattner
55200e5274 Now that Module has its own kind field, drop the various module
discriminators from DeclContext.  This is cleaner and should
enable us to drop the alignment of DeclContext (coming next Jordan!)



Swift SVN r8059
2013-09-09 22:43:11 +00:00
Anna Zaks
e36839ca8a [IRGen] Eliminate calls to SILLocation() from IRGen.
Here, the location information does not have to always be available. Use Optional instead of creating an empty location.

Swift SVN r8055
2013-09-09 22:34:01 +00:00
Anna Zaks
369a948248 [SIL] Minor auto-generated SILLocation API rename/refactor.
Swift SVN r8018
2013-09-06 23:57:27 +00:00
Joe Groff
e6309152e5 IRGen: Kill the 'buildFakeType' abomination in GenericMetadataBuilder.
To instantiate the value witness table for generic types, we were instantiating the generic type at () for all of its parameters and hoping for the best. That's insane. Instead, let's use the DeclaredTypeInContext for the generic type so the archetypes actually get usefully bound inside the witnesses. This way, the witness implementations should be independent of generic parameters, so we can also mangle the unbound type into the witness symbols.

Swift SVN r7901
2013-09-04 17:50:12 +00:00
Anna Zaks
440631f86a [SIL] Add the SILLocation hierarchy.
Now we should be ready to start using these.

Swift SVN r7632
2013-08-27 22:16:18 +00:00
Adrian Prantl
cf4e28a70a Debug Info: Change the type caching to be based on the Type instead of
DebugTypeInfo. This is based off the observation that no two types that
share the same canonical type can have different storage and alignment
and has the benefit of being able to locate the debug info for a type
described by a meta type.

Swift SVN r7578
2013-08-26 17:55:14 +00:00
Doug Gregor
484ab259de Switch a few more clients over to Type::findIf().
Swift SVN r7536
2013-08-23 22:28:02 +00:00
Jordan Rose
1b687f3855 Add autolinking metadata output to IRGen.
This currently only works with Clang modules, since there's no way to specify
requirements for a Swift module.

Also, update some tests with a fake Foundation module to make sure they pick
up the fake Foundation adapter instead of the real one.

Swift SVN r7490
2013-08-22 23:20:28 +00:00
John McCall
1ea82afa8e Split ReferenceStorageType into {Weak,Unowned}StorageType.
Swift SVN r7478
2013-08-22 21:36:36 +00:00
Doug Gregor
7c84fd5926 Start detangling archetypes from the interface of generic functions.
This breaks the type-canonicalization link between a generic parameter
type and the archetype to which it maps. Generic type parameter types
are now separate entities (that can eventually be canonicalized) from
archetypes (rather than just being sugar).

Most of the front end still traffics in archetypes. As a step away
from this, allow us to type-check the generic parameter list's types
prior to wiring the generic type parameter declarations to archetypes,
using the new "dependent" member type to describe assocaited
types. The archetype builder understands dependent member types and
uses them to map down to associated types when building archetypes.

Once we have assigned archetypes, we revert the dependent identifier
types within the generic parameter list to an un-type-checked state
and do the type checking again in the presence of archetypes, so that
nothing beyond the generic-parameter-list checking code has to deal
with dependent types. We'll creep support out to other dependent types
elsewhere over time.



Swift SVN r7462
2013-08-22 18:07:40 +00:00
Doug Gregor
6ff6ec9df8 Reduce the reliance of PolymorphicFunctionType on GenericParamList.
This is a baby step toward eliminating GenericParamList from
PolymorphicFunctionType, fixing up the easy callers. No functionality
change.


Swift SVN r7370
2013-08-20 21:18:11 +00:00
Doug Gregor
1ddb34fb71 Factor generic parameters and associated types into their own decl nodes.
Previously, TypeAliasDecl was used for typealiases, generic
parameters, and assocaited types, which is hideous and the source of
much confusion. Factor the latter two out into their own decl nodes,
with a common abstract base for "type parameters", and push these
nodes throughout the frontend.

No real functionality change, but this is a step toward uniquing
polymorphic types, among other things.


Swift SVN r7345
2013-08-19 23:36:58 +00:00
John McCall
eaa6228124 getFragileTypeInfo -> getTypeInfo
I didn't end up going the same way with fragility that I
thought I would at start, and this method name has become a
legacy.

Swift SVN r7340
2013-08-19 23:01:44 +00:00
Joe Groff
b8f9e53c37 IRGen: Emit injection functions for single-payload unions.
When injecting the payload case of the union, pack the payload value into its native representation, and add zeroed extra bits if needed. When injecting the non-payload cases, assign them extra inhabitants if we have them, spilling into setting extra bits if needed.

Swift SVN r7323
2013-08-18 23:55:40 +00:00
Jordan Rose
10f08eea96 Look up standard protocols and types in the standard library, not the TU.
However, the default literal types /are/ looked up in the current TU, so
that they can be changed. It's questionable whether or not this should
include "Slice" and "Dictionary", though.

If the module "swift" isn't available, we fall back to TU-based lookup,
which is necessary to build the standard library itself.

Full list of values now looked up in "swift":
  ArrayBound
  ArrayLiteralConvertible
  Bool
  BuiltinCharacterLiteralConvertible
  BuiltinFloatLiteralConvertible
  BuiltinIntegerLiteralConvertible
  C_ARGC
  C_ARGV
  CharacterLiteralConvertible
  DictionaryLiteralConvertible
  Enumerable
  Enumerator
  false
  FloatLiteralConvertible
  IntegerLiteralConvertible
  LogicValue
  MaxBuiltinFloatType
  MaxBuiltinIntegerType
  Optional (for T?)
  print
  Slice (for T[] but not as default array literal type)
  StringInterpolationConvertible
  StringLiteralConvertible
  true

Swift SVN r7262
2013-08-15 17:32:04 +00:00
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +00:00
Adrian Prantl
5e98accde4 Debug info: Rename createFunction -> emitFunction for consistency.
Swift SVN r7054
2013-08-08 21:20:07 +00:00
John McCall
e9b913fb5b Remove LocalStorageType, make it a kind of SILType.
Swift SVN r6968
2013-08-07 00:22:26 +00:00
Adrian Prantl
bf436fd3cf Debug info: The age of DietDebugInfo(TM) is over. Here come sugared types!
Type aliases are represented as DW_TAG_typedef.

Swift SVN r6959
2013-08-06 22:50:18 +00:00
Adrian Prantl
d27879abfd Debug info: Global variables: emit the human-readable name in addition to
the linkage name.

Swift SVN r6948
2013-08-06 20:26:07 +00:00
John McCall
36aa6c2645 alloc_stack needs to return two values like alloc_box.
The current implementation of dealloc_stack in IR-gen is a
no-op, but that's very much wrong for types with non-trivial
local allocation requirements, e.g. archetypes.  So we need
to be able to do non-trivial code here.  However, that means
modeling both the buffer pointer and the allocated address
in SIL.

To make this more type-safe, introduce a SIL-specific
'[local_storage] T' type that represents the required
allocation for locally storing a T.  alloc_stack now returns
one of those in additon to a *T, and dealloc_stack expects
the former.

IR-gen still implements dealloc_stack as a no-op, but
that's now easy to fix.

Swift SVN r6937
2013-08-06 07:31:41 +00:00
Joe Groff
4316239f5d Kill Builtin.OpaquePointer.
It's not needed by SIL anymore.

Swift SVN r6873
2013-08-03 01:56:06 +00:00
Adrian Prantl
37ca2c3903 Debug info: Emit all imports into the IR.
Swift SVN r6813
2013-08-01 18:47:59 +00:00
Joe Groff
3503ffe4fa IRGen: Set up LinkEntities for protocol witness tables.
We need to handle three cases:

- If a protocol conformance has no associated types, or the associated type witnesses all have statically resolvable metadata, we can expose a *direct* witness table symbol.
- If a protocol conformance has associated types with runtime-instantiated metadata, we need to gate the witness table behind a *lazy* initializer function to fill in the metadata fields.
- If a protocol conformance has associated types where the type or one of its conformances are *dependent* on its parent's generic parameters, we need to instantiate multiple witness tables at runtime.

Swift SVN r6805
2013-08-01 05:25:32 +00:00
Jordan Rose
674a03b085 Replace "oneof" with "union"...everywhere.
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!

Swift SVN r6783
2013-07-31 21:33:33 +00:00
Adrian Prantl
70a0cffe9d silence warning
Swift SVN r6715
2013-07-29 22:10:00 +00:00
Jordan Rose
d9b7c8ad5a Move ClangModule into the ClangImporter library.
This makes it very clear who is depending on special behavior at the
module level. Doing isa<ClangModule> now requires a header import; anything
more requires actually linking against the ClangImporter library.

If the current source file really can't import ClangModule.h, it can
still fall back to checking against the DeclContext's getContextKind()
(and indeed AST currently does in a few places).

Swift SVN r6695
2013-07-29 18:56:35 +00:00
Doug Gregor
3d0c2e2612 Record the protocols and superclass for generic parameters.
This allows us to use getProtocols() rather than getInherited()
wherever we're dealing with generic parameters and associated types.


Swift SVN r6683
2013-07-29 14:27:25 +00:00
Joe Groff
7b5653aa9b IRGen: Remove not-constant-null assertion for known function data.
Until SIL becomes wise enough to optimize away unneeded thin_to_thick operations, it doesn't hold this invariant.

Swift SVN r6662
2013-07-27 00:03:27 +00:00
Doug Gregor
d0f60ab755 Introduce some encapsulation into ProtocolConformance.
Swift SVN r6648
2013-07-26 18:12:17 +00:00
Adrian Prantl
3c9bb55b8d Debug Info: Emit the qualified names for many more ObjC-derived types.
This should get rid of most <null>-types in the DWARF output.

Swift SVN r6512
2013-07-23 21:35:21 +00:00
John McCall
69b64a09ce More canonical type preserving.
Swift SVN r6377
2013-07-19 07:08:38 +00:00
Dmitri Hrybenko
722cc29cab Factor out DeclContext::getParentModule(). This cleans up a few places where
similar loops were duplicated.

No functionality changes.


Swift SVN r6353
2013-07-18 20:41:58 +00:00
Doug Gregor
d42e385371 Remove UnstructuredUnresolvedType.
Swift SVN r6241
2013-07-13 05:10:38 +00:00
John McCall
127a0e66a4 Privatize IRGenSILFunction.
Swift SVN r6173
2013-07-11 21:17:50 +00:00
John McCall
18a9290cbe Add ReferenceStorageType.
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
2013-07-09 08:37:40 +00:00
Adrian Prantl
0c34b57c74 Debug Info: Add basic support for global and stack-allocated variables and
their types.
- DebugTypeInfo holds all type info we need to emit debug information.
- Type info is limited to name, location, and storage size.
- As a side-effect: verbose LLVM IR allocas in debug builds!

Swift SVN r5980
2013-07-03 23:02:04 +00:00
Adrian Prantl
ae9bd9397b Debug Info: Generate scope information for many more builtin/artificial functions.
Swift SVN r5876
2013-06-28 20:05:41 +00:00
Adrian Prantl
ceb32c281c Debug Info: Attach (some of the) functions without sources to their scopes.
Various cleanups.

Swift SVN r5863
2013-06-28 00:52:07 +00:00
Adrian Prantl
c375617244 Address a couple of Joe's comments.
Swift SVN r5858
2013-06-27 23:25:22 +00:00
Adrian Prantl
de32b201d0 Debug Info: Add support for subprograms.
This means that single-stepping in lldb actually works now!

Swift SVN r5828
2013-06-27 00:46:30 +00:00
Doug Gregor
9a5c96a8c1 Introduce basic support for LLVM vectors as builtins.
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
2013-06-26 21:16:36 +00:00
Doug Gregor
cace751e86 Eliminate DeducibleGenericParamType.
The type was used by the old type coercion code; it is no longer relevant.


Swift SVN r5799
2013-06-25 16:32:44 +00:00
Chris Lattner
1040bfec6a In the REPL, allow access to the Builtin module if explicitly imported,
there is no reason to deny it and it could be theoretically useful.


Swift SVN r5779
2013-06-24 16:07:56 +00:00
Joe Groff
e129ad26d0 Recursively consider ObjC protocol conformances.
Propagate ObjC-ness and emit ObjC thunks and metadata for ObjC protocols indirectly conformed to through protocol refinement.

Swift SVN r5680
2013-06-19 05:35:27 +00:00
Joe Groff
514d659ead IRGen: Emit categories for extensions that conform to ObjC protocols.
Swift SVN r5659
2013-06-18 22:37:55 +00:00
Dmitri Hrybenko
49fa6738b9 Remove CPointer<T>, it was almost equivalent to UnsafePointer<T>, but
implemented pointer arithmetic.  Enhanced UnsafePointer<T> to do pointer
arithmetic.

Also: update Clang importer to import T* as UsafePointer<T>, fix standard
library fallout.


Swift SVN r5616
2013-06-17 17:10:08 +00:00