1- #include < llvm/IR/DIBuilder .h>
1+ #include < llvm/Config/llvm-config .h>
22#include < llvm/IR/IRBuilder.h>
3- #include < llvm/IR/DebugLoc.h>
43#include < llvm/Target/TargetMachine.h>
54#include < llvm-c/TargetMachine.h>
65
@@ -9,50 +8,27 @@ using namespace llvm;
98#define LLVM_VERSION_GE (major, minor ) \
109 (LLVM_VERSION_MAJOR > (major) || LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR >= (minor))
1110
12- #define LLVM_VERSION_EQ (major, minor ) \
13- (LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR == (minor))
14-
15- #define LLVM_VERSION_LE (major, minor ) \
16- (LLVM_VERSION_MAJOR < (major) || LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR <= (minor))
11+ #if !LLVM_VERSION_GE(9, 0)
12+ #include < llvm/IR/DIBuilder.h>
13+ #endif
1714
1815#if LLVM_VERSION_GE(16, 0)
1916#define makeArrayRef ArrayRef
2017#endif
2118
22- typedef DIBuilder *DIBuilderRef;
23- #define DIArray DINodeArray
24- template <typename T> T *unwrapDIptr (LLVMMetadataRef v) {
25- return (T *)(v ? unwrap<MDNode>(v) : NULL );
26- }
27-
2819extern " C" {
2920
30- #if LLVM_VERSION_GE(9, 0)
31- #else
21+ #if !LLVM_VERSION_GE(9, 0)
3222LLVMMetadataRef LLVMExtDIBuilderCreateEnumerator (
3323 LLVMDIBuilderRef Dref, const char *Name, int64_t Value) {
3424 DIEnumerator *e = unwrap (Dref)->createEnumerator (Name, Value);
3525 return wrap (e);
3626}
37- #endif
3827
39- void LLVMExtSetCurrentDebugLocation (
40- LLVMBuilderRef Bref, unsigned Line, unsigned Col, LLVMMetadataRef Scope,
41- LLVMMetadataRef InlinedAt) {
42- #if LLVM_VERSION_GE(12, 0)
43- if (!Scope)
44- unwrap (Bref)->SetCurrentDebugLocation (DebugLoc ());
45- else
46- unwrap (Bref)->SetCurrentDebugLocation (
47- DILocation::get (unwrap<MDNode>(Scope)->getContext (), Line, Col,
48- unwrapDIptr<DILocalScope>(Scope),
49- unwrapDIptr<DILocation>(InlinedAt)));
50- #else
51- unwrap (Bref)->SetCurrentDebugLocation (
52- DebugLoc::get (Line, Col, Scope ? unwrap<MDNode>(Scope) : nullptr ,
53- InlinedAt ? unwrap<MDNode>(InlinedAt) : nullptr ));
54- #endif
28+ void LLVMExtClearCurrentDebugLocation (LLVMBuilderRef B) {
29+ unwrap (B)->SetCurrentDebugLocation (DebugLoc::get (0 , 0 , nullptr ));
5530}
31+ #endif
5632
5733OperandBundleDef *LLVMExtBuildOperandBundleDef (
5834 const char *Name, LLVMValueRef *Inputs, unsigned NumInputs) {
0 commit comments