Commit Graph

6634 Commits

Author SHA1 Message Date
Joe Groff
51d7e56d4e SIL.rst: Update docs for protocol type instructions.
Swift SVN r6500
2013-07-23 16:41:25 +00:00
John McCall
e668ff914f Add parsing and IR-gen for weak_retain and weak_release.
Swift SVN r6492
2013-07-23 06:28:51 +00:00
Joe Groff
a9c8ad3c07 SIL.rst: Update docs for reference counting instructions.
The retain_autoreleased docs might need some help from someone more versed in the arcana of the autoreleased-return-value hack.

Swift SVN r6491
2013-07-23 03:09:10 +00:00
Joe Groff
a245dfae3a SIL.rst: Update docs for load/store-ish instructions.
Swift SVN r6490
2013-07-23 03:09:02 +00:00
Joe Groff
b9ab10d67a SIL.rst: Update docs for aggregate construct/extract insts.
Swift SVN r6486
2013-07-23 01:45:11 +00:00
Joe Groff
ff4b9ce1f3 SIL.rst: Put the 'module' instruction in with the literal insts.
Swift SVN r6485
2013-07-23 01:45:05 +00:00
Joe Groff
2bec3871d8 SIL.rst: Update docs for metatype instructions.
Swift SVN r6484
2013-07-23 01:45:00 +00:00
Joe Groff
dffe597ee0 SIL.rst: Update docs for function application instructions.
Swift SVN r6483
2013-07-23 01:44:53 +00:00
Joe Groff
b55d0c7ae9 SIL.rst: Update documentation for dynamic method instructions.
Swift SVN r6482
2013-07-22 21:42:40 +00:00
Joe Groff
37b3911cef SIL.rst: Update documentation for literal instructions.
Swift SVN r6480
2013-07-22 21:42:10 +00:00
Joe Groff
c0b03b42ac SIL.rst: Reorder instructions consistent with SILNodes.def.
Neither order is particularly great yet, but getting them in sync will help us keep SIL.rst coverage up as we add/remove instructions in the future.

Swift SVN r6457
2013-07-22 17:31:26 +00:00
Chris Lattner
b70073588f byref arguments to apply and partial_apply do not capture their result,
so allow alloc_box to be promoted to alloc_stack in such cases.


Swift SVN r6432
2013-07-21 20:36:36 +00:00
Joe Groff
8ac1bda817 SIL: Move retain/release/destroy helpers onto SILBuilder.
Add a convenience SILModule::getTypeLoweringInfo forwarder, and move the emitRetainRValue and emitReleaseRValue helpers from SILGenFunction to SILBuilder so they're more readily available to non-SILGen passes. Add an emitDestroyAddress helper that emits nothing, destroy_addr, or load + release based on the value semantics of the referenced type.

Swift SVN r6431
2013-07-21 18:39:56 +00:00
Joe Groff
1984cf41e0 SIL: Rename SILFunction::getMangledName to SILFunction::getName.
Swift SVN r6430
2013-07-21 18:39:51 +00:00
Joe Groff
59c7fa881c SIL: Refactor TypeLoweringInfo to be keyed on SILType.
SIL passes need to have the value semantics information in TypeLoweringInfo available by SILType. Refactor getTypeLoweringInfo into separate "derive the SILType from a Swift type" and "determine the value semantics for a SILType" stages, and index the resulting TypeLoweringInfo by both (CanType, uncurryLevel) and SILType.

Swift SVN r6429
2013-07-21 18:39:47 +00:00
Chris Lattner
099f0cf451 simplify the construction of SILFunctionTypeInfo, inlining some singly-called helper functions.
Swift SVN r6427
2013-07-21 15:42:25 +00:00
Chris Lattner
c7373c563b add regular convenience methods to SIL IR objects for getting parent containers.
Add a getOperand(n) method to SILInstruction.


Swift SVN r6425
2013-07-21 06:12:29 +00:00
Chris Lattner
a9e92a2b61 Expose basic post-dominance information.
Swift SVN r6421
2013-07-21 04:29:29 +00:00
Chris Lattner
496446ce64 Make all SIL objects that are print()-able, also raw_ostream insertable
with <<.  Use this to implement a DEBUG() dump in MemoryPromotion.cpp


Swift SVN r6412
2013-07-20 02:43:26 +00:00
Chris Lattner
8638600923 simplify a SILBuilder constructor.
Swift SVN r6410
2013-07-20 01:58:36 +00:00
Chris Lattner
f8c8eb1037 add some helper methods for IR passes to use.
Swift SVN r6407
2013-07-20 01:36:46 +00:00
Chris Lattner
d528b49fca make getElementType() methods on SIL allocation instructions return a SILType.
This points out that perhaps IRGen's HeapArrayInfo should traffic in SILTypes
instead of CanTypes.  I did the minimal update though.


Swift SVN r6405
2013-07-20 01:25:20 +00:00
Chris Lattner
47dd7a4cf4 rename SIL internals for AllocVar and DeallocVar to [De]AllocStack.
No syntax change yet.


Swift SVN r6382
2013-07-19 19:38:29 +00:00
John McCall
6b6427ee55 TypeVariableType and ErrorType are canonical, even if
they're unchecked, and they should have Can* variants.

Swift SVN r6375
2013-07-19 07:08:30 +00:00
John McCall
170868921b UnboundGenericType is now an UNCHECKED_TYPE.
Change a couple routines which can validly be used on
unchecked decls/types to not generically handle UNCHECKED_TYPE.

Swift SVN r6374
2013-07-19 03:10:15 +00:00
Argyrios Kyrtzidis
ff072270c7 Use CanType in the Mangler API.
Swift SVN r6369
2013-07-19 00:47:58 +00:00
John McCall
16063866ed Preserve type canonicality with isa/cast/dyn_cast.
Swift SVN r6362
2013-07-18 23:28:53 +00:00
Joe Groff
8e56e45f22 SIL: Define a switch_oneof instruction.
This instruction encapsulates testing, branching, and destructuring a oneof, as in:

oneof Expr {
  case True
  case False
  case IntLiteral(Int)
  case StringLiteral(String)
}

sil @dispatch_expr : $(Expr) -> () {
entry(%expr : $Expr):
  switch_oneof %expr, \
    case #Expr.True!oneofelt : bb1, \
    case #Expr.False!oneofelt : bb2, \
    case #Expr.IntLiteral!oneofelt : bb3, \
    default bb4
bb1:
  ...
bb2:
  ...
bb3(%int : $Int):
  ...
bb4:
  ...
}

Swift SVN r6329
2013-07-17 16:55:29 +00:00
Anna Zaks
a984d9b24c Move the SIL diagnostic emission entrypoint from SILGen to the top level swift.cpp driver
This addresses Chris’s review of r6151.

Swift SVN r6290
2013-07-16 18:53:23 +00:00
Anna Zaks
4d2e985a33 Cleanup: Forward declare SourceLoc instead of including it
Swift SVN r6285
2013-07-16 01:50:32 +00:00
Anna Zaks
f6d1ec48f0 [SIL] Refactor SILLocation not to derive from PointerUnion3 but to include it as a member
As per Chris's suggestion (review of r6152), further refactored SILLocation not to derive from PointerUnion3 but to include it as a member.

In addition, added some template magic to make sure we don't have to chain dyn_casts, which I suspect will be/is happening a lot with SILLocation:
Ex:
-  if (auto E = Func.dyn_cast<Expr*>()) {
-    if (const FuncExpr *FE = dyn_cast<FuncExpr>(E))
-      return SILLocation(FE->getBody())
+  if (const FuncExpr *FE = Func.getAs<FuncExpr>())
+    return SILLocation(FE->getBody());

Swift SVN r6283
2013-07-16 01:50:29 +00:00
Dmitri Hrybenko
aa46064432 Pass a const ASTContext and const DeclContext whenever possible. This makes it
possible to use lookupVisibleDecls() with a const DeclContext.


Swift SVN r6274
2013-07-15 23:39:00 +00:00
Doug Gregor
a12d30d9b1 Emit entrypoints for the default argument generator functions.
In the resilience model for default arguments, the presence of a
default argument is API, but its specific value is not. Thus, the
actual default argument values can evolve over time. To implement
this, for each default argument, we emit a function that
takes no arguments and produces the default value for that
argument. The caller will then call that function to form the default
argument.

This commit emits these functions for each default argument, even
though they are not currently being called. This is part of
<rdar://problem/11561185>.

We'll probably want a different calling convention for these functions
that preserves all registers, since they will often end up being very
trivial functions. 




Swift SVN r6260
2013-07-15 17:34:22 +00:00
Chris Lattner
12872e5190 remove the allocation kind enum from alloc_var/dealloc_var/alloc_ref. There is
only one kind now: stack.  alloc_var is just for stack memory now.


Swift SVN r6256
2013-07-15 16:48:56 +00:00
Chris Lattner
5322275156 remove the 'heap' form of alloc_var. It is not used, and the imagined
possible use cases are far enough away that we shouldn't worry about them
now.


Swift SVN r6253
2013-07-15 16:33:09 +00:00
Chris Lattner
5c1320042c remove the "pseudo" class of alloc_var. It is not used.
Swift SVN r6252
2013-07-15 16:25:19 +00:00
Anna Zaks
4078785192 Turn SILLocation out of typedef and into a class.
Swift SVN r6154
2013-07-11 17:12:13 +00:00
Anna Zaks
2e4170e249 Add the first SIL-based waring - "missing return"
Add a warning on a missing return statement.
(This is not yet an error since we need to handle no-return functions.)

Swift SVN r6153
2013-07-11 17:12:12 +00:00
Anna Zaks
c315b357af Add SILLocation to the SILFunction and to the UnreachableInst, which represents falling off the end of the function.
Both of these are needed to produce user-friendly diagnostics from SIL.

Swift SVN r6152
2013-07-11 17:12:12 +00:00
Joe Groff
f24add3175 SIL: Give Unreachable instructions SILLocation info.
UnreachableInst's constructor didn't take a SILLocation. Oops. Fix that, and associate Unreachables emitted due to failed switch coverage with the switch. For missing-return Unreachables, there isn't yet readily available SILLocation info to attach to them, but Anna will fix that soon.

Swift SVN r6132
2013-07-10 21:54:37 +00:00
Joe Groff
4bbf608e8f SILGen: Implement variable bindings.
As clause matrix specialization exposes columns with variable bindings, bind all of the variables in each column to a new box for the variables in that column. (Since only one row out of the matrix ever ends up getting executed, we can share one box for the entire column.) Set up a scope hierarchy following that of the specialized clause matrices, and associate each case with the scope it needs to see all the variables of its fully-destructured pattern clause. Remove our ad-hoc hack for binding ExprPattern implicit variables, and bind them to the column's box too.

Swift SVN r6127
2013-07-10 19:09:58 +00:00
Joe Groff
5f9ff68d95 Revert r5949: "SIL: Null-terminate literal instruction string data."
The APFloat crash should be fixed in LLVM trunk, and we haven't seen the Interpreter crash in a while.

Swift SVN r6095
2013-07-09 20:49:52 +00:00
Joe Groff
0ac8c2b532 SIL: Null-terminate literal instruction string data.
Guard against StringRef-uncleanness in APFloat (e.g. rdar://14323230) and hopefully stop the intermittent buildbot failures in some Interpreter tests.

Swift SVN r5951
2013-07-01 21:48:31 +00:00
Chris Lattner
b13c50157e implement proper name binding and resolution of global sil function names, including
diagnosing redefinitions, use of undefined values, handling forward references, etc.



Swift SVN r5908
2013-06-30 19:31:19 +00:00
Adrian Prantl
c375617244 Address a couple of Joe's comments.
Swift SVN r5858
2013-06-27 23:25:22 +00:00
Chris Lattner
c18abe1ca3 add newline
Swift SVN r5831
2013-06-27 03:48:14 +00:00
Adrian Prantl
de32b201d0 Debug Info: Add support for subprograms.
This means that single-stepping in lldb actually works now!

Swift SVN r5828
2013-06-27 00:46:30 +00:00
Joe Groff
59e803ed84 ClangImporter,SIL: Bridge ObjCBool to Bool.
Map BOOL parameters, return types, and properties to swift.Bool in the Clang importer like we map NSString to swift.String. Generalize SIL's handling of type bridging to accommodate Bool bridging in addition to String bridging. Add convertObjCBoolToBool and v.v. entry points for the compiler to use to insert bridging conversions between the two types. Implements <rdar://problem/14271667>.

Swift SVN r5819
2013-06-26 21:15:17 +00:00
Chris Lattner
5c661f3c38 push global reference parsing forward a bit, diagnosing a type error.
Swift SVN r5811
2013-06-26 05:33:49 +00:00
Doug Gregor
cace751e86 Eliminate DeducibleGenericParamType.
The type was used by the old type coercion code; it is no longer relevant.


Swift SVN r5799
2013-06-25 16:32:44 +00:00