Added SILInstructionMemoryBehavior::MayRead/MayReadWrite and mayRead()/mayWrite() methods on SILInstruction.

Swift SVN r7963
This commit is contained in:
Michael Gottesman
2013-09-05 22:28:54 +00:00
parent 1200ef4fab
commit c001e3e82b
3 changed files with 26 additions and 5 deletions

View File

@@ -46,13 +46,17 @@ class VarDecl;
enum class SILInstructionMemoryBehavior {
None,
/// The instruction may read memory.
MayRead,
/// \brief The instruction may write to memory.
MayWrite,
/// The instruction may read or write memory.
MayReadWrite,
/// \brief The instruction may have side effects not captured solely by its
/// users. Specifically, it can return, release memory, or store. Note,
/// alloc is not considered to have side effects because its
/// result/users represent its effect.
MayHaveSideEffects,
/// \brief The instruction may write to memory.
MayWrite
};
enum IsTake_t { IsNotTake, IsTake };
@@ -132,6 +136,22 @@ public:
/// that are not visible by merely examining their uses.
bool mayHaveSideEffects() const;
/// Returns true if the instruction may write to memory.
bool mayWrite() const {
const SILInstructionMemoryBehavior B = getMemoryBehavior();
return B == SILInstructionMemoryBehavior::MayWrite ||
B == SILInstructionMemoryBehavior::MayReadWrite ||
B == SILInstructionMemoryBehavior::MayHaveSideEffects;
}
/// Returns true if the instruction may read from memory.
bool mayRead() const {
const SILInstructionMemoryBehavior B = getMemoryBehavior();
return B == SILInstructionMemoryBehavior::MayRead ||
B == SILInstructionMemoryBehavior::MayReadWrite ||
B == SILInstructionMemoryBehavior::MayHaveSideEffects;
}
static bool classof(const ValueBase *V) {
return V->getKind() >= ValueKind::First_SILInstruction &&
V->getKind() <= ValueKind::Last_SILInstruction;