aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/computation/mkql_block_impl_codegen.h.txt
blob: afc435fb4434ed3763478f456a29010ffa901696 (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
#pragma once

#include <yql/essentials/minikql/computation/mkql_block_item.h>
#include "mkql_llvm_base.h"

#include <yql/essentials/minikql/codegen/codegen.h>

namespace NKikimr::NMiniKQL {

#ifndef MKQL_DISABLE_CODEGEN
    class TLLVMFieldsStructureBlockState: public TLLVMFieldsStructure<TComputationValue<TBlockState>> {
    private:
        using TBase = TLLVMFieldsStructure<TComputationValue<TBlockState>>;
        llvm::IntegerType*const CountType;
        llvm::PointerType*const PointerType;
        llvm::ArrayType*const SkipSpaceType;
    protected:
        using TBase::Context;
        static constexpr auto BaseFields = 3U;
    public:
        std::vector<llvm::Type*> GetFieldsArray() {
            std::vector<llvm::Type*> result = TBase::GetFields();
            result.emplace_back(CountType);
            result.emplace_back(PointerType);
            result.emplace_back(SkipSpaceType);
            return result;
        }

        llvm::Constant* GetCount() {
            return llvm::ConstantInt::get(llvm::Type::getInt32Ty(Context), TBase::GetFieldsCount() + 0);
        }

        llvm::Constant* GetPointer() {
            return llvm::ConstantInt::get(llvm::Type::getInt32Ty(Context), TBase::GetFieldsCount() + 1);
        }

        TLLVMFieldsStructureBlockState(llvm::LLVMContext& context, size_t width)
            : TBase(context)
            , CountType(llvm::Type::getInt64Ty(Context))
            , PointerType(llvm::PointerType::getUnqual(llvm::ArrayType::get(llvm::Type::getInt128Ty(Context), width)))
            , SkipSpaceType(llvm::ArrayType::get(llvm::Type::getInt64Ty(Context), 9U)) // Skip std::vectors Values & Arrays
        {}
    };
#endif
} //namespace NKikimr::NMiniKQL