Goose  Artifact [a23f58d868]

Artifact a23f58d868bdcb6473092cd7e62ba57b90900620eb4902d7317ca19f0e1a442d:

  • File bs/cir/tempaddr.h — part of check-in [26c691ecb9] at 2021-01-02 18:24:23 on branch trunk — Yet one more reference/address refactor: each calculation step (getting temp addr, getting var addr, selecting a member) is now a separate cir instruction. We need this level of generalization to be able to obtain addresses from anywhere, including variables and function parameters. (user: achavasse size: 1060)

#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 isCompTimeStackAddr() const { return true; }

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

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

#endif