Commit Graph

365 Commits

Author SHA1 Message Date
Joe Groff
223d0251bd IRGen: Add getFragileTypeInfo and getFunctionType for SIL types.
Add overloads of getFragileTypeInfo and getFunctionType that take a SILType instead of a Swift CanType, and use them where it's easy to do so. Right now they just forward to the CanType versions, but we'll want to do SILType-specific type conversion soon. Clean up some IRGenSILFunction interfaces now that SILFunction carries most of the information IRGen needs intrinsically. No functionality change.

Swift SVN r5141
2013-05-10 16:28:25 +00:00
John McCall
d8cdb0160f Switch IR-generation to generally traffic in alignment
masks rather than raw alignments.

Swift SVN r5136
2013-05-10 06:16:28 +00:00
Chris Lattner
6c9c6c47a9 revert r5028, re-eliminating Scope since its caching behavior is better handled
by the LLVM IR optimizer.  Tuple metadata refs are now largely
readnone, function metadata refs are already readnone.  There may be some
left that are not, but they can be handled later. 


Swift SVN r5071
2013-05-06 23:27:05 +00:00
Joe Groff
df059d02cc IRGen: Revive scoped metadata caching, at BB level.
John talked me out of this. We still want to cache metadata at the BB level, because even with SIL GVN, there are potentially redundant metadata bits at a level SIL doesn't know about.

Swift SVN r5030
2013-05-02 23:28:31 +00:00
Joe Groff
14cef05844 IRGen: Kill scoped metadata caching.
It doesn't really work with SIL-IRGen, and SIL GVN and LICM will hopefully have the same intended effect eventually.

Swift SVN r5028
2013-05-02 22:17:21 +00:00
Joe Groff
0566088bf2 Move name mangling into SIL.
Sever the last load-bearing link between SILFunction and SILConstant by naming SILFunctions with their mangled symbol names. Move the core of the mangler up to SIL, and teach SILGen how to use it to mangle a SILConstant.

Swift SVN r4964
2013-04-28 03:32:41 +00:00
John McCall
c74ad61247 Extract functions to work with value witnesses into their own file.
Swift SVN r4924
2013-04-26 21:33:21 +00:00
John McCall
13fbec4108 Extend IGF's emitMemCpy API to handle memcpy's of an unknown size.
Swift SVN r4923
2013-04-26 21:33:19 +00:00
John McCall
24c55531ea Promote emitTypeMetadataRef to being "top-level" IGF API.
Swift SVN r4920
2013-04-26 18:48:33 +00:00
John McCall
a23349caa5 Add IGF::emitByteOffsetGEP to conveniently create a pointer
at a dynamic offset.

Swift SVN r4901
2013-04-25 01:39:52 +00:00
Joe Groff
bcb49ce450 SIL: Key functions directly without SILConstant.
Replace 'constant_ref' with 'function_ref', which references a SILFunction directly, and 'global_addr', which references a global variable VarDecl. Get rid of the SILConstant-to-SILFunction mapping in SILModule and replace it with an ilist of SILFunctions. Allow SILFunctions to be 'external' by not having any blocks in their body. 

For now, SILFunctions still carry around their SILConstant "name", because name mangling and IRGen still rely on access to the original decl in order to recover IRGen information, which unfortunately leaves IRGen's CodeRefs in a gross, awkward intermediate state. Lifting mangling, AbstractCC, and other linkage attributes to SIL should clear up this up.

Swift SVN r4865
2013-04-23 23:29:04 +00:00
Chris Lattner
43bd01689b Tidy up IGF a bit, changing some ivars to be arguments to emitProlog, removing
dead methods, and moving emitInvoke to CallInvocation.

An interesting semantic change of this is that we're now calling getResultType
on the function type every time IGF is constructed, which exposed some latent
bugs.  Specifically two places in GenObjC are trying to extra curry level two 
from function types like "SomeObject -> (value : SomeObject) -> ()" which
doesn't make sense.  I switched them to get curry level 1, but this definitely
needs some close review.



Swift SVN r4852
2013-04-21 17:00:33 +00:00
Chris Lattner
5664431c9a remove Cleanup.h and references to the Cleanup class, along with
some dead logic in IRGenFunction.



Swift SVN r4847
2013-04-21 06:36:22 +00:00
Chris Lattner
0be7bbdddf remove ManagedValue.
Swift SVN r4843
2013-04-21 05:56:02 +00:00
Chris Lattner
e8686c9560 remove Cleanups from IGF, simplify Initialization a bit.
Swift SVN r4841
2013-04-21 05:28:04 +00:00
Chris Lattner
6e50329da3 remove the cleanups list from CallEmission and ManagedValue, along with the machinery for adding Cleanups.
Swift SVN r4840
2013-04-21 05:16:00 +00:00
Chris Lattner
e3d6a489af remove the Cleanup subclasses.
Swift SVN r4839
2013-04-21 05:06:52 +00:00
Chris Lattner
19baff9169 remove some code now that Cleanups are never "used".
Swift SVN r4837
2013-04-21 04:33:00 +00:00
Chris Lattner
13b2af4f54 remove getAddrForParameter and some other dead logic.
Swift SVN r4824
2013-04-19 04:06:37 +00:00
Chris Lattner
a124da99eb remove the dead "Locals" map and supporting logic.
Swift SVN r4823
2013-04-19 04:01:59 +00:00
Chris Lattner
35edbcd29e prune some minor dead Stmt stuff.
Swift SVN r4818
2013-04-19 00:09:51 +00:00
Chris Lattner
abee79b26e remove some Expr stuff.
Swift SVN r4810
2013-04-18 22:32:37 +00:00
Chris Lattner
f60b1b65cf remove some dead initialization logic.
Swift SVN r4806
2013-04-18 18:00:44 +00:00
Joe Groff
d1a04c92a7 IRGen: Kill dead emitSupertoArchetype overload.
Swift SVN r4805
2013-04-18 15:28:13 +00:00
Chris Lattner
fa168e15a9 remove emitRValueAsUnsubstituted and some related logic. Once I get this deep, it
seems that this is not a good idea, because it seems statically live from the SIL
SuperToArchetypeInst.  However, apparently nothing in the testsuite exercises
this code, so I'll need to discuss and a testcase to know how much logic needs
to be ressurrected from SVN.  rdar://13681541



Swift SVN r4800
2013-04-18 05:41:20 +00:00
Chris Lattner
a7748f61ae remove emitRValue, which is dead, at least dynamically according to our testsuite.
Swift SVN r4799
2013-04-18 05:33:40 +00:00
Chris Lattner
1abf1d0ebc remove RValueEmitter and some implementation logic for it, as well as
FullExpr.  Scope is kept alive by one dangling thread, rdar://13681467


Swift SVN r4798
2013-04-18 05:24:50 +00:00
Chris Lattner
dc0454e1d2 remove GenArray.{h,cpp} as they are handled by SILGen. Remove getAddrOfLocalFunction.
Swift SVN r4796
2013-04-18 05:12:01 +00:00
Chris Lattner
47e508c24d remove LValue, PathComponent, and LValue.h as a whole.
Swift SVN r4792
2013-04-18 04:50:03 +00:00
Chris Lattner
20a712a2fc remove emitAddressLValue and PhysicalPathComponent.
Swift SVN r4791
2013-04-18 04:46:41 +00:00
Chris Lattner
ac6dbfb604 remove some protocol stuff, which is the last user of emitFakeLValue.
Remove emitFakeLValue, the last user of emitAddressLValue.


Swift SVN r4790
2013-04-18 04:42:49 +00:00
Chris Lattner
447ceab4e1 remove JumpDest class and JumpDest.h, it is now a SILGen concept.
Swift SVN r4783
2013-04-17 22:52:38 +00:00
Chris Lattner
477bdbd08a remove emitConstructorBody and GenConstructor.cpp now that Joe implemented
implicit struct constructors in r4776.


Swift SVN r4782
2013-04-17 22:38:38 +00:00
Chris Lattner
ffe3388aa5 remove the dead logic form GenTuple, RValueInitEmitter, and some
erasure/protocol expr logic.


Swift SVN r4775
2013-04-17 06:34:27 +00:00
Chris Lattner
01a36864a3 Remove LogicalPathComponent, emitLoad, emitAssign, emitLValueAsScalar,
and supporting logic.

PathComponent and LValue are (apparently unnecessarily) kept alive by 
projectPhysicalClassMemberAddress (rdar://13671033)



Swift SVN r4773
2013-04-17 06:00:34 +00:00
Chris Lattner
091652fe47 remove GetterSetter.h and implementation logic, now that this is handled by SILGen
Swift SVN r4772
2013-04-17 05:53:52 +00:00
Chris Lattner
ade66c8b10 Remove the emitIgnored, emitLValue, and tryEmitAsAddress mechanics and
supporting logic.


Swift SVN r4770
2013-04-17 05:33:23 +00:00
Chris Lattner
dace3e95fd remove local decl emission and local pattern binding emission.
Swift SVN r4769
2013-04-17 05:09:37 +00:00
Chris Lattner
0701489691 remove Condition.
Swift SVN r4768
2013-04-17 05:01:03 +00:00
Chris Lattner
ec6d194c5d remove the old IRGen path for statements.
Swift SVN r4767
2013-04-17 04:48:26 +00:00
Joe Groff
7dde07cfd3 IRGen: Lower SIL ArchetypeToSuper (and v.v.).
Swift SVN r4747
2013-04-15 23:32:46 +00:00
Joe Groff
bfd2f85b5c Parse 'fallthrough' statements.
Create a new FallthroughStmt, which transfers control from a 'case' or 'default' block to the next 'case' or 'default' block within a switch. Implement parsing and sema for FallthroughStmt, which syntactically consists of a single 'fallthrough' keyword. Sema verifies that 'fallthrough' actually appears inside a switch statement and that there is a following case or default block to pass control to.

SILGen/IRGen support forthcoming.

Swift SVN r4653
2013-04-10 17:30:42 +00:00
Joe Groff
9fbd9f19b8 Runtime: Clean up swift_allocBox a bit.
Per John's comments, make a GenericBox struct to represent the layout of a generic box allocation, move all the layout calculations into methods on GenericBox, and alter swift_deallocBox to take the type as an argument so that it's future-proofed for when we start special-casing certain types in allocBox.

Swift SVN r4613
2013-04-05 18:51:36 +00:00
Joe Groff
14355a8134 Runtime: Add swift_allocBox.
Add a runtime function that, given a generic type metadata pointer, allocates a heap object capable of containing a value of that type. This is a first-pass implementation that always does the worst case thing of stuffing the type metadata into the box with the value and using its value witness table to size, align, and destroy the box. Use swift_allocBox to implement ArchetypeTypeInfo::allocate correctly for heap object allocations. This means SIL's alloc_box $T now works for archetypes, and a simple generics test now (almost) compiles through SIL!

Swift SVN r4599
2013-04-05 01:34:28 +00:00
Joe Groff
3f81dfef15 IRGen: Implement 'x is T' for archetype T.
<rdar://problem/13530695> blocks this from actually working yet.

Swift SVN r4523
2013-03-28 22:18:17 +00:00
Joe Groff
35c85c5017 Implement 'x is T' runtime type checks.
Implement type-checking and IRGen for 'x is T', and fix a bug in 'x as! T' typechecking when the operand is an lvalue. For IRGen I'm reusing the checked swift_dynamicCastClass runtime function and testing the result against null.

Swift SVN r4515
2013-03-28 16:51:25 +00:00
Joe Groff
062ad267c4 Value-only switch statements.
Implement switch statements with simple value comparison to get the drudge work of parsing and generating switches in place. Cases are checked using a '=~' operator to compare the subject of the switch to the value in the case. Unlike a C switch, cases each have their own scope and don't fall through. 'break' and 'continue' apply to an outer loop rather to the switch itself. Multiple case values can be specified in a comma-separated list, as in 'case 1, 2, 3, 4:'. Currently no effort is made to check for duplicate cases or to rank cases by match strength; cases are just checked in source order, and the first one wins (aside from 'default', which is branched to if all cases fail).

Swift SVN r4359
2013-03-12 04:43:01 +00:00
Joe Groff
be09b16f93 Sema: Allow returns from constructors/destructors.
In the StmtChecker, consider a ConstructorDecl or DestructorDecl context to be a function context that returns (). In IRGen for constructors and destructors, set up proper return blocks so that 'return' does the right thing, and in constructors, pretend that the body has no return value even though the underlying constructor mechanism totally returns a value. Fixes <rdar://problem/12950817>.

Swift SVN r3915
2013-01-31 22:30:12 +00:00
Joe Groff
1459512901 IRGen: SIL tuple helper instructions.
Implement ElementAddrInst for lvalue tuples, and implement the AllocArray, IndexAddr, and IntegerValue insts used to lower variadic tuples. (Actually compiling code that uses variadic tuples still requires support for SpecializeInst and generic functions.)

Swift SVN r3781
2013-01-17 18:17:39 +00:00
Joe Groff
8320df8b9d IRGen: SIL branching and variable allocation.
Implement SIL-to-IR lowering for allocation, deallocation, load, store, and branching instructions so that local variables and branching control flow can be used. Add a Fibonacci loop test to exercise the new instructions.

Swift SVN r3767
2013-01-15 22:32:49 +00:00