mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL: add new instructions to support tail-allocated arrays in SIL.
The new instructions are: ref_tail_addr, tail_addr and a new attribute [ tail_elems ] for alloc_ref. For details see docs/SIL.rst As these new instructions are not generated so far, this is a NFC.
This commit is contained in:
@@ -95,6 +95,13 @@ Projection::Projection(SILInstruction *I) : Value() {
|
||||
REAI->getType());
|
||||
break;
|
||||
}
|
||||
case ValueKind::RefTailAddrInst: {
|
||||
auto *RTAI = cast<RefTailAddrInst>(I);
|
||||
auto *Ty = RTAI->getTailType().getSwiftRValueType().getPointer();
|
||||
Value = ValueTy(ProjectionKind::TailElems, Ty);
|
||||
assert(getKind() == ProjectionKind::TailElems);
|
||||
break;
|
||||
}
|
||||
case ValueKind::ProjectBoxInst: {
|
||||
auto *PBI = cast<ProjectBoxInst>(I);
|
||||
Value = ValueTy(ProjectionKind::Box, (unsigned)0);
|
||||
@@ -212,6 +219,8 @@ Projection::createObjectProjection(SILBuilder &B, SILLocation Loc,
|
||||
return B.createUncheckedEnumData(Loc, Base, getEnumElementDecl(BaseTy));
|
||||
case ProjectionKind::Class:
|
||||
return nullptr;
|
||||
case ProjectionKind::TailElems:
|
||||
return nullptr;
|
||||
case ProjectionKind::Box:
|
||||
return nullptr;
|
||||
case ProjectionKind::Upcast:
|
||||
@@ -253,6 +262,8 @@ Projection::createAddressProjection(SILBuilder &B, SILLocation Loc,
|
||||
getEnumElementDecl(BaseTy));
|
||||
case ProjectionKind::Class:
|
||||
return B.createRefElementAddr(Loc, Base, getVarDecl(BaseTy));
|
||||
case ProjectionKind::TailElems:
|
||||
return B.createRefTailAddr(Loc, Base, getCastType(BaseTy));
|
||||
case ProjectionKind::Box:
|
||||
return B.createProjectBox(Loc, Base);
|
||||
case ProjectionKind::Upcast:
|
||||
@@ -825,6 +836,7 @@ SILValue Projection::getOperandForAggregate(SILInstruction *I) const {
|
||||
}
|
||||
break;
|
||||
case ProjectionKind::Class:
|
||||
case ProjectionKind::TailElems:
|
||||
case ProjectionKind::Box:
|
||||
case ProjectionKind::Upcast:
|
||||
case ProjectionKind::RefCast:
|
||||
|
||||
Reference in New Issue
Block a user