Goose  Artifact [a647fe2a4e]

Artifact a647fe2a4e6c3fd6488ec58bf8e0f153eab8a2a18bd3ead94a6cf0231aafdec8:

  • File bs/cir/instruction.cpp — part of check-in [4cc7a833f8] at 2021-01-03 15:44:11 on branch trunk — cir: load, store and select store their base addresses directly as cir instructiions, rather than wrapped into eir values, which is useless there. (user: achavasse size: 1653)

#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 if constexpr( is_same_v< ET, ptr< CFG > > )
                return e->canBeExecuted();
            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 if constexpr( is_same_v< ET, ptr< CFG > > )
                return e->canBeEagerlyEvaluated();
            else
                return e.canBeEagerlyEvaluated();
        }, m_content );
    }

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

    bool Select::isCompTimeStackAddr() const
    {
        return m_baseAddr && m_baseAddr->isCompTimeStackAddr();
    }

    bool Load::canBeEagerlyEvaluated() const
    {
        return m_addr && m_addr->isCompTimeStackAddr();
    }

    bool Store::canBeEagerlyEvaluated() const
    {
        return m_addr && m_addr->isCompTimeStackAddr()
            && CanValueBeEagerlyEvaluated( m_val );
    }
}