Commit Graph

944 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
0fe6d45e62 [IDE] Introduce semantic annotation functionality and test.
Swift SVN r8618
2013-09-25 01:35:36 +00:00
Doug Gregor
56edc42dc8 IRGen for Objective-C subscript thunks.
Swift SVN r8617
2013-09-25 01:14:54 +00:00
Dmitri Hrybenko
3f15ea9f88 AST printing tests: move error cases to a separate file
This allows us to serialize the non-error cases, and then print the
deserialized AST (not implemented yet).


Swift SVN r8615
2013-09-24 23:58:43 +00:00
Greg Parker
9fe5f880c4 Objective-C Class<Proto> is unretained just like unqualified Class.
Swift SVN r8613
2013-09-24 23:18:55 +00:00
Doug Gregor
e6f47a6e2d IRGen for dynamic subscripting operations.
Swift SVN r8612
2013-09-24 22:28:36 +00:00
Joe Groff
014f270516 SIL: Have project_existential_ref project to a protocol Self archetype.
This mirrors the behavior of project_existential and simplifies some special cases in SILGen. It unfortunately makes dynamic_lookup sequences a bit noisier because of the need to explicitly cast the projection from DynamicLookup.Self to Builtin.ObjCPointer, but I think this modeling is more solid and will fit better with my planned redesign of archetype_method/protocol_method.

Swift SVN r8572
2013-09-23 21:57:12 +00:00
Anna Zaks
6ad7454df0 [SIL DCE] Chain optimization rounds to ensure true/false folds.
This is an ad-hoc, temporary solution.

(TODO: More tests with real 'true' & 'false' after they get deserialized
from stdlib and inlined.)

Swift SVN r8569
2013-09-23 20:57:18 +00:00
Joe Groff
9e54a69016 SIL: Allow RefToObjectPointer and ObjectPointerToRef to cast to/from Builtin.ObjCPointer.
Swift SVN r8558
2013-09-23 16:20:29 +00:00
Doug Gregor
9b0525bc70 Objective-C "Class" (which maps to DynamicLookup.metatype) is unretained.
Swift SVN r8554
2013-09-23 15:13:56 +00:00
Dmitri Hrybenko
f9d1923c0e Add a basic AST printing test
AST printing is important for Swift, but we did not have any tests for it.

rdar://15042725


Swift SVN r8541
2013-09-21 03:36:07 +00:00
John McCall
3ef23d6268 [weak] variables have Optional type.
This contains one significant difference from the design:
previously, you declared:
  var [weak] x : NSObject
and the type of 'x' was implicitly Optional.  This change
in the formal type proved problematic in a number of ways,
and Joe made the excellent suggestion to eliminate it:
so now you have to declare:
  var [weak] x : NSObject?
and [weak] is just a kind of modifier on the storage of the
optional value.  You could argue that this is somewhat
pedantic, but I think it restores a lot of consistency to
the model.

Swift SVN r8538
2013-09-21 00:26:17 +00:00
John McCall
22a3574654 Use copy_value and destroy_value when destroying loadable
aggregates in SIL-gen.  Leave the old expanded paths around
as emitLoweredCopyValue and emitLoweredDestroyValue.

Swift SVN r8535
2013-09-20 23:33:40 +00:00
Doug Gregor
903a4d2ea1 Implement SILGen/IRGen support for dynamic lookup that resolves to properties.
Swift SVN r8521
2013-09-20 22:15:03 +00:00
Adrian Prantl
c7801fc114 LIT: Hack the %libdir expansion once more, so it works with
- configure+make
- cmake+make
and (drumroll)
- cmake+xcode
The problem is that in XCode, swift_lib_dir will expand to
"lib/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)". So apparently the only
safe solution is to use $(dirname %swift)/../lib.

Swift SVN r8520
2013-09-20 22:14:29 +00:00
Anna Zaks
5b71c8dcc5 [SIL] Propagate basic block arguments.
Propagate/remove basic block input values when all predecessors supply
the same arguments. Another optimization needed to fold 'true'.

TODO: I need to figure out additional surcumstances in which to to trigger this
optimization and if we need to rerun CCP after this. (For example, we need to
rerun this after constant folding the terminator in order to fold 'true'.)

Swift SVN r8518
2013-09-20 21:53:28 +00:00
Joe Groff
5d8a7ff9e7 Allow multiple comma-separated enum elements in a 'case' decl.
Introduce an EnumCaseDecl for source fidelity to track the 'case' location and ordering of EnumElementDecls. Parse a comma-separated list of EnumElementDecls after a 'case' token.

Swift SVN r8509
2013-09-20 19:51:13 +00:00
Adrian Prantl
9f84b92aa4 Mangler: Implement hierarchical lookup of generic parameters for the case
where we don't find an ArcheType in the local context.
Fixes rdar://problem/15033772

Swift SVN r8507
2013-09-20 19:00:29 +00:00
Doug Gregor
bc3f655105 s/constructor/init in a few more places.
Swift SVN r8504
2013-09-20 18:37:15 +00:00
Anna Zaks
4beee47c83 [SIL DCE] Reapply r8471: Constant fold SwitchUnionInst and SwitchIntInst.
Includes the fix for the crash - pass the payload as an argument to the
successor blocks when available. (By looking at the documentation and the
existing test cases, successors of SwitchIntInst do not take arguments.)

Swift SVN r8502
2013-09-20 17:53:42 +00:00
Anna Zaks
3fef691010 [SIL DCE] revert folding of SwitchUnionInst and SwitchIntInst (r8471)
Until further investigation..
This change triggered a test failure (which was masked at the time).

Swift SVN r8497
2013-09-20 16:25:09 +00:00
Doug Gregor
f2b0944e0b Map Objective-C's Class to DynamicLookup.metatype.
Swift SVN r8489
2013-09-20 14:52:31 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Greg Parker
9b5d7dae13 Unconditionally enable interpreter- and repl-based tests.
Swift SVN r8477
2013-09-20 00:48:12 +00:00
Anna Zaks
bce75895bd [SIL DCE] Constant fold SwitchUnionInst and SwitchIntInst when possible.
Swift SVN r8473
2013-09-19 23:41:04 +00:00
Anna Zaks
7a1233be74 [SIL: CCP] Fix a bug that was preventing chaining constant propagation.
Swift SVN r8471
2013-09-19 23:41:02 +00:00
Joe Groff
c10340433c IRGen: Forward extra inhabitants through single-payload unions.
If a single-payload union doesn't use up all of its payload's extra inhabitants, it can claim the remaining ones as its own. While we're here, specialize the extra inhabitants implementation for no-payload unions to generously (and more efficiently) give out all integer values within its storage type above the largest discriminator as extra inhabitants, instead of relying entirely on the spare bits mask.

Swift SVN r8470
2013-09-19 23:16:53 +00:00
John McCall
7954960797 Add 'copy_value' and 'destroy_value' operations to destroy
entire aggregates at once.

This has three worth effects:
  - It significantly decreases the amount of SIL required
    for these operations.
  - It makes it far easier for IR-gen to choose efficient
    patterns of destruction, e.g. calling a single entrypoint
    or recognizing that it can just use the runtime 'release'
    entrypoints.
  - It makes it easier to recognize and optimize aggregate
    copy/destroy operations.
It does make SROA-like tasks a bit more challenging.  The
intent is to give TypeLowering a way to expand these into
their primitive behavior.

Swift SVN r8465
2013-09-19 22:14:55 +00:00
Adrian Prantl
2155d3d6b7 Debug info: Fix line table entries for implicit return statements.
rdar://problem/14981751

Swift SVN r8462
2013-09-19 20:30:54 +00:00
Chris Lattner
842d9176cd teach memory promotion to promote alloc_stack values, which can have
promotable loads and stores after inlining.  This resolves rdar://15025490


Swift SVN r8444
2013-09-19 06:02:57 +00:00
Joe Groff
fd1e1c55bd SILGen: Don't pass down stale stack values from address-only ternaries.
When emitting ternaries of address-only type we were providing a result address that pointed into dead stack storage. Oops.

Swift SVN r8422
2013-09-18 22:11:11 +00:00
Dmitri Hrybenko
a813e14b6d Code completion: complete 'super.init' in constructors
Also add tests for completing constructors declared with selector syntax.


Swift SVN r8412
2013-09-18 19:05:39 +00:00
Adrian Prantl
3033e0269d typo
Swift SVN r8411
2013-09-18 18:51:44 +00:00
Adrian Prantl
ba4fd38e4d Attempt to make the ASTStreamer test more robust under various build setups.
(My configure+make build to verify this change is still not finished,
so there may be more coming)

Swift SVN r8408
2013-09-18 18:14:43 +00:00
Doug Gregor
dabdb5cf21 Swift has a more restrictive definition of 'init method' than Clang.
Only import an Objective-C 'init' method if both Clang and Swift
consider it an init method.


Swift SVN r8403
2013-09-18 17:28:57 +00:00
Greg Parker
f32b6e972e [test] Add test requirements swift_interpreter for swift -i and swift_repl for swift -repl.
Swift SVN r8392
2013-09-18 04:36:48 +00:00
Dmitri Hrybenko
30117c6a42 Code completion tests: split 'super' tests into complete_after_super.swift
test/IDE/complete_value_expr.swift is becoming too large (and too slow)


Swift SVN r8381
2013-09-18 01:05:30 +00:00
Adrian Prantl
65bc68bc50 Debug info: Implment bound generic unions. Fixes rdar://problem/15014441.
Swift SVN r8376
2013-09-18 00:37:59 +00:00
Doug Gregor
f7a2d5eed0 Emit Objective-C thunks for [objc] initializing constructors.
Now that all [objc] constructors have a suitable "init" selector, emit
an Objective-C thunk for the initializing constructor (not the
allocating constructor!) with that selector, and make sure it shows up
in the Objective-C metadata. 

With this, we can write a Swift constructor "constructor()" to
override "-init"; see the change to ListMaker that exercises this.

Joe or John: I'd love a review of these.



Swift SVN r8373
2013-09-18 00:30:54 +00:00
Manman Ren
8cd676143a SIL Serialization: handle more SILInstructions
Add serialization/deserialization of the following SILInstructions:
BuiltinFunctionRefInst, IndexRawPointerInst, ModuleInst,
Conversion instructions:
  RefToObjectPointerInst, UpcastInst, CoerceInst, AddressToPointerInst,
  PointerToAddressInst, ObjectPointerToRefInst, RefToRawPointerInst,
  RawPointerToRefInst, RefToUnownedInst, UnownedToRefInst
DestroyAddrInst, LoadInst, StrongReleaseInst, StrongRetainInst,
TupleElementAddrInst, TupleExtractInst

Make getModule in ModuleFile public to be used by SILDeserializer, also
make addModuleRef in Serializer public to be used by SILSerializer.

Update testing case to cover the above SILInstructions.


Swift SVN r8372
2013-09-18 00:25:23 +00:00
Dmitri Hrybenko
4671a63ad8 Code completion tests: split 'self' tests into complete_after_self.swift
test/IDE/complete_value_expr.swift is becoming too large (and too slow)


Swift SVN r8371
2013-09-18 00:15:55 +00:00
Doug Gregor
90b8b3e499 Constructor selectors always start with 'init'.
Implement the new rules for mapping between selector names and
constructors. The selector for a given constructor is formed by
looking at the names of the constructor parameters:
  * For the first parameter, prepend "init" to the parameter name and
  uppercase the first letter of the parameter name. Append ':' if
  there are > 1 parameters or the parameter has non-empty-tuple type.
  * For the remaining parameters, the name of each parameter followed
  by ':'.

When a parameter doesn't exist, assume that the parameter name is the
empty string.

And, because I failed to commit it separately, support selector-style
declarations of constructor parameters so that we can actually write
constructors nicely, e.g.:

  // selector is initWithFoo:bar:
  constructor withFoo(foo : Foo) bar(bar : Bar) { ... }



Swift SVN r8361
2013-09-17 22:49:05 +00:00
Joe Groff
569bb0d373 Update test.
Swift SVN r8357
2013-09-17 21:49:22 +00:00
Joe Groff
717d3b2de7 IRGen: Implement tag injection for dynamic single-payload unions.
Use swift_storeUnionTagSinglePayload to implement tag injection.

Swift SVN r8336
2013-09-17 17:12:52 +00:00
Joe Groff
58407c4724 IRGen: Switch over dynamic single-payload unions.
Use the swift_getUnionCaseSinglePayload runtime function to calculate the case index for a dynamic union, then switch on the case index.

Swift SVN r8333
2013-09-17 16:45:49 +00:00
Joe Groff
14112d671f IRGen: Abstract the value semantics of single-payload unions to accommodate the dynamic case.
Conditionalize dependencies on fixed layout in the init/assign/destroy implementations for single-payload unions, and use some to-be-written runtime entry points in the dynamic case. Provide an initializeValueWitnessTable implementation for dynamic single-payload union metadata.

Swift SVN r8319
2013-09-17 01:29:33 +00:00
Doug Gregor
4a377575f8 IRGen support for dynamic method lookup of static methods.
Swift SVN r8301
2013-09-16 22:27:53 +00:00
Adrian Prantl
650b75aeaa Debug info: emit mangled names for protocol compositions.
Swift SVN r8300
2013-09-16 22:10:11 +00:00
Adrian Prantl
b80840dc97 Debug info: Implement function pointers. rdar://problem/14960518
Swift SVN r8267
2013-09-15 02:57:25 +00:00
Adrian Prantl
950f819603 Debug info: support protocol function arguments. rdar://problem/14978875
Swift SVN r8261
2013-09-15 01:26:17 +00:00
Joe Groff
a6fa8fda58 IRGen: Substitute union element types when making UnionTypeInfos.
Use getTypeOfMember to get the TypeInfo for the specialized types of union elements when creating TypeInfos for a bound generic union.

Swift SVN r8255
2013-09-14 23:48:28 +00:00