Goose  Artifact [dda4713ca7]

Artifact dda4713ca73c1c560934a834cb5518c7383b451172ad27a87cf0f1293e90071e:

  • File bs/cir/tempaddr.h — part of check-in [bcca4c51ba] at 2021-02-02 20:46:17 on branch trunk — CIR expressions pretty printing (user: achavasse size: 1199)

#ifndef GOOSE_CIR_TEMPADDR_H
#define GOOSE_CIR_TEMPADDR_H

namespace goose::cir
{
    class TempAddr
    {
        public:
            template< typename T >
            TempAddr( uint32_t i, T&& init ) :
                m_initValue( forward< T >( init ) ),
                m_tempIndex( i )
            {}

            const auto& initValue() const
            {
                return m_initValue;
            }

            uint32_t tempIndex() const
            {
                return m_tempIndex;
            }

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

            bool operator<( const TempAddr& rhs ) const
            {
                if( m_tempIndex != rhs.m_tempIndex )
                    return m_tempIndex < rhs.m_tempIndex;
                return m_initValue < rhs.m_initValue;
            }

            friend ostream& operator<<( ostream& out, const TempAddr& ins )
            {
                return out << "TEMPADDR(" << ins.m_tempIndex << ", " << ins.m_initValue << ')';
            }

        private:
            eir::Value m_initValue;
            uint32_t m_tempIndex = 0;
    };
}

#endif