summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-lower-generics.cpp
blob: 7df590b2314e940c0298bd7d065b3af2697b3934 (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
32
33
// slang-ir-lower-generics.cpp
#include "slang-ir-lower-generics.h"

#include "slang-ir-any-value-marshalling.h"
#include "slang-ir-generics-lowering-context.h"
#include "slang-ir-lower-generic-function.h"
#include "slang-ir-lower-generic-call.h"
#include "slang-ir-lower-generic-type.h"
#include "slang-ir-witness-table-wrapper.h"
#include "slang-ir-ssa.h"
#include "slang-ir-dce.h"

namespace Slang
{
    void lowerGenerics(
        IRModule* module,
        DiagnosticSink* sink)
    {
        SharedGenericsLoweringContext sharedContext;
        sharedContext.module = module;
        sharedContext.sink = sink;

        lowerGenericFunctions(&sharedContext);
        lowerGenericType(&sharedContext);
        lowerGenericCalls(&sharedContext);
        generateWitnessTableWrapperFunctions(&sharedContext);
        generateAnyValueMarshallingFunctions(&sharedContext);
        // We might have generated new temporary variables during lowering.
        // An SSA pass can clean up unnecessary load/stores.
        constructSSA(module);
        eliminateDeadCode(module);
    }
} // namespace Slang