summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-peephole.h
blob: b67e09d71f8b2110404871acbe707818d0d7164b (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
// slang-ir-peephole.h
#pragma once

namespace Slang
{
struct IRModule;
struct IRCall;
struct IRInst;
class TargetProgram;

struct PeepholeOptimizationOptions
{
    bool isPrelinking = false;
    static PeepholeOptimizationOptions getPrelinking()
    {
        PeepholeOptimizationOptions result;
        result.isPrelinking = true;
        return result;
    }
};

/// Apply peephole optimizations.
bool peepholeOptimize(TargetProgram* target, IRModule* module, PeepholeOptimizationOptions options);
bool peepholeOptimize(TargetProgram* target, IRInst* func);
bool peepholeOptimizeInst(TargetProgram* target, IRModule* module, IRInst* inst);
bool peepholeOptimizeGlobalScope(TargetProgram* target, IRModule* module);
bool tryReplaceInstUsesWithSimplifiedValue(TargetProgram* target, IRModule* module, IRInst* inst);
} // namespace Slang