summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-vm.h
blob: ee412c752920bef41bc4422726e66b6daa761749 (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
#ifndef SLANG_EMIT_VM_H
#define SLANG_EMIT_VM_H

#include "slang-emit-base.h"
#include "slang-ir-link.h"
#include "slang-vm-bytecode.h"

namespace Slang
{

struct VMByteCodeFunctionBuilder
{
    VMOperand name = {};
    uint32_t workingSetSizeInBytes = 0;
    List<uint8_t> code;
    List<Index> instOffsets;
    List<uint32_t> parameterOffsets;
    uint32_t resultSize = 0;
    uint32_t parameterSize = 0;
};

struct VMByteCodeBuilder
{
    List<VMByteCodeFunctionBuilder> functions;
    ComPtr<slang::IBlob> kernelBlob;

    List<uint8_t> constantSection;
    List<uint32_t> stringOffsets;
    SlangResult serialize(slang::IBlob** outBlob);
};

SlangResult emitVMByteCodeForEntryPoints(
    CodeGenContext* codeGenContext,
    LinkedIR& linkedIR,
    VMByteCodeBuilder& byteCode);
} // namespace Slang

#endif