diff options
| author | gingerBill <bill@gingerbill.org> | 2021-09-11 16:53:18 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-09-11 16:53:18 +0100 |
| commit | e3359a2639fdcba83d9ba7b43fefeaf1915f8f26 (patch) | |
| tree | ba8c2f022f0d2b6da4467ab82238e055c4652c5c /src/llvm_backend_general.cpp | |
| parent | 344abf2cb2e9c1b27d6e786618aed633f72b89af (diff) | |
Prepare for LLVM 12.0.1 compatibility
Diffstat (limited to 'src/llvm_backend_general.cpp')
| -rw-r--r-- | src/llvm_backend_general.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 1bf3bab7c..113c9ba62 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -1968,24 +1968,32 @@ void lb_add_procedure_value(lbModule *m, lbProcedure *p) { LLVMAttributeRef lb_create_enum_attribute_with_type(LLVMContextRef ctx, char const *name, LLVMTypeRef type) { + unsigned kind = 0; String s = make_string_c(name); - // NOTE(2021-02-25, bill); All this attributes require a type associated with them - // and the current LLVM C API does not expose this functionality yet. - // It is better to ignore the attributes for the time being - if (s == "byval") { - // return nullptr; - } else if (s == "byref") { - return nullptr; - } else if (s == "preallocated") { - return nullptr; - } else if (s == "sret") { - // return nullptr; - } + #if (LLVM_VERSION_MAJOR > 12 || (LLVM_VERSION_MAJOR == 12 && (LLVM_VERSION_MINOR > 0 || LLVM_VERSION_PATCH >= 1))) + kind = LLVMGetEnumAttributeKindForName(name, s.len); + GB_ASSERT_MSG(kind != 0, "unknown attribute: %s", name); + return LLVMCreateTypeAttribute(ctx, kind, type); + #else + // NOTE(2021-02-25, bill); All this attributes require a type associated with them + // and the current LLVM C API does not expose this functionality yet. + // It is better to ignore the attributes for the time being + if (s == "byval") { + // return nullptr; + } else if (s == "byref") { + return nullptr; + } else if (s == "preallocated") { + return nullptr; + } else if (s == "sret") { + // return nullptr; + } + - unsigned kind = LLVMGetEnumAttributeKindForName(name, s.len); - GB_ASSERT_MSG(kind != 0, "unknown attribute: %s", name); - return LLVMCreateEnumAttribute(ctx, kind, 0); + kind = LLVMGetEnumAttributeKindForName(name, s.len); + GB_ASSERT_MSG(kind != 0, "unknown attribute: %s", name); + return LLVMCreateEnumAttribute(ctx, kind, 0); + #endif } LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value) { |