//===-------- BasicOrcV2CBindings.c - Basic OrcV2 C Bindings Demo ---------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm-c/Core.h" #include "llvm-c/Error.h" #include "llvm-c/IRReader.h" #include "llvm-c/LLJIT.h" #include "llvm-c/Support.h" #include "llvm-c/Target.h" #include <assert.h> #include <stdio.h> #include <string.h> int handleError(LLVMErrorRef Err) { … } // Example IR modules. // // Note that in the conditionally compiled modules, FooMod and BarMod, functions // have been given an _body suffix. This is to ensure that their names do not // clash with their lazy-reexports. // For clients who do not wish to rename function bodies (e.g. because they want // to re-use cached objects between static and JIT compiles) techniques exist to // avoid renaming. See the lazy-reexports section of the ORCv2 design doc. const char FooMod[] = …; const char BarMod[] = …; const char MainMod[] = …; LLVMErrorRef applyDataLayout(void *Ctx, LLVMModuleRef M) { … } LLVMErrorRef parseExampleModule(const char *Source, size_t Len, const char *Name, LLVMOrcThreadSafeModuleRef *TSM) { … } void Destroy(void *Ctx) { … } void Materialize(void *Ctx, LLVMOrcMaterializationResponsibilityRef MR) { … } int main(int argc, const char *argv[]) { … }