aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_abi.cpp
diff options
context:
space:
mode:
authorMichael Lee <leecommamichael@gmail.com>2025-12-23 16:12:53 -0600
committerGitHub <noreply@github.com>2025-12-23 16:12:53 -0600
commit550e57aba977ff766e5ab38a4c13a8dc18d55992 (patch)
tree6704ea53d838f7d7427e5bf6faa1d586378869b3 /src/llvm_abi.cpp
parent729d0a8e8ace759d5d1358b14b20e19f68f44ff0 (diff)
parent57352d9933785097e21c282807f5e845ec8f6d85 (diff)
Merge branch 'odin-lang:master' into core-image-tga
Diffstat (limited to 'src/llvm_abi.cpp')
-rw-r--r--src/llvm_abi.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp
index 8dbb8fa76..ec7c63b1a 100644
--- a/src/llvm_abi.cpp
+++ b/src/llvm_abi.cpp
@@ -144,7 +144,11 @@ gb_internal void lb_add_function_type_attributes(LLVMValueRef fn, lbFunctionType
LLVMContextRef c = ft->ctx;
LLVMAttributeRef noalias_attr = lb_create_enum_attribute(c, "noalias");
LLVMAttributeRef nonnull_attr = lb_create_enum_attribute(c, "nonnull");
+#if LLVM_VERSION_MAJOR >= 21
+ LLVMAttributeRef nocapture_attr = lb_create_string_attribute(c, make_string_c("captures"), make_string_c("none"));
+#else
LLVMAttributeRef nocapture_attr = lb_create_enum_attribute(c, "nocapture");
+#endif
unsigned arg_index = offset;
for (unsigned i = 0; i < arg_count; i++) {
@@ -522,6 +526,23 @@ namespace lbAbiAmd64Win64 {
}
};
+
+gb_internal bool is_llvm_type_slice_like(LLVMTypeRef type) {
+ if (!lb_is_type_kind(type, LLVMStructTypeKind)) {
+ return false;
+ }
+ if (LLVMCountStructElementTypes(type) != 2) {
+ return false;
+ }
+ LLVMTypeRef fields[2] = {};
+ LLVMGetStructElementTypes(type, fields);
+ if (!lb_is_type_kind(fields[0], LLVMPointerTypeKind)) {
+ return false;
+ }
+ return lb_is_type_kind(fields[1], LLVMIntegerTypeKind) && lb_sizeof(fields[1]) == 8;
+
+}
+
// NOTE(bill): I hate `namespace` in C++ but this is just because I don't want to prefix everything
namespace lbAbiAmd64SysV {
enum RegClass {
@@ -652,23 +673,6 @@ namespace lbAbiAmd64SysV {
return false;
}
- gb_internal bool is_llvm_type_slice_like(LLVMTypeRef type) {
- if (!lb_is_type_kind(type, LLVMStructTypeKind)) {
- return false;
- }
- if (LLVMCountStructElementTypes(type) != 2) {
- return false;
- }
- LLVMTypeRef fields[2] = {};
- LLVMGetStructElementTypes(type, fields);
- if (!lb_is_type_kind(fields[0], LLVMPointerTypeKind)) {
- return false;
- }
- return lb_is_type_kind(fields[1], LLVMIntegerTypeKind) && lb_sizeof(fields[1]) == 8;
-
- }
-
-
gb_internal bool is_aggregate(LLVMTypeRef type) {
LLVMTypeKind kind = LLVMGetTypeKind(type);
switch (kind) {