Commit Graph

12848 Commits

Author SHA1 Message Date
John McCall
e231868a84 Add witnesses for base protocols. For now, these are always
out-of-line rather than prefixed.

Swift SVN r1914
2012-05-21 20:01:36 +00:00
John McCall
e98d38bb3c Set up the basic framework for building witness-table layouts in
both the abstract and concrete cases.

Swift SVN r1913
2012-05-21 20:01:34 +00:00
Dave Zarzycki
94e67cc4e9 Add fast/basic alloc/dealloc APIs
Swift SVN r1908
2012-05-21 17:08:54 +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
06992eec7a Introduce helper templates to make it easier to define
type infos that can be efficiently scalarized.

Swift SVN r1904
2012-05-19 03:16:08 +00:00
John McCall
38bac7c706 Add Builtin.ObjCPointer with accompanying IR-gen support and
wrap it in an 'id' type in the standard library.

Also fix a bug noticed by inspection where initWithTake for
function types wasn't entering a cleanup for the taken value.
This probably doesn't matter for existing possibilities, but
it's potentially important under exceptions.

Swift SVN r1902
2012-05-18 23:40:17 +00:00
John McCall
7b2216216a Delete redundant file.
Swift SVN r1901
2012-05-18 18:27:41 +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
450a722215 Add an IRBuilder::CreateBitCast variant which maps addresses.
Swift SVN r1898
2012-05-18 10:01:57 +00:00
John McCall
71c45f5212 Lion's libc++ headers do not support shared_ptr under -fno-rtti.
This is <rdar://problem/10217868>.  Apparently I'm using Lion's
libc++ headers somehow, which I should probably fix;  but since
the use of shared_ptr is just a hack until DenseMap supports
move-only types, I don't feel bad about changing it to a different
hack that avoids shared_map altogether.

Swift SVN r1897
2012-05-18 10:01:54 +00:00
John McCall
cf6a1fd284 Implement assignment on protocol types.
Swift SVN r1896
2012-05-18 10:01:50 +00:00
John McCall
85acda32bb Implement basic functionality for protocol types, with the
exception of assign.

Swift SVN r1895
2012-05-18 10:01:46 +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
Chris Lattner
065614c8ac Add support for working with IR intrinsics that return multiple values, like the
overflow stuff.


Swift SVN r1891
2012-05-17 20:42:38 +00:00
Chris Lattner
b2fb91fba6 rip out my previous hack for Builtin.trap() and put in general code that
allows access to any LLVM IR intrinsic that has types that can be mapped
to swift types.  Notably, this excludes vector stuff, but there is a lot
of other goodness that can now be poked at.



Swift SVN r1890
2012-05-17 20:31:17 +00:00
Eli Friedman
1341f19da8 IRGen for varargs tuples.
Swift SVN r1883
2012-05-17 03:22:49 +00:00
Eli Friedman
5e206bc10f Rename DistinctTypeDecl to NominalTypeDecl.
Swift SVN r1882
2012-05-17 01:54:15 +00:00
Eli Friedman
6e69e27975 Kill ScalarToTupleExpr, which is no longer in use.
Swift SVN r1881
2012-05-17 01:50:48 +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
Doug Gregor
5f8d5efda2 Unbreak the CMake build, and add -momit-leaf-frame-pointer to the
runtime build for optimized builds.


Swift SVN r1871
2012-05-16 18:03:59 +00:00
Eli Friedman
33f20a14e0 Add NewReferenceExpr, for allocating class objects.
Swift SVN r1867
2012-05-16 01:36:03 +00:00
Eli Friedman
98933b8510 More work on ClassDecls; this is enough to get member access working.
Swift SVN r1863
2012-05-16 00:22:09 +00:00
Eli Friedman
ec77975642 Minor fix for mangling; I wasn't trying to change the mangling of oneofs with my last commit.
Swift SVN r1859
2012-05-15 21:55:46 +00:00
Eli Friedman
79c3276b07 AST representation for ClassDecls.
Swift SVN r1858
2012-05-15 21:53:38 +00:00
Chris Lattner
5163b40020 Hack in support for Builtin.trap(), resolving rdar://11442881. a more
general solution to get access to arbitrary intrinsics will follow.


Swift SVN r1857
2012-05-15 17:40:46 +00:00
Chris Lattner
f3c3ad086f Remove OverloadedBuiltinKind::Arithmetic, replacing it with OverloadedBuiltinKind::Special
and simplifying Builtins.def.


Swift SVN r1854
2012-05-15 04:29:47 +00:00
Chris Lattner
6faa726012 switch binops builtin irgen to the new world order.
Swift SVN r1852
2012-05-15 04:15:54 +00:00
Eli Friedman
6f045aad2f Throw the switch to use "var" syntax to declare members of structs. This also means we no longer build an implicit extension for every struct decl. Everything seems to be working, but please yell if this breaks anything.
Swift SVN r1851
2012-05-15 03:27:13 +00:00
Eli Friedman
907cc521ab Switch a couple booleans in Module over to an enum.
Swift SVN r1845
2012-05-15 00:20:01 +00:00
Doug Gregor
056ba286eb Implement subtyping rules that allow one to convert a function type to
another function type, so long as the source is a subtype of the
target. The subtyping relation is fairly obvious, allowing parameter
renaming, qualification conversions for lvalue types, and
protocol-conformance conversions (at the top level of function
types). It is a strict subset of the allowed type coercions.

The representation of FunctionConversionExpr is temporary. It will
need to account for the capture of the source of the conversion in the
trivial-trivial case.



Swift SVN r1839
2012-05-14 19:10:22 +00:00
Chris Lattner
90fc3c35bb split the 3 "arithmetic" binary operations into fp vs integer variants.
Swift SVN r1838
2012-05-14 18:45:33 +00:00
Chris Lattner
dd63c83ecc rework compare builtins to use the new-school way of
IRGen'ing them.


Swift SVN r1837
2012-05-14 17:53:19 +00:00
Chris Lattner
5dc60f4252 pull hard-coded builtins out of the switch.
Swift SVN r1836
2012-05-14 17:39:02 +00:00
Chris Lattner
fd38dab6e2 switch cast builtins IRGen to use a different approach.
Swift SVN r1835
2012-05-14 17:37:07 +00:00
Chris Lattner
f1478aa81c regularize cast processing in IRGen
Swift SVN r1834
2012-05-14 17:32:57 +00:00
Doug Gregor
59db25658a Ban the use of SuperConversionExpr to produce lvalues, since that is,
in general, not sound. For the limited cases where we did use this
expression kind on lvalues (member access or instance method
invocations on a superprotocol), leave the conversion to the client of
their respective AST nodes (MemberRefExpr, DotSyntaxCallExpr). We may
decide to enrich these ASTs in the future with more information about
the conversion path, but it's not clear that it's actually useful
information for, e.g., IRgen.


Swift SVN r1830
2012-05-14 15:38:27 +00:00
John McCall
8617d1733d Change the IR translation of struct types to just require a single
level of IR struct type.  At first we were emitting two layers
because structs were secretly tuples, and then more recently
we were emitting two layers to avoid having to adjust a bunch
of tests.  Just bite the bullet now;  it makes the IR a lot
cleaner, and it's never going to be easier.

Swift SVN r1824
2012-05-12 07:19:48 +00:00
John McCall
48cd78cfef Allow an opaque struct type to be specified as the struct
to perform struct-layout into.

Swift SVN r1823
2012-05-12 07:19:43 +00:00
Eli Friedman
120f6deb6b Add GenStruct.h, which I meant to commit with r1806.
Swift SVN r1815
2012-05-11 21:45:22 +00:00
Doug Gregor
a49d6c88c8 Introduce a conversion-to-supertype expression to capture conversions
from a protocol to a protocol it inherits. This is a far simpler
operation that the general type-erasure expression, so generate this
AST when we can.


Swift SVN r1813
2012-05-11 17:25:14 +00:00
Doug Gregor
9e55349172 r1805 and r1806 collided and left Swift in a broken state; fix in the
most obvious way.


Swift SVN r1809
2012-05-11 14:32:34 +00:00
Eli Friedman
01a18f6c7a Use VarDecls to represent struct members, and MemberRefExprs to represent member access in structs. Eliminate the horrible hack which was LookThroughOneOfExpr.
Swift SVN r1808
2012-05-11 03:08:15 +00:00
John McCall
875d914c77 Extract the layout logic out of GenTuple.cpp into a template header.
It does seem silly for this to all be templated, but I couldn't
really see a very elegant solution given how I wanted things to
be genericized.

...interestingly, a ?t.t[] type would have done nicely for some
of this.

Swift SVN r1807
2012-05-11 01:34:56 +00:00
Doug Gregor
70bfc235b8 Implement protocol inheritance, e.g.,
protocol Document { var title : String }
  protocol Versioning { func bumpVersion() }
  protocol VersionedDocument : Document, Versioning { }

This commit covers the basic functionality of protocol inheritance, including:
  - Parsing & AST representation
  - Conforming to a protocol also requires conforming to its inherited
  protocols
  - Member lookup into a protocol also looks into its inherited
  protocols (results are aggregated; there is no name hiding)
  - Teach ErasureExpr to maintain lvalueness, so we don't end up
  performing a silly load/erase/materialize dance when accessing
  members from an inherited protocol.




Swift SVN r1804
2012-05-11 00:00:50 +00:00
Eli Friedman
28cddd1b90 Make sure we use the right IR generation options for the IRGen standard library hack.
Swift SVN r1801
2012-05-10 22:22:18 +00:00
Eli Friedman
ed63824918 Fix a minor logic issue with swift::irgen::IRBuilder::insertBlockAnywhere. Fixes the rest of <rdar://problem/11425939>.
Swift SVN r1800
2012-05-10 21:52:04 +00:00
Eli Friedman
8d58b9f6f6 Make sure we destroy the element variable in a for-each loop in the right place. Part of <rdar://problem/11425939>.
Swift SVN r1799
2012-05-10 21:32:18 +00:00
Doug Gregor
3e7b52d025 Implement support for coercing a value of a given type T to a protocol
P, so long as T conforms to the protocol P.



Swift SVN r1797
2012-05-10 18:55:30 +00:00