Add SILValue::stripObjectProjections().

This method looks recursively through the operand chain of the given SILValue
until it finds a non-object projection instruction. It then returns that value.

An object projection instruction is one of:

1. struct_extract.
2. tuple_extract.

Swift SVN r12918
This commit is contained in:
Michael Gottesman
2014-01-24 18:20:10 +00:00
parent 8db21be9e5
commit bbc1093efd
2 changed files with 23 additions and 0 deletions

View File

@@ -87,6 +87,22 @@ SILValue SILValue::stripAddressProjections() {
}
}
SILValue SILValue::stripObjectProjections() {
SILValue V = *this;
while (true) {
switch (V->getKind()) {
case ValueKind::StructExtractInst:
case ValueKind::TupleExtractInst:
V = cast<SILInstruction>(V.getDef())->getOperand(0);
continue;
default:
return V;
}
}
}
SILUndef *SILUndef::get(SILType Ty, SILModule *M) {
// Unique these.
SILUndef *&Entry = M->UndefValues[Ty];