-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
111 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
add_library(bpftime_llvm_vm STATIC ./compat_llvm.cpp) | ||
add_library(bpftime_llvm_vm STATIC compat_llvm.cpp) | ||
|
||
add_dependencies(bpftime_llvm_vm llvmbpf_vm spdlog::spdlog bpftime_vm_compat) | ||
|
||
target_link_libraries(bpftime_llvm_vm PUBLIC bpftime_vm_compat spdlog::spdlog) | ||
target_link_libraries(bpftime_llvm_vm PUBLIC bpftime_vm_compat spdlog::spdlog llvmbpf_vm) | ||
|
||
target_include_directories(bpftime_llvm_vm PRIVATE ../../llvm-jit/inc ${CMAKE_CURRENT_SOURCE_DIR} ${SPDLOG_INCLUDE}) | ||
target_include_directories(bpftime_llvm_vm PRIVATE ../../llvm-jit/include ${CMAKE_CURRENT_SOURCE_DIR} ${SPDLOG_INCLUDE}) | ||
|
||
add_subdirectory(../../llvm-jit ${CMAKE_CURRENT_BINARY_DIR}/llvm-jit) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,48 @@ | ||
#include <bpftime_vm_compat.hpp> | ||
#include <compat_llvm.hpp> | ||
|
||
namespace bpftime::vm::compat | ||
{ | ||
|
||
std::unique_ptr<bpftime_vm_impl> create_vm_instance() | ||
{ | ||
return std::make_unique<llvm::bpftime_llvm_vm>(); | ||
} | ||
|
||
} // namespace bpftime::vm::compat | ||
|
||
namespace bpftime::vm::llvm { | ||
|
||
int bpftime_llvm_vm::register_external_function(size_t index, const std::string &name, void *fn) { | ||
return bpftime::llvmbpf_vm::register_external_function(index, name, fn); | ||
} | ||
|
||
void bpftime_llvm_vm::unload_code() { | ||
bpftime::llvmbpf_vm::unload_code(); | ||
} | ||
|
||
int bpftime_llvm_vm::exec(void *mem, size_t mem_len, uint64_t &bpf_return_value) { | ||
return bpftime::llvmbpf_vm::exec(mem, mem_len, bpf_return_value); | ||
} | ||
|
||
std::vector<uint8_t> bpftime_llvm_vm::do_aot_compile(bool print_ir) { | ||
return bpftime::llvmbpf_vm::do_aot_compile(print_ir); | ||
} | ||
|
||
std::optional<compat::precompiled_ebpf_function> bpftime_llvm_vm::load_aot_object(const std::vector<uint8_t> &object) { | ||
return bpftime::llvmbpf_vm::load_aot_object(object); | ||
} | ||
|
||
std::optional<compat::precompiled_ebpf_function> bpftime_llvm_vm::compile() { | ||
return bpftime::llvmbpf_vm::compile(); | ||
} | ||
|
||
void bpftime_llvm_vm::set_lddw_helpers(uint64_t (*map_by_fd)(uint32_t), | ||
uint64_t (*map_by_idx)(uint32_t), | ||
uint64_t (*map_val)(uint64_t), | ||
uint64_t (*var_addr)(uint32_t), | ||
uint64_t (*code_addr)(uint32_t)) { | ||
bpftime::llvmbpf_vm::set_lddw_helpers(map_by_fd, map_by_idx, map_val, var_addr, code_addr); | ||
} | ||
|
||
} // namespace bpftime::vm::llvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters