Commit Graph

239 Commits

Author SHA1 Message Date
Chris Lattner
1abf1d0ebc remove RValueEmitter and some implementation logic for it, as well as
FullExpr.  Scope is kept alive by one dangling thread, rdar://13681467


Swift SVN r4798
2013-04-18 05:24:50 +00:00
Chris Lattner
dc0454e1d2 remove GenArray.{h,cpp} as they are handled by SILGen. Remove getAddrOfLocalFunction.
Swift SVN r4796
2013-04-18 05:12:01 +00:00
Chris Lattner
47e508c24d remove LValue, PathComponent, and LValue.h as a whole.
Swift SVN r4792
2013-04-18 04:50:03 +00:00
Chris Lattner
20a712a2fc remove emitAddressLValue and PhysicalPathComponent.
Swift SVN r4791
2013-04-18 04:46:41 +00:00
Chris Lattner
ac6dbfb604 remove some protocol stuff, which is the last user of emitFakeLValue.
Remove emitFakeLValue, the last user of emitAddressLValue.


Swift SVN r4790
2013-04-18 04:42:49 +00:00
Chris Lattner
447ceab4e1 remove JumpDest class and JumpDest.h, it is now a SILGen concept.
Swift SVN r4783
2013-04-17 22:52:38 +00:00
Chris Lattner
477bdbd08a remove emitConstructorBody and GenConstructor.cpp now that Joe implemented
implicit struct constructors in r4776.


Swift SVN r4782
2013-04-17 22:38:38 +00:00
Chris Lattner
ffe3388aa5 remove the dead logic form GenTuple, RValueInitEmitter, and some
erasure/protocol expr logic.


Swift SVN r4775
2013-04-17 06:34:27 +00:00
Chris Lattner
01a36864a3 Remove LogicalPathComponent, emitLoad, emitAssign, emitLValueAsScalar,
and supporting logic.

PathComponent and LValue are (apparently unnecessarily) kept alive by 
projectPhysicalClassMemberAddress (rdar://13671033)



Swift SVN r4773
2013-04-17 06:00:34 +00:00
Chris Lattner
091652fe47 remove GetterSetter.h and implementation logic, now that this is handled by SILGen
Swift SVN r4772
2013-04-17 05:53:52 +00:00
Chris Lattner
ade66c8b10 Remove the emitIgnored, emitLValue, and tryEmitAsAddress mechanics and
supporting logic.


Swift SVN r4770
2013-04-17 05:33:23 +00:00
Chris Lattner
dace3e95fd remove local decl emission and local pattern binding emission.
Swift SVN r4769
2013-04-17 05:09:37 +00:00
Chris Lattner
0701489691 remove Condition.
Swift SVN r4768
2013-04-17 05:01:03 +00:00
Chris Lattner
ec6d194c5d remove the old IRGen path for statements.
Swift SVN r4767
2013-04-17 04:48:26 +00:00
Joe Groff
7dde07cfd3 IRGen: Lower SIL ArchetypeToSuper (and v.v.).
Swift SVN r4747
2013-04-15 23:32:46 +00:00
Joe Groff
bfd2f85b5c Parse 'fallthrough' statements.
Create a new FallthroughStmt, which transfers control from a 'case' or 'default' block to the next 'case' or 'default' block within a switch. Implement parsing and sema for FallthroughStmt, which syntactically consists of a single 'fallthrough' keyword. Sema verifies that 'fallthrough' actually appears inside a switch statement and that there is a following case or default block to pass control to.

SILGen/IRGen support forthcoming.

Swift SVN r4653
2013-04-10 17:30:42 +00:00
Joe Groff
9fbd9f19b8 Runtime: Clean up swift_allocBox a bit.
Per John's comments, make a GenericBox struct to represent the layout of a generic box allocation, move all the layout calculations into methods on GenericBox, and alter swift_deallocBox to take the type as an argument so that it's future-proofed for when we start special-casing certain types in allocBox.

Swift SVN r4613
2013-04-05 18:51:36 +00:00
Joe Groff
14355a8134 Runtime: Add swift_allocBox.
Add a runtime function that, given a generic type metadata pointer, allocates a heap object capable of containing a value of that type. This is a first-pass implementation that always does the worst case thing of stuffing the type metadata into the box with the value and using its value witness table to size, align, and destroy the box. Use swift_allocBox to implement ArchetypeTypeInfo::allocate correctly for heap object allocations. This means SIL's alloc_box $T now works for archetypes, and a simple generics test now (almost) compiles through SIL!

Swift SVN r4599
2013-04-05 01:34:28 +00:00
Joe Groff
3f81dfef15 IRGen: Implement 'x is T' for archetype T.
<rdar://problem/13530695> blocks this from actually working yet.

Swift SVN r4523
2013-03-28 22:18:17 +00:00
Joe Groff
35c85c5017 Implement 'x is T' runtime type checks.
Implement type-checking and IRGen for 'x is T', and fix a bug in 'x as! T' typechecking when the operand is an lvalue. For IRGen I'm reusing the checked swift_dynamicCastClass runtime function and testing the result against null.

Swift SVN r4515
2013-03-28 16:51:25 +00:00
Joe Groff
062ad267c4 Value-only switch statements.
Implement switch statements with simple value comparison to get the drudge work of parsing and generating switches in place. Cases are checked using a '=~' operator to compare the subject of the switch to the value in the case. Unlike a C switch, cases each have their own scope and don't fall through. 'break' and 'continue' apply to an outer loop rather to the switch itself. Multiple case values can be specified in a comma-separated list, as in 'case 1, 2, 3, 4:'. Currently no effort is made to check for duplicate cases or to rank cases by match strength; cases are just checked in source order, and the first one wins (aside from 'default', which is branched to if all cases fail).

Swift SVN r4359
2013-03-12 04:43:01 +00:00
Joe Groff
be09b16f93 Sema: Allow returns from constructors/destructors.
In the StmtChecker, consider a ConstructorDecl or DestructorDecl context to be a function context that returns (). In IRGen for constructors and destructors, set up proper return blocks so that 'return' does the right thing, and in constructors, pretend that the body has no return value even though the underlying constructor mechanism totally returns a value. Fixes <rdar://problem/12950817>.

Swift SVN r3915
2013-01-31 22:30:12 +00:00
Joe Groff
1459512901 IRGen: SIL tuple helper instructions.
Implement ElementAddrInst for lvalue tuples, and implement the AllocArray, IndexAddr, and IntegerValue insts used to lower variadic tuples. (Actually compiling code that uses variadic tuples still requires support for SpecializeInst and generic functions.)

Swift SVN r3781
2013-01-17 18:17:39 +00:00
Joe Groff
8320df8b9d IRGen: SIL branching and variable allocation.
Implement SIL-to-IR lowering for allocation, deallocation, load, store, and branching instructions so that local variables and branching control flow can be used. Add a Fibonacci loop test to exercise the new instructions.

Swift SVN r3767
2013-01-15 22:32:49 +00:00
Joe Groff
9259c0d912 IRGen: Get "hello world" to compile through SIL.
Add a path through IRGenModule to optionally codegen FuncDecls using their corresponding SIL Functions when constructed with a SILModule. Jury-rig an IRGenSILFunction subclass of IRGenFunction that does the bare minimum necessary to compile "hello world" from SIL. There are some impedance mismatches between irgen and SIL that need to be smoothed out, particularly the AST-dependent way irgen currently handles function calls. Nonetheless, `swift -sil-i hello.swift` works!

Swift SVN r3759
2013-01-14 02:57:11 +00:00
John McCall
b15b306314 Emit ObjC metadata and swift-as-ObjC thunks for methods.
Swift SVN r3697
2013-01-05 23:46:24 +00:00
Chris Lattner
47dbc4051c update for mainline LLVM header file moves.
Swift SVN r3634
2013-01-02 14:38:42 +00:00
Doug Gregor
662861fd66 Implement runtime checking for super-to-archetype casts, finishing <rdar://problem/12768631>.
Introduce a new swift_dynamicCast pair that take in a general metatype
pointer, rather than the more specific class-metatype pointer used for
class downcasts, and grab the class out of that general metatype
pointer, which may actually be an Objective-C wrapper. This is
slightly slower, but it works for the super-to-archetype cases like
T(an_NSObject), where T can have either kind of metadata.

NSTypedArray<T> is actually run-time type checked now, yay!


Swift SVN r3564
2012-12-20 18:47:39 +00:00
Doug Gregor
b4ca0f1fef Rename llvm::AttrListPtr -> llvm::AttributeSet to sync with LLVM mainline.
Swift SVN r3430
2012-12-10 23:21:19 +00:00
Doug Gregor
1f45f28837 Emit the constructors synthesized by the Clang importer for ObjC init/new methods.
Note that the constructors we emit don't function yet, since they rely
on the not-yet-implemented class message sends to Objective-C
methods.


Swift SVN r3370
2012-12-05 22:01:38 +00:00
Joe Groff
7fcaed63c7 IRGen: fix typo in comment
Swift SVN r3194
2012-11-15 22:24:07 +00:00
Joe Groff
cb6d12d52d Revert "WIP"
Not ready for prime time, sorry.

This reverts commit 3185.

Swift SVN r3189
2012-11-15 00:11:40 +00:00
Joe Groff
9d08711627 WIP
Swift SVN r3187
2012-11-15 00:04:23 +00:00
John McCall
84f3b7f884 Unify the ObjC and Swift heap pointer TypeInfos.
Swift SVN r3088
2012-10-30 00:19:33 +00:00
John McCall
0548cc7cff Cache local metadata in the scope in which we compute it,
to avoid some obvious redundancies.  This also gives us a
more general framework with which to exploit other ways
in which metadata is known.

Swift SVN r3047
2012-10-23 23:30:23 +00:00
John McCall
17944ddefe Rename emitRValueUnderSubstitutions to make clear the
direction of substitution.

Swift SVN r2974
2012-10-11 04:29:24 +00:00
John McCall
1f5b775bc7 Use metatype pointers as generic type arguments. Movements
towards optimizing generic calls to derive things from the
'this' pointer, which is actually crucial for virtual
dispatch (to get all methods to agree about how the
implicit arguments are passed).  Fix a number of assorted
bugs in metadata emission.  Lots of assorted enhancements.

This was proving surprisingly difficult to actually tease
apart into smaller patches.

Swift SVN r2927
2012-10-03 08:57:40 +00:00
John McCall
179e260ea3 Add an abstraction to encapsulate a Decl + explosion level +
uncurrying level, which is something I find myself passing around
quite a bit.  Make sure that it can propagate getter/setter
references in the same way.

Swift SVN r2902
2012-09-28 05:21:24 +00:00
John McCall
ee012c0903 Make IR-gen use canonical types as the basic type currency.
This is kindof a pain in a few places where the type system
doesn't propagate canonicality.  Also, member initializations
are always direct-initializations and so are allowed to use
explicit constructors, which is a hole in our canonicality
tracking.  But overall I like the idea of always working
with canonical types.

Swift SVN r2893
2012-09-21 07:53:08 +00:00
Chris Lattner
7055cfe43a move DiverseList and DiverseStack to swift/Basic, out of IRGen.
Swift SVN r2784
2012-08-26 20:10:10 +00:00
John McCall
baecef724d Work out a different way to meet access-control restrictions
on the archetype wtable mapping.  Amp up the asserts, too.

Swift SVN r2627
2012-08-14 00:34:15 +00:00
John McCall
b82165019c Fix access-control bug in a slightly different way.
Swift SVN r2626
2012-08-14 00:34:09 +00:00
Doug Gregor
0a30594524 Access control fix for those using a bleeding-edge Clang.
Swift SVN r2623
2012-08-13 17:53:16 +00:00
Eli Friedman
742f51f5b0 Some random fixes to avoid crashing on unimplemented IRGen codepaths.
Swift SVN r2554
2012-08-04 01:14:52 +00:00
Ted Kremenek
219b7bd430 Move LLVM.h to libBasic.
Swift SVN r2550
2012-08-03 23:54:29 +00:00
Eli Friedman
a87d83b7b8 Work-in-progress towards getting generic new array expressions working.
Swift SVN r2509
2012-08-02 21:36:33 +00:00
Eli Friedman
751c463a2e Rewrite the way we represent construction of value types so that it looks
more like a call.  This should be enough to get generic constructors working.



Swift SVN r2437
2012-07-24 23:43:43 +00:00
John McCall
3950a6af41 Generic calls status code dump activate!
Swift SVN r2386
2012-07-20 21:59:14 +00:00
John McCall
3b30fbfc36 Support multiple protocols on a generic parameter.
Swift SVN r2363
2012-07-17 06:20:38 +00:00
Eli Friedman
77751012d2 Switch over constructors so that they return a value instead of being a
method to initialize the members.  This doesn't matter so much
for structs (the generated IR is essentially equivalent except for
small structs), but on classes, we don't want to make "new X" generate
code that knows about metadata/destructors/etc for the class X.

Also, make sure classes always have a constructor.  (We haven't really
discussed the rules for implicitly declared constructors, so for now,
the rule is just "generate an implicit constructor if there is no
explicit constructor".  We'll want to revisit this when we actually
design object construction.)



Swift SVN r2361
2012-07-17 00:32:28 +00:00