blob: 4057fc2f4965b146c36f116fd10e21d973efc337 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// slang-ir-entry-point-pass.cpp
#include "slang-ir-entry-point-pass.h"
namespace Slang
{
void PerEntryPointPass::processModule(IRModule* module)
{
m_module = module;
// Note that we are only looking at true global-scope
// functions and not functions nested inside of
// IR generics. When using generic entry points, this
// pass should be run after the entry point(s) have
// been specialized to their generic type parameters.
for (auto inst : module->getGlobalInsts())
{
// We are only interested in entry points.
//
// Every entry point must be a function.
//
auto func = as<IRFunc>(inst);
if (!func)
continue;
// Entry points will always have the `[entryPoint]`
// decoration to differentiate them from ordinary
// functions.
//
auto entryPointDecoration = func->findDecoration<IREntryPointDecoration>();
if (!entryPointDecoration)
continue;
// If we find a candidate entry point, then we
// will process it.
//
processEntryPoint(func, entryPointDecoration);
}
}
void PerEntryPointPass::processEntryPoint(
IRFunc* entryPointFunc,
IREntryPointDecoration* entryPointDecoration)
{
m_entryPoint.func = entryPointFunc;
m_entryPoint.decoration = entryPointDecoration;
processEntryPointImpl(m_entryPoint);
}
} // namespace Slang
|