summaryrefslogtreecommitdiffstats
path: root/include/llvm/Target/TargetSelect.h
blob: 8aa314ac774733e2bf2cbc82dea8cd0c18c005b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//===- TargetSelect.h - Target Selection & Registration -------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file provides utilities to make sure that certain classes of targets are
// linked into the main application executable, and initialize them as
// appropriate.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TARGET_TARGETSELECT_H
#define LLVM_TARGET_TARGETSELECT_H

#include "llvm/Config/config.h"

namespace llvm {
  // Declare all of the target-initialization functions that are available.
#define LLVM_TARGET(TargetName) void Initialize##TargetName##Target();
#include "llvm/Config/Targets.def"
  
  // Declare all of the available asm-printer initialization functions.
  // Declare all of the target-initialization functions.
#define LLVM_ASM_PRINTER(TargetName) void Initialize##TargetName##AsmPrinter();
#include "llvm/Config/AsmPrinters.def"
  
  /// InitializeAllTargets - The main program should call this function if it
  /// wants to link in all available targets that LLVM is configured to support.
  inline void InitializeAllTargets() {
#define LLVM_TARGET(TargetName) llvm::Initialize##TargetName##Target();
#include "llvm/Config/Targets.def"
  }
  
  /// InitializeAllAsmPrinters - The main program should call this function if
  /// it wants all asm printers that LLVM is configured to support.  This will
  /// cause them to be linked into its executable.
  inline void InitializeAllAsmPrinters() {
#define LLVM_ASM_PRINTER(TargetName) Initialize##TargetName##AsmPrinter();
#include "llvm/Config/AsmPrinters.def"
  }
  
  
  /// InitializeNativeTarget - The main program should call this function to
  /// initialize the native target corresponding to the host.  This is useful 
  /// for JIT applications to ensure that the target gets linked in correctly.
  inline bool InitializeNativeTarget() {
  // If we have a native target, initialize it to ensure it is linked in.
#ifdef LLVM_NATIVE_ARCH
#define DoInit2(TARG)   llvm::Initialize ## TARG ()
#define DoInit(T) DoInit2(T)
    DoInit(LLVM_NATIVE_ARCH);
    return false;
#undef DoInit
#undef DoInit2
#else
    return true;
#endif
  }  
}

#endif
OpenPOWER on IntegriCloud