On second thought, having SILConstant be able to point to a TLCD is going
against the goal of making SILConstant be a "SILGen thing". I'll find another
approach.
Swift SVN r4680
The Verifier wasn't actually verifying function bodies, because I neglected to visit the actual basic blocks after checking the entry point arguments in verifySILFunction. This revealed a SILType identity issue where TypeConverter::getLoweredType and SILType::getEmptyTupleType returned non-identical SILTypes for the empty tuple type; fix that by removing SILType::getEmptyTupleType, moving TypeConverter into SILModule, and forcing all SILType creation through TypeConverter.
Swift SVN r4616
Function and compound types have a bunch of extra calling convention and uncurrying info stuffed into a "SILTypeInfo" object that until now had to be fetched through the SILModule. Change the representation of SILType to be a PointerUnion of CanType and SILTypeInfo*, and move the uncurry level onto the SILTypeInfo for functions, so that SILTypeInfo is available directly through the SILType and SILType can go back to being pointer-sized.
Swift SVN r4582
In top-level code, global variables are notionally local variables of the "main" function, but we give them global storage as an implementation detail. Add the ability to represent physical global variables to SILConstant, and emit top-level-code global variable initializers and references in terms of the physical address.
Swift SVN r4479
Take into account the context uncurry level when determining the uncurry level of SILConstant for local properties whose getters or setters capture.
Swift SVN r4381
Pack the uncurry level onto SILConstant, and modify SILConstant constructors to determine the natural uncurry level of their referenced entity by default. While we're here, improve how SILConstant represents different kinds of constants by using a real enum for the kind. Type closure entry points by giving them an extra curry level for their context. The implementation of ApplyInst and ClosureInst hasn't been updated yet, so tests that lower closures to SIL are temporarily broken.
Swift SVN r4354
We want to port CallEmission to the SIL level to handle uncurrying, but IRGen needs to have the original signature of a function available to it so that it can maintain the correct calling convention for different ABIs independent of SIL. Instead of flattening curried function types in SIL and losing that information, add an uncurryLevel to SILType so it can represent the type of an entry point at a given uncurry level. Unfortunately, this makes SILType outgrow a single word, so the way Value unions SILType and SILTypeList folding sets needs to be tweaked too.
Swift SVN r4345
Archetypes and projected existentials have the type %swift.opaque* and not i8*, so I need a corresponding SIL type to be able to model the ProjectExistential operation. We might also end up needing the builtin type for other low-level things down the line.
Swift SVN r3793
Add a new "kind" to SILConstant so that SIL can reference destructors without decls. Generate a destructor for classes even if they don't have an explicit destructor. If a class has a base class, call the base class destructor instead of dealloc_ref-ing the current instance.
Swift SVN r3665
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
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
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
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
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
Generalize a bunch of code that assumed address-of-value-type for the "this" side of properties to accept reftypes as well. Use RefElementAddrInst to extract physical elements of reference types. Fix an off-by-one in the writeback logic in emitStoreToLValue so that writeback chains properly terminate at the deepest value type component below a reference type component.
Swift SVN r3445
- Steal some bits from SILConstant::id to reference getter and setter definitions, and normalize SILConstant references to property FuncDecls to be SILConstant references to the ValueDecl getter/setter instead.
- In normal expression context, handle getting properties by calling the getter and materializing the return value. Setting lvalues is not implemented yet; that will require borrowing the LValue and GenLValue machinery from irgen to construct logical lvalue paths in assignment and byref contexts.
Swift SVN r3414
Instead of considering `constant_ref @var` to give the address of `var` directly, consider it to be a `() -> [byref] T` function that returns the address, presumably after running the initializer for the global if necessary. Generate a DeclRef to a global var as a constant_ref to get the function followed by an apply to get the address. Actually generating the global accessor is still to be implemented.
Swift SVN r3389
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
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
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