1//===-- Target.cpp --------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the common infrastructure (including C bindings) for
10// libLLVMTarget.a, which implements target information.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm-c/Target.h"
15#include "llvm/Analysis/TargetLibraryInfo.h"
16#include "llvm/IR/LegacyPassManager.h"
17#include "llvm/InitializePasses.h"
18
19using namespace llvm;
20
21inline TargetLibraryInfoImpl *unwrap(LLVMTargetLibraryInfoRef P) {
22 return reinterpret_cast<TargetLibraryInfoImpl*>(P);
23}
24
25inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfoImpl *P) {
26 TargetLibraryInfoImpl *X = const_cast<TargetLibraryInfoImpl*>(P);
27 return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
28}
29
30void llvm::initializeTarget(PassRegistry &Registry) {
31 initializeTargetLibraryInfoWrapperPassPass(Registry);
32 initializeRuntimeLibraryInfoWrapperPass(Registry);
33 initializeTargetTransformInfoWrapperPassPass(Registry);
34}
35
36void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI,
37 LLVMPassManagerRef PM) {
38 unwrap(P: PM)->add(P: new TargetLibraryInfoWrapperPass(*unwrap(P: TLI)));
39}
40