Goose  allocvar.h at [1793989d05]

File bs/cir/allocvar.h artifact 706de7ca56 part of check-in 1793989d05


#ifndef GOOSE_CIR_ALLOCVAR_H
#define GOOSE_CIR_ALLOCVAR_H

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

            const auto& type() const { return m_type; }
            const auto& index() const { return m_index; }
            void setIndex( uint32_t index ) { m_index = 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.get() << ')';
            }

        private:
            LowerableType m_type;
            uint32_t m_index = 0;
    };
}

#endif