mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL: Ensure all terminators are handled by TermInst::getSuccessors.
Create a separate TERMINATOR xmacro in SILNodes.def that only expands for terminators. Use it in TermInst::getSuccessors to automatically delegate to leaf terminator getSuccessors implementations without requiring additional maintenance work when new terminator instructions are added in the future. Swift SVN r6869
This commit is contained in:
@@ -15,14 +15,14 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// VALUE(Id, Parent)
|
||||
/// The expression enumerator value is an ValueKind. The node's class name is
|
||||
/// The expression enumerator value is a ValueKind. The node's class name is
|
||||
/// Id, and the name of its base class (in the SILValue hierarchy) is Parent.
|
||||
#ifndef VALUE
|
||||
#define VALUE(Id, Parent)
|
||||
#endif
|
||||
|
||||
/// INST(Id, Parent, MemBehavior)
|
||||
/// The expression enumerator value is an ValueKind. The node's class name is
|
||||
/// The expression enumerator value is a ValueKind. The node's class name is
|
||||
/// Id, and the name of its base class (in the SILInstruction hierarchy) is
|
||||
/// Parent. MemBehavior is an enum value that reflects the memory behavior of
|
||||
/// the instruction.
|
||||
@@ -30,6 +30,15 @@
|
||||
#define INST(Id, Parent, MemBehavior) VALUE(Id, Parent)
|
||||
#endif
|
||||
|
||||
/// TERMINATOR(Id, Parent, MemBehavior)
|
||||
/// Expands for terminator instructions. The expression enumerator value is
|
||||
/// a ValueKind. The node's class name is Id, and the name of its base class
|
||||
/// (in the SILInstruction hierarchy) is Parent. MemBehavior is an enum value
|
||||
/// that reflects the memory behavior of the instruction.
|
||||
#ifndef TERMINATOR
|
||||
#define TERMINATOR(Id, Parent, MemBehavior) INST(Id, Parent, MemBehavior)
|
||||
#endif
|
||||
|
||||
/// An abstract instruction is an abstract base class in the hierarchy;
|
||||
/// it is never a most-derived type, and it does not have an enumerator in
|
||||
/// ValueKind.
|
||||
@@ -164,18 +173,19 @@ ABSTRACT_VALUE(SILInstruction, ValueBase)
|
||||
|
||||
// Terminators
|
||||
ABSTRACT_VALUE(TermInst, SILInstruction)
|
||||
INST(UnreachableInst, TermInst, None)
|
||||
INST(ReturnInst, TermInst, None)
|
||||
INST(AutoreleaseReturnInst, TermInst, None)
|
||||
INST(BranchInst, TermInst, None)
|
||||
INST(CondBranchInst, TermInst, None)
|
||||
INST(SwitchIntInst, TermInst, None)
|
||||
INST(SwitchUnionInst, TermInst, None)
|
||||
TERMINATOR(UnreachableInst, TermInst, None)
|
||||
TERMINATOR(ReturnInst, TermInst, None)
|
||||
TERMINATOR(AutoreleaseReturnInst, TermInst, None)
|
||||
TERMINATOR(BranchInst, TermInst, None)
|
||||
TERMINATOR(CondBranchInst, TermInst, None)
|
||||
TERMINATOR(SwitchIntInst, TermInst, None)
|
||||
TERMINATOR(SwitchUnionInst, TermInst, None)
|
||||
VALUE_RANGE(TermInst, UnreachableInst, SwitchUnionInst)
|
||||
|
||||
VALUE_RANGE(SILInstruction, AllocStackInst, CondBranchInst)
|
||||
VALUE_RANGE(SILInstruction, AllocStackInst, SwitchUnionInst)
|
||||
|
||||
#undef VALUE_RANGE
|
||||
#undef ABSTRACT_VALUE
|
||||
#undef TERMINATOR
|
||||
#undef INST
|
||||
#undef VALUE
|
||||
|
||||
Reference in New Issue
Block a user