summaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/codegen/codegen.h
diff options
context:
space:
mode:
authorvvvv <[email protected]>2024-11-07 04:19:26 +0300
committervvvv <[email protected]>2024-11-07 04:29:50 +0300
commit2661be00f3bc47590fda9218bf0386d6355c8c88 (patch)
tree3d316c07519191283d31c5f537efc6aabb42a2f0 /yql/essentials/minikql/codegen/codegen.h
parentcf2a23963ac10add28c50cc114fbf48953eca5aa (diff)
Moved yql/minikql YQL-19206
init [nodiff:caesar] commit_hash:d1182ef7d430ccf7e4d37ed933c7126d7bd5d6e4
Diffstat (limited to 'yql/essentials/minikql/codegen/codegen.h')
-rw-r--r--yql/essentials/minikql/codegen/codegen.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/yql/essentials/minikql/codegen/codegen.h b/yql/essentials/minikql/codegen/codegen.h
new file mode 100644
index 00000000000..4c7e2ab4f12
--- /dev/null
+++ b/yql/essentials/minikql/codegen/codegen.h
@@ -0,0 +1,75 @@
+#pragma once
+
+#include <memory>
+#include <util/generic/fwd.h>
+#include <util/generic/strbuf.h>
+
+class IOutputStream;
+
+namespace llvm {
+ class Module;
+ class Function;
+ class LLVMContext;
+ class ExecutionEngine;
+}
+
+namespace NYql {
+namespace NCodegen {
+
+enum class ETarget {
+ Native, // Run on current processor and OS
+ CurrentOS,
+ Linux,
+ Windows,
+ Darwin
+};
+
+enum class ESanitize {
+ Auto,
+ Asan,
+ Msan,
+ Tsan
+};
+
+struct TCodegenStats {
+ ui64 TotalFunctions = 0;
+ ui64 TotalInstructions = 0;
+ ui64 MaxFunctionInstructions = 0;
+};
+
+struct TCompileStats {
+ ui32 FunctionPassTime = 0;
+ ui32 ModulePassTime = 0;
+ ui32 FinalizeTime = 0;
+ ui64 TotalObjectSize = 0;
+};
+
+class ICodegen {
+public:
+ virtual ~ICodegen() = default;
+ virtual ETarget GetEffectiveTarget() const = 0;
+ virtual llvm::LLVMContext& GetContext() = 0;
+ virtual llvm::Module& GetModule() = 0;
+ virtual llvm::ExecutionEngine& GetEngine() = 0;
+ virtual void Verify() = 0;
+ virtual void GetStats(TCodegenStats& stats) = 0;
+ virtual void ExportSymbol(llvm::Function* function) = 0; // to run DCE before Compile
+ virtual void Compile(const TStringBuf compileOpts = TStringBuf(), TCompileStats* compileStats = nullptr) = 0;
+ virtual void* GetPointerToFunction(llvm::Function* function) = 0;
+ virtual ui64 GetFunctionCodeSize(llvm::Function* function) = 0;
+ virtual void ShowGeneratedFunctions(IOutputStream* out) = 0;
+ virtual void LoadBitCode(TStringBuf bitcode, TStringBuf uniqId) = 0;
+ virtual void AddGlobalMapping(TStringBuf name, const void* address) = 0;
+ virtual void TogglePerfJITEventListener() = 0;
+
+ using TPtr = std::unique_ptr<ICodegen>;
+ static TPtr Make(ETarget target, ESanitize sanitize = ESanitize::Auto);
+
+ using TSharedPtr = std::shared_ptr<ICodegen>;
+ static TSharedPtr MakeShared(ETarget target, ESanitize sanitize = ESanitize::Auto);
+
+ static bool IsCodegenAvailable();
+};
+
+}
+}