Goose  Artifact [a38ba0f568]

Artifact a38ba0f568bc8f6e79d3d2d4bef84c3eb8e146ff12809dd5195edd56d559074a:

  • File bs/cir/instruction.cpp — part of check-in [b4d5bdf6ec] at 2022-06-18 18:51:47 on branch cir-stack-language —
    • Added a location id to all CIR instructions (needed with the stack based approach to locate intermediate results)
    • Fixed a bunch of verifier errors
    • Re-enabled most verifier tests, other than some requiring to re-implement a few more bits
    (user: zlodo size: 2487)

#include "cir/cir.h"

namespace goose::cir
{
    bool Instruction::canBeExecuted() const
    {
        return visit( []< typename ET >( const ET& e )
        {
            if constexpr( is_same_v< ET, monostate > )
                return false;
            else
                return e.canBeExecuted();
        }, m_content );
    }

    bool Instruction::canBeEagerlyEvaluated() const
    {
        return visit( []< typename ET >( const ET& e )
        {
            if constexpr( is_same_v< ET, monostate > )
                return false;
            else
                return e.canBeEagerlyEvaluated();
        }, m_content );
    }

    bool Instruction::haveSideEffects() const
    {
        return visit( []< typename ET >( const ET& e )
        {
            if constexpr( is_same_v< ET, monostate > )
                return false;
            else
                return e.haveSideEffects();
        }, m_content );
    }

    ostream& operator<<( ostream& out, const Instruction& inst )
    {
        return visit( [&]< typename ET >( const ET& e ) -> ostream&
        {
            if constexpr( is_same_v< ET, monostate > )
                return out << "NIL";
            else
                return out << e;
        }, inst.m_content );
    }

    ostream& operator<<( ostream& out, const Select& ins )
    {
        out << "SELECT(" << ins.m_memberIndex;
         return out << ')';
    }

    ostream& operator<<( ostream& out, const Load& ins )
    {
        out << "LOAD(";
         return out << ins.m_type << ')';
    }

    ostream& operator<<( ostream& out, const Store& ins )
    {
        return out << "STORE";
    }

    ostream& operator<<( ostream& out, const PHOverrideSet& ins )
    {
        return out << "PHOVERRIDESET(" << ins.m_name << ')';
    }

    ostream& operator<<( ostream& out, const PHOverrideClear& ins )
    {
        return out << "PHOVERRIDECLEAR(" << ins.m_name << ')';
    }

    bool Select::operator<( const Select& rhs ) const
    {
        return m_memberIndex < rhs.m_memberIndex;
    }

    bool Load::operator<( const Load& rhs ) const
    {
        return m_type < rhs.m_type;
    }

    bool Store::operator<( const Store& rhs ) const
    {
        return m_type < rhs.m_type;
    }

    bool PHOverrideSet::operator<( const PHOverrideSet& rhs ) const
    {
        return m_name < rhs.m_name;
    }

    bool PHOverrideClear::operator<( const PHOverrideClear& rhs ) const
    {
        return m_name < rhs.m_name;
    }
}