| //===-- Target.cpp --------------------------------------------------------===// | |
| // | |
| // 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 | |
| // | |
| //===----------------------------------------------------------------------===// | |
| // | |
| // This file implements the common infrastructure (including C bindings) for | |
| // libLLVMTarget.a, which implements target information. | |
| // | |
| //===----------------------------------------------------------------------===// | |
| #include "llvm-c/Target.h" | |
| #include "llvm/Analysis/TargetLibraryInfo.h" | |
| #include "llvm/IR/LegacyPassManager.h" | |
| #include "llvm/InitializePasses.h" | |
| using namespace llvm; | |
| inline TargetLibraryInfoImpl *unwrap(LLVMTargetLibraryInfoRef P) { | |
| return reinterpret_cast<TargetLibraryInfoImpl*>(P); | |
| } | |
| inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfoImpl *P) { | |
| TargetLibraryInfoImpl *X = const_cast<TargetLibraryInfoImpl*>(P); | |
| return reinterpret_cast<LLVMTargetLibraryInfoRef>(X); | |
| } | |
| void llvm::initializeTarget(PassRegistry &Registry) { | |
| initializeTargetLibraryInfoWrapperPassPass(Registry); | |
| initializeRuntimeLibraryInfoWrapperPass(Registry); | |
| initializeTargetTransformInfoWrapperPassPass(Registry); | |
| } | |
| void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI, | |
| LLVMPassManagerRef PM) { | |
| unwrap(PM)->add(new TargetLibraryInfoWrapperPass(*unwrap(TLI))); | |
| } |