Commit Graph

368 Commits

Author SHA1 Message Date
Joe Groff
08d06e850d IRGen: Emit top-level globals from SIL.
Set up IRGen to emit SIL code that uses top-level-code global variables. Add -sil-i to a bunch of Interpreter tests that use global variables.

Swift SVN r4480
2013-03-22 23:34:38 +00:00
Joe Groff
2858bc4fde SIL: Replace '-dump-sil-verbose' hack with DEBUG()
Swift SVN r3728
2013-01-10 03:45:40 +00:00
Joe Groff
cb03dbd3be SIL: Associate SILTypeInfo with the SILModule.
For some types, there is lowering info that is useful to IRGen, such as the SIL-level calling convention for functions or the element layout of aggregates, that can't fit in a SILType pointer but still should be associated with the module. Add a SILTypeInfo hierarchy, add a mapping of SILTypes to infos to SILModule, and rename the SILGen-specific TypeInfo to TypeLoweringInfo. Move the derived layout information for compound types from TypeLoweringInfo to SILTypeInfo so that IRGen will be able to use it.

Swift SVN r3712
2013-01-09 00:02:38 +00:00
Joe Groff
7d8f04ac45 SIL: Make SILType independent of Type.
Move SILType to its own header, and make it its own container type consisting of a Type with an "isAddress" bit for representing address types. Move the "isAddressOnly" information from SILGen's TypeInfo onto SILType as a second bit, because address-only-ness is extremely useful for verification outside of SILGen. Instead of mangling function types during type lowering, rely on the fact that SILType is no longer a Type to force us to mangle argument and return types when we see them. (We may eventually need SILFunctionType and SILTupleType things to represent lowered SIL function and tuple types containing addresses, but for now we can lower function and tuple components as needed.)

Swift SVN r3551
2012-12-19 21:51:39 +00:00
Joe Groff
6ad32a20c4 SIL: Use SILType and lower types where needed.
Change over SIL Values and Instructions to work in terms of SILTypes, and update SILGen to lower types where needed. Add LValueType logic to SILType lowering to get rid of those annoying lvalue qualifiers so we can ignore RequalifyExprs. Tighten up the XFAILs in the SIL tests and disable the checks that currently crash.

Swift SVN r3538
2012-12-18 23:53:39 +00:00
Joe Groff
dc1af6ae11 SILGen: Implement address-only type lowering.
Add a getLoweredType() method to SILGen's TypeInfo and logic to convert function signatures and address-only types to their SIL-level representations. Drive a (currently weak) type wedge between lowered and unlowered types by making a SILType subclass of CanType. Make SILConstants take on their lowered function types. This breaks a bunch of SIL test cases, which I've temporarily XFAILed until proper address-only type support can propagate through the rest of SILGen.

Swift SVN r3528
2012-12-18 02:29:27 +00:00
Joe Groff
601f1d3c4d SIL: Move SILModule::getConstantType to TypeInfo.
Determining constant types requires help from SILGen because of address-only types, and the type of a constant after SILGen should always be readily available from the ConstantRefInst. Initialize SIL Function objects with their lowered type as well so that it's available to IRGen and SIL passes.

Swift SVN r3526
2012-12-17 20:27:46 +00:00
Joe Groff
9f7b89b1b2 Add a -dump-sil-verbose option.
Since I can't seem to help myself from committing my local debug dumps.

Swift SVN r3495
2012-12-14 18:44:51 +00:00
Joe Groff
3e14d9782a SILGen: Specialize generic property accessors.
Generic accessors need to have a specialize instruction applied to them to get the concrete accessor before applying them.

Swift SVN r3492
2012-12-14 16:51:59 +00:00
Joe Groff
d3d617ca70 SILGen: Implement getting subscripts.
Subscripts are just another kind of property. Refactor some logic from ApplyExpr codegen to visit index arguments consistently with apply arguments. Also move the logic for determining SIL constant types onto SILModule because it's too hairy to calculate on the fly.

Swift SVN r3452
2012-12-12 20:23:56 +00:00
Joe Groff
a593076d09 SIL: Introduce a SILConstant type.
We need something more general than ValueDecl to be able to talk about anonymous functions, curried entry points, etc. as SIL constants. SILConstant is a (ValueDecl | CapturingExpr) union with an additional index for discriminating multiple instances or entry points derived from the same AST entity. Update ConstantInst and SILModule's function table to be keyed by SILConstant rather than ValueDecl.

Swift SVN r3372
2012-12-05 22:40:38 +00:00
Joe Groff
703bd9f355 SIL: Add bits to distinguish get/set in SILModule.
SIL needs a way to generate and reference getters and setters, which share a decl. Change SILModule to key its component Functions on a (ValueDecl, flags) pair rather than just on ValueDecl.

Swift SVN r3354
2012-12-04 21:42:35 +00:00
Joe Groff
7b5e8c84cb SILGen: Gen VarDecls as locals for toplevel code.
If the TranslationUnit being silgenned is a Main or Repl unit, generate globals like locals. Generating toplevel functions as closures still needs to be done.

Swift SVN r3340
2012-12-04 00:04:38 +00:00
Joe Groff
814229fce7 SILGen: Generate top-level code.
Add a toplevel Function object to SILModule. When SILGenModule encounters TopLevelCodeDecls, pass their bodies on to SILGenFunction to emit SIL into the toplevel function

Swift SVN r3336
2012-12-03 20:38:14 +00:00
Joe Groff
ec1e1aedc4 SILModule: Use llvm::MapVector to store Functions.
(instead of slumming with a DenseMap/vector pair)
Re: r3322

Swift SVN r3331
2012-12-03 17:16:34 +00:00
Joe Groff
fdb8982f35 Add doc-comments to SIL Function and SILModule.
re: r3322

Swift SVN r3330
2012-12-03 17:16:32 +00:00
Joe Groff
79c7e825f7 Don't <>-include llvm headers.
In response to Chris' feedback on r3322.

Swift SVN r3329
2012-12-03 17:16:29 +00:00
Joe Groff
1c21b9f304 SIL: Introduce a SILModule object.
Create a SILModule type, and lift ownership of TU-global things like the bump allocator and type list uniquing from Function to SILModule. Move the ad-hoc SIL dumping logic out of main() into SILModule and into a new SILGenModule class.

Swift SVN r3324
2012-12-01 01:29:59 +00:00