Commit Graph

6634 Commits

Author SHA1 Message Date
John McCall
8d68478c77 Move the SILDeclRef mangler to the SIL library. NFC.
Swift SVN r11894
2014-01-04 09:11:14 +00:00
Michael Gottesman
445e6167a4 Add 3 arguments SILBuilder::createTupleExtract which infers the 4th type argument from its operand.
There already is an analogous 3 argument version of
SILBuilder::createStructExtract that works like this.

I use this in the soon to be incoming SILSROA.

Swift SVN r11891
2014-01-04 05:58:59 +00:00
Joe Groff
62e9afa778 Provide "interface" versions of SILFunctionType's convenience APIs.
And put some macros on things so we can flip a switch and get deprecation warnings for things using the old types.

Swift SVN r11867
2014-01-03 20:11:16 +00:00
Doug Gregor
1ee513e7e8 Use Builtin.Word for array lengths, string literal lengths, etc.
This eliminates a number of 64-bit integer/64-bit pointer assumptions
in the type checker and SILGen.


Swift SVN r11863
2014-01-03 18:53:01 +00:00
Joe Groff
53d2844a2e SIL: Give TypeLowering support for dependent generic contexts.
Give TypeConverter methods to push and pop a generic context given a set of generic parameter types and requirements from a generic signature. Dependent types lowered in this context can then be lowered using an ArchetypeBuilder seeded with that signature. The TypeLowering objects created for dependent types are put in a special arena which we clear out when we pop the generic context. This sets the stage for allowing us to lower SILFunctionTypes using their interface types.

Swift SVN r11848
2014-01-03 04:04:46 +00:00
Joe Groff
7331eddfcc SIL: Handle dependent types in AbstractionPattern::isOpaque.
To do this with complete accuracy requires mapping the dependent types into a context, but isOpaque is currently only used as a sanity check in assertions, and a tuple being matched to a class-constrained archetype is an unlikely enough occurrence that it's probably OK to accept this inaccuracy instead of trying to push generic contexts all the way down into isOpaque's clients.

Swift SVN r11824
2014-01-02 19:04:00 +00:00
Joe Groff
cdc2b34a80 SIL: Give SILFunction context generic params and a mapTypeInContext method.
For now, steal the context generic params from the SILFunctionType, and borrow ArchetypeBuilder's implementation of mapTypeInContext for AST decl contexts. This should eventually be an independent property.

Swift SVN r11811
2014-01-02 05:47:39 +00:00
Chris Lattner
917d2a1d9c remove the dead 'TypeConverter::getMethodSelfType' method, which
is also incorrect.


Swift SVN r11807
2014-01-02 00:59:01 +00:00
Chris Lattner
859883d88e further detangle @lvalue and @inout. types, this time in libsil.
Swift SVN r11800
2014-01-01 20:46:54 +00:00
Chris Lattner
1cda63d0b3 sil abstraction patterns never see @lvalue types, only @inout types.
Swift SVN r11797
2014-01-01 20:24:34 +00:00
Michael Gottesman
962df13b6c [lower-aggregate-instrs] Teach TypeLowering how to produce "lowered" copy values without bugs this time = ).
Originally there was a emitLoweredCopyValue method in TypeLowering, but it was
removed by Chris in r11353 since SILGen was no longer using it and it had bugs.
This method is useful for SILLowerAggregateInstrs, so I resurrected it, fixing
the bugs therein.

The bug was that emitLoweredCopyValue was not reforming aggregates correctly
since it was only considering non-trivial values. The new implementation passes
in all child values, but only recursively lowers the non-trivial children. This
does create an extra tuple_extract, struct_extract for trivial arguments, but
those are easily cleaned up by later dce.

Swift SVN r11753
2013-12-31 01:10:45 +00:00
Michael Gottesman
e960091e31 [lower-aggregate-instrs] Add an additional type lowering style "DeepNoEnum" for use in lowering aggregate memory operations.
The idea here is that the aggregate memory operation is lowered deep recursively
for all types except enums which recieve a shallow lowering. This prevents code
bloat due to the deep lowering of an enum requiring the creation of a bunch of
new basic blocks, code bloat which we do not want.

Another thing to note is that this method is actually not used anywhere else
currently, but in case this behavior was left in on purpose I decided to extend
it by adding the enum class flag rather than just changing the underlying
behavior (i.e. making deep not lower enum values).

Swift SVN r11748
2013-12-30 23:07:32 +00:00
Chris Lattner
9ae289de46 Drive the semantic wedge harder into lvalues. Now, instead of having one LValueType
with qualifiers on it, we have two distinct types:
 - LValueType(T) aka @lvalue T, which is used for mutable values on the LHS of an
   assignment in the typechecker.
 - InOutType(T) aka @inout T, which is used for @inout arguments, and the implicit
   @inout self argument of mutable methods on value types.  This type is also used
   at the SIL level for address types.

While I detangled a number of cases that were checking for LValueType (without checking
qualifiers) and only meant @inout or @lvalue, there is more to be done here.  Notably,
getRValueType() still strips @inout, which is totally and unbearably wrong.



Swift SVN r11727
2013-12-29 22:23:11 +00:00
Chris Lattner
d3c91387e9 Substantially simplify the API to LValueType now that nonsettable is gone.
Swift SVN r11703
2013-12-28 22:48:44 +00:00
Nadav Rotem
3355cf7bfa VTables should be accessed by reference.
Swift SVN r11691
2013-12-28 09:00:12 +00:00
Joe Groff
c76548916e SIL: Have VTables and WitnessTables bump the reference counts of SILFunctions.
Fixes <rdar://problem/15725600>.

Swift SVN r11666
2013-12-27 05:59:19 +00:00
Joe Groff
3e30cbcfef SILGen/IRGen: Don't emit top_level_code for libraries.
If there's no script-mode file in a module, don't produce a top_level_code SILFunction for it, and don't consider emitting an LLVM global_ctor for it. We should never emit static constructors from user code anymore.

Swift SVN r11644
2013-12-26 00:18:29 +00:00
Michael Gottesman
2eb34c35a4 [sil-inliner] Ensure that all special flags are propagated when we create a CleanupLocation, MandatoryInlinedLocation, or InlinedLocation from a SILLocation.
This corresponds to the fix I spoke of in r11595.

Swift SVN r11600
2013-12-23 06:35:38 +00:00
Nadav Rotem
20410a3b92 CondBranchInst: Save the number of true and false arguments.
The current implementation depends on the target basic block to record the number of argumens, but this is a bad idea because it makes it difficult to modify the argument list.



Swift SVN r11597
2013-12-23 06:23:02 +00:00
Michael Gottesman
668320964f [sil-inliner] Teach silcloner how to remap undefs.
Swift SVN r11591
2013-12-23 03:02:20 +00:00
Joe Groff
8f47dc7383 SIL: Add a SILModule::lookUpWitnessTable method.
Looks up the SILWitnessTable for a ProtocolConformance.

Swift SVN r11576
2013-12-22 22:37:56 +00:00
Joe Groff
fd7b61ac71 SIL: Add a lookup cache StringMap to SILModule.
Because doing linear lookup all the time is dumb. NFC.

Swift SVN r11575
2013-12-22 22:37:55 +00:00
Chris Lattner
1472e4d914 Remove the ASTContext argument from LValueType::get(). It is already
only two loads away from the type argument passed in.



Swift SVN r11496
2013-12-20 01:28:50 +00:00
Michael Gottesman
b390ad4279 Fixed typo from 11456.
Swift SVN r11457
2013-12-19 00:27:29 +00:00
Michael Gottesman
dffa7fe5bf [sil-inliner] Add support for Stmt, Pattern ASTNodes to Inlined/MandatoryInlined Location as per my discussion with Anna.
Swift SVN r11456
2013-12-19 00:16:21 +00:00
Chris Lattner
b35cd1e276 remove emitLoweredCopyValue, it is dead and happens to have bugs.
This resolves rdar://15669586


Swift SVN r11353
2013-12-16 19:42:28 +00:00
Jim Ingham
e0b163ae67 Pass a SILBuilder into the debugger client so that
it can indeed build SIL expressions rather than just
look at them go by.


Swift SVN r11285
2013-12-14 01:14:44 +00:00
Joe Groff
2db553c98d SIL: Give protocol members @cc(witness_method) convention.
Swift SVN r11283
2013-12-14 00:03:55 +00:00
Joe Groff
fe99127bdb SILGen: Don't emit base_protocol or associated_type_protocol witness table entries for @objc requirements.
And put the 'P->isObjC()' check behind a more semantic 'protocolRequiresWitnessTable' check.

Swift SVN r11276
2013-12-13 23:37:07 +00:00
Joe Groff
1da0fba39c SILGen: Emit witness tables for generic types.
Tweak the type lowering code to work when the conforming type is generic. Handle the case of an associated type with protocol requirements being witnessed by an archetype of the conforming type, which results in a null ProtocolConformance pointer in the witnessing substitution.

Swift SVN r11275
2013-12-13 22:59:38 +00:00
Joe Groff
61c674b82f SILGen: Include refined protocol conformances in witness tables.
When a type conforms to a protocol that refines another protocol, emit the witness table for the base protocol, and drop a reference into the witness table for the derived protocol. Keep track of what conformances we've already emitted so we don't emit redundant witness tables when types conform redundantly to base protocols or have multiple references to a base protocol via a refinement diamond.

Swift SVN r11263
2013-12-13 19:23:22 +00:00
Joe Groff
402f4daa58 SILGen: Emit protocol witnesses.
Reuse John's abstraction thunking machinery in SILGenPoly to emit the abstraction change from a protocol requirement to a concrete witness. There are potentially two abstraction changes necessary; if a witness is generic, we need to reabstract again from the concrete substituted type of the witness to the generic witness function's original signature. This currently leads to a bunch of extra temporaries in cases where an argument or return gets unabstracted to a loadable value then reabstracted to a generic parameter, but optimizations should be able to clean this up. Protocol witnesses also have additional potential abstraction changes in their 'self' parameter: the 'self' parameter of the protocol requirement is always considered @inout, but class 'self' parameters are not; also, an operator requirement can be satisfied by a free function, in which case 'self' is discarded.

Also, fix a bug in return value thunking where, if the thunk could reuse its @out parameter as the @out parameter of the underlying function, we would not disable the cleanup we install on the result value, leading to the result getting overreleased.

Swift SVN r11245
2013-12-13 05:58:51 +00:00
Adrian Prantl
c610ac94ef Add an IsBare attribute to SILFunction for functions that do not have an
AST.

Swift SVN r11236
2013-12-13 04:48:37 +00:00
Sean Callanan
a1881434c2 Added support to allow LLDB to provide the
location of variables at SIL generation time.
This patch introduces a SILDebuggerClient that
knows how to resolve the locations of variables
that are generated by the debugger.  These
variables have a flag on them that only LLDB
sets.


Swift SVN r11230
2013-12-13 01:43:02 +00:00
Anna Zaks
e9870cd347 [SIL] Add helper - it's useful when printing SILInstructions.
Swift SVN r11196
2013-12-12 19:07:02 +00:00
Nadav Rotem
a8887d0ff4 Specialize calls using call-graph information.
Swift SVN r11156
2013-12-12 00:05:21 +00:00
Joe Groff
88e5dece28 SILGen: Implement a visitor to produce witness tables.
Walk the ProtocolConformances of type and extension decls to produce SILWitnessTables for them. Work out the type of the witness function by applying substitutions from the witness map and lowering it at the abstraction level of the requirement, then emit a symbol for the witness function (but don't emit the body of the witness function just yet).

Swift SVN r11143
2013-12-11 21:40:44 +00:00
Adrian Prantl
2acb71831e SILArgument: Make Decls mandatory for function arguments.
Swift SVN r11099
2013-12-10 23:30:23 +00:00
Adrian Prantl
8b99609e94 relax assertion
Swift SVN r11096
2013-12-10 22:53:16 +00:00
Adrian Prantl
1f927d9ffc Overhaul the handling of return locations for auto-generated code.
- change SILGenFunction to use Cleanup and Implicit return locations for
  auto-generated cleanups/returns where sensible.
- Fix a bug in where ConstructorDecl that would return the wrong
  source range.
- Move the expected locations of some errors to the end of the function
  where they should belong.

Fixes <rdar://problem/15609768> Line tables for classes that don't have
init but just initialize ivars are odd

Swift SVN r11086
2013-12-10 19:23:34 +00:00
Adrian Prantl
0fb0dff185 formatting
Swift SVN r11085
2013-12-10 19:23:33 +00:00
Joe Groff
02a0e996c4 SIL: Kill initialize_var instruction.
Remove the initialize_var instruction now that DI fully diagnoses initialization problems. Change String-to-NSString bridging to explicitly invoke String's default constructor; it was the last remaining user of initialize_var. Remove dead code to emit an implicit default constructor without a body.

Swift SVN r11066
2013-12-10 03:36:59 +00:00
Chris Lattner
a0499d90d5 remove the SIL builtin_zero instruction.
Swift SVN r11052
2013-12-09 23:41:35 +00:00
Chris Lattner
bf3948139d introduce a new "derived self" form of mark_uninitialized.
Swift SVN r11021
2013-12-09 15:25:46 +00:00
Chris Lattner
db0fe52b65 Introduce a new CaptureKind::Constant concept to SILGen, allowing it
to correctly form closures over 'constant' VarDecls like 'self' in 
some cases.


Swift SVN r10978
2013-12-07 05:48:59 +00:00
Chris Lattner
dec95a6890 At Joe's request, rename CaptureKind::Constant ->
CaptureKind::LocalFunction, and LocalConstants -> LocalFunctions


Swift SVN r10965
2013-12-07 01:25:30 +00:00
Joe Groff
27d96bbdc9 SIL: Generalize archetype_method to accept concrete types.
Allow archetype_method to look up a witness from a concrete ProtocolConformance record. This will allow generic specialization to apply to constrained generic functions independent of archetype_method devirtualization. <rdar://problem/14748543>

Swift SVN r10950
2013-12-07 00:00:51 +00:00
Joe Groff
59e5272e9c SIL: archetype_method and protocol_method will have simpler requirements in the new regime.
They will always return a thin function with the appropriate witness CC. The metadata pointer, if any, will be passed as part of the witness CC lowering.

Swift SVN r10923
2013-12-06 15:58:10 +00:00
Joe Groff
2a7de8f495 Introduce a SILWitnessTable class.
We will generate these in SILGen when we see a NormalProtocolConformance, to provide a mapping of method requirements to witnesses for types.

Swift SVN r10900
2013-12-06 01:32:36 +00:00
Joe Groff
0ff977d407 Add a 'WitnessMethod' enumerator to AbstractCC.
We'll use this to represent the slightly-different polymorphic calling convention used for passing Self into protocol witnesses.

Swift SVN r10898
2013-12-06 01:32:35 +00:00