mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user