]> git.proxmox.com Git - rustc.git/blame - src/rustllvm/rustllvm.h
New upstream version 1.13.0+dfsg1
[rustc.git] / src / rustllvm / rustllvm.h
CommitLineData
970d7e83
LB
1// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
1a4d82fc 11#include "llvm/IR/IRBuilder.h"
970d7e83
LB
12#include "llvm/IR/InlineAsm.h"
13#include "llvm/IR/LLVMContext.h"
1a4d82fc 14#include "llvm/IR/Module.h"
970d7e83
LB
15#include "llvm/IR/InlineAsm.h"
16#include "llvm/IR/LLVMContext.h"
970d7e83
LB
17#include "llvm/Analysis/Passes.h"
18#include "llvm/Analysis/Lint.h"
1a4d82fc 19#include "llvm/ADT/ArrayRef.h"
970d7e83
LB
20#include "llvm/ADT/Triple.h"
21#include "llvm/ADT/DenseSet.h"
970d7e83
LB
22#include "llvm/Support/CommandLine.h"
23#include "llvm/Support/FormattedStream.h"
24#include "llvm/Support/Timer.h"
25#include "llvm/Support/raw_ostream.h"
26#include "llvm/Support/TargetSelect.h"
27#include "llvm/Support/TargetRegistry.h"
28#include "llvm/Support/SourceMgr.h"
29#include "llvm/Support/Host.h"
30#include "llvm/Support/Debug.h"
31#include "llvm/Support/DynamicLibrary.h"
32#include "llvm/Support/Memory.h"
33#include "llvm/ExecutionEngine/ExecutionEngine.h"
970d7e83
LB
34#include "llvm/ExecutionEngine/MCJIT.h"
35#include "llvm/ExecutionEngine/Interpreter.h"
36#include "llvm/Target/TargetMachine.h"
37#include "llvm/Target/TargetOptions.h"
38#include "llvm/Transforms/Scalar.h"
39#include "llvm/Transforms/IPO.h"
40#include "llvm/Transforms/Instrumentation.h"
41#include "llvm/Transforms/Vectorize.h"
1a4d82fc 42#include "llvm/Bitcode/ReaderWriter.h"
970d7e83
LB
43#include "llvm-c/Core.h"
44#include "llvm-c/BitReader.h"
45#include "llvm-c/ExecutionEngine.h"
46#include "llvm-c/Object.h"
47
9e0c209e
SL
48#define LLVM_VERSION_GE(major, minor) \
49 (LLVM_VERSION_MAJOR > (major) || LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR >= (minor))
50
51#define LLVM_VERSION_EQ(major, minor) \
52 (LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR == (minor))
53
54#define LLVM_VERSION_LE(major, minor) \
55 (LLVM_VERSION_MAJOR < (major) || LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR <= (minor))
56
57#if LLVM_VERSION_GE(3, 7)
62682a34
SL
58#include "llvm/IR/LegacyPassManager.h"
59#else
60#include "llvm/PassManager.h"
61#endif
62
1a4d82fc
JJ
63#include "llvm/IR/IRPrintingPasses.h"
64#include "llvm/IR/DebugInfo.h"
65#include "llvm/IR/DIBuilder.h"
66#include "llvm/Linker/Linker.h"
1a4d82fc 67
1a4d82fc
JJ
68void LLVMRustSetLastError(const char*);
69
5bcae85e
SL
70enum class LLVMRustResult {
71 Success,
72 Failure
73};
74
1a4d82fc
JJ
75typedef struct OpaqueRustString *RustStringRef;
76typedef struct LLVMOpaqueTwine *LLVMTwineRef;
77typedef struct LLVMOpaqueDebugLoc *LLVMDebugLocRef;
78typedef struct LLVMOpaqueSMDiagnostic *LLVMSMDiagnosticRef;
79typedef struct LLVMOpaqueRustJITMemoryManager *LLVMRustJITMemoryManagerRef;
80
81extern "C" void
82rust_llvm_string_write_impl(RustStringRef str, const char *ptr, size_t size);
83
84class raw_rust_string_ostream : public llvm::raw_ostream {
85 RustStringRef str;
86 uint64_t pos;
87
88 void write_impl(const char *ptr, size_t size) override {
89 rust_llvm_string_write_impl(str, ptr, size);
90 pos += size;
91 }
92
93 uint64_t current_pos() const override {
94 return pos;
95 }
96
97public:
98 explicit raw_rust_string_ostream(RustStringRef str)
99 : str(str), pos(0) { }
100
101 ~raw_rust_string_ostream() {
102 // LLVM requires this.
103 flush();
104 }
105};