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:
Roman Levenstein
2016-07-11 11:16:44 -07:00
parent a7ee8ba9cf
commit ae8b2ba0de
2 changed files with 26 additions and 0 deletions

View File

@@ -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 {