fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
3.2 KiB124 linesraw
1#include "llvm-c/BitReader.h"
2#include "llvm-c/Core.h"
3#include "llvm-c/Object.h"
4#include "llvm/ADT/ArrayRef.h"
5#include "llvm/ADT/DenseSet.h"
6#include "llvm/ADT/SmallVector.h"
7#include "llvm/Analysis/Lint.h"
8#include "llvm/Analysis/Passes.h"
9#include "llvm/IR/IRBuilder.h"
10#include "llvm/IR/InlineAsm.h"
11#include "llvm/IR/LLVMContext.h"
12#include "llvm/IR/Module.h"
13#include "llvm/Support/CommandLine.h"
14#include "llvm/Support/Debug.h"
15#include "llvm/Support/DynamicLibrary.h"
16#include "llvm/Support/FormattedStream.h"
17#include "llvm/Support/JSON.h"
18#include "llvm/Support/Memory.h"
19#include "llvm/Support/SourceMgr.h"
20#include "llvm/Support/TargetSelect.h"
21#include "llvm/Support/Timer.h"
22#include "llvm/Support/raw_ostream.h"
23#include "llvm/Target/TargetMachine.h"
24#include "llvm/Target/TargetOptions.h"
25#include "llvm/Transforms/IPO.h"
26#include "llvm/Transforms/Instrumentation.h"
27#include "llvm/Transforms/Scalar.h"
28#include "llvm/Transforms/Vectorize.h"
29
30#define LLVM_VERSION_GE(major, minor)                                          \
31  (LLVM_VERSION_MAJOR > (major) ||                                             \
32   LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR >= (minor))
33
34#define LLVM_VERSION_LT(major, minor) (!LLVM_VERSION_GE((major), (minor)))
35
36#include "llvm/IR/LegacyPassManager.h"
37
38#include "llvm/Bitcode/BitcodeReader.h"
39#include "llvm/Bitcode/BitcodeWriter.h"
40
41#include "llvm/IR/DIBuilder.h"
42#include "llvm/IR/DebugInfo.h"
43#include "llvm/IR/IRPrintingPasses.h"
44#include "llvm/Linker/Linker.h"
45
46#if LLVM_VERSION_GE(16, 0)
47#include "llvm/TargetParser/Triple.h"
48#else
49#include "llvm/ADT/Triple.h"
50#endif
51
52extern "C" void LLVMRustSetLastError(const char *);
53
54enum class LLVMRustResult { Success, Failure };
55
56enum LLVMRustAttribute {
57  AlwaysInline = 0,
58  ByVal = 1,
59  Cold = 2,
60  InlineHint = 3,
61  MinSize = 4,
62  Naked = 5,
63  NoAlias = 6,
64  NoCapture = 7,
65  NoInline = 8,
66  NonNull = 9,
67  NoRedZone = 10,
68  NoReturn = 11,
69  NoUnwind = 12,
70  OptimizeForSize = 13,
71  ReadOnly = 14,
72  SExt = 15,
73  StructRet = 16,
74  UWTable = 17,
75  ZExt = 18,
76  InReg = 19,
77  SanitizeThread = 20,
78  SanitizeAddress = 21,
79  SanitizeMemory = 22,
80  NonLazyBind = 23,
81  OptimizeNone = 24,
82  ReturnsTwice = 25,
83  ReadNone = 26,
84  SanitizeHWAddress = 28,
85  WillReturn = 29,
86  StackProtectReq = 30,
87  StackProtectStrong = 31,
88  StackProtect = 32,
89  NoUndef = 33,
90  SanitizeMemTag = 34,
91  NoCfCheck = 35,
92  ShadowCallStack = 36,
93  AllocSize = 37,
94  AllocatedPointer = 38,
95  AllocAlign = 39,
96  SanitizeSafeStack = 40,
97};
98
99typedef struct OpaqueRustString *RustStringRef;
100typedef struct LLVMOpaqueTwine *LLVMTwineRef;
101typedef struct LLVMOpaqueSMDiagnostic *LLVMSMDiagnosticRef;
102
103extern "C" void LLVMRustStringWriteImpl(RustStringRef Str, const char *Ptr,
104                                        size_t Size);
105
106class RawRustStringOstream : public llvm::raw_ostream {
107  RustStringRef Str;
108  uint64_t Pos;
109
110  void write_impl(const char *Ptr, size_t Size) override {
111    LLVMRustStringWriteImpl(Str, Ptr, Size);
112    Pos += Size;
113  }
114
115  uint64_t current_pos() const override { return Pos; }
116
117public:
118  explicit RawRustStringOstream(RustStringRef Str) : Str(Str), Pos(0) {}
119
120  ~RawRustStringOstream() {
121    // LLVM requires this.
122    flush();
123  }
124};