mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[proj] Add Projection::create{Addr,Value}Projection so one can create Projections without knowing what the internal state of the projection is.
Swift SVN r23371
This commit is contained in:
@@ -251,33 +251,11 @@ forwardAddrToLdWithExtractPath(SILValue Address, SILValue StoredValue,
|
||||
// from our list of address projections.
|
||||
SILValue LastExtract = StoredValue;
|
||||
SILBuilderWithScope<16> Builder(Inst);
|
||||
for (auto II = Path->rbegin(), IE = Path->rend(); II != IE; ++II) {
|
||||
auto P = *II;
|
||||
switch (P.getKind()) {
|
||||
case ProjectionKind::Struct:
|
||||
LastExtract = Builder.createStructExtract(Inst->getLoc(), LastExtract,
|
||||
cast<VarDecl>(P.getDecl()),
|
||||
P.getType().getObjectType());
|
||||
assert(cast<StructExtractInst>(*LastExtract).getStructDecl() &&
|
||||
"Instruction must have a struct decl!");
|
||||
break;
|
||||
case ProjectionKind::Enum:
|
||||
LastExtract = Builder.createUncheckedEnumData(
|
||||
Inst->getLoc(), LastExtract, cast<EnumElementDecl>(P.getDecl()),
|
||||
P.getType().getObjectType());
|
||||
assert(cast<UncheckedEnumDataInst>(*LastExtract).getElement() &&
|
||||
"Instruction must have an enum element decl!");
|
||||
break;
|
||||
case ProjectionKind::Tuple:
|
||||
LastExtract = Builder.createTupleExtract(Inst->getLoc(), LastExtract,
|
||||
P.getIndex(),
|
||||
P.getType().getObjectType());
|
||||
assert(cast<TupleExtractInst>(*LastExtract).getTupleType() &&
|
||||
"Instruction must have a tuple type!");
|
||||
break;
|
||||
case ProjectionKind::Class:
|
||||
llvm_unreachable("Can not handle classes here");
|
||||
}
|
||||
|
||||
// Construct the path!
|
||||
for (auto PI = Path->rbegin(), PE = Path->rend(); PI != PE; ++PI) {
|
||||
LastExtract = PI->createValueProjection(Builder, Inst->getLoc(),
|
||||
LastExtract).get();
|
||||
}
|
||||
|
||||
// Return the last extract we created.
|
||||
|
||||
Reference in New Issue
Block a user