aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/computation/mkql_llvm_base.h.txt
blob: 2ba02161a5121ab729389c04df3bb7ceebe5e623 (plain) (blame)
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
52
53
54
55
56
57
58
59
60
#pragma once

#ifndef MKQL_DISABLE_CODEGEN
#include <yql/essentials/minikql/computation/mkql_computation_node_impl.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Constant.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/Constants.h>

namespace NKikimr::NMiniKQL {
template <class T>
class TLLVMFieldsStructure;

template <class T>
class TLLVMFieldsStructure<TComputationValue<T>> {
protected:
    llvm::LLVMContext& Context;
    ui32 GetFieldsCount() const {
        return FieldsCount;
    }
    const std::vector<llvm::Type*>& GetFields() const {
        return Fields;
    }
private:
    llvm::PointerType* StructPtrType;
    std::vector<llvm::Type*> Fields;
    const ui32 FieldsCount;
    std::vector<llvm::Type*> BuildFields() {
        std::vector<llvm::Type*> result;
        result.emplace_back(StructPtrType);             // vtbl
        result.emplace_back(llvm::Type::getInt32Ty(Context)); // ref
        result.emplace_back(llvm::Type::getInt16Ty(Context)); // abi
        result.emplace_back(llvm::Type::getInt16Ty(Context)); // reserved
#ifndef NDEBUG
        result.emplace_back(StructPtrType);             // meminfo
#endif
        return result;
    }

public:
    TLLVMFieldsStructure(llvm::LLVMContext& context)
        : Context(context)
        , StructPtrType(llvm::PointerType::getUnqual(llvm::StructType::get(Context)))
        , Fields(BuildFields())
        , FieldsCount(Fields.size()) {

    }

    llvm::Constant* This() const {
        return llvm::ConstantInt::get(llvm::Type::getInt32Ty(Context), 0);
    }

    const std::vector<llvm::Type*>& GetFieldsArray() const {
        return Fields;
    }
};

}
#endif