Merge pull request #22808 from ziglang/fast-gpa
[zig.git] / src / zig_llvm.h
blobd2a85405e65a5627617f6c2619de52c742f5b521
1 /*
2 * Copyright (c) 2015 Andrew Kelley
4 * This file is part of zig, which is MIT licensed.
5 * See http://opensource.org/licenses/MIT
6 */
8 #ifndef ZIG_ZIG_LLVM_HPP
9 #define ZIG_ZIG_LLVM_HPP
11 #include <stdbool.h>
12 #include <stddef.h>
13 #include <llvm-c/Core.h>
14 #include <llvm-c/Analysis.h>
15 #include <llvm-c/Target.h>
16 #include <llvm-c/TargetMachine.h>
18 #ifdef __cplusplus
19 #define ZIG_EXTERN_C extern "C"
20 #else
21 #define ZIG_EXTERN_C
22 #endif
24 // ATTENTION: If you modify this file, be sure to update the corresponding
25 // extern function declarations in the self-hosted compiler.
27 // synchronize with llvm/include/Transforms/Instrumentation.h::SanitizerCoverageOptions::Type
28 // synchronize with codegen/llvm/bindings.zig::TargetMachine::EmitOptions::Coverage::Type
29 enum ZigLLVMCoverageType {
30 ZigLLVMCoverageType_None = 0,
31 ZigLLVMCoverageType_Function,
32 ZigLLVMCoverageType_BB,
33 ZigLLVMCoverageType_Edge
36 struct ZigLLVMCoverageOptions {
37 ZigLLVMCoverageType CoverageType;
38 bool IndirectCalls;
39 bool TraceBB;
40 bool TraceCmp;
41 bool TraceDiv;
42 bool TraceGep;
43 bool Use8bitCounters;
44 bool TracePC;
45 bool TracePCGuard;
46 bool Inline8bitCounters;
47 bool InlineBoolFlag;
48 bool PCTable;
49 bool NoPrune;
50 bool StackDepth;
51 bool TraceLoads;
52 bool TraceStores;
53 bool CollectControlFlow;
56 struct ZigLLVMEmitOptions {
57 bool is_debug;
58 bool is_small;
59 bool time_report;
60 bool tsan;
61 bool sancov;
62 bool lto;
63 bool allow_fast_isel;
64 const char *asm_filename;
65 const char *bin_filename;
66 const char *llvm_ir_filename;
67 const char *bitcode_filename;
68 ZigLLVMCoverageOptions coverage;
71 // synchronize with llvm/include/Object/Archive.h::Object::Archive::Kind
72 // synchronize with codegen/llvm/bindings.zig::ArchiveKind
73 enum ZigLLVMArchiveKind {
74 ZigLLVMArchiveKind_GNU,
75 ZigLLVMArchiveKind_GNU64,
76 ZigLLVMArchiveKind_BSD,
77 ZigLLVMArchiveKind_DARWIN,
78 ZigLLVMArchiveKind_DARWIN64,
79 ZigLLVMArchiveKind_COFF,
80 ZigLLVMArchiveKind_AIXBIG,
83 // synchronize with llvm/include/Target/TargetOptions.h::FloatABI::ABIType
84 // synchronize with codegen/llvm/bindings.zig::TargetMachine::FloatABI
85 enum ZigLLVMFloatABI {
86 ZigLLVMFloatABI_Default, // Target-specific (either soft or hard depending on triple, etc).
87 ZigLLVMFloatABI_Soft, // Soft float.
88 ZigLLVMFloatABI_Hard // Hard float.
91 ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref,
92 char **error_message, const ZigLLVMEmitOptions *options);
94 ZIG_EXTERN_C LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple,
95 const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,
96 LLVMCodeModel CodeModel, bool function_sections, bool data_sections, ZigLLVMFloatABI float_abi,
97 const char *abi_name);
99 ZIG_EXTERN_C void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit);
101 ZIG_EXTERN_C void ZigLLVMEnableBrokenDebugInfoCheck(LLVMContextRef context_ref);
102 ZIG_EXTERN_C bool ZigLLVMGetBrokenDebugInfo(LLVMContextRef context_ref);
104 ZIG_EXTERN_C void ZigLLVMParseCommandLineOptions(size_t argc, const char *const *argv);
106 ZIG_EXTERN_C bool ZigLLDLinkCOFF(int argc, const char **argv, bool can_exit_early, bool disable_output);
107 ZIG_EXTERN_C bool ZigLLDLinkELF(int argc, const char **argv, bool can_exit_early, bool disable_output);
108 ZIG_EXTERN_C bool ZigLLDLinkWasm(int argc, const char **argv, bool can_exit_early, bool disable_output);
110 ZIG_EXTERN_C bool ZigLLVMWriteArchive(const char *archive_name, const char **file_names, size_t file_name_count,
111 ZigLLVMArchiveKind archive_kind);
113 ZIG_EXTERN_C bool ZigLLVMWriteImportLibrary(const char *def_path, unsigned int coff_machine,
114 const char *output_lib_path, bool kill_at);
116 #endif