Goose  Artifact [92ee24faaa]

Artifact 92ee24faaa1c64dac22ff51363fbf3ffc2ece341c3bd837a41f937056434ec3d:

  • File bs/llr/cfg.h — part of check-in [6c8e8075ff] at 2019-10-03 19:58:53 on branch trunk — FuncValidator: model the execution flow in z3 by generating boolean expressions describing when each basic block is executed. (user: achavasse size: 1775)

#ifndef GOOSE_LLR_CFG_H
#define GOOSE_LLR_CFG_H

namespace goose::llr
{
    class BasicBlock;

    class CFG
    {
        public:
            CFG();

            bool isPoisoned() const { return m_poisoned; }
            void poison() { m_poisoned = true; }

            const auto& entryBB() const { return m_basicBlocks.front(); }
            const auto& lastBB() const { return m_basicBlocks.back(); }

            const auto& currentBB() const { return m_currentBB; }
            template< typename T >
            void setCurrentBB( T&& pBB )
            {
                m_currentBB = forward<  T >( pBB );
            }

            const auto& getBB( uint32_t index ) { return m_basicBlocks[index]; }

            auto count() const { return m_basicBlocks.size(); }
            auto uniqueId() const { return m_uniqueId; }

            const ptr< llr::BasicBlock >& createBB();

            auto getNewTemporaryIndex() { return m_temporariesCount++; }

            // Clear the llvm basic block pointers from the entire cfg.
            void unbindFromLLVM();

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

            template< typename F >
            void ForEachBB( F&& func )
            {
                for( auto&& bb : m_basicBlocks )
                    func( bb );
            }

        private:
            vector< ptr< BasicBlock > > m_basicBlocks;
            ptr< BasicBlock > m_currentBB;

            // The unique identifier of this CFG.
            uint32_t m_uniqueId = ms_nextUniqueId++;

            // The number of temporary indices used by this CFG.
            uint32_t m_temporariesCount = 0;

            bool m_poisoned = false;

            static uint32_t ms_nextUniqueId;
    };
}

#endif