llvm.org GIT mirror llvm / cca8dbe
Reorganize the C API headers to improve build times. Type specific declarations have been moved to Type.h and error handling routines have been moved to ErrorHandling.h. Both are included in Core.h so nothing should change for projects directly including the headers, but transitive dependencies may be affected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255965 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 3 years ago
39 changed file(s) with 212 addition(s) and 146 deletion(s). Raw diff Collapse all Expand all
1414
1515 /*
1616 #include "llvm-c/Analysis.h" // If you are getting an error here read bindings/go/README.txt
17 #include "llvm-c/Core.h"
1718 #include
1819 */
1920 import "C"
1414
1515 /*
1616 #include "llvm-c/BitReader.h"
17 #include "llvm-c/Core.h"
1718 #include
1819 */
1920 import "C"
1313 package llvm
1414
1515 /*
16 #include "llvm-c/Core.h"
1617 #include "llvm-c/ExecutionEngine.h"
1718 #include
1819 */
1313 package llvm
1414
1515 /*
16 #include "llvm-c/Core.h"
1617 #include "llvm-c/Linker.h"
1718 #include
1819 */
1313 package llvm
1414
1515 /*
16 #include "llvm-c/Core.h"
1617 #include "llvm-c/Target.h"
1718 #include "llvm-c/TargetMachine.h"
1819 #include
5050
5151 * The deprecated C APIs LLVMGetBitcodeModuleProviderInContext and
5252 LLVMGetBitcodeModuleProvider have been removed.
53
54 * With this release, the C API headers have been reorganized to improve build
55 time. Type specific declarations have been moved to Type.h, and error
56 handling routines have been moved to ErrorHandling.h. Both are included in
57 Core.h so nothing should change for projects directly including the headers,
58 but transitive dependencies may be affected.
5359
5460 .. NOTE
5561 For small 1-3 sentence descriptions, just add an entry at the end of
1414 #ifndef LLVM_IR_DIAGNOSTICINFO_H
1515 #define LLVM_IR_DIAGNOSTICINFO_H
1616
17 #include "llvm-c/Core.h"
1817 #include "llvm/ADT/ArrayRef.h"
1918 #include "llvm/IR/DebugLoc.h"
2019 #include "llvm/IR/Module.h"
1414 #ifndef LLVM_IR_LLVMCONTEXT_H
1515 #define LLVM_IR_LLVMCONTEXT_H
1616
17 #include "llvm-c/Core.h"
1817 #include "llvm/Support/CBindingWrapping.h"
1918 #include "llvm/Support/Compiler.h"
2019 #include "llvm/Support/Options.h"
1414 #ifndef LLVM_IR_TYPE_H
1515 #define LLVM_IR_TYPE_H
1616
17 #include "llvm-c/Core.h"
1817 #include "llvm/ADT/APFloat.h"
1918 #include "llvm/ADT/SmallPtrSet.h"
2019 #include "llvm/Support/CBindingWrapping.h"
2424 #ifndef LLVM_IR_USE_H
2525 #define LLVM_IR_USE_H
2626
27 #include "llvm-c/Core.h"
2827 #include "llvm/ADT/PointerIntPair.h"
2928 #include "llvm/Support/CBindingWrapping.h"
3029 #include "llvm/Support/Compiler.h"
1313 #ifndef LLVM_IR_VALUE_H
1414 #define LLVM_IR_VALUE_H
1515
16 #include "llvm-c/Core.h"
1716 #include "llvm/ADT/iterator_range.h"
1817 #include "llvm/IR/Use.h"
1918 #include "llvm/Support/CBindingWrapping.h"
1616 #ifndef LLVM_PASSREGISTRY_H
1717 #define LLVM_PASSREGISTRY_H
1818
19 #include "llvm-c/Core.h"
2019 #include "llvm/ADT/DenseMap.h"
2120 #include "llvm/ADT/SmallPtrSet.h"
2221 #include "llvm/ADT/StringMap.h"
1414 #define LLVM_SUPPORT_CBINDINGWRAPPING_H
1515
1616 #include "llvm/Support/Casting.h"
17 #include "llvm-c/Types.h"
1718
1819 #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
1920 inline ty *unwrap(ref P) { \
1313 #ifndef LLVM_SUPPORT_MEMORYBUFFER_H
1414 #define LLVM_SUPPORT_MEMORYBUFFER_H
1515
16 #include "llvm-c/Support.h"
1716 #include "llvm/ADT/Twine.h"
1817 #include "llvm/Support/CBindingWrapping.h"
1918 #include "llvm/Support/DataTypes.h"
1818 #ifndef LLVM_C_ANALYSIS_H
1919 #define LLVM_C_ANALYSIS_H
2020
21 #include "llvm-c/Core.h"
21 #include "llvm-c/Types.h"
2222
2323 #ifdef __cplusplus
2424 extern "C" {
1818 #ifndef LLVM_C_BITREADER_H
1919 #define LLVM_C_BITREADER_H
2020
21 #include "llvm-c/Core.h"
21 #include "llvm-c/Types.h"
2222
2323 #ifdef __cplusplus
2424 extern "C" {
1818 #ifndef LLVM_C_BITWRITER_H
1919 #define LLVM_C_BITWRITER_H
2020
21 #include "llvm-c/Core.h"
21 #include "llvm-c/Types.h"
2222
2323 #ifdef __cplusplus
2424 extern "C" {
1414 #ifndef LLVM_C_CORE_H
1515 #define LLVM_C_CORE_H
1616
17 #include "llvm-c/Support.h"
17 #include "llvm-c/ErrorHandling.h"
18 #include "llvm-c/Types.h"
1819
1920 #ifdef __cplusplus
2021 extern "C" {
3940 * the LLVM intermediate representation as well as other related types
4041 * and utilities.
4142 *
42 * LLVM uses a polymorphic type hierarchy which C cannot represent, therefore
43 * parameters must be passed as base types. Despite the declared types, most
44 * of the functions provided operate only on branches of the type hierarchy.
45 * The declared parameter names are descriptive and specify which type is
46 * required. Additionally, each type hierarchy is documented along with the
47 * functions that operate upon it. For more detail, refer to LLVM's C++ code.
48 * If in doubt, refer to Core.cpp, which performs parameter downcasts in the
49 * form unwrap(Param).
50 *
5143 * Many exotic languages can interoperate with C code but have a harder time
5244 * with C++ due to name mangling. So in addition to C, this interface enables
5345 * tools written in such languages.
6052 *
6153 * @{
6254 */
63
64 /* Opaque types. */
65
66 /**
67 * The top-level container for all LLVM global data. See the LLVMContext class.
68 */
69 typedef struct LLVMOpaqueContext *LLVMContextRef;
70
71 /**
72 * The top-level container for all other LLVM Intermediate Representation (IR)
73 * objects.
74 *
75 * @see llvm::Module
76 */
77 typedef struct LLVMOpaqueModule *LLVMModuleRef;
78
79 /**
80 * Each value in the LLVM IR has a type, an LLVMTypeRef.
81 *
82 * @see llvm::Type
83 */
84 typedef struct LLVMOpaqueType *LLVMTypeRef;
85
86 /**
87 * Represents an individual value in LLVM IR.
88 *
89 * This models llvm::Value.
90 */
91 typedef struct LLVMOpaqueValue *LLVMValueRef;
92
93 /**
94 * Represents a basic block of instructions in LLVM IR.
95 *
96 * This models llvm::BasicBlock.
97 */
98 typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
99
100 /**
101 * Represents an LLVM basic block builder.
102 *
103 * This models llvm::IRBuilder.
104 */
105 typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
106
107 /**
108 * Interface used to provide a module to JIT or interpreter.
109 * This is now just a synonym for llvm::Module, but we have to keep using the
110 * different type to keep binary compatibility.
111 */
112 typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
113
114 /** @see llvm::PassManagerBase */
115 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
116
117 /** @see llvm::PassRegistry */
118 typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
119
120 /**
121 * Used to get the users and usees of a Value.
122 *
123 * @see llvm::Use */
124 typedef struct LLVMOpaqueUse *LLVMUseRef;
125
126
127 /**
128 * @see llvm::DiagnosticInfo
129 */
130 typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef;
13155
13256 typedef enum {
13357 LLVMZExtAttribute = 1<<0,
436360
437361 char *LLVMCreateMessage(const char *Message);
438362 void LLVMDisposeMessage(char *Message);
439
440 typedef void (*LLVMFatalErrorHandler)(const char *Reason);
441
442 /**
443 * Install a fatal error handler. By default, if LLVM detects a fatal error, it
444 * will call exit(1). This may not be appropriate in many contexts. For example,
445 * doing exit(1) will bypass many crash reporting/tracing system tools. This
446 * function allows you to install a callback that will be invoked prior to the
447 * call to exit(1).
448 */
449 void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
450
451 /**
452 * Reset the fatal error handler. This resets LLVM's fatal error handling
453 * behavior to the default.
454 */
455 void LLVMResetFatalErrorHandler(void);
456
457 /**
458 * Enable LLVM's built-in stack trace code. This intercepts the OS's crash
459 * signals and prints which component of LLVM you were in at the time if the
460 * crash.
461 */
462 void LLVMEnablePrettyStackTrace(void);
463363
464364 /**
465365 * @defgroup LLVMCCoreContext Contexts
24372337 *
24382338 * @see llvm::Instruction::getOpCode()
24392339 */
2440 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
2340 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
24412341
24422342 /**
24432343 * Obtain the predicate of an instruction.
0 /*===-- llvm-c/ErrorHandling.h - Error Handling C Interface -------*- C -*-===*\
1 |* *|
2 |* The LLVM Compiler Infrastructure *|
3 |* *|
4 |* This file is distributed under the University of Illinois Open Source *|
5 |* License. See LICENSE.TXT for details. *|
6 |* *|
7 |*===----------------------------------------------------------------------===*|
8 |* *|
9 |* This file defines the C interface to LLVM's error handling mechanism. *|
10 |* *|
11 \*===----------------------------------------------------------------------===*/
12
13 #ifndef LLVM_C_ERROR_HANDLING_H
14 #define LLVM_C_ERROR_HANDLING_H
15
16 #include "llvm-c/Types.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 typedef void (*LLVMFatalErrorHandler)(const char *Reason);
23
24 /**
25 * Install a fatal error handler. By default, if LLVM detects a fatal error, it
26 * will call exit(1). This may not be appropriate in many contexts. For example,
27 * doing exit(1) will bypass many crash reporting/tracing system tools. This
28 * function allows you to install a callback that will be invoked prior to the
29 * call to exit(1).
30 */
31 void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
32
33 /**
34 * Reset the fatal error handler. This resets LLVM's fatal error handling
35 * behavior to the default.
36 */
37 void LLVMResetFatalErrorHandler(void);
38
39 /**
40 * Enable LLVM's built-in stack trace code. This intercepts the OS's crash
41 * signals and prints which component of LLVM you were in at the time if the
42 * crash.
43 */
44 void LLVMEnablePrettyStackTrace(void);
45
46 #ifdef __cplusplus
47 }
48 #endif
49
50 #endif
1818 #ifndef LLVM_C_EXECUTIONENGINE_H
1919 #define LLVM_C_EXECUTIONENGINE_H
2020
21 #include "llvm-c/Core.h"
21 #include "llvm-c/Types.h"
2222 #include "llvm-c/Target.h"
2323 #include "llvm-c/TargetMachine.h"
2424
1313 #ifndef LLVM_C_IRREADER_H
1414 #define LLVM_C_IRREADER_H
1515
16 #include "llvm-c/Core.h"
16 #include "llvm-c/Types.h"
1717
1818 #ifdef __cplusplus
1919 extern "C" {
1515 #ifndef LLVM_C_INITIALIZATION_H
1616 #define LLVM_C_INITIALIZATION_H
1717
18 #include "llvm-c/Core.h"
18 #include "llvm-c/Types.h"
1919
2020 #ifdef __cplusplus
2121 extern "C" {
1313 #ifndef LLVM_C_LINKER_H
1414 #define LLVM_C_LINKER_H
1515
16 #include "llvm-c/Core.h"
16 #include "llvm-c/Types.h"
1717
1818 #ifdef __cplusplus
1919 extern "C" {
1818 #ifndef LLVM_C_OBJECT_H
1919 #define LLVM_C_OBJECT_H
2020
21 #include "llvm-c/Core.h"
21 #include "llvm-c/Types.h"
2222 #include "llvm/Config/llvm-config.h"
2323
2424 #ifdef __cplusplus
1414 #define LLVM_C_SUPPORT_H
1515
1616 #include "llvm/Support/DataTypes.h"
17 #include "llvm-c/Types.h"
1718
1819 #ifdef __cplusplus
1920 extern "C" {
2021 #endif
21
22 /**
23 * @defgroup LLVMCSupportTypes Types and Enumerations
24 *
25 * @{
26 */
27
28 typedef int LLVMBool;
29
30 /**
31 * Used to pass regions of memory through LLVM interfaces.
32 *
33 * @see llvm::MemoryBuffer
34 */
35 typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
36
37 /**
38 * @}
39 */
4022
4123 /**
4224 * This function permanently loads the dynamic library at the given path.
1818 #ifndef LLVM_C_TARGET_H
1919 #define LLVM_C_TARGET_H
2020
21 #include "llvm-c/Core.h"
21 #include "llvm-c/Types.h"
2222 #include "llvm/Config/llvm-config.h"
2323
2424 #if defined(_MSC_VER) && !defined(inline)
1818 #ifndef LLVM_C_TARGETMACHINE_H
1919 #define LLVM_C_TARGETMACHINE_H
2020
21 #include "llvm-c/Core.h"
21 #include "llvm-c/Types.h"
2222 #include "llvm-c/Target.h"
2323
2424 #ifdef __cplusplus
1414 #ifndef LLVM_C_TRANSFORMS_IPO_H
1515 #define LLVM_C_TRANSFORMS_IPO_H
1616
17 #include "llvm-c/Core.h"
17 #include "llvm-c/Types.h"
1818
1919 #ifdef __cplusplus
2020 extern "C" {
1313 #ifndef LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H
1414 #define LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H
1515
16 #include "llvm-c/Core.h"
16 #include "llvm-c/Types.h"
1717
1818 typedef struct LLVMOpaquePassManagerBuilder *LLVMPassManagerBuilderRef;
1919
1818 #ifndef LLVM_C_TRANSFORMS_SCALAR_H
1919 #define LLVM_C_TRANSFORMS_SCALAR_H
2020
21 #include "llvm-c/Core.h"
21 #include "llvm-c/Types.h"
2222
2323 #ifdef __cplusplus
2424 extern "C" {
1919 #ifndef LLVM_C_TRANSFORMS_VECTORIZE_H
2020 #define LLVM_C_TRANSFORMS_VECTORIZE_H
2121
22 #include "llvm-c/Core.h"
22 #include "llvm-c/Types.h"
2323
2424 #ifdef __cplusplus
2525 extern "C" {
5050 #endif /* defined(__cplusplus) */
5151
5252 #endif
53
0 /*===-- llvm-c/Support.h - C Interface Types declarations ---------*- C -*-===*\
1 |* *|
2 |* The LLVM Compiler Infrastructure *|
3 |* *|
4 |* This file is distributed under the University of Illinois Open Source *|
5 |* License. See LICENSE.TXT for details. *|
6 |* *|
7 |*===----------------------------------------------------------------------===*|
8 |* *|
9 |* This file defines types used by the the C interface to LLVM. *|
10 |* *|
11 \*===----------------------------------------------------------------------===*/
12
13 #ifndef LLVM_C_TYPES_H
14 #define LLVM_C_TYPES_H
15
16 #include "llvm/Support/DataTypes.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 /**
23 * @defgroup LLVMCSupportTypes Types and Enumerations
24 *
25 * @{
26 */
27
28 typedef int LLVMBool;
29
30 /* Opaque types. */
31
32 /**
33 * LLVM uses a polymorphic type hierarchy which C cannot represent, therefore
34 * parameters must be passed as base types. Despite the declared types, most
35 * of the functions provided operate only on branches of the type hierarchy.
36 * The declared parameter names are descriptive and specify which type is
37 * required. Additionally, each type hierarchy is documented along with the
38 * functions that operate upon it. For more detail, refer to LLVM's C++ code.
39 * If in doubt, refer to Core.cpp, which performs parameter downcasts in the
40 * form unwrap(Param).
41 */
42
43 /**
44 * Used to pass regions of memory through LLVM interfaces.
45 *
46 * @see llvm::MemoryBuffer
47 */
48 typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
49
50 /**
51 * The top-level container for all LLVM global data. See the LLVMContext class.
52 */
53 typedef struct LLVMOpaqueContext *LLVMContextRef;
54
55 /**
56 * The top-level container for all other LLVM Intermediate Representation (IR)
57 * objects.
58 *
59 * @see llvm::Module
60 */
61 typedef struct LLVMOpaqueModule *LLVMModuleRef;
62
63 /**
64 * Each value in the LLVM IR has a type, an LLVMTypeRef.
65 *
66 * @see llvm::Type
67 */
68 typedef struct LLVMOpaqueType *LLVMTypeRef;
69
70 /**
71 * Represents an individual value in LLVM IR.
72 *
73 * This models llvm::Value.
74 */
75 typedef struct LLVMOpaqueValue *LLVMValueRef;
76
77 /**
78 * Represents a basic block of instructions in LLVM IR.
79 *
80 * This models llvm::BasicBlock.
81 */
82 typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
83
84 /**
85 * Represents an LLVM basic block builder.
86 *
87 * This models llvm::IRBuilder.
88 */
89 typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
90
91 /**
92 * Interface used to provide a module to JIT or interpreter.
93 * This is now just a synonym for llvm::Module, but we have to keep using the
94 * different type to keep binary compatibility.
95 */
96 typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
97
98 /** @see llvm::PassManagerBase */
99 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
100
101 /** @see llvm::PassRegistry */
102 typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
103
104 /**
105 * Used to get the users and usees of a Value.
106 *
107 * @see llvm::Use */
108 typedef struct LLVMOpaqueUse *LLVMUseRef;
109
110 /**
111 * @see llvm::DiagnosticInfo
112 */
113 typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef;
114
115 /**
116 * @}
117 */
118
119 #ifdef __cplusplus
120 }
121 #endif
122
123 #endif
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm-c/BitReader.h"
10 #include "llvm-c/Core.h"
1011 #include "llvm/Bitcode/ReaderWriter.h"
1112 #include "llvm/IR/DiagnosticPrinter.h"
1213 #include "llvm/IR/LLVMContext.h"
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "llvm/Support/ErrorHandling.h"
15 #include "llvm-c/Core.h"
15 #include "llvm-c/ErrorHandling.h"
1616 #include "llvm/ADT/SmallVector.h"
1717 #include "llvm/ADT/Twine.h"
1818 #include "llvm/Config/config.h"
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "llvm/Support/PrettyStackTrace.h"
15 #include "llvm-c/Core.h"
15 #include "llvm-c/ErrorHandling.h"
1616 #include "llvm/ADT/SmallString.h"
1717 #include "llvm/Config/config.h" // Get autoconf configuration settings
1818 #include "llvm/Support/Compiler.h"
1212 \*===----------------------------------------------------------------------===*/
1313
1414 #include "llvm-c-test.h"
15 #include "llvm-c/Core.h"
1516 #include "llvm-c/Object.h"
1617 #include
1718 #include
88
99 #include "OrcTestCommon.h"
1010 #include "gtest/gtest.h"
11 #include "llvm-c/Core.h"
1112 #include "llvm-c/OrcBindings.h"
1213 #include "llvm-c/Target.h"
1314 #include "llvm-c/TargetMachine.h"
1414 #include "llvm/IR/LLVMContext.h"
1515 #include "llvm/IR/Module.h"
1616 #include "llvm/Support/SourceMgr.h"
17 #include "llvm-c/Core.h"
1718 #include "gtest/gtest.h"
1819
1920 namespace llvm {
1515 #include "llvm/IR/Module.h"
1616 #include "llvm/Linker/Linker.h"
1717 #include "llvm/Support/SourceMgr.h"
18 #include "llvm-c/Core.h"
1819 #include "llvm-c/Linker.h"
1920 #include "gtest/gtest.h"
2021