mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Make lb_create_enum_attribute ignore certain attributes (they are not properly supported by the actual LLVM C API)
This commit is contained in:
+4
-11
@@ -443,9 +443,7 @@ namespace lbAbi386 {
|
|||||||
case 4: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 32), nullptr, nullptr);
|
case 4: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 32), nullptr, nullptr);
|
||||||
case 8: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 64), nullptr, nullptr);
|
case 8: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 64), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
LLVMAttributeRef attr = nullptr;
|
LLVMAttributeRef attr = lb_create_enum_attribute(c, "sret", true);
|
||||||
// TODO(bill): sret doesn't work correct for LLVM C API
|
|
||||||
// attr = lb_create_enum_attribute(c, "sret", true);
|
|
||||||
return lb_arg_type_indirect(return_type, attr);
|
return lb_arg_type_indirect(return_type, attr);
|
||||||
}
|
}
|
||||||
return non_struct(c, return_type, true);
|
return non_struct(c, return_type, true);
|
||||||
@@ -604,8 +602,7 @@ namespace lbAbiAmd64SysV {
|
|||||||
if (attribute_kind == Amd64TypeAttribute_ByVal) {
|
if (attribute_kind == Amd64TypeAttribute_ByVal) {
|
||||||
attribute = lb_create_enum_attribute(c, "byval", true);
|
attribute = lb_create_enum_attribute(c, "byval", true);
|
||||||
} else if (attribute_kind == Amd64TypeAttribute_StructRect) {
|
} else if (attribute_kind == Amd64TypeAttribute_StructRect) {
|
||||||
// TODO(bill): sret doesn't work correct for LLVM C API
|
attribute = lb_create_enum_attribute(c, "sret", true);
|
||||||
// attribute = lb_create_enum_attribute(c, "sret", true);
|
|
||||||
}
|
}
|
||||||
return lb_arg_type_indirect(type, attribute);
|
return lb_arg_type_indirect(type, attribute);
|
||||||
} else {
|
} else {
|
||||||
@@ -904,9 +901,7 @@ namespace lbAbiAmd64SysV {
|
|||||||
case 4: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 32), nullptr, nullptr);
|
case 4: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 32), nullptr, nullptr);
|
||||||
case 8: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 64), nullptr, nullptr);
|
case 8: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 64), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
LLVMAttributeRef attr = nullptr;
|
LLVMAttributeRef attr = lb_create_enum_attribute(c, "sret", true);
|
||||||
// TODO(bill): sret doesn't work correct for LLVM C API
|
|
||||||
// attr = lb_create_enum_attribute(c, "sret", true);
|
|
||||||
return lb_arg_type_indirect(return_type, attr);
|
return lb_arg_type_indirect(return_type, attr);
|
||||||
} else if (build_context.metrics.os == TargetOs_windows && lb_is_type_kind(return_type, LLVMIntegerTypeKind) && lb_sizeof(return_type) == 16) {
|
} else if (build_context.metrics.os == TargetOs_windows && lb_is_type_kind(return_type, LLVMIntegerTypeKind) && lb_sizeof(return_type) == 16) {
|
||||||
return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 128), nullptr, nullptr);
|
return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 128), nullptr, nullptr);
|
||||||
@@ -1055,9 +1050,7 @@ namespace lbAbiArm64 {
|
|||||||
}
|
}
|
||||||
return lb_arg_type_direct(type, cast_type, nullptr, nullptr);
|
return lb_arg_type_direct(type, cast_type, nullptr, nullptr);
|
||||||
} else {
|
} else {
|
||||||
LLVMAttributeRef attr = nullptr;
|
LLVMAttributeRef attr = lb_create_enum_attribute(c, "sret", true);
|
||||||
// TODO(bill): sret doesn't work correct for LLVM C API
|
|
||||||
// attr = lb_create_enum_attribute(c, "sret", true);
|
|
||||||
return lb_arg_type_indirect(type, attr);
|
return lb_arg_type_indirect(type, attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-1
@@ -1977,7 +1977,22 @@ lbValue lb_emit_string(lbProcedure *p, lbValue str_elem, lbValue str_len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value) {
|
LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value) {
|
||||||
unsigned kind = LLVMGetEnumAttributeKindForName(name, gb_strlen(name));
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned kind = LLVMGetEnumAttributeKindForName(name, s.len);
|
||||||
GB_ASSERT_MSG(kind != 0, "unknown attribute: %s", name);
|
GB_ASSERT_MSG(kind != 0, "unknown attribute: %s", name);
|
||||||
return LLVMCreateEnumAttribute(ctx, kind, value);
|
return LLVMCreateEnumAttribute(ctx, kind, value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user