mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Merge pull request #24342 from kitaisreal/jit-support-aarch64-compilation
LLVM JIT support AARCH64
This commit is contained in:
commit
2c4920186b
@ -1,57 +1,57 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <llvm/IR/IRBuilder.h>
|
// #include <llvm/IR/IRBuilder.h>
|
||||||
|
|
||||||
#include <Interpreters/JIT/CHJIT.h>
|
// #include <Interpreters/JIT/CHJIT.h>
|
||||||
|
|
||||||
void test_function()
|
// void test_function()
|
||||||
{
|
// {
|
||||||
std::cerr << "Test function" << std::endl;
|
// std::cerr << "Test function" << std::endl;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
(void)(argc);
|
(void)(argc);
|
||||||
(void)(argv);
|
(void)(argv);
|
||||||
|
|
||||||
auto jit = DB::CHJIT();
|
// auto jit = DB::CHJIT();
|
||||||
|
|
||||||
jit.registerExternalSymbol("test_function", reinterpret_cast<void *>(&test_function));
|
// jit.registerExternalSymbol("test_function", reinterpret_cast<void *>(&test_function));
|
||||||
|
|
||||||
auto compiled_module_info = jit.compileModule([](llvm::Module & module)
|
// auto compiled_module_info = jit.compileModule([](llvm::Module & module)
|
||||||
{
|
// {
|
||||||
auto & context = module.getContext();
|
// auto & context = module.getContext();
|
||||||
llvm::IRBuilder<> b (context);
|
// llvm::IRBuilder<> b (context);
|
||||||
|
|
||||||
auto * func_declaration_type = llvm::FunctionType::get(b.getVoidTy(), { }, /*isVarArg=*/false);
|
// auto * func_declaration_type = llvm::FunctionType::get(b.getVoidTy(), { }, /*isVarArg=*/false);
|
||||||
auto * func_declaration = llvm::Function::Create(func_declaration_type, llvm::Function::ExternalLinkage, "test_function", module);
|
// auto * func_declaration = llvm::Function::Create(func_declaration_type, llvm::Function::ExternalLinkage, "test_function", module);
|
||||||
|
|
||||||
auto * value_type = b.getInt64Ty();
|
// auto * value_type = b.getInt64Ty();
|
||||||
auto * pointer_type = value_type->getPointerTo();
|
// auto * pointer_type = value_type->getPointerTo();
|
||||||
|
|
||||||
auto * func_type = llvm::FunctionType::get(b.getVoidTy(), { pointer_type }, /*isVarArg=*/false);
|
// auto * func_type = llvm::FunctionType::get(b.getVoidTy(), { pointer_type }, /*isVarArg=*/false);
|
||||||
auto * function = llvm::Function::Create(func_type, llvm::Function::ExternalLinkage, "test_name", module);
|
// auto * function = llvm::Function::Create(func_type, llvm::Function::ExternalLinkage, "test_name", module);
|
||||||
auto * entry = llvm::BasicBlock::Create(context, "entry", function);
|
// auto * entry = llvm::BasicBlock::Create(context, "entry", function);
|
||||||
|
|
||||||
auto * argument = function->args().begin();
|
// auto * argument = function->args().begin();
|
||||||
b.SetInsertPoint(entry);
|
// b.SetInsertPoint(entry);
|
||||||
|
|
||||||
b.CreateCall(func_declaration);
|
// b.CreateCall(func_declaration);
|
||||||
|
|
||||||
auto * load_argument = b.CreateLoad(argument);
|
// auto * load_argument = b.CreateLoad(argument);
|
||||||
auto * value = b.CreateAdd(load_argument, load_argument);
|
// auto * value = b.CreateAdd(load_argument, load_argument);
|
||||||
b.CreateRet(value);
|
// b.CreateRet(value);
|
||||||
});
|
// });
|
||||||
|
|
||||||
for (const auto & compiled_function_name : compiled_module_info.compiled_functions)
|
// for (const auto & compiled_function_name : compiled_module_info.compiled_functions)
|
||||||
{
|
// {
|
||||||
std::cerr << compiled_function_name << std::endl;
|
// std::cerr << compiled_function_name << std::endl;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int64_t value = 5;
|
// int64_t value = 5;
|
||||||
auto * test_name_function = reinterpret_cast<int64_t (*)(int64_t *)>(jit.findCompiledFunction(compiled_module_info, "test_name"));
|
// auto * test_name_function = reinterpret_cast<int64_t (*)(int64_t *)>(jit.findCompiledFunction(compiled_module_info, "test_name"));
|
||||||
auto result = test_name_function(&value);
|
// auto result = test_name_function(&value);
|
||||||
std::cerr << "Result " << result << std::endl;
|
// std::cerr << "Result " << result << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ if (NOT DEFINED ENABLE_UTILS OR ENABLE_UTILS)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# memcpy_jart.S contains position dependent code
|
# memcpy_jart.S contains position dependent code
|
||||||
if (NOT CMAKE_POSITION_INDEPENDENT_CODE AND NOT OS_DARWIN AND NOT OS_SUNOS)
|
if (NOT CMAKE_POSITION_INDEPENDENT_CODE AND NOT OS_DARWIN AND NOT OS_SUNOS AND NOT ARCH_AARCH64)
|
||||||
add_subdirectory (memcpy-bench)
|
add_subdirectory (memcpy-bench)
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
Loading…
Reference in New Issue
Block a user