mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add a helper method mayHaveOpenedArchetypeOperands to SILInstruction
This method returns true if a given kind of instructions may have opened archetype operands. It does not mean that a concrete instruction instance necessarily has such operands.
This commit is contained in:
@@ -704,6 +704,23 @@ namespace {
|
||||
return {}; \
|
||||
return I->getOpenedArchetypeOperands(); \
|
||||
}
|
||||
#include "swift/SIL/SILNodes.def"
|
||||
};
|
||||
|
||||
class MayHaveOpenedArchetypeOperandsAccessor
|
||||
: public SILVisitor<MayHaveOpenedArchetypeOperandsAccessor,
|
||||
bool> {
|
||||
public:
|
||||
#define VALUE(CLASS, PARENT) \
|
||||
bool visit##CLASS(const CLASS *I) { \
|
||||
llvm_unreachable("accessing non-instruction " #CLASS); \
|
||||
}
|
||||
#define INST(CLASS, PARENT, MEMBEHAVIOR, RELEASINGBEHAVIOR) \
|
||||
bool visit##CLASS(const CLASS *I) { \
|
||||
return IMPLEMENTS_METHOD(CLASS, SILInstruction, \
|
||||
getOpenedArchetypeOperands, \
|
||||
ArrayRef<Operand>() const); \
|
||||
}
|
||||
#include "swift/SIL/SILNodes.def"
|
||||
};
|
||||
} // end anonymous namespace
|
||||
@@ -725,6 +742,11 @@ MutableArrayRef<Operand> SILInstruction::getOpenedArchetypeOperands() {
|
||||
return OpenedArchetypeOperandsMutableAccessor().visit(this);
|
||||
}
|
||||
|
||||
bool SILInstruction::mayHaveOpenedArchetypeOperands() const {
|
||||
return MayHaveOpenedArchetypeOperandsAccessor().visit(
|
||||
const_cast<SILInstruction *>(this));
|
||||
}
|
||||
|
||||
/// getOperandNumber - Return which operand this is in the operand list of the
|
||||
/// using instruction.
|
||||
unsigned Operand::getOperandNumber() const {
|
||||
|
||||
Reference in New Issue
Block a user