mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add SILValue::getDefiningInstructionOrTerminator().
This allows code to handle terminator results similar to any other instruction result. Data flow should generally handle terminator results like any other instruction that may forward operand ownership to its results. The fact that it is represented as a block argument is an implementation detail that gets in the way of conceptual simplicity.
This commit is contained in:
@@ -494,6 +494,13 @@ public:
|
|||||||
}
|
}
|
||||||
SILInstruction *getDefiningInstruction();
|
SILInstruction *getDefiningInstruction();
|
||||||
|
|
||||||
|
/// Return the instruction that defines this value, terminator instruction
|
||||||
|
/// that produces this result, or null if it is not defined by an instruction.
|
||||||
|
const SILInstruction *getDefiningInstructionOrTerminator() const {
|
||||||
|
return const_cast<ValueBase*>(this)->getDefiningInstructionOrTerminator();
|
||||||
|
}
|
||||||
|
SILInstruction *getDefiningInstructionOrTerminator();
|
||||||
|
|
||||||
/// Return the SIL instruction that can be used to describe the first time
|
/// Return the SIL instruction that can be used to describe the first time
|
||||||
/// this value is available.
|
/// this value is available.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -80,6 +80,16 @@ SILInstruction *ValueBase::getDefiningInstruction() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SILInstruction *ValueBase::getDefiningInstructionOrTerminator() {
|
||||||
|
if (auto *inst = dyn_cast<SingleValueInstruction>(this))
|
||||||
|
return inst;
|
||||||
|
if (auto *result = dyn_cast<MultipleValueInstructionResult>(this))
|
||||||
|
return result->getParent();
|
||||||
|
if (auto *result = SILArgument::isTerminatorResult(this))
|
||||||
|
return result->getSingleTerminator();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
SILInstruction *ValueBase::getDefiningInsertionPoint() {
|
SILInstruction *ValueBase::getDefiningInsertionPoint() {
|
||||||
if (auto *inst = getDefiningInstruction())
|
if (auto *inst = getDefiningInstruction())
|
||||||
return inst;
|
return inst;
|
||||||
|
|||||||
Reference in New Issue
Block a user