Skip to content

SIL: Give project_box a field index operand. #5429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -3396,6 +3396,7 @@ class SILBoxType final : public TypeBase,
CanType getBoxedType() const;
// In SILType.h
SILType getBoxedAddressType() const;
SILType getFieldType(unsigned index) const;

static bool classof(const TypeBase *T) {
return T->getKind() == TypeKind::SILBox;
Expand Down
3 changes: 1 addition & 2 deletions include/swift/SIL/Projection.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ class Projection {
case ProjectionKind::Enum:
return BaseType.getEnumElementType(getEnumElementDecl(BaseType), M);
case ProjectionKind::Box:
return SILType::getPrimitiveAddressType(BaseType.castTo<SILBoxType>()->
getBoxedType());
return BaseType.castTo<SILBoxType>()->getFieldType(getIndex());
case ProjectionKind::Tuple:
return BaseType.getTupleElementType(getIndex());
case ProjectionKind::Upcast:
Expand Down
14 changes: 5 additions & 9 deletions include/swift/SIL/SILBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1226,17 +1226,13 @@ class SILBuilder {
return insert(new (F.getModule()) ProjectValueBufferInst(
getSILDebugLocation(Loc), valueType, operand));
}
ProjectBoxInst *createProjectBox(SILLocation Loc, SILValue boxOperand) {
auto valueTy =
boxOperand->getType().castTo<SILBoxType>()->getBoxedAddressType();
ProjectBoxInst *createProjectBox(SILLocation Loc, SILValue boxOperand,
unsigned index) {
auto boxTy = boxOperand->getType().castTo<SILBoxType>();
auto fieldTy = boxTy->getFieldType(index);

return insert(new (F.getModule()) ProjectBoxInst(
getSILDebugLocation(Loc), valueTy, boxOperand));
}
ProjectBoxInst *createProjectBox(SILLocation Loc, SILType valueTy,
SILValue boxOperand) {
return insert(new (F.getModule()) ProjectBoxInst(
getSILDebugLocation(Loc), valueTy, boxOperand));
getSILDebugLocation(Loc), boxOperand, index, fieldTy));
}
ProjectExistentialBoxInst *createProjectExistentialBox(SILLocation Loc,
SILType valueTy,
Expand Down
6 changes: 3 additions & 3 deletions include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -1739,8 +1739,8 @@ void SILCloner<ImplClass>::visitProjectBoxInst(ProjectBoxInst *Inst) {
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
doPostProcess(Inst,
getBuilder().createProjectBox(getOpLocation(Inst->getLoc()),
getOpType(Inst->getValueType()),
getOpValue(Inst->getOperand())));
getOpValue(Inst->getOperand()),
Inst->getFieldIndex()));
}

template<typename ImplClass>
Expand All @@ -1749,7 +1749,7 @@ void SILCloner<ImplClass>::visitProjectExistentialBoxInst(
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
doPostProcess(Inst,
getBuilder().createProjectExistentialBox(getOpLocation(Inst->getLoc()),
getOpType(Inst->getValueType()),
getOpType(Inst->getType()),
getOpValue(Inst->getOperand())));
}

Expand Down
Loading