Commit Graph

512 Commits

Author SHA1 Message Date
Chris Lattner
3c0c9a5da7 introduce a new mark_uninitialized SIL instruction which will be used by
definitive initialization of top-level code.


Swift SVN r8144
2013-09-12 04:30:48 +00:00
Joe Groff
705102b544 SIL: Rename 'ClangThunk' specifier to 'Thunk'.
Lazily-generated currying thunks will require the same IR-level linkonce_odr linkage as clang thunks currently do, so generalize the name of the existing SIL-level linkage specifier 'clang_thunk'.

Swift SVN r8122
2013-09-11 23:47:15 +00:00
Joe Groff
cc37187c53 SIL: Remove 'UncurryDirection' and uncurry all methods right-to-left.
ObjC methods are already tagged with a special calling convention and have special IRGen handling to keep the _cmd argument abstracted away from SIL. We can use the CC to also abstract away the detail that Swift methods pass 'self' last but ObjC methods pass 'self' first. This eliminates a weird special case from SIL's perspective, and also means that 'partial_apply' can work on objc methods correctly without becoming significantly more complex.

Swift SVN r8091
2013-09-11 17:05:44 +00:00
Joe Groff
e80871f3e2 SIL: Don't crash when printing closure-local SILDeclRefs.
I don't know what we should print here to produce a parsable SILDeclRef, but this keeps tests from crashing in the meantime.

Swift SVN r8075
2013-09-10 18:59:12 +00:00
Doug Gregor
24f4706056 SIL: Introduce the dynamic_method_br instruction.
The dynamic_method_br instruction branches depending on whether a
particular object can accept a given message, as determined at
runtime. If the object can accept the message, it branches to the
first basic block, providing the uncurried method as the BB
argument. If the object cannot accept the message, it branches to the
second basic block. Either way, the result is packaged up into an
optional type and passed along to the continuation block, which
provides the optional result.

Note that this instruction is restricted to lookup of Objective-C
methods.

Documentation and IR generation (via -respondsToSelector) to
follow. Review greatly appreciated!



Swift SVN r8065
2013-09-09 23:46:10 +00:00
Chris Lattner
55200e5274 Now that Module has its own kind field, drop the various module
discriminators from DeclContext.  This is cleaner and should
enable us to drop the alignment of DeclContext (coming next Jordan!)



Swift SVN r8059
2013-09-09 22:43:11 +00:00
Doug Gregor
c5557a624c SIL: Introduce the 'dynamic_method' instruction for dynamic method dispatch.
The dynamic_method instruction handles method lookup on an existential
of type DynamicLookup based on the selector of an [objc] method of a
class or protocol. It is only introduced in the narrow case where we
are forcing a use of the method with '!', e.g.,

class X {
  func [objc] f() { println("Dynamic lookup") }
}

var x : DynamicLookup = X()
x.f!()



Swift SVN r8037
2013-09-09 16:12:50 +00:00
Doug Gregor
6e67e34b40 Rename DynamicMethodInst -> MethodInst.
Swift SVN r8031
2013-09-09 14:29:51 +00:00
Anna Zaks
42f87d7725 [SIL] Represent module-level locations.
These are used for code that is usually associated with the enclosing decl such as epilog code and cleanups.

Swift SVN r8017
2013-09-06 23:57:25 +00:00
Anna Zaks
2015d3a767 [SIL] Dump the <no loc> SILLocation, which means the SILLocation is null.
Swift SVN r7914
2013-09-04 21:57:48 +00:00
Anna Zaks
fbcf5d458f [SIL Loc] Use a separate bit to represent auto-generated code
Auto generated location should not be a separate location kind since
we might have different kinds of auto generated locations (ex: cleanup,
return). Even though the kind info might not be necessary for diagnostics or
debug info, it allows us to better use type system, for example, only pass
CleanupLocation where expected.

Swift SVN r7816
2013-08-30 23:41:33 +00:00
Dmitri Hrybenko
d98408425e Remove unused OwningPtr.h includes
Swift is C++11 and uses std::unique_ptr.


Swift SVN r7731
2013-08-29 20:09:49 +00:00
Anna Zaks
b67f3c3552 [SIL] Use the ReturnLocation/ImplicitReturnLocation instead of generic SILLocations.
We mark the branch instructions leading into single epilog code with ReturnLocation/ImplicitReturnLocation. If SIL Gen simplifies the code and merges the code representing the return into the epilog block, the terminator of the epilog block (the ReturnInst) will have the return location info on it. Otherwise, the ReturnInst has the RegularLocation, which represents the enclosing FunctionExpr or Constructor/Destructor Decls.
(I've discussed dropping the optimization from SILGen, and keeping the epilog code canonical, with Adrian; but he said that there might not be any wins in doing so, so keeping it for now.)

Added AutoGeneratedLocation to represent segments of code generated by SILGen. This will be used for thunks and other auto-generated segments.

Swift SVN r7634
2013-08-27 22:16:24 +00:00
Michael Gottesman
d41b871b3a At Joe's suggestion added the prefix strong to instructions Retain,Release,RetainAutoreleased,RetainUnowned to prevent confusion in between RetainUnowned and UnownedRetain.
This is was a very mechanical patch where I basically first renamed SILNodes.def
and then just kept fixing things until everything compiled, so even though it is
large patch I feel ok(ish) with committing it.

If anyone has any concerns/etc, please email me and I will revert in 1 second.

Swift SVN r7604
2013-08-26 23:32:16 +00:00
Joe Groff
c74dc79610 SIL: Add instructions to implement address-only unions.
Because union layout may interleave tag bits with payload data, we need to be able to efficiently inject and remove tag bits from an address-only union in-place. To do this, we'll model address-only union initialization by projecting out the data address (union_data_addr) and storing to it, then overlaying the tag bits (inject_union_addr). To dispatch and project out the data, we'll use a destructive_switch_union_addr instruction that clears any tag bits in-place necessary to give a valid data address.

Swift SVN r7589
2013-08-26 20:50:31 +00:00
Joe Groff
fe1ad586e7 SIL: Add a 'union' instruction to construct unions.
The instruction represents constructing a loadable union given a case and the data for that case, which will let us emit union constructor functions in SIL instead of IRGen (rdar://problem/14773182).

Swift SVN r7558
2013-08-24 18:33:24 +00:00
Chris Lattner
e1855fd3a5 move SIL verification logic to SIL/Verifier.cpp and change
sil-opt to run the verifier after every sil pass it runs.


Swift SVN r7477
2013-08-22 21:27:19 +00:00
Chris Lattner
29829a23f4 change the SILPrinter to print the demanged name for a function_ref on the previous line, instead of at the end of an already really long line. This is a purely cosmetic comment change.
Swift SVN r7452
2013-08-22 16:50:42 +00:00
Chris Lattner
69d0afb658 rename [force_inlining] to [transparent].
Swift SVN r7448
2013-08-22 16:05:41 +00:00
Enrico Granata
47d1a137b5 Major demangler changes.
This commit changes the Swift demangler to produce a tree-like list of tokens instead of a string.
This is mostly useful for LLDB since we can use the inherent structure in a Swift mangled name to make more informed decisions about matters such as type information extraction from modules
The ability to convert the tokenized output into a plain string for viewing purposes is of course preserved



Swift SVN r7297
2013-08-16 22:30:58 +00:00
Stephen Lin
5fc7966675 Add [force_inline] to SIL apply instruction; kill FunctionInst abstract value type
Swift SVN r7163
2013-08-12 17:33:37 +00:00
Chris Lattner
b25af92552 change the StoreWeak "initialization" bit and accessors to follow the naming
convention of the CopyAddrInst methods.


Swift SVN r7161
2013-08-12 17:30:02 +00:00
Chris Lattner
c8f01a0bf3 Introduce a new SIL "assign" instruction to represent assignments in SIL when
SILGen doesn't know whether they are initializations or stores.


Swift SVN r7146
2013-08-12 14:24:52 +00:00
Dmitri Hrybenko
efd688dcd9 Now findBufferContainingLoc() can not fail, so store Buffer IDs in unsigned
variables.


Swift SVN r7121
2013-08-10 02:12:59 +00:00
Manman Ren
538a4c118c SIL Parser: parse specialize.
Modify SILPrinter to print the generic function type for specialize.

TODO: the testing case needs uniquing of PolymorphicFunctionType. Right now,
we will get a type mismatch between two copies of the same
PolymorphicFunctionType.


Swift SVN r7097
2013-08-09 20:27:24 +00:00
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +00:00
Manman Ren
591410ea23 SIL Parser: parse init_existential, init_existential_ref, deinit_existential.
TODO: Conformances are currently not included in SIL.rst for init_existential
or init_existential_ref, but they exist in InitExistentialInst and
InitExistentialRefInst.


Swift SVN r7076
2013-08-09 01:10:10 +00:00
Ted Kremenek
a32d8e357a Add basic color output to SILPrinter for terminals that support color.
Current the following is colorized:
- basic block labels
- types
- SSA values

Swift SVN r7044
2013-08-08 15:05:51 +00:00
John McCall
14cb7001b3 Implement basic support for [weak].
Swift SVN r7041
2013-08-08 04:04:51 +00:00
Anna Zaks
aaa4b2c332 [SIL Printer] Add optional source location printing.
Added a -v(verbose) option to swift that will trigger verbose printing in SIL
Printer. SIL Printer will print the location info only in the verbose mode.

Here is the example of the format - only the line and colon are displayed for
brevity:

%24 = apply %13(%22) : $[cc(method), thin] ((), [byref] Bool) -> Builtin.Int1 // user: %26 line:46:10

(This will be used to test the validity of SILLocation info.)

Swift SVN r6991
2013-08-07 18:39:48 +00:00
John McCall
e9b913fb5b Remove LocalStorageType, make it a kind of SILType.
Swift SVN r6968
2013-08-07 00:22:26 +00:00
John McCall
fcd998a48b PrettyStackTrace enhancements for SIL constructs.
Swift SVN r6966
2013-08-07 00:10:57 +00:00
John McCall
b0084f7204 Prepare SILType for more than just isAddress.
Swift SVN r6946
2013-08-06 20:23:12 +00:00
John McCall
592732c6b4 Split *one* unimplemented dealloc_ref instruction into
*two* unimplemented instructions!  This is progress.

Swift SVN r6931
2013-08-06 01:23:51 +00:00
Manman Ren
bfe0c39884 SIL Parser: parse builtin_function_ref.
In SILParser, factor out lookupTopDecl and lookupMember.
lookupTopDecl finds the top-level ValueDecl or Module given a name and
lookupMember finds the ValueDecl given a type and a member name.
Update comments for parseSILDeclRef to match SIL.rst.
We now handle the case where the first component of a dotted path is a
module.

In SILPrinter, print the full path for builtin_function_ref, also
"!" is optional when printing SILDeclRef.


Swift SVN r6926
2013-08-06 00:53:07 +00:00
John McCall
b77c430848 Add SIL-gen and some missing runtime support for [unowned].
Swift SVN r6881
2013-08-03 08:46:54 +00:00
Joe Groff
5a2128bc77 SIL: Model project_existential using an address.
Have project_existential return $*This instead of $Builtin.OpaquePointer, and have protocol_method do the same for methods of opaque protocols. This makes it easier for passes to reason about the semantics of the projected address, since it's restricted by the semantics of SIL addresses.

Swift SVN r6872
2013-08-03 01:48:15 +00:00
John McCall
d7a72b93e1 Add ref_to_unowned and unowned_to_ref bitcast instructions.
Swift SVN r6838
2013-08-02 08:31:01 +00:00
John McCall
00a940ac1b Rename weak_retain to unowned_retain and change it to
require the correct [unowned] type as an argument.

Swift SVN r6825
2013-08-02 00:02:09 +00:00
Anna Zaks
2c529eb21a [SILParser] Parse basic block arguments in branch instructions
Added types when printing these args in the SIL printer.

As a side effect, I've removed the assertions that check
that we have the correct number of arguments in the Branch instruction
creation routines. The reason is that we do not have a complete block when
parsing and creating the branch instruction and it is possible to add
arguments to a basic block after creation. The assertion will be checked
by the SIL verifier.

Swift SVN r6818
2013-08-01 21:32:05 +00:00
Joe Groff
ba774364f1 SIL: Have SILModules track their SILStage.
Modules can be in either 'Raw' or 'Canonical' form, with different invariants on each. We don't actually distinguish those invariants yet, but this patch adds the field to SILModule and adds a "sil_stage" declaration to SIL printer/parser syntax.

Swift SVN r6793
2013-08-01 00:58:31 +00:00
Jordan Rose
674a03b085 Replace "oneof" with "union"...everywhere.
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!

Swift SVN r6783
2013-07-31 21:33:33 +00:00
Joe Groff
cc45633714 SIL: Don't print instruction labels for value-less instructions.
Swift SVN r6756
2013-07-30 22:33:34 +00:00
Joe Groff
26c00fd429 SIL: Add a switch_int instruction.
This will help represent cleanup blocks in the grown-up Clang way instead of the childish SILGen way, e.g.:

  retain %x
  retain %y
  ...
break_branch:
  %1 = int_literal 1 : $Builtin.Int64
  br cleanup(%1)
return_branch:
  %2 = int_literal 2 : $Builtin.Int64
  br cleanup(%2)
cleanup(%dest : $Builtin.Int64):
  release %z
  release %y
  switch %dest, case 1: break_dest, case 2: return_dest

Swift SVN r6753
2013-07-30 21:32:23 +00:00
Argyrios Kyrtzidis
21785c8a36 Call Type::print(), instead of TypeBase::print(); the former includes the null check.
Swift SVN r6751
2013-07-30 21:25:36 +00:00
Enrico Granata
c75fe924a1 Moving the Swift demangler from libSIL to libBasic
Plus, a couple of minor cosmetic changes that I had held off for a couple days now



Swift SVN r6691
2013-07-29 17:42:57 +00:00
Joe Groff
50bd6cb630 SILPrinter: Handle bound generic types as SILConstant context.
Fixes <rdar://problem/14503782>.

Swift SVN r6688
2013-07-29 15:55:42 +00:00
Joe Groff
3c03a8cb21 SIL: Patch up float_literal bit handling.
Add a getBits() method to FloatLiteralInst so we don't need to round trip APInt -> APFloat -> APInt to print the bits in the printer. Use allocateLiteralInstWithBitSize instead of -WithTextSize to avoid wasting space.

Swift SVN r6680
2013-07-28 17:39:51 +00:00
Joe Groff
d46bdbe25d SIL: Reorder float_literal printing to be a bit clearer.
Swift SVN r6679
2013-07-27 17:10:39 +00:00
Joe Groff
24dc1cfad7 SIL: Remove the redundant associated_metatype instruction.
Its behavior was exactly the same in IRGen as 'metatype' on the associated type. Managing type metadata should be IRGen's job.

Swift SVN r6677
2013-07-27 04:13:59 +00:00