#include "config.h"
#include "B3Effects.h"
#if ENABLE(B3_JIT)
#include <wtf/CommaPrinter.h>
namespace JSC { namespace B3 {
namespace {
bool interferesWithTerminal(const Effects& terminal, const Effects& other)
{
if (!terminal.terminal)
return false;
return other.terminal || other.controlDependent || other.writesLocalState || other.writes || other.writesPinned;
}
bool interferesWithExitSideways(const Effects& exitsSideways, const Effects& other)
{
if (!exitsSideways.exitsSideways)
return false;
return other.controlDependent || other.writes || other.writesPinned;
}
bool interferesWithWritesLocalState(const Effects& writesLocalState, const Effects& other)
{
if (!writesLocalState.writesLocalState)
return false;
return other.writesLocalState || other.readsLocalState;
}
bool interferesWithWritesPinned(const Effects& writesPinned, const Effects& other)
{
if (!writesPinned.writesPinned)
return false;
return other.writesPinned || other.readsPinned;
}
}
bool Effects::interferes(const Effects& other) const
{
return interferesWithTerminal(*this, other)
|| interferesWithTerminal(other, *this)
|| interferesWithExitSideways(*this, other)
|| interferesWithExitSideways(other, *this)
|| interferesWithWritesLocalState(*this, other)
|| interferesWithWritesLocalState(other, *this)
|| interferesWithWritesPinned(*this, other)
|| interferesWithWritesPinned(other, *this)
|| writes.overlaps(other.writes)
|| writes.overlaps(other.reads)
|| reads.overlaps(other.writes)
|| (fence && other.fence);
}
bool Effects::operator==(const Effects& other) const
{
return terminal == other.terminal
&& exitsSideways == other.exitsSideways
&& controlDependent == other.controlDependent
&& writesLocalState == other.writesLocalState
&& readsLocalState == other.readsLocalState
&& writesPinned == other.writesPinned
&& readsPinned == other.readsPinned
&& writes == other.writes
&& reads == other.reads
&& fence == other.fence;
}
bool Effects::operator!=(const Effects& other) const
{
return !(*this == other);
}
void Effects::dump(PrintStream& out) const
{
CommaPrinter comma("|");
if (terminal)
out.print(comma, "Terminal");
if (exitsSideways)
out.print(comma, "ExitsSideways");
if (controlDependent)
out.print(comma, "ControlDependent");
if (writesLocalState)
out.print(comma, "WritesLocalState");
if (readsLocalState)
out.print(comma, "ReadsLocalState");
if (writesPinned)
out.print(comma, "WritesPinned");
if (readsPinned)
out.print(comma, "ReadsPinned");
if (fence)
out.print(comma, "Fence");
if (writes)
out.print(comma, "Writes:", writes);
if (reads)
out.print(comma, "Reads:", reads);
}
} }
#endif // ENABLE(B3_JIT)