mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Added SILInstructionMemoryBehavior::MayRead/MayReadWrite and mayRead()/mayWrite() methods on SILInstruction.
Swift SVN r7963
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user