cyx-6 commented on code in PR #254: URL: https://github.com/apache/tvm-ffi/pull/254#discussion_r2986922999
########## addons/tvm-ffi-orcjit/src/ffi/orcjit_session.cc: ########## @@ -0,0 +1,664 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file orcjit_session.cc + * \brief LLVM ORC JIT ExecutionSession implementation + */ + +#include "orcjit_session.h" + +#include <llvm/ExecutionEngine/JITLink/JITLink.h> +#include <llvm/ExecutionEngine/JITLink/x86_64.h> +#include <llvm/ExecutionEngine/Orc/AbsoluteSymbols.h> +#include <llvm/ExecutionEngine/Orc/LLJIT.h> +#include <llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h> +#include <llvm/ExecutionEngine/Orc/ObjectTransformLayer.h> +#include <llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h> +#include <llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h> +#include <llvm/Support/DynamicLibrary.h> +#include <llvm/Support/Error.h> +#include <llvm/Support/TargetSelect.h> +#include <llvm/TargetParser/SubtargetFeature.h> +#include <tvm/ffi/cast.h> +#include <tvm/ffi/error.h> +#include <tvm/ffi/object.h> +#include <tvm/ffi/reflection/registry.h> + +#include <cstddef> +#include <cstring> + +#ifdef _WIN32 +#ifndef NOMINMAX +#define NOMINMAX +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include <psapi.h> +#include <windows.h> +#endif + +#include "orcjit_dylib.h" +#include "orcjit_utils.h" + +namespace tvm { +namespace ffi { +namespace orcjit { + +// Initialize LLVM native target (only once) +struct LLVMInitializer { + LLVMInitializer() { + llvm::InitializeNativeTarget(); + llvm::InitializeNativeTargetAsmPrinter(); + llvm::InitializeNativeTargetAsmParser(); + } +}; + +static LLVMInitializer llvm_initializer; + +class InitFiniPlugin : public llvm::orc::ObjectLinkingLayer::Plugin { + ORCJITExecutionSession session_; + + public: + explicit InitFiniPlugin(ORCJITExecutionSession session) : session_(std::move(session)) {} Review Comment: already fixed -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
