Goose  Artifact [10e8dcddd4]

Artifact 10e8dcddd48e34a78d8e816e49691fbc1cbe54f4b67041412e2e3c794f0be595:

  • File bs/cir/allocvar.h — part of check-in [b81d4242e3] at 2022-06-27 16:56:56 on branch cir-stack-language —
    • cir: allow verification specific code and instructions to be interspersed with regular code again and added a function to filter them out before consuming the code in the interpreter and during codegen
    • verification: better handling of non-representable types that don't involve giving up entirely on verifying the function
    • g0 api: updated it to match the CIR changes
    • prelude: adapted reference verification to the new CIR api
    (user: zlodo size: 1197) [more...]

#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; }

            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