Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Support/TargetSelect.h
Line
Count
Source (jump to first uncovered line)
1
//===- TargetSelect.h - Target Selection & Registration ---------*- C++ -*-===//
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 provides utilities to make sure that certain classes of targets are
10
// linked into the main application executable, and initialize them as
11
// appropriate.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_SUPPORT_TARGETSELECT_H
16
#define LLVM_SUPPORT_TARGETSELECT_H
17
18
#include "llvm/Config/llvm-config.h"
19
20
extern "C" {
21
  // Declare all of the target-initialization functions that are available.
22
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetInfo();
23
#include "llvm/Config/Targets.def"
24
25
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
26
#include "llvm/Config/Targets.def"
27
28
  // Declare all of the target-MC-initialization functions that are available.
29
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetMC();
30
#include "llvm/Config/Targets.def"
31
32
  // Declare all of the available assembly printer initialization functions.
33
#define LLVM_ASM_PRINTER(TargetName) void LLVMInitialize##TargetName##AsmPrinter();
34
#include "llvm/Config/AsmPrinters.def"
35
36
  // Declare all of the available assembly parser initialization functions.
37
#define LLVM_ASM_PARSER(TargetName) void LLVMInitialize##TargetName##AsmParser();
38
#include "llvm/Config/AsmParsers.def"
39
40
  // Declare all of the available disassembler initialization functions.
41
#define LLVM_DISASSEMBLER(TargetName) \
42
  void LLVMInitialize##TargetName##Disassembler();
43
#include "llvm/Config/Disassemblers.def"
44
}
45
46
namespace llvm {
47
  /// InitializeAllTargetInfos - The main program should call this function if
48
  /// it wants access to all available targets that LLVM is configured to
49
  /// support, to make them available via the TargetRegistry.
50
  ///
51
  /// It is legal for a client to make multiple calls to this function.
52
157k
  inline void InitializeAllTargetInfos() {
53
2.51M
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
54
157k
#include "llvm/Config/Targets.def"
55
157k
  }
56
57
  /// InitializeAllTargets - The main program should call this function if it
58
  /// wants access to all available target machines that LLVM is configured to
59
  /// support, to make them available via the TargetRegistry.
60
  ///
61
  /// It is legal for a client to make multiple calls to this function.
62
139k
  inline void InitializeAllTargets() {
63
139k
    // FIXME: Remove this, clients should do it.
64
139k
    InitializeAllTargetInfos();
65
139k
66
2.22M
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
67
139k
#include "llvm/Config/Targets.def"
68
139k
  }
69
70
  /// InitializeAllTargetMCs - The main program should call this function if it
71
  /// wants access to all available target MC that LLVM is configured to
72
  /// support, to make them available via the TargetRegistry.
73
  ///
74
  /// It is legal for a client to make multiple calls to this function.
75
96.4k
  inline void InitializeAllTargetMCs() {
76
1.54M
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
77
96.4k
#include "llvm/Config/Targets.def"
78
96.4k
  }
79
80
  /// InitializeAllAsmPrinters - The main program should call this function if
81
  /// it wants all asm printers that LLVM is configured to support, to make them
82
  /// available via the TargetRegistry.
83
  ///
84
  /// It is legal for a client to make multiple calls to this function.
85
78.9k
  inline void InitializeAllAsmPrinters() {
86
1.26M
#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
87
78.9k
#include "llvm/Config/AsmPrinters.def"
88
78.9k
  }
89
90
  /// InitializeAllAsmParsers - The main program should call this function if it
91
  /// wants all asm parsers that LLVM is configured to support, to make them
92
  /// available via the TargetRegistry.
93
  ///
94
  /// It is legal for a client to make multiple calls to this function.
95
91.7k
  inline void InitializeAllAsmParsers() {
96
1.28M
#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
97
91.7k
#include "llvm/Config/AsmParsers.def"
98
91.7k
  }
99
100
  /// InitializeAllDisassemblers - The main program should call this function if
101
  /// it wants all disassemblers that LLVM is configured to support, to make
102
  /// them available via the TargetRegistry.
103
  ///
104
  /// It is legal for a client to make multiple calls to this function.
105
  inline void InitializeAllDisassemblers() {
106
#define LLVM_DISASSEMBLER(TargetName) LLVMInitialize##TargetName##Disassembler();
107
#include "llvm/Config/Disassemblers.def"
108
  }
109
110
  /// InitializeNativeTarget - The main program should call this function to
111
  /// initialize the native target corresponding to the host.  This is useful
112
  /// for JIT applications to ensure that the target gets linked in correctly.
113
  ///
114
  /// It is legal for a client to make multiple calls to this function.
115
  inline bool InitializeNativeTarget() {
116
  // If we have a native target, initialize it to ensure it is linked in.
117
#ifdef LLVM_NATIVE_TARGET
118
    LLVM_NATIVE_TARGETINFO();
119
    LLVM_NATIVE_TARGET();
120
    LLVM_NATIVE_TARGETMC();
121
    return false;
122
#else
123
    return true;
124
#endif
125
  }
126
127
  /// InitializeNativeTargetAsmPrinter - The main program should call
128
  /// this function to initialize the native target asm printer.
129
  inline bool InitializeNativeTargetAsmPrinter() {
130
  // If we have a native target, initialize the corresponding asm printer.
131
#ifdef LLVM_NATIVE_ASMPRINTER
132
    LLVM_NATIVE_ASMPRINTER();
133
    return false;
134
#else
135
    return true;
136
#endif
137
  }
138
139
  /// InitializeNativeTargetAsmParser - The main program should call
140
  /// this function to initialize the native target asm parser.
141
  inline bool InitializeNativeTargetAsmParser() {
142
  // If we have a native target, initialize the corresponding asm parser.
143
#ifdef LLVM_NATIVE_ASMPARSER
144
    LLVM_NATIVE_ASMPARSER();
145
    return false;
146
#else
147
    return true;
148
#endif
149
  }
150
151
  /// InitializeNativeTargetDisassembler - The main program should call
152
  /// this function to initialize the native target disassembler.
153
0
  inline bool InitializeNativeTargetDisassembler() {
154
0
  // If we have a native target, initialize the corresponding disassembler.
155
0
#ifdef LLVM_NATIVE_DISASSEMBLER
156
0
    LLVM_NATIVE_DISASSEMBLER();
157
0
    return false;
158
0
#else
159
0
    return true;
160
0
#endif
161
0
  }
162
}
163
164
#endif