mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -291,11 +291,8 @@ APFloat FloatLiteralInst::getValue() const {
|
||||
return getExpr()->getValue();
|
||||
}
|
||||
|
||||
StringLiteralInst::StringLiteralInst(StringLiteralExpr *E)
|
||||
: SILInstruction(ValueKind::StringLiteralInst, E,
|
||||
// The string literal tuple type is always a valid SIL type.
|
||||
SILType::getPreLoweredType(E->getType()->getCanonicalType(),
|
||||
/*address=*/false, /*loadable=*/true)) {
|
||||
StringLiteralInst::StringLiteralInst(StringLiteralExpr *E, SILType ty)
|
||||
: SILInstruction(ValueKind::StringLiteralInst, E, ty) {
|
||||
}
|
||||
|
||||
StringLiteralExpr *StringLiteralInst::getExpr() const {
|
||||
@@ -402,6 +399,18 @@ SuperToArchetypeInst::SuperToArchetypeInst(SILLocation Loc,
|
||||
Operands(this, SrcBase, DestArchetypeAddress) {
|
||||
}
|
||||
|
||||
StructInst *StructInst::createImpl(SILLocation Loc, SILType Ty,
|
||||
ArrayRef<SILValue> Elements, SILFunction &F) {
|
||||
void *Buffer = F.allocate(sizeof(StructInst) +
|
||||
decltype(Operands)::getExtraSize(Elements.size()),
|
||||
alignof(StructInst));
|
||||
return ::new(Buffer) StructInst(Loc, Ty, Elements);
|
||||
}
|
||||
|
||||
StructInst::StructInst(SILLocation Loc, SILType Ty, ArrayRef<SILValue> Elems)
|
||||
: SILInstruction(ValueKind::StructInst, Loc, Ty), Operands(this, Elems) {
|
||||
}
|
||||
|
||||
TupleInst *TupleInst::createImpl(SILLocation Loc, SILType Ty,
|
||||
ArrayRef<SILValue> Elements, SILFunction &F) {
|
||||
void *Buffer = F.allocate(sizeof(TupleInst) +
|
||||
|
||||
Reference in New Issue
Block a user