Commit Graph

6634 Commits

Author SHA1 Message Date
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
Chris Lattner
e2611273fc extend SILLocation to be able to store locations in SIL files.
This doubles SILLocation to being two words, since SourceLocations
can't be dumped into a PointerUnion, but it is due for a redesign someday
anyway, so I'm not going to worry about it.


Swift SVN r6989
2013-08-07 18:36:45 +00:00
John McCall
2eabba0faa Add a getUser() to ValueBase::use_iterator.
Swift SVN r6973
2013-08-07 03:21:11 +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
eaf693aace Constify SILLocation.
Swift SVN r6965
2013-08-07 00:10:56 +00:00
John McCall
dc676c2207 ReferenceTypePath has been dead for a while now.
Swift SVN r6964
2013-08-07 00:10:55 +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
36aa6c2645 alloc_stack needs to return two values like alloc_box.
The current implementation of dealloc_stack in IR-gen is a
no-op, but that's very much wrong for types with non-trivial
local allocation requirements, e.g. archetypes.  So we need
to be able to do non-trivial code here.  However, that means
modeling both the buffer pointer and the allocated address
in SIL.

To make this more type-safe, introduce a SIL-specific
'[local_storage] T' type that represents the required
allocation for locally storing a T.  alloc_stack now returns
one of those in additon to a *T, and dealloc_stack expects
the former.

IR-gen still implements dealloc_stack as a no-op, but
that's now easy to fix.

Swift SVN r6937
2013-08-06 07:31:41 +00:00
John McCall
adfba641a8 Eliminate AllocInst, which does nothing for us.
Swift SVN r6936
2013-08-06 07:31:38 +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
Dmitri Hrybenko
6b988e93d1 Fix DenseMapInfo for swift::SILDeclRef: empty and tombstone keys were equal
No testcase, found by reading code.


Swift SVN r6911
2013-08-05 18:29:58 +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
John McCall
d7b6009374 Introduce the concept of the "semantic" type of a lowered
type and audit a great deal of code to deal with it appropriately.

Spot fixes in a few other places.

Fixes rdar://14615768

Swift SVN r6879
2013-08-03 05:59:19 +00:00
John McCall
0fe3bee1e5 Normalize the names of createUnowned{Retain,Release}.
Swift SVN r6878
2013-08-03 05:59:18 +00:00
Joe Groff
4316239f5d Kill Builtin.OpaquePointer.
It's not needed by SIL anymore.

Swift SVN r6873
2013-08-03 01:56:06 +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
Joe Groff
ea4ace470d SILGen: Implement UnionElementPattern dispatch.
Build a switch_union instruction over all the matched union elements, and check for exhaustiveness to see if we need to emit a default branch either for subsequent matches or to fall off the end and emit unreachable if we run out of cases.

Swift SVN r6870
2013-08-02 23:26:18 +00:00
Joe Groff
a851072a25 SIL: Ensure all terminators are handled by TermInst::getSuccessors.
Create a separate TERMINATOR xmacro in SILNodes.def that only expands for terminators. Use it in TermInst::getSuccessors to automatically delegate to leaf terminator getSuccessors implementations without requiring additional maintenance work when new terminator instructions are added in the future.

Swift SVN r6869
2013-08-02 23:26:17 +00:00
John McCall
796e434f63 Make "isTake" and "isInitialization" flags type-safe.
Swift SVN r6860
2013-08-02 22:38:14 +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
Anna Zaks
29d2d8fb92 [SIL] Add memory behavior bit to SIL instruction definition.
As per code review discussion for r 6763.

The memory behavior enumeration is currently a subset of what it could be. Let’s add more kinds as needed.

Swift SVN r6830
2013-08-02 01:27:57 +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
ae94c8c48e [DCE] Propagate BB arguments when simplifying a conditional branch into unconditional one
Swift SVN r6819
2013-08-01 21:32:06 +00:00
Joe Groff
3503ffe4fa IRGen: Set up LinkEntities for protocol witness tables.
We need to handle three cases:

- If a protocol conformance has no associated types, or the associated type witnesses all have statically resolvable metadata, we can expose a *direct* witness table symbol.
- If a protocol conformance has associated types with runtime-instantiated metadata, we need to gate the witness table behind a *lazy* initializer function to fill in the metadata fields.
- If a protocol conformance has associated types where the type or one of its conformances are *dependent* on its parent's generic parameters, we need to instantiate multiple witness tables at runtime.

Swift SVN r6805
2013-08-01 05:25:32 +00:00
John McCall
b6d49ea46d Give some dynamic behavior to TypeLowering and lay out
some groundwork for more customization.

Swift SVN r6799
2013-08-01 01:28:39 +00:00
John McCall
9f6e2bf9bb Permit Patterns in SILLocation as well.
Swift SVN r6798
2013-08-01 01:28:38 +00:00
John McCall
f46ffb3382 Shorten "TypeLoweringInfo" to "TypeLowering".
Swift SVN r6795
2013-08-01 01:28:34 +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
Anna Zaks
930b95cdb0 [SIL] Add SILInstruction::mayHaveSideEffects helper.
Swift SVN r6765
2013-07-30 23:08:37 +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
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
Doug Gregor
0842fb5cf8 Rename "base class" to "superclass" and "derived class" to "subclass".
Standardize on the more-common "superclass" and "subclass" terminology
throughout the compiler, rather than the odd mix of base/derived and
super/sub. 

Also, have ClassDecl only store the Type of the superclass. Location
information will be part of the inheritance clause for parsed classes.




Swift SVN r6687
2013-07-29 15:48:34 +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
Joe Groff
1300efb8fb SIL: Represent float_literal values with bitwise representations.
This way we don't need to deal with the inaccuracy of decimal float literals. While we're here, modify the in-memory representation of IntegerLiteralInst and FloatLiteralInst to save the word array of the APInt instead of round-tripping through plain text.

Swift SVN r6676
2013-07-27 03:57:14 +00:00
Anna Zaks
e5c3a7ea80 [SIL] Make sure SILBasicBlock destructor gets called.
This also ensures that the instructions indie the basic block
get destructed.

Swift SVN r6667
2013-07-27 00:25:03 +00:00
Anna Zaks
dde5e15457 [SIL] Cleanup, remove redundant initializers.
Swift SVN r6666
2013-07-27 00:25:02 +00:00
Anna Zaks
098f197cb8 [SIL] Add convenience SILBasicBlock successor iterators.
Swift SVN r6665
2013-07-27 00:25:02 +00:00
Dmitri Hrybenko
51bd267d06 Don't use a reserved identifier for the include guard macro
Swift SVN r6609
2013-07-25 20:48:40 +00:00
Dmitri Hrybenko
6a6f1f66fe Demangler: clean up includes and extra llvm:: prefixes
Swift SVN r6608
2013-07-25 20:45:07 +00:00
Joe Groff
398cbba5be Rename SILConstant to SILDeclRef.
"SILConstant" doesn't really describe its role in SIL anymore, which is to provide a reference to a Swift declaration in a SIL instruction, such as a method or nominal type field.

Swift SVN r6559
2013-07-24 21:21:31 +00:00
Enrico Granata
efcd17f604 This commit implements the Demangler API in C++ and de facto deprecates the existing Demangle.swift
The new demangler is in the "swift/SIL/Demangle.{h|cpp}" files, and in the swift::Demangle namespace, which has two public entry points:

std::string demangleSymbol(llvm::StringRef mangled);
std::string demangleType(llvm::StringRef mangled);

This was necessary to support the need for LLDB to demangle Swift symbol (and type) names

Test case is included



Swift SVN r6547
2013-07-24 17:52:27 +00:00
John McCall
325b86b82a Prepare SIL type lowering to create more expressive type-infos.
Swift SVN r6545
2013-07-24 04:58:49 +00:00
Joe Groff
b2115265d3 SIL.rst: Update docs for index_addr/index_raw_pointer.
And lump them in with memory access instructions.

Swift SVN r6537
2013-07-24 00:24:10 +00:00
Joe Groff
08723dd3a9 SIL.rst: Update docs for checked cast instructions.
Swift SVN r6535
2013-07-24 00:03:35 +00:00
John McCall
4df7c9d33f Adjust the mechanics of type lowering to avoid double-caching.
Swift SVN r6531
2013-07-23 23:51:13 +00:00
Joe Groff
ac5cefddb8 SIL.rst: Update docs for unchecked conversion instructions.
Swift SVN r6530
2013-07-23 23:15:52 +00:00
Joe Groff
06f0eb3240 SIL: Remove stale leading name from doc comment.
Swift SVN r6509
2013-07-23 21:17:54 +00:00