Commit Graph

1069 Commits

Author SHA1 Message Date
Joe Groff
5852448152 IRGen: Generate SIL ctor and property decls.
Remove the filter that only irgenned SIL functions for FuncDecls so that we emit functions for all SIL decls, and disable the old paths for properties, constructors, and destructors when a SIL module is present. Unfortunately this breaks class constructors because SIL and IRGen don't agree on how initializing constructors should work. I need to sync with John to figure out how to fix that.

Swift SVN r3827
2013-01-22 02:45:27 +00:00
Joe Groff
ae396e3905 IRGen: SIL AllocRefInst.
Implement AllocRefInst so that SIL-emitted constructors can be irgenned. Factor the code for allocating a class instance from GenClass's emitClassConstructor function.

Swift SVN r3826
2013-01-22 02:45:25 +00:00
Joe Groff
8c48a3afdd IRGen: Map SIL allocating/initializing ctors.
Now that John's implemented allocating and initializing constructors in irgen, map SIL's representation to irgen's.

Swift SVN r3823
2013-01-21 23:10:08 +00:00
Joe Groff
19d65fede5 IRGen: Visit all SIL Functions in a SILModule.
Make the SIL visitor path a bit less hacky by more cleanly separating the AST walk to find types to codegen from the SIL module walk to find functions to codegen. This way, local functions and other such entry points from SIL actually get generated, and the closures test works.

Swift SVN r3820
2013-01-21 20:17:05 +00:00
Joe Groff
c9d6a351f5 IRGen: SIL ClosureInsts (almost).
Implement lowering of SIL ClosureInsts by packing the partial arguments into a heap allocation and emitting a thunk to unpack them and apply the closure function, similar to curried entry points. The test doesn't work quite yet because nested FuncDecls don't get visited anymore. I need to replace my hacked SIL path with a proper walk of the SIL module to generate functions and the AST to generate types.

Swift SVN r3817
2013-01-20 19:50:10 +00:00
John McCall
3713b6a549 Add a framework for distinguishing between deallocating
and non-deallocating destructors and allocating/non-allocating
constructors.

Non-deallocating destructors might not play well with ObjC
classes;  we might have to limit them to pure-swift hierarchies.

No functionality change except that I decided to not force
destructors to have internal linkage unconditionally.

Swift SVN r3814
2013-01-20 19:40:12 +00:00
Joe Groff
5674cfd0b1 IRGen: SIL literals and zero initialization.
Pick up the remaining low-hanging fruit by implementing irgen for FloatLiteralInst, ZeroValueInst, and ZeroAddrInst.

Swift SVN r3801
2013-01-18 18:02:10 +00:00
Joe Groff
6c6d4dfbdf IRGen: Implement SIL protocol method calls.
Factor out the parts of GenProto's prepareExistentialMemberRefCall necessary to map to SIL's ProtocolMethodInst. Similar to ConstantRefInst, we map the ProtocolMethodInst to an incomplete CallEmission and emit the call when all curry levels have been applied.

Swift SVN r3794
2013-01-18 02:24:26 +00:00
Joe Groff
d2c91a2323 IRGen: SIL protocol type value support.
Factor out the witness table initialization and projection logic from GenProto so that IRGenSIL can use it to implement the ProjectExistential and InitExistential instructions. Also map the CopyAddr and DestroyAddr instructions to value witness table calls so that value semantics on protocol values (and other address-only values) work. The added test compiles but doesn't run yet because invoking methods on a protocol value still requires implementing the ProtocolMethod instruction.

Swift SVN r3787
2013-01-17 23:20:59 +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
312e4872e9 IRGen: SIL class accessors.
Implement IRGen for RefElementAddr so that class accessors work. Add a loadUnmanaged method to TypeInfo classes so that we can populate Explosions without accruing unwanted cleanups.

Swift SVN r3779
2013-01-16 22:12:21 +00:00
Joe Groff
7e57041393 IRGen: SIL struct manipulation.
Implement ElementRefInst so that struct accessors work. Also extend SILConstant lowering to support constant_refs to constructors, destructors, and property accessors so that constructor and property accessor references work. (Constructors don't yet get visited by IRGenSIL, though.)

Swift SVN r3776
2013-01-16 19:04:08 +00:00
Joe Groff
30a5493250 IRGen: Lower SIL retain instruction.
Oops, I did release but not retain. Like 'release' it currently just does emitRetainCall without checking if the type in question requires ObjC or some other future kind of memory management.

Swift SVN r3770
2013-01-16 01:20:17 +00:00
Joe Groff
afa65ef3f4 IRGen: SIL function arguments and return values.
Lower arguments and value returns instead of assuming all functions are () -> ().

Swift SVN r3769
2013-01-16 01:20:15 +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
Dave Zarzycki
3b1aef5422 Fix an unused variable build warning
Swift SVN r3763
2013-01-14 22:40:23 +00:00
Dave Zarzycki
7c136717a5 Fix a build warning (missing newline at EOF)
Swift SVN r3762
2013-01-14 22:21:43 +00:00
Joe Groff
0970a18e7d IRGen: Compile the toplevel through SIL.
If IRGenModule has a SILModule, use its toplevel Function to emit the top-level code instead of re-walking TopLevelCodeDecls itself.

Swift SVN r3761
2013-01-14 18:33:08 +00:00
Joe Groff
9259c0d912 IRGen: Get "hello world" to compile through SIL.
Add a path through IRGenModule to optionally codegen FuncDecls using their corresponding SIL Functions when constructed with a SILModule. Jury-rig an IRGenSILFunction subclass of IRGenFunction that does the bare minimum necessary to compile "hello world" from SIL. There are some impedance mismatches between irgen and SIL that need to be smoothed out, particularly the AST-dependent way irgen currently handles function calls. Nonetheless, `swift -sil-i hello.swift` works!

Swift SVN r3759
2013-01-14 02:57:11 +00:00