summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-reachability.h
blob: e8c86efdb3c1dfdf7f4de7ae54b43db5d5e5dac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// slang-ir-reachability.h
#pragma once

#include "slang-ir.h"

namespace Slang
{

// A context for computing and caching reachability between blocks on the CFG.
struct ReachabilityContext
{
    Dictionary<IRBlock*, int> mapBlockToId;
    List<IRBlock*> allBlocks;
    List<UIntSet> sourceBlocks; // sourcesBlocks[i] stores the set of blocks from which block i can
                                // be reached.

    ReachabilityContext() = default;
    ReachabilityContext(IRGlobalValueWithCode* code);

    bool isInstReachable(IRInst* from, IRInst* to);
    bool isBlockReachable(IRBlock* from, IRBlock* to);
};

} // namespace Slang