SILGen: Emit implicit constructors.

Teach SILGen how to emit the implicit elementwise constructor for structs and the implicit default constructor for classes, and eliminate the now dead IRGen code for them. Add a StructInst SIL instruction to represent constructing a loadable struct value from elements, analogous to TupleInst for tuples.

Swift SVN r4778
This commit is contained in:
Joe Groff
2013-04-17 20:51:26 +00:00
parent dc1fe2f8e2
commit b9bb84c58e
14 changed files with 255 additions and 189 deletions

View File

@@ -151,8 +151,8 @@ public:
FloatLiteralInst *createFloatLiteral(FloatLiteralExpr *E) {
return insert(new FloatLiteralInst(E));
}
StringLiteralInst *createStringLiteral(StringLiteralExpr *E) {
return insert(new StringLiteralInst(E));
StringLiteralInst *createStringLiteral(StringLiteralExpr *E, SILType Ty) {
return insert(new StringLiteralInst(E, Ty));
}
LoadInst *createLoad(SILLocation Loc, SILValue LV) {
@@ -171,8 +171,8 @@ public:
CopyAddrInst *createCopyAddr(SILLocation Loc,
SILValue SrcLValue, SILValue DestLValue,
bool isTake = false,
bool isInitialize = false) {
bool isTake,
bool isInitialize) {
return insert(new CopyAddrInst(Loc, SrcLValue, DestLValue,
isTake, isInitialize));
}
@@ -228,7 +228,12 @@ public:
SILValue DestArchetypeAddr) {
return insert(new SuperToArchetypeInst(Loc, SrcBase, DestArchetypeAddr));
}
StructInst *createStruct(SILLocation Loc, SILType Ty,
ArrayRef<SILValue> Elements){
return insert(StructInst::create(Loc, Ty, Elements, F));
}
TupleInst *createTuple(SILLocation Loc, SILType Ty,
ArrayRef<SILValue> Elements){
return insert(TupleInst::create(Loc, Ty, Elements, F));