aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_utility.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-11-23 11:43:32 +0000
committergingerBill <bill@gingerbill.org>2021-11-23 11:43:32 +0000
commit9246e89c4a0bb35048253c1c5bf6ea86c146b289 (patch)
tree642ffb44bc68d0caad8117cd1f65a743465c6dc6 /src/llvm_backend_utility.cpp
parent2e89585c8cca77b7863686032643fc92eed6599d (diff)
Fix #1328
Diffstat (limited to 'src/llvm_backend_utility.cpp')
-rw-r--r--src/llvm_backend_utility.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp
index 46f7a22a3..0350f7287 100644
--- a/src/llvm_backend_utility.cpp
+++ b/src/llvm_backend_utility.cpp
@@ -179,32 +179,24 @@ lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t) {
GB_ASSERT_MSG(sz == dz, "Invalid transmute conversion: '%s' to '%s'", type_to_string(src_type), type_to_string(t));
// NOTE(bill): Casting between an integer and a pointer cannot be done through a bitcast
- if (is_type_uintptr(src) && is_type_pointer(dst)) {
+ if (is_type_uintptr(src) && is_type_internally_pointer_like(dst)) {
res.value = LLVMBuildIntToPtr(p->builder, value.value, lb_type(m, t), "");
return res;
}
- if (is_type_pointer(src) && is_type_uintptr(dst)) {
- res.value = LLVMBuildPtrToInt(p->builder, value.value, lb_type(m, t), "");
- return res;
- }
- if (is_type_uintptr(src) && is_type_proc(dst)) {
- res.value = LLVMBuildIntToPtr(p->builder, value.value, lb_type(m, t), "");
- return res;
- }
- if (is_type_proc(src) && is_type_uintptr(dst)) {
+ if (is_type_internally_pointer_like(src) && is_type_uintptr(dst)) {
res.value = LLVMBuildPtrToInt(p->builder, value.value, lb_type(m, t), "");
return res;
}
- if (is_type_integer(src) && (is_type_pointer(dst) || is_type_cstring(dst))) {
+ if (is_type_integer(src) && is_type_internally_pointer_like(dst)) {
res.value = LLVMBuildIntToPtr(p->builder, value.value, lb_type(m, t), "");
return res;
- } else if ((is_type_pointer(src) || is_type_cstring(src)) && is_type_integer(dst)) {
+ } else if (is_type_internally_pointer_like(src) && is_type_integer(dst)) {
res.value = LLVMBuildPtrToInt(p->builder, value.value, lb_type(m, t), "");
return res;
}
- if (is_type_pointer(src) && is_type_pointer(dst)) {
+ if (is_type_internally_pointer_like(src) && is_type_internally_pointer_like(dst)) {
res.value = LLVMBuildPointerCast(p->builder, value.value, lb_type(p->module, t), "");
return res;
}