Goose  Artifact [bbf8939fb2]

Artifact bbf8939fb2b7c84f724d663e5ab96416964b3c1bb3ef5c8cc30680041fa54297:

  • File bs/cir/op-allocvar.h — part of check-in [184c1add90] at 2024-09-15 21:15:04 on branch cir-ssa-refactor —
    • Fix index Values EIR encoding
    • Fix CFG printer
    (user: achavasse size: 1209)

#ifndef GOOSE_CIR_ALLOCVAR_H
#define GOOSE_CIR_ALLOCVAR_H

namespace goose::cir
{
    class AllocVar : public Operation< 0, false >
    {
      public:
        template< typename T >
        AllocVar( T&& type, uint32_t index, LocationId loc ) :
            Operation( 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.type() << ')';
        }

      private:
        LowerableType m_type;
        uint32_t m_index = 0;
    };
} // namespace goose::cir

#endif