Commit Graph

665 Commits

Author SHA1 Message Date
Joe Groff
0422897a47 Expose %swift.opaque as a builtin type.
Archetypes and projected existentials have the type %swift.opaque* and not i8*, so I need a corresponding SIL type to be able to model the ProjectExistential operation. We might also end up needing the builtin type for other low-level things down the line.

Swift SVN r3793
2013-01-18 02:24:23 +00:00
Joe Groff
c39e922092 Quell warning about the new 'Half' IITDescriptor.
Swift SVN r3760
2013-01-14 02:57:15 +00:00
Chris Lattner
b58a87c7c4 do an inttoptr/ptrtoint dance to enable atomics on Builtin.RawPointer,
implementing: rdar://12939803 - ER: support atomic cmpxchg/xchg with pointers


Swift SVN r3702
2013-01-07 19:14:01 +00:00
John McCall
9b2a906669 Include Intrinsics.gen at its actual location.
Swift SVN r3683
2013-01-04 22:35:22 +00:00
Chris Lattner
47dbc4051c update for mainline LLVM header file moves.
Swift SVN r3634
2013-01-02 14:38:42 +00:00
Chris Lattner
bb389185c1 move the LLVM IR intrinsics namespace from Builtin.x to Builtin.int_x
(e.g. Builtin.int_trap instead of Builtin.trap) to avoid conflicts between
IR instructions and intrinsics (e.g. trunc and llvm.trunc).


Swift SVN r3621
2012-12-30 10:31:04 +00:00
Chris Lattner
854880b04d simplify some code by using the new implicit TupleTypeElt ctor.
Swift SVN r3620
2012-12-30 10:24:57 +00:00
Chris Lattner
db63db1c6b expose the llvm atomicrmw instruction through the builtin module to swift code,
wrapping up rdar://12939282.


Swift SVN r3619
2012-12-30 09:53:41 +00:00
Chris Lattner
53baaafffb implement support for generating the fence instruction through
Builtin.fence_*, part of rdar://12939282


Swift SVN r3618
2012-12-30 09:36:08 +00:00
Chris Lattner
fd2a4490fa expose the llvm cmpxchg instruction featureset through to the swift Builtin module,
first part of rdar://12939282.


Swift SVN r3617
2012-12-30 09:21:26 +00:00
Chris Lattner
1fd5d9c1da clean up Builtins.def:
- Don't require "OverloadedBuiltinKind::" to be in the invocation
   of a bunch of builtins for their specification of overload info.
   Eliminating this makes the file fit in 80 columns.
 - Eliminate a bunch of classifications that only classify one thing,
   in favor of a "BUILTIN_MISC_OPERATION" dumping ground for all the
   custom stuff.  This eliminates a bunch of boilerplate.

No functionality change.


Swift SVN r3615
2012-12-30 08:03:14 +00:00
Doug Gregor
75c8591487 When lookup finds a generic parameter, treat it like a local declaration, not a member declaration.
Swift SVN r3534
2012-12-18 22:50:49 +00:00
Doug Gregor
be915b9c04 Implement semantic analysis for inherits-from constraints.
This change enables inheritance constraints such as "T : NSObject",
which specifies that the type parameter T must inherit (directly or
indirectly) from NSObject. One can then implicit convert from T to
NSObject and perform (checked) downcasts from an NSObject to a T. With
this, we can type-

IR generation still needs to be updated to handle these implicit
conversions and downcasts. New AST nodes may follow.


Swift SVN r3459
2012-12-12 23:28:19 +00:00
Eli Friedman
56cc6953ee Add a hack to make swift work with llvm trunk.
Swift SVN r3197
2012-11-15 22:28:41 +00:00
John McCall
e7b9ae47fa Defer to the value witness when moving an archetype. This
is really a deficiency in TypeInfo::initializeWithTake, which
is now virtual and not implemented in TypeInfo anymore.  This
fixes rdar://problem/12153619.

While I'm at it, fix an inefficiency in how we were handling
ignored results of generic calls, and add 4 new builtins:
  Builtin.strideof is like sizeof, but guarantees that it
  returns a multiple of the alignment (i.e., like C sizeof,
  it is the appropriate allocation size for members of an
  array).
  Builtin.destroy destroys something "in place";  previously
  this was being simulated by moving and ignoring the result.
  Builtin.allocRaw allocates raw, uninitialized memory, given
  a size and alignment.
  Builtin.deallocRaw deallocates a pointer allocated with
  Builtin.allocRaw;  it must be given the allocated size.

Swift SVN r2720
2012-08-23 05:21:31 +00:00
Eli Friedman
9e06964c8a Make the TypeLoc constructor which takes just a type private, and expose a
static method to call it, to make it more explicit what is happening.  Avoid
using TypeLoc::withoutLoc for function definitions; instead, just use an empty
TypeLoc.



Swift SVN r2606
2012-08-10 02:09:00 +00:00
Eli Friedman
95cb2d6af2 Add builtins to convert between arbitrary retainable pointers,
Builtin.ObjectPointer, and Builtin.RawPointer.  I don't really like the way
these builtins are defined (specifically, the part where messing up
gives a mysterious IRGen error), but it's workable. <rdar://problem/11976323>.



Swift SVN r2585
2012-08-08 00:40:07 +00:00
Doug Gregor
9e8633ac41 Encode and pass all of the archetypes, including derived archetypes,
in SpecializeExpr, so that we have complete substitution and
protocol-conformance information. On the IR generation side, pass
witness tables for all of the archetypes (again, including derived
archetypes) into generic functions, so that we have witness tables for
all of the associated types.

There are at least two major issues:

  (1) This is a terribly inefficient way to pass witness tables for
  associated types. The witness tables for associated types should be
  accessible via the witness tables of their parent. However, we need
  more information in the ASTs here, because there may be additional
  witness tables that will need to be passed for requirements that are
  placed on the associated type by the generic function itself.

  (2) Something about my test triggers a void/non-void verification failure
  in the witness build for an instance function whose abstracted form
  returns an associated type archetype and whose concrete form returns
  an empty struct. See the FIXME in the test.



Swift SVN r2464
2012-07-26 17:52:04 +00:00
Eli Friedman
688138482d Complete the implementation of a basic Vector<T>.
Swift SVN r2457
2012-07-25 22:51:46 +00:00
Doug Gregor
ce1c30f531 Switch the representation of archetype types so that it encodes when
an archetype is a nested type of another archetype. No functionality
change (yet).


Swift SVN r2416
2012-07-23 21:54:31 +00:00
Eli Friedman
d6a4ba90dd Move TypeLocs to a design where a TypeLoc is a struct containing a type plus
location info for that type.  Propagate TypeLocs a bit more through the AST.



Swift SVN r2383
2012-07-20 21:00:30 +00:00
Eli Friedman
361f931a16 Start propgating TypeLocs from the parser into the AST.
Swift SVN r2372
2012-07-19 02:54:28 +00:00
Chris Lattner
79906830d1 fix the build with whatever version of Xc4.4 I'm using.
Swift SVN r2354
2012-07-13 05:19:10 +00:00
Doug Gregor
d684a74ada Implement builtin 'sizeof' and 'alignof' for everthing except archetypes.
Swift SVN r2330
2012-07-10 18:35:48 +00:00
Eli Friedman
728f948a79 Make Builtin.load, Builtin.init, and Builtin.assign generic functions.
This is most of what is necessary to implement UnsafePointer<T>; we also
will need Builtin.sizeof eventually.



Swift SVN r2325
2012-07-09 23:55:03 +00:00
Doug Gregor
bf71eeb26d Include the generic parameter list of a function declaration in the
FuncDecl AST, and use it for local name lookup.


Swift SVN r2198
2012-06-18 23:49:40 +00:00
Eli Friedman
ae86d64644 Rename Decl::getLocStart() to Decl::getStartLoc(). Add Decl::getLoc(), which is essentially the location which should be used for diagnostics.
Swift SVN r2105
2012-05-31 23:56:30 +00:00
Chris Lattner
e65472637d update for mainline api change, much nicer interface now.
Swift SVN r2020
2012-05-27 18:29:53 +00:00
Doug Gregor
130a72c611 Fix typo of GET_INTRINSIC_GENERATOR_GLOBAL
Swift SVN r1952
2012-05-23 14:32:58 +00:00
Chris Lattner
d689beecc1 avoid a warning with llvm r157312
Swift SVN r1951
2012-05-23 05:20:45 +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
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
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
4c5c948ab7 inline isBuiltinValue into its only caller and simplify it.
Swift SVN r1855
2012-05-15 04:38:01 +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
18530ed142 change BuiltinValueKind and isBuiltinValue to be private to Builtins.cpp.
Swift SVN r1853
2012-05-15 04:17:38 +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
c168af44e8 split the Builtin name parsing logic out to its own function.
Swift SVN r1832
2012-05-14 17:23:18 +00:00
Doug Gregor
86cf79a746 Add a range subscript operation for SliceInt64 that produces a slice, e.g.,
a[5..9]

will return a 4-element slice of the array a. Addresses
<rdar://problem/11329415>.


Swift SVN r1665
2012-04-27 00:07:52 +00:00
John McCall
c7b7c085bd Following IR gen's motivated lead, split Builtin.store
into Builtin.assign and Builtin.init operations.

Swift SVN r1593
2012-04-24 09:51:05 +00:00
Doug Gregor
b237823246 Implement load and store builtins, which we use to provide get() and
set() functions for UnsafePointerInt.


Swift SVN r1533
2012-04-20 17:58:23 +00:00
Eli Friedman
d5e7784010 Get rid of isModuleScope bit, since we don't like scattering bits across the AST; as a replacement, introduce TopLevelCodeDecl, which provides a DeclContext for all expressions and statements at the top level. <rdar://problem/11259941>.
Swift SVN r1503
2012-04-19 21:22:12 +00:00
Chris Lattner
3584b0aea5 implement the rest of support for casts that I care about.
Swift SVN r1435
2012-04-14 02:43:35 +00:00
Chris Lattner
4f4c8b1455 add initial support for Builtin cast instructions, patch #1/2.
Swift SVN r1433
2012-04-14 00:56:35 +00:00
Chris Lattner
868eccff76 implement a new Builtin.gep operation which maps to the LLVM Getelementptr instruction,
used for pointer offseting.  We can figure out inbounds later.  This is to be used by
UnsafePointerInt


Swift SVN r1429
2012-04-13 23:10:42 +00:00
Eli Friedman
361481835c Introduce a notion of module scope declarations; use it where appropriate instead of checking for a local declcontext.
Swift SVN r1380
2012-04-11 02:52:40 +00:00
Chris Lattner
65b400e30d introduce a new "Builtin.RawPointer" type, which corresponds to LLVM's "i8*" type,
and is just an unmanaged pointer.  Also, introduce a basic swift.string type.

This is progress towards rdar://10923403 and strings.  Review welcome.



Swift SVN r1349
2012-04-10 00:52:52 +00:00
John McCall
1f118dbda6 Basic support for Builtin.ObjectPointer as a completely
opaque type.  Also some rudimentary support for retain/release.

Swift SVN r1214
2012-03-16 09:26:32 +00:00
John McCall
b2a2027a43 Revert r1144, r1145, and r1146. These changes (which removed ParenType
in favor of a single-element non-canonical TupleType) broke the type
system, in that supposed sugar (the TupleType) supported a different
set of operations from the canonical type.  For example, a
single-element unlabelled tuple type supports elementwise projection
(foo.$0), but the underlying element does not (or supports it
differently).

The IR-gen failure was due to a very related problem:  IR-gen
was not updated to reflect that a single unlabelled tuple element
is the same type as its element type, and therefore it was giving
different representations to these types ({ %foo } and %foo,
respectively), which broke widespread assumptions.

The removal of ParenType was done in pursuit of an AST invariant
that's not actually particularly interesting in the first place
and which, furthermore, is problematic to attain.

Swift SVN r1182
2012-03-11 09:15:21 +00:00
Chris Lattner
2d7babaf43 clean up some stuff around function argument types.
Swift SVN r1148
2012-03-02 00:25:31 +00:00