Goose  Artifact [0ea19f27fc]

Artifact 0ea19f27fc521571beac9523260f61f36f0b3599f9444d05861b7f472009499b:

  • File bs/cir/allocvar.h — part of check-in [dd5c48041c] at 2022-05-26 11:31:44 on branch cir-stack-language — Re-enabled codegen and related tests, and adapted it to the now stack-based CIR language (user: zlodo size: 1116)

#ifndef GOOSE_CIR_ALLOCVAR_H
#define GOOSE_CIR_ALLOCVAR_H

namespace goose::cir
{
    class AllocVar
    {
        public:
            template< typename T >
            AllocVar( T&& type, uint32_t index ) :
                m_type( forward< T >( type ) ),
                m_index( index )
            {}

            const auto& type() const { return m_type; }
            const auto& index() const { return m_index; }

            bool canBeExecuted() const { return true; }
            bool canBeEagerlyEvaluated() const { return false; }
            bool haveSideEffects() const { return true; }

            bool operator<( const AllocVar& rhs ) const
            {
                if( m_index != rhs.m_index )
                    return m_index < rhs.m_index;
                return m_type < rhs.m_type;
            }

            friend ostream& operator<<( ostream& out, const AllocVar& ins )
            {
                return out << "ALLOCVAR(" << ins.m_index << ", " << ins.m_type << ')';
            }

        private:
            eir::Value m_type;
            uint32_t m_index = 0;
    };
}

#endif