#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