summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-simplify-cfg.h
blob: 3822b0fa8308d61b539536f66c5ae704c50ea0be (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
25
26
27
28
29
30
31
// slang-ir-simplify-cfg.h
#pragma once

namespace Slang
{
struct IRModule;
struct IRGlobalValueWithCode;
struct IRLoop;
struct IRDominatorTree;

struct CFGSimplificationOptions
{
    bool removeTrivialSingleIterationLoops = true;
    bool removeSideEffectFreeLoops = true;
    static CFGSimplificationOptions getDefault() { return CFGSimplificationOptions(); }
    static CFGSimplificationOptions getFast() { return CFGSimplificationOptions{false, false}; }
};

bool isTrivialSingleIterationLoop(
    IRDominatorTree* domTree,
    IRGlobalValueWithCode* func,
    IRLoop* loop);

/// Simplifies control flow graph by merging basic blocks that
/// forms a simple linear chain.
/// Returns true if changed.
bool simplifyCFG(IRModule* module, CFGSimplificationOptions options);

bool simplifyCFG(IRGlobalValueWithCode* func, CFGSimplificationOptions options);

} // namespace Slang