Goose  Artifact [1cb2155fd4]

Artifact 1cb2155fd4e86a5ad4ca9e4905fcee57cc5aa00b96e069c1c7b5cb30b0dfca86:

  • File bs/cir/binaryop.h — part of check-in [90c951f66f] at 2021-01-12 21:08:37 on branch trunk — Implemented missing lowering of reference types to pointer types, added a bunch of runtime/compilation time reference tests. (user: achavasse size: 1152)

#ifndef GOOSE_CIR_BINARYINSTR_H
#define GOOSE_CIR_BINARYINSTR_H

namespace goose::cir
{
    class BinaryOp
    {
        public:
            template< typename L, typename R >
            BinaryOp( L&& lhs, R&& rhs ) :
                m_lhs( forward< L >( lhs ) ),
                m_rhs( forward< R >( rhs ) )
            {}

            const auto& lhs() const { return m_lhs; }
            const auto& rhs() const { return m_rhs; }

            bool canBeExecuted() const;
            bool canBeEagerlyEvaluated() const;

            bool operator<( const BinaryOp& rhs ) const
            {
                if( m_lhs != rhs.m_lhs )
                    return m_lhs < rhs.m_lhs;
                return m_rhs < rhs.m_rhs;
            }

        private:
            eir::Value m_lhs;
            eir::Value m_rhs;
    };

    class BinaryOpSameTypes : public BinaryOp
    {
        public:
            template< typename L, typename R >
            BinaryOpSameTypes( L&& l, R&& r ) :
                BinaryOp( forward< L >( l ), forward< R >( r ) )
            {
                assert( lhs().type() == rhs().type() );
            }
    };
}

#endif