Goose  Artifact [cf3fbf0aef]

Artifact cf3fbf0aef07551d772b5444cc33f9197f4e377b3d1de533fa723c4454408ace:

  • File bs/llr/branch.h — part of check-in [c9a44e2fb9] at 2019-08-08 16:53:15 on branch trunk —
    • Implemented the local variable unification rule, which allows to read them.
    • Fixed comparison operators not returning bools.
    (user: achavasse size: 1265)

#ifndef EMPATHY_LLR_BRANCH_H
#define EMPATHY_LLR_BRANCH_H

namespace empathy::llr
{
    class BasicBlock;

    class Branch
    {
        public:
            template< typename B >
            Branch( B&& dest ) :
                m_dest( forward< B >( dest ) )
            {}

            const auto& dest() const { return m_dest; }

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

        private:
            wptr< BasicBlock > m_dest;
    };

    class CondBranch
    {
        public:
            template< typename V, typename BT, typename BF >
            CondBranch( V&& cond, BT&& trueDest, BF&& falseDest ) :
                m_cond( forward< V >( cond ) ),
                m_trueDest( forward< BT >( trueDest ) ),
                m_falseDest( forward< BF >( falseDest ) )
            {}

            const auto& cond() const { return m_cond; }
            const auto& trueDest() const { return m_trueDest; }
            const auto& falseDest() const { return m_falseDest; }

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

        private:
            ir::Value m_cond;
            wptr< BasicBlock > m_trueDest;
            wptr< BasicBlock > m_falseDest;
    };
}

#endif