Commit Graph

365 Commits

Author SHA1 Message Date
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
Eli Friedman
66907893d3 Allow destructuring assignments (assignment to a tuple expression). <rdar://problem/11719247>.
Swift SVN r2285
2012-07-02 21:39:52 +00:00
John McCall
e53aed65d7 Initial support for IR-genning generic function bodies.
Mangling is still a hack, pending a better type AST.  Fixed
a bug where arguments passed indirectly were not being destroyed
by the callee (when passed by value).  Changed some of the protocol
signatures to use the generic opaque pointer type, making the
types a bit more self-documenting in the IR.

Swift SVN r2274
2012-06-28 08:50:06 +00:00
John McCall
4d4073cafa Provide a dinky little interface for associating a wtable with an
archetype within a context.

Swift SVN r2247
2012-06-25 20:45:06 +00:00
John McCall
e3ea138183 Pack of changes leading towards a more-correct implementation
of archetypes.

Swift SVN r2243
2012-06-25 20:45:01 +00:00
Chris Lattner
56886268dd implement irgen support for do/while statements, wrapping up rdar://11576294
Swift SVN r2188
2012-06-17 04:16:55 +00:00
Eli Friedman
e5b4b924a1 More work on constructors. Basic testcases with "constructor" declarations appear to be working, although there's probably more work to be done. (Both old-style and new-style constructors work for the moment.)
Swift SVN r2163
2012-06-07 01:57:57 +00:00
John McCall
53646ccfc8 Better support for mangling, emitting, and using local
functions.

Swift SVN r2152
2012-06-05 04:51:21 +00:00
John McCall
5064f39024 Refactor towards the goal of using different CCs when
passing this pointers or data arguments.

Swift SVN r2149
2012-06-05 04:50:58 +00:00
Eli Friedman
26bebcfd61 IRGen for break/continue.
Swift SVN r2089
2012-05-31 02:45:18 +00:00
Eli Friedman
8eeeb361ad IRGen support for member functions on local types.
Swift SVN r2085
2012-05-31 00:16:46 +00:00
Eli Friedman
6abcbcde33 Allow using LinkEntity for members of/witnesses for local types. As a simple test to start using them, get rid of getAddrOfLocalInjectionFunction.
Swift SVN r2084
2012-05-30 23:53:58 +00:00
Eli Friedman
9895a11be8 Get rid of some unnecessary handling for ExtensionDecls.
Swift SVN r2063
2012-05-30 00:27:32 +00:00
Chris Lattner
16cf77644f switch the frontend to generate swift_retain_noresult calls instead of
swift_retain calls.  The pertinent difference is that the former can be
marked nocapture, allowing general LLVM optimizations more flexibility.

With this change, early-cse is able to zap 9 more instructions, and 3
more functions are able to be marked nocapture by functionattrs in the
stdlib.


Swift SVN r2043
2012-05-28 20:20:07 +00:00
John McCall
40d1591f89 Some minor tweaks to make our use of the allocation entrypoints
match the actual entrypoints vended by the runtime:
1) there is no swift_slowRawAlloc
2) swift_deallocObject takes two arguments
Also, make all calls to swift_allocObject go through a common
function so that we can easily use optimized entrypoints if the
runtime provides them.

Swift SVN r1993
2012-05-25 17:34:59 +00:00
John McCall
30244a2f0d Do all the dancing necessary to get method calls through
protocols working.

Swift SVN r1969
2012-05-24 12:16:51 +00:00
John McCall
72ebeee76f Try to optimize assignment a bit more, and fix assignment
of protocol types to correctly handle self-assignment.
This ends up creating such a large amount of code that it's
worth extracting into its own helper function.  Fortunately,
this can be the same helper function for every protocol type.

Swift SVN r1905
2012-05-19 06:46:05 +00:00
John McCall
90939b19c0 Provide a base class for implementing a single retainable object
pointer TypeInfo more conveniently.  Have this class return true for
isSingleRetainablePointer().  Further specialize the implementations
of the value witnesses so that we no longer ever require type-specific
witnesses for reference types.

Swift SVN r1900
2012-05-18 10:02:04 +00:00
John McCall
d461d72e85 Implement ErasureExpr in IR-gen, at least as far as generating
value witnesses goes.

There are three major remaining things to do to support protocols:
  - laying out the actual protocol members
  - emitting witnesse for the actual protocol members
  - detecting uses of the actual protocol members and funnelling
    them through the witnesses as appropriate
All this work was just to let us treat protocol types as
first-class values.

Swift SVN r1899
2012-05-18 10:02:01 +00:00
John McCall
6b392f8479 Turn initializeWithCopy into a generic operation on TypeInfos
so we can optimize sub-operations properly.

Swift SVN r1894
2012-05-18 10:01:42 +00:00
John McCall
675ec2234c Teach IRGen how to emit a call or load directly as the initializer for
some hunk of memory.

Swift SVN r1893
2012-05-18 10:01:38 +00:00
Eli Friedman
b788bad8e6 A couple missing pieces for classes. Also, a few fixes for local types.
Swift SVN r1873
2012-05-16 19:21:07 +00:00
Eli Friedman
77fa49ec2b Introduce StructDecl and StructType; use them for structs instead of OneOfDecl/OneOfType. To keep this patch small, I'm leaving in LookThroughOneOf etc. for the moment, but that's next on the agenda.
Swift SVN r1780
2012-05-09 00:27:44 +00:00
Eli Friedman
d9f8ab5084 Get rid of unused functions.
Swift SVN r1776
2012-05-08 21:14:07 +00:00
Eli Friedman
c2868d6d0a Make local oneofs not crash in IRGen. <rdar://problem/11292678>.
Swift SVN r1743
2012-05-04 18:20:51 +00:00